Mini browser in less than 100 lines
Mini browser in less than 100 lines
In this example we'll use Glade# to construct the GUI of the application, and then use Gecko# to add the actual browser component.
| Notice To make Gecko# application run and detect Mozilla's libraries, you have to make sure that MOZILLA_FIVE_HOME directory is in the LD_LIBARY_PATH |
First step - Create GUI in Glade
The design of the GUI is entirely up to you, all you need is a few buttons for basic actions, like Back,Forward,Refresh and etc, and a placeholder for Mozilla's Webcontrol.
For each button prepare a Clicked signals, and write down their names. We'll write handlers for them later on.
You can find my Glade generated at the end of the article.
Second step - Write the code
Basic idea of constructing Glade application is as follows:
- create a class
- on it's constructor:
- call Application.Init()
- loads the GUI xml, and connects it's signals to handlers in the code
- add any additional controls if needed
- call Application.Run()
So, here's the code:
And here's the Glade-generated GUI file:
Step three: Running
Since, we've specified the list of assemblies that need to be referenced in the import section, all the is left now is to run the application:
mono booi.exe browser.boo
Or even compile it into executable, and then run it:
mono booc.exe browser.boo mono browser.exe
That's it! Have fun boo-ing!
Eli Yukelzon
