[epiphany] ephy-removable-pixbuf-renderer: use the pixbuf size to determine the position of the close x



commit 2f7c4405bd300e90e7c46454473208bd486a69ab
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu Aug 30 11:21:08 2012 +0300

    ephy-removable-pixbuf-renderer: use the pixbuf size to determine the position of the close x

 lib/widgets/ephy-removable-pixbuf-renderer.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/lib/widgets/ephy-removable-pixbuf-renderer.c b/lib/widgets/ephy-removable-pixbuf-renderer.c
index 48d8be0..8c113a0 100644
--- a/lib/widgets/ephy-removable-pixbuf-renderer.c
+++ b/lib/widgets/ephy-removable-pixbuf-renderer.c
@@ -52,20 +52,32 @@ get_icon_rectangle (GtkWidget *widget,
 		    GdkRectangle *rectangle)
 {
   GtkTextDirection direction;
-  gint x_offset, xpad, ypad;
+  gint x_offset, y_offset, xpad, ypad;
   gint icon_size;
+  gint w = 0, h = 0;
+  GdkPixbuf *pixbuf;
 
   gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
   direction = gtk_widget_get_direction (widget);
   icon_size = gdk_pixbuf_get_width (icon);
 
+  g_object_get (cell, "pixbuf", &pixbuf, NULL);
+  if (pixbuf) {
+    w = gdk_pixbuf_get_width (pixbuf);
+    h = gdk_pixbuf_get_height (pixbuf);
+    g_object_unref (pixbuf);
+  }
+
+  x_offset = (cell_area->width - w)/2 + 10;
+  y_offset = (cell_area->height - h)/2 + 9;
+
   if (direction == GTK_TEXT_DIR_RTL)
-    x_offset = xpad + 10;
+    x_offset += xpad;
   else
-    x_offset = cell_area->width - icon_size - xpad - 10;
+    x_offset = cell_area->width - icon_size - xpad - x_offset;
 
   rectangle->x = cell_area->x + x_offset;
-  rectangle->y = cell_area->y + ypad + 5;
+  rectangle->y = cell_area->y + ypad + y_offset;
   rectangle->width = rectangle->height = icon_size;
 }
 



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