Demo-2  <<--BACK            HOME            UP --^           NEXT-->>  Demo-4
side4linux, a simple integrated development environment!

GNOMEC Demo-3  Adding an 'About Box' using Glade-3 and how to change the Version number of your Project.

Purpose:  To provide a basic introduction to adding an 'About Box' to a new Project. We will not be creating a new Product for this so we will place the new Project into the existing Product 'MC-1`' Note this Demo is intended to be built using Glade-3 and not Glade-2 which is now deprecated.

Requirements:

Exercise-1: Create the basic program and add the 'About Box'.
  1. Open 'side4linux' and click on 'Project>New Project' in the Main Menue.
  2. Select 'GNOME 'C' GUI Program' as in figure-1 below and click on 'NEXT' in the Dialog Box.
  3. Select the 'PRODUCTS' Product Area in the Product Selection Dialog and click on 'OK' as in figure-2,
  4. Select 'MC-1' from the Product Area selection Combo Box as in figure-3 and click on the 'Next' button,
  5. In the New Project dialog enter the name of 'About' as in figure-4 and click on 'Build'.
  6. Once the Project is Built, close then re-open it to let things settle into place.
  7. 'Project>Close Project'
  8. 'Project>Open Project'
  9. Double click on the 'PRODUCTS' Product Area,
  10. Double click on the 'MC1' Product,
  11. In the file dialog double click the  'GNOMEC' folder, this takes you to where 'GNOME' visual 'C' language projects are kept.
  12. Double click on 'About', this opens the 'About' project folder.
  13. Double click on 'about.prf', this opens the 'About' project file.
  14. Now open the Glade-3 GUI builder program, 'Edit Project>Edit Project Visuals with Glade-3'
  15. ( un-dock the windows and shrink the Main window to about one third screen size )
  16. Double click on the 'mainWindow' widget in the 'Inspector' window to make it appear in the 'Main' window ( figure-5 ).
  17. Notice that the top of the Glade Main window says that we are editing 'about.glade'.
  18. Notice the 'Palette' window from where we 'pick' our visual widgets from ( figure-6 ).
  19. Notice in the 'Properties' window that the 'Name' of the main window widget is set to 'mainWindow' ( figure-7 ),
  20. Now let us add our 'About Box', click on 'Toplevels' in the 'Palette' window and then click on 'About Dialog' ( third from top left )
  21. This should enter the 'aboutdialog1' into our 'Project Box' below the 'Main Window' entry ( figure-8 ),
  22. Click on 'Save' in the Glade Main window to save the 'glade' GUI XML file ( about.glade ).
  23. Now close the Glade-3 GUI Builder program.
  24. Close the newly created project 'Project>Close Project'.
  25. Note that it will be stored in the 'GNOMEC' section of the 'MC-1' Product.
 

Fig-1

Fig-2

Fig-3

Fig-4

Fig-5

Fig-6


Fig-7


Fig-8

Exercise-2: Re-open the new project and connect the 'About Box'.
  1. Open the newly created 'About' project 'Project>Open Project'  in the IDE.
  2. Note that it will be stored in the 'GNOMEC' section of the 'MC-1' Product.
  3. Let us now add the callback to show the 'About Box',
  4. We will 'run' the Program 'about' in a terminal.
  5. Change workspaces and open a terminal program in the ' ~~ /SIDE/PRODUCTS/MC1/GNOMEC/About/src '  directory,
  6. and run the program ( ./about ) notice the full stop and forward slash to run a program in the current directory to get the following messages ( or similar ),
db@wks1:~/Data/Projects/SIDE/PRODUCTS/MC1/GNOMEC/About/src$ ./about
Trying local 'glade' file
Local 'glade' file found!

(about:8804): libglade-WARNING **: could not find signal handler 'on_save1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_preferences1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_quit1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_cut1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_about1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_open1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_paste1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_clear1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_new1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_save_as1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_properties1_activate'.
(about:8804): libglade-WARNING **: could not find signal handler 'on_copy1_activate'.

Notice that these are all 'callback signals' that the IDE has set up for you when it built your new project 'About'.
We will note that there needs to be 'signal handler functions' created ( often referred to as 'callback functions' ) to match the callback signals.

You will create two callback handler functions, one to 'show' the About Box and one to 'close'
the About Box.
Note you should follow the norm of placing the prototypes into your 'callbacks.h' file as follows,

