Re: gtk_widget_set_size_request stopped working with GTK3



Hi Tristan
 
> I must admit the docs are incorrect about this, it says:
> 
>    "Sets the minimum size of a widget; that is, the widget's size request will be width by height. You can use this function to force a widget to be either larger or smaller than it normally would be."
> 
> But what it should say:
> 
>    "Sets the minimum size of a widget; that is, the widget's size request will be width by height. You can use this function to force a widget to be larger than it normally would be."

Thanks for the clarification.  Although, I am not convinced that restricting it to only allow enlarging the min size is desirable.  If an application really wants to make a widget smaller and accepts that content may get clipped, why not allowing gtk_widget_set_size_request setting a smaller size, like it was in GTK2?
 
> In other words, as Cosimo already mentioned in the report, a widget can never be smaller than the minimum size reported by the implementation.
> 
> He also mentioned that you can configure that particular widget to actually be smaller.

The suggested solution was using the "pixel-size" property which does not do anything when using a GdkPixBuf as image.  The min size of the GtkImage will be the size of the GdkPixBuf.  If that one is large, so will be the GtkImage. If an application accepts image filenames typed in by a user, and thus does not know a-priori the size of an image, the GtkImage might spawn a size larger than the screen. 
 
> Two other options are:
>   o If you cant display the whole widget, put it in a scrolled window

I tried that as well.  When using the GTK_POLICY_NEVER scrollbar policy, the min size of the GtkScrolledWindow becomes the min size of the GtkImage.

>   o Use clutter-gtk library to put the GtkWidget one a stage and then scale it and transform it to the desired size ;-)

I would prefer not using additonal libs and don't need any scaling or transformations, just clipping and centering.

Here is what I am trying to do.

I have an image.  The center part of the image contains a logo that I want to display to the user.  Around the center part there is little extra content that is not important but nice to have.  With GTK2 I set the min size (properties "with-request" and "height-request") to just about the size of the logo, place the GtkImage into a GtkWindow, set the default size of the GtkWindow to slightly larger than the min size but smaller than the fulll size of the image, make the window resizable, and show it to the user.  GtkImage in GTK2 automatically clipped the image and centered it.  The user can enlarge the window and see more of the image, or shrink it down to the min size where only the logo stays visible.

I have not found a way yet to achive the same with GTK3.

Steffen  



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