[gnome-usage/tracker-powered-storage-view-wip] storage-row: Add check buttton



commit 5782fa940c8decd0e8e0e59188c840dd359a8a61
Author: Petr Štětka <pstetka redhat com>
Date:   Fri Jul 27 09:43:37 2018 +0200

    storage-row: Add check buttton

 data/ui/header-bar.ui              |  2 +-
 data/ui/storage-view-row.ui        | 11 ++++++++++
 src/application.vala               |  2 +-
 src/storage/storage-view-item.vala | 41 ++++++++++++++++++++++++++++++++++++++
 src/storage/storage-view-row.vala  |  4 ++++
 src/storage/storage-view.vala      |  1 -
 src/window.vala                    |  1 +
 7 files changed, 59 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/header-bar.ui b/data/ui/header-bar.ui
index b5a6f35..31ba908 100644
--- a/data/ui/header-bar.ui
+++ b/data/ui/header-bar.ui
@@ -3,7 +3,7 @@
   <!-- interface-requires gtk+ 3.9 -->
 
   <template class="UsageHeaderBar" parent="GtkHeaderBar">
-    <property name="visible">False</property>
+    <property name="visible">True</property>
     <property name="show-close-button">True</property>
     <child type="title">
       <object class="GtkStackSwitcher" id="stack_switcher">
diff --git a/data/ui/storage-view-row.ui b/data/ui/storage-view-row.ui
index 1a57d49..44d866a 100644
--- a/data/ui/storage-view-row.ui
+++ b/data/ui/storage-view-row.ui
@@ -40,6 +40,17 @@
           </packing>
         </child>
 
+        <child>
+          <object class="GtkCheckButton" id="check_button">
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="draw_indicator">True</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/application.vala b/src/application.vala
index 404bbdd..9633227 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -65,7 +65,7 @@ namespace Usage
             menu.append_section(null, menu_common);
 
             set_app_menu(menu);
-            window.show_all();
+            window.show();
         }
 
         protected override void startup()
diff --git a/src/storage/storage-view-item.vala b/src/storage/storage-view-item.vala
index 0bfdcd3..8749227 100644
--- a/src/storage/storage-view-item.vala
+++ b/src/storage/storage-view-item.vala
@@ -45,6 +45,12 @@ public class Usage.StorageViewItem : GLib.Object {
         }
     }
 
+    public bool show_check_button {
+        get {
+           return _show_check_button ();
+        }
+    }
+
     public StorageViewItem.from_file (File file) {
         uri = file.get_uri ();
 
@@ -116,4 +122,39 @@ public class Usage.StorageViewItem : GLib.Object {
         if (_style_class == null)
             style_class = "files";
     }
+
+    private bool _show_check_button () {
+        if(custom_type != null) {
+            switch(custom_type) {
+                case "os":
+                case "available-graph":
+                case "up-folder":
+                    return false;
+            }
+        }
+
+        if (dir != null) {
+            switch (dir) {
+                case UserDirectory.PICTURES:
+                case UserDirectory.VIDEOS:
+                case UserDirectory.DOCUMENTS:
+                case UserDirectory.MUSIC:
+                case UserDirectory.DOWNLOAD:
+                    return true;
+            }
+        }
+
+        switch (ontology) {
+            case "nmm#MusicPiece":
+            case "nmm#Photo":
+            case "nmm#Video":
+            case "nfo#PaginatedTextDocument":
+            case "nfo#PlainTextDocument":
+            case "nfo#FileDataObject":
+            case "nfo#EBook":
+                return true;
+        }
+
+        return false;
+    }
 }
diff --git a/src/storage/storage-view-row.vala b/src/storage/storage-view-row.vala
index a58a011..4f50a06 100644
--- a/src/storage/storage-view-row.vala
+++ b/src/storage/storage-view-row.vala
@@ -32,6 +32,9 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
     [GtkChild]
     private Gtk.Label title;
 
+    [GtkChild]
+    public Gtk.CheckButton check_button;
+
     [GtkChild]
     public Gtk.Label size_label;
 
@@ -62,6 +65,7 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
         size_label.label = Utils.format_size_values (item.size);
 
         tag.get_style_context ().add_class (item.style_class);
+        check_button.visible = item.show_check_button;
 
         if (item.type == FileType.DIRECTORY || item.custom_type != null)
             tag.width_request = tag.height_request = 20;
diff --git a/src/storage/storage-view.vala b/src/storage/storage-view.vala
index 4fa8e13..9462b2b 100644
--- a/src/storage/storage-view.vala
+++ b/src/storage/storage-view.vala
@@ -129,7 +129,6 @@ public class Usage.NewStorageView : Usage.View {
             row.colorize(storage_row_i, shown_rows_number);
 
         storage_row_i++;
-        row.show_all ();
 
         return row;
     }
diff --git a/src/window.vala b/src/window.vala
index 169e14d..b53682a 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -47,6 +47,7 @@ namespace Usage
             });
 
                        var stack = new Gtk.Stack();
+            stack.visible = true;
                        header_bar = new Usage.HeaderBar(stack);
                        set_titlebar(header_bar);
 


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