Skip to end of metadata
Go to start of metadata

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

Icon

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:

  1. create a class
  2. on it's constructor:
    1. call Application.Init()
    2. loads the GUI xml, and connects it's signals to handlers in the code
    3. add any additional controls if needed
    4. call Application.Run()

So, here's the code:

browser.boo

And here's the Glade-generated GUI file:

gui.glade

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

  • No labels