src/gtkimhtml.c

changeset 11840
c9ec5a42d420
parent 11820
534903b9226e
child 11844
57ad7c52cc9c
--- a/src/gtkimhtml.c	Wed Oct 26 05:59:26 2005 +0000
+++ b/src/gtkimhtml.c	Wed Oct 26 08:35:12 2005 +0000
@@ -381,7 +381,7 @@
 	}
 }
 
-static gboolean gtk_size_allocate_cb(GtkIMHtml *widget, GtkAllocation *alloc, gpointer user_data)
+static void gtk_size_allocate_cb(GtkIMHtml *widget, GtkAllocation *alloc, gpointer user_data)
 {
 	GdkRectangle rect;
 	int xminus;
@@ -403,7 +403,7 @@
 	}
 
 	widget->old_rect = rect;
-	return FALSE;
+	return;
 }
 
 static gint
@@ -3152,22 +3152,19 @@
 	GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale;
 
 	if(image->width > width || image->height > height){
+		double ratio_w, ratio_h, ratio;
+		int new_h, new_w;
 		GdkPixbuf *new_image = NULL;
-		float factor;
-		int new_width = image->width, new_height = image->height;
-
-		if(image->width > (width - 2)){
-			factor = (float)(width)/image->width;
-			new_width = width;
-			new_height = image->height * factor;
-		}
-		if(new_height >= (height - 2)){
-			factor = (float)(height)/new_height;
-			new_height = height;
-			new_width = new_width * factor;
-		}
-
-		new_image = gdk_pixbuf_scale_simple(image->pixbuf, new_width, new_height, GDK_INTERP_BILINEAR);
+
+		ratio_w = ((double)width - 2) / image->width;
+		ratio_h = ((double)height - 2) / image->height;
+
+		ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h;
+
+		new_w = (int)(image->width * ratio);
+		new_h = (int)(image->height * ratio);
+
+		new_image = gdk_pixbuf_scale_simple(image->pixbuf, new_w, new_h, GDK_INTERP_BILINEAR);
 		gtk_image_set_from_pixbuf(image->image, new_image);
 		g_object_unref(G_OBJECT(new_image));
 	}

mercurial