[gimp/tito] app: do not log '*-set' and '*-accel' actions.



commit be5109886922ddb66f714e99677f6c0483cd3331
Author: Jehan <jehan girinstud io>
Date:   Sat Dec 14 21:18:27 2013 +1300

    app: do not log '*-set' and '*-accel' actions.
    
    '*-set' actions are made for midi dial devices, but they are useless
    on their own, thus with the search dialog. For instance what is the
    point of "layers-opacity-set" if you can't even choose an arbitrary
    value?
    '*-accel' actions are alternative actions for shortcuts using the
    numeric keypad.

 app/dialogs/action-search-dialog.c |   15 ++++++++++-----
 app/widgets/gimpaction-history.c   |   30 ++++++++++++++++++++----------
 app/widgets/gimpaction-history.h   |    2 ++
 3 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/app/dialogs/action-search-dialog.c b/app/dialogs/action-search-dialog.c
index 492ce7c..d6c654c 100644
--- a/app/dialogs/action-search-dialog.c
+++ b/app/dialogs/action-search-dialog.c
@@ -567,11 +567,16 @@ action_search_history_and_actions (const gchar  *keyword,
 
           name = gtk_action_get_name (action);
 
-          if (g_str_has_suffix (name, "-menu")           ||
-              g_str_has_suffix (name, "-popup")          ||
-              g_str_has_prefix (name, "context-")        ||
-              g_str_has_prefix (name, "plug-in-recent-") ||
-              g_strcmp0 (name, "dialogs-action-search") == 0)
+          /* The action search dialog don't show any non-historized
+           * action, with the exception of "plug-in-repeat/reshow"
+           * actions.
+           * Logging them is meaningless (they may mean a different
+           * actual action each time), but they are still interesting
+           * as a search result.
+           */
+          if (gimp_action_history_excluded_action (name) &&
+              g_strcmp0 (name, "plug-in-repeat") != 0    &&
+              g_strcmp0 (name, "plug-in-reshow") != 0)
             continue;
 
           if (! gtk_action_get_sensitive (action) && ! private->config->search_show_unavailable)
diff --git a/app/widgets/gimpaction-history.c b/app/widgets/gimpaction-history.c
index bd20f52..23be381 100644
--- a/app/widgets/gimpaction-history.c
+++ b/app/widgets/gimpaction-history.c
@@ -119,6 +119,24 @@ gimp_action_history_exit (GimpGuiConfig *config)
   g_free (history_file_path);
 }
 
+/* gimp_action_history_excluded_action:
+ *
+ * Returns whether an action should be excluded from history.
+ */
+gboolean
+gimp_action_history_excluded_action (const gchar *action_name)
+{
+  return (g_str_has_suffix (action_name, "-menu")           ||
+          g_str_has_suffix (action_name, "-popup")          ||
+          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-") ||
+          g_strcmp0 (action_name, "plug-in-repeat") == 0    ||
+          g_strcmp0 (action_name, "plug-in-reshow") == 0    ||
+          g_strcmp0 (action_name, "dialogs-action-search") == 0);
+}
+
 /* Callback run on the `activate` signal of an action.
    It allows us to log all used action. */
 void
@@ -132,13 +150,7 @@ gimp_action_history_activate_callback (GtkAction *action,
   action_name = gtk_action_get_name (action);
 
   /* Some specific actions are of no log interest. */
-  if (g_str_has_suffix (action_name, "-menu")           ||
-      g_str_has_suffix (action_name, "-popup")          ||
-      g_str_has_prefix (action_name, "context-")        ||
-      g_str_has_prefix (action_name, "plug-in-recent-") ||
-      g_strcmp0 (action_name, "plug-in-repeat") == 0    ||
-      g_strcmp0 (action_name, "plug-in-reshow") == 0    ||
-      g_strcmp0 (action_name, "dialogs-action-search") == 0)
+  if (gimp_action_history_excluded_action (action_name))
     return;
 
   for (actions = history; actions; actions = g_list_next (actions))
@@ -244,9 +256,7 @@ gimp_action_insert (const gchar *action_name,
   GimpUIManager     *manager;
 
   /* We do not insert some categories of actions. */
-  if (g_str_has_suffix (action_name, "-menu")  ||
-      g_str_has_suffix (action_name, "-popup") ||
-      g_str_has_prefix (action_name, "context-"))
+  if (gimp_action_history_excluded_action (action_name))
     return;
 
   manager = gimp_ui_managers_from_name ("<Image>")->data;
diff --git a/app/widgets/gimpaction-history.h b/app/widgets/gimpaction-history.h
index 7300f49..c0ca984 100644
--- a/app/widgets/gimpaction-history.h
+++ b/app/widgets/gimpaction-history.h
@@ -37,4 +37,6 @@ GList *    gimp_action_history_search            (const gchar         *keyword,
                                                   GimpActionMatchFunc  match_func,
                                                   GimpGuiConfig       *config);
 
+gboolean   gimp_action_history_excluded_action   (const gchar         *action_name);
+
 #endif  /* __GIMP_ACTION_HISTORY_H__ */


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