[gnome-boxes/wip/exalm/libhandy1: 2/6] collection-filter-switcher: Replace local/remote with favorites



commit b7ee8149db312bac340cb7843d3a4532f9361d46
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue May 26 15:59:43 2020 +0500

    collection-filter-switcher: Replace local/remote with favorites
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-boxes/-/issues/465

 data/ui/collection-filter-switcher.ui | 19 ++-----------------
 src/collection-filter-switcher.vala   | 21 +++++----------------
 2 files changed, 7 insertions(+), 33 deletions(-)
---
diff --git a/data/ui/collection-filter-switcher.ui b/data/ui/collection-filter-switcher.ui
index b14618f3..e0e7fbde 100644
--- a/data/ui/collection-filter-switcher.ui
+++ b/data/ui/collection-filter-switcher.ui
@@ -22,26 +22,11 @@
     </child>
 
     <child>
-      <object class="GtkRadioButton" id="local_button">
+      <object class="GtkRadioButton" id="favorites_button">
         <property name="visible">True</property>
         <property name="group">all_button</property>
         <property name="draw-indicator">False</property>
-        <property name="label" translatable="yes" comments="Translators: this is a switch to show only local 
boxes in main view.">Local</property>
-        <signal name="toggled" handler="activate_button"/>
-      </object>
-
-      <packing>
-        <property name="expand">True</property>
-        <property name="fill">True</property>
-      </packing>
-    </child>
-
-    <child>
-      <object class="GtkRadioButton" id="remote_button">
-        <property name="visible">True</property>
-        <property name="group">all_button</property>
-        <property name="draw-indicator">False</property>
-        <property name="label" translatable="yes" comments="Translators: this is a switch to show only 
remote boxes in main view.">Remote</property>
+        <property name="label" translatable="yes" comments="Translators: this is a switch to show only 
favorite boxes in main view.">Favorites</property>
         <signal name="toggled" handler="activate_button"/>
       </object>
 
diff --git a/src/collection-filter-switcher.vala b/src/collection-filter-switcher.vala
index 8aff0f4a..1270b722 100644
--- a/src/collection-filter-switcher.vala
+++ b/src/collection-filter-switcher.vala
@@ -5,9 +5,7 @@
     [GtkChild]
     private Gtk.ToggleButton all_button;
     [GtkChild]
-    private Gtk.ToggleButton local_button;
-    [GtkChild]
-    private Gtk.ToggleButton remote_button;
+    private Gtk.ToggleButton favorites_button;
 
     private Gtk.ToggleButton active_button;
     private weak AppWindow window;
@@ -26,26 +24,17 @@ public void setup_ui (AppWindow window) {
     private unowned CollectionFilterFunc? get_filter_func () {
         if (active_button == all_button)
             return null;
-        if (active_button == local_button)
-            return local_filter_func;
-        if (active_button == remote_button)
-            return remote_filter_func;
+        if (active_button == favorites_button)
+            return favorites_filter_func;
         else
             return null;
     }
 
-    private bool local_filter_func (Boxes.CollectionItem item) {
-        assert (item != null && item is Machine);
-        var machine = item as Machine;
-
-        return machine.is_local;
-    }
-
-    private bool remote_filter_func (Boxes.CollectionItem item) {
+    private bool favorites_filter_func (Boxes.CollectionItem item) {
         assert (item != null && item is Machine);
         var machine = item as Machine;
 
-        return !machine.is_local;
+        return "favorite" in machine.config.categories;
     }
 
     private void on_app_ready () {


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