summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 776a483)
raw | patch | inline | side by side (parent: 776a483)
author | Jon A. Cruz <jon@joncruz.org> | |
Fri, 29 Oct 2010 07:49:37 +0000 (00:49 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Fri, 29 Oct 2010 07:49:37 +0000 (00:49 -0700) |
src/shortcuts.cpp | patch | blob | history | |
src/widgets/button.cpp | patch | blob | history | |
src/widgets/toolbox.cpp | patch | blob | history |
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp
index bf7fb8a4339561725e136fe6f11c09e57fb1f5b5..c8ff5b3296c9e328efc3193e659138e064355ecf 100644 (file)
--- a/src/shortcuts.cpp
+++ b/src/shortcuts.cpp
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
* 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)
- ));
+ gchar *result = 0;
+ if (shortcut != GDK_VoidSymbol) {
+ result = 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)
+ ));
+ }
+ return result;
}
/*
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index aa32a9d9101f727cf063e6c19bf7f18afa80e0bd..dc830d09690594737003056d9ef5aa59febf2b83 100644 (file)
--- 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 *
index f6af1ca55102fc9b0cb85bbe18a2c26d567b6509..f7c493915509f8e65a0ef90d5638658de2172c56 100644 (file)
--- 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 );