2006-06-01 Matthias Clasen <mclasen@redhat.com>
+ * gtk/gtktoolbutton.c (gtk_tool_button_class_init): Add
+ an icon-spacing style property for the same purpose.
+
+ * gtk/gtkbutton.c (gtk_button_class_init): Add an image-spacing
+ style property that allows to adjust the spacing between image
+ and label in button. (#320431, James Moger)
+
* gtk-pristine/gtkprintoperation-private.h:
* gtk-pristine/gtkprintoperation.c:
* gtk-pristine/gtkprintoperation-unix.c: Move the
2006-06-01 Matthias Clasen <mclasen@redhat.com>
+ * gtk/gtktoolbutton.c (gtk_tool_button_class_init): Add
+ an icon-spacing style property for the same purpose.
+
+ * gtk/gtkbutton.c (gtk_button_class_init): Add an image-spacing
+ style property that allows to adjust the spacing between image
+ and label in button. (#320431, James Moger)
+
* gtk-pristine/gtkprintoperation-private.h:
* gtk-pristine/gtkprintoperation.c:
* gtk-pristine/gtkprintoperation-unix.c: Move the
static void gtk_button_unrealize (GtkWidget *widget);
static void gtk_button_map (GtkWidget *widget);
static void gtk_button_unmap (GtkWidget *widget);
+static void gtk_button_style_set (GtkWidget *widget,
+ GtkStyle *prev_style);
static void gtk_button_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_button_size_allocate (GtkWidget *widget,
widget_class->unrealize = gtk_button_unrealize;
widget_class->map = gtk_button_map;
widget_class->unmap = gtk_button_unmap;
+ widget_class->style_set = gtk_button_style_set;
widget_class->size_request = gtk_button_size_request;
widget_class->size_allocate = gtk_button_size_allocate;
widget_class->expose_event = gtk_button_expose;
/**
* GtkButton:image-position:
*
- * Sets the position of the image relative to the text inside the button.
+ * The position of the image relative to the text inside the button.
*
* Since: 2.10
*/
g_object_class_install_property (gobject_class,
PROP_IMAGE_POSITION,
g_param_spec_enum ("image-position",
- P_("Image position"),
+ P_("Image position"),
P_("The position of the image relative to the text"),
GTK_TYPE_POSITION_TYPE,
GTK_POS_LEFT,
GTK_TYPE_BORDER,
GTK_PARAM_READABLE));
+ /**
+ * GtkButton::image-spacing:
+ *
+ * Spacing in pixels between the image and label.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("image-spacing",
+ P_("Image spacing"),
+ P_("Spacing in pixels between the image and label"),
+ 0,
+ G_MAXINT,
+ 2,
+ GTK_PARAM_READABLE));
+
+
gtk_settings_install_property (g_param_spec_boolean ("gtk-button-images",
P_("Show button images"),
P_("Whether stock icons should be shown in buttons"),
GtkWidget *align;
GtkWidget *image = NULL;
gchar *label_text = NULL;
+ gint image_spacing;
if (!button->constructed)
return;
if (!button->label_text && !priv->image)
return;
+ gtk_widget_style_get (GTK_WIDGET (button),
+ "image-spacing", &image_spacing,
+ NULL);
+
if (priv->image && !priv->image_is_stock)
{
image = g_object_ref (priv->image);
if (priv->image_position == GTK_POS_LEFT ||
priv->image_position == GTK_POS_RIGHT)
- box = gtk_hbox_new (FALSE, 2);
+ box = gtk_hbox_new (FALSE, image_spacing);
else
- box = gtk_vbox_new (FALSE, 2);
+ box = gtk_vbox_new (FALSE, image_spacing);
if (priv->align_set)
align = gtk_alignment_new (priv->xalign, priv->yalign, 0.0, 0.0);
GTK_WIDGET_CLASS (gtk_button_parent_class)->unmap (widget);
}
+static void
+gtk_button_style_set (GtkWidget *widget,
+ GtkStyle *prev_style)
+{
+ gtk_button_construct_child (GTK_BUTTON (widget));
+}
+
static void
gtk_button_get_props (GtkButton *button,
GtkBorder *default_border,
* @button: a #GtkButton
* @position: the position
*
- * Sets the position of the image relative to the text inside the button.
+ * Sets the position of the image relative to the text
+ * inside the button.
*
* Since: 2.10
*/
* gtk_button_get_image_position:
* @button: a #GtkButton
*
- * Gets the position of the image relative to the text inside the button.
+ * Gets the position of the image relative to the text
+ * inside the button.
*
* Return value: the position
*
return priv->image_position;
}
+
#define __GTK_BUTTON_C__
#include "gtkaliasdef.c"
static gboolean gtk_tool_button_create_menu_proxy (GtkToolItem *item);
static void button_clicked (GtkWidget *widget,
GtkToolButton *button);
+static void gtk_tool_button_style_set (GtkWidget *widget,
+ GtkStyle *prev_style);
static void gtk_tool_button_construct_contents (GtkToolItem *tool_item);
gtk_tool_button_class_init (GtkToolButtonClass *klass)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
GtkToolItemClass *tool_item_class;
parent_class = g_type_class_peek_parent (klass);
object_class = (GObjectClass *)klass;
+ widget_class = (GtkWidgetClass *)klass;
tool_item_class = (GtkToolItemClass *)klass;
object_class->set_property = gtk_tool_button_set_property;
object_class->notify = gtk_tool_button_property_notify;
object_class->finalize = gtk_tool_button_finalize;
+ widget_class->style_set = gtk_tool_button_style_set;
+
tool_item_class->create_menu_proxy = gtk_tool_button_create_menu_proxy;
tool_item_class->toolbar_reconfigured = gtk_tool_button_toolbar_reconfigured;
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE));
+ /**
+ * GtkButton::icon-spacing:
+ *
+ * Spacing in pixels between the icon and label.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("icon-spacing",
+ P_("Icon spacing"),
+ P_("Spacing in pixels between the icon and label"),
+ 0,
+ G_MAXINT,
+ 0,
+ GTK_PARAM_READWRITE));
+
/**
* GtkToolButton::clicked:
* @toolbutton: the object that emitted the signal
gboolean need_icon = FALSE;
GtkIconSize icon_size;
GtkWidget *box = NULL;
+ guint icon_spacing;
+
+ gtk_widget_style_get (GTK_WIDGET (tool_item),
+ "icon-spacing", &icon_spacing,
+ NULL);
if (button->priv->icon_widget && button->priv->icon_widget->parent)
{
break;
case GTK_TOOLBAR_BOTH:
- box = gtk_vbox_new (FALSE, 0);
+ box = gtk_vbox_new (FALSE, icon_spacing);
if (icon)
gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
break;
case GTK_TOOLBAR_BOTH_HORIZ:
- box = gtk_hbox_new (FALSE, 0);
+ box = gtk_hbox_new (FALSE, icon_spacing);
if (icon)
gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
if (label)
gtk_tool_button_construct_contents (tool_item);
}
+static void
+gtk_tool_button_style_set (GtkWidget *widget,
+ GtkStyle *prev_style)
+{
+ gtk_tool_button_construct_contents (GTK_TOOL_ITEM (widget));
+}
+
/**
* gtk_tool_button_new_from_stock:
* @stock_id: the name of the stock item
return button->priv->button;
}
+
#define __GTK_TOOL_BUTTON_C__
#include "gtkaliasdef.c"