[gtk+] color scale: Improve themability
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] color scale: Improve themability
- Date: Sat, 16 Jan 2016 01:10:07 +0000 (UTC)
commit e7fc87e4ac5548db71bfab93e7293fe5fb66ab07
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 15 20:08:57 2016 -0500
color scale: Improve themability
Add the .color class, so themes can style scale.color.
Clip the trough rendering to the content path, so that
themes can set rounded corners.
gtk/gtkcolorscale.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcolorscale.c b/gtk/gtkcolorscale.c
index 81dd685..5509c9c 100644
--- a/gtk/gtkcolorscale.c
+++ b/gtk/gtkcolorscale.c
@@ -27,6 +27,7 @@
#include "gtkaccessible.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtkrenderprivate.h"
#include <math.h>
@@ -216,6 +217,7 @@ scale_draw (GtkWidget *widget,
GtkColorScale *scale = GTK_COLOR_SCALE (widget);
gint width, height, x_offset, y_offset;
cairo_pattern_t *pattern;
+ GtkStyleContext *context;
create_surface (scale);
gtk_color_scale_get_trough_size (scale,
@@ -224,7 +226,9 @@ scale_draw (GtkWidget *widget,
cairo_save (cr);
cairo_translate (cr, x_offset, y_offset);
- cairo_rectangle (cr, 0, 0, width, height);
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_render_content_path (context, cr, 0, 0, width, height);
pattern = cairo_pattern_create_for_surface (scale->priv->surface);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL &&
@@ -251,6 +255,8 @@ scale_draw (GtkWidget *widget,
static void
gtk_color_scale_init (GtkColorScale *scale)
{
+ GtkStyleContext *context;
+
scale->priv = gtk_color_scale_get_instance_private (scale);
gtk_widget_add_events (GTK_WIDGET (scale), GDK_TOUCH_MASK);
@@ -260,6 +266,9 @@ gtk_color_scale_init (GtkColorScale *scale)
G_CALLBACK (hold_action), scale);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (scale->priv->long_press_gesture),
GTK_PHASE_TARGET);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (scale));
+ gtk_style_context_add_class (context, "color");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]