Problem with callback functions...
- From: "James Vanns" <jamesv galleon co uk>
- To: <gtk-list gnome org>
- Subject: Problem with callback functions...
- Date: Tue, 18 Dec 2001 17:09:35 -0000
Hi everyone. Thanks in advance for at least reading my small problem!
Okay. I have a function called create_toogle_window (). Within this function
I have a few GtkWidgets initiated as GtkToggleButtons (3 of) and then one OK
button.
I have also a struct defined as within a header file:
typedef struct _options {
gboolean bss;
gboolean caf;
gboolean sb;
} options;
and an instance of it (automatic not pointer) within the named function
above.
Ok heres my problem. I am passing the options object defined (say it's
called foo) to the three callbacks written for the 'toggled' event:
gtk_signal_connect (GTK_OBJECT (checkbutton_caf), "toggled",
GTK_SIGNAL_FUNC (on_checkbutton_caf_toggled),
&foo);
gtk_signal_connect (GTK_OBJECT (checkbutton_bss), "toggled",
GTK_SIGNAL_FUNC (on_checkbutton_bss_toggled),
&foo);
gtk_signal_connect (GTK_OBJECT (checkbutton_sb), "toggled",
GTK_SIGNAL_FUNC (on_checkbutton_sb_toggled),
&foo);
the GtkFuncs look like:
void on_checkbutton_caf_toggled (GtkToggleButton * togglebutton, options
*bar)
{
bar->caf = gtk_toggle_button_get_active (togglebutton);
}
The callbacks here are working fine. If I stick a g_print on the value of
bar->element in the callbacks they all print 0 or 1 accordingly. Problem is
though I want this struct (foo) passed to the button OK callback where I'll
actually do something withit:
gtk_signal_connect (GTK_OBJECT (button_transextract_ok), "clicked",
GTK_SIGNAL_FUNC (on_button_transextract_ok_clicked),
&foo);
I.e. I select what I want using the togglebuttons, they store my config in
the struct which is then passed to the button ok callback for
manipulation/processing. All I get though when I do a g_print on the values
of bar in the button ok callback function is rubbish, no nice 0's or 1's.
WHat am I doing wrong and what do I need to do to fix it?? Should I be doing
this another way??
Cheers for your time.
Jim
--
James Vanns BSc (Hons) MCP
Software Engineer (UNIX / C)
Galleon Ltd.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]