[gimp/gimp-2-10] libgimpwidgets: add GimpChainButton::icon-size property



commit fcfe6997cd86503904c739fbb2df9dcf89e884cb
Author: Ell <ell_se yahoo com>
Date:   Mon Feb 4 11:57:28 2019 -0500

    libgimpwidgets: add GimpChainButton::icon-size property
    
    ... and corresponding gimp_chain_button_{get,size}_icon_size()
    functions, which control the chain-button's icon size.
    
    (cherry picked from commit 8d6c7e42bf254d9334f298fb42aee2b9b1c8d6a2)

 libgimpwidgets/gimpchainbutton.c | 73 ++++++++++++++++++++++++++++++++++++++--
 libgimpwidgets/gimpchainbutton.h | 14 +++++---
 2 files changed, 80 insertions(+), 7 deletions(-)
---
diff --git a/libgimpwidgets/gimpchainbutton.c b/libgimpwidgets/gimpchainbutton.c
index 8ce2a9e568..773b51484d 100644
--- a/libgimpwidgets/gimpchainbutton.c
+++ b/libgimpwidgets/gimpchainbutton.c
@@ -54,7 +54,8 @@
 enum
 {
   PROP_0,
-  PROP_POSITION
+  PROP_POSITION,
+  PROP_ICON_SIZE
 };
 
 enum
@@ -131,6 +132,22 @@ gimp_chain_button_class_init (GimpChainButtonClass *klass)
                                                       GIMP_CHAIN_TOP,
                                                       G_PARAM_CONSTRUCT_ONLY |
                                                       GIMP_PARAM_READWRITE));
+
+  /**
+   * GimpChainButton:icon-size:
+   *
+   * The chain button icon size.
+   *
+   * Since: 2.10.10
+   */
+  g_object_class_install_property (object_class, PROP_ICON_SIZE,
+                                   g_param_spec_enum ("icon-size",
+                                                      "Icon Size",
+                                                      "The chain's icon size",
+                                                      GTK_TYPE_ICON_SIZE,
+                                                      GTK_ICON_SIZE_BUTTON,
+                                                      G_PARAM_CONSTRUCT |
+                                                      GIMP_PARAM_READWRITE));
 }
 
 static void
@@ -202,6 +219,10 @@ gimp_chain_button_set_property (GObject      *object,
       button->position = g_value_get_enum (value);
       break;
 
+    case PROP_ICON_SIZE:
+      g_object_set_property (G_OBJECT (button->image), "icon-size", value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -222,6 +243,10 @@ gimp_chain_button_get_property (GObject    *object,
       g_value_set_enum (value, button->position);
       break;
 
+    case PROP_ICON_SIZE:
+      g_object_get_property (G_OBJECT (button->image), "icon-size", value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -254,6 +279,50 @@ gimp_chain_button_new (GimpChainPosition position)
                        NULL);
 }
 
+/**
+ * gimp_chain_button_set_icon_size:
+ * @button: Pointer to a #GimpChainButton.
+ * @size: The new icon size.
+ *
+ * Sets the icon size of the #GimpChainButton.
+ *
+ * Since: 2.10.10
+ */
+void
+gimp_chain_button_set_icon_size (GimpChainButton *button,
+                                 GtkIconSize      size)
+{
+  g_return_if_fail (GIMP_IS_CHAIN_BUTTON (button));
+
+  g_object_set (button,
+                "icon-size", size,
+                NULL);
+}
+
+/**
+ * gimp_chain_button_get_icon_size:
+ * @button: Pointer to a #GimpChainButton.
+ *
+ * Gets the icon size of the #GimpChainButton.
+ *
+ * Returns: The icon size.
+ *
+ * Since: 2.10.10
+ */
+GtkIconSize
+gimp_chain_button_get_icon_size (GimpChainButton *button)
+{
+  GtkIconSize size;
+
+  g_return_val_if_fail (GIMP_IS_CHAIN_BUTTON (button), GTK_ICON_SIZE_BUTTON);
+
+  g_object_get (button,
+                "icon-size", &size,
+                NULL);
+
+  return size;
+}
+
 /**
  * gimp_chain_button_set_active:
  * @button: Pointer to a #GimpChainButton.
@@ -312,7 +381,7 @@ gimp_chain_button_update_image (GimpChainButton *button)
 
   gtk_image_set_from_icon_name (GTK_IMAGE (button->image),
                                 gimp_chain_icon_names[i],
-                                GTK_ICON_SIZE_BUTTON);
+                                gimp_chain_button_get_icon_size (button));
 }
 
 
diff --git a/libgimpwidgets/gimpchainbutton.h b/libgimpwidgets/gimpchainbutton.h
index 0a77b6fc9f..b89f7e91f4 100644
--- a/libgimpwidgets/gimpchainbutton.h
+++ b/libgimpwidgets/gimpchainbutton.h
@@ -74,13 +74,17 @@ struct _GimpChainButtonClass
 };
 
 
-GType       gimp_chain_button_get_type   (void) G_GNUC_CONST;
+GType         gimp_chain_button_get_type      (void) G_GNUC_CONST;
 
-GtkWidget * gimp_chain_button_new        (GimpChainPosition  position);
+GtkWidget   * gimp_chain_button_new           (GimpChainPosition  position);
 
-void        gimp_chain_button_set_active (GimpChainButton   *button,
-                                          gboolean           active);
-gboolean    gimp_chain_button_get_active (GimpChainButton   *button);
+void          gimp_chain_button_set_icon_size (GimpChainButton   *button,
+                                               GtkIconSize        size);
+GtkIconSize   gimp_chain_button_get_icon_size (GimpChainButton   *button);
+
+void          gimp_chain_button_set_active    (GimpChainButton   *button,
+                                               gboolean           active);
+gboolean      gimp_chain_button_get_active    (GimpChainButton   *button);
 
 
 G_END_DECLS


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