Commit 99a53112 authored by Allison Karlitskaya's avatar Allison Karlitskaya

GtkAccelLabel: adjust recent accel changes

In the event that a GtkAccelKey was present for the closure but it
contained a keyval of 0 the previous code would show "".  After the
recent adjustments, "-/-" would be shown in this case.

It turns out to be a pretty common case, so fix the logic to stop using
'0' as a magic value to mean "don't have an accel" and add a separate
boolean for that purpose.
parent 8c3caae3
...@@ -908,23 +908,35 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label) ...@@ -908,23 +908,35 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
if (enable_accels && (accel_label->priv->accel_closure || accel_label->priv->accel_key)) if (enable_accels && (accel_label->priv->accel_closure || accel_label->priv->accel_key))
{ {
guint accel_key = accel_label->priv->accel_key; gboolean have_accel = FALSE;
GdkModifierType accel_mods = accel_label->priv->accel_mods; guint accel_key;
GdkModifierType accel_mods;
/* First check for a manual accel set with _set_accel() */
if (accel_label->priv->accel_key)
{
accel_mods = accel_label->priv->accel_mods;
accel_key = accel_label->priv->accel_key;
have_accel = TRUE;
}
/* If we don't have a hardcoded value, check the accel group */ /* If we don't have a hardcoded value, check the accel group */
if (!accel_key) if (!have_accel)
{ {
GtkAccelKey *key = gtk_accel_group_find (accel_label->priv->accel_group, find_accel, accel_label->priv->accel_closure); GtkAccelKey *key;
key = gtk_accel_group_find (accel_label->priv->accel_group, find_accel, accel_label->priv->accel_closure);
if (key && key->accel_flags & GTK_ACCEL_VISIBLE) if (key && key->accel_flags & GTK_ACCEL_VISIBLE)
{ {
accel_key = key->accel_key; accel_key = key->accel_key;
accel_mods = key->accel_mods; accel_mods = key->accel_mods;
have_accel = TRUE;
} }
} }
/* If we found a key using either method, set it */ /* If we found a key using either method, set it */
if (accel_key) if (have_accel)
{ {
GtkAccelLabelClass *klass; GtkAccelLabelClass *klass;
gchar *tmp; gchar *tmp;
...@@ -934,10 +946,12 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label) ...@@ -934,10 +946,12 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
accel_label->priv->accel_string = g_strconcat (" ", tmp, NULL); accel_label->priv->accel_string = g_strconcat (" ", tmp, NULL);
g_free (tmp); g_free (tmp);
} }
if (!accel_label->priv->accel_string)
accel_label->priv->accel_string = g_strdup ("-/-"); else
/* Otherwise we have a closure with no key. Show "-/-". */
accel_label->priv->accel_string = g_strdup ("-/-");
} }
if (!accel_label->priv->accel_string) if (!accel_label->priv->accel_string)
accel_label->priv->accel_string = g_strdup (""); accel_label->priv->accel_string = g_strdup ("");
......
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