Bug 774890 - "Keyboard shortcuts" dialog does not show all actions

Revert "app: action search should search accross all available actions."

This reverts commit 53b3673bd8.

Had to revert these two commits, quoting comment 6 of the bug:

Thinking again, that entire change is unfortunately wrong, the only
right UI manager is in fact

gimp_ui_managers_from_name ("<Image>")->data

because it's the global popup <Image> UI manager which is independent
of a display and it always in the right state for the currently
active image, all other UI managers are wrong.
This commit is contained in:
Michael Natterer 2016-11-24 21:08:34 +01:00
parent 1517a0952b
commit 6131b00b54
2 changed files with 61 additions and 101 deletions

View File

@ -35,13 +35,9 @@
#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"
@ -81,18 +77,19 @@ action_search_history_and_actions (GimpSearchPopup *popup,
const gchar *keyword,
gpointer data)
{
GList *menus;
GimpUIManager *manager;
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);
@ -104,83 +101,68 @@ 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))
for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
list;
list = g_list_next (list))
{
GimpMenuFactoryEntry *entry = menus->data;
GList *managers;
GList *list2;
GimpActionGroup *group = list->data;
GList *actions = NULL;
managers = gimp_ui_managers_from_name (entry->identifier);
actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
for (; managers; managers = g_list_next (managers))
for (list2 = actions; list2; list2 = g_list_next (list2))
{
GimpUIManager *manager = managers->data;
const gchar *name;
GtkAction *action = list2->data;
gboolean is_redundant = FALSE;
gint section;
for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
list;
list = g_list_next (list))
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, &section, gimp))
{
GList *list2;
GimpActionGroup *group = list->data;
GList *actions = NULL;
GList *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))
/* 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))
{
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, &section, gimp))
if (strcmp (gtk_action_get_name (GTK_ACTION (list3->data)),
name) == 0)
{
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);
}
is_redundant = TRUE;
break;
}
}
g_list_free (actions);
if (! is_redundant)
{
gimp_search_popup_add_result (popup, action, section);
}
}
}
}
g_list_free (actions);
}
g_list_free_full (history_actions, (GDestroyNotify) g_object_unref);
}

View File

@ -33,12 +33,9 @@
#include "core/gimp.h"
#include "menus/menus.h"
#include "gimpuimanager.h"
#include "gimpaction.h"
#include "gimpaction-history.h"
#include "gimpmenufactory.h"
#include "gimpuimanager.h"
#define GIMP_ACTION_HISTORY_FILENAME "action-history"
@ -254,6 +251,7 @@ gimp_action_history_search (Gimp *gimp,
const gchar *keyword)
{
GimpGuiConfig *config;
GimpUIManager *manager;
GList *actions;
GList *result = NULL;
gint i;
@ -262,41 +260,21 @@ 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 = NULL;
GList *menus;
GtkAction *action;
for (menus = gimp_menu_factory_get_registered_menus (global_menu_factory);
menus;
menus = g_list_next (menus))
{
GimpMenuFactoryEntry *entry = menus->data;
GList *managers;
action = gimp_ui_manager_find_action (manager, NULL, item->action_name);
if (action == NULL)
continue;
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))
if (! gtk_action_is_sensitive (action) &&
! config->search_show_unavailable)
continue;
if (match_func (action, keyword, NULL, gimp))