Question

I'm using Glade-3 for my GUI design, but I keep hitting this problem. I don't see anything in the GTK+ documentation mapping signals to events or in Glade-3 (3.4.5). Is there a place in the GTK+ source code to find this information?

Note: It is important in this question to recognize that events and signals are NOT the same thing in GTK.

Example:

I have an eventbox that requires the following events in order to receive the following signals. How do I determine what events are required by a given signal?

Events: GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK
Signals: leave_notify_event, enter_notify_event
Was it helpful?

Solution

Ok, I think I know what you mean now, I found this table matching up the gtk signals and gdk events. Here it is.

OTHER TIPS

Assuming that I have interpreted your question correctly you are wanting to connect the signals you specified in the Glade file to the functions in the source code. How you do this depends if you are using libglade to load the files generate or GtkBuilder, both are similar but I will give samples in C just to be complete.

Using libglade you would do it like so:

GladeXml *xml = glade_xml_new(filename, NULL, NULL); // Load the file
glade_xml_signal_autoconnect(xml); // Connect the signals

Using GtkBuilder it would be like this:

GtkBuilder *xml = gtk_builder_new();
gtk_builder_add_from_file(xml, filename, NULL); // Load the file
gtk_builder_connect_signals(xml, NULL); // Connect the signals

When using GtkBuilder the second parameter in signal connect function can be replaced with a pointer to data which will then be passed to the signal handlers.

Going forward I would suggest using GtkBuilder as libglade is on its way to being deprecated.

Links

Here are the links to the relevent documentation about the two functions mentioned above

You can capture the events with gdk_event_handler_set()

First register your own GDK event handler on startup:

gdk_event_handler_set(my_gdk_event_handler, NULL, NULL);

... Then use it to print out any useful information, and don't forget to pass the event to GTK+ through gtk_main_do_event() like here:

void my_gdk_event_handler(GdkEvent *event, gpointer data)
{
    printf("Received GdkEvent of type %d", event->type);

    gtk_main_do_event(event); // Pass event to GTK+
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top