void on_about1_activate();
void aboutdialog1_response_cb();

followed by the actual functions into 'callbacks.c' as follows,

GtkWidget *aboutPtr=NULL;

void on_about1_activate()
{
  char versionString[256];

  sprintf(versionString," %s",VERSION);
  g_print("fetching About Box\n");
  if(aboutPtr == NULL)
     aboutPtr = GTK_WIDGET(glade_xml_get_widget(gladeXML,"aboutdialog1"));
  gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(aboutPtr),versionString);

  gtk_widget_show(aboutPtr);
}
void aboutdialog1_response_cb()
{
  gtk_widget_hide(aboutPtr);
  g_print("About box close button pressed\n");
}

Open the files in the Notebook of the IDE  ( click on 'Open-Txt' Toolbar button ) and cut/paste from above.
Make sure there is at least one blank line below your code so that your 'C' compiler does not complain!
Then click on 'Build'.

Now change to another workspace and in a terminal run the file as above,
you should see your visual Program ( figure-9 ) and the warning messages should no longer refer to
'on_about1_activate'.


Fig-9

Fig-10


Exercise-3: Connect up the remaining callbacks ( 'Close About Box' and 'File>Quit' ).
  1. Open the newly created 'About' project 'Project>Open Project'.
  2. Note that it will be stored in the 'GNOMEC' section of the 'MC-1' Product.
  3. Open the Glade-3 GUI Builder program, 'Edit Project>Edit Project Visuals with Glade-3'
  4. Let us now add the callback to 'Close' the 'About Box',
  5. We have already put a callback handler function into callbacks.c so we must set up the 'glade' XML file to include a callback signal with the same name as the handler function.
  6. In Glade-3, in the 'Inspector' window click on the 'aboutdialog1' widget and look at the 'Properties' window, click on the 'Signals' tab,
  7. and add the signal by clicking on 'response <type here>' and selecting 'aboutdialog1_response_cb' ( figure-11  ).
  8. Note: The 'response' signal in this widget is connected to the 'Close' button in the About Box.
  9. Now double click on the 'mainWindow' widget so that we can connect the 'File>Quit' signal.
  10. Double clicking should make the 'mainWindow' active in the Glade-3 Main Window so click on  'mainWindow' widget 'File' then 'File>Quit'.
  11. Look at the 'Properties' window for 'Quit1' in the 'General' tab, click on the 'Signals' tab and notice the signal 'activate <on_quit1_activate>'.
  12. As we already have a quit function in callbacks.c ( void gtkQuit(void); ) we need to add just an 'on_quit1_activate()' function that calls it as follows,
add to callbacks.c

void on_quit1_activate()
{
 
gtkQuit();
}

also add to callbacks.h

void on_quit1_activate();

Click on 'Save' in the Glade-3 Main window to save the modified about.glade XML file.
Click on the 'Build' toolbar button in the IDE to re-build the 'About' Project.
Now change to another workspace and in a terminal re-run the 'about' file as above,

Fig-11

Fig-12

Fig-13

Fig-14

Fig-15

 
To end the Practical we cannot have Users clicking the 'X' in the top right corner of the About Box widget ( figure-10 ) as it will destroy it such that it will not show later. So in the Glade-3 program click on the 'aboutdialog1' widget entry in the 'Inspector' window and in the 'Properties' window, in the 'General' tag, change the 'Deletable' property of the widget to 'No' ( figure-12 ),
Also erase the 'Program name' property which currently says 'Glade' so that the line is empty of all characters and spaces.

Now try running the program again after you have clicked on 'Save' in Glade-3 and clicked on the 'Build' button, to see if the little cross has gone away! ( figure-13 )

Finally we can alter the Project Version String to show that we have updated the Project, 'Project>Edit Project>Edit Project Properties'.
Set the Project to Version '0.0.2' in the Dialog Box and click on 'Apply' ( figure-14 ).

Now try running the program again after you have clicked on the 'Build' button. ( figure-15 )


Summary: Creating a new Visual Project using side4linux and Glade-3
Note: Should you not succeed with this Demo then look in SIDE/DEMOS/SIDEdemos/GNOMEC/About for a working copy of the 'About' project.

We will provide other demos as 'side4linux' develops to cover GNOME visual programming and integration into a real world machine controller.

GUI interface made with Gtk and Glade GUI demo built with Glade