[gimp] app: "vectors-copy" and "vectors-export" are now multi-paths aware.



commit 9fc8260c7c6f2e4a575317a84f77e652eda1fbc2
Author: Jehan <jehan girinstud io>
Date:   Wed Oct 12 22:13:38 2022 +0200

    app: "vectors-copy" and "vectors-export" are now multi-paths aware.

 app/actions/vectors-actions.c       |  8 ++++----
 app/actions/vectors-commands.c      | 12 ++++++------
 app/config/gimpdialogconfig.c       |  2 +-
 app/config/gimprc-blurbs.h          |  2 +-
 app/dialogs/preferences-dialog.c    |  2 +-
 app/dialogs/vectors-export-dialog.c |  2 +-
 app/vectors/gimpvectors-export.c    | 35 ++++++++++++-----------------------
 app/vectors/gimpvectors-export.h    |  4 ++--
 app/widgets/gimpvectorstreeview.c   |  8 ++++----
 9 files changed, 32 insertions(+), 43 deletions(-)
---
diff --git a/app/actions/vectors-actions.c b/app/actions/vectors-actions.c
index 7d3fff2d32..f133598208 100644
--- a/app/actions/vectors-actions.c
+++ b/app/actions/vectors-actions.c
@@ -140,7 +140,7 @@ static const GimpActionEntry vectors_actions[] =
     GIMP_HELP_PATH_STROKE },
 
   { "vectors-copy", GIMP_ICON_EDIT_COPY,
-    NC_("vectors-action", "Co_py Path"), "", NULL,
+    NC_("vectors-action", "Co_py Paths"), "", NULL,
     vectors_copy_cmd_callback,
     GIMP_HELP_PATH_COPY },
 
@@ -150,7 +150,7 @@ static const GimpActionEntry vectors_actions[] =
     GIMP_HELP_PATH_PASTE },
 
   { "vectors-export", GIMP_ICON_DOCUMENT_SAVE,
-    NC_("vectors-action", "E_xport Path..."), "", NULL,
+    NC_("vectors-action", "E_xport Paths..."), "", NULL,
     vectors_export_cmd_callback,
     GIMP_HELP_PATH_EXPORT },
 
@@ -431,9 +431,9 @@ vectors_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("vectors-lower",           n_selected_vectors > 0 && have_next);
   SET_SENSITIVE ("vectors-lower-to-bottom", n_selected_vectors > 0 && have_next);
 
-  SET_SENSITIVE ("vectors-copy",   n_selected_vectors == 1);
+  SET_SENSITIVE ("vectors-copy",   n_selected_vectors > 0);
   SET_SENSITIVE ("vectors-paste",  image);
