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/widgets/button.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/widgets/button.cpp') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 6769fa389..aa32a9d91 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -27,6 +27,8 @@ #include "shortcuts.h" #include "interface.h" +#include + #include "icon.h" #include "button.h" @@ -291,15 +293,15 @@ sp_button_set_composed_tooltip (GtkTooltips *tooltips, GtkWidget *widget, SPActi { if (action) { unsigned int shortcut = sp_shortcut_get_primary (action->verb); - if (shortcut) { + if (shortcut!=GDK_VoidSymbol) { // there's both action and shortcut - gchar key[256]; - sp_ui_shortcut_string (shortcut, key); + 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 -- 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/widgets/button.cpp | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'src/widgets/button.cpp') 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 * -- cgit v1.2.3