[gimp] app: always add ALT+number accelerators to the image window menu items
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: always add ALT+number accelerators to the image window menu items
- Date: Sat, 7 May 2011 22:03:34 +0000 (UTC)
commit 3b71b71c4cddc561e2b258a5226a2dfa6b95a6bf
Author: Michael Natterer <mitch gimp org>
Date: Sun May 8 00:00:55 2011 +0200
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.
app/actions/windows-actions.c | 48 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c
index 8e015e0..5e0c342 100644
--- a/app/actions/windows-actions.c
+++ b/app/actions/windows-actions.c
@@ -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
{
@@ -318,6 +325,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,
GimpActionGroup *group)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]