Re: g_signal_new

Hi Emmanual,

(Please ask questions like this to the gtk-list and not only directly to me. I'm taking the freedom to CC the list for my reply. Hope it's ok with you.)

Here are five different ways that you use to pass more than one value in a signal callback.
  1. Use g_object_set_data() to attach additional data to the widgets. This is a hash table and you can put whatever you want in it. In the handle use g_object_get_data() to retrieve the values.
  2. Create a structure that contains the two values that you want to pass a long, dynamically allocate it and pass a pointer to the memory as the last parameter of g_signal_connect().
  3. Subclass GtkButton (I prefer to use gob2 or vala) for more compact syntax and add your new parameter to the widget.
  4. Subclass one of the the parent widget of GtkButton (e.g. GtkWindow as MyApp) and add your new parameter to the widget. In last parameter of g_signal_callback() pass a pointer to MyApp.
  5. Use global variables.
Hope this helps.


On Thu, Dec 2, 2010 at 03:20, Emmanuel Gontcho <gontcho gmail com> wrote:
Hello Dov,

I write to you to ask for help. I want to add to a GtkButton a signal which callback should carry two paramaters instead of the ordinary one with the "clicked" signal. You are a widget developper I saw a call to gtk_signal_new in your source code. I want you to tell me if that is (the call) all that must be done and how to trigger the signal, since I don't write a new widget but just add the signal to an existing one.

Thank you.

Emmanuel Mbenga Gontcho
!!!!! Gem !!!!!

N'utilisez pas Windows 7. Pour savoir pourquoi :
Don't use Windows 7. To know why :

Membre de l'April - « promouvoir et défendre le logiciel libre » -

Rejoignez maintenant plus de 2 500 personnes, associations, entreprises et
collectivités qui soutiennent notre action

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