[gnome-panel] panel: Check that toplevel/object id is unique as a dconf dir
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] panel: Check that toplevel/object id is unique as a dconf dir
- Date: Mon, 28 Mar 2011 21:13:00 +0000 (UTC)
commit f458292b693924216a885f84be977a2e255b3e1c
Author: Vincent Untz <vuntz gnome org>
Date: Thu Mar 24 21:50:59 2011 +0100
panel: Check that toplevel/object id is unique as a dconf dir
We were only checking that the id is not in the id list, but we don't
want to re-use a pre-existing dconf directory, so we have to check that
too.
gnome-panel/panel-layout.c | 34 +++++++++++++++++++++++-----------
gnome-panel/panel-schemas.h | 6 +++---
2 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index eb81243..93f83bc 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -31,6 +31,7 @@
#include <gdk/gdk.h>
#include <libpanel-util/panel-cleanup.h>
+#include <libpanel-util/panel-dconf.h>
#include <libpanel-util/panel-gsettings.h>
#include "panel-schemas.h"
@@ -172,18 +173,20 @@ panel_layout_append_self_check (GSettings *settings,
static char *
panel_layout_find_free_id (const char *id_list_key,
const char *schema,
+ const char *path_prefix,
const char *try_id,
int screen_for_toplevels)
{
char *unique_id;
char **existing_ids;
+ char **existing_dirs;
gboolean existing;
int index;
int i;
- /* TODO also check it doesn't exist in dconf */
existing_ids = g_settings_get_strv (layout_settings,
id_list_key);
+ existing_dirs = panel_dconf_list_subdirs (path_prefix);
index = 0;
existing = TRUE;
@@ -201,12 +204,16 @@ panel_layout_find_free_id (const char *id_list_key,
existing = FALSE;
- for (i = 0; existing_ids[i] != NULL; i++) {
+ for (i = 0; !existing && existing_ids[i] != NULL; i++) {
if (g_strcmp0 (unique_id,
- existing_ids[i]) == 0) {
+ existing_ids[i]) == 0)
+ existing = TRUE;
+ }
+ for (i = 0; !existing && existing_dirs[i] != NULL; i++) {
+ if (g_strcmp0 (unique_id,
+ existing_dirs[i]) == 0)
existing = TRUE;
break;
- }
}
if (existing)
@@ -235,18 +242,23 @@ panel_layout_find_free_id (const char *id_list_key,
existing = FALSE;
- for (i = 0; existing_ids[i] != NULL; i++) {
+ for (i = 0; !existing && existing_ids[i] != NULL; i++) {
if (g_strcmp0 (unique_id,
- existing_ids[i]) == 0) {
+ existing_ids[i]) == 0)
+ existing = TRUE;
+ }
+ for (i = 0; !existing && existing_dirs[i] != NULL; i++) {
+ if (g_strcmp0 (unique_id,
+ existing_dirs[i]) == 0)
existing = TRUE;
- break;
- }
}
- g_free (unique_id);
+ if (existing)
+ g_free (unique_id);
index++;
}
+ g_strfreev (existing_dirs);
g_strfreev (existing_ids);
return unique_id;
@@ -292,10 +304,10 @@ panel_layout_append_group_helper (GKeyFile *keyfile,
if (id && !panel_gsettings_is_valid_keyname (id, error))
return FALSE;
- unique_id = panel_layout_find_free_id (id_list_key, schema,
+ unique_id = panel_layout_find_free_id (id_list_key, schema, path_prefix,
id, set_screen_to);
- path = g_strdup_printf ("%s/%s/", path_prefix, unique_id);
+ path = g_strdup_printf ("%s%s/", path_prefix, unique_id);
settings = g_settings_new_with_path (schema, path);
g_free (path);
diff --git a/gnome-panel/panel-schemas.h b/gnome-panel/panel-schemas.h
index 4846ce2..b6fda2c 100644
--- a/gnome-panel/panel-schemas.h
+++ b/gnome-panel/panel-schemas.h
@@ -25,11 +25,11 @@
#define PANEL_LAYOUT_TOPLEVEL_ID_LIST "toplevel-id-list"
#define PANEL_LAYOUT_OBJECT_ID_LIST "object-id-list"
-#define PANEL_LAYOUT_TOPLEVEL_PATH "/org/gnome/gnome-panel/layout/toplevels"
+#define PANEL_LAYOUT_TOPLEVEL_PATH "/org/gnome/gnome-panel/layout/toplevels/"
#define PANEL_LAYOUT_TOPLEVEL_DEFAULT_PREFIX "toplevel"
-#define PANEL_LAYOUT_OBJECT_PATH "/org/gnome/gnome-panel/layout/objects"
+#define PANEL_LAYOUT_OBJECT_PATH "/org/gnome/gnome-panel/layout/objects/"
#define PANEL_LAYOUT_OBJECT_DEFAULT_PREFIX "object"
-#define PANEL_LAYOUT_OBJECT_CONFIG_SUFFIX "instance-config"
+#define PANEL_LAYOUT_OBJECT_CONFIG_SUFFIX "/instance-config/"
#define PANEL_TOPLEVEL_SCHEMA "org.gnome.gnome-panel.toplevel"
#define PANEL_TOPLEVEL_NAME "name"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]