Re: forcing a a widget_queue_draw



Are all the widgets in this list the same type?  What type are they?
Are they toggle buttons?  (created with gtk_toggle_button_new() or
similar?) Or are they radio buttons?  Or, if they are a new type defined
by you, what widget are they sub-classed from?

gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(buttons[n]), myboolean);

...should be all you need.  in fact, it's possible that setting the
"button_down" and "active" properties directly is what's screwing things
up.

I assume you're calling gtk_widget_show() on these buttons before this
code is running.  The buttons are visible, right?

Do you have "toggled" a signal handler connected to these buttons?  In
that signal handler, do you activate or de-activate any buttons in the
array that did not receive the signal?  If yes, you'll probably want to
block the signal before calling the .._set_active() function.

(I'm kind of grasping at straws if you can't tell.  There are a lot of
possibilities.)

- Ben


On Mon, Jan 31, 2005 at 02:29:23PM -0800, Adrian E. Feiguin wrote:
> Hi,
>    I probably wasn't clear. I just want to initialize my GUI. Suppose 
> that I have a list of buttons (something like radio buttons, although I 
> implement it myself in a customized fashion). I have a list of widgets, 
> if widget_list[n] == active_widget, then the button is down, else it's 
> up. So I do something like this:
> 
> ...
>        if(widget_list[n] == active_widget){
>            GTK_BUTTON(buttons[n])->button_down = TRUE;
>            GTK_TOGGLE_BUTTON(buttons[n])->active = TRUE;
>            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(buttons[n]), 
> TRUE);
>        }else{
>            GTK_BUTTON(buttons[n])->button_down = FALSE;
>            GTK_TOGGLE_BUTTON(buttons[n])->active = FALSE;
>            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(buttons[n]), 
> FALSE);
>        }
>        gtk_widget_queue_draw(buttons[n]);
>        n++;
> ...
> 
> And its simply doesn't work as intended. The button does not appear down 
> until I force the expose event. With gtk-1 I would use gtk_widget_draw 
> instead of queue draw, and it worked just fine. But now in gtk-2 there 
> is no gtk_widget_draw. How do I force the widget to draw?
> Thanks!
> <ADRIAN>
> 
> Tristan Van Berkom wrote:
> 
> >On Mon, 31 Jan 2005 12:42:33 -0800, Adrian E. Feiguin <afeiguin uci edu> 
> >wrote:
> > 
> >
> >>Hi all.
> >>   This is an example, but there are many cases when I want to do
> >>something similar:
> >>
> >>Suppose that I change the state of a toggle button with
> >>gtk_toggle_button_set_active or gtk_widget_set_state. The widget just
> >>wont draw properly until I move the mouse pointer over it forcing an
> >>expose event. What's going on? in gtk-1 I would simply call
> >>gtk_widget_draw, but now, event calling gtk_widget_queue_draw, the
> >>widget won't update. Can anyone explain it to me, please?
> >>   
> >>
> >
> >Hmm, 
> >   seems like you're hijacking the main loop somewhere, you
> >got a `while (42) { /* code body */ }' lying around in your code ?
> >
> >If its absolutely nescisary to implement the main program loop yourself;
> >you can call:
> >   `while (gtk_events_pending()) gtk_main_iteration_do (FALSE);' once
> >every loop.
> >
> >Just a guess, OTOH maybe there is something wrong with your X server 
> >installation (if your not recieving expose events or are unable to queue 
> >them).
> >
> >Cheers,
> >                                        -Tristan
> >
> >.
> >
> > 
> >
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list

-- 
Ben Johnson
Hi Point Coffee
425-591-4120



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