[gnome-usage/tracker-powered-storage-view-wip] storage: StorageViewRow add loading spinner
- From: Petr Štětka <pstetka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-usage/tracker-powered-storage-view-wip] storage: StorageViewRow add loading spinner
- Date: Tue, 2 Oct 2018 10:49:06 +0000 (UTC)
commit 90b9ec8e57f933c8209da7b68837abaf65ed151e
Author: Petr Štětka <pstetka redhat com>
Date: Tue Oct 2 12:07:55 2018 +0200
storage: StorageViewRow add loading spinner
data/ui/storage-view-row.ui | 10 ++++++++++
src/storage/storage-view-item.vala | 1 +
src/storage/storage-view-row.vala | 24 ++++++++++++++++++++++--
3 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/storage-view-row.ui b/data/ui/storage-view-row.ui
index 44d866a..b36aa2e 100644
--- a/data/ui/storage-view-row.ui
+++ b/data/ui/storage-view-row.ui
@@ -51,6 +51,16 @@
</packing>
</child>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="active">True</property>
+ <property name="visible">False</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
<child>
<object class="GtkLabel" id="size_label">
<property name="visible">True</property>
diff --git a/src/storage/storage-view-item.vala b/src/storage/storage-view-item.vala
index 9251c8c..86a167a 100644
--- a/src/storage/storage-view-item.vala
+++ b/src/storage/storage-view-item.vala
@@ -20,6 +20,7 @@
public class Usage.StorageViewItem : GLib.Object {
public double percentage { set; get; }
+ public bool loaded { get; set; default = false; }
public string uri;
public string name;
diff --git a/src/storage/storage-view-row.vala b/src/storage/storage-view-row.vala
index 7c0845e..e59b476 100644
--- a/src/storage/storage-view-row.vala
+++ b/src/storage/storage-view-row.vala
@@ -38,6 +38,9 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
[GtkChild]
public Gtk.Label size_label;
+ [GtkChild]
+ public Gtk.Spinner spinner;
+
[GtkChild]
public Gtk.Box tag;
@@ -63,6 +66,7 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
public signal void check_button_toggled();
public StorageViewItem item;
+ public Gdk.RGBA default_color;
public StorageViewRow.from_item (StorageViewItem item) {
this.item = item;
@@ -79,19 +83,35 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
if (item.type == FileType.DIRECTORY || item.custom_type != null)
tag.width_request = tag.height_request = 20;
- if(item.custom_type == "up-folder")
+ if(item.custom_type == "up-folder") {
get_style_context().add_class("up-folder");
+
+ if(!item.loaded) {
+ spinner.visible = true;
+ size_label.visible = false;
+ }
+
+ item.notify["loaded"].connect(() => {
+ if(item.loaded) {
+ spinner.visible = false;
+ size_label.visible = true;
+ }
+ });
+ }
+
+ default_color = tag.get_style_context().get_background_color(get_style_context().get_state());
}
public void colorize(uint order, uint all_count) {
if(order == 0)
return;
- var default_color = tag.get_style_context().get_background_color(get_style_context().get_state());
var result_color = Utils.generate_color(default_color, order, all_count, true);
var css_provider = new Gtk.CssProvider();
tag.get_style_context().add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ title.label = item.name + " - " + Math.round(item.percentage).to_string() + "%";
+
var css =
@".row-tag {
background: $result_color;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]