Home > C, centOS, Fedora 12, Solaris, Unix/Linux > C – gui – glade2 – gtk – how to

C – gui – glade2 – gtk – how to

Happy “C” ing

How can i make on linux/mac/windows/unix a basic C code and a basic Gui, fastest and easiest way?

– we will follow 16 steps

1. Open glade2 (not glade3 in centOS i dont have it)

2. click new icon > click new gtk+ project

3. on left window icon click

4. apply close event

5. click 3 horizontal table > click on window

6. click 2 vertical table > click on bottom left

7. clik ok button > click left bottom > click ok button > click right bottom (2 buttons ready)

8. click textbox > click on middle horizontal table > click label > click on top horizontal table

9. click window > right bottom button > apply event for click

10. click left bottom button > apply click event

11. click the options to make sure where the project2 is located

12. click save to save project > click build to generate all the codes in (above path)

13. open editor (vi or kate or gedit or any shell etc) > go to the path > execute ./autogen.

14. go to the src > there is three event actions > replace it with following code ( 1 for button1, 1 for button2, 1 for window close action)

callback.c > insert this

on_button2_clicked                     (GtkButton       *button,
gpointer         user_data)

on_window1_destroy                     (GtkObject       *object,
gpointer         user_data)

on_button1_clicked                     (GtkButton       *button,
gpointer         user_data)
GtkWidget *label = lookup_widget( GTK_WIDGET(button), “label1” );
GtkWidget *entry = lookup_widget( GTK_WIDGET(button), “entry1” );

gchar ch[50] = “Hello “;

strcat( ch, gtk_entry_get_text(GTK_ENTRY(entry)));
gtk_label_set_text( GTK_LABEL(label), ch);


15. compile/build using > make

16. on success make > run the program by > ./project2

Happy “C” ing…

Categories: C, centOS, Fedora 12, Solaris, Unix/Linux
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: