? libxfcegui4-config.h Index: xfce_scaled_image.c =================================================================== RCS file: /var/cvs/xfce/xfce4/libxfcegui4/libxfcegui4/xfce_scaled_image.c,v retrieving revision 1.4 diff -u -r1.4 xfce_scaled_image.c --- xfce_scaled_image.c 28 Oct 2004 12:50:23 -0000 1.4 +++ xfce_scaled_image.c 2 Nov 2004 12:56:37 -0000 @@ -44,7 +44,6 @@ static gboolean xfce_scaled_image_scale (XfceScaledImage * image); -static void image_style_set (GtkWidget * widget, GtkStyle * old); /* Local data */ @@ -93,6 +92,15 @@ widget_class->size_allocate = xfce_scaled_image_size_allocate; gobject_class->finalize = xfce_scaled_image_finalize; + + gtk_rc_parse_string ("\n" + " style \"scaled-image-style\"\n" + " {\n" + " xthickness=0\n" + " ythickness=0\n" + " }\n" "\n" + " widget \"*.scaled-image\" style \"scaled-image-style\"\n" + "\n"); } static void @@ -100,16 +108,17 @@ { image->width = image->height = -1; image->pb = NULL; - - /* force style thickness programmatically */ - g_signal_connect (image, "style-set", - G_CALLBACK (image_style_set), NULL); } GtkWidget * xfce_scaled_image_new (void) { - return GTK_WIDGET (g_object_new (xfce_scaled_image_get_type (), NULL)); + GtkWidget *widget = + GTK_WIDGET (g_object_new (xfce_scaled_image_get_type (), NULL)); + + gtk_widget_set_name (widget, "scaled-image"); + + return widget; } GtkWidget * @@ -138,7 +147,7 @@ if (image->pb) g_object_ref (image->pb); - if (image->width > 0) + if (image->width > 1) { xfce_scaled_image_scale (image); } @@ -167,6 +176,25 @@ G_OBJECT_CLASS (parent_class)->finalize (object); } +static gboolean +_image_needs_scaling (XfceScaledImage *image) +{ + GtkAllocation *allocation = &(GTK_WIDGET (image)->allocation); + + /* use two pixel margin to reduce rescaling */ + if (image->width <= allocation->width + && image->height <= allocation->height + && image->width > allocation->width - 2 + && image->height > allocation->height - 2) + { + return FALSE; + } + else + { + return TRUE; + } +} + static void xfce_scaled_image_size_allocate (GtkWidget * widget, GtkAllocation * allocation) @@ -181,8 +209,7 @@ widget->allocation = *allocation; - if (image->width != allocation->width || - image->height != allocation->height) + if (_image_needs_scaling (image)) { image->width = allocation->width; image->height = allocation->height; @@ -215,8 +242,8 @@ pw = gdk_pixbuf_get_width (image->pb); ph = gdk_pixbuf_get_height (image->pb); - w = image->width <= 0 ? pw : image->width; - h = image->height <= 0 ? ph : image->height; + w = image->width <= 1 ? pw : image->width; + h = image->height <= 1 ? ph : image->height; if (w >= pw && h >= ph) { @@ -250,25 +277,3 @@ return TRUE; } -static void -real_style_set (GtkWidget * widget, GtkStyle * old) -{ - GtkRcStyle *style; - - style = gtk_widget_get_modifier_style (widget); - style->xthickness = style->ythickness = 0; - gtk_widget_modify_style (widget, style); -} - -static void -image_style_set (GtkWidget * widget, GtkStyle * old) -{ - static int recursive = 0; - - if (recursive > 0) - return; - - recursive++; - real_style_set (widget, old); - recursive--; -}