[gimp] app: add gimp_action_is_gui_blacklisted()



commit dcad833d1c29c977db4efa953cf2ecf3aa192220
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 20 15:57:57 2014 +0200

    app: add gimp_action_is_gui_blacklisted()
    
    which filters out some implementation details but mainly all the
    tool-specific options actions which only exist as redirect targets for
    the generic tool opaticy, size, aspect and angle actions. Use the new
    function from the shortcut editor and from action search so stuff is
    consistently hidden.

 app/widgets/gimpaction-history.c |    8 +++---
 app/widgets/gimpaction.c         |   43 ++++++++++++++++++++++++++++++++++++++
 app/widgets/gimpaction.h         |   16 ++++++++------
 app/widgets/gimpactionview.c     |    4 +--
 4 files changed, 57 insertions(+), 14 deletions(-)
---
diff --git a/app/widgets/gimpaction-history.c b/app/widgets/gimpaction-history.c
index d74f7f1..b087c81 100644
--- a/app/widgets/gimpaction-history.c
+++ b/app/widgets/gimpaction-history.c
@@ -161,10 +161,10 @@ gimp_action_history_exit (GimpGuiConfig *config)
 gboolean
 gimp_action_history_excluded_action (const gchar *action_name)
 {
-  return (action_name[0] == '<'                             ||
-          g_str_has_suffix (action_name, "-menu")           ||
-          g_str_has_suffix (action_name, "-popup")          ||
-          g_str_has_suffix (action_name, "-set")            ||
+  if (gimp_action_is_gui_blacklisted (action_name))
+    return TRUE;
+
+  return (g_str_has_suffix (action_name, "-set")            ||
           g_str_has_suffix (action_name, "-accel")          ||
           g_str_has_prefix (action_name, "context-")        ||
           g_str_has_prefix (action_name, "plug-in-recent-") ||
diff --git a/app/widgets/gimpaction.c b/app/widgets/gimpaction.c
index ffc68fb..425f3eb 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -317,6 +317,49 @@ gimp_action_name_compare (GimpAction  *action1,
                  gtk_action_get_name ((GtkAction *) action2));
 }
 
+gboolean
+gimp_action_is_gui_blacklisted (const gchar *action_name)
+{
+  static const gchar *suffixes[] =
+    {
+      "-menu",
+      "-popup"
+    };
+
+  static const gchar *prefixes[] =
+    {
+      "<",
+      "tools-color-average-radius-",
+      "tools-paint-brush-size-",
+      "tools-paint-brush-angle-",
+      "tools-paint-brush-aspect-ratio-",
+      "tools-ink-blob-size-",
+      "tools-ink-blob-aspect-",
+      "tools-ink-blob-angle-",
+      "tools-foreground-select-brush-size-",
+      "tools-transform-preview-opacity-"
+    };
+
+  gint i;
+
+  if (! (action_name && *action_name))
+    return TRUE;
+
+  for (i = 0; i < G_N_ELEMENTS (suffixes); i++)
+    {
+      if (g_str_has_suffix (action_name, suffixes[i]))
+        return TRUE;
+    }
+
+  for (i = 0; i < G_N_ELEMENTS (prefixes); i++)
+    {
+      if (g_str_has_prefix (action_name, prefixes[i]))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
 
 /*  private functions  */
 
diff --git a/app/widgets/gimpaction.h b/app/widgets/gimpaction.h
index 725ed98..6ffbb41 100644
--- a/app/widgets/gimpaction.h
+++ b/app/widgets/gimpaction.h
@@ -50,15 +50,17 @@ struct _GimpActionClass
 };
 
 
-GType        gimp_action_get_type     (void) G_GNUC_CONST;
+GType        gimp_action_get_type           (void) G_GNUC_CONST;
 
-GimpAction * gimp_action_new          (const gchar *name,
-                                       const gchar *label,
-                                       const gchar *tooltip,
-                                       const gchar *stock_id);
+GimpAction * gimp_action_new                (const gchar *name,
+                                             const gchar *label,
+                                             const gchar *tooltip,
+                                             const gchar *stock_id);
 
-gint         gimp_action_name_compare (GimpAction  *action1,
-                                       GimpAction  *action2);
+gint         gimp_action_name_compare       (GimpAction  *action1,
+                                             GimpAction  *action2);
+
+gboolean     gimp_action_is_gui_blacklisted (const gchar *action_name);
 
 
 #endif  /* __GIMP_ACTION_H__ */
diff --git a/app/widgets/gimpactionview.c b/app/widgets/gimpactionview.c
index 254f9a7..f522240 100644
--- a/app/widgets/gimpactionview.c
+++ b/app/widgets/gimpactionview.c
@@ -251,9 +251,7 @@ gimp_action_view_new (GimpUIManager *manager,
           GClosure        *accel_closure = NULL;
           GtkTreeIter      action_iter;
 
-          if (strstr (name, "-menu")  ||
-              strstr (name, "-popup") ||
-              name[0] == '<')
+          if (gimp_action_is_gui_blacklisted (name))
             continue;
 
           label = gimp_strip_uline (gtk_action_get_label (action));


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