[gnome-panel/wip/geiger/geometry: 27/33] panel-layout: load default layout in separate function
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/geiger/geometry: 27/33] panel-layout: load default layout in separate function
- Date: Sat, 6 Jan 2018 21:53:55 +0000 (UTC)
commit bc98e5ce4090a901e877b211b513bddb03a4c07c
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..77d46a3 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]