mirror of https://github.com/GNOME/gimp.git
app: action search should search accross all available actions.
It was only searching through the "<Image>" GimpUIManager, so several action groups were ignored, for instance all palettes-* actions.
This commit is contained in:
parent
ad339d3bad
commit
53b3673bd8
|
@ -35,9 +35,13 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "menus/menus.h"
|
||||
|
||||
#include "widgets/gimpaction.h"
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimpaction-history.h"
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimpmenufactory.h"
|
||||
#include "widgets/gimpsearchpopup.h"
|
||||
#include "widgets/gimpuimanager.h"
|
||||
|
||||
|
@ -77,19 +81,18 @@ action_search_history_and_actions (GimpSearchPopup *popup,
|
|||
const gchar *keyword,
|
||||
gpointer data)
|
||||
{
|
||||
GimpUIManager *manager;
|
||||
GList *menus;
|
||||
GList *list;
|
||||
GList *history_actions = NULL;
|
||||
Gimp *gimp;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (data));
|
||||
|
||||
gimp = GIMP (data);
|
||||
manager = gimp_ui_managers_from_name ("<Image>")->data;
|
||||
|
||||
if (g_strcmp0 (keyword, "") == 0)
|
||||
return;
|
||||
|
||||
gimp = GIMP (data);
|
||||
|
||||
history_actions = gimp_action_history_search (gimp,
|
||||
action_search_match_keyword,
|
||||
keyword);
|
||||
|
@ -101,68 +104,83 @@ action_search_history_and_actions (GimpSearchPopup *popup,
|
|||
}
|
||||
|
||||
/* Now check other actions. */
|
||||
for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
for (menus = gimp_menu_factory_get_registered_menus (global_menu_factory);
|
||||
menus;
|
||||
menus = g_list_next (menus))
|
||||
{
|
||||
GList *list2;
|
||||
GimpActionGroup *group = list->data;
|
||||
GList *actions = NULL;
|
||||
GimpMenuFactoryEntry *entry = menus->data;
|
||||
GList *managers;
|
||||
|
||||
actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
|
||||
actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
|
||||
managers = gimp_ui_managers_from_name (entry->identifier);
|
||||
|
||||
for (list2 = actions; list2; list2 = g_list_next (list2))
|
||||
for (; managers; managers = g_list_next (managers))
|
||||
{
|
||||
const gchar *name;
|
||||
GtkAction *action = list2->data;
|
||||
gboolean is_redundant = FALSE;
|
||||
gint section;
|
||||
GimpUIManager *manager = managers->data;
|
||||
|
||||
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.
|
||||
*/
|
||||
if (gimp_action_history_excluded_action (name) &&
|
||||
g_strcmp0 (name, "filters-repeat") != 0 &&
|
||||
g_strcmp0 (name, "filters-reshow") != 0)
|
||||
continue;
|
||||
|
||||
if (! gtk_action_is_sensitive (action) &&
|
||||
! GIMP_GUI_CONFIG (gimp->config)->search_show_unavailable)
|
||||
continue;
|
||||
|
||||
if (action_search_match_keyword (action, keyword, §ion, gimp))
|
||||
for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GList *list3;
|
||||
GList *list2;
|
||||
GimpActionGroup *group = list->data;
|
||||
GList *actions = NULL;
|
||||
|
||||
/* A matching action. Check if we have not already added
|
||||
* it as an history action.
|
||||
*/
|
||||
for (list3 = history_actions; list3; list3 = g_list_next (list3))
|
||||
actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
|
||||
actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
|
||||
|
||||
for (list2 = actions; list2; list2 = g_list_next (list2))
|
||||
{
|
||||
if (strcmp (gtk_action_get_name (GTK_ACTION (list3->data)),
|
||||
name) == 0)
|
||||
const gchar *name;
|
||||
GtkAction *action = list2->data;
|
||||
gboolean is_redundant = FALSE;
|
||||
gint section;
|
||||
|
||||
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.
|
||||
*/
|
||||
if (gimp_action_history_excluded_action (name) &&
|
||||
g_strcmp0 (name, "filters-repeat") != 0 &&
|
||||
g_strcmp0 (name, "filters-reshow") != 0)
|
||||
continue;
|
||||
|
||||
if (! gtk_action_is_sensitive (action) &&
|
||||
! GIMP_GUI_CONFIG (gimp->config)->search_show_unavailable)
|
||||
continue;
|
||||
|
||||
if (action_search_match_keyword (action, keyword, §ion, gimp))
|
||||
{
|
||||
is_redundant = TRUE;
|
||||
break;
|
||||
GList *list3;
|
||||
|
||||
/* A matching action. Check if we have not already added
|
||||
* it as an history action.
|
||||
*/
|
||||
for (list3 = history_actions; list3; list3 = g_list_next (list3))
|
||||
{
|
||||
if (strcmp (gtk_action_get_name (GTK_ACTION (list3->data)),
|
||||
name) == 0)
|
||||
{
|
||||
is_redundant = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! is_redundant)
|
||||
{
|
||||
gimp_search_popup_add_result (popup, action, section);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! is_redundant)
|
||||
{
|
||||
gimp_search_popup_add_result (popup, action, section);
|
||||
}
|
||||
g_list_free (actions);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (actions);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free_full (history_actions, (GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
|
|
@ -33,9 +33,12 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "gimpuimanager.h"
|
||||
#include "menus/menus.h"
|
||||
|
||||
#include "gimpaction.h"
|
||||
#include "gimpaction-history.h"
|
||||
#include "gimpmenufactory.h"
|
||||
#include "gimpuimanager.h"
|
||||
|
||||
|
||||
#define GIMP_ACTION_HISTORY_FILENAME "action-history"
|
||||
|
@ -251,7 +254,6 @@ gimp_action_history_search (Gimp *gimp,
|
|||
const gchar *keyword)
|
||||
{
|
||||
GimpGuiConfig *config;
|
||||
GimpUIManager *manager;
|
||||
GList *actions;
|
||||
GList *result = NULL;
|
||||
gint i;
|
||||
|
@ -260,21 +262,41 @@ gimp_action_history_search (Gimp *gimp,
|
|||
g_return_val_if_fail (match_func != NULL, NULL);
|
||||
|
||||
config = GIMP_GUI_CONFIG (gimp->config);
|
||||
manager = gimp_ui_managers_from_name ("<Image>")->data;
|
||||
|
||||
for (actions = history.items, i = 0;
|
||||
actions && i < config->action_history_size;
|
||||
actions = g_list_next (actions), i++)
|
||||
{
|
||||
GimpActionHistoryItem *item = actions->data;
|
||||
GtkAction *action;
|
||||
GtkAction *action = NULL;
|
||||
GList *menus;
|
||||
|
||||
action = gimp_ui_manager_find_action (manager, NULL, item->action_name);
|
||||
if (action == NULL)
|
||||
continue;
|
||||
for (menus = gimp_menu_factory_get_registered_menus (global_menu_factory);
|
||||
menus;
|
||||
menus = g_list_next (menus))
|
||||
{
|
||||
GimpMenuFactoryEntry *entry = menus->data;
|
||||
GList *managers;
|
||||
|
||||
if (! gtk_action_is_sensitive (action) &&
|
||||
! config->search_show_unavailable)
|
||||
managers = gimp_ui_managers_from_name (entry->identifier);
|
||||
|
||||
for (; managers; managers = g_list_next (managers))
|
||||
{
|
||||
GimpUIManager *manager = managers->data;
|
||||
|
||||
action = gimp_ui_manager_find_action (manager, NULL,
|
||||
item->action_name);
|
||||
|
||||
if (action)
|
||||
break;
|
||||
}
|
||||
if (action)
|
||||
break;
|
||||
}
|
||||
|
||||
if (action == NULL ||
|
||||
(! gtk_action_is_sensitive (action) &&
|
||||
! config->search_show_unavailable))
|
||||
continue;
|
||||
|
||||
if (match_func (action, keyword, NULL, gimp))
|
||||
|
|
Loading…
Reference in New Issue