[gimp] app: layers-mode-* actions should not always be sensitive.



commit 4003bc79db8f9e325420256e022a6ddda1ed1c47
Author: Jehan <jehan girinstud io>
Date:   Thu Nov 16 01:14:18 2017 +0100

    app: layers-mode-* actions should not always be sensitive.

 app/actions/layers-actions.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c
index 0b21008..91ee468 100644
--- a/app/actions/layers-actions.c
+++ b/app/actions/layers-actions.c
@@ -755,6 +755,8 @@ layers_actions_update (GimpActionGroup *group,
   GList         *next           = NULL;
   GList         *next_visible   = NULL;
   GList         *prev           = NULL;
+  gboolean       next_mode      = FALSE;
+  gboolean       prev_mode      = FALSE;
 
   if (image)
     {
@@ -767,10 +769,13 @@ layers_actions_update (GimpActionGroup *group,
 
       if (layer)
         {
+          GimpLayerMode *modes;
           GimpLayerMode  mode   = gimp_layer_get_mode (layer);
           const gchar   *action = NULL;
           GList         *layer_list;
           GList         *list;
+          gint           n_modes;
+          gint           i = 0;
 
           switch (gimp_layer_get_blend_space (layer))
             {
@@ -859,6 +864,15 @@ layers_actions_update (GimpActionGroup *group,
                 }
             }
 
+          modes = gimp_layer_mode_get_context_array (mode,
+                                                     GIMP_LAYER_MODE_CONTEXT_LAYER,
+                                                     &n_modes);
+          while (i < (n_modes - 1) && modes[i] != mode)
+            i++;
+          g_free (modes);
+          next_mode = (i < n_modes - 1);
+          prev_mode = (i > 0);
+
           text_layer = gimp_item_is_text_layer (GIMP_ITEM (layer));
         }
     }
@@ -895,6 +909,11 @@ layers_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("layers-duplicate",        layer && !fs && !ac);
   SET_SENSITIVE ("layers-delete",           layer && !ac);
 
+  SET_SENSITIVE ("layers-mode-first",       layer && !ac && prev_mode);
+  SET_SENSITIVE ("layers-mode-last",        layer && !ac && next_mode);
+  SET_SENSITIVE ("layers-mode-previous",    layer && !ac && prev_mode);
+  SET_SENSITIVE ("layers-mode-next",        layer && !ac && next_mode);
+
   SET_SENSITIVE ("layers-select-top",       layer && !fs && !ac && prev);
   SET_SENSITIVE ("layers-select-bottom",    layer && !fs && !ac && next);
   SET_SENSITIVE ("layers-select-previous",  layer && !fs && !ac && prev);


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