Attachment 'gnu.c'
Download 1 #include<stdio.h>
2 #include<gtk/gtk.h>
3 #include<glade/glade.h>
4
5 /*
6 (C) Feb 2005 Muthiah Annamalai, Octave-GTK & Octave-libGlade
7 */
8
9 void on_spin_activate(GtkSpinButton *b);
10 void on_spin_changed(GtkSpinButton *b);
11
12 GladeXML *gx;
13
14 int main(int argc,char *argv[])
15 {
16 GtkWidget *w;
17
18 gtk_init(&argc,&argv);
19 gx=glade_xml_new("gnu.glade",NULL,NULL);
20 g_assert(gx != NULL);
21
22 glade_xml_signal_autoconnect(gx);
23 w=glade_xml_get_widget(gx,"window");
24
25 g_signal_connect(G_OBJECT(w),"destroy",G_CALLBACK(gtk_main_quit),NULL);
26 gtk_widget_show_all(w);
27
28 gtk_main();
29 return 0;
30 }
31
32 void on_spin_changed(GtkSpinButton *b)
33 {
34 gint count=0;
35 char buffer[10];
36 GtkLabel *label=GTK_LABEL(glade_xml_get_widget(gx,"label"));
37 count=gtk_spin_button_get_value_as_int(b);
38 sprintf(buffer,"%3d",count);
39 gtk_label_set_text(label,buffer);
40 printf("changed: %s <=> %d\n",buffer,count);
41 }
42
43 void on_spin_activate(GtkSpinButton *b)
44 {
45 //Doesnt work.
46 unsigned char count=0;
47 char buffer[10];
48 GtkLabel *label=GTK_LABEL(glade_xml_get_widget(gx,"label"));
49 count=gtk_spin_button_get_value_as_int(b);
50 sprintf(buffer,"%d",count);
51 gtk_label_set_text(label,buffer);
52 printf("actiavted: %s <=> %d\n",buffer,count);
53 }
54
55 /**
56 gcc -o gnu -Wall gnu.c `pkg-config gtk+-2.0 --cflags --libs` -I/usr/include/libglade-2.0 -lxml -lglade-2.0
57 */
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.