Re: emitting a signal for refeshing entries



Hi Peter,

Reading your mail more carefully, I'm now not sure about your approach. Why do you need to send redraw signals? This should be automatic.

You may be doing this already, but if you're not, I'd strongly urge you to restructure as a model/view design. If I understand you right, you have a big optionmenu at the top which you use to switch between different sets of preset values for the other widgets in the window (spins, combos etc).

I would have a struct shared by all the widgets in your window containing the widget pointers and the current setting of each of the controls as int, float, whatever. Write a function called refresh_view() which updates all of the widgets from these values. For example:

typedef struct _Model {
 GtkWidget *spin;
 double spin_value;

 ... etc.
} Model;

void
refresh_view( Model *model )
{
 gtk_spin_button_set_value( GTK_WIDGET( model->spin ), model->spin_value );
 ... etc.
}

In the callback from the main optionmenu, load up a new bunch of settings into Model and call refresh_view() to update the screen. For each of the widget callbacks, update the corresponding value in Model (and optionally adjust some other values too) then also call refresh_view().

The idea here is to split your program into two parts: something that represents your state (the model), and something that shows that state to the user (the view). The principle then is that you have a single thing which updates the view from the model, and you then only ever change the model, you never directly change the view. You should find that your program becomes much simpler.

John

Peter Van Osta wrote:
John,

Thanks for the information, but will gtk_widget_queue_draw()
cause all subelements in the window like spinbuttons to update if I do not capture the "draw" signal ? I use the callbacks for the "expose" signal to refresh the values of the spinbuttons, etc.

A parameter can vary form 1 to 100 and I want the spinbutton to show this value from this parameter when it changes in the program not only by interaction. I now how to set it from within the software, but I would like to ahve all callback function that react on "expose" events to be activated at once.

Best regards,

Peter Van Osta

Union Biometrica N.V./S.A.
European Scientific Operations (ESO)
Cipalstraat 3
B-2440 Geel
Belgium
Tel.: +32 (0)14 570 620
Fax.: +32 (0)14 570 621

http://www.unionbio-eu.com/

http://ourworld.compuserve.com/homepages/pvosta/cvwww.htm

==============================================

John Cupitt wrote:

Yes, just call gtk_widget_queue_draw() for your window. It will invalidate the window and queue a redraw for all the widgets.
Peter Van Osta wrote:

Hi,

I have a window in which there are several other elements, such as spinbuttons, combo boxes, etc. . There is one combo box which allows to choose a specific application which includes different settings for the spinbuttons, other combo boxes, etc.

I want to send one signal (if possible), such as an expose_event which I already use to show the current updated values if something has changed between windows after re-exposure. Is it possible to emit an "expose" signal to the main window, so it is propagated to its "chilren" ? Or do I have to emit signals to each one of the widgets in the main window ?

Best regards,

Peter Van Osta

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list










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