[gtk+] levelbar: update css nodes even when no offset value is found



commit 85070839289cdeb281a18eb028a4e7b1e8708dee
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Nov 2 00:46:10 2016 -0200

    levelbar: update css nodes even when no offset value is found
    
    GtkLevelBar supports adding custom offsets as style classes, and they
    are applied whenever the :value property matches. The current code,
    however, only updates any CSS nodes when an offset is found, causing
    it to not update when a discrete value changes but no custom offset
    is added.
    
    Fix that by always updating the CSS nodes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773799

 gtk/gtklevelbar.c |   38 +++++++++++++++++---------------------
 1 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index f7229f5..33bf44c 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -644,9 +644,12 @@ update_level_style_classes (GtkLevelBar *self)
 {
   GtkLevelBarPrivate *priv = self->priv;
   gdouble value;
+  const gchar *classes[3] = { NULL, NULL, NULL };
   const gchar *value_class = NULL;
   GtkLevelBarOffset *offset, *prev_offset;
   GList *l;
+  gint num_filled, num_blocks, i;
+  gboolean inverted;
 
   value = gtk_level_bar_get_value (self);
 
@@ -673,30 +676,23 @@ update_level_style_classes (GtkLevelBar *self)
         break;
     }
 
-  if (value_class)
-    {
-      const gchar *classes[3] = { NULL, NULL, NULL };
-      gint num_filled, num_blocks, i;
-      gboolean inverted;
-
-      inverted = gtk_level_bar_get_real_inverted (self);
-      num_blocks = gtk_level_bar_get_num_block_nodes (self);
+  inverted = gtk_level_bar_get_real_inverted (self);
+  num_blocks = gtk_level_bar_get_num_block_nodes (self);
 
-      if (priv->bar_mode == GTK_LEVEL_BAR_MODE_CONTINUOUS)
-        num_filled = 1;
-      else
-        num_filled = MIN (num_blocks, (gint) round (priv->cur_value) - (gint) round (priv->min_value));
+  if (priv->bar_mode == GTK_LEVEL_BAR_MODE_CONTINUOUS)
+    num_filled = 1;
+  else
+    num_filled = MIN (num_blocks, (gint) round (priv->cur_value) - (gint) round (priv->min_value));
 
-      classes[0] = "filled";
-      classes[1] = value_class;
-      for (i = 0; i < num_filled; i++)
-        gtk_css_node_set_classes (gtk_css_gadget_get_node (priv->block_gadget[inverted ? num_blocks - 1 - i 
: i]), classes);
+  classes[0] = "filled";
+  classes[1] = value_class;
+  for (i = 0; i < num_filled; i++)
+    gtk_css_node_set_classes (gtk_css_gadget_get_node (priv->block_gadget[inverted ? num_blocks - 1 - i : 
i]), classes);
 
-      classes[0] = "empty";
-      classes[1] = NULL;
-      for (; i < num_blocks; i++)
-        gtk_css_node_set_classes (gtk_css_gadget_get_node (priv->block_gadget[inverted ? num_blocks - 1 - i 
: i]), classes);
-    }
+  classes[0] = "empty";
+  classes[1] = NULL;
+  for (; i < num_blocks; i++)
+    gtk_css_node_set_classes (gtk_css_gadget_get_node (priv->block_gadget[inverted ? num_blocks - 1 - i : 
i]), classes);
 }
 
 static void


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