-  SET_SENSITIVE ("vectors-export", n_selected_vectors == 1);
+  SET_SENSITIVE ("vectors-export", n_selected_vectors > 0);
   SET_SENSITIVE ("vectors-import", image);
 
   SET_SENSITIVE ("vectors-selection-to-vectors",          image && !mask_empty);
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index 0699fd9279..2edbe5d4a6 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -590,9 +590,9 @@ vectors_copy_cmd_callback (GimpAction *action,
                            gpointer    data)
 {
   GimpImage   *image;
-  GimpVectors *vectors;
+  GList       *vectors;
   gchar       *svg;
-  return_if_no_vectors (image, vectors, data);
+  return_if_no_vectors_list (image, vectors, data);
 
   svg = gimp_vectors_export_string (image, vectors);
 
@@ -645,10 +645,10 @@ vectors_export_cmd_callback (GimpAction *action,
                              gpointer    data)
 {
   GimpImage   *image;
-  GimpVectors *vectors;
+  GList       *vectors;
   GtkWidget   *widget;
   GtkWidget   *dialog;
-  return_if_no_vectors (image, vectors, data);
+  return_if_no_vectors_list (image, vectors, data);
   return_if_no_widget (widget, data);
 
 #define EXPORT_DIALOG_KEY "gimp-vectors-export-dialog"
@@ -903,7 +903,7 @@ vectors_export_callback (GtkWidget *dialog,
                          gpointer   user_data)
 {
   GimpDialogConfig *config  = GIMP_DIALOG_CONFIG (image->gimp->config);
-  GimpVectors      *vectors = NULL;
+  GList            *vectors = NULL;
   gchar            *path    = NULL;
   GError           *error   = NULL;
 
@@ -919,7 +919,7 @@ vectors_export_callback (GtkWidget *dialog,
     g_free (path);
 
   if (config->vectors_export_active_only)
-    vectors = gimp_image_get_active_vectors (image);
+    vectors = gimp_image_get_selected_vectors (image);
 
   if (! gimp_vectors_export_file (image, vectors, file, &error))
     {
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index 4162526b0e..412274404a 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -441,7 +441,7 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
 
   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_VECTORS_EXPORT_ACTIVE_ONLY,
                             "path-export-active-only",
-                            "Default export only the active path",
+                            "Default export only the selected paths",
                             VECTORS_EXPORT_ACTIVE_ONLY_BLURB,
                             TRUE,
                             GIMP_PARAM_STATIC_STRINGS);
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 7c2573ffa1..537bdc4093 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -650,7 +650,7 @@ _("Sets the default path name for the 'New Path' dialog.")
 _("Sets the default folder path for the 'Export Path' dialog.")
 
 #define VECTORS_EXPORT_ACTIVE_ONLY_BLURB \
-_("Sets the default 'Export the active path' state for the 'Export Path' dialog.")
+_("Sets the default 'Export the selected paths' state for the 'Export Path' dialog.")
 
 #define VECTORS_IMPORT_PATH_BLURB \
 _("Sets the default folder path for the 'Import Path' dialog.")
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index ec2f3bef3c..e1d34023ab 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -2540,7 +2540,7 @@ prefs_dialog_new (Gimp       *gimp,
                                  GTK_GRID (grid), 0, size_group);
 
   prefs_check_button_add (object, "path-export-active-only",
-                          _("Export the active path only"),
+                          _("Export the selected paths only"),
                           GTK_BOX (vbox2));
 
   /*  Import Path Dialog  */
diff --git a/app/dialogs/vectors-export-dialog.c b/app/dialogs/vectors-export-dialog.c
index 3bb47014eb..e9f6f2eab1 100644
--- a/app/dialogs/vectors-export-dialog.c
+++ b/app/dialogs/vectors-export-dialog.c
@@ -118,7 +118,7 @@ vectors_export_dialog_new (GimpImage                 *image,
                     G_CALLBACK (vectors_export_dialog_response),
                     private);
 
-  combo = gimp_int_combo_box_new (_("Export the active path"),           TRUE,
+  combo = gimp_int_combo_box_new (_("Export the selected paths"),           TRUE,
                                   _("Export all paths from this image"), FALSE,
                                   NULL);
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
diff --git a/app/vectors/gimpvectors-export.c b/app/vectors/gimpvectors-export.c
index 0e72d92f91..613949d147 100644
--- a/app/vectors/gimpvectors-export.c
+++ b/app/vectors/gimpvectors-export.c
@@ -37,7 +37,7 @@
 
 
 static GString * gimp_vectors_export            (GimpImage   *image,
-                                                 GimpVectors *vectors);
+                                                 GList       *vectors);
 static void      gimp_vectors_export_image_size (GimpImage   *image,
                                                  GString     *str);
 static void      gimp_vectors_export_path       (GimpVectors *vectors,
@@ -48,7 +48,7 @@ static gchar   * gimp_vectors_export_path_data  (GimpVectors *vectors);
 /**
  * gimp_vectors_export_file:
  * @image: the #GimpImage from which to export vectors
- * @vectors: a #GimpVectors object or %NULL to export all vectors in @image
+ * @vectors: a #GList of #GimpVectors objects or %NULL to export all vectors in @image
  * @file: the file to write
  * @error: return location for errors
  *
@@ -59,7 +59,7 @@ static gchar   * gimp_vectors_export_path_data  (GimpVectors *vectors);
  **/
 gboolean
 gimp_vectors_export_file (GimpImage    *image,
-                          GimpVectors  *vectors,
+                          GList        *vectors,
                           GFile        *file,
                           GError      **error)
 {
@@ -68,7 +68,6 @@ gimp_vectors_export_file (GimpImage    *image,
   GError        *my_error = NULL;
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
-  g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), FALSE);
   g_return_val_if_fail (G_IS_FILE (file), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -116,20 +115,20 @@ gimp_vectors_export_file (GimpImage    *image,
  * Returns: a %NUL-terminated string that holds a complete XML document
  **/
 gchar *
-gimp_vectors_export_string (GimpImage   *image,
-                            GimpVectors *vectors)
+gimp_vectors_export_string (GimpImage *image,
+                            GList     *vectors)
 {
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
-  g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), NULL);
 
   return g_string_free (gimp_vectors_export (image, vectors), FALSE);
 }
 
 static GString *
-gimp_vectors_export (GimpImage   *image,
-                     GimpVectors *vectors)
+gimp_vectors_export (GimpImage *image,
+                     GList     *vectors)
 {
   GString *str = g_string_new (NULL);
+  GList   *list;
 
   g_string_append_printf (str,
                           "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
@@ -147,21 +146,11 @@ gimp_vectors_export (GimpImage   *image,
                           gimp_image_get_width  (image),
                           gimp_image_get_height (image));
 
-  if (vectors)
-    {
-      gimp_vectors_export_path (vectors, str);
-    }
-  else
-    {
-      GList *list;
+  if (! vectors)
+    vectors = gimp_image_get_vectors_iter (image);
 
-      for (list = gimp_image_get_vectors_iter (image);
-           list;
-           list = list->next)
-        {
-          gimp_vectors_export_path (GIMP_VECTORS (list->data), str);
-        }
-    }
+  for (list = vectors; list; list = list->next)
+    gimp_vectors_export_path (GIMP_VECTORS (list->data), str);
 
   g_string_append (str, "</svg>\n");
 
diff --git a/app/vectors/gimpvectors-export.h b/app/vectors/gimpvectors-export.h
index d61eae2c86..8def7acf83 100644
--- a/app/vectors/gimpvectors-export.h
+++ b/app/vectors/gimpvectors-export.h
@@ -20,11 +20,11 @@
 
 
 gboolean   gimp_vectors_export_file   (GimpImage    *image,
-                                       GimpVectors  *vectors,
+                                       GList        *vectors,
                                        GFile        *file,
                                        GError      **error);
 gchar    * gimp_vectors_export_string (GimpImage    *image,
-                                       GimpVectors  *vectors);
+                                       GList        *vectors);
 
 
 #endif /* __GIMP_VECTORS_IMPORT_H__ */
diff --git a/app/widgets/gimpvectorstreeview.c b/app/widgets/gimpvectorstreeview.c
index 6b4d2eedfc..e54948c660 100644
--- a/app/widgets/gimpvectorstreeview.c
+++ b/app/widgets/gimpvectorstreeview.c
@@ -264,16 +264,16 @@ gimp_vectors_tree_view_drag_svg (GtkWidget *widget,
 {
   GimpItemTreeView *view  = GIMP_ITEM_TREE_VIEW (data);
   GimpImage        *image = gimp_item_tree_view_get_image (view);
-  GimpItem         *item;
+  GList            *items;
   gchar            *svg_data = NULL;
 
-  item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
+  items = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_selected_items (image);
 
   *svg_data_len = 0;
 
-  if (item)
+  if (items)
     {
-      svg_data = gimp_vectors_export_string (image, GIMP_VECTORS (item));
+      svg_data = gimp_vectors_export_string (image, items);
 
       if (svg_data)
         *svg_data_len = strlen (svg_data);


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