app: Action Search does not use GimpUiManager anymore.

It directly uses the action added to the GtkApplication/GActionMap.
This commit is contained in:
Jehan 2023-01-30 00:19:32 +01:00
parent 35b5729bcc
commit 4f8357d7f6
2 changed files with 40 additions and 62 deletions

View file

@ -40,7 +40,6 @@
#include "widgets/gimpaction-history.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpsearchpopup.h"
#include "widgets/gimpuimanager.h"
#include "action-search-dialog.h"
@ -79,15 +78,14 @@ action_search_history_and_actions (GimpSearchPopup *popup,
const gchar *keyword,
gpointer data)
{
GimpUIManager *manager;
GList *list;
GList *history_actions = NULL;
Gimp *gimp;
gchar **actions;
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;
@ -102,63 +100,45 @@ action_search_history_and_actions (GimpSearchPopup *popup,
gimp_action_is_sensitive (list->data, NULL) ? 0 : ACTION_SECTION_INACTIVE);
/* 1. Then other matching actions. */
for (list = gimp_ui_manager_get_action_groups (manager);
list;
list = g_list_next (list))
actions = g_action_group_list_actions (G_ACTION_GROUP (gimp->app));
for (gint i = 0; actions[i] != NULL; i++)
{
GList *list2;
GimpActionGroup *group = list->data;
GList *actions = NULL;
GAction *action;
gint section;
actions = gimp_action_group_list_actions (group);
actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
/* 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_is_blacklisted_action (actions[i]))
continue;
for (list2 = actions; list2; list2 = g_list_next (list2))
action = g_action_map_lookup_action (G_ACTION_MAP (gimp->app), actions[i]);
g_return_if_fail (GIMP_IS_ACTION (action));
if (! gimp_action_is_visible (GIMP_ACTION (action)))
continue;
if (action_search_match_keyword (GIMP_ACTION (action), keyword, &section, gimp))
{
const gchar *name;
GimpAction *action = list2->data;
gboolean is_redundant = FALSE;
gint section;
GList *redundant;
name = gimp_action_get_name (action);
/* 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().
/* A matching action. Check if we have not already added
* it as an history action.
*/
if (gimp_action_history_is_blacklisted_action (name))
continue;
for (redundant = history_actions; redundant; redundant = g_list_next (redundant))
if (strcmp (gimp_action_get_name (redundant->data), actions[i]) == 0)
break;
if (! gimp_action_is_visible (action))
continue;
if (action_search_match_keyword (action, keyword, &section, gimp))
{
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 (gimp_action_get_name (list3->data),
name) == 0)
{
is_redundant = TRUE;
break;
}
}
if (! is_redundant)
{
gimp_search_popup_add_result (popup, action, section);
}
}
if (redundant == NULL)
gimp_search_popup_add_result (popup, GIMP_ACTION (action), section);
}
}
g_list_free (actions);
}
g_strfreev (actions);
g_list_free_full (history_actions, (GDestroyNotify) g_object_unref);
}

View file

@ -34,7 +34,6 @@
#include "core/gimp.h"
#include "gimpuimanager.h"
#include "gimpaction.h"
#include "gimpaction-history.h"
@ -280,7 +279,6 @@ gimp_action_history_search (Gimp *gimp,
const gchar *keyword)
{
GimpGuiConfig *config;
GimpUIManager *manager;
GList *actions;
GList *result = NULL;
gint i;
@ -289,23 +287,23 @@ 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->head, i = 0;
actions && i < config->action_history_size;
actions = g_list_next (actions), i++)
{
GimpActionHistoryItem *item = actions->data;
GimpAction *action;
GimpActionHistoryItem *item = actions->data;
GAction *action;
action = gimp_ui_manager_find_action (manager, NULL, item->action_name);
action = g_action_map_lookup_action (G_ACTION_MAP (gimp->app), item->action_name);
if (action == NULL)
continue;
if (! gimp_action_is_visible (action))
g_return_val_if_fail (GIMP_IS_ACTION (action), NULL);
if (! gimp_action_is_visible (GIMP_ACTION (action)))
continue;
if (match_func (action, keyword, NULL, gimp))
if (match_func (GIMP_ACTION (action), keyword, NULL, gimp))
result = g_list_prepend (result, g_object_ref (action));
}