After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 547379 - "clicked" is not work on gtkbutton
"clicked" is not work on gtkbutton
Status: RESOLVED DUPLICATE of bug 56070
Product: gtk+
Classification: Platform
Component: Widget: Other
2.12.x
Other All
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-08-12 03:49 UTC by weikting
Modified: 2008-08-12 05:21 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22



Description weikting 2008-08-12 03:49:07 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
Comment 1 Cody Russell 2008-08-12 03:55:08 UTC
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?
Comment 2 weikting 2008-08-12 04:51:39 UTC
(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 !
Comment 3 Cody Russell 2008-08-12 05:06:07 UTC
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 ***
Comment 4 weikting 2008-08-12 05:13:36 UTC
which gtk version will add the fixed ? 
Comment 5 Cody Russell 2008-08-12 05:19:08 UTC
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.
Comment 6 weikting 2008-08-12 05:21:57 UTC
Thanks !