[Gllug] Handwavy GTK2 question

will will at hellacool.co.uk
Sat Feb 7 13:22:28 UTC 2004


will wrote:
> I have registered a callback on the button being pressed and this works, 
> I am using gprint to print out just an 'x' to stdout to test it.  The 
> problem is when I want to update the status bar from the callback. 
> Because the status bar was declared in a subroutine earlier on in the 
> program, the statusbar widget does not exist in the scope of the callback:
> 
> void on_ok_button_clicked (GtkButton *button, gpointer user_data) {
>   //this line fails, statusbar does not exist here:
>   gtk_statusbar_push(statusbar1, 
> gtk_statusbar_get_context_id(statusbar1, "a"), "foo");
> 
>   g_print ("x");
> }

This seems to work:

   GtkWidget *statusbar;
   statusbar = lookup_widget (GTK_WIDGET (button), "statusbar");	
   gtk_statusbar_push(statusbar, gtk_statusbar_get_context_id(statusbar, 
"a"), "foo");
   gtk_statusbar_push(statusbar, gtk_statusbar_get_context_id(statusbar, 
"a"), "foo");

Will.
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list