GNOME Bugzilla – Bug 547379
"clicked" is not work on gtkbutton
Last modified: 2008-08-12 05:21:57 UTC
This is the code: #include<gtk/gtk.h> /* gcc -o gtkbuttonbug gtkbuttonbug.c `pkg-config gtk+-2.0 --libs --cflags` */ void on_button(GtkButton *button,char *id) { static gint count1 = 1; static gint count2 = 1; gchar *str = NULL; if(*id=='1'){ gtk_widget_set_sensitive(button,FALSE); str = g_strdup_printf("This is the %dth click on button%s.",count1++,id); }else str = g_strdup_printf("This is the %dth click on button%s.",count2++,id); gtk_button_set_label(button,str); gtk_widget_set_sensitive(button,TRUE); g_print("%s\n",str); g_free(str); } gboolean on_window_delete (GtkWidget *widget, GdkEvent *event, gpointer user_data) { gtk_widget_destroy(widget); gtk_main_quit(); return TRUE; } int main(int argc,char **argv) { gtk_init(&argc,&argv); GtkWidget *win; GtkWidget *button1; GtkWidget *button2; GtkWidget *vbox; win = gtk_window_new(GTK_WINDOW_TOPLEVEL); vbox = gtk_vbox_new(FALSE,1); button1 = gtk_button_new_with_label("button1"); button2 = gtk_button_new_with_label("button2"); gtk_box_pack_start(GTK_BOX(vbox), button1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), button2, TRUE, TRUE, 0); g_signal_connect(button1,"clicked",G_CALLBACK(on_button),"1"); g_signal_connect(button2,"clicked",G_CALLBACK(on_button),"2"); g_signal_connect(win,"delete-event",G_CALLBACK(on_window_delete),NULL); gtk_container_add(win,vbox); gtk_widget_show_all(win); gtk_main(); return 0; } if I move the mouse on the button1 and never move the mouse. I find that just first "clicked" work .And the button2 have no this problem ,So it can be a bug ! Other information: -0-$ dpkg -l|grep libgtk ii libgtk2-perl 1:1.190-1 Perl interface to the 2.x series of the Gimp ii libgtk2.0-0 2.12.11-3 The GTK+ graphical user interface library ii libgtk2.0-bin 2.12.11-3 The programs for the GTK+ graphical user int ii libgtk2.0-common 2.12.11-3 Common files for the GTK+ graphical user int ii libgtk2.0-dev 2.12.11-3 Development files for the GTK+ library ii libgtk2.0-doc 2.12.11-3 Documentation for the GTK+ graphical user in ii libgtkhtml2-0 2.11.1-2 HTML rendering/editing library - runtime fil ii libgtkmm-2.4-1c2a 1:2.12.7-1 C++ wrappers for GTK+ 2.4 (shared libraries) ii libgtksourceview-common 1.8.5-1 common files for the GTK+ syntax highlightin ii libgtksourceview1.0-0 1.8.5-1 shared libraries for the GTK+ syntax highlig ii libgtksourceview2.0-0 2.2.2-1 shared libraries for the GTK+ syntax highlig ii libgtksourceview2.0-common 2.2.2-1 common files for the GTK+ syntax highlightin ii libgtkspell0 -0-$ cat /etc/issue Debian GNU/Linux lenny/sid \n \l
Can you please describe the problem in more detail? I ran this code and it seemed to work as expected. I clicked Button 1, and did not move the mouse at all. The label changed and the window grew larger, and I clicked button 1 again and it worked again. What am I missing here?
(In reply to comment #1) > Can you please describe the problem in more detail? I ran this code and it > seemed to work as expected. > > I clicked Button 1, and did not move the mouse at all. The label changed and > the window grew larger, and I clicked button 1 again and it worked again. What > am I missing here? > Have you move the mouse ? After a click, the mouse should not move out of button's range . it is importan important ! And then you click button ,you will find this click do not work ! I mean the text on the button1 will not change !
I just actually looked at the code more carefully and noticed your calls to gtk_widget_set_sensitive(). This is what is causing the problem for you, and this was just recently fixed in bug #56070. *** This bug has been marked as a duplicate of 56070 ***
which gtk version will add the fixed ?
It will be in the 2.14 release, which is the next stable series. It is in the latest 2.13.x release now I think.
Thanks !