Dynamic user interface using glade and gtk  is rapid development method. Glade is graphical user interface designer tool. One can design GUI by simply drag and drop utility. It helps rapid application development for gtk based application. Without glade gtk developers need to build gui using gtk+ widgets. Today we will learn how to make gui using Galde and use glade files in gtk+ program. Open Glade

 openglade
The glade tool will be opened like..

glade

Building glade GUI

Any GUI requires an window and some interactive widgets through which user interact with. widgets like button, entry, textarea etc are interactive gtk widgets. Making a good interface requires a layout. glade and gtk provides box layout widget to split the main window area. After creating layouts inside the main window area , we can place the requires widgets inside the layout area. Here is simple video tutorial which creates a simple gui with some buttons and using the glade files in gtk+ program.

How to compile glade and gtk+ program

  • Create a c file ( main.c )

  • Save your glade file from glade tool as mainui.glade ( you can give any name ) , but the same name should be in  builder =    gtk_builder_new();
    gtk_builder_add_from_file (builder, “mainui.glade”, NULL);
  • compile using  following command

Let us learn some more

During ui creation we have add signals and callbacks in glade files. Like with ok button we have declare a callback on_button_ok_clicked  function with “click” signal and with cancel button we have declare on_button_cancel_clicked function with “click” signal. when a user click on ok button gtk will emit “click” signal and on_button_ok_clicked function will be called. We can modify gui or write require code inside the on_button_ok_clicked function. Let us say hello word inside the on_button_ok_clicked. Here is modified code. without defining on_button_ok_clicked and on_button_cancel_clicked we will get warnings like below.

sigandcallback

 Below code defines two signal handers

Note: compile the above program using