[gimp] libgimpwidgets: add GimpChainButton::icon-size property



commit 8d6c7e42bf254d9334f298fb42aee2b9b1c8d6a2
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.

 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 09adc239cd..d47cc76318 100644
--- a/libgimpwidgets/gimpchainbutton.c
+++ b/libgimpwidgets/gimpchainbutton.c
@@ -54,7 +54,8 @@
 enum
 {
   PROP_0,
-  PROP_POSITION
+  PROP_POSITION,
+  PROP_ICON_SIZE
 };
 
 enum
@@ -146,6 +147,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
@@ -222,6 +239,10 @@ gimp_chain_button_set_property (GObject      *object,
       private->position = g_value_get_enum (value);
       break;
 
+    case PROP_ICON_SIZE:
+      g_object_set_property (G_OBJECT (private->image), "icon-size", value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -242,6 +263,10 @@ gimp_chain_button_get_property (GObject    *object,
       g_value_set_enum (value, private->position);
       break;
 
+    case PROP_ICON_SIZE:
+      g_object_get_property (G_OBJECT (private->image), "icon-size", value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -274,6 +299,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.
@@ -364,7 +433,7 @@ gimp_chain_button_update_image (GimpChainButton *button)
 
   gtk_image_set_from_icon_name (GTK_IMAGE (private->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 51b843f136..317500a3f7 100644
--- a/libgimpwidgets/gimpchainbutton.h
+++ b/libgimpwidgets/gimpchainbutton.h
@@ -73,13 +73,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);
 
 GtkWidget * gimp_chain_button_get_button (GimpChainButton   *button);
 


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