Re: [gtk-list] Re: Disabling callbacks - Further explanation




I believe what you want to do is something like:

static gint sig_id = gtk_signal_connect(GTK_OBJECT(my_tog_button),
	GTK_SIGNAL_FUNC(my_callback_to_change_var), my_data_to_cb);

Then, when you change the variable on the commandline:

static gint command_line_cb_or_whatever(GtkWidget *w, gpointer data) {
  gtk_signal_block(GTK_OBJECT(my_tog_button), sig_id);
 gtk_toggle_button_set_active_or_whatever(GTK_TOGGLE_BUTTON(my_tog_button),
  TRUE/FALSE);
  gtk_signal_unblock(GTK_OBJECT(my_tog_button), sig_id);
}

where it's your job to make my_tog_button and sig_id visible to your entry
cb by making it global or passing it through the data parameter etc.

You could alternatively use one of the other signal blocking functions (by
function, by data).

I hope this helps.

--josh

----------------------------------------------------------------
                       Joshua Richardson
Dept. Cognitive and Neural Systems / Center for Adaptive Systems
                       Boston University
----------------------------------------------------------------

On Wed, 2 Jun 1999, K. M. Hawarden-Ogata wrote:

> Okay, maybe I need to explain better.
> 
> I have a program that uses both widgets (buttons, check boxes, toggle
> buttons, etc) to enter commands, etc. The user can also enter these commands
> manually through a text widget command line.
> 
> The problem I am encountering (an infinite loop of update widget -->
> callback --> update widget, etc ) generally occurs because when the screen
> is updated, due to a redraw, expose, or whatever, OR the user entering a
> command which, for example, might depress a toggle button, the visual state
> of the widget must be changed to reflect the state of the variable.
> 
> For example: suppose I have a pair of radio button which control whether
> data is saved to an external file or not. The user can select "on" with the
> mouse OR type "save on" in the command line. Either one of these actions
> should result in the "On" button being depressed, the "Off" button being
> undepressed and the 'save' variable being set to 1.
> 
> Unfortunately, when the screen is redrawn, and the button is toggled,
> another signal is emitted, (toggled) and I don't want this to happen.
> 
> Basically, I want to be able to turn the signal of, update my display, and
> turn them back on again.
> 
> I hope this gives you a better picture of what I'm trying to do.
> 
> Thanks, Miranda
> 
> /------------------------------------------------------------------------\
> | Miranda Hawarden-Ogata             Email: hawarden@irtf.ifa.hawaii.edu |
> | NASA IRTF, Institute of Astronomy  Phone: (808) 974-4206               |
> | 1175 Manono St., Bldg 393            Fax: (808) 974-4207               |
> | Hilo, HI 96720                                                         |
> \------------------------------------------------------------------------/
> 
> 
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]