diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2012-04-12 08:14:09 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2012-04-12 08:14:09 +0000 |
| commit | d46d124918afeb7a04da14b49ab5f605512c1189 (patch) | |
| tree | 621b7cd97da25b7ed9a75228ca31cda7e74c383c /src/shortcuts.cpp | |
| parent | Warning cleanup. (diff) | |
| download | inkscape-d46d124918afeb7a04da14b49ab5f605512c1189.tar.gz inkscape-d46d124918afeb7a04da14b49ab5f605512c1189.zip | |
Shortcut patch. Fixes bug #974531
Fixed bugs:
- https://launchpad.net/bugs/974531
(bzr r11232)
Diffstat (limited to 'src/shortcuts.cpp')
| -rw-r--r-- | src/shortcuts.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index fe1d31331..aab55327d 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -25,6 +25,7 @@ #include <vector> #include <cstring> #include <string> +#include <map> #include <gdk/gdk.h> #include <gdk/gdkkeysyms.h> @@ -60,8 +61,8 @@ sp_shortcut_invoke(unsigned int shortcut, Inkscape::UI::View::View *view) return false; } -static GHashTable *verbs = NULL; -static GHashTable *primary_shortcuts = NULL; +static std::map<unsigned int, Inkscape::Verb * > *verbs = NULL; +static std::map<Inkscape::Verb *, unsigned int> *primary_shortcuts = NULL; static void sp_shortcut_init() @@ -71,8 +72,8 @@ sp_shortcut_init() using Inkscape::IO::Resource::USER; using Inkscape::IO::Resource::KEYS; - verbs = g_hash_table_new(NULL, NULL); - primary_shortcuts = g_hash_table_new(NULL, NULL); + verbs = new std::map<unsigned int, Inkscape::Verb * >(); + primary_shortcuts = new std::map<Inkscape::Verb *, unsigned int>(); read_shortcuts_file(get_path(SYSTEM, KEYS, "default.xml")); try_shortcuts_file(get_path(USER, KEYS, "default.xml")); @@ -175,20 +176,20 @@ sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool co { if (!verbs) sp_shortcut_init(); - Inkscape::Verb *old_verb = (Inkscape::Verb *)(g_hash_table_lookup(verbs, GINT_TO_POINTER(shortcut))); - g_hash_table_insert(verbs, GINT_TO_POINTER(shortcut), (gpointer)(verb)); + Inkscape::Verb *old_verb = (*verbs)[shortcut]; + (*verbs)[shortcut] = verb; /* Maintain the invariant that sp_shortcut_get_primary(v) returns either 0 or a valid shortcut for v. */ if (old_verb && old_verb != verb) { - unsigned int const old_primary = (unsigned int)GPOINTER_TO_INT(g_hash_table_lookup(primary_shortcuts, (gpointer)old_verb)); + unsigned int const old_primary = (*primary_shortcuts)[old_verb]; if (old_primary == shortcut) { - g_hash_table_insert(primary_shortcuts, (gpointer)old_verb, GINT_TO_POINTER(0)); + (*primary_shortcuts)[old_verb] = 0; } } if (is_primary) { - g_hash_table_insert(primary_shortcuts, (gpointer)(verb), GINT_TO_POINTER(shortcut)); + (*primary_shortcuts)[verb] = shortcut; } } @@ -196,7 +197,7 @@ Inkscape::Verb * sp_shortcut_get_verb(unsigned int shortcut) { if (!verbs) sp_shortcut_init(); - return (Inkscape::Verb *)(g_hash_table_lookup(verbs, GINT_TO_POINTER(shortcut))); + return (*verbs)[shortcut]; } unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) @@ -205,9 +206,9 @@ unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) if (!primary_shortcuts) { sp_shortcut_init(); } - gpointer value = 0; - if (g_hash_table_lookup_extended(primary_shortcuts, static_cast<gpointer>(verb), NULL, &value)) { - result = static_cast<unsigned int>(GPOINTER_TO_INT(value)); + + if (primary_shortcuts->count(verb)) { + result = (*primary_shortcuts)[verb]; } return result; } |
