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




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