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:
Jehan 2016-11-23 04:01:30 +01:00
parent ad339d3bad
commit 53b3673bd8
2 changed files with 101 additions and 61 deletions

View File

@ -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,6 +104,19 @@ action_search_history_and_actions (GimpSearchPopup *popup,
}
/* Now check other actions. */
for (menus = gimp_menu_factory_get_registered_menus (global_menu_factory);
menus;
menus = g_list_next (menus))
{
GimpMenuFactoryEntry *entry = menus->data;
GList *managers;
managers = gimp_ui_managers_from_name (entry->identifier);
for (; managers; managers = g_list_next (managers))
{
GimpUIManager *manager = managers->data;
for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
list;
list = g_list_next (list))
@ -163,6 +179,8 @@ action_search_history_and_actions (GimpSearchPopup *popup,
g_list_free (actions);
}
}
}
g_list_free_full (history_actions, (GDestroyNotify) g_object_unref);
}

View File

@ -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))