Re: Pass multiple arguments to a signal event



On Wed, Sep 05, 2007 at 03:58:25PM +0200, pespin espeweb no-ip com wrote:
I can't figure how to pass multiple arguments to a signal event.I'll be very grateful if someone could 
explain it to me or write some example.

You can pass a pointer and this is enough becuase a pointer
can point to arbitrarily complex data structures.  Therefore
you can pass arbitrarily complex data structures, even
though sometimes it can be less convenient than passing
multiple arguments directly.

Also, in some cases you can use g_object_set_data() to
attach data related to widgets (and other objects) directly
to them and pick them later in the callback with
g_object_get_data().

For example, let's say I have in a window 2 entries and a button. How can I pass the 2 entry widgets to the 
signal function for working with them? 

As far as I know I can't do something like:

g_signal_connect_swapped(button, "clicked", G_CALLBACK (callback_func_example), here_the_two_widgets );

You can:

  GtkWidget **here_the_two_widgets;

  here_the_two_widgets = g_new(GtkWidget*, 2);
  here_the_two_widgets[0] = entry1;
  here_the_two_widgets[1] = entry2;
  g_signal_connect_swapped(button, "clicked",
                           G_CALLBACK(callback_func_example),
                           here_the_two_widgets);

(not the best example, but hopefully gives the idea).

Yeti

--
http://gwyddion.net/



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