Commit 2816695e authored by Ell's avatar Ell

app: add gimp_action_history_is_blacklisted_action()

... and rename gimp_action_history_excluded_action() to
gimp_action_history_is_excluded_action().

is_blacklisted_action() determines whether an action should be
excluded from *both* the history and the search results, while
is_excluded_action() determines if an action should be excluded
only from the history.  This eliminates some redundancy across
gimpaction-history and action-search-dialog.
parent dba39b13
......@@ -121,16 +121,12 @@ action_search_history_and_actions (GimpSearchPopup *popup,
name = gtk_action_get_name (action);
/* 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.
/* The action search dialog doesn't show any non-historized
* actions, with a few exceptions. See the difference between
* gimp_action_history_is_blacklisted_action() and
* gimp_action_history_is_excluded_action().
*/
if (gimp_action_history_excluded_action (name) &&
g_strcmp0 (name, "filters-repeat") != 0 &&
g_strcmp0 (name, "filters-reshow") != 0)
if (gimp_action_history_is_blacklisted_action (name))
continue;
if (! gtk_action_is_sensitive (action) &&
......
......@@ -138,7 +138,7 @@ gimp_action_history_init (Gimp *gimp)
break;
}
if (! gimp_action_history_excluded_action (action_name))
if (! gimp_action_history_is_excluded_action (action_name))
{
history.items =
g_list_insert_sorted (history.items,
......@@ -287,12 +287,13 @@ gimp_action_history_search (Gimp *gimp,
return g_list_reverse (result);
}
/* gimp_action_history_excluded_action:
/* gimp_action_history_is_blacklisted_action:
*
* Returns whether an action should be excluded from history.
* Returns whether an action should be excluded from both
* history and search results.
*/
gboolean
gimp_action_history_excluded_action (const gchar *action_name)
gimp_action_history_is_blacklisted_action (const gchar *action_name)
{
if (gimp_action_is_gui_blacklisted (action_name))
return TRUE;
......@@ -301,11 +302,27 @@ gimp_action_history_excluded_action (const gchar *action_name)
g_str_has_suffix (action_name, "-accel") ||
g_str_has_prefix (action_name, "context-") ||
g_str_has_prefix (action_name, "filters-recent-") ||
g_strcmp0 (action_name, "filters-repeat") == 0 ||
g_strcmp0 (action_name, "filters-reshow") == 0 ||
g_strcmp0 (action_name, "dialogs-action-search") == 0);
}
/* gimp_action_history_is_excluded_action:
*
* Returns whether an action should be excluded from history.
*
* Some actions should not be logged in the history, but should
* otherwise appear in the search results, since they correspond
* to different functions at different times.
*/
gboolean
gimp_action_history_is_excluded_action (const gchar *action_name)
{
if (gimp_action_history_is_blacklisted_action (action_name))
return TRUE;
return (g_strcmp0 (action_name, "filters-repeat") == 0 ||
g_strcmp0 (action_name, "filters-reshow") == 0);
}
/* Callback run on the `activate` signal of an action.
* It allows us to log all used action.
*/
......@@ -320,7 +337,7 @@ gimp_action_history_activate_callback (GtkAction *action,
action_name = gtk_action_get_name (action);
/* Some specific actions are of no log interest. */
if (gimp_action_history_excluded_action (action_name))
if (gimp_action_history_is_excluded_action (action_name))
return;
for (actions = history.items; actions; actions = g_list_next (actions))
......
......@@ -28,19 +28,20 @@ typedef gboolean (* GimpActionMatchFunc) (GtkAction *action,
Gimp *gimp);
void gimp_action_history_init (Gimp *gimp);
void gimp_action_history_exit (Gimp *gimp);
void gimp_action_history_init (Gimp *gimp);
void gimp_action_history_exit (Gimp *gimp);
void gimp_action_history_clear (Gimp *gimp);
void gimp_action_history_clear (Gimp *gimp);
GList * gimp_action_history_search (Gimp *gimp,
GimpActionMatchFunc match_func,
const gchar *keyword);
GList * gimp_action_history_search (Gimp *gimp,
GimpActionMatchFunc match_func,
const gchar *keyword);
gboolean gimp_action_history_excluded_action (const gchar *action_name);
gboolean gimp_action_history_is_blacklisted_action (const gchar *action_name);
gboolean gimp_action_history_is_excluded_action (const gchar *action_name);
void gimp_action_history_activate_callback (GtkAction *action,
gpointer user_data);
void gimp_action_history_activate_callback (GtkAction *action,
gpointer user_data);
#endif /* __GIMP_ACTION_HISTORY_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment