[gtk+] Change icon-size properties



commit d9a146f54aa73c4d11687f0fe2c9464ae0832508
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 15 14:20:40 2017 -0500

    Change icon-size properties
    
    We no longer support registering custom icon sizes, so
    we can make these properties just enums. This also lets
    us specify them by nick in ui files. Nice!

 gtk/gtkimage.c         |   36 ++++++++++++++++++++++++++----------
 gtk/gtkstackswitcher.c |   21 +++++++++++----------
 2 files changed, 37 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 48968f4..f9af644 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -174,12 +174,12 @@ gtk_image_class_init (GtkImageClass *class)
                            GTK_PARAM_READWRITE);
 
   image_props[PROP_ICON_SIZE] =
-      g_param_spec_int ("icon-size",
-                        P_("Icon size"),
-                        P_("Symbolic size to use for icon set or named icon"),
-                        0, G_MAXINT,
-                        GTK_ICON_SIZE_INHERIT,
-                        GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+      g_param_spec_enum ("icon-size",
+                         P_("Icon size"),
+                         P_("Symbolic size to use for icon set or named icon"),
+                         GTK_TYPE_ICON_SIZE,
+                         GTK_ICON_SIZE_INHERIT,
+                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
 
   /**
    * GtkImage:pixel-size:
@@ -321,7 +321,7 @@ gtk_image_set_property (GObject      *object,
       gtk_image_set_from_file (image, g_value_get_string (value));
       break;
     case PROP_ICON_SIZE:
-      gtk_image_set_icon_size (image, g_value_get_int (value));
+      gtk_image_set_icon_size (image, g_value_get_enum (value));
       break;
     case PROP_PIXEL_SIZE:
       gtk_image_set_pixel_size (image, g_value_get_int (value));
@@ -368,7 +368,7 @@ gtk_image_get_property (GObject     *object,
       g_value_set_string (value, priv->filename);
       break;
     case PROP_ICON_SIZE:
-      g_value_set_int (value, priv->icon_size);
+      g_value_set_enum (value, priv->icon_size);
       break;
     case PROP_PIXEL_SIZE:
       g_value_set_int (value, _gtk_icon_helper_get_pixel_size (&priv->icon_helper));
@@ -522,7 +522,11 @@ gtk_image_new_from_surface (cairo_surface_t *surface)
  * If the icon name isn’t known, a “broken image” icon will be
  * displayed instead.  If the current icon theme is changed, the icon
  * will be updated appropriately.
- * 
+ *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Returns: a new #GtkImage displaying the themed icon
  *
  * Since: 2.6
@@ -547,7 +551,11 @@ gtk_image_new_from_icon_name (const gchar *icon_name)
  * If the icon name isn’t known, a “broken image” icon will be
  * displayed instead.  If the current icon theme is changed, the icon
  * will be updated appropriately.
- * 
+ *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Returns: a new #GtkImage displaying the themed icon
  *
  * Since: 2.14
@@ -832,6 +840,10 @@ gtk_image_set_from_pixbuf (GtkImage  *image,
  *
  * See gtk_image_new_from_icon_name() for details.
  *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Since: 2.6
  **/
 void
@@ -861,6 +873,10 @@ gtk_image_set_from_icon_name  (GtkImage    *image,
  *
  * See gtk_image_new_from_gicon() for details.
  *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Since: 2.14
  **/
 void
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index ebb3149..b686998 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -27,6 +27,7 @@
 #include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtkwidgetprivate.h"
+#include "gtktypebuiltins.h"
 
 /**
  * SECTION:gtkstackswitcher
@@ -65,7 +66,7 @@ struct _GtkStackSwitcherPrivate
 {
   GtkStack *stack;
   GHashTable *buttons;
-  gint icon_size;
+  GtkIconSize icon_size;
   gboolean in_child_changed;
   GtkWidget *switch_button;
   guint switch_timer;
@@ -558,7 +559,7 @@ gtk_stack_switcher_get_stack (GtkStackSwitcher *switcher)
 
 static void
 gtk_stack_switcher_set_icon_size (GtkStackSwitcher *switcher,
-                                  gint              icon_size)
+                                  GtkIconSize       icon_size)
 {
   GtkStackSwitcherPrivate *priv;
 
@@ -593,7 +594,7 @@ gtk_stack_switcher_get_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ICON_SIZE:
-      g_value_set_int (value, priv->icon_size);
+      g_value_set_enum (value, priv->icon_size);
       break;
 
     case PROP_STACK:
@@ -617,7 +618,7 @@ gtk_stack_switcher_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ICON_SIZE:
-      gtk_stack_switcher_set_icon_size (switcher, g_value_get_int (value));
+      gtk_stack_switcher_set_icon_size (switcher, g_value_get_enum (value));
       break;
 
     case PROP_STACK:
@@ -677,12 +678,12 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class)
    */
   g_object_class_install_property (object_class,
                                    PROP_ICON_SIZE,
-                                   g_param_spec_int ("icon-size",
-                                                     P_("Icon Size"),
-                                                     P_("Symbolic size to use for named icon"),
-                                                     0, G_MAXINT,
-                                                     GTK_ICON_SIZE_INHERIT,
-                                                     G_PARAM_EXPLICIT_NOTIFY | GTK_PARAM_READWRITE));
+                                   g_param_spec_enum ("icon-size",
+                                                      P_("Icon Size"),
+                                                      P_("Symbolic size to use for named icon"),
+                                                      GTK_TYPE_ICON_SIZE,
+                                                      GTK_ICON_SIZE_INHERIT,
+                                                      G_PARAM_EXPLICIT_NOTIFY | GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                    PROP_STACK,


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