[gtk+/gtk-3-20] progressbar: add empty and full classes on trough based on fill-level
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-20] progressbar: add empty and full classes on trough based on fill-level
- Date: Sat, 3 Dec 2016 17:22:18 +0000 (UTC)
commit 4ed5f5ed433ccb5b4b49d72a03e7bf494a69ab65
Author: Simon Steinbeiss <simon steinbeiss elfenbeinturm at>
Date: Fri Nov 18 23:43:09 2016 +0100
progressbar: add empty and full classes on trough based on fill-level
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=774695
gtk/gtkprogressbar.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index 74fc9b4..7f1ccca 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -73,7 +73,7 @@
*
* |[<!-- language="plain" -->
* progressbar[.osd]
- * ╰── trough
+ * ╰── trough[.empty][.full]
* ├── [text]
* ╰── progress[.pulse]
* ]|
@@ -428,6 +428,36 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
}
static void
+update_fraction_classes (GtkProgressBar *pbar)
+{
+ GtkProgressBarPrivate *priv = pbar->priv;
+ gboolean empty = FALSE;
+ gboolean full = FALSE;
+
+ /* Here we set classes based on fill-level unless we're in activity-mode.
+ */
+
+ if (!priv->activity_mode)
+ {
+ if (priv->fraction <= 0.0)
+ empty = TRUE;
+
+ if (priv->fraction >= 1.0)
+ full = TRUE;
+ }
+
+ if (empty)
+ gtk_css_gadget_add_class (priv->trough_gadget, "empty");
+ else
+ gtk_css_gadget_remove_class (priv->trough_gadget, "empty");
+
+ if (full)
+ gtk_css_gadget_add_class (priv->trough_gadget, "full");
+ else
+ gtk_css_gadget_remove_class (priv->trough_gadget, "full");
+}
+
+static void
update_node_classes (GtkProgressBar *pbar)
{
GtkProgressBarPrivate *priv = pbar->priv;
@@ -495,6 +525,8 @@ update_node_classes (GtkProgressBar *pbar)
gtk_css_gadget_add_class (priv->progress_gadget, GTK_STYLE_CLASS_BOTTOM);
else
gtk_css_gadget_remove_class (priv->progress_gadget, GTK_STYLE_CLASS_BOTTOM);
+
+ update_fraction_classes (pbar);
}
static void
@@ -1398,6 +1430,7 @@ gtk_progress_bar_set_fraction (GtkProgressBar *pbar,
priv->fraction = CLAMP (fraction, 0.0, 1.0);
gtk_progress_bar_set_activity_mode (pbar, FALSE);
gtk_widget_queue_allocate (GTK_WIDGET (pbar));
+ update_fraction_classes (pbar);
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_FRACTION]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]