Hi, You're not using the right callback format for the "clicked" signal. http://library.gnome.org/devel/gtk/stable/GtkToolButton.html#GtkToolButton-clicked
You're using for both handler 1 and handler 2: void user_function (void) while it should be: void user_function (GtkToolButton *toolbutton, gpointer user_data) When you use a signal, ALWAYS look at the prototype you need to use for the callback. This way, as you do the same thing in both callbacks, you can use a single callback to process the signals emitted by both buttons: void on_toolbutton_clicked (GtkToolButton *toolbutton, gpointer user_data) { gtk_widget_hide (GTK_WIDGET (toolbutton)); } Hope this resolves your problem... Cheers, Luis [EMAIL PROTECTED] a écrit : > Hello, > I've encountered a problem with hiding a GtkToolButton inserted into > GtkToolbar. Consider the small program bellow. > When pressing button2, this program freezes. I don't know why this happens - > I think the reasons may be two: > > 1. Using threads on Win32 > 2. Some bug. > > The problem appears when using GTK 2.12.X under Windows and does not appear > under Linux (GTK 2.10.X 2.12.X) and also does > not appear when using GTK 2.10.X under Windows. If I remove the threads > related code, everything works perfectly on all platforms > with all versions of GTK. > > I've also investigated, that the button being hidden must be first in the > toolbar and must have the signal connected, in other > case the problem does not appear. > > What reason is correct ? > > Thanks for ideas > > > > #include <gtk/gtk.h> > > GtkWindow *window; > GtkToolButton *button1; > GtkToolButton *button2; > GtkToolbar *toolbar; > > void handler1() { > gtk_widget_hide(GTK_WIDGET(button2)); > > > } > > void handler2() { > /*CRASH*/ > gtk_widget_hide(GTK_WIDGET(button1)); > } > > void quitHandler() { > > gtk_main_quit(); > > } > > > int main(int argc,char* argv[]) { > g_thread_init(NULL); > gdk_threads_init(); > gdk_threads_enter(); > > gtk_init(&argc,&argv); > > /*Window*/ > window=GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); > > /*Toolbar*/ > toolbar=GTK_TOOLBAR(gtk_toolbar_new()); > > /*Buttons*/ > button1=GTK_TOOL_BUTTON(gtk_tool_button_new_from_stock("gtk-add")); > button2=GTK_TOOL_BUTTON(gtk_tool_button_new_from_stock("gtk-edit")); > > gtk_toolbar_insert(toolbar,GTK_TOOL_ITEM(button1),0); > gtk_toolbar_insert(toolbar,GTK_TOOL_ITEM(button2),1); > > gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(toolbar)); > > /*Show all*/ > gtk_widget_show_all(GTK_WIDGET(window)); > gtk_widget_show(GTK_WIDGET(window)); > > g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(handler1),NULL); > g_signal_connect(G_OBJECT(button2),"clicked",G_CALLBACK(handler2),NULL); > > g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(quitHandler),NULL); > > gtk_main(); > > gdk_threads_leave(); > } > > > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list