summaryrefslogtreecommitdiff
path: root/gtk/gtkprogressbar.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-07-19 00:40:09 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-07-19 00:40:09 -0400
commita9201b8379673e8e338166e43df50d1d5d12d14b (patch)
tree6d74893433926bd92a6efbb201b1d146567a5709 /gtk/gtkprogressbar.c
parent04c4e1963f3ec8230dff3197f10e42b40aea6ec0 (diff)
downloadgtk+-a9201b8379673e8e338166e43df50d1d5d12d14b.tar.gz
GtkProgressBar: Add style classes for edges
Add left/right/top/bottom style classes according to which edge(s) of the progressbar the progress is adjacent to. Only for a fraction of 1.0 will we set more than one edge.
Diffstat (limited to 'gtk/gtkprogressbar.c')
-rw-r--r--gtk/gtkprogressbar.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index 65399214a6..5cdda739ae 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -759,23 +759,31 @@ gtk_progress_bar_paint_activity (GtkProgressBar *pbar,
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PULSE);
+
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
gtk_progress_bar_get_activity (pbar, orientation, &area.x, &area.width);
area.y = y + padding.top;
area.height = height - padding.top - padding.bottom;
+ if (pbar->priv->activity_pos <= 0.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ else if (pbar->priv->activity_pos >= 1.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
}
else
{
gtk_progress_bar_get_activity (pbar, orientation, &area.y, &area.height);
area.x = x + padding.left;
area.width = width - padding.left - padding.right;
+ if (pbar->priv->activity_pos <= 0.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ else if (pbar->priv->activity_pos >= 1.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
}
- gtk_style_context_save (context);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_PULSE);
-
gtk_render_activity (context, cr, area.x, area.y, area.width, area.height);
gtk_style_context_restore (context);
@@ -805,6 +813,9 @@ gtk_progress_bar_paint_continuous (GtkProgressBar *pbar,
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
area.width = amount;
@@ -815,6 +826,11 @@ gtk_progress_bar_paint_continuous (GtkProgressBar *pbar,
area.x = x + padding.left;
else
area.x = width - amount - padding.right;
+
+ if (!inverted || gtk_progress_bar_get_fraction (pbar) == 1.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
+ if (inverted || gtk_progress_bar_get_fraction (pbar) == 1.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
}
else
{
@@ -826,10 +842,12 @@ gtk_progress_bar_paint_continuous (GtkProgressBar *pbar,
area.y = y + padding.top;
else
area.y = height - amount - padding.bottom;
- }
- gtk_style_context_save (context);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+ if (!inverted || gtk_progress_bar_get_fraction (pbar) == 1.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ if (inverted || gtk_progress_bar_get_fraction (pbar) == 1.0)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ }
gtk_render_activity (context, cr, area.x, area.y, area.width, area.height);