[gnome-panel] panel-layout: load default layout in separate function
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] panel-layout: load default layout in separate function
- Date: Fri, 16 Feb 2018 19:34:13 +0000 (UTC)
commit 32cf1e076962cbb30859433c836c73b8bff9fbde
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 | 67 +++++++++++++++++++++++++++-----------------
1 files changed, 41 insertions(+), 26 deletions(-)
---
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 53893e7..1ca1159 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -1081,6 +1081,40 @@ panel_layout_get_default_layout_file (void)
NULL);
}
+static 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 +1127,15 @@ panel_layout_load (void)
toplevels = g_settings_get_strv (layout_settings,
PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY);
- if (!toplevels[0]) {
- char *default_layout_file;
+ if (!toplevels[0])
+ {
+ g_strfreev (toplevels);
- g_strfreev (toplevels);
+ toplevels = panel_layout_load_default ();
- 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)
+ 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]