[gimp] app: add gimp_spin_scale_set_label() and get_label()



commit 6940c007746edbec53b3d6548cbfc6491bccbff6
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 28 15:29:44 2013 +0200

    app: add gimp_spin_scale_set_label() and get_label()

 app/widgets/gimpspinscale.c |   56 ++++++++++++++++++++++++++++++------------
 app/widgets/gimpspinscale.h |   32 +++++++++++++----------
 2 files changed, 58 insertions(+), 30 deletions(-)
---
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index ecc65ab..9adb717 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -187,19 +187,12 @@ gimp_spin_scale_set_property (GObject      *object,
                               const GValue *value,
                               GParamSpec   *pspec)
 {
-  GimpSpinScalePrivate *private = GET_PRIVATE (object);
+  GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
 
   switch (property_id)
     {
     case PROP_LABEL:
-      g_free (private->label);
-      private->label = g_value_dup_string (value);
-      if (private->layout)
-        {
-          g_object_unref (private->layout);
-          private->layout = NULL;
-        }
-      gtk_widget_queue_resize (GTK_WIDGET (object));
+      gimp_spin_scale_set_label (scale, g_value_get_string (value));
       break;
 
     default:
@@ -214,12 +207,12 @@ gimp_spin_scale_get_property (GObject    *object,
                               GValue     *value,
                               GParamSpec *pspec)
 {
-  GimpSpinScalePrivate *private = GET_PRIVATE (object);
+  GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
 
   switch (property_id)
     {
     case PROP_LABEL:
-      g_value_set_string (value, private->label);
+      g_value_set_string (value, gimp_spin_scale_get_label (scale));
       break;
 
     default:
@@ -686,6 +679,41 @@ gimp_spin_scale_new (GtkAdjustment *adjustment,
 }
 
 void
+gimp_spin_scale_set_label (GimpSpinScale *scale,
+                           const gchar   *label)
+{
+  GimpSpinScalePrivate *private;
+
+  g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
+
+  private = GET_PRIVATE (scale);
+
+  if (label == private->label)
+    return;
+
+  g_free (private->label);
+  private->label = g_strdup (label);
+
+  if (private->layout)
+    {
+      g_object_unref (private->layout);
+      private->layout = NULL;
+    }
+
+  gtk_widget_queue_resize (GTK_WIDGET (scale));
+
+  g_object_notify (G_OBJECT (scale), "label");
+}
+
+const gchar *
+gimp_spin_scale_get_label (GimpSpinScale *scale)
+{
+  g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL);
+
+  return GET_PRIVATE (scale)->label;
+}
+
+void
 gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
                                   gdouble        lower,
                                   gdouble        upper)
@@ -765,11 +793,7 @@ gimp_spin_scale_set_gamma (GimpSpinScale *scale,
 gdouble
 gimp_spin_scale_get_gamma (GimpSpinScale *scale)
 {
-  GimpSpinScalePrivate *private;
-
   g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
 
-  private = GET_PRIVATE (scale);
-
-  return private->gamma;
+  return GET_PRIVATE (scale)->gamma;
 }
diff --git a/app/widgets/gimpspinscale.h b/app/widgets/gimpspinscale.h
index f3079d4..d7993a2 100644
--- a/app/widgets/gimpspinscale.h
+++ b/app/widgets/gimpspinscale.h
@@ -44,23 +44,27 @@ struct _GimpSpinScaleClass
 };
 
 
-GType       gimp_spin_scale_get_type           (void) G_GNUC_CONST;
+GType         gimp_spin_scale_get_type           (void) G_GNUC_CONST;
 
-GtkWidget * gimp_spin_scale_new                (GtkAdjustment *adjustment,
-                                                const gchar   *label,
-                                                gint           digits);
+GtkWidget   * gimp_spin_scale_new                (GtkAdjustment *adjustment,
+                                                  const gchar   *label,
+                                                  gint           digits);
 
-void        gimp_spin_scale_set_scale_limits   (GimpSpinScale *scale,
-                                                gdouble        lower,
-                                                gdouble        upper);
-void        gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale);
-gboolean    gimp_spin_scale_get_scale_limits   (GimpSpinScale *scale,
-                                                gdouble       *lower,
-                                                gdouble       *upper);
+void          gimp_spin_scale_set_label          (GimpSpinScale *scale,
+                                                  const gchar   *label);
+const gchar * gimp_spin_scale_get_label          (GimpSpinScale *scale);
 
-void        gimp_spin_scale_set_gamma          (GimpSpinScale *scale,
-                                                gdouble        gamma);
-gdouble     gimp_spin_scale_get_gamma          (GimpSpinScale *scale);
+void          gimp_spin_scale_set_scale_limits   (GimpSpinScale *scale,
+                                                  gdouble        lower,
+                                                  gdouble        upper);
+void          gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale);
+gboolean      gimp_spin_scale_get_scale_limits   (GimpSpinScale *scale,
+                                                  gdouble       *lower,
+                                                  gdouble       *upper);
+
+void          gimp_spin_scale_set_gamma          (GimpSpinScale *scale,
+                                                  gdouble        gamma);
+gdouble       gimp_spin_scale_get_gamma          (GimpSpinScale *scale);
 
 
 #endif  /*  __GIMP_SPIN_SCALE_H__  */


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