[Gllug] Handwavy GTK2 question

will will at hellacool.co.uk
Thu Feb 5 23:25:55 UTC 2004


Hello all,

I am learning a bit of GTK2 (and c at the same time ;) ) at the moment, 
but have coms across a bit of a problem.  I have created a window and 
then a button and statusbar insite that:

window------ statusbar
          |
           `- button

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");
}

Does anyone know how to reference the statusbar that was created in a 
different subroutine in this instance?  I have read the gtk2 tutorial 
http://gtk.org/ and googled, but either I have missed the answer, or I 
just have not found the information yet.

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




More information about the GLLUG mailing list