[Glade-users] signal handler with arguments from property editor



mw158979 wrote:

I have built a gtk keypad with Glade and I wish to assign the same
"pressed" signal handler to every key button and to give an additional
argument to the signal callback, specifying for each key button a
different key identifier. Is it possible to do this from the property
editor? Thanks in advance for any help.
   

 From what I'm seeing, unfortunately that not currently possible.

You can fill the field 'object'.

Glade then generates code with that text as gpointer type
argument for g_signal_connect, perhaps you will need
to place conversion in the editor. I don't know how about
libglade.

That argument you will receive in your callback (as user_data).
 

Well, I'm not exactly sure about the code that glade-2
generates, but libglade uses that feild to lookup a widget
by that name and connect the object as user_data.

I assume the code glade-2 would generate would look like:
    g_signal_connect (button, "clicked", my_hanlder, lookup_widget 
("my_object"));
where you put "my_object" in the "object" field.

Either way, if you are useing code generation, you can modify the
generated code and use a string constant for user data, if
your not generating code; you'll have to find another way.

That other way could be:

void
my_clicked_handler (GtkWidget *button, gpointer unused)
{
    gchar *key, *name;

    name = gtk_widget_get_name (button);
    key = derive_key_from_widget_name ();

    /* keyboard code */
}

Cheers,
                                   -Tristan




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