static void mx_progress_bar_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *nat_width_p) { MxPadding padding; MxProgressBarPrivate *priv = MX_PROGRESS_BAR (actor)->priv; gfloat height; clutter_actor_get_preferred_width (priv->fill, for_height, min_width_p, nat_width_p); clutter_actor_get_preferred_height (priv->fill, -1, &height, NULL); mx_widget_get_padding (MX_WIDGET (actor), &padding); if (min_width_p) *min_width_p += padding.left + padding.right; /* Add an arbitrary amount to the width for preferred width, so that the * indicator is visible and can display some values */ if (nat_width_p) *nat_width_p += padding.left + padding.right + height * 4; }
static void mx_progress_bar_unmap (ClutterActor *actor) { MxProgressBarPrivate *priv = MX_PROGRESS_BAR (actor)->priv; CLUTTER_ACTOR_CLASS (mx_progress_bar_parent_class)->unmap (actor); clutter_actor_unmap (priv->fill); }
static void update (MpdStorageDeviceTile *self) { MpdStorageDeviceTilePrivate *priv = GET_PRIVATE (self); char *markup; int64_t size = -1; int64_t available_size = -1; markup = mpd_storage_device_tile_get_title (self); clutter_text_set_markup (GET_CLUTTER_TEXT (priv->label), markup); g_free (markup); if (priv->storage) { g_object_get (priv->storage, "size", &size, "available-size", &available_size, NULL); } if (size > -1 && available_size > -1) { unsigned int percentage = 100 - (double) available_size / size * 100; mx_progress_bar_set_progress (MX_PROGRESS_BAR (priv->meter), percentage / 100.); } else { g_object_set (priv->meter, "visible", false, NULL); mx_table_child_set_row_span (MX_TABLE (priv->table), priv->label, 2); } }
static void mx_progress_bar_apply_style (MxWidget *widget, MxStyle *style) { MxProgressBarPrivate *priv = MX_PROGRESS_BAR (widget)->priv; if (priv->fill != NULL) mx_stylable_set_style (MX_STYLABLE (priv->fill), style); }
static void mx_progress_bar_allocate (ClutterActor *actor, const ClutterActorBox *box, ClutterAllocationFlags flags) { MxProgressBar *self = MX_PROGRESS_BAR (actor); CLUTTER_ACTOR_CLASS (mx_progress_bar_parent_class)-> allocate (actor, box, flags); mx_progress_bar_allocate_fill (self, box, flags); }
static void mx_progress_bar_dispose (GObject *object) { MxProgressBarPrivate *priv = MX_PROGRESS_BAR (object)->priv; if (priv->fill) { clutter_actor_unparent (CLUTTER_ACTOR (priv->fill)); priv->fill = NULL; } G_OBJECT_CLASS (mx_progress_bar_parent_class)->dispose (object); }
static void mx_progress_bar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { MxProgressBar *self = MX_PROGRESS_BAR (object); switch (property_id) { case PROP_PROGRESS: mx_progress_bar_set_progress (self, g_value_get_double (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void mx_progress_bar_get_preferred_height (ClutterActor *actor, gfloat for_width, gfloat *min_height_p, gfloat *nat_height_p) { MxPadding padding; MxProgressBarPrivate *priv = MX_PROGRESS_BAR (actor)->priv; clutter_actor_get_preferred_height (priv->fill, for_width, min_height_p, nat_height_p); mx_widget_get_padding (MX_WIDGET (actor), &padding); if (min_height_p) *min_height_p += padding.top + padding.bottom; if (nat_height_p) *nat_height_p += padding.top + padding.bottom; }
static void update (MpdDiskTile *self) { MpdDiskTilePrivate *priv = GET_PRIVATE (self); char *markup; char *size_text; uint64_t size; uint64_t available_size; unsigned int percentage; g_object_get (priv->storage, "size", &size, "available-size", &available_size, NULL); percentage = 100 - (double) available_size / size * 100; /* We don't want to display 0% used, we still have *something* installed */ if (percentage == 0) percentage++; size_text = g_format_size (size); markup = g_strdup_printf (_("You are using %d%% of %s"), percentage, size_text); clutter_text_set_markup (CLUTTER_TEXT (mx_label_get_clutter_text ( MX_LABEL (priv->label))), markup); g_free (markup); g_free (size_text); /* The progress bar does not look good if the percentage < 3%. We cheat * and always display a minimum of 3% */ mx_progress_bar_set_progress (MX_PROGRESS_BAR (priv->meter), MAX (.03, percentage / 100.)); }