From e396a825a3bd1781f77df0427a14c0a33d2e51d4 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 29 Oct 2010 00:49:37 -0700 Subject: [PATCH] Cleanups from backports. --- src/shortcuts.cpp | 19 +++++++++++-------- src/widgets/button.cpp | 42 ++++++++++++++++++++--------------------- src/widgets/toolbox.cpp | 4 ++-- 3 files changed, 33 insertions(+), 32 deletions(-) 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; } /* diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index aa32a9d91..dc830d096 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -288,29 +288,27 @@ sp_button_action_set_shortcut (SPAction *action, unsigned int /*shortcut*/, void } } -static void -sp_button_set_composed_tooltip (GtkTooltips *tooltips, GtkWidget *widget, SPAction *action) +static void sp_button_set_composed_tooltip(GtkTooltips *tooltips, GtkWidget *widget, SPAction *action) { - if (action) { - unsigned int shortcut = sp_shortcut_get_primary (action->verb); - if (shortcut!=GDK_VoidSymbol) { - // there's both action and shortcut - - gchar* key = sp_shortcut_get_label(shortcut); - - gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); - gtk_tooltips_set_tip (tooltips, widget, tip, NULL); - g_free (tip); - g_free (key); - - } else { - // action has no shortcut - gtk_tooltips_set_tip (tooltips, widget, action->tip, NULL); - } - } else { - // no action - gtk_tooltips_set_tip (tooltips, widget, NULL, NULL); - } + if (action) { + unsigned int shortcut = sp_shortcut_get_primary (action->verb); + if (shortcut != GDK_VoidSymbol) { + // there's both action and shortcut + + gchar *key = sp_shortcut_get_label(shortcut); + + gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); + gtk_tooltips_set_tip(tooltips, widget, tip, NULL); + g_free(tip); + g_free(key); + } else { + // action has no shortcut + gtk_tooltips_set_tip(tooltips, widget, action->tip, NULL); + } + } else { + // no action + gtk_tooltips_set_tip(tooltips, widget, NULL, NULL); + } } GtkWidget * diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f6af1ca55..f7c493915 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -827,8 +827,8 @@ GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inksc unsigned int shortcut = sp_shortcut_get_primary(verb); - if (shortcut!=GDK_VoidSymbol) { - gchar* key = sp_shortcut_get_label(shortcut); + if (shortcut != GDK_VoidSymbol) { + gchar *key = sp_shortcut_get_label(shortcut); gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); if ( t ) { gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, tip, 0 ); -- 2.30.2