Re: Shrinking and growing widgets in GTK+ 3.x
On Thu, 2010-12-02 at 13:07 +0900, Tristan Van Berkom wrote: On Thu, 2010-12-02 at 00:56 +, Bastien Nocera wrote: Heya, snip If you want the whole window to shrink, a.) that's a little yuck, I'm not sure how much end-users like that behaviour ... b.) GTK+ doesnt like doing that... but if I recall correctly you might provoke GTK+ to do that by calling gtk_container_check_resize()... I'd have to take a deeper look to make sure. It might be yuck, but it's a feature other movie players implement, and something we implemented a long time ago: commit 9567aa7563ddd1cb6d38ee65bc42eb6ff5942804 Author: Bastien Nocera had...@hadess.net Date: Sun Sep 15 20:48:15 2002 + added /apps/totem/auto_resize implement automatically changing the ratio 2002-09-15 Bastien Nocera had...@hadess.net * data/totem.schemas.in: added /apps/totem/auto_resize * src/gtk-xine.c: (frame_output_cb), (gtk_xine_idle_signal), (gtk_xine_ratio_fits_screen), (gtk_xine_set_scale_ratio): implement automatically changing the ratio when the video changes size (Closes: #92320) Note that it's disabled by default. gtk_container_check_resize() is lacking documentation in my day old checkout of gtk+. Cheers ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Shrinking and growing widgets in GTK+ 3.x
Hi, It seems like the following would work but maybe I'm missing the obvious * have the video request natural size = its natural unscaled size, and min size of whatever lowest scale factor you want to allow * to snap to natural size, just size request the entire toplevel to get the natural size, then gtk_window_resize() to that size Havoc ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Shrinking and growing widgets in GTK+ 3.x
On Thu, 2010-12-02 at 00:56 +, 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 ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Shrinking and growing widgets in GTK+ 3.x
On Thu, 2010-12-02 at 11:51 -0500, Havoc Pennington wrote: Hi, It seems like the following would work but maybe I'm missing the obvious * have the video request natural size = its natural unscaled size, and min size of whatever lowest scale factor you want to allow * to snap to natural size, just size request the entire toplevel to get the natural size, then gtk_window_resize() to that size It might work :) I went with Owen's solution, and it seems to behave as expected even with the GtkPaned (though it already had some custom code to handle the resizing there). Thanks for the help. Cheers ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Shrinking and growing widgets in GTK+ 3.x
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) http://git.gnome.org/browse/totem/tree/src/backend/video-utils.c#n197 It's pretty gruesome, but mostly works. For GTK+ 3.x, I wanted to clean that code. I tried saving our wanted size, calling gtk_widget_queue_resize() and wait for -get_preferred_{width,height} to be called, and set the wanted size as the natural size. Problem is that this only worked when growing the window, not shrinking it. My current backup plan was to do the above in 2 steps: - save our wanted size and queue a resize * set the natural size to 1x1, and queue an idle handler - idle handler calls gtk_widget_queue_resize() * set the natural size to the actual wanted size This is just about as gruesome as the original GTK+ 2.x code. Does anyone have a better idea on how i implement my own sync-ish gtk_widget_resize(). Cheers ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Shrinking and growing widgets in GTK+ 3.x
On Thu, 2010-12-02 at 00:56 +, 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) http://git.gnome.org/browse/totem/tree/src/backend/video-utils.c#n197 It's pretty gruesome, but mostly works. For GTK+ 3.x, I wanted to clean that code. I tried saving our wanted size, calling gtk_widget_queue_resize() and wait for -get_preferred_{width,height} to be called, and set the wanted size as the natural size. Problem is that this only worked when growing the window, not shrinking it. My current backup plan was to do the above in 2 steps: - save our wanted size and queue a resize * set the natural size to 1x1, and queue an idle handler - idle handler calls gtk_widget_queue_resize() * set the natural size to the actual wanted size This is just about as gruesome as the original GTK+ 2.x code. Does anyone have a better idea on how i implement my own sync-ish gtk_widget_resize(). You want your toplevel GtkWindow to shrink because of the new video size ? or you just want your canvas to fit the video size in a user resizable toplevel ? Lets assume you have a derived GtkWidget which is the VideoDisplay and that it implements get_preferred_width()/get_preferred_height(). Pack it into something in your UI (whatever it is) and set the valign/halign GtkWidget properties to GTK_ALIGN_CENTER. When the stream's video sizes is detected, queue a resize on VideoDisplay and it will be re-requested (and just return the video size from the get_preferred_width()/height() vfuncs on VideoDisplay). If you want the whole window to shrink, a.) that's a little yuck, I'm not sure how much end-users like that behaviour ... b.) GTK+ doesnt like doing that... but if I recall correctly you might provoke GTK+ to do that by calling gtk_container_check_resize()... I'd have to take a deeper look to make sure. Cheers, -Tristan ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list