Commit cf7ddd11 authored by Jim Krehl's avatar Jim Krehl
Browse files

linked up user_modifiable gconf keys

svn path=/branches/version-2/; revision=187
parent fe1a666f
......@@ -18,6 +18,11 @@
#define DOCS_BOOKMARK_FILENAME "documents.xbel"
#define DIRS_BOOKMARK_FILENAME "places.xbel"
#define MODIFIABLE_SYSTEM_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_system_area"
#define MODIFIABLE_APPS_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_apps"
#define MODIFIABLE_DOCS_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_docs"
#define MODIFIABLE_DIRS_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_dirs"
static gchar *get_data_file_path (const gchar *, gboolean);
static gboolean store_has_uri (const gchar *, const gchar *);
static GList *get_uri_list (const gchar *);
......@@ -892,73 +897,61 @@ save_uri_list (const gchar *filename, const GList *uris)
static gchar *
get_data_file_path (const gchar *filename, gboolean writeable)
{
GList *dirs = NULL;
gboolean user_modifiable;
gchar *path;
gchar **global_dirs;
gchar *dir;
gchar *path;
gchar *dir;
GList *node;
gint i;
const gchar * const *sys_dirs;
gint i;
path = (gchar *) g_getenv ("XDG_DATA_HOME");
if (path)
dirs = g_list_append (dirs, g_build_filename (path, TOP_CONFIG_DIR, NULL));
if (! strcmp (filename, SYSTEM_BOOKMARK_FILENAME))
user_modifiable = GPOINTER_TO_INT (
libslab_get_gconf_value (MODIFIABLE_SYSTEM_GCONF_KEY));
else if (! strcmp (filename, APPS_BOOKMARK_FILENAME))
user_modifiable = GPOINTER_TO_INT (
libslab_get_gconf_value (MODIFIABLE_APPS_GCONF_KEY));
else if (! strcmp (filename, DOCS_BOOKMARK_FILENAME))
user_modifiable = GPOINTER_TO_INT (
libslab_get_gconf_value (MODIFIABLE_DOCS_GCONF_KEY));
else if (! strcmp (filename, DIRS_BOOKMARK_FILENAME))
user_modifiable = GPOINTER_TO_INT (
libslab_get_gconf_value (MODIFIABLE_DIRS_GCONF_KEY));
else
user_modifiable = TRUE;
dirs = g_list_append (dirs, g_build_filename (
g_get_home_dir (), DEFAULT_USER_XDG_DIR, TOP_CONFIG_DIR, NULL));
if (! user_modifiable && writeable)
return NULL;
if (! writeable) {
global_dirs = g_strsplit (g_getenv ("XDG_DATA_DIRS"), ":", 0);
if (user_modifiable) {
path = g_build_filename (g_get_user_data_dir (), PACKAGE, filename, NULL);
if (! (global_dirs && global_dirs [0])) {
g_strfreev (global_dirs);
global_dirs = g_strsplit (DEFAULT_GLOBAL_XDG_PATH, ":", 0);
}
if (writeable) {
dir = g_path_get_dirname (path);
g_mkdir_with_parents (dir, 0700);
g_free (dir);
for (i = 0; global_dirs [i]; ++i) {
path = g_build_filename (
global_dirs [i], TOP_CONFIG_DIR, NULL);
dirs = g_list_append (dirs, path);
return path;
}
g_strfreev (global_dirs);
}
for (node = dirs, path = NULL; ! path && node; node = node->next) {
dir = (gchar *) node->data;
path = g_build_filename (dir, filename, NULL);
if (! g_file_test (path, G_FILE_TEST_EXISTS)) {
g_free (path);
path = NULL;
}
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
}
if (! path && writeable) {
for (node = dirs, dir = NULL; ! dir && node; node = node->next) {
dir = (gchar *) node->data;
sys_dirs = g_get_system_data_dirs ();
if (! g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
dir = NULL;
}
for (i = 0; sys_dirs [i]; ++i) {
path = g_build_filename (sys_dirs [i], PACKAGE, filename, NULL);
if (! dir) {
dir = (gchar *) dirs->data;
g_mkdir_with_parents (dir, 0700);
}
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
path = g_build_filename (dir, filename, NULL);
g_free (path);
}
for (node = dirs; node; node = node->next)
g_free (node->data);
g_list_free (dirs);
return path;
return NULL;
}
static GnomeVFSMonitorHandle *
......
......@@ -241,6 +241,18 @@
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/applications/main-menu/lock-down/user_modifiable_system_area</key>
<applyto>/desktop/gnome/applications/main-menu/lock-down/user_modifiable_system_area</applyto>
<owner>gnome-main-menu</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short>lock-down status for the system area</short>
<long>set to true if the user is allowed to modify the list of system items.</long>
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/applications/main-menu/lock-down/user_modifiable_apps</key>
<applyto>/desktop/gnome/applications/main-menu/lock-down/user_modifiable_apps</applyto>
......
......@@ -97,6 +97,9 @@ bookmark_tile_table_update (TileTable *this, TileTableUpdateEvent *event)
path_old = BOOKMARK_TILE_TABLE_GET_CLASS (this)->get_store_path (FALSE);
path_new = BOOKMARK_TILE_TABLE_GET_CLASS (this)->get_store_path (TRUE);
if (! path_new)
goto exit;
bm_file_old = libslab_bookmark_file_new ();
libslab_bookmark_file_load_from_file (bm_file_old, path_old, & error);
......@@ -122,8 +125,11 @@ bookmark_tile_table_update (TileTable *this, TileTableUpdateEvent *event)
libslab_bookmark_file_free (bm_file_old);
libslab_bookmark_file_free (bm_file_new);
g_free (path_old);
g_free (path_new);
exit:
g_free (path_old);
}
static void
......@@ -140,6 +146,9 @@ bookmark_tile_table_uri_added (TileTable *this, TileTableURIAddedEvent *event)
path_old = BOOKMARK_TILE_TABLE_GET_CLASS (this)->get_store_path (FALSE);
path_new = BOOKMARK_TILE_TABLE_GET_CLASS (this)->get_store_path (TRUE);
if (! path_new)
goto exit;
bm_file = libslab_bookmark_file_new ();
libslab_bookmark_file_load_from_file (bm_file, path_old, & error);
......@@ -165,8 +174,11 @@ bookmark_tile_table_uri_added (TileTable *this, TileTableURIAddedEvent *event)
libslab_bookmark_file_free (bm_file);
g_free (path_old);
g_free (path_new);
exit:
g_free (path_old);
}
static void
......
......@@ -57,12 +57,16 @@
#define FILE_BROWSER_GCONF_KEY "/desktop/gnome/applications/main-menu/file_browser"
#define SEARCH_CMD_GCONF_KEY "/desktop/gnome/applications/main-menu/search_command"
#define LOCKDOWN_GCONF_DIR "/desktop/gnome/applications/main-menu/lock-down"
#define MORE_LINK_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/application_browser_link_visible"
#define SEARCH_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/search_area_visible"
#define STATUS_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/status_area_visible"
#define SYSTEM_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/system_area_visible"
#define SHOWABLE_TYPES_GCONF_KEY LOCKDOWN_GCONF_DIR "/showable_file_types"
#define LOCKDOWN_GCONF_DIR "/desktop/gnome/applications/main-menu/lock-down"
#define MORE_LINK_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/application_browser_link_visible"
#define SEARCH_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/search_area_visible"
#define STATUS_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/status_area_visible"
#define SYSTEM_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/system_area_visible"
#define SHOWABLE_TYPES_GCONF_KEY LOCKDOWN_GCONF_DIR "/showable_file_types"
#define MODIFIABLE_SYSTEM_GCONF_KEY LOCKDOWN_GCONF_DIR "/user_modifiable_system_area"
#define MODIFIABLE_APPS_GCONF_KEY LOCKDOWN_GCONF_DIR "/user_modifiable_apps"
#define MODIFIABLE_DOCS_GCONF_KEY LOCKDOWN_GCONF_DIR "/user_modifiable_docs"
#define MODIFIABLE_DIRS_GCONF_KEY LOCKDOWN_GCONF_DIR "/user_modifiable_dirs"
G_DEFINE_TYPE (MainMenuUI, main_menu_ui, G_TYPE_OBJECT)
......@@ -109,6 +113,10 @@ typedef struct {
guint status_vis_gconf_mntr_id;
guint system_vis_gconf_mntr_id;
guint showable_types_gconf_mntr_id;
guint modifiable_system_gconf_mntr_id;
guint modifiable_apps_gconf_mntr_id;
guint modifiable_docs_gconf_mntr_id;
guint modifiable_dirs_gconf_mntr_id;
gboolean ptr_is_grabbed;
gboolean kbd_is_grabbed;
......@@ -341,6 +349,10 @@ main_menu_ui_init (MainMenuUI *this)
priv->status_vis_gconf_mntr_id = 0;
priv->system_vis_gconf_mntr_id = 0;
priv->showable_types_gconf_mntr_id = 0;
priv->modifiable_system_gconf_mntr_id = 0;
priv->modifiable_apps_gconf_mntr_id = 0;
priv->modifiable_docs_gconf_mntr_id = 0;
priv->modifiable_dirs_gconf_mntr_id = 0;
priv->ptr_is_grabbed = FALSE;
priv->kbd_is_grabbed = FALSE;
......@@ -371,6 +383,10 @@ main_menu_ui_finalize (GObject *g_obj)
libslab_gconf_notify_remove (priv->status_vis_gconf_mntr_id);
libslab_gconf_notify_remove (priv->system_vis_gconf_mntr_id);
libslab_gconf_notify_remove (priv->showable_types_gconf_mntr_id);
libslab_gconf_notify_remove (priv->modifiable_system_gconf_mntr_id);
libslab_gconf_notify_remove (priv->modifiable_apps_gconf_mntr_id);
libslab_gconf_notify_remove (priv->modifiable_docs_gconf_mntr_id);
libslab_gconf_notify_remove (priv->modifiable_dirs_gconf_mntr_id);
G_OBJECT_CLASS (main_menu_ui_parent_class)->finalize (g_obj);
}
......@@ -794,6 +810,15 @@ setup_lock_down (MainMenuUI *this)
SYSTEM_VIS_GCONF_KEY, lockdown_notify_cb, this);
priv->showable_types_gconf_mntr_id = libslab_gconf_notify_add (
SHOWABLE_TYPES_GCONF_KEY, lockdown_notify_cb, this);
priv->modifiable_system_gconf_mntr_id = libslab_gconf_notify_add (
MODIFIABLE_SYSTEM_GCONF_KEY, lockdown_notify_cb, this);
priv->modifiable_apps_gconf_mntr_id = libslab_gconf_notify_add (
MODIFIABLE_APPS_GCONF_KEY, lockdown_notify_cb, this);
priv->modifiable_docs_gconf_mntr_id = libslab_gconf_notify_add (
MODIFIABLE_DOCS_GCONF_KEY, lockdown_notify_cb, this);
priv->modifiable_dirs_gconf_mntr_id = libslab_gconf_notify_add (
MODIFIABLE_DIRS_GCONF_KEY, lockdown_notify_cb, this);
}
static void
......@@ -1195,6 +1220,11 @@ apply_lockdown_settings (MainMenuUI *this)
for (i = 0; i < 5; ++i)
set_table_section_visible (this, priv->file_tables [i]);
tile_table_reload (priv->sys_table);
tile_table_reload (priv->file_tables [USER_APPS_TABLE]);
tile_table_reload (priv->file_tables [USER_DOCS_TABLE]);
tile_table_reload (priv->file_tables [USER_DIRS_TABLE]);
update_limits (this);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment