LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Enable/Disable GTk CheckButton (https://www.linuxquestions.org/questions/programming-9/enable-disable-gtk-checkbutton-120883/)

Claus 11-28-2003 09:07 PM

Enable/Disable GTk CheckButton
 
How can i enable/disable a GtkCheckButton ??

i was trying with this

Code:

do{
                        switch(acl_rights[count]){
                                case 'l':
                                        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(checkbutton_l), TRUE);
                                        break;
...

But i get this message when i run and the program goes through that code...

Code:

(gyrus:20019): GLib-GObject-WARNING **: invalid cast from `GtkCheckButton' to `GtkCheckMenuItem'
 
(gyrus:20019): Gtk-CRITICAL **: file gtkcheckmenuitem.c: line 205 (gtk_check_menu_item_set_active): assertion `GTK_IS_CHECK_MENU_ITEM (check_menu_item)' failed

and off course, the checkbutton dont get activated...

So anyone can tell me how it's really supposed to be done??? Thank you..

mhearn 11-30-2003 08:43 AM

Try:

gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_l));

You see, GtkCheckMenuItem is a different class to GtkCheckButton (one is a tick box, one is a menu item), and you are attempting to typecast between them which is invalid, hence the assertions. GtkCheckButton doesn't have its own way to toggle on and off, but it inherits from GtkToggleButton which does, hence you need gtk_toggle_button_* stuff.

Hope that helps

Claus 12-01-2003 04:44 AM

thank you.


All times are GMT -5. The time now is 03:44 PM.