mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
progressbar: add empty and full classes on trough based on fill-level
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=774695
This commit is contained in:
parent
ca47c75272
commit
a1deb8e459
@ -75,7 +75,7 @@
|
||||
*
|
||||
* |[<!-- language="plain" -->
|
||||
* progressbar[.osd]
|
||||
* ╰── trough
|
||||
* ╰── trough[.empty][.full]
|
||||
* ├── [text]
|
||||
* ╰── progress[.pulse]
|
||||
* ]|
|
||||
@ -324,6 +324,36 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
|
||||
gtk_widget_class_set_css_name (widget_class, "progressbar");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -392,6 +422,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
|
||||
@ -1196,6 +1228,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]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user