[gtk+] imagedefinition: Remove icon-size



commit 4a42aa5229e0ba80cf4673c67575ef57d60ae6c5
Author: Benjamin Otte <otte redhat com>
Date:   Tue Dec 1 04:44:29 2015 +0100

    imagedefinition: Remove icon-size
    
    The size of icons is a property that is relevant to who is rendering the
    icon, not to the icon itself.
    
    Example: Starting a DND operation from an entry icon should cause the
    icon to resize (from the entr icon's size to the DND icon size).

 gtk/gtkdnd.c                    |    9 ++++---
 gtk/gtkdragsource.c             |    6 ++--
 gtk/gtkiconhelper.c             |   18 +++++++---------
 gtk/gtkimagedefinition.c        |   43 +++-----------------------------------
 gtk/gtkimagedefinitionprivate.h |   13 +++--------
 5 files changed, 24 insertions(+), 65 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index b5dfe09..81abab0 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -2491,7 +2491,7 @@ gtk_drag_begin_internal (GtkWidget          *widget,
         }
       else
         {
-          icon = gtk_image_definition_new_icon_name ("text-x-generic", GTK_ICON_SIZE_DND);
+          icon = gtk_image_definition_new_icon_name ("text-x-generic");
           set_icon_helper (info->context, icon, 0, 0, FALSE);
           gtk_image_definition_unref (icon);
         }
@@ -2777,6 +2777,7 @@ set_icon_helper (GdkDragContext     *context,
       _gtk_icon_helper_set_window (info->icon_helper, gdk_drag_context_get_source_window (context));
     }
   _gtk_icon_helper_set_definition (info->icon_helper, def);
+  _gtk_icon_helper_set_icon_size (info->icon_helper, GTK_ICON_SIZE_DND);
 
   display = gdk_window_get_display (gdk_drag_context_get_source_window (context));
   _gtk_icon_helper_get_size (info->icon_helper, 
@@ -2902,7 +2903,7 @@ gtk_drag_set_icon_stock (GdkDragContext *context,
   g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
   g_return_if_fail (stock_id != NULL);
 
-  def = gtk_image_definition_new_stock (stock_id, GTK_ICON_SIZE_DND);
+  def = gtk_image_definition_new_stock (stock_id);
   set_icon_helper (context, def, hot_x, hot_y, FALSE);
 
   gtk_image_definition_unref (def);
@@ -3080,7 +3081,7 @@ gtk_drag_set_icon_name (GdkDragContext *context,
   g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
   g_return_if_fail (icon_name != NULL);
 
-  def = gtk_image_definition_new_icon_name (icon_name, GTK_ICON_SIZE_DND);
+  def = gtk_image_definition_new_icon_name (icon_name);
   set_icon_helper (context, def, hot_x, hot_y, FALSE);
 
   gtk_image_definition_unref (def);
@@ -3111,7 +3112,7 @@ gtk_drag_set_icon_gicon (GdkDragContext *context,
   g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
   g_return_if_fail (icon != NULL);
 
-  def = gtk_image_definition_new_gicon (icon, GTK_ICON_SIZE_DND);
+  def = gtk_image_definition_new_gicon (icon);
   set_icon_helper (context, def, hot_x, hot_y, FALSE);
 
   gtk_image_definition_unref (def);
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index 5a46022..6713b99 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -396,7 +396,7 @@ gtk_drag_source_set_icon_stock (GtkWidget   *widget,
   g_return_if_fail (site != NULL);
 
   gtk_image_definition_unref (site->image_def);
-  site->image_def = gtk_image_definition_new_stock (stock_id, GTK_ICON_SIZE_DND);
+  site->image_def = gtk_image_definition_new_stock (stock_id);
 }
 
 /**
@@ -422,7 +422,7 @@ gtk_drag_source_set_icon_name (GtkWidget   *widget,
   g_return_if_fail (site != NULL);
 
   gtk_image_definition_unref (site->image_def);
-  site->image_def = gtk_image_definition_new_icon_name (icon_name, GTK_ICON_SIZE_DND);
+  site->image_def = gtk_image_definition_new_icon_name (icon_name);
 }
 
 /**
@@ -448,6 +448,6 @@ gtk_drag_source_set_icon_gicon (GtkWidget *widget,
   g_return_if_fail (site != NULL);
 
   gtk_image_definition_unref (site->image_def);
-  site->image_def = gtk_image_definition_new_gicon (icon, GTK_ICON_SIZE_DND);
+  site->image_def = gtk_image_definition_new_gicon (icon);
 }
 
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 1429fda..126c81d 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -53,8 +53,6 @@ static void
 gtk_icon_helper_take_definition (GtkIconHelper      *self,
                                  GtkImageDefinition *def)
 {
-  GtkIconSize icon_size;
-
   _gtk_icon_helper_clear (self);
 
   if (def == NULL)
@@ -63,10 +61,6 @@ gtk_icon_helper_take_definition (GtkIconHelper      *self,
   gtk_image_definition_unref (self->priv->def);
   self->priv->def = def;
 
-  icon_size = gtk_image_definition_get_icon_size (def);
-  if (icon_size != GTK_ICON_SIZE_INVALID)
-    self->priv->icon_size = icon_size;
-  
   _gtk_icon_helper_invalidate (self);
 }
 
@@ -891,7 +885,8 @@ _gtk_icon_helper_set_gicon (GtkIconHelper *self,
                             GIcon *gicon,
                             GtkIconSize icon_size)
 {
-  gtk_icon_helper_take_definition (self, gtk_image_definition_new_gicon (gicon, icon_size));
+  gtk_icon_helper_take_definition (self, gtk_image_definition_new_gicon (gicon));
+  _gtk_icon_helper_set_icon_size (self, icon_size);
 }
 
 void 
@@ -899,7 +894,8 @@ _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
                                 const gchar *icon_name,
                                 GtkIconSize icon_size)
 {
-  gtk_icon_helper_take_definition (self, gtk_image_definition_new_icon_name (icon_name, icon_size));
+  gtk_icon_helper_take_definition (self, gtk_image_definition_new_icon_name (icon_name));
+  _gtk_icon_helper_set_icon_size (self, icon_size);
 }
 
 void 
@@ -907,7 +903,8 @@ _gtk_icon_helper_set_icon_set (GtkIconHelper *self,
                                GtkIconSet *icon_set,
                                GtkIconSize icon_size)
 {
-  gtk_icon_helper_take_definition (self, gtk_image_definition_new_icon_set (icon_set, icon_size));
+  gtk_icon_helper_take_definition (self, gtk_image_definition_new_icon_set (icon_set));
+  _gtk_icon_helper_set_icon_size (self, icon_size);
 }
 
 void 
@@ -936,7 +933,8 @@ _gtk_icon_helper_set_stock_id (GtkIconHelper *self,
                                const gchar *stock_id,
                                GtkIconSize icon_size)
 {
-  gtk_icon_helper_take_definition (self, gtk_image_definition_new_stock (stock_id, icon_size));
+  gtk_icon_helper_take_definition (self, gtk_image_definition_new_stock (stock_id));
+  _gtk_icon_helper_set_icon_size (self, icon_size);
 }
 
 gboolean
diff --git a/gtk/gtkimagedefinition.c b/gtk/gtkimagedefinition.c
index 1486031..351dbe4 100644
--- a/gtk/gtkimagedefinition.c
+++ b/gtk/gtkimagedefinition.c
@@ -48,7 +48,6 @@ struct _GtkImageDefinitionStock {
   gint ref_count;
 
   char *id;
-  GtkIconSize icon_size;
 };
 
 struct _GtkImageDefinitionIconSet {
@@ -56,7 +55,6 @@ struct _GtkImageDefinitionIconSet {
   gint ref_count;
 
   GtkIconSet *icon_set;
-  GtkIconSize icon_size;
 };
 
 struct _GtkImageDefinitionAnimation {
@@ -72,7 +70,6 @@ struct _GtkImageDefinitionIconName {
   gint ref_count;
 
   char *icon_name;
-  GtkIconSize icon_size;
 };
 
 struct _GtkImageDefinitionGIcon {
@@ -80,7 +77,6 @@ struct _GtkImageDefinitionGIcon {
   gint ref_count;
 
   GIcon *gicon;
-  GtkIconSize icon_size;
 };
 
 struct _GtkImageDefinitionSurface {
@@ -152,8 +148,7 @@ gtk_image_definition_new_pixbuf (GdkPixbuf *pixbuf,
 }
 
 GtkImageDefinition *
-gtk_image_definition_new_stock (const char  *stock_id,
-                                GtkIconSize  icon_size)
+gtk_image_definition_new_stock (const char *stock_id)
 {
   GtkImageDefinition *def;
 
@@ -162,14 +157,12 @@ gtk_image_definition_new_stock (const char  *stock_id,
 
   def = gtk_image_definition_alloc (GTK_IMAGE_STOCK);
   def->stock.id = g_strdup (stock_id);
-  def->stock.icon_size = icon_size;
 
   return def;
 }
 
 GtkImageDefinition *
-gtk_image_definition_new_icon_set (GtkIconSet  *icon_set,
-                                   GtkIconSize  icon_size)
+gtk_image_definition_new_icon_set (GtkIconSet *icon_set)
 {
   GtkImageDefinition *def;
 
@@ -180,7 +173,6 @@ gtk_image_definition_new_icon_set (GtkIconSet  *icon_set,
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   def->icon_set.icon_set = gtk_icon_set_ref (icon_set);
 G_GNUC_END_IGNORE_DEPRECATIONS;
-  def->icon_set.icon_size = icon_size;
 
   return def;
 }
@@ -202,8 +194,7 @@ gtk_image_definition_new_animation (GdkPixbufAnimation *animation,
 }
 
 GtkImageDefinition *
-gtk_image_definition_new_icon_name (const char  *icon_name,
-                                    GtkIconSize  icon_size)
+gtk_image_definition_new_icon_name (const char *icon_name)
 {
   GtkImageDefinition *def;
 
@@ -212,14 +203,12 @@ gtk_image_definition_new_icon_name (const char  *icon_name,
 
   def = gtk_image_definition_alloc (GTK_IMAGE_ICON_NAME);
   def->icon_name.icon_name = g_strdup (icon_name);
-  def->icon_name.icon_size = icon_size;
 
   return def;
 }
 
 GtkImageDefinition *
-gtk_image_definition_new_gicon (GIcon       *gicon,
-                                GtkIconSize  icon_size)
+gtk_image_definition_new_gicon (GIcon *gicon)
 {
   GtkImageDefinition *def;
 
@@ -228,7 +217,6 @@ gtk_image_definition_new_gicon (GIcon       *gicon,
 
   def = gtk_image_definition_alloc (GTK_IMAGE_GICON);
   def->gicon.gicon = g_object_ref (gicon);
-  def->gicon.icon_size = icon_size;
 
   return def;
 }
@@ -303,29 +291,6 @@ gtk_image_definition_get_storage_type (const GtkImageDefinition *def)
   return def->type;
 }
 
-GtkIconSize
-gtk_image_definition_get_icon_size (const GtkImageDefinition *def)
-{
-  switch (def->type)
-    {
-    default:
-      g_assert_not_reached ();
-    case GTK_IMAGE_EMPTY:
-    case GTK_IMAGE_PIXBUF:
-    case GTK_IMAGE_ANIMATION:
-    case GTK_IMAGE_SURFACE:
-      return GTK_ICON_SIZE_INVALID;
-    case GTK_IMAGE_STOCK:
-      return def->stock.icon_size;
-    case GTK_IMAGE_ICON_SET:
-      return def->icon_set.icon_size;
-    case GTK_IMAGE_ICON_NAME:
-      return def->icon_name.icon_size;
-    case GTK_IMAGE_GICON:
-      return def->gicon.icon_size;
-    }
-}
-
 gint
 gtk_image_definition_get_scale (const GtkImageDefinition *def)
 {
diff --git a/gtk/gtkimagedefinitionprivate.h b/gtk/gtkimagedefinitionprivate.h
index 63a580d..b9111ad 100644
--- a/gtk/gtkimagedefinitionprivate.h
+++ b/gtk/gtkimagedefinitionprivate.h
@@ -28,23 +28,18 @@ typedef union _GtkImageDefinition GtkImageDefinition;
 GtkImageDefinition *    gtk_image_definition_new_empty          (void);
 GtkImageDefinition *    gtk_image_definition_new_pixbuf         (GdkPixbuf                      *pixbuf,
                                                                  int                             scale);
-GtkImageDefinition *    gtk_image_definition_new_stock          (const char                     *stock_id,
-                                                                 GtkIconSize                     icon_size);
-GtkImageDefinition *    gtk_image_definition_new_icon_set       (GtkIconSet                     *icon_set,
-                                                                 GtkIconSize                     icon_size);
+GtkImageDefinition *    gtk_image_definition_new_stock          (const char                     *stock_id);
+GtkImageDefinition *    gtk_image_definition_new_icon_set       (GtkIconSet                     *icon_set);
 GtkImageDefinition *    gtk_image_definition_new_animation      (GdkPixbufAnimation             *animation,
                                                                  int                             scale);
-GtkImageDefinition *    gtk_image_definition_new_icon_name      (const char                     *icon_name,
-                                                                 GtkIconSize                     icon_size);
-GtkImageDefinition *    gtk_image_definition_new_gicon          (GIcon                          *gicon,
-                                                                 GtkIconSize                     icon_size);
+GtkImageDefinition *    gtk_image_definition_new_icon_name      (const char                     *icon_name);
+GtkImageDefinition *    gtk_image_definition_new_gicon          (GIcon                          *gicon);
 GtkImageDefinition *    gtk_image_definition_new_surface        (cairo_surface_t                *surface);
 
 GtkImageDefinition *    gtk_image_definition_ref                (GtkImageDefinition             *def);
 void                    gtk_image_definition_unref              (GtkImageDefinition             *def);
 
 gboolean                gtk_image_definition_get_storage_type   (const GtkImageDefinition       *def);
-GtkIconSize             gtk_image_definition_get_icon_size      (const GtkImageDefinition       *def);
 gint                    gtk_image_definition_get_scale          (const GtkImageDefinition       *def);
 GdkPixbuf *             gtk_image_definition_get_pixbuf         (const GtkImageDefinition       *def);
 const gchar *           gtk_image_definition_get_stock          (const GtkImageDefinition       *def);


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