[gtk+] range: Add a CSS node for the trough



commit 2bfb5ad812b8b54f6acc4245a7fe6ce9ea65d236
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Nov 5 00:20:05 2015 -0500

    range: Add a CSS node for the trough
    
    This is in sync with what we do elsewhere for troughs.

 gtk/gtkrange.c     |   13 ++++++++++++-
 gtk/gtkscale.c     |   10 ++++++----
 gtk/gtkscrollbar.c |    9 +++++----
 3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 3748fe0..3abf0cc 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -108,6 +108,7 @@ struct _GtkRangePrivate
   GtkCssNode *stepper_b_node;
   GtkCssNode *stepper_c_node;
   GtkCssNode *stepper_d_node;
+  GtkCssNode *trough_node;
   GtkCssNode *slider_node;
 
   GtkOrientation     orientation;
@@ -774,9 +775,16 @@ gtk_range_init (GtkRange *range)
   _gtk_orientable_set_style_classes (GTK_ORIENTABLE (range));
 
   widget_node = gtk_widget_get_css_node (GTK_WIDGET (range));
+  priv->trough_node = gtk_css_node_new ();
+  gtk_css_node_set_name (priv->trough_node, I_("trough"));
+  gtk_css_node_set_parent (priv->trough_node, widget_node);
+  gtk_css_node_set_state (priv->trough_node, gtk_css_node_get_state (widget_node));
+  g_signal_connect_object (priv->trough_node, "style-changed", G_CALLBACK (node_style_changed_cb), range, 0);
+  g_object_unref (priv->trough_node);
+
   priv->slider_node = gtk_css_node_new ();
   gtk_css_node_set_name (priv->slider_node, I_("slider"));
-  gtk_css_node_set_parent (priv->slider_node, widget_node);
+  gtk_css_node_set_parent (priv->slider_node, priv->trough_node);
   gtk_css_node_set_state (priv->slider_node, gtk_css_node_get_state (widget_node));
   g_signal_connect_object (priv->slider_node, "style-changed", G_CALLBACK (node_style_changed_cb), range, 0);
   g_object_unref (priv->slider_node);
@@ -1975,6 +1983,7 @@ gtk_range_draw (GtkWidget *widget,
             }
         }
 
+      gtk_style_context_save_to_node (context, priv->trough_node);
       gtk_style_context_get_margin (context, widget_state, &margin);
 
       x += margin.left;
@@ -2053,6 +2062,8 @@ gtk_range_draw (GtkWidget *widget,
             }
         }
 
+      gtk_style_context_restore (context);
+
       if (priv->show_fill_level &&
           gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) -
           gtk_adjustment_get_lower (priv->adjustment) != 0)
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 9cb0d36..5c8db20 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -76,16 +76,18 @@
  *
  * |[<!-- language="plain" -->
  * scale
- * ├── slider
+ * ├── trough
+ * │   ╰── slider
  * ╰── marks
  *     ├── mark.bottom
  *     ├── mark.top
  *     ╰── ...
  * ]|
  *
- * GtkScale has a main CSS node with name scale and a subnode with name slider.
- * If marks are present, there is a marks subnode, below which each mark gets
- * a node with name mark, and either the .top or .bottom style class.
+ * GtkScale has a main CSS node with name scale, and subnodes with names
+ * trough and slider. If marks are present, there is a marks subnode, below
+ * which each mark gets a node with name mark, and either the .top or .bottom
+ * style class.
  */
 
 
diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c
index d61df75..2b68361 100644
--- a/gtk/gtkscrollbar.c
+++ b/gtk/gtkscrollbar.c
@@ -59,14 +59,15 @@
  * scrollbar
  * ├── [button.down]
  * ├── [button.up]
- * ├── slider
+ * ├── trough
+ * │   ╰── slider
  * ├── [button.down]
  * ╰── [button.up]
  * ]|
  *
- * GtkScrollbar has a main CSS node with name scrollbar, and a subnode
- * with name slider. If steppers are enabled, they are represented by up
- * to four additional subnodes with name button. These get the style classes
+ * GtkScrollbar has a main CSS node with name scrollbar, and subnodes with
+ * names trough and slider. If steppers are enabled, they are represented by
+ * up to four additional subnodes with name button. These get the style classes
  * .up and .down to indicate in which direction they are moving.
  */
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]