[gnome-usage/tracker-powered-storage-view-wip] storage: Add "operating system" row popover



commit bd4011226a5057671a5dc7ce22357ed3af72e7b9
Author: Petr Štětka <pstetka redhat com>
Date:   Tue Jun 19 15:52:56 2018 +0200

    storage: Add "operating system" row popover

 data/meson.build                     |  1 +
 data/org.gnome.Usage.gresource.xml   |  1 +
 data/ui/storage-row-popover.ui       | 18 +++++++++++++++++
 src/meson.build                      |  1 +
 src/storage/storage-row-popover.vala | 38 ++++++++++++++++++++++++++++++++++++
 src/storage/storage-view-item.vala   |  8 ++++++++
 src/storage/storage-view.vala        | 15 ++++++++------
 7 files changed, 76 insertions(+), 6 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index b8fa0c6..ea401de 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -8,6 +8,7 @@ resource_data = files(
   'ui/quit-process-dialog.ui',
   'ui/speedometer.ui',
   'ui/storage-actionbar.ui',
+  'ui/storage-row-popover.ui',
   'ui/storage-view.ui',
   'ui/swap-speedometer.ui'
 )
diff --git a/data/org.gnome.Usage.gresource.xml b/data/org.gnome.Usage.gresource.xml
index 3c258e1..2c17323 100644
--- a/data/org.gnome.Usage.gresource.xml
+++ b/data/org.gnome.Usage.gresource.xml
@@ -9,6 +9,7 @@
         <file preprocess="xml-stripblanks">ui/quit-process-dialog.ui</file>
         <file preprocess="xml-stripblanks">ui/speedometer.ui</file>
         <file preprocess="xml-stripblanks">ui/storage-actionbar.ui</file>
+        <file preprocess="xml-stripblanks">ui/storage-row-popover.ui</file>
         <file preprocess="xml-stripblanks">ui/storage-view.ui</file>
         <file preprocess="xml-stripblanks">ui/storage-view-row.ui</file>
         <file preprocess="xml-stripblanks">ui/process-row.ui</file>
diff --git a/data/ui/storage-row-popover.ui b/data/ui/storage-row-popover.ui
new file mode 100644
index 0000000..7c953c5
--- /dev/null
+++ b/data/ui/storage-row-popover.ui
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <template class="UsageStorageRowPopover" parent="GtkPopover">
+    <property name="position">right</property>
+    <property name="modal">True</property>
+    <child>
+      <object class="GtkLabel" id="label">
+        <property name="visible">True</property>
+        <property name="label" translatable="yes">label</property>
+        <property name="margin">10</property>
+        <property name="max-width-chars">30</property>
+        <property name="wrap">True</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index 1018a98..c838def 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -29,6 +29,7 @@ vala_sources = [
   'settings.vala',
   'speedometer.vala',
   'storage/query-builder.vala',
+  'storage/storage-row-popover.vala',
   'storage/storage-view-item.vala',
   'storage/storage-view.vala',
   'storage/storage-view-row.vala',
diff --git a/src/storage/storage-row-popover.vala b/src/storage/storage-row-popover.vala
new file mode 100644
index 0000000..1d58e9a
--- /dev/null
+++ b/src/storage/storage-row-popover.vala
@@ -0,0 +1,38 @@
+/* storage-row-popover.vala
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Petr Štětka <pstetka redhat com>
+ */
+
+[GtkTemplate (ui = "/org/gnome/Usage/ui/storage-row-popover.ui")]
+public class Usage.StorageRowPopover : Gtk.Popover {
+
+    [GtkChild]
+    private Gtk.Label label;
+
+    public void present (StorageViewRow row) {
+        relative_to = row;
+
+        switch(row.item.custom_type) {
+            case "os":
+                label.label = _("Operating system files are an essential part of your system and cannot be 
removed.");
+                break;
+        }
+
+        popup();
+    }
+}
\ No newline at end of file
diff --git a/src/storage/storage-view-item.vala b/src/storage/storage-view-item.vala
index 7d165d8..355c48d 100644
--- a/src/storage/storage-view-item.vala
+++ b/src/storage/storage-view-item.vala
@@ -102,6 +102,14 @@ public class Usage.StorageViewItem : GLib.Object {
             }
         }
 
+        if(custom_type != null) {
+            switch(custom_type) {
+                case "os":
+                    style_class = "os-tag";
+                    break;
+            }
+        }
+
         if (_style_class == null)
             style_class = "files";
     }
diff --git a/src/storage/storage-view.vala b/src/storage/storage-view.vala
index 75ed928..a69d6b7 100644
--- a/src/storage/storage-view.vala
+++ b/src/storage/storage-view.vala
@@ -42,7 +42,8 @@ public class Usage.NewStorageView : Usage.View {
     [GtkChild]
     private StorageGraph graph;
 
-    private StorageViewRow os_row = new StorageViewRow ();
+    private StorageViewItem os_item = new StorageViewItem ();
+    private StorageRowPopover row_popover = new StorageRowPopover();
 
     private UserDirectory[] xdg_folders = {
         UserDirectory.DOCUMENTS,
@@ -81,6 +82,8 @@ public class Usage.NewStorageView : Usage.View {
             listbox.pop();
         } else if (storage_row.item.type == FileType.DIRECTORY) {
             present_dir.begin (storage_row.item.uri);
+        } else if (storage_row.item.custom_type != null) {
+            row_popover.present(storage_row);
         } else {
             graph.queue_draw ();
         }
@@ -153,11 +156,9 @@ public class Usage.NewStorageView : Usage.View {
             var used = total - free;
 
             if (dir == "/") {
-                os_row.label = _("Operating System");
-                os_row.tag_size = StorageViewRow.TagSize.BIG;
-                os_row.get_style_context ().add_class ("stack-children");
-                os_row.tag.get_style_context ().add_class ("os-tag");
-                os_row.size_label.label = Utils.format_size_values (used);
+                os_item.name = _("Operating System");
+                os_item.size = used;
+                os_item.custom_type = "os";
             }
 
             total_used_size += used;
@@ -183,6 +184,8 @@ public class Usage.NewStorageView : Usage.View {
             return;
 
         var model = new GLib.ListStore (typeof (StorageViewItem));
+        model.append(os_item);
+
         foreach (var dir in xdg_folders) {
             var file = File.new_for_uri (get_user_special_dir_path (dir));
             var item = new StorageViewItem.from_file (file);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]