[gimp] app: Add File -> Debug -> Dump Keyboard Shortcuts menu command
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp] app: Add File -> Debug -> Dump Keyboard Shortcuts menu command
- Date: Fri, 8 May 2009 14:13:52 -0400 (EDT)
commit 1c33708f5ab10e7ded58cfb506ab847a266d3f62
Author: Martin Nordholts <martinn src gnome org>
Date: Fri May 8 17:40:13 2009 +0200
app: Add File -> Debug -> Dump Keyboard Shortcuts menu command
Add a Debug menu item 'Dump Keyboard Shortcuts' that can for example
be used to see what keyboard shortcuts that are unused or to simply
get an overview of what current keyboard shortcuts we hvae. Based on
code in gimp_action_view_new().
---
app/actions/debug-actions.c | 5 ++
app/actions/debug-commands.c | 103 ++++++++++++++++++++++++++++++++++++++----
app/actions/debug-commands.h | 26 ++++++-----
menus/image-menu.xml.in | 1 +
4 files changed, 114 insertions(+), 21 deletions(-)
diff --git a/app/actions/debug-actions.c b/app/actions/debug-actions.c
index 68a42bb..87ce47d 100644
--- a/app/actions/debug-actions.c
+++ b/app/actions/debug-actions.c
@@ -65,6 +65,11 @@ static const GimpActionEntry debug_actions[] =
G_CALLBACK (debug_dump_managers_cmd_callback),
NULL },
+ { "debug-dump-keyboard-shortcuts", NULL,
+ "Dump _Keyboard Shortcuts", NULL, NULL,
+ G_CALLBACK (debug_dump_keyboard_shortcuts_cmd_callback),
+ NULL },
+
{ "debug-dump-attached-data", NULL,
"Dump Attached Data", NULL, NULL,
G_CALLBACK (debug_dump_attached_data_cmd_callback),
diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c
index 4046c22..97f25a8 100644
--- a/app/actions/debug-commands.c
+++ b/app/actions/debug-commands.c
@@ -41,6 +41,10 @@
#include "gegl/gimp-gegl-utils.h"
+#include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
+
+#include "widgets/gimpaction.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpuimanager.h"
@@ -54,17 +58,21 @@
/* local function prototypes */
-static gboolean debug_benchmark_projection (GimpImage *image);
-static gboolean debug_show_image_graph (GimpImage *source_image);
+static gboolean debug_benchmark_projection (GimpImage *image);
+static gboolean debug_show_image_graph (GimpImage *source_image);
+
+static void debug_dump_menus_recurse_menu (GtkWidget *menu,
+ gint depth,
+ gchar *path);
-static void debug_dump_menus_recurse_menu (GtkWidget *menu,
- gint depth,
- gchar *path);
+static void debug_print_qdata (GimpObject *object);
+static void debug_print_qdata_foreach (GQuark key_id,
+ gpointer data,
+ gpointer user_data);
-static void debug_print_qdata (GimpObject *object);
-static void debug_print_qdata_foreach (GQuark key_id,
- gpointer data,
- gpointer user_data);
+static gboolean debug_accel_find_func (GtkAccelKey *key,
+ GClosure *closure,
+ gpointer data);
/* public functions */
@@ -174,6 +182,74 @@ debug_dump_managers_cmd_callback (GtkAction *action,
}
void
+debug_dump_keyboard_shortcuts_cmd_callback (GtkAction *action,
+ gpointer data)
+{
+ GimpDisplay *display = NULL;
+ GimpDisplayShell *shell = NULL;
+ GtkAccelGroup *accel_group = NULL;
+ GList *group_it = NULL;
+ return_if_no_display (display, data);
+
+ shell = GIMP_DISPLAY_SHELL (display->shell);
+ accel_group = gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (shell->menubar_manager));
+
+ for (group_it = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (shell->menubar_manager));
+ group_it;
+ group_it = g_list_next (group_it))
+ {
+ GimpActionGroup *group = group_it->data;
+ GList *actions = NULL;
+ GList *action_it = NULL;
+
+ actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
+ actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
+
+ for (action_it = actions; action_it; action_it = g_list_next (action_it))
+ {
+ GtkAction *action = action_it->data;
+ const gchar *name = gtk_action_get_name (action);
+ GClosure *accel_closure = NULL;
+
+ if (strstr (name, "-menu") ||
+ strstr (name, "-popup") ||
+ name[0] == '<')
+ continue;
+
+ accel_closure = gtk_action_get_accel_closure (action);
+
+ if (accel_closure)
+ {
+ GtkAccelKey *key = gtk_accel_group_find (accel_group,
+ debug_accel_find_func,
+ accel_closure);
+ if (key &&
+ key->accel_key &&
+ key->accel_flags & GTK_ACCEL_VISIBLE)
+ {
+ gchar *label_tmp = NULL;
+ gchar *label = NULL;
+ gchar *key_string = NULL;
+
+ g_object_get (action, "label", &label_tmp, NULL);
+ label = gimp_strip_uline (label_tmp);
+ key_string = gtk_accelerator_get_label (key->accel_key,
+ key->accel_mods);
+
+ g_print ("%-20s %s\n", key_string, label);
+
+ g_free (key_string);
+ g_free (label);
+ g_free (label_tmp);
+ }
+ }
+ }
+
+ g_list_free (actions);
+ }
+}
+
+void
debug_dump_attached_data_cmd_callback (GtkAction *action,
gpointer data)
{
@@ -343,4 +419,13 @@ debug_print_qdata_foreach (GQuark key_id,
g_print ("%s: %p\n", g_quark_to_string (key_id), data);
}
+static gboolean
+debug_accel_find_func (GtkAccelKey *key,
+ GClosure *closure,
+ gpointer data)
+{
+ return (GClosure *) data == closure;
+}
+
+
#endif /* ENABLE_DEBUG_MENU */
diff --git a/app/actions/debug-commands.h b/app/actions/debug-commands.h
index 930fe9f..a9f6275 100644
--- a/app/actions/debug-commands.h
+++ b/app/actions/debug-commands.h
@@ -26,18 +26,20 @@
#ifdef ENABLE_DEBUG_MENU
-void debug_mem_profile_cmd_callback (GtkAction *action,
- gpointer data);
-void debug_dump_menus_cmd_callback (GtkAction *action,
- gpointer data);
-void debug_dump_managers_cmd_callback (GtkAction *action,
- gpointer data);
-void debug_dump_attached_data_cmd_callback (GtkAction *action,
- gpointer data);
-void debug_benchmark_projection_cmd_callback (GtkAction *action,
- gpointer data);
-void debug_show_image_graph_cmd_callback (GtkAction *action,
- gpointer data);
+void debug_mem_profile_cmd_callback (GtkAction *action,
+ gpointer data);
+void debug_dump_menus_cmd_callback (GtkAction *action,
+ gpointer data);
+void debug_dump_managers_cmd_callback (GtkAction *action,
+ gpointer data);
+void debug_dump_keyboard_shortcuts_cmd_callback (GtkAction *action,
+ gpointer data);
+void debug_dump_attached_data_cmd_callback (GtkAction *action,
+ gpointer data);
+void debug_benchmark_projection_cmd_callback (GtkAction *action,
+ gpointer data);
+void debug_show_image_graph_cmd_callback (GtkAction *action,
+ gpointer data);
#endif /* ENABLE_DEBUG_MENU */
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index 916580b..2407f3f 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -31,6 +31,7 @@
<separator />
<menuitem action="debug-dump-items" />
<menuitem action="debug-dump-managers" />
+ <menuitem action="debug-dump-keyboard-shortcuts" />
<menuitem action="debug-dump-attached-data" />
</menu>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]