summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-05-18 12:59:39 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-05-18 13:02:11 -0400
commite441c17a0add3023ca447a38b7413f7c02e59315 (patch)
tree13730d6b669c0ce5ef4cd2fffa3988d6c77edd96
parentaec4dbfa9445e94fba7250540f1aece223cd64c5 (diff)
downloadgtk+-e441c17a0add3023ca447a38b7413f7c02e59315.tar.gz
scale: Bring back marks-related style classes
It turns out that it is too hard (and in some cases, impossible) to get this information from node positioning, so bring back the .scale-has-marks-above/below style classes on the main node. This should allow us to fix the 'pointy sliders'. https://bugzilla.gnome.org/show_bug.cgi?id=766440
-rw-r--r--gtk/gtkscale.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 8b22cc0bd5..227fd8932d 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -76,13 +76,14 @@
* # CSS nodes
*
* |[<!-- language="plain" -->
- * scale[.fine-tune]
+ * scale[.fine-tune][.scale-has-marks-above][.scale-has-marks-below]
* ├── marks.top
* │ ├── mark
* │ ┊ ├── [label]
* │ ┊ ╰── indicator
* ┊ ┊
* │ ╰── mark
+ * ├── [value]
* ├── contents
* │ ╰── trough
* │ ├── slider
@@ -117,6 +118,12 @@
* has a subnode named label. When the mark is either above or left of the
* scale, the label subnode is the first when present. Otherwise, the indicator
* subnode is the first.
+ *
+ * The main CSS node gets the 'scale-has-marks-above' and/or 'scale-has-marks-below'
+ * style classes added depending on what marks are present.
+ *
+ * If the scale is displaying the value (see #GtkScale:draw-value), there is
+ * subnode with name value.
*/
@@ -1989,6 +1996,7 @@ void
gtk_scale_clear_marks (GtkScale *scale)
{
GtkScalePrivate *priv;
+ GtkStyleContext *context;
g_return_if_fail (GTK_IS_SCALE (scale));
@@ -2004,6 +2012,10 @@ gtk_scale_clear_marks (GtkScale *scale)
gtk_css_node_set_parent (gtk_css_gadget_get_node (priv->bottom_marks_gadget), NULL);
g_clear_object (&priv->bottom_marks_gadget);
+ context = gtk_widget_get_style_context (GTK_WIDGET (scale));
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);
+
_gtk_range_set_stop_values (GTK_RANGE (scale), NULL, 0);
gtk_widget_queue_resize (GTK_WIDGET (scale));
@@ -2046,6 +2058,7 @@ gtk_scale_add_mark (GtkScale *scale,
gdouble *values;
gint n, i;
GtkCssNode *widget_node, *marks_node;
+ GtkStyleContext *context;
g_return_if_fail (GTK_IS_SCALE (scale));
@@ -2170,6 +2183,12 @@ gtk_scale_add_mark (GtkScale *scale,
g_free (values);
+ context = gtk_widget_get_style_context (GTK_WIDGET (scale));
+ if (priv->top_marks_gadget)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);
+ if (priv->bottom_marks_gadget)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW);
+
gtk_widget_queue_resize (widget);
}