Getting started with winGTK and wGLADE

By Barry Drake

To setup and use wGlade with winGTK:

SET PATH = %PATH%;C:\winGTK

Note that the procedure for using Glade is the same if you have chosen GTK4Win or Dev-C++ with DevEx.  The remainder of the procedure with GTK4Win is explained in the included documentaion, and if you choose Dev-C++ you simply make use of the GTK+ template, and add your C source files to the project you have created!

 

Creating & running a project:

Window image For this exercise, add a 'Fixed Container' from the Palette window onto your window. This is the one on the eighth row down in the right hand column.  It has a popup hint that says "Fixed Positions". Then add two buttons to this container. Choose the button labelled OK. The buttons can be re-positioned and resized - why not make them fairly large. Your project will now have two buttons labelled 'Button 1' and 'Button 2'.

Properties Click on Button 1. If you look at the 'Properties' window, you will see that it now refers to Button 1.  Change the Button Text field to read 'Exit'.  Now click on the 'Signals' tab in the properties window.  You will see that this is empty.  Use the dropdown to select 'Clicked' as the signal, and use the dropdown under 'Handler' to select gtk_main_quit.  Click on the 'Add' button.  Now repeat the process for button 2, calling the button 'Click-Me'. Set the signal to 'Clicked' once more, but this time leave the signal handler set to the default that is offered.  
This will read 'on_button2_clicked'.

Now click the Window icon in the Glade main window.  This is the object labelled 'window1'.  The properties window should now bear the heading 'window1'.  Change the Title to: 'My First Program'.  This is going to be your Window title for the compiled executable.  Now set up the signal for your main window.  You need to set the signal to 'destroy' and the handler to gtk_main_quit.  This will ensure that the program is closed if the main window is closed using the 'X' at the top right.
Congratulations! You have now not only created an interface which will build the frontend for your first project, but you have also a created a compilable, working program!

Note that the procedure so far for using Glade is the same if you have chosen GTK4Win or Dev-C++ with DevEx.  The remainder of the procedure with GTK4Win is explained in the GTK4Win included documentaion, and if you choose Dev-C++ you simply make use of the GTK+ tamplate, and add your C source files to the project you have created!  The next few paragraps of the procedure is concerned with the use of winGTK so if you are using Dev-C++ you can skip down to the paragrap headed "Editing the code".

cd C:\Projects\First {Press Enter}
copy C:\winGTK\makefile {Press Enter}
edit makefile {Press Enter}

Editing your code
MessageBox (0, "Hello World\nfrom My First Program!\n", "My First MessageBox", MB_ICONINFORMATION);
All the examples in these exercises are available in one file ( Projects.zip ) which you can download.

Home | Getting Started | Tutorials | Download | Applications | Mailing List torrent suche | torrent search |