[glib/wip/plist] nextstep settings backend initial fixes



commit 3ec1825e31681f675040d32e5b6415a861818488
Author: William Hua <william attente ca>
Date:   Tue Dec 27 02:14:03 2011 -0500

    nextstep settings backend initial fixes
    
    Fixed:
    Copyright headers
    Finalizer chain up
    Removed insanity
    Used size from g_variant_iter_init directly
    
    To do:
    Hook up signals
    Just write the blob as data
    Use g_variant_type_{key,value} instead
    Remove object path, signature support
    Remove duplicate else return NULL;'s
    Unalign code
    Remove extra space

 gio/gnextstepsettingsbackend.c |   54 +++++++++++++++++++++++-----------------
 gio/gnextstepsettingsbackend.h |   23 +++++++++++++++++
 2 files changed, 54 insertions(+), 23 deletions(-)
---
diff --git a/gio/gnextstepsettingsbackend.c b/gio/gnextstepsettingsbackend.c
index a746c14..4431016 100644
--- a/gio/gnextstepsettingsbackend.c
+++ b/gio/gnextstepsettingsbackend.c
@@ -1,3 +1,26 @@
+/*
+ * Copyright  2011 William Hua
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: William Hua <william attente ca>
+ */
+
+
+
 #include "gnextstepsettingsbackend.h"
 #include "gsimplepermission.h"
 #include "giomodule.h"
@@ -124,6 +147,8 @@ g_nextstep_settings_backend_finalize (GObject *self)
   [G_NEXTSTEP_SETTINGS_BACKEND (self)->user_defaults release];
 
   [pool drain];
+
+  G_OBJECT_CLASS (g_nextstep_settings_backend_parent_class)->finalize (self);
 }
 
 
@@ -135,29 +160,16 @@ g_nextstep_settings_backend_read (GSettingsBackend   *backend,
                                   gboolean            default_value)
 {
   NSAutoreleasePool *pool;
-  NSUserDefaults    *user_defaults;
   NSString          *name;
   id                 value;
   GVariant          *variant;
 
-  pool          = [[NSAutoreleasePool alloc] init];
-  user_defaults = G_NEXTSTEP_SETTINGS_BACKEND (backend)->user_defaults;
-  name          = [NSString stringWithUTF8String:key];
-
   if (default_value)
-    {
-      id old_value;
-
-      old_value = [[[user_defaults objectForKey:name] retain] autorelease];
-      [user_defaults removeObjectForKey:name];
-      value = [[[user_defaults objectForKey:name] retain] autorelease];
-
-      if (old_value != value)
-        [user_defaults setObject:old_value forKey:name];
-    }
-  else
-    value = [user_defaults objectForKey:name];
+    return NULL;
 
+  pool    = [[NSAutoreleasePool alloc] init];
+  name    = [NSString stringWithUTF8String:key];
+  value   = [G_NEXTSTEP_SETTINGS_BACKEND (backend)->user_defaults objectForKey:name];
   variant = g_nextstep_settings_backend_get_g_variant (value, expected_type);
 
   [pool drain];
@@ -491,9 +503,7 @@ g_nextstep_settings_backend_get_ns_object (GVariant *variant)
       GVariant            *name;
       GVariant            *value;
 
-      dictionary = [NSMutableDictionary dictionaryWithCapacity:g_variant_n_children (variant)];
-
-      g_variant_iter_init (&iter, variant);
+      dictionary = [NSMutableDictionary dictionaryWithCapacity:g_variant_iter_init (&iter, variant)];
 
       while (g_variant_iter_loop (&iter, "{s*}", &name, &value))
         {
@@ -514,9 +524,7 @@ g_nextstep_settings_backend_get_ns_object (GVariant *variant)
       GVariantIter    iter;
       GVariant       *value;
 
-      array = [NSMutableArray arrayWithCapacity:g_variant_n_children (variant)];
-
-      g_variant_iter_init (&iter, variant);
+      array = [NSMutableArray arrayWithCapacity:g_variant_iter_init (&iter, variant)];
 
       while ((value = g_variant_iter_next_value (&iter)) != NULL)
         [array addObject:g_nextstep_settings_backend_get_ns_object (value)];
diff --git a/gio/gnextstepsettingsbackend.h b/gio/gnextstepsettingsbackend.h
index e4e3dbe..34b29ea 100644
--- a/gio/gnextstepsettingsbackend.h
+++ b/gio/gnextstepsettingsbackend.h
@@ -1,3 +1,26 @@
+/*
+ * Copyright  2011 William Hua
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: William Hua <william attente ca>
+ */
+
+
+
 #ifndef __G_NEXTSTEP_SETTINGS_BACKEND_H__
 #define __G_NEXTSTEP_SETTINGS_BACKEND_H__
 



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