Hi friend, for
Fake a signal By: neocruze (5 replies) Sat, 03/01/2008 - 19:20
- Re: Fake a signal By: gtkgalaxy (03/02/2008 - 05:52)
- Re: Re: Fake a signal By: neocruze (03/02/2008 - 15:07)
- Hi friend, for By: gtkgalaxy (03/03/2008 - 17:53)
- Re: Re: Fake a signal By: neocruze (03/02/2008 - 15:08)
- Re: Re: Fake a signal By: neocruze (03/02/2008 - 15:07)
- yes you can By: gtkgalaxy (03/01/2008 - 19:45)
Recent blog posts
- Nirmitsu Technologies Launches NU2000, NU2100 and NU4000
- Gtk and Embedded Devices - part 1
- gtk extra plot...
- GtkSheet with freeze panes
- Fake a signal
- Query::Setting Color of submenu Widgets
- how to color the combo box entry
- Multiline Text Editing Widget
- Setting Color of submenu Widgets
- GtkFB (Gtk+) for the Linux Framebuffer
Hi friend, for
Hi friend,
for gtk_signal_emit_by_name you should
pass callback's argument list
not callback itself
below i attached my tested sample
code for this fake signal.
When you click button 1
signal handler of button 2 is called.
see below code
/* Sample code from www.gtkhelp.com
* Gtk Help Team
*
*
*
*
*
*
*
*
*
*
*
*
*/
#include
#include
//Button2 callback
void
hello (GtkWidget * button, gpointer data)
{
printf ("hello B2 clicked\n");
}
//Button 1 callback
//this will generate a fake signal for button2
void
b1_clicked (GtkWidget * button, gpointer data)
{
GtkWidget *b = (GtkWidget *) data;
printf ("in b1\n");
//argument list is the arguments given to callback function
gtk_signal_emit_by_name (G_OBJECT (b), "clicked", b, NULL);
}
//main code
main (int argc, char **argv)
{
GtkWidget *button1, *button2, *fixed;
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (window, 400, 400);
gtk_window_set_title (GTK_WINDOW (window), "TEST");
fixed = gtk_fixed_new ();
gtk_widget_show (fixed);
gtk_container_add (GTK_CONTAINER (window), fixed);
button1 = gtk_button_new_with_label ("B1");
button2 = gtk_button_new_with_label ("B2");
gtk_fixed_put (fixed, button1, 10, 5);
gtk_fixed_put (fixed, button2, 50, 5);
//button2
g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (hello), NULL);
//button1
g_signal_connect (G_OBJECT (button1), "clicked", G_CALLBACK (b1_clicked),
button2);
gtk_widget_show_all (window);
gtk_main ();
}