[gimp] Bug 585607 - Vectors select (next, previous, top & bottom)



commit 2de6beaea831336c60ce80b5367e45f64e6c5e4c
Author: Lionel N <lionel libreart info>
Date:   Sun Jun 25 22:10:11 2017 +0200

    Bug 585607 - Vectors select (next, previous, top & bottom)
    
    Now possible to have keybindings for previous/next/top/bottom vector

 app/actions/vectors-actions.c  |   42 +++++++++++++++++++++++++++++++++++++++-
 app/actions/vectors-commands.c |   29 +++++++++++++++++++++++++++
 app/actions/vectors-commands.h |    5 +++-
 app/widgets/gimphelp-ids.h     |    6 ++++-
 4 files changed, 79 insertions(+), 3 deletions(-)
---
diff --git a/app/actions/vectors-actions.c b/app/actions/vectors-actions.c
index 01b73c9..a703eae 100644
--- a/app/actions/vectors-actions.c
+++ b/app/actions/vectors-actions.c
@@ -298,6 +298,32 @@ static const GimpEnumActionEntry vectors_selection_to_vectors_actions[] =
     GIMP_HELP_SELECTION_TO_PATH }
 };
 
+static const GimpEnumActionEntry vectors_select_actions[] =
+{
+  { "vectors-select-top", NULL,
+    NC_("vectors-action", "Select _Top Vectors"), NULL,
+    NC_("vectors-action", "Select the topmost vector"),
+    GIMP_ACTION_SELECT_FIRST, FALSE,
+    GIMP_HELP_VECTORS_TOP },
+
+  { "vectors-select-bottom", NULL,
+    NC_("vectors-action", "Select _Bottom Vectors"), NULL,
+    NC_("vectors-action", "Select the bottommost vector"),
+    GIMP_ACTION_SELECT_LAST, FALSE,
+    GIMP_HELP_VECTORS_BOTTOM },
+
+  { "vectors-select-previous", NULL,
+    NC_("vectors-action", "Select _Previous Vectors"), NULL,
+    NC_("vectors-action", "Select the vector above the current vector"),
+    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
+    GIMP_HELP_VECTORS_PREVIOUS },
+
+  { "vectors-select-next", NULL,
+    NC_("vectors-action", "Select _Next Vector"), NULL,
+    NC_("vectors-action", "Select the vector below the current vector"),
+    GIMP_ACTION_SELECT_NEXT, FALSE,
+    GIMP_HELP_VECTORS_NEXT }
+};
 
 void
 vectors_actions_setup (GimpActionGroup *group)
@@ -325,6 +351,11 @@ vectors_actions_setup (GimpActionGroup *group)
                                       G_N_ELEMENTS (vectors_selection_to_vectors_actions),
                                       G_CALLBACK (vectors_selection_to_vectors_cmd_callback));
 
+  gimp_action_group_add_enum_actions (group, "vectors-action",
+                                      vectors_select_actions,
+                                      G_N_ELEMENTS (vectors_select_actions),
+                                      G_CALLBACK (vectors_select_cmd_callback));
+                                      
   items_actions_setup (group, "vectors");
 }
 
@@ -341,9 +372,13 @@ vectors_actions_update (GimpActionGroup *group,
   gboolean      dr_children   = FALSE;
   GList        *next          = NULL;
   GList        *prev          = NULL;
+  gboolean      fs            = FALSE;    /*  floating sel           */
+  gboolean      ac            = FALSE;    /*  active channel         */
 
   if (image)
     {
+      fs      = (gimp_image_get_floating_selection (image) != NULL);
+      ac      = (gimp_image_get_active_channel (image) != NULL);
       n_vectors  = gimp_image_get_n_vectors (image);
       mask_empty = gimp_channel_is_empty (gimp_image_get_mask (image));
 
@@ -420,7 +455,12 @@ vectors_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("vectors-selection-from-vectors", vectors);
   SET_SENSITIVE ("vectors-selection-add",          vectors);
   SET_SENSITIVE ("vectors-selection-subtract",     vectors);
-  SET_SENSITIVE ("vectors-selection-intersect",    vectors);
+  SET_SENSITIVE ("vectors-selection-intersect",    vectors);  
+
+  SET_SENSITIVE ("vectors-select-top",       vectors && !fs && !ac && prev);
+  SET_SENSITIVE ("vectors-select-bottom",    vectors && !fs && !ac && next);
+  SET_SENSITIVE ("vectors-select-previous",  vectors && !fs && !ac && prev);
+  SET_SENSITIVE ("vectors-select-next",      vectors && !fs && !ac && next);
 
 #undef SET_SENSITIVE
 #undef SET_ACTIVE
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index 563f3b4..4b5207e 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -827,3 +827,32 @@ vectors_export_callback (GtkWidget *dialog,
 
   gtk_widget_destroy (dialog);
 }
+
+void
+vectors_select_cmd_callback (GtkAction *action,
+                             gint       value,
+                             gpointer   data)
+{
+  GimpImage      *image;
+  GimpVectors    *vectors;
+  GimpContainer  *container;
+  GimpVectors    *new_vectors;
+  return_if_no_image (image, data);
+
+  vectors = gimp_image_get_active_vectors (image);
+
+  if (vectors)
+    container = gimp_item_get_container (GIMP_ITEM (vectors));
+  else
+    container = gimp_image_get_vectors (image);
+
+  new_vectors = (GimpVectors *) action_select_object ((GimpActionSelectType) value,
+                                                       container,
+                                                      (GimpObject *) vectors);
+
+  if (new_vectors && new_vectors != vectors)
+    {
+      gimp_image_set_active_vectors (image, new_vectors);
+      gimp_image_flush (image);
+    }
+}
\ No newline at end of file
diff --git a/app/actions/vectors-commands.h b/app/actions/vectors-commands.h
index ac572cc..ca88480 100644
--- a/app/actions/vectors-commands.h
+++ b/app/actions/vectors-commands.h
@@ -81,5 +81,8 @@ void   vectors_color_tag_cmd_callback            (GtkAction   *action,
                                                   gint         value,
                                                   gpointer     data);
 
-
+void   vectors_select_cmd_callback               (GtkAction   *action,
+                                                  gint         value,
+                                                  gpointer     data);
+                                                  
 #endif /* __VECTORS_COMMANDS_H__ */
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index c5a318f..c63585c 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -222,6 +222,11 @@
 #define GIMP_HELP_LAYER_CROP                      "gimp-layer-crop"
 #define GIMP_HELP_LAYER_EDIT                      "gimp-layer-edit"
 
+#define GIMP_HELP_VECTORS_PREVIOUS                "gimp-vector-previous"
+#define GIMP_HELP_VECTORS_NEXT                    "gimp-vector-next"
+#define GIMP_HELP_VECTORS_TOP                     "gimp-vector-top"
+#define GIMP_HELP_VECTORS_BOTTOM                  "gimp-vector-bottom"
+
 #define GIMP_HELP_CHANNEL_DIALOG                  "gimp-channel-dialog"
 #define GIMP_HELP_CHANNEL_NEW                     "gimp-channel-new"
 #define GIMP_HELP_CHANNEL_RAISE                   "gimp-channel-raise"
@@ -706,5 +711,4 @@
 #define GIMP_HELP_CONTROLLER_MOUSE                "gimp-controller-mouse"
 #define GIMP_HELP_CONTROLLER_WHEEL                "gimp-controller-wheel"
 
-
 #endif /* __GIMP_HELP_IDS_H__ */


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