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



commit f057cd0681fd3ee8b0a59d5b699f506b58a595ef
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 |   64 ++++++++++++++++++++++++++------------------
 1 files changed, 38 insertions(+), 26 deletions(-)
---
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 53893e7..cb1b519 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)
 {
@@ -1094,32 +1128,10 @@ panel_layout_load (void)
                                          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;
-                }
+          g_strfreev(toplevels);
+          if (!panel_layout_load_default (&toplevels)) {
+            return FALSE;
+          }
         }
 
         for (i = 0; toplevels[i] != NULL; i++)


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