[gimp] app: add a "status-title" string property to GimpToolLine



commit 2da59e7ba39d407481f04b61fdd1b7cb73253ac5
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jul 3 01:02:23 2017 +0200

    app: add a "status-title" string property to GimpToolLine
    
    which defaults to "Line: ". Set it to "Blend: " in the blend tool.

 app/display/gimptoolline.c |   41 +++++++++++++++++++++++++++++++++++++++--
 app/tools/gimpblendtool.c  |    4 ++++
 2 files changed, 43 insertions(+), 2 deletions(-)
---
diff --git a/app/display/gimptoolline.c b/app/display/gimptoolline.c
index 3788b74..5a23d35 100644
--- a/app/display/gimptoolline.c
+++ b/app/display/gimptoolline.c
@@ -61,7 +61,8 @@ enum
   PROP_X1,
   PROP_Y1,
   PROP_X2,
-  PROP_Y2
+  PROP_Y2,
+  PROP_STATUS_TITLE,
 };
 
 struct _GimpToolLinePrivate
@@ -70,6 +71,7 @@ struct _GimpToolLinePrivate
   gdouble            y1;
   gdouble            x2;
   gdouble            y2;
+  gchar             *status_title;
 
   gdouble            saved_x1;
   gdouble            saved_y1;
@@ -92,6 +94,7 @@ struct _GimpToolLinePrivate
 /*  local function prototypes  */
 
 static void     gimp_tool_line_constructed     (GObject               *object);
+static void     gimp_tool_line_finalize        (GObject               *object);
 static void     gimp_tool_line_set_property    (GObject               *object,
                                                 guint                  property_id,
                                                 const GValue          *value,
@@ -153,6 +156,7 @@ gimp_tool_line_class_init (GimpToolLineClass *klass)
   GimpToolWidgetClass *widget_class = GIMP_TOOL_WIDGET_CLASS (klass);
 
   object_class->constructed     = gimp_tool_line_constructed;
+  object_class->finalize        = gimp_tool_line_finalize;
   object_class->set_property    = gimp_tool_line_set_property;
   object_class->get_property    = gimp_tool_line_get_property;
 
@@ -192,6 +196,13 @@ gimp_tool_line_class_init (GimpToolLineClass *klass)
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT));
 
+  g_object_class_install_property (object_class, PROP_STATUS_TITLE,
+                                   g_param_spec_string ("status-title",
+                                                        NULL, NULL,
+                                                        _("Line: "),
+                                                        GIMP_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT));
+
   g_type_class_add_private (klass, sizeof (GimpToolLinePrivate));
 }
 
@@ -260,6 +271,21 @@ gimp_tool_line_constructed (GObject *object)
 }
 
 static void
+gimp_tool_line_finalize (GObject *object)
+{
+  GimpToolLine        *line    = GIMP_TOOL_LINE (object);
+  GimpToolLinePrivate *private = line->private;
+
+  if (private->status_title)
+    {
+      g_free (private->status_title);
+      private->status_title = NULL;
+    }
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
 gimp_tool_line_set_property (GObject      *object,
                              guint         property_id,
                              const GValue *value,
@@ -283,6 +309,13 @@ gimp_tool_line_set_property (GObject      *object,
       private->y2 = g_value_get_double (value);
       break;
 
+    case PROP_STATUS_TITLE:
+      g_free (private->status_title);
+      private->status_title = g_value_dup_string (value);
+      if (! private->status_title)
+        private->status_title = g_strdup (_("Line: "));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -313,6 +346,10 @@ gimp_tool_line_get_property (GObject    *object,
       g_value_set_double (value, private->y2);
       break;
 
+    case PROP_STATUS_TITLE:
+      g_value_set_string (value, private->status_title);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -629,7 +666,7 @@ gimp_tool_line_update_status (GimpToolLine    *line,
                                 _("%s to move the whole line"));
 
       gimp_tool_widget_set_status_coords (GIMP_TOOL_WIDGET (line),
-                                          _("Blend: "),
+                                          private->status_title,
                                           private->x2 - private->x1,
                                           ", ",
                                           private->y2 - private->y1,
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 04bc872..33f7898 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -607,6 +607,10 @@ gimp_blend_tool_start (GimpBlendTool    *blend_tool,
                                            blend_tool->end_x,
                                            blend_tool->end_y);
 
+  g_object_set (blend_tool->widget,
+                "status-title", _("Blend: "),
+                NULL);
+
   gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (tool), blend_tool->widget);
 
   g_signal_connect (blend_tool->widget, "changed",


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