GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Apr 24, 2014 11:22 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: gtk_test_widget_click - no "clicked" signal emmitted
PostPosted: Wed Jul 03, 2013 2:21 pm 
Offline
Familiar Face

Joined: Mon Dec 21, 2009 4:36 pm
Posts: 22
Hello. I'm trying to make a simple test. A window has two buttons: b1 and b2. When user clicks b1 gtk_test_widget_click "clicks" the second button. But actually when I click first button there is no second "click" signal occurs. Instead, mouse just comes to second button and that is all. This is a sample code. What is wrong here?

Code:
#include "gtk/gtk.h"

void clicked1(GtkButton *button, gpointer user_data){
   gtk_test_widget_click(GTK_WIDGET(user_data), 1, 0);
}

void clicked2(GtkButton *button, gpointer user_data){
   g_print("clicked");
}

int main(int argc, char **argv) {
   GtkWidget *window;
   GtkWidget *hbox;
   GtkWidget *button1;
   GtkWidget *button2;

   gtk_init(&argc, &argv);

   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   g_signal_connect(G_OBJECT( window ), "destroy", G_CALLBACK( gtk_main_quit ),
         NULL);

   hbox = gtk_hbox_new(FALSE, 1);
   button1 = gtk_button_new();
   gtk_button_set_label(GTK_BUTTON(button1), "b1");
   button2 = gtk_button_new();
   gtk_button_set_label(GTK_BUTTON(button2), "b2");
   g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(clicked1), button2);
   g_signal_connect(G_OBJECT(button2), "clicked", G_CALLBACK(clicked2), NULL);


   gtk_container_add(GTK_CONTAINER(window), hbox);
   gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button1), FALSE,  FALSE, 5);
   gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button2), FALSE,  FALSE, 5);

   gtk_widget_show_all(window);

   gtk_main();
}


Top
 Profile  
 
 Post subject: Re: gtk_test_widget_click - no "clicked" signal emmitted
PostPosted: Fri Jul 19, 2013 7:49 pm 
Offline
Familiar Face

Joined: Mon Dec 21, 2009 4:36 pm
Posts: 22
Is there any solution? Or function should work that way?


Top
 Profile  
 
 Post subject: Re: gtk_test_widget_click - no "clicked" signal emmitted
PostPosted: Sat Jul 20, 2013 10:29 am 
Offline
Familiar Face

Joined: Thu Aug 27, 2009 9:44 pm
Posts: 21
The code you have posted works for me.

If i click on button `button1` the cursor jumps to `button2` and the callback `clicked2(...)` is executed from within `clicked1(...)`.
If i click on button `button2` the cursor stays at it's place and callback `clicked2(...)` is executed.

I compiled it on a system with the following library versions
Code:
$ pkg-config --modversion gtk+-2.0 glib-2.0
2.24.10
2.32.4


Top
 Profile  
 
 Post subject: Re: gtk_test_widget_click - no "clicked" signal emmitted
PostPosted: Fri Aug 02, 2013 12:47 pm 
Offline
Familiar Face

Joined: Mon Dec 21, 2009 4:36 pm
Posts: 22
I have the following versions of packages:
Code:
pkg-config --modversion gtk+-3.0 glib-2.0
3.6.4
2.36.0

My system is Ubuntu 13.04.
Can anyone run my code on similar system?


Top
 Profile  
 
 Post subject: Re: gtk_test_widget_click - no "clicked" signal emmitted
PostPosted: Fri Aug 02, 2013 6:50 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
Hello,

I get exactly the same results. The reason is that the GTK test routines have not been initialised. To do this gtk_init() needs to be replaced with gtk_test_init(). Once you have done this you will get the expected results. The gtk_test_*() functions are used for application testing and not for final application releases.

Also with the version of GTK+ that you are using the GtkHBox is now deprecated and should not be used. Use the alternatives GtkBox or GtkGrid instead.

_________________
E.


Top
 Profile  
 
 Post subject: Re: gtk_test_widget_click - no "clicked" signal emmitted
PostPosted: Sun Aug 04, 2013 3:47 pm 
Offline
Familiar Face

Joined: Mon Dec 21, 2009 4:36 pm
Posts: 22
errol

Thank you very much!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group