[dconf-editor] Refactor window creation.



commit 468a25798bf9481beff4c266cd209ddcab3abb72
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Dec 9 06:42:07 2017 +0100

    Refactor window creation.

 editor/dconf-editor.vala |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index d7078b0..d6f3a5f 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -330,8 +330,7 @@ class ConfigurationEditor : Gtk.Application
                 commands.print (_("Cannot understand second argument in this context.\n"));
                 ret = Posix.EXIT_FAILURE;
             }
-            DConfWindow window = new DConfWindow (disable_warning, null, arg0, null);
-            add_window (window);
+            Gtk.Window window = get_new_window (null, arg0, null);
             window.present ();
             return ret;
         }
@@ -373,8 +372,7 @@ class ConfigurationEditor : Gtk.Application
             }
         }
 
-        DConfWindow window = new DConfWindow (disable_warning, test_format [0], path, key_name);
-        add_window (window);
+        Gtk.Window window = get_new_window (test_format [0], path, key_name);
         window.present ();
         return ret;
     }
@@ -390,13 +388,17 @@ class ConfigurationEditor : Gtk.Application
     {
         Gtk.Window? window = get_active_window ();
         if (window == null)
-        {
-            window = new DConfWindow (disable_warning, null, null, null);
-            add_window ((!) window);
-        }
+            window = get_new_window (null, null, null);
         ((!) window).present ();
     }
 
+    private Gtk.Window get_new_window (string? schema, string? path, string? key_name)
+    {
+        DConfWindow window = new DConfWindow (disable_warning, schema, path, key_name);
+        add_window (window);
+        return (Gtk.Window) window;
+    }
+
     /*\
     * * Copy action
     \*/


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