[Xfce4-commits] <gtk-xfce-engine:master> Draw inset border around default button (bug #8454)
Peter de Ridder
noreply at xfce.org
Thu Mar 29 22:00:04 CEST 2012
Updating branch refs/heads/master
to 8e0ab26b57e5d87b7434ac3045946c07a37dff03 (commit)
from ad461c453a0415d8781280a857397639a8190271 (commit)
commit 8e0ab26b57e5d87b7434ac3045946c07a37dff03
Author: Peter de Ridder <peter at xfce.org>
Date: Mon Mar 26 23:39:27 2012 +0200
Draw inset border around default button (bug #8454)
Gtk 3 doesn't draw a inset border around the default button when
-GtkButton-default-border is set. With -xfce-button-default-border this
border will be drawn.
gtk-3.0/xfce_engine.c | 70 +++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 59 insertions(+), 11 deletions(-)
diff --git a/gtk-3.0/xfce_engine.c b/gtk-3.0/xfce_engine.c
index c2231e4..e04b146 100644
--- a/gtk-3.0/xfce_engine.c
+++ b/gtk-3.0/xfce_engine.c
@@ -15,7 +15,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 1999-2004 Olivier Fourdan (fourdan at xfce.org)
- * Copyright (C) 2011 Peter de Ridder (peter at xfce.org)
+ * Copyright (C) 2011-2012 Peter de Ridder (peter at xfce.org)
*
* Portions based Thinice port by
* Tim Gerla <timg at rrv.net>,
@@ -57,6 +57,9 @@
#define GRIP_STYLE "grip-style"
#define XFCE_GRIP_STYLE "-"XFCE_NAMESPACE"-"GRIP_STYLE
+#define BUTTON_DEFAULT_BORDER "button-default-border"
+#define XFCE_BUTTON_DEFAULT_BORDER "-"XFCE_NAMESPACE"-"BUTTON_DEFAULT_BORDER
+
/* macros to make sure that things are sane ... */
#define GE_CAIRO_INIT \
cairo_set_line_width (cr, 1.0); \
@@ -70,6 +73,7 @@ G_DEFINE_DYNAMIC_TYPE(XfceEngine, xfce_engine, GTK_TYPE_THEMING_ENGINE)
/* internal functions */
static void xfce_draw_grips(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height, GtkOrientation orientation);
+static void xfce_draw_frame(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height, GtkBorderStyle border_style);
static void render_line(GtkThemingEngine * engine, cairo_t * cr, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
static void render_background(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height);
@@ -409,13 +413,58 @@ static void render_frame(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdo
gint xthick, ythick;
GtkStateFlags state;
GtkBorderStyle border_style;
+ GtkBorder border;
+ GtkBorder *default_border;
+
+ state = gtk_theming_engine_get_state(engine);
+ gtk_theming_engine_get(engine, state, GTK_STYLE_PROPERTY_BORDER_STYLE, &border_style, NULL);
+
+ xthick = border.left;
+ ythick = border.top;
+
+ xt = MIN(xthick, width - 1);
+ yt = MIN(ythick, height - 1);
+
+ /* Spin buttons are a special case */
+ if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SPINBUTTON) && gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON))
+ {
+ /* Draw an outset border when hovering a spinner button */
+ if (!(state & GTK_STATE_FLAG_ACTIVE))
+ border_style = GTK_BORDER_STYLE_OUTSET;
+ }
+
+ /* Default buttons are a special case */
+ if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON) && gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_DEFAULT))
+ {
+ /* Draw an inset border around the default border */
+ gtk_theming_engine_get(engine, state, XFCE_BUTTON_DEFAULT_BORDER, &default_border, NULL);
+
+ if (default_border &&
+ (default_border->left > xt) && (default_border->right > xt) &&
+ (default_border->top > yt) && (default_border->bottom > yt))
+ {
+ xfce_draw_frame(engine, cr, x - default_border->left, y - default_border->top,
+ width + default_border->left + default_border->right, height + default_border->top + default_border->bottom,
+ GTK_BORDER_STYLE_INSET);
+ }
+
+ gtk_border_free(default_border);
+ }
+
+ xfce_draw_frame(engine, cr, x, y, width, height, border_style);
+}
+
+static void xfce_draw_frame(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height, GtkBorderStyle border_style)
+{
+ gint xt, yt;
+ gint xthick, ythick;
+ GtkStateFlags state;
GdkRGBA dark, light, mid, bg;
GdkRGBA black = {0.0, 0.0, 0.0, 1.0}; /* black */
gboolean smooth_edge;
GtkBorder border;
state = gtk_theming_engine_get_state(engine);
- gtk_theming_engine_get(engine, state, GTK_STYLE_PROPERTY_BORDER_STYLE, &border_style, NULL);
if (border_style == GTK_BORDER_STYLE_NONE)
return;
@@ -428,14 +477,6 @@ static void render_frame(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdo
xthick = border.left;
ythick = border.top;
- /* Spin buttons are a special case */
- if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SPINBUTTON) && gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON))
- {
- /* Draw an outset border when hovering a spinner button */
- if (!(state & GTK_STATE_FLAG_ACTIVE))
- border_style = GTK_BORDER_STYLE_OUTSET;
- }
-
xt = MIN(xthick, width - 1);
yt = MIN(ythick, height - 1);
@@ -1406,7 +1447,7 @@ static void render_frame_gap(GtkThemingEngine * engine, cairo_t * cr, gdouble x,
cairo_rectangle (cr, x0, ey + eh, x1 - x0, y_1 - (ey + eh));
cairo_clip (cr);
- render_frame (engine, cr, x, y, width, height);
+ xfce_draw_frame (engine, cr, x, y, width, height, border_style);
cairo_restore (cr);
}
@@ -1619,6 +1660,13 @@ static void xfce_engine_class_init(XfceEngineClass * klass)
gtk_theming_engine_register_property(XFCE_NAMESPACE, NULL,
g_param_spec_enum(GRIP_STYLE, "Grip style", "Grip style",
XFCE_TYPE_GRIP_STYLE, XFCE_GRIP_ROUGH, 0));
+
+ /* Compatibility properties */
+ gtk_theming_engine_register_property(XFCE_NAMESPACE, NULL,
+ g_param_spec_boxed (BUTTON_DEFAULT_BORDER,
+ "Default Spacing",
+ "Extra space to add for GTK_CAN_DEFAULT buttons",
+ GTK_TYPE_BORDER, 0));
}
static void xfce_engine_class_finalize(XfceEngineClass * klass)
More information about the Xfce4-commits
mailing list