[gimp] app: add gimp_progress_set_text_literal()



commit 328e4eff18c4565dc430c72cf2a4e1788c6d6208
Author: Michael Natterer <mitch gimp org>
Date:   Sun Jul 20 23:32:19 2014 +0200

    app: add gimp_progress_set_text_literal()
    
    and use it instead of set_text (progress, "%s", literal_message);

 app/core/gimpdrawable-blend.c           |    4 +-
 app/core/gimpimage-convert-type.c       |    8 +++---
 app/core/gimpprogress.c                 |   32 +++++++++++++++++++-----------
 app/core/gimpprogress.h                 |    4 ++-
 app/display/gimpdisplay.c               |    2 +-
 app/display/gimpdisplayshell-progress.c |    2 +-
 app/gegl/gimp-gegl-apply-operation.c    |    2 +-
 app/plug-in/gimpplugin-progress.c       |    4 +-
 app/tools/gimptool-progress.c           |    2 +-
 app/widgets/gimpfiledialog.c            |    2 +-
 app/widgets/gimpprogressdialog.c        |    2 +-
 11 files changed, 37 insertions(+), 27 deletions(-)
---
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index 5a92151..198b17f 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -540,7 +540,7 @@ gradient_precalc_shapeburst (GimpImage           *image,
   GeglBuffer  *temp_buffer;
   GeglNode    *shapeburst;
 
-  gimp_progress_set_text (progress, _("Calculating distance map"));
+  gimp_progress_set_text_literal (progress, _("Calculating distance map"));
 
   /*  allocate the distance map  */
   dist_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
@@ -863,7 +863,7 @@ gradient_fill_region (GimpImage           *image,
       rbd.dist_buffer = gradient_precalc_shapeburst (image, drawable,
                                                      buffer_region,
                                                      rbd.dist, progress);
-      gimp_progress_set_text (progress, _("Blending"));
+      gimp_progress_set_text_literal (progress, _("Blending"));
       break;
 
     default:
diff --git a/app/core/gimpimage-convert-type.c b/app/core/gimpimage-convert-type.c
index eaa7fcb..7be9373 100644
--- a/app/core/gimpimage-convert-type.c
+++ b/app/core/gimpimage-convert-type.c
@@ -880,8 +880,8 @@ gimp_image_convert_type (GimpImage               *image,
         }
 
       if (progress)
-        gimp_progress_set_text (progress,
-                                _("Converting to indexed colors (stage 2)"));
+        gimp_progress_set_text_literal (progress,
+                                        _("Converting to indexed colors (stage 2)"));
 
       if (old_type == GIMP_RGB &&
           ! needs_quantize     &&
@@ -925,8 +925,8 @@ gimp_image_convert_type (GimpImage               *image,
     }
 
   if (progress)
-    gimp_progress_set_text (progress,
-                            _("Converting to indexed colors (stage 3)"));
+    gimp_progress_set_text_literal (progress,
+                                    _("Converting to indexed colors (stage 3)"));
 
   /* Initialise data which must persist across indexed layer iterations */
   switch (new_type)
diff --git a/app/core/gimpprogress.c b/app/core/gimpprogress.c
index 11dd7fb..7ad5db1 100644
--- a/app/core/gimpprogress.c
+++ b/app/core/gimpprogress.c
@@ -160,26 +160,34 @@ gimp_progress_set_text (GimpProgress *progress,
                         const gchar  *format,
                         ...)
 {
-  GimpProgressInterface *progress_iface;
+  va_list  args;
+  gchar   *message;
 
   g_return_if_fail (GIMP_IS_PROGRESS (progress));
   g_return_if_fail (format != NULL);
 
-  progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
+  va_start (args, format);
+  message = g_strdup_vprintf (format, args);
+  va_end (args);
 
-  if (progress_iface->set_text)
-    {
-      va_list  args;
-      gchar   *text;
+  gimp_progress_set_text_literal (progress, message);
 
-      va_start (args, format);
-      text = g_strdup_vprintf (format, args);
-      va_end (args);
+  g_free (message);
+}
+
+void
+gimp_progress_set_text_literal (GimpProgress *progress,
+                                const gchar  *message)
+{
+  GimpProgressInterface *progress_iface;
 
-      progress_iface->set_text (progress, text);
+  g_return_if_fail (GIMP_IS_PROGRESS (progress));
+  g_return_if_fail (message != NULL);
 
-      g_free (text);
-    }
+  progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
+
+  if (progress_iface->set_text)
+    progress_iface->set_text (progress, message);
 }
 
 void
diff --git a/app/core/gimpprogress.h b/app/core/gimpprogress.h
index ee52e84..567a920 100644
--- a/app/core/gimpprogress.h
+++ b/app/core/gimpprogress.h
@@ -71,8 +71,10 @@ void           gimp_progress_end                (GimpProgress        *progress);
 gboolean       gimp_progress_is_active          (GimpProgress        *progress);
 
 void           gimp_progress_set_text           (GimpProgress        *progress,
-                                                 const gchar         *message,
+                                                 const gchar         *format,
                                                  ...) G_GNUC_PRINTF (2, 3);
+void           gimp_progress_set_text_literal   (GimpProgress        *progress,
+                                                 const gchar         *message);
 void           gimp_progress_set_value          (GimpProgress        *progress,
                                                  gdouble              percentage);
 gdouble        gimp_progress_get_value          (GimpProgress        *progress);
diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c
index 4155665..da92e9f 100644
--- a/app/display/gimpdisplay.c
+++ b/app/display/gimpdisplay.c
@@ -310,7 +310,7 @@ gimp_display_progress_set_text (GimpProgress *progress,
   GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
 
   if (private->shell)
-    gimp_progress_set_text (GIMP_PROGRESS (private->shell), "%s", message);
+    gimp_progress_set_text_literal (GIMP_PROGRESS (private->shell), message);
 }
 
 static void
diff --git a/app/display/gimpdisplayshell-progress.c b/app/display/gimpdisplayshell-progress.c
index 03946d8..14d70d9 100644
--- a/app/display/gimpdisplayshell-progress.c
+++ b/app/display/gimpdisplayshell-progress.c
@@ -68,7 +68,7 @@ gimp_display_shell_progress_set_text (GimpProgress *progress,
   GimpDisplayShell *shell     = GIMP_DISPLAY_SHELL (progress);
   GimpStatusbar    *statusbar = gimp_display_shell_get_statusbar (shell);
 
-  gimp_progress_set_text (GIMP_PROGRESS (statusbar), "%s", message);
+  gimp_progress_set_text_literal (GIMP_PROGRESS (statusbar), message);
 }
 
 static void
diff --git a/app/gegl/gimp-gegl-apply-operation.c b/app/gegl/gimp-gegl-apply-operation.c
index 1db54c1..3e0605c 100644
--- a/app/gegl/gimp-gegl-apply-operation.c
+++ b/app/gegl/gimp-gegl-apply-operation.c
@@ -140,7 +140,7 @@ gimp_gegl_apply_cached_operation (GeglBuffer          *src_buffer,
       if (gimp_progress_is_active (progress))
         {
           if (undo_desc)
-            gimp_progress_set_text (progress, "%s", undo_desc);
+            gimp_progress_set_text_literal (progress, undo_desc);
 
           progress_started = FALSE;
           cancellable      = FALSE;
diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c
index 1b9104c..70d90e6 100644
--- a/app/plug-in/gimpplugin-progress.c
+++ b/app/plug-in/gimpplugin-progress.c
@@ -123,7 +123,7 @@ gimp_plug_in_progress_start (GimpPlugIn  *plug_in,
       if (gimp_progress_is_active (proc_frame->progress))
         {
           if (message)
-            gimp_progress_set_text (proc_frame->progress, "%s", message);
+            gimp_progress_set_text_literal (proc_frame->progress, message);
 
           if (gimp_progress_get_value (proc_frame->progress) > 0.0)
             gimp_progress_set_value (proc_frame->progress, 0.0);
@@ -178,7 +178,7 @@ gimp_plug_in_progress_set_text (GimpPlugIn  *plug_in,
   proc_frame = gimp_plug_in_get_proc_frame (plug_in);
 
   if (proc_frame->progress)
-    gimp_progress_set_text (proc_frame->progress, "%s", message);
+    gimp_progress_set_text_literal (proc_frame->progress, message);
 }
 
 void
diff --git a/app/tools/gimptool-progress.c b/app/tools/gimptool-progress.c
index f7e21e1..d05d719 100644
--- a/app/tools/gimptool-progress.c
+++ b/app/tools/gimptool-progress.c
@@ -213,7 +213,7 @@ gimp_tool_progress_set_text (GimpProgress *progress,
     {
       GimpDisplayShell *shell = gimp_display_get_shell (tool->progress_display);
 
-      gimp_progress_set_text (GIMP_PROGRESS (tool->progress), "%s", message);
+      gimp_progress_set_text_literal (GIMP_PROGRESS (tool->progress), message);
       gimp_widget_flush_expose (shell->canvas);
     }
 }
diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c
index 6b2d659..c3fe93d 100644
--- a/app/widgets/gimpfiledialog.c
+++ b/app/widgets/gimpfiledialog.c
@@ -253,7 +253,7 @@ gimp_file_dialog_progress_set_text (GimpProgress *progress,
   GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
 
   if (dialog->progress)
-    gimp_progress_set_text (GIMP_PROGRESS (dialog->progress), "%s", message);
+    gimp_progress_set_text_literal (GIMP_PROGRESS (dialog->progress), message);
 }
 
 static void
diff --git a/app/widgets/gimpprogressdialog.c b/app/widgets/gimpprogressdialog.c
index c932511..1285314 100644
--- a/app/widgets/gimpprogressdialog.c
+++ b/app/widgets/gimpprogressdialog.c
@@ -179,7 +179,7 @@ gimp_progress_dialog_progress_set_text (GimpProgress *progress,
   if (! dialog->box)
     return;
 
-  gimp_progress_set_text (GIMP_PROGRESS (dialog->box), "%s", message);
+  gimp_progress_set_text_literal (GIMP_PROGRESS (dialog->box), message);
 }
 
 static void


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