I am new to GTK+ programming and Linux programming in general, I am trying to understand how I can develop a small and simple application using C and GTK+.
First of all I installed on my ubuntu 7.04 the Glade(1) version and I saw that from the application was possible to design the GUI layout and push the button generate Code. From my understading I saw that was quite good , because I got generated the files main.c , interface.c and callbacks.c . Editing the callbacks I was able to put the code behind the buttons and entries created with the glade interface. After using the make Command I found in the SRC directory of the glade project the executable to startup My program. This method was quite good , except that I had to build the code manually , because If I edit the main.c , callbacks.c etc.. with an IDE I could not get success in building the application and I had to type the command manually in shell, the same happened if I try to run the application created directly form the IDE.
I have then searched around on the web to get more details on this programming techniques , and I found that glade1 with its automated code generator has been deprecated, now it is Recommended to use anjuta IDE in combination with Glade3. With anjuta you write the code and with glade3 only the GUI.
I read some HOWto, and if I understood well I saw that the best way to develop applications with those software is to generate a libglade 2.0 project in anjuta , then edit the file project.glade created automatically by the anjuta IDE using the glade3 program and modify the GUI design.
I did some test using this process, but I saw the files structure is changed, I ma not sure if I understood well, but in this case if I use glade3 to setup the signals and I use the auto connect features , I just need to put in the main.c file of anjuta the function that is called by the callback. I did some test and I saw it works. The alternative is to just design the GUI and then write the callback and function inside the main.c f, however the callbacks.c and the other files which were generated by glade1 are not anymore available. Using this last combination of software I was able to write the function for a simple program that prints a message on the shell as soon as a button is pressed. This code is from the main.c of anjuta libglade 2.0 project.
void on_BT_OK_clicked (GtkWidget *Widget, gpointer user_data)
int main (int argc, char *argv)
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
gnome_init (PACKAGE, VERSION, argc, argv);
xml = glade_xml_new (PACKAGE_SOURCE_DIR"/esercizio_autoconnect.glade", NULL, NULL);
window1 = glade_xml_get_widget (xml, "window1");
The way of using glade3 and anjuta with the signals set in glad3 looks nice , but I do not understand where the code that was in callbacks and interface is now located. Following this method , I also tried to develop a small program which gets the data written in an entry filed and after processing it , returns the output in another entry. I followand old tutorial.
However this was written using the glade1 with the autocode generator and the function associated to the button_clicked has inside the lookup_widget
If I use glade1 then I can get this example working, if I use the method3 trying to put it in the main.c , when I build with anjuta I get an error saying that lookup_widget is undeclared.
on_ok_button_clicked (GtkButton *button, gpointer user_data)
GtkWidget *entry = lookup_widget(GTK_WIDGET(button), "entry1");
GtkWidget *info_entry = lookup_widget (GTK_WIDGET(button), "info_entry");
GtkWidget *rad_currency = lookup_widget(GTK_WIDGET(button), "rad_currency");
GtkWidget *rad_capital = lookup_widget(GTK_WIDGET(button), "rad_capital");
GtkWidget *info_label = lookup_widget(GTK_WIDGET(button), "info_label");
gchar *entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
gchar *countries, *capitals, *currencies;
GtkWidget *dialog, *dg_label, *dg_OK;
countries  = "India"; countries  = "France";
capitals  = "Delhi"; capitals  = "Paris";
currencies  = "Rupees"; currencies  = "Francs";
for (x=0; x<2; x++)
What is the meaning of the lookup_widget ? If I understood well to get the text from the entry field is associated to the pointer *entry_text the gtk_entry_get_text () â€¦
I am a bit confusedâ€¦
As I understood another method would be writing all the code on your own , I just purchased the book foundation GTK+ programming book , I think it is very good to really understand all behind the gtk+ programming technique , but I am not sure if this is what I am looking for and if this is the most common method used by programmers. In this case if I understood well you do not use glade3 + anjuta , but any IDE which uses gcc.
I would appreciate if someone can provide some comments on my considerations, I apologize if what I wrote is not correct , but I think I am a bit confused...