RE: Using arguments in callbacks



Well, I guess I'm making progress, but I still can't get this to work.  I
have now added the Object "trajectoryTB" to the "toggled" Signal with
Handler named "trajectoryCb" for the Widget named "trajectoryTB" (i.e., it's
specifying itself as the object).  I no longer get the error I mentioned
previously, but now I get the following message when I build:

Please make sure that these member functions exist, I can't declare them,
yet.
           void Gtk::ToggleButton::trajectoryCb()
           void Gtk::ToggleButton::trajectoryCb()

If I ignore this message and try to compile the program, I get the following
error:

PPIWindow_glade.cc: In constructor 'PPIWindow_glade::PPIWindow_glade()':
PPIWindow_glade.cc:368: error: 'trajectoryCb' is not a member of type '
         Gtk::ToggleButton'

This is line 368 of PPIWindow_glade.cc:

trajectoryTB->signal_toggled().connect(sigc::mem_fun(*trajectoryTB,
&Gtk::ToggleButton::trajectoryCb), true);

This is the only line that changed by adding the object to the signal.
Before adding that, it looked like this:

trajectoryTB->signal_toggled().connect(sigc::mem_fun(*this,
&PPIWIndow_glade::trajectoryCb), true);

Why does it change to the ToggleButton class?  This seems to make things a
lot more confusing for me.  I'm sorry to keep asking so many questions about
this, but most of this is very new to me, so I don't really understand how
all of this works together.

Thanks,

Mike


-----Original Message-----
From: Tristan Van Berkom [  <mailto:tvb gnome org> mailto:tvb gnome org]
Sent: Wednesday, March 23, 2005 5:05 PM
To: Irwin Michael G DLVA
Cc: 'Hubert Sokolowski'; gtk-app-devel-list gnome org
Subject: Re: Using arguments in callbacks


Irwin Michael G DLVA wrote:
I'm not sure what exactly you mean by not supporting dlsym lookups for
user
data.  If I just want to pass a single integer as an argument to my
callback, is that even possible?  And if so, how do I do it?  You are
correct that I am trying to build the source with glade.

I'm assuming that whether you use generated code or libglade the
significance of the "object" field in the signal editor are the
same.

When you specify "object" in your signal; the "object" is a widget
name in the glade project (like "label1" or "togglebutton2" or something
smarter that you chose yourself).

When the signal callback gets called the said "object" will be the
*first* argument to the callback. So a decent example is:

   - You connect to the "clicked" signal on the "Quit" button and
     pass "main window" as the "object" field.
   - The said signal callback gets called as such:

   /* callback for "clicked" on quit_button connected with
    * the G_CONNECT_SWAPPED flag.
    */
   void callback (GtkWidget *main_window,
                  gpointer quit_button)
   {
       gtk_widget_destroy (main_window);
   }

As far as libglade functionality goes; this is the *only* way that
the "object" field works; the "object" field refers to the name of
a widget in the said glade project, nothing else.

Cheers,
                              -Tristan

BTW: what I meant by dlsym lookups is that it's possible to use
the "object" field to pass a string to libglade so that libglade
will lookup the symbol in the calling code (in the global scope
ofcourse); I have a patch pending which implements this.

 <http://bugzilla.gnome.org/show_bug.cgi?id=161903>
http://bugzilla.gnome.org/show_bug.cgi?id=161903




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]