summaryrefslogtreecommitdiff
path: root/gtk/gtkbutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-09-20 14:43:18 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-09-20 14:43:18 +0000
commitef7455d9814b76b1f0f23a714e02e65c97bba49e (patch)
treee39ef74296c397b49b0bc1415c4724e31351467e /gtk/gtkbutton.c
parent3d3e4699b8788b75059bca7baf56cc366f1cb757 (diff)
downloadgdk-pixbuf-ef7455d9814b76b1f0f23a714e02e65c97bba49e.tar.gz
Add a boolean ::displace-focus style property and apply child displacement
2004-09-20 Matthias Clasen <mclasen@redhat.com> * gtk/gtkbutton.c (gtk_button_class_init): Add a boolean ::displace-focus style property and apply child displacement to the focus rectangle if it is TRUE. (#141170, Soeren Sandmann)
Diffstat (limited to 'gtk/gtkbutton.c')
-rw-r--r--gtk/gtkbutton.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index d2ed60125..bcce75134 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -376,6 +376,21 @@ gtk_button_class_init (GtkButtonClass *klass)
0,
G_PARAM_READABLE));
+ /**
+ * GtkButton:displace-focus:
+ *
+ * Whether the child_displacement_x/child_displacement_y properties should also
+ * affect the focus rectangle.
+ *
+ * Since: 2.6
+ */
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boolean ("displace-focus",
+ P_("Displace focus"),
+ P_("Whether the child_displacement_x/_y properties should also affect the focus rectangle"),
+ FALSE,
+ G_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"),
@@ -1064,6 +1079,16 @@ _gtk_button_paint (GtkButton *button,
if (GTK_WIDGET_HAS_FOCUS (widget))
{
+ gint child_displacement_x;
+ gint child_displacement_y;
+ gboolean displace_focus;
+
+ gtk_widget_style_get (GTK_WIDGET (widget),
+ "child_displacement_y", &child_displacement_y,
+ "child_displacement_x", &child_displacement_x,
+ "displace_focus", &displace_focus,
+ NULL);
+
if (interior_focus)
{
x += widget->style->xthickness + focus_pad;
@@ -1079,6 +1104,12 @@ _gtk_button_paint (GtkButton *button,
height += 2 * (focus_width + focus_pad);
}
+ if (button->depressed && displace_focus)
+ {
+ x += child_displacement_x;
+ y += child_displacement_y;
+ }
+
gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
area, widget, "button",
x, y, width, height);