[gnome-boxes] display-config: add set_category() to add/remove a category



commit 09c6cc5cfbfc54690e8afbef7aba200085201cc3
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Mon Aug 20 19:00:22 2012 +0200

    display-config: add set_category() to add/remove a category
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682292

 src/display-config.vala |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/display-config.vala b/src/display-config.vala
index f785274..7cf1a82 100644
--- a/src/display-config.vala
+++ b/src/display-config.vala
@@ -39,7 +39,17 @@ public class Boxes.DisplayConfig: GLib.Object, Boxes.IConfig {
         this.group = group;
     }
 
-    public void add_category (string category) {
+    private void remove_category (string category) {
+        string[] categories = {};
+
+        foreach (var it in this.categories)
+            if (it != category)
+                categories += it;
+
+        this.categories = categories;
+    }
+
+    private void add_category (string category) {
         if (category in categories)
             return;
 
@@ -47,6 +57,13 @@ public class Boxes.DisplayConfig: GLib.Object, Boxes.IConfig {
         string[] categories = categories;
         categories += category;
         this.categories = categories;
+    }
+
+    public void set_category (string category, bool enabled) {
+        if (enabled)
+            add_category (category);
+        else
+            remove_category (category);
 
         save ();
     }



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