How to build a Glade# application that uses glade-2 with Visual Studio.Net 2003

By Francisco "Paco" Martínez

Purpose:

- This small tutorial will explain how to create a simple Glade# application that uses Glade-2 to create the user interface and Visual Studio.Net 2003 to write and build code.

 

Environment used:

- Windows XP 

- Visual Studio.Net 2003

- GTK# Win32 Installer for Microsoft .NET Framework 1.1 SDK

 

Setting up:

- Before starting this excersice install and configure Visual Studio .NET 2003 as well as the GTK# Win32 Installer for Microsoft .NET Framework 1.1 SDK (http://forge.novell.com/modules/xfmod/project/?gtks-inst4win)

 

Creating the project form a project template:

- Open Visual Studio .NET 2003 and from the main menu select: File/New/Project...

 

Initial Menu selection

figure1

- The New Project dialog box will will apear. Select the Glade# Project from the list of available C# projects. Pick the destiantion directory and project name that best suit your needs and press the OK button (figure2)

 

New Project dialog box

figure2

- A C# project and a Microsoft Visual Studio Solution file will be created in the directory you have chosen along with two C# code files (*.cs) and one Glade UI description file (*.glade).  The file Driver.cs will be open on the editor pane as seen in figure 3.  At this point, you should select the solution explorer view within the IDE so you can review what has happened.

 

New Project dialog box

figure3

Project details:

- Before we build our project, we need to be aware of some special settings that distinguish our project from a .NET System.Windows.Forms project.

- Inspect the project property pages. This can be acomplished by selecting the last option from the Project menu, "<project name> Properties..."  You may also right click on the project icon in the solution explorer to display the context menu and select properties. Either method should present the Project Property Pages dialog box. See figure4 below.  Pay particular attention to the fact that the Default Namespace property's value is blank or not set.  This is by design and simplifes the access to "Embedded Resources".

 

figure4

- Notice how UI description file gladesharp1.glade has its Build action property set to "Embedded Resource".  See figure5 below.

 

properties for embedded resource

figure5

- Right click over the Gtk# library modules that are listed as references to your project. This will bring up the context menu at which time you should select "properties...".  Figure 6 shows gtk-sharp module's settings for this project.  Change the "Copy Local" property's value to "True".  Once done repeat for all other Gtk# library modules in the reference list.

 

properties for gtk-sharp module

figure6

Run and debug:

- Now you may build and run your program.  In figure7 we show the application running in debug mode.  Notice the watch that was place on this.window1 as it displays a list of its runtime contents!

 

The final product

figure7

Credits:

- Thanks to Maurício de Lemos Rodrigues Collares Neto and Carlos Alberto Cesario for their enthusiasm and contributions to this document.