GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Function Callback for Radio Buttons

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
weiliang10



Joined: 28 Apr 2008
Posts: 1

PostPosted: Mon Apr 28, 2008 8:23 am    Post subject: Function Callback for Radio Buttons Reply with quote

I am new to GTK and have a question with regards to callback for radio buttons.

I have created a group of 2 radio buttons as per the GTK tutorial:


Code: (C++)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.
GtkWidget *res;
GtkWidget *vboxmjsettings;
GSList *Group_Resolution;
   
.
.

    ctx->res = gtk_radio_button_new_with_label (NULL, "500cpi");
    gtk_box_pack_start (GTK_BOX (ctx->vboxmjsettings), ctx->res, TRUE, TRUE, 0);
    gtk_widget_show (ctx->res);

    ctx->Group_Resolution = gtk_radio_button_group(GTK_RADIO_BUTTON (ctx->res));
   

    ctx->res = gtk_radio_button_new_with_label (ctx->Group_Resolution, "1000cpi");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctx->res), TRUE);
 ctx->res);
    gtk_box_pack_start (GTK_BOX (ctx->vboxmjsettings), ctx->res, TRUE, TRUE, 0);
    gtk_widget_show (ctx->res);
    GTK_WIDGET_SET_FLAGS (ctx->res, GTK_CAN_DEFAULT);




How do I attach a callback function to each of the radio button?

I am not able to use the 'g_signal_connect' function since both the '500cpi' and '1000cpi' radio buttons are not widgets. My intention is to to have each of the radio button to call a function when selected.

Appreciate if someone could help me out. Thanks in advance.[/code]
Back to top
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 42

PostPosted: Mon Apr 28, 2008 11:02 am    Post subject: Reply with quote

GObject
+----GInitiallyUnowned
+----GtkObject
+----GtkWidget
+----GtkContainer
+----GtkBin
+----GtkButton
+----GtkToggleButton
+----GtkCheckButton
+----GtkRadioButton

So GtkRadioButton is definetly widget. If you want to detect which radiobutton causes signal, use g_object_set.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP