Make stock buttons have mnemonics again

We used to treat stock buttons as having an implicit use-underline.
A recent but fix lost that.
This commit is contained in:
Matthias Clasen
2009-07-01 15:11:03 -04:00
parent bde64ecda2
commit 584c9c8a02

View File

@ -934,15 +934,15 @@ gtk_button_construct_child (GtkButton *button)
GtkWidget *image = NULL; GtkWidget *image = NULL;
gchar *label_text = NULL; gchar *label_text = NULL;
gint image_spacing; gint image_spacing;
if (!button->constructed) if (!button->constructed)
return; return;
if (!button->label_text && !priv->image) if (!button->label_text && !priv->image)
return; return;
gtk_widget_style_get (GTK_WIDGET (button), gtk_widget_style_get (GTK_WIDGET (button),
"image-spacing", &image_spacing, "image-spacing", &image_spacing,
NULL); NULL);
if (priv->image && !priv->image_is_stock) if (priv->image && !priv->image_is_stock)
@ -951,7 +951,7 @@ gtk_button_construct_child (GtkButton *button)
if (image->parent) if (image->parent)
gtk_container_remove (GTK_CONTAINER (image->parent), image); gtk_container_remove (GTK_CONTAINER (image->parent), image);
} }
priv->image = NULL; priv->image = NULL;
if (GTK_BIN (button)->child) if (GTK_BIN (button)->child)
@ -973,7 +973,7 @@ gtk_button_construct_child (GtkButton *button)
if (image) if (image)
{ {
priv->image = image; priv->image = image;
g_object_set (priv->image, g_object_set (priv->image,
"visible", show_image (button), "visible", show_image (button),
"no-show-all", TRUE, "no-show-all", TRUE,
NULL); NULL);
@ -997,7 +997,7 @@ gtk_button_construct_child (GtkButton *button)
if (label_text) if (label_text)
{ {
if (button->use_underline) if (button->use_underline || button->use_stock)
{ {
label = gtk_label_new_with_mnemonic (label_text); label = gtk_label_new_with_mnemonic (label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), gtk_label_set_mnemonic_widget (GTK_LABEL (label),
@ -1012,7 +1012,7 @@ gtk_button_construct_child (GtkButton *button)
else else
gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
} }
gtk_container_add (GTK_CONTAINER (button), align); gtk_container_add (GTK_CONTAINER (button), align);
gtk_container_add (GTK_CONTAINER (align), box); gtk_container_add (GTK_CONTAINER (align), box);
gtk_widget_show_all (align); gtk_widget_show_all (align);
@ -1021,18 +1021,18 @@ gtk_button_construct_child (GtkButton *button)
return; return;
} }
if (button->use_underline) if (button->use_underline || button->use_stock)
{ {
label = gtk_label_new_with_mnemonic (button->label_text); label = gtk_label_new_with_mnemonic (button->label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button)); gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
} }
else else
label = gtk_label_new (button->label_text); label = gtk_label_new (button->label_text);
if (priv->align_set) if (priv->align_set)
gtk_misc_set_alignment (GTK_MISC (label), priv->xalign, priv->yalign); gtk_misc_set_alignment (GTK_MISC (label), priv->xalign, priv->yalign);
gtk_widget_show (label); gtk_widget_show (label);
gtk_container_add (GTK_CONTAINER (button), label); gtk_container_add (GTK_CONTAINER (button), label);
} }