[gnome-boxes] App.filter -> CollectionView



commit 7e0652e2d57a6e4c051d176615a70553dc7740af
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Jul 1 12:49:26 2015 +0200

    App.filter -> CollectionView
    
    This is needed to make CollectionView more self contained and hence make
    the code easier to understand.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751710

 src/app-window.vala      |    4 ++++
 src/app.vala             |    2 --
 src/collection-view.vala |   12 +++++++-----
 src/searchbar.vala       |    3 +--
 4 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 57b5edf..1140266 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -282,6 +282,10 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
         item_selected (item);
     }
 
+    public void filter (string text) {
+        view.filter.text = text;
+    }
+
     [GtkCallback]
     public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
         var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
diff --git a/src/app.vala b/src/app.vala
index 23beb30..557b490 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -28,7 +28,6 @@ private class Boxes.App: Gtk.Application {
 
     public string? uri { get; set; }
     public Collection collection;
-    public CollectionFilter filter;
 
     private bool is_ready;
     public signal void ready ();
@@ -49,7 +48,6 @@ private class Boxes.App: Gtk.Application {
         windows = new List<Boxes.AppWindow> ();
         sources = new HashTable<string,CollectionSource> (str_hash, str_equal);
         brokers = new HashTable<string,Broker> (str_hash, str_equal);
-        filter = new Boxes.CollectionFilter ();
         var action = new GLib.SimpleAction ("quit", null);
         action.activate.connect (() => { quit_app (); });
         add_action (action);
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 72b2466..df34372 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -37,6 +37,8 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
     private Boxes.ActionsPopover context_popover;
     private GLib.List<CollectionItem> hidden_items;
 
+    public CollectionFilter filter { construct; get; }
+
     private const Gtk.CornerType[] right_corners = { Gtk.CornerType.TOP_RIGHT, Gtk.CornerType.BOTTOM_RIGHT };
     private const Gtk.CornerType[] bottom_corners = { Gtk.CornerType.BOTTOM_LEFT, 
Gtk.CornerType.BOTTOM_RIGHT };
 
@@ -53,8 +55,12 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
     construct {
         category = new Category (_("New and Recent"), Category.Kind.NEW);
         hidden_items = new GLib.List<CollectionItem> ();
+        filter = new CollectionFilter ();
         setup_view ();
         notify["ui-state"].connect (ui_state_changed);
+        filter.notify["text"].connect (() => {
+            model_filter.refilter ();
+        });
     }
 
     public void setup_ui (AppWindow window) {
@@ -256,11 +262,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
         if (item  == null)
             return false;
 
-        return App.app.filter.filter (item);
-    }
-
-    public void refilter () {
-        model_filter.refilter ();
+        return filter.filter (item);
     }
 
     public void activate_first_item () {
diff --git a/src/searchbar.vala b/src/searchbar.vala
index ff6ee1e..538129d 100644
--- a/src/searchbar.vala
+++ b/src/searchbar.vala
@@ -29,8 +29,7 @@ private class Boxes.Searchbar: Gtk.SearchBar {
 
     [GtkCallback]
     private void on_search_changed () {
-        App.app.filter.text = text;
-        window.view.refilter ();
+        window.filter (text);
     }
 
     [GtkCallback]


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