stopping signals
- From: dave walters <walter8950 yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: stopping signals
- Date: Thu, 20 Nov 2003 08:39:54 -0800 (PST)
I'm trying to stop a spinbutton from emitting the "value_changed" signal when a
set_value() is executed in a callback. I tried using g_signal_stop_emission_by_name()
but it didn't work. I've attached the code. Any ideas on what I'm doing wrong?
Thanks,
Walt
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
#include <gtk/gtk.h>
void set_val(GtkWidget *spin,gpointer data)
{
gint a,k;
k =(int)data;
a=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
g_print("a before %d \n",a);
g_signal_stop_emission_by_name(GTK_SPIN_BUTTON(spin),"value_changed");
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),(gdouble)(a+1));
a=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
g_print("a after %d \n",a);
}
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *spin;
GtkWidget *main_vbox;
GtkWidget *vbox1;
GtkWidget *button;
GtkAdjustment *adj;
/* Initialise GTK */
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
gtk_window_set_title (GTK_WINDOW (window), "Spin Button");
main_vbox = gtk_vbox_new (FALSE, 5);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 10);
gtk_container_add (GTK_CONTAINER (window), main_vbox);
vbox1 = gtk_vbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), vbox1, FALSE, FALSE, 5);
adj = (GtkAdjustment *) gtk_adjustment_new (1,
1, 10.0, 1.0, 5.0, 0.0);
spin = gtk_spin_button_new(adj,0,0);
g_signal_connect(G_OBJECT(spin),"value_changed",
G_CALLBACK(set_val),(gpointer) 1);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin),TRUE);
gtk_box_pack_start (GTK_BOX (vbox1), spin, TRUE, FALSE, 0);
button = gtk_button_new_with_label ("Close");
g_signal_connect_swapped (G_OBJECT (button), "clicked",
G_CALLBACK (gtk_widget_destroy),
window);
gtk_box_pack_start (GTK_BOX (main_vbox), button, TRUE, TRUE, 5);
gtk_widget_show_all (window);
/* Enter the event loop */
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]