From 971f1a9b316ada3ff38f443152a99c3864c1754d Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 2 Jan 2016 18:03:15 -0800 Subject: [PATCH] levelbar: split out a function --- gtk/gtklevelbar.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c index 7259f85de5..9452d0903d 100644 --- a/gtk/gtklevelbar.c +++ b/gtk/gtklevelbar.c @@ -305,6 +305,16 @@ gtk_level_bar_get_num_blocks (GtkLevelBar *self) return 0; } +static gboolean +gtk_level_bar_get_real_inverted (GtkLevelBar *self) +{ + if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL && + self->priv->orientation == GTK_ORIENTATION_HORIZONTAL) + return !self->priv->inverted; + + return self->priv->inverted; +} + static void gtk_level_bar_get_borders (GtkLevelBar *self, GtkBorder *borders_out) @@ -342,14 +352,8 @@ gtk_level_bar_draw_fill_continuous (GtkLevelBar *self, gdouble fill_percentage; gboolean inverted; - inverted = self->priv->inverted; - if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL) - { - if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL) - inverted = !inverted; - } - context = gtk_widget_get_style_context (widget); + inverted = gtk_level_bar_get_real_inverted (self); /* render the empty (unfilled) part */ gtk_style_context_save_to_node (context, self->priv->block_node[inverted ? 0 : 1]); @@ -696,10 +700,7 @@ update_level_style_classes (GtkLevelBar *self) gint num_filled, num_blocks, i; gboolean inverted; - inverted = priv->inverted; - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && - gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL) - inverted = !inverted; + inverted = gtk_level_bar_get_real_inverted (self); if (priv->bar_mode == GTK_LEVEL_BAR_MODE_CONTINUOUS) {