[gtk+] Port GtkRange widgets to GtkStyleContext
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Port GtkRange widgets to GtkStyleContext
- Date: Mon, 13 Dec 2010 21:34:29 +0000 (UTC)
commit c64a1891f80b2dd9041e21b7ed027f33b10b27dc
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Dec 13 13:43:52 2010 +0100
Port GtkRange widgets to GtkStyleContext
gtk/gtkrange.c | 342 +++++++++++++++++++++++++------------------------
gtk/gtkscale.c | 68 +++++-----
gtk/gtkscrollbar.c | 12 +-
gtk/gtkstylecontext.h | 14 ++
4 files changed, 230 insertions(+), 206 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 3345e88..c2409af 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -214,12 +214,11 @@ static gboolean gtk_range_grab_broken (GtkWidget *widget,
GdkEventGrabBroken *event);
static void gtk_range_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
-static void gtk_range_state_changed (GtkWidget *widget,
- GtkStateType previous_state);
+static void gtk_range_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_state);
static gboolean gtk_range_scroll_event (GtkWidget *widget,
GdkEventScroll *event);
-static void gtk_range_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
+static void gtk_range_style_updated (GtkWidget *widget);
static void update_slider_position (GtkRange *range,
gint mouse_x,
gint mouse_y);
@@ -316,8 +315,8 @@ gtk_range_class_init (GtkRangeClass *class)
widget_class->leave_notify_event = gtk_range_leave_notify;
widget_class->grab_broken_event = gtk_range_grab_broken;
widget_class->grab_notify = gtk_range_grab_notify;
- widget_class->state_changed = gtk_range_state_changed;
- widget_class->style_set = gtk_range_style_set;
+ widget_class->state_flags_changed = gtk_range_state_flags_changed;
+ widget_class->style_updated = gtk_range_style_updated;
widget_class->key_press_event = gtk_range_key_press;
class->move_slider = gtk_range_move_slider;
@@ -1044,9 +1043,12 @@ gtk_range_set_min_slider_size (GtkRange *range,
{
priv->min_slider_size = min_size;
- priv->need_recalc = TRUE;
- gtk_range_calc_layout (range, priv->adjustment->value);
- gtk_widget_queue_draw (GTK_WIDGET (range));
+ if (gtk_widget_is_drawable (GTK_WIDGET (range)))
+ {
+ priv->need_recalc = TRUE;
+ gtk_range_calc_layout (range, priv->adjustment->value);
+ gtk_widget_queue_draw (GTK_WIDGET (range));
+ }
}
}
@@ -1769,8 +1771,6 @@ gtk_range_realize (GtkWidget *widget)
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (priv->event_window, range);
-
- gtk_widget_style_attach (widget);
}
static void
@@ -1813,81 +1813,74 @@ gtk_range_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_range_parent_class)->unmap (widget);
}
-static const gchar *
-gtk_range_get_slider_detail (GtkRange *range)
+static void
+_gtk_range_update_context_for_stepper (GtkRange *range,
+ GtkStyleContext *context,
+ Stepper stepper)
{
GtkRangePrivate *priv = range->priv;
- const gchar *slider_detail;
-
- if (priv->slider_detail_quark)
- return g_quark_to_string (priv->slider_detail_quark);
-
- slider_detail = GTK_RANGE_GET_CLASS (range)->slider_detail;
-
- if (slider_detail && slider_detail[0] == 'X')
- {
- gchar *detail = g_strdup (slider_detail);
-
- detail[0] = priv->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v';
-
- priv->slider_detail_quark = g_quark_from_string (detail);
-
- g_free (detail);
-
- return g_quark_to_string (priv->slider_detail_quark);
- }
+ GtkJunctionSides sides = 0;
+ gboolean vertical, is_rtl;
- return slider_detail;
-}
+ vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL);
+ is_rtl = (gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL);
-static const gchar *
-gtk_range_get_stepper_detail (GtkRange *range,
- Stepper stepper)
-{
- GtkRangePrivate *priv = range->priv;
- const gchar *stepper_detail;
- gchar *detail;
- const gchar *position = NULL;
-
- if (priv->stepper_detail_quark[stepper])
- return g_quark_to_string (priv->stepper_detail_quark[stepper]);
+ /* Take junction sides from what's been
+ * previously set to the widget itself
+ */
+ sides = gtk_style_context_get_junction_sides (context);
- stepper_detail = GTK_RANGE_GET_CLASS (range)->stepper_detail;
+ if (vertical)
+ sides &= ~(GTK_JUNCTION_TOP | GTK_JUNCTION_BOTTOM);
+ else
+ sides &= ~(GTK_JUNCTION_LEFT | GTK_JUNCTION_RIGHT);
switch (stepper)
{
case STEPPER_A:
- position = "_start";
+ if (vertical)
+ sides |= GTK_JUNCTION_BOTTOM;
+ else
+ sides |= (is_rtl) ? GTK_JUNCTION_LEFT : GTK_JUNCTION_RIGHT;
break;
case STEPPER_B:
if (priv->has_stepper_a)
- position = "_start_inner";
+ {
+ if (vertical)
+ sides |= GTK_JUNCTION_TOP;
+ else
+ sides |= (is_rtl) ? GTK_JUNCTION_RIGHT : GTK_JUNCTION_LEFT;
+ }
+
+ if (vertical)
+ sides |= GTK_JUNCTION_BOTTOM;
else
- position = "_start";
+ sides |= (is_rtl) ? GTK_JUNCTION_LEFT : GTK_JUNCTION_RIGHT;
break;
case STEPPER_C:
if (priv->has_stepper_d)
- position = "_end_inner";
+ {
+ if (vertical)
+ sides |= GTK_JUNCTION_BOTTOM;
+ else
+ sides |= (is_rtl) ? GTK_JUNCTION_LEFT : GTK_JUNCTION_RIGHT;
+ }
+
+ if (vertical)
+ sides |= GTK_JUNCTION_TOP;
else
- position = "_end";
+ sides |= (is_rtl) ? GTK_JUNCTION_RIGHT : GTK_JUNCTION_LEFT;
break;
case STEPPER_D:
- position = "_end";
+ if (vertical)
+ sides |= GTK_JUNCTION_TOP;
+ else
+ sides |= (is_rtl) ? GTK_JUNCTION_RIGHT : GTK_JUNCTION_LEFT;
break;
- default:
- g_assert_not_reached ();
}
- detail = g_strconcat (stepper_detail, position, NULL);
-
- if (detail[0] == 'X')
- detail[0] = priv->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v';
-
- priv->stepper_detail_quark[stepper] = g_quark_from_string (detail);
-
- g_free (detail);
-
- return g_quark_to_string (priv->stepper_detail_quark[stepper]);
+ gtk_style_context_set_junction_sides (context, sides);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
}
static void
@@ -1900,17 +1893,15 @@ draw_stepper (GtkRange *range,
{
GtkRangePrivate *priv = range->priv;
GtkAllocation allocation;
- GtkStateType state_type;
- GtkShadowType shadow_type;
- GtkStyle *style;
+ GtkStateFlags state = 0;
+ GtkStyleContext *context;
GtkWidget *widget = GTK_WIDGET (range);
GdkWindow *window;
gfloat arrow_scaling;
GdkRectangle *rect;
gint arrow_x;
gint arrow_y;
- gint arrow_width;
- gint arrow_height;
+ gdouble arrow_size, angle;
gboolean arrow_sensitive;
switch (stepper)
@@ -1948,37 +1939,34 @@ draw_stepper (GtkRange *range,
}
if (!gtk_widget_is_sensitive (GTK_WIDGET (range)) || !arrow_sensitive)
- state_type = GTK_STATE_INSENSITIVE;
- else if (clicked)
- state_type = GTK_STATE_ACTIVE;
- else if (prelighted)
- state_type = GTK_STATE_PRELIGHT;
- else
- state_type = GTK_STATE_NORMAL;
-
- if (clicked && arrow_sensitive)
- shadow_type = GTK_SHADOW_IN;
+ state = GTK_STATE_FLAG_INSENSITIVE;
else
- shadow_type = GTK_SHADOW_OUT;
+ {
+ if (clicked)
+ state |= GTK_STATE_FLAG_ACTIVE;
+ if (prelighted)
+ state |= GTK_STATE_FLAG_PRELIGHT;
+ }
- style = gtk_widget_get_style (widget);
window = gtk_widget_get_window (widget);
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (context);
+ _gtk_range_update_context_for_stepper (range, context, stepper);
+ gtk_style_context_set_state (context, state);
- gtk_paint_box (style, cr,
- state_type, shadow_type,
- widget,
- gtk_range_get_stepper_detail (range, stepper),
- rect->x,
- rect->y,
- rect->width,
- rect->height);
+ gtk_render_background (context, cr,
+ rect->x, rect->y,
+ rect->width, rect->height);
+ gtk_render_frame (context, cr,
+ rect->x, rect->y,
+ rect->width, rect->height);
gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
- arrow_width = rect->width * arrow_scaling;
- arrow_height = rect->height * arrow_scaling;
- arrow_x = rect->x + (rect->width - arrow_width) / 2;
- arrow_y = rect->y + (rect->height - arrow_height) / 2;
+ arrow_size = MIN (rect->width, rect->height) * arrow_scaling;
+ arrow_x = rect->x + (rect->width - arrow_size) / 2;
+ arrow_y = rect->y + (rect->height - arrow_size) / 2;
if (clicked && arrow_sensitive)
{
@@ -1993,13 +1981,29 @@ draw_stepper (GtkRange *range,
arrow_y += arrow_displacement_y;
}
- gtk_paint_arrow (style, cr,
- state_type, shadow_type,
- widget,
- gtk_range_get_stepper_detail (range, stepper),
- arrow_type,
- TRUE,
- arrow_x, arrow_y, arrow_width, arrow_height);
+ switch (arrow_type)
+ {
+ case GTK_ARROW_RIGHT:
+ angle = G_PI / 2;
+ break;
+ case GTK_ARROW_DOWN:
+ angle = G_PI;
+ break;
+ case GTK_ARROW_LEFT:
+ angle = 3 * (G_PI / 2);
+ break;
+ case GTK_ARROW_UP:
+ default:
+ angle = 0;
+ break;
+ }
+
+ gtk_render_arrow (context, cr,
+ angle,
+ arrow_x, arrow_y,
+ arrow_size);
+
+ gtk_style_context_restore (context);
}
static gboolean
@@ -2009,15 +2013,15 @@ gtk_range_draw (GtkWidget *widget,
GtkRange *range = GTK_RANGE (widget);
GtkRangePrivate *priv = range->priv;
gboolean sensitive;
- GtkStateType state;
- GtkShadowType shadow_type;
- GtkStyle *style;
+ GtkStateFlags state = 0;
GdkWindow *window;
gint focus_line_width = 0;
gint focus_padding = 0;
gboolean touchscreen;
gboolean draw_trough = TRUE;
+ GtkStyleContext *context;
+ context = gtk_widget_get_style_context (widget);
g_object_get (gtk_widget_get_settings (widget),
"gtk-touchscreen-mode", &touchscreen,
NULL);
@@ -2026,7 +2030,6 @@ gtk_range_draw (GtkWidget *widget,
priv->adjustment->upper == priv->adjustment->lower)
draw_trough = FALSE;
- style = gtk_widget_get_style (widget);
if (gtk_widget_get_can_focus (GTK_WIDGET (range)))
gtk_widget_style_get (GTK_WIDGET (range),
"focus-line-width", &focus_line_width,
@@ -2072,6 +2075,11 @@ gtk_range_draw (GtkWidget *widget,
"stepper-spacing", &stepper_spacing,
NULL);
+ gtk_style_context_save (context);
+
+ if (!sensitive)
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_INSENSITIVE);
+
if (stepper_spacing > 0)
trough_under_steppers = FALSE;
@@ -2117,6 +2125,9 @@ gtk_range_draw (GtkWidget *widget,
}
}
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH);
+
if (draw_trough)
{
gint trough_change_pos_x = width;
@@ -2131,40 +2142,36 @@ gtk_range_draw (GtkWidget *widget,
priv->slider.height / 2 -
y);
- gtk_paint_box (style, cr,
- sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN,
- GTK_WIDGET (range),
- should_invert (range) ? "trough-upper" : "trough-lower",
- x, y,
- trough_change_pos_x, trough_change_pos_y);
+ /* FIXME: was trough-upper and trough-lower really used,
+ * in that case, it should still be exposed somehow.
+ */
+ gtk_render_background (context, cr, x, y,
+ trough_change_pos_x,
+ trough_change_pos_y);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
trough_change_pos_y = 0;
else
trough_change_pos_x = 0;
- gtk_paint_box (style, cr,
- sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN,
- GTK_WIDGET (range),
- should_invert (range) ? "trough-lower" : "trough-upper",
- x + trough_change_pos_x, y + trough_change_pos_y,
- width - trough_change_pos_x,
- height - trough_change_pos_y);
+ gtk_render_background (context, cr,
+ x + trough_change_pos_x, y + trough_change_pos_y,
+ width - trough_change_pos_x,
+ height - trough_change_pos_y);
+
+ gtk_render_frame (context, cr,
+ x, y, width, height);
}
else
{
- gtk_paint_box (style, cr,
- sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN,
- GTK_WIDGET (range),
- "trough-upper",
- x, y,
- width,
- height);
+ gtk_render_background (context, cr,
+ x, y, width, height);
+ gtk_render_frame (context, cr,
+ x, y, width, height);
}
+ gtk_style_context_restore (context);
+
if (priv->show_fill_level &&
priv->adjustment->upper - priv->adjustment->page_size -
priv->adjustment->lower != 0)
@@ -2176,6 +2183,9 @@ gtk_range_draw (GtkWidget *widget,
gint fill_height = height;
gchar *fill_detail;
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+
fill_level = CLAMP (fill_level, priv->adjustment->lower,
priv->adjustment->upper -
priv->adjustment->page_size);
@@ -2214,40 +2224,40 @@ gtk_range_draw (GtkWidget *widget,
else
fill_detail = "trough-fill-level";
- gtk_paint_box (style, cr,
- sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_OUT,
- GTK_WIDGET (range), fill_detail,
- fill_x, fill_y,
- fill_width, fill_height);
+ gtk_render_activity (context, cr,
+ fill_x, fill_y,
+ fill_width, fill_height);
+
+ gtk_style_context_restore (context);
}
+ gtk_style_context_restore (context);
+
if (sensitive && gtk_widget_has_focus (widget))
- gtk_paint_focus (style, cr,
- gtk_widget_get_state (widget),
- widget, "trough",
- priv->range_rect.x,
- priv->range_rect.y,
- priv->range_rect.width,
- priv->range_rect.height);
+ {
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context,
+ gtk_widget_get_state_flags (widget));
+
+ gtk_render_focus (context, cr,
+ priv->range_rect.x,
+ priv->range_rect.y,
+ priv->range_rect.width,
+ priv->range_rect.height);
+
+ gtk_style_context_restore (context);
+ }
}
cairo_restore (cr);
- shadow_type = GTK_SHADOW_OUT;
-
if (!sensitive)
- state = GTK_STATE_INSENSITIVE;
+ state = GTK_STATE_FLAG_INSENSITIVE;
else if (!touchscreen && priv->mouse_location == MOUSE_SLIDER)
- state = GTK_STATE_PRELIGHT;
- else
- state = GTK_STATE_NORMAL;
+ state = GTK_STATE_FLAG_PRELIGHT;
if (priv->grab_location == MOUSE_SLIDER)
- {
- state = GTK_STATE_ACTIVE;
- shadow_type = GTK_SHADOW_IN;
- }
+ state |= GTK_STATE_FLAG_ACTIVE;
cairo_save (cr);
gdk_cairo_rectangle (cr, &priv->slider);
@@ -2255,17 +2265,18 @@ gtk_range_draw (GtkWidget *widget,
if (draw_trough)
{
- gtk_paint_slider (style,
- cr,
- state,
- shadow_type,
- widget,
- gtk_range_get_slider_detail (range),
- priv->slider.x,
- priv->slider.y,
- priv->slider.width,
- priv->slider.height,
- priv->orientation);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_slider (context, cr,
+ priv->slider.x,
+ priv->slider.y,
+ priv->slider.width,
+ priv->slider.height,
+ priv->orientation);
+
+ gtk_style_context_restore (context);
}
cairo_restore (cr);
@@ -2867,8 +2878,8 @@ gtk_range_grab_notify (GtkWidget *widget,
}
static void
-gtk_range_state_changed (GtkWidget *widget,
- GtkStateType previous_state)
+gtk_range_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_state)
{
if (!gtk_widget_is_sensitive (widget))
stop_scrolling (GTK_RANGE (widget));
@@ -2973,15 +2984,14 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment,
}
static void
-gtk_range_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+gtk_range_style_updated (GtkWidget *widget)
{
GtkRange *range = GTK_RANGE (widget);
GtkRangePrivate *priv = range->priv;
priv->need_recalc = TRUE;
- GTK_WIDGET_CLASS (gtk_range_parent_class)->style_set (widget, previous_style);
+ GTK_WIDGET_CLASS (gtk_range_parent_class)->style_updated (widget);
}
static void
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index cd00b2e..d81868e 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -127,8 +127,7 @@ static void gtk_scale_get_preferred_width (GtkWidget *widget,
static void gtk_scale_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
-static void gtk_scale_style_set (GtkWidget *widget,
- GtkStyle *previous);
+static void gtk_scale_style_updated (GtkWidget *widget);
static void gtk_scale_get_range_border (GtkRange *range,
GtkBorder *border);
static void gtk_scale_get_mark_label_size (GtkScale *scale,
@@ -204,7 +203,7 @@ gtk_scale_class_init (GtkScaleClass *class)
gobject_class->get_property = gtk_scale_get_property;
gobject_class->finalize = gtk_scale_finalize;
- widget_class->style_set = gtk_scale_style_set;
+ widget_class->style_updated = gtk_scale_style_updated;
widget_class->screen_changed = gtk_scale_screen_changed;
widget_class->draw = gtk_scale_draw;
widget_class->get_preferred_width = gtk_scale_get_preferred_width;
@@ -430,6 +429,7 @@ gtk_scale_init (GtkScale *scale)
{
GtkScalePrivate *priv;
GtkRange *range = GTK_RANGE (scale);
+ GtkStyleContext *context;
scale->priv = G_TYPE_INSTANCE_GET_PRIVATE (scale,
GTK_TYPE_SCALE,
@@ -449,6 +449,9 @@ gtk_scale_init (GtkScale *scale)
g_signal_connect (scale, "notify::orientation",
G_CALLBACK (gtk_scale_orientation_notify),
NULL);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (scale));
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCALE);
}
static void
@@ -921,8 +924,7 @@ gtk_scale_get_mark_label_size (GtkScale *scale,
}
static void
-gtk_scale_style_set (GtkWidget *widget,
- GtkStyle *previous)
+gtk_scale_style_updated (GtkWidget *widget)
{
gint slider_length;
GtkRange *range;
@@ -937,7 +939,7 @@ gtk_scale_style_set (GtkWidget *widget,
_gtk_scale_clear_layout (GTK_SCALE (widget));
- GTK_WIDGET_CLASS (gtk_scale_parent_class)->style_set (widget, previous);
+ GTK_WIDGET_CLASS (gtk_scale_parent_class)->style_updated (widget);
}
static void
@@ -1032,8 +1034,8 @@ gtk_scale_draw (GtkWidget *widget,
GtkScale *scale = GTK_SCALE (widget);
GtkScalePrivate *priv = scale->priv;
GtkRange *range = GTK_RANGE (scale);
- GtkStateType state_type;
- GtkStyle *style;
+ GtkStateFlags state = 0;
+ GtkStyleContext *context;
gint n_marks;
gint *marks;
gint focus_padding;
@@ -1041,7 +1043,7 @@ gtk_scale_draw (GtkWidget *widget,
gint value_spacing;
gint min_sep = 4;
- style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
gtk_widget_style_get (widget,
"focus-padding", &focus_padding,
"slider-width", &slider_width,
@@ -1053,9 +1055,8 @@ gtk_scale_draw (GtkWidget *widget,
*/
GTK_WIDGET_CLASS (gtk_scale_parent_class)->draw (widget, cr);
- state_type = GTK_STATE_NORMAL;
if (!gtk_widget_is_sensitive (widget))
- state_type = GTK_STATE_INSENSITIVE;
+ state |= GTK_STATE_FLAG_INSENSITIVE;
if (priv->marks)
{
@@ -1098,8 +1099,12 @@ gtk_scale_draw (GtkWidget *widget,
max_pos = find_next_pos (widget, m, marks + i, GTK_POS_TOP, 0) - min_sep;
}
- gtk_paint_vline (style, cr, state_type,
- widget, "scale-mark", y1, y2, x1);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_line (context, cr,
+ x1, y1, x1, y2);
if (mark->markup)
{
@@ -1124,10 +1129,11 @@ gtk_scale_draw (GtkWidget *widget,
min_pos_after = x3 + logical_rect.width + min_sep;
}
- gtk_paint_layout (style, cr, state_type,
- FALSE, widget, "scale-mark",
- x3, y3, layout);
+ gtk_render_layout (context, cr,
+ x3, y3, layout);
}
+
+ gtk_style_context_restore (context);
}
else
{
@@ -1147,8 +1153,12 @@ gtk_scale_draw (GtkWidget *widget,
}
y1 = marks[i];
- gtk_paint_hline (style, cr, state_type,
- widget, "range-mark", x1, x2, y1);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_line (context, cr,
+ x1, y1, x2, y1);
if (mark->markup)
{
@@ -1173,10 +1183,11 @@ gtk_scale_draw (GtkWidget *widget,
min_pos_after = y3 + logical_rect.height + min_sep;
}
- gtk_paint_layout (style, cr, state_type,
- FALSE, widget, "scale-mark",
- x3, y3, layout);
+ gtk_render_layout (context, cr,
+ x3, y3, layout);
}
+
+ gtk_style_context_restore (context);
}
}
@@ -1197,17 +1208,10 @@ gtk_scale_draw (GtkWidget *widget,
gtk_scale_get_layout_offsets (scale, &x, &y);
gtk_widget_get_allocation (widget, &allocation);
- gtk_paint_layout (style,
- cr,
- state_type,
- FALSE,
- widget,
- orientation == GTK_ORIENTATION_HORIZONTAL ?
- "hscale" : "vscale",
- x - allocation.x,
- y - allocation.y,
- layout);
-
+ gtk_render_layout (context, cr,
+ x - allocation.x,
+ y - allocation.y,
+ layout);
}
return FALSE;
diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c
index df4ad75..4a852f2 100644
--- a/gtk/gtkscrollbar.c
+++ b/gtk/gtkscrollbar.c
@@ -56,8 +56,7 @@
*/
-static void gtk_scrollbar_style_set (GtkWidget *widget,
- GtkStyle *previous);
+static void gtk_scrollbar_style_updated (GtkWidget *widget);
G_DEFINE_TYPE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_RANGE)
@@ -66,9 +65,7 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
- widget_class->style_set = gtk_scrollbar_style_set;
-
- GTK_RANGE_CLASS (class)->stepper_detail = "Xscrollbar";
+ widget_class->style_updated = gtk_scrollbar_style_updated;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("min-slider-length",
@@ -125,8 +122,7 @@ gtk_scrollbar_init (GtkScrollbar *scrollbar)
}
static void
-gtk_scrollbar_style_set (GtkWidget *widget,
- GtkStyle *previous)
+gtk_scrollbar_style_updated (GtkWidget *widget)
{
GtkRange *range = GTK_RANGE (widget);
gint slider_length;
@@ -147,7 +143,7 @@ gtk_scrollbar_style_set (GtkWidget *widget,
_gtk_range_set_steppers (range,
has_a, has_b, has_c, has_d);
- GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_set (widget, previous);
+ GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_updated (widget);
}
/**
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index 74539c2..98fc9fb 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -254,6 +254,13 @@ struct _GtkStyleContextClass
#define GTK_STYLE_CLASS_SCROLLBAR "scrollbar"
/**
+ * GTK_STYLE_CLASS_SCALE:
+ *
+ * A CSS class to match scale widgets.
+ */
+#define GTK_STYLE_CLASS_SCALE "scale"
+
+/**
* GTK_STYLE_CLASS_HEADER:
*
* A CSS class to match a header element.
@@ -296,6 +303,13 @@ struct _GtkStyleContextClass
#define GTK_STYLE_CLASS_SPINNER "spinner"
/**
+ * GTK_STYLE_CLASS_MARK:
+ *
+ * A widget class defining marks in a widget, such as in scales
+ */
+#define GTK_STYLE_CLASS_MARK "mark"
+
+/**
* GTK_STYLE_CLASS_NOTEBOOK:
*
* A widget class defining a notebook
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]