2006-03-05 Matthias Clasen <mclasen@redhat.com> Fix handling of image-only buttons. (#332985, Kalle Vahlmann, #333555) * gtk/gtkbutton.c (gtk_button_construct_child): Don't return early if there an image to show. (show_image): Always return TRUE if there is no text.
This commit is contained in:
parent
33f840d244
commit
459eeebde9
@ -677,10 +677,17 @@ gtk_button_new (void)
|
|||||||
static gboolean
|
static gboolean
|
||||||
show_image (GtkButton *button)
|
show_image (GtkButton *button)
|
||||||
{
|
{
|
||||||
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (button));
|
|
||||||
gboolean show;
|
gboolean show;
|
||||||
|
|
||||||
g_object_get (settings, "gtk-button-images", &show, NULL);
|
if (button->label_text)
|
||||||
|
{
|
||||||
|
GtkSettings *settings;
|
||||||
|
|
||||||
|
settings = gtk_widget_get_settings (GTK_WIDGET (button));
|
||||||
|
g_object_get (settings, "gtk-button-images", &show, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
show = TRUE;
|
||||||
|
|
||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
@ -699,25 +706,24 @@ gtk_button_construct_child (GtkButton *button)
|
|||||||
if (!button->constructed)
|
if (!button->constructed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (button->label_text == NULL)
|
if (!button->label_text && !priv->image)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (GTK_BIN (button)->child)
|
if (priv->image && !priv->image_is_stock)
|
||||||
{
|
{
|
||||||
if (priv->image && !priv->image_is_stock)
|
image = g_object_ref (priv->image);
|
||||||
{
|
if (image->parent)
|
||||||
image = g_object_ref (priv->image);
|
gtk_container_remove (GTK_CONTAINER (image->parent), image);
|
||||||
if (image->parent)
|
|
||||||
gtk_container_remove (GTK_CONTAINER (image->parent), image);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_container_remove (GTK_CONTAINER (button),
|
|
||||||
GTK_BIN (button)->child);
|
|
||||||
|
|
||||||
priv->image = NULL;
|
priv->image = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GTK_BIN (button)->child)
|
||||||
|
gtk_container_remove (GTK_CONTAINER (button),
|
||||||
|
GTK_BIN (button)->child);
|
||||||
|
|
||||||
if (button->use_stock &&
|
if (button->use_stock &&
|
||||||
|
button->label_text &&
|
||||||
gtk_stock_lookup (button->label_text, &item))
|
gtk_stock_lookup (button->label_text, &item))
|
||||||
{
|
{
|
||||||
if (!image)
|
if (!image)
|
||||||
@ -730,9 +736,6 @@ gtk_button_construct_child (GtkButton *button)
|
|||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
label = gtk_label_new_with_mnemonic (label_text);
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
|
|
||||||
|
|
||||||
priv->image = image;
|
priv->image = image;
|
||||||
|
|
||||||
g_object_set (priv->image,
|
g_object_set (priv->image,
|
||||||
@ -747,7 +750,15 @@ gtk_button_construct_child (GtkButton *button)
|
|||||||
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
||||||
|
if (label_text)
|
||||||
|
{
|
||||||
|
label = gtk_label_new_with_mnemonic (label_text);
|
||||||
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
|
||||||
|
GTK_WIDGET (button));
|
||||||
|
|
||||||
|
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (button), align);
|
gtk_container_add (GTK_CONTAINER (button), align);
|
||||||
gtk_container_add (GTK_CONTAINER (align), hbox);
|
gtk_container_add (GTK_CONTAINER (align), hbox);
|
||||||
@ -758,7 +769,7 @@ gtk_button_construct_child (GtkButton *button)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button->use_underline)
|
if (button->use_underline)
|
||||||
{
|
{
|
||||||
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));
|
||||||
|
Loading…
Reference in New Issue
Block a user