Commit 3b71b71c authored by Michael Natterer's avatar Michael Natterer 😴

app: always add ALT+number accelerators to the image window menu items

There is no reason why we should have them only in single-window-mode.
The accels are numbered in the order the displays are opened, which is
also the order they appear in the menu. The only thing that needs to
be taken care of is that switching to SWM swallows the image windows
into the single window in the right order. Fixes bug #647524.
parent 1ebd2b51
......@@ -19,6 +19,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
......@@ -60,6 +61,8 @@ static void windows_actions_display_remove (GimpContainer *conta
static void windows_actions_image_notify (GimpDisplay *display,
const GParamSpec *unused,
GimpActionGroup *group);
static void windows_actions_update_display_accels (GimpActionGroup *group);
static void windows_actions_dock_window_added (GimpDialogFactory *factory,
GimpDockWindow *dock_window,
GimpActionGroup *group);
......@@ -238,6 +241,8 @@ windows_actions_display_remove (GimpContainer *container,
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
g_free (action_name);
windows_actions_update_display_accels (group);
}
static void
......@@ -310,6 +315,8 @@ windows_actions_image_notify (GimpDisplay *display,
}
g_free (action_name);
windows_actions_update_display_accels (group);
}
else
{
......@@ -317,6 +324,47 @@ windows_actions_image_notify (GimpDisplay *display,
}
}
static void
windows_actions_update_display_accels (GimpActionGroup *group)
{
GList *list;
gint i;
for (list = gimp_get_display_iter (group->gimp), i = 0;
list && i < 10;
list = g_list_next (list), i++)
{
GimpDisplay *display = list->data;
GtkAction *action;
gchar *action_name;
if (! gimp_display_get_image (display))
break;
action_name = gimp_display_get_action_name (display);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
action_name);
if (action)
{
const gchar *accel_path;
guint accel_key;
accel_path = gtk_action_get_accel_path (action);
if (i < 9)
accel_key = GDK_KEY_1 + i;
else
accel_key = GDK_KEY_0;
gtk_accel_map_change_entry (accel_path,
accel_key, GDK_MOD1_MASK,
TRUE);
}
}
}
static void
windows_actions_dock_window_added (GimpDialogFactory *factory,
GimpDockWindow *dock_window,
......
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