Re: Newbie Gtk+ questions...




> >>>>> "OT" == Owen Taylor <owt1@cornell.edu> writes:
> 
> [ integer valued scale ]
>   OT> If you want a scale widget that actually moves in integer
>   OT> increments, then you are out of luck, unless you write your
>   OT> own. Otherwise, just use
> 
>   OT>   gtk_scale_set_digits (GTK_SCALE(my_scale), 0);
> 
> That will do the trick. It will be easy enough to convert the value to
> an int myself when I get it back :)

(setting the digits actually makes sure that the value is always
an integer - so you just need to cast it to an int)

[...]
> 
> UTS,L! = Use The Source, Luke! (IE, digging through the gtk code :)

Ah. That's what I was asking abot.

[...]

> Sounds confusing.. I'll just go with...
> 
>   >> Can I call gtk_main_iteration_do() in the middle of my idle
>   >> function and have it process events correctly, or am I basically
>   >> taking my chances if I do that?
> 
>   OT> Just calling gtk_main_iteration_do() is taking your
>   OT> chances. (The non-block isn't currently working) But doing:
> 
>   OT>   while (gtk_events_pending()) gtk_main_iteration();
> 
> This here.. That seems to work better (though that 350ms grab is still
> a hit - I may need to bite the bullet and do the qcam stuff myself :()
> and is simple enough for a beginner like me to understand. :)
> 
>   OT> will work safely. Though, if you do this, idle redraws may not
>   OT> work correctly. [ I haven't tested it out, but it strikes me
>   OT> that this may be the case. Maybe gtk_events_pending() should
>   OT> count idle handlers above some priority as pending events? ]
> 
> Idle redraws? What's that? Should I be concerned?

Resizing and redrawing in GTK isn't done immediately when triggered,
but rather in an idle handler. (In post 0.99.3 GTK, these idle
handlers have a priority higher than default, so they get called
before the user's idle handlers) But the:

  while (gtk_events_pending()) 
    gtk_main_iteration();

Won't run these handlers, because they don't count as pending events.
This is almost certainly a bug in GTK. 

It will just cause some slightly funny resizing/redrawing behavior,
if you don't continually run in that loop, so if things work
OK, you may not need to do anything. I've fixed the problem in
CVS, anyways.

[ I've added

  if (idle_functions &&
      (((GtkIdleFunction *)idle_functions->data)->priority >=
       GTK_PRIORITY_INTERNAL))
    result += 1;

To gtk_events_pending. Which should solve that problem. (the internal
handlers are always one-shot, so the loop will terminate when
they are finished) ]

Regards,
                                        Owen



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