Using g_signal_connect in an event handler
- From: Lorenzo Marcon <lorenzo marcon startrekitalia com>
- To: gtk-app-devel-list gnome org
- Subject: Using g_signal_connect in an event handler
- Date: Tue, 17 Oct 2006 13:51:47 +0200
Hi to all,
this is my first experience with GTK+ and my first post here too.
I'm currently writing a small application using GtkNotebook. (Not multi-thread
or multi-process)
My application works in this way:
- The main function draws the main GUI and associate some event handlers to
some buttons
- When one of this button is clicked, the event hanlder associated with it
creates a new tab in the GtkNotebook.
- Every created tab has an xpm image in the label that allows to close it. To
do this I have to connect the event_box containing the xpm image with the
"close-tab" event handler.
So I have to use the "g_signal_connect" function again in the event handler
called by the button pressure. The problem is that I do not seem able to pass
correctly arguments in this second call.
int main(int argc, char *argv[]) {
...
gpointer data[5];
...
data[0] = (gpointer) gtk_entry_get_text (GTK_ENTRY (entry));
data[1] = (gpointer) notebook;
data[2] = (gpointer) progress_bar;
data[3] = (gpointer) &stop;
data[4] = (gpointer) window;
...
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (enter_callback),
data);
...
}
gboolean enter_callback(GtkWidget *widget, gpointer *data) {
...
g_signal_connect (G_OBJECT (event_box), "button-press-event", G_CALLBACK
(x_click_callback), data[1]);
....
}
gboolean x_click_callback(GtkWidget *event_box, gpointer data) {
//Here I get segfault if I try to remove the tab.
}
I have tried to print out the value of the pointer to the Gtknotebook with a
simple g_print("%p", notebook) both in the enter callback and
x_click_callback. They are always different.
I cannot explain this to myself, because I'm successfully passing arguments
and resolving them in the first event handler.
Any help will be appreciated. Thank you.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]