[gnome-panel/wip/geiger/geometry: 2/8] panel-layout: load default layout in separate function



commit 91c51404d3443c0b910fcd56f0c9ee2c123c7206
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sat Jan 6 09:41:23 2018 +0100

    panel-layout: load default layout in separate function

 gnome-panel/panel-layout.c |   70 ++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 28 deletions(-)
---
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 53893e7..c92a4cd 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -53,6 +53,7 @@ static void panel_layout_load_toplevel    (const char *toplevel_id);
 static void panel_layout_load_object      (const char *object_id);
 static void panel_layout_changed_toplevel (void);
 static void panel_layout_changed_object   (void);
+static gboolean panel_layout_load_default (char ***toplevels);
 
 static GQuark
 panel_layout_error_quark (void)
@@ -1081,6 +1082,39 @@ panel_layout_get_default_layout_file (void)
                                  NULL);
 }
 
+gboolean panel_layout_load_default (char ***toplevels)
+{
+  char *default_layout_file;
+
+
+  if (!g_settings_is_writable(layout_settings,
+                              PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY) ||
+      !g_settings_is_writable(layout_settings,
+                              PANEL_LAYOUT_OBJECT_ID_LIST_KEY))
+    {
+      g_printerr(_("Cannot create initial panel layout.\n"));
+
+      return FALSE;
+    }
+
+  default_layout_file = panel_layout_get_default_layout_file ();
+  panel_layout_append_from_file (default_layout_file);
+  g_free (default_layout_file);
+
+  *toplevels = g_settings_get_strv (layout_settings,
+                                    PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY);
+
+  if (!toplevels[0])
+    {
+      g_strfreev (*toplevels);
+      g_printerr (_("Cannot create initial panel layout.\n"));
+
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
 gboolean
 panel_layout_load (void)
 {
@@ -1093,34 +1127,14 @@ panel_layout_load (void)
         toplevels = g_settings_get_strv (layout_settings,
                                          PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY);
 
-        if (!toplevels[0]) {
-                char *default_layout_file;
-
-                g_strfreev (toplevels);
-
-                if (!g_settings_is_writable (layout_settings,
-                                             PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY) ||
-                    !g_settings_is_writable (layout_settings,
-                                             PANEL_LAYOUT_OBJECT_ID_LIST_KEY)) {
-                        g_printerr (_("Cannot create initial panel layout.\n"));
-
-                        return FALSE;
-                }
-
-                default_layout_file = panel_layout_get_default_layout_file ();
-                panel_layout_append_from_file (default_layout_file);
-                g_free (default_layout_file);
-
-                toplevels = g_settings_get_strv (layout_settings,
-                                                 PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY);
-
-                if (!toplevels[0]) {
-                        g_strfreev (toplevels);
-                        g_printerr (_("Cannot create initial panel layout.\n"));
-
-                        return FALSE;
-                }
-        }
+        if (!toplevels[0])
+          {
+            g_strfreev (toplevels);
+            if (!panel_layout_load_default (&toplevels))
+              {
+                return FALSE;
+              }
+          }
 
         for (i = 0; toplevels[i] != NULL; i++)
                 panel_layout_load_toplevel (toplevels[i]);


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