Re: gtk_widget_set_size_request stopped working with GTK3



Lets not go around the merry-go-round one more time.

In GTK+3, widgets receive *at least* what they requested in the size
requesting phase.

User facing apis cannot undermine the minimal requirements for the geometry
which a widget has requested.

User facing apis can however, enforce a minimum size (i.e. the widget
will be at least "this big")
or they can configure a widget in such a way that it will require less size.

The "pixel-size" thing not working for pixbufs could be considered an
enhancement
request bug for GtkImage.

i.e. it should support clipping of pixbufs (and then, it should also
need some alignment
parameters to decide which portion of the input image should be
clipped, also pixel-size
does not really imply clipping directly, the user might very well
expect the image to scale
to the desired size).

On Sat, Sep 29, 2012 at 2:28 AM, Steffen Gutmann <muibase yahoo com> wrote:
[...]
> 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.

a.) Create a GtkDrawingArea

b.) Connect to "draw" signal

c.) Use this code:

   gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
   cairo_paint (cr);
   (borrowed directly from:
http://developer.gnome.org/gtk3/3.5/gtk-migrating-2-to-3.html)


The above should pretty much get you what you want, just consider the widget's
allocation at "draw" time and use that to offset the given x,y for
gdk_cairo_set_source_pixbuf().

Cheers,
             -Tristan


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