[gnome-boxes] Revert "Remove unused identifiers"



commit 63e6ec8d1ac03e0e6dde5e964bcfb43ee742dab3
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Mon Oct 24 23:30:39 2011 +0200

    Revert "Remove unused identifiers"
    
    This reverts commit 0e5b75459b4f68e280f7d20531f775a665bb4248.

 src/collection.vala |    9 +++++++++
 src/util.vala       |   22 ++++++++++++++++++++++
 src/wizard.vala     |    2 +-
 3 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/collection.vala b/src/collection.vala
index dff3e94..1138934 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -60,6 +60,15 @@ private class Boxes.CollectionSource: GLib.Object {
                                 KeyFileFlags.KEEP_COMMENTS | KeyFileFlags.KEEP_TRANSLATIONS);
     }
 
+    private void save () {
+        if (filename == null) {
+            filename = make_filename (name);
+            keyfile_save (keyfile, get_pkgconfig_source (filename));
+        } else {
+            keyfile_save (keyfile, get_pkgconfig_source (filename), true);
+        }
+    }
+
     private string? get_string (string group, string key) {
         try {
             return keyfile.get_string (group, key);
diff --git a/src/util.vala b/src/util.vala
index 6febb31..b73af2e 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -144,6 +144,17 @@ namespace Boxes {
         return obj->stringval;
     }
 
+    private bool keyfile_save (KeyFile key_file, string file_name, bool overwrite = false) {
+        if (!overwrite && FileUtils.test (file_name, FileTest.EXISTS))
+            return false;
+
+        var file = FileStream.open (file_name, "w");
+        var data = key_file.to_data (null);
+        file.puts (data);
+
+        return true;
+    }
+
     public string replace_regex (string str, string old, string replacement) {
         try {
             var regex = new GLib.Regex (old);
@@ -154,6 +165,17 @@ namespace Boxes {
         }
     }
 
+    private string make_filename (string name) {
+        var filename = replace_regex (name, "[\\\\/:()<>|?*]", "_");
+
+        var tryname = filename;
+        for (var i = 0; FileUtils.test (tryname, FileTest.EXISTS); i++) {
+            tryname =  "%s-%d".printf (filename, i);
+        }
+
+        return tryname;
+    }
+
     private void actor_add (Clutter.Actor actor, Clutter.Container container) {
         if (actor.get_parent () == (Clutter.Actor) container)
             return;
diff --git a/src/wizard.vala b/src/wizard.vala
index 9ebf897..9783cc2 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -204,7 +204,7 @@ private class Boxes.Wizard: Boxes.UI {
             var text = this.source.url_entry.get_text ();
 
             bool uncertain;
-            ContentType.guess (text, null, out uncertain);
+            var type = ContentType.guess (text, null, out uncertain);
             if (uncertain) {
                 var uri = Xml.URI.parse (text);
                 if (uri.scheme == "spice" || uri.scheme == "vnc") {



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