[gtk+] imagemenuitem: No need to query image size by default



commit a85883ba2b2dcd83d2c7456e547a8550c4e2c236
Author: Benjamin Otte <otte redhat com>
Date:   Sat Apr 30 05:31:05 2011 +0200

    imagemenuitem: No need to query image size by default
    
    Also makes the code look nicer, so woohoo

 gtk/gtkimagemenuitem.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c
index f3d60ea..69fea65 100644
--- a/gtk/gtkimagemenuitem.c
+++ b/gtk/gtkimagemenuitem.c
@@ -439,7 +439,6 @@ gtk_image_menu_item_get_preferred_width (GtkWidget        *widget,
 {
   GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
   GtkImageMenuItemPrivate *priv = image_menu_item->priv;
-  gint child_width = 0;
   GtkPackDirection pack_dir;
   GtkWidget *parent;
 
@@ -450,21 +449,18 @@ gtk_image_menu_item_get_preferred_width (GtkWidget        *widget,
   else
     pack_dir = GTK_PACK_DIRECTION_LTR;
 
-  if (priv->image && gtk_widget_get_visible (priv->image))
-    {
-      GtkRequisition child_requisition;
-
-      gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
-
-      child_width = child_requisition.width;
-    }
-
   GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);
 
-  if (pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT)
+  if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
+      priv->image &&
+      gtk_widget_get_visible (priv->image))
     {
-      *minimum = MAX (*minimum, child_width);
-      *natural = MAX (*natural, child_width);
+      gint child_minimum, child_natural;
+
+      gtk_widget_get_preferred_width (priv->image, &child_minimum, &child_natural);
+
+      *minimum = MAX (*minimum, child_minimum);
+      *natural = MAX (*natural, child_natural);
     }
 }
 



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