ShellKeyringPrompt: Strip out mnemonics indicators from labels
Currently GNOME Shell doesn't support mnemonics and prompters may send labels with it. Remove the mnemonics indicator for now. Signed-off-by: Stef Walter <stefw@redhat.com> * Fixed style issue https://bugzilla.gnome.org/show_bug.cgi?id=750465
This commit is contained in:
parent
b881e4b62a
commit
59a18c4ead
@ -111,6 +111,34 @@ shell_keyring_prompt_init (ShellKeyringPrompt *self)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
remove_mnemonics (const GValue *value)
|
||||||
|
{
|
||||||
|
const gchar mnemonic = '_';
|
||||||
|
gchar *stripped_label, *temp;
|
||||||
|
const gchar *label;
|
||||||
|
|
||||||
|
g_return_val_if_fail (value != NULL, NULL);
|
||||||
|
g_return_val_if_fail (G_VALUE_HOLDS_STRING (value), NULL);
|
||||||
|
|
||||||
|
label = g_value_get_string (value);
|
||||||
|
g_return_val_if_fail (label != NULL, NULL);
|
||||||
|
|
||||||
|
/* Stripped label will have the original label lenght at most */
|
||||||
|
stripped_label = temp = g_new (gchar, strlen(label) + 1);
|
||||||
|
g_assert (stripped_label != NULL);
|
||||||
|
|
||||||
|
while (*label != '\0')
|
||||||
|
{
|
||||||
|
if (*label == mnemonic)
|
||||||
|
label++;
|
||||||
|
*(temp++) = *(label++);
|
||||||
|
}
|
||||||
|
*temp = '\0';
|
||||||
|
|
||||||
|
return stripped_label;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shell_keyring_prompt_set_property (GObject *obj,
|
shell_keyring_prompt_set_property (GObject *obj,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -145,7 +173,7 @@ shell_keyring_prompt_set_property (GObject *obj,
|
|||||||
break;
|
break;
|
||||||
case PROP_CHOICE_LABEL:
|
case PROP_CHOICE_LABEL:
|
||||||
g_free (self->choice_label);
|
g_free (self->choice_label);
|
||||||
self->choice_label = g_value_dup_string (value);
|
self->choice_label = remove_mnemonics (value);
|
||||||
if (!self->choice_label)
|
if (!self->choice_label)
|
||||||
self->choice_label = g_strdup ("");
|
self->choice_label = g_strdup ("");
|
||||||
g_object_notify (obj, "choice-label");
|
g_object_notify (obj, "choice-label");
|
||||||
@ -165,12 +193,12 @@ shell_keyring_prompt_set_property (GObject *obj,
|
|||||||
break;
|
break;
|
||||||
case PROP_CONTINUE_LABEL:
|
case PROP_CONTINUE_LABEL:
|
||||||
g_free (self->continue_label);
|
g_free (self->continue_label);
|
||||||
self->continue_label = g_value_dup_string (value);
|
self->continue_label = remove_mnemonics (value);
|
||||||
g_object_notify (obj, "continue-label");
|
g_object_notify (obj, "continue-label");
|
||||||
break;
|
break;
|
||||||
case PROP_CANCEL_LABEL:
|
case PROP_CANCEL_LABEL:
|
||||||
g_free (self->cancel_label);
|
g_free (self->cancel_label);
|
||||||
self->cancel_label = g_value_dup_string (value);
|
self->cancel_label = remove_mnemonics (value);
|
||||||
g_object_notify (obj, "cancel-label");
|
g_object_notify (obj, "cancel-label");
|
||||||
break;
|
break;
|
||||||
case PROP_PASSWORD_ACTOR:
|
case PROP_PASSWORD_ACTOR:
|
||||||
|
Loading…
Reference in New Issue
Block a user