Commit 43910107 authored by Jon A. Cruz's avatar Jon A. Cruz

Cleanups from backports.

(bzr r9863)
parent 6c551a61
......@@ -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<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;
}
/*
......
......@@ -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 *
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment