[gnome-panel/wip/muktupavels/default-layout: 9/9] layout: redo default layout loading
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/default-layout: 9/9] layout: redo default layout loading
- Date: Mon, 16 Dec 2019 15:36:40 +0000 (UTC)
commit b341b4f25bd07834e4e08630fbfe5863952eb64e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Dec 16 16:22:01 2019 +0200
layout: redo default layout loading
Default layout now can be configured with default-layout key in
org.gnome.gnome-panel.general schema.
Panel will look for default layout in ~/.config/gnome-panel/layouts
and then in /usr/share/gnome-panel/layouts. If configured layout
does not exist panel will fallback to default.layout in
/usr/share/gnome-panel/layouts.
data/org.gnome.gnome-panel.gschema.xml | 6 +++++
gnome-panel/panel-layout.c | 41 ++++++++++++++++++++++++++--------
2 files changed, 38 insertions(+), 9 deletions(-)
---
diff --git a/data/org.gnome.gnome-panel.gschema.xml b/data/org.gnome.gnome-panel.gschema.xml
index 83df79c90..457332f83 100644
--- a/data/org.gnome.gnome-panel.gschema.xml
+++ b/data/org.gnome.gnome-panel.gschema.xml
@@ -23,6 +23,12 @@
</enum>
<schema id="org.gnome.gnome-panel.general" path="/org/gnome/gnome-panel/general/">
+ <key name="default-layout" type="s">
+ <default>'default'</default>
+ <summary>Default panel layout</summary>
+ <description>The default panel layout to use when panels are created.</description>
+ </key>
+
<key name="enable-tooltips" type="b">
<default>true</default>
<summary>Enable tooltips</summary>
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 3de5a4e24..a94d4d26d 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -1078,18 +1078,41 @@ panel_layout_load_object (const char *object_id)
static char *
panel_layout_get_default_layout_file (void)
{
- char *user_file;
+ GSettings *settings;
+ char *default_layout;
+ char *layout_name;
+ char *filename;
- user_file = g_build_filename (g_get_user_config_dir (),
- "gnome-panel",
- "layouts",
- DEFAULT_LAYOUT_FILE,
- NULL);
+ settings = g_settings_new ("org.gnome.gnome-panel.general");
+ default_layout = g_settings_get_string (settings, "default-layout");
+ g_object_unref (settings);
+
+ layout_name = g_strdup_printf ("%s.layout", default_layout);
+ g_free (default_layout);
- if (g_file_test (user_file, G_FILE_TEST_IS_REGULAR))
- return user_file;
+ filename = g_build_filename (g_get_user_config_dir (),
+ "gnome-panel",
+ "layouts",
+ layout_name,
+ NULL);
+
+ if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
+ g_free (layout_name);
+ return filename;
+ }
+
+ g_free (filename);
+ filename = g_build_filename (LAYOUTSDIR,
+ layout_name,
+ NULL);
+
+ if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
+ g_free (layout_name);
+ return filename;
+ }
- g_free (user_file);
+ g_free (layout_name);
+ g_free (filename);
return g_build_filename (LAYOUTSDIR,
DEFAULT_LAYOUT_FILE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]