From be519f62404daf6dff2449a2eb5280d998298868 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Mon, 6 Sep 2010 19:32:05 +0200 Subject: Automatically add shortcuts to tooltips (bzr r9745) --- src/shortcuts.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/shortcuts.cpp') 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 #include +#include #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( + ((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: -- cgit v1.2.3 From d454d77da77d1ef2b5b0ccaed5698871bd5f9d3e Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 10 Sep 2010 01:34:09 -0700 Subject: Fixed valgrind-detected issue with tooltip shortcuts and profile manager on delete. (bzr r9753) --- src/shortcuts.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/shortcuts.cpp') diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index d02ef6e48..bf7fb8a43 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -199,16 +199,17 @@ sp_shortcut_get_verb(unsigned int shortcut) return (Inkscape::Verb *)(g_hash_table_lookup(verbs, GINT_TO_POINTER(shortcut))); } -unsigned int -sp_shortcut_get_primary(Inkscape::Verb *verb) +unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) { - if (!primary_shortcuts) sp_shortcut_init(); - 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; + unsigned int result = GDK_VoidSymbol; + if (!primary_shortcuts) { + sp_shortcut_init(); } + gpointer value = 0; + if (g_hash_table_lookup_extended(primary_shortcuts, static_cast(verb), NULL, &value)) { + result = static_cast(GPOINTER_TO_INT(value)); + } + return result; } gchar* sp_shortcut_get_label (unsigned int shortcut) -- cgit v1.2.3 From 43910107bd13f3968d48d955a81bb787942af865 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 29 Oct 2010 00:49:37 -0700 Subject: Cleanups from backports. (bzr r9863) --- src/shortcuts.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/shortcuts.cpp') diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index bf7fb8a43..c8ff5b329 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -212,7 +212,7 @@ unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) return result; } -gchar* sp_shortcut_get_label (unsigned int shortcut) +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 @@ -223,13 +223,16 @@ gchar* sp_shortcut_get_label (unsigned int shortcut) * 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( - ((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) - )); + gchar *result = 0; + if (shortcut != GDK_VoidSymbol) { + result = gtk_accelerator_get_label( + shortcut & (~SP_SHORTCUT_MODIFIER_MASK), static_cast( + ((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) + )); + } + return result; } /* -- cgit v1.2.3 From 144819c918dc761641c3cb5a490205fb73194ee3 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 17 Nov 2010 13:12:56 +1100 Subject: Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in all 1074 Vim modelines. The reason for this is that (a) setting the encoding isn't nice, and (b) Vim 7.3 (with modeline enabled) disallows it and pops up an error whenever you open any file with it ("invalid modeline"). Also corrected five deviant modestrings: * src/ui/widget/dock.cpp and src/ui/widget/dock.h: missing colon at the end * src/ui/dialog/tile.cpp: removed gratuitous second colon at the end * src/helper/units-test.h: removed gratuitous space before a colon * share/extensions/export_gimp_palette.py: missing textwidth=99 That's my geekiest commit yet. (bzr r9900) --- src/shortcuts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/shortcuts.cpp') diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index c8ff5b329..d647d30b3 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -244,4 +244,4 @@ gchar *sp_shortcut_get_label(unsigned int shortcut) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3