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



commit 9272191f1b5f571b9e2cf3b9339accf5b31d06d3
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, 44 insertions(+), 26 deletions(-)
---
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 53893e7..752f443 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 char **panel_layout_load_default (void);
 
 static GQuark
 panel_layout_error_quark (void)
@@ -1081,6 +1082,40 @@ panel_layout_get_default_layout_file (void)
                                  NULL);
 }
 
+char **
+panel_layout_load_default (void)
+{
+  char *default_layout_file;
+  char **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 NULL;
+    }
+
+  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 NULL;
+    }
+
+  return toplevels;
+}
+
 gboolean
 panel_layout_load (void)
 {
@@ -1093,34 +1128,17 @@ 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 (!toplevels[0])
+          {
+            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"));
+            toplevels = panel_layout_load_default ();
 
-                        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)
+              {
+                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]