Re: Shrinking and growing widgets in GTK+ 3.x



On Thu, 2010-12-02 at 00:56 +0000, Bastien Nocera wrote:
> Heya,
> 
> One of the features of Totem (and one implemented in a number of movie
> players) is to resize the video to match the actual video size (or a
> multiple of it). For example, a 320x480 video would see Totem resize its
> video canvas to 480x320, if the preference is enabled.
> 
> The old GTK+ 2.x code did that by:
> - shrinking the toplevel to 1x1 (so all the widgets in the window get
> their minimum size set)
> - wait for the "size-request"
> - request our real size (480x320) in the size-request signal
> - and unset that size request in an idle (so that the window can be
> shrinked)

Is there some reason that your "real size" is computable only in the
size request signal?

The simple thing to do would be something like:

 gtk_window_set_geometry_hints (window,
                                video_canvas, /* geometry_widget */,
                                NULL, 0); /* hints/mask */
 gtk_window_resize_to_geometry (window, 480, 320);

Then code in GtkWindow will take care of figuring out what that means
for the size of your toplevel.

[ I'm not 100% sure how this will interact with the GtkPaned usage
  in Totem without more thought and looking at the GtkPaned code. ]

- Owen




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