summaryrefslogtreecommitdiffstats
path: root/src/shortcuts.cpp
diff options
context:
space:
mode:
authorJasper van de Gronde <jasper.vandegronde@gmail.com>2010-09-06 17:32:05 +0000
committerJasper van de Gronde <th.v.d.gronde@hccnet.nl>2010-09-06 17:32:05 +0000
commitbe519f62404daf6dff2449a2eb5280d998298868 (patch)
tree0512806eccbf0707bc63716be91e5223b48072bb /src/shortcuts.cpp
parentExtensions. Consistency fix and UI improvements (Generate from path submenu). (diff)
downloadinkscape-be519f62404daf6dff2449a2eb5280d998298868.tar.gz
inkscape-be519f62404daf6dff2449a2eb5280d998298868.zip
Automatically add shortcuts to tooltips
(bzr r9745)
Diffstat (limited to 'src/shortcuts.cpp')
-rw-r--r--src/shortcuts.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp
index 7d0f3747d..d02ef6e48 100644
--- a/src/shortcuts.cpp
+++ b/src/shortcuts.cpp
@@ -28,6 +28,7 @@
#include <gdk/gdkkeys.h>
#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
#include "helper/action.h"
#include "io/sys.h"
@@ -202,10 +203,33 @@ unsigned int
sp_shortcut_get_primary(Inkscape::Verb *verb)
{
if (!primary_shortcuts) sp_shortcut_init();
- return (unsigned int)GPOINTER_TO_INT(g_hash_table_lookup(primary_shortcuts,
- (gpointer)(verb)));
+ gpointer value;
+ if (g_hash_table_lookup_extended(primary_shortcuts, (gpointer)(verb), NULL, &value)) {
+ return (unsigned int)GPOINTER_TO_INT(value);
+ } else {
+ return GDK_VoidSymbol;
+ }
}
+gchar* sp_shortcut_get_label (unsigned int shortcut)
+{
+ // The comment below was copied from the function sp_ui_shortcut_string in interface.cpp (which was subsequently removed)
+ /* TODO: This function shouldn't exist. Our callers should use GtkAccelLabel instead of
+ * a generic GtkLabel containing this string, and should call gtk_widget_add_accelerator.
+ * Will probably need to change sp_shortcut_invoke callers.
+ *
+ * The existing gtk_label_new_with_mnemonic call can be replaced with
+ * g_object_new(GTK_TYPE_ACCEL_LABEL, NULL) followed by
+ * gtk_label_set_text_with_mnemonic(lbl, str).
+ */
+ if (shortcut==GDK_VoidSymbol) return 0;
+ return gtk_accelerator_get_label(
+ shortcut&(~SP_SHORTCUT_MODIFIER_MASK),static_cast<GdkModifierType>(
+ ((shortcut&SP_SHORTCUT_SHIFT_MASK)?GDK_SHIFT_MASK:0) |
+ ((shortcut&SP_SHORTCUT_CONTROL_MASK)?GDK_CONTROL_MASK:0) |
+ ((shortcut&SP_SHORTCUT_ALT_MASK)?GDK_MOD1_MASK:0)
+ ));
+}
/*
Local Variables: