[dconf-editor] Make --enable-experimental-non-null less angry.



commit dcf52de5bf1fa52b4804018755f9e14d35ac14a9
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Oct 12 01:51:19 2015 +0200

    Make --enable-experimental-non-null less angry.

 editor/dconf-editor.vala |    9 +++----
 editor/dconf-model.vala  |   51 ++++++++++++++++++++++++++++------------------
 editor/dconf-view.vala   |    4 +-
 editor/dconf-window.vala |   14 ++++++++----
 4 files changed, 46 insertions(+), 32 deletions(-)
---
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 3871d75..89c534b 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -17,10 +17,9 @@
 
 class ConfigurationEditor : Gtk.Application
 {
-    private const OptionEntry [] option_entries =
+    private const OptionEntry option_entries [] =
     {
-        { "version", 'v', 0, OptionArg.NONE, null, N_("Print release version and exit"), null },
-        { null }
+        { "version", 'v', 0, OptionArg.NONE, null, N_("Print release version and exit"), null }
     };
 
     private const GLib.ActionEntry [] action_entries =
@@ -84,7 +83,7 @@ class ConfigurationEditor : Gtk.Application
 
     private void about_cb ()
     {
-        string [] authors = { "Robert Ancell", "Arnaud Bonatti", null };
+        string [] authors = { "Robert Ancell", "Arnaud Bonatti" };
         string license = _("Dconf Editor is free software: you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of 
the License, or (at your option) any later version.\n\nDconf Editor 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 General Public License for more details.\n\nYou should have received a copy 
of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.");
         Gtk.show_about_dialog (get_active_window (),
                                "program-name", _("dconf Editor"),
@@ -99,7 +98,7 @@ class ConfigurationEditor : Gtk.Application
                                null);
     }
 
-    private void quit_cb ()     // session crash (!) if a modal GtkMessageDialog/KeyEditorDialog is open
+    private void quit_cb ()
     {
         get_active_window ().destroy ();
     }
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index c372999..3ada913 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -81,7 +81,7 @@ public class Key : SettingObject
             if (maybe_variant == null)
                 return cool_boolean_text_value (null, false);
             if (type == "mb")
-                return cool_boolean_text_value (maybe_variant.get_boolean (), false);
+                return cool_boolean_text_value (((!) maybe_variant).get_boolean (), false);
         }
         return variant.print (false);
     }
@@ -135,7 +135,7 @@ public class Key : SettingObject
 
     public bool is_default
     {
-        get { update_value(); return _value == null; }
+        get { update_value (); return _value == null; }
     }
 
     public signal void value_changed();
@@ -158,9 +158,9 @@ public class Key : SettingObject
         this.schema = schema;
         has_schema = schema != null;
 
-        if (has_schema)
-            type_string = schema.type;
-        else if (value != null)
+        if (schema != null)
+            type_string = ((!) schema).type;
+        else if (_value != null)
             type_string = value.get_type_string ();
 
         model.item_changed.connect (item_changed);
@@ -169,7 +169,15 @@ public class Key : SettingObject
     public void set_to_default()
         requires (has_schema)
     {
-        value = null;
+        _value = null;
+        try
+        {
+            model.client.write_sync (full_name, null);
+        }
+        catch (Error e)
+        {
+        }
+        value_changed ();
     }
 
     private void update_value()
@@ -201,10 +209,12 @@ public class SettingsModel : Object, Gtk.TreeModel
 
         foreach (string settings_schema_id in non_relocatable_schemas)
         {
-            SettingsSchema settings_schema = settings_schema_source.lookup (settings_schema_id, true);
-            string schema_path = settings_schema.get_path ();
+            SettingsSchema? settings_schema = settings_schema_source.lookup (settings_schema_id, true);
+            if (settings_schema == null)
+                continue;       // TODO better
+            string schema_path = ((!) settings_schema).get_path ();
             Directory view = create_gsettings_views (root, schema_path [1:schema_path.length]);
-            create_keys (view, settings_schema, schema_path);
+            create_keys (view, (!) settings_schema, schema_path);
         }
 
         client = new DConf.Client ();
@@ -246,13 +256,13 @@ public class SettingsModel : Object, Gtk.TreeModel
     private Directory get_child (Directory parent_view, string name)
     {
         Directory? view = parent_view.child_map.lookup (name);
-        if (view == null)
-        {
-            view = new Directory (parent_view, name, parent_view.full_name + name + "/");
-            parent_view.children.insert_sorted (view, (a, b) => { return strcmp (((Directory) a).name, 
((Directory) b).name); });
-            parent_view.child_map.insert (name, view);
-        }
-        return view;
+        if (view != null)
+            return (!) view;
+
+        Directory new_view = new Directory (parent_view, name, parent_view.full_name + name + "/");
+        parent_view.children.insert_sorted (new_view, (a, b) => { return strcmp (((Directory) a).name, 
((Directory) b).name); });
+        parent_view.child_map.insert (name, new_view);
+        return new_view;
     }
 
     /*\
@@ -293,12 +303,13 @@ public class SettingsModel : Object, Gtk.TreeModel
 
     private void make_key (Directory view, string name, SchemaKey? schema_key)
     {
-        if (view.key_map.lookup (name) != null)
+        Key? key = view.key_map.lookup (name);
+        if (key != null)
             return;
 
-        Key key = new Key (this, view, name, schema_key);
-        view.key_model.insert_sorted (key, (a, b) => { return strcmp (((SettingObject) a).name, 
((SettingObject) b).name); });
-        view.key_map.insert (name, key);
+        Key new_key = new Key (this, view, name, schema_key);
+        view.key_model.insert_sorted (new_key, (a, b) => { return strcmp (((SettingObject) a).name, 
((SettingObject) b).name); });
+        view.key_map.insert (name, new_key);
     }
 
     /*\
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index 9d14590..588f3bf 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -329,7 +329,7 @@ private class KeyEditorChildNullableBool : Grid, KeyEditorChild
         if (maybe_variant == null)
             button.label = Key.cool_boolean_text_value (null);
         else
-            button.label = Key.cool_boolean_text_value (maybe_variant.get_boolean ());
+            button.label = Key.cool_boolean_text_value (((!) maybe_variant).get_boolean ());
         this.attach (button, 1, 0, 1, 1);
 
         ContextPopover popover = new ContextPopover ();
@@ -538,7 +538,7 @@ private class KeyEditorChildDefault : Entry, KeyEditorChild
         try
         {
             Variant? tmp_variant = Variant.parse (new VariantType (variant_type), this.text);
-            variant = tmp_variant;
+            variant = (!) tmp_variant;
             return true;
         }
         catch (VariantParseError e)
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 5d95e2a..38b897d 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -198,7 +198,7 @@ class DConfWindow : ApplicationWindow
         {
             ListBoxRow? selected_row = (ListBoxRow) key_list_box.get_selected_row ();
             if (selected_row != null)
-                position = selected_row.get_index () + 1;
+                position = ((!) selected_row).get_index () + 1;
         }
         else if (!model.get_iter_first (out iter))      // TODO doesn't that reset iter?
             return;     // TODO better
@@ -442,7 +442,9 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
         popover = new ContextPopover ();
         popover.add_action_button (_("Customize…"), () => { show_dialog (); }, true);
         popover.add_action_button (_("Copy"), () => {
-                Clipboard clipboard = Clipboard.get_default (Gdk.Display.get_default ());
+                Gdk.Display? display = Gdk.Display.get_default ();
+                    if (display == null) return;
+                Clipboard clipboard = Clipboard.get_default ((!) display);
                 string copy = key.full_name + " " + key.value.print (false);
                 clipboard.set_text (copy, copy.length);
             });
@@ -483,7 +485,9 @@ private class KeyListBoxRowEditable : KeyListBoxRow
         popover = new ContextPopover ();
         popover.add_action_button (_("Customize…"), () => { show_dialog (); }, true);
         popover.add_action_button (_("Copy"), () => {
-                Clipboard clipboard = Clipboard.get_default (Gdk.Display.get_default ());
+                Gdk.Display? display = Gdk.Display.get_default ();
+                    if (display == null) return;
+                Clipboard clipboard = Clipboard.get_default ((!) display);
                 string copy = key.schema.schema_id + " " + key.name + " " + key.value.print (false);
                 clipboard.set_text (copy, copy.length);
             });
@@ -594,10 +598,10 @@ private class ContextPopover : Popover
                 Variant? new_variant = tmp_variant.get_maybe ();
                 if (new_variant == null)
                     set_to_default ();
-                else if (new_variant.get_data () == null)
+                else if (((!) new_variant).get_data () == null)     // TODO better
                     value_changed (null);
                 else
-                    value_changed (new_variant.get_data_as_bytes ());
+                    value_changed (((!) new_variant).get_data_as_bytes ());
             });
     }
 


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