[planner] Search files in XDG directories instead of old config dirs.
- From: Luis Menina <lmenina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner] Search files in XDG directories instead of old config dirs.
- Date: Tue, 31 Jul 2012 18:00:54 +0000 (UTC)
commit 439976587b2a1219bf608bdf1d737fc12b802513
Author: Caolan McNamara <caolanm redhat com>
Date: Mon Jul 11 10:18:00 2011 +0000
Search files in XDG directories instead of old config dirs.
https://bugzilla.gnome.org/show_bug.cgi?id=596173
src/planner-msp-plugin.c | 2 +-
src/planner-print-dialog.c | 10 ++++----
src/planner-python-plugin.c | 46 +++++++++++++++++++++++++------------
src/planner-window.c | 2 +-
src/planner-xml-planner-plugin.c | 2 +-
5 files changed, 39 insertions(+), 23 deletions(-)
---
diff --git a/src/planner-msp-plugin.c b/src/planner-msp-plugin.c
index 12b69c6..27c13e3 100644
--- a/src/planner-msp-plugin.c
+++ b/src/planner-msp-plugin.c
@@ -177,7 +177,7 @@ msp_plugin_get_last_dir (PlannerPlugin *plugin)
dir = planner_conf_get_string (CONF_MSP_PLUGIN_LAST_DIR, NULL);
if (dir == NULL) {
- dir = g_strdup (g_get_home_dir ());
+ dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
}
return dir;
diff --git a/src/planner-print-dialog.c b/src/planner-print-dialog.c
index d008c43..b78a11b 100644
--- a/src/planner-print-dialog.c
+++ b/src/planner-print-dialog.c
@@ -43,7 +43,7 @@ ensure_dir (void)
{
char *dir;
- dir = g_build_filename (g_get_home_dir (), ".gnome2", NULL);
+ dir = g_build_filename (g_get_user_config_dir (), NULL);
if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
if (g_mkdir (dir, 0755) != 0) {
@@ -54,7 +54,7 @@ ensure_dir (void)
g_free (dir);
- dir = g_build_filename (g_get_home_dir (), ".gnome2", "planner", NULL);
+ dir = g_build_filename (g_get_user_config_dir (), "planner", NULL);
if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
if (g_mkdir (dir, 0755) != 0) {
@@ -75,13 +75,12 @@ get_config_filename (void)
return NULL;
}
- return g_build_filename (g_get_home_dir (),
- ".gnome2", "planner",
+ return g_build_filename (g_get_user_config_dir (),
+ "planner",
PLANNER_PRINT_CONFIG_FILE,
NULL);
}
-
GtkPageSetup *
planner_print_dialog_load_page_setup (void)
{
@@ -171,6 +170,7 @@ planner_print_dialog_load_print_settings (void)
filename,
G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
NULL);
+
g_free (filename);
if (success) {
diff --git a/src/planner-python-plugin.c b/src/planner-python-plugin.c
index 27f0a91..61dc077 100644
--- a/src/planner-python-plugin.c
+++ b/src/planner-python-plugin.c
@@ -125,26 +125,15 @@ python_plugin_execute (const gchar *filename,
}
}
-G_MODULE_EXPORT void
-plugin_init (PlannerPlugin *plugin)
+static void
+plugin_execute_scripts(PlannerPlugin *plugin, const gchar *dirname)
{
- PlannerPluginPriv *priv;
GDir *dir;
- gchar *dirname, *full_filename;
+ gchar *full_filename;
const gchar *filename;
- priv = g_new0 (PlannerPluginPriv, 1);
- plugin->priv = priv;
-
- priv->scripts = g_hash_table_new (g_str_hash, g_str_equal);
-
- Py_Initialize ();
-
- /* Look in ~/.gnome2/planner/python/ and run the scripts that we find */
- dirname = g_build_filename (g_get_home_dir(), ".gnome2", "planner", "python", NULL);
dir = g_dir_open (dirname, 0, NULL);
if (dir == NULL) {
- g_free (dirname);
return;
}
@@ -152,7 +141,7 @@ plugin_init (PlannerPlugin *plugin)
while (filename != NULL) {
if (g_str_has_suffix (filename, ".py")) {
full_filename = g_build_filename (dirname, filename, NULL);
- python_plugin_execute (full_filename, plugin->main_window, priv->scripts);
+ python_plugin_execute (full_filename, plugin->main_window, plugin->priv->scripts);
g_free (full_filename);
}
@@ -164,6 +153,33 @@ plugin_init (PlannerPlugin *plugin)
}
G_MODULE_EXPORT void
+plugin_init (PlannerPlugin *plugin)
+{
+ PlannerPluginPriv *priv;
+ GDir *dir;
+ gchar *dirname;
+ const gchar *filename;
+
+ priv = g_new0 (PlannerPluginPriv, 1);
+ plugin->priv = priv;
+
+ priv->scripts = g_hash_table_new (g_str_hash, g_str_equal);
+
+ Py_Initialize ();
+
+ /* Look in $XDG_DATA_HOME/planner/python/ and run the scripts that we find */
+ dirname = g_build_filename (g_get_user_data_dir(), "planner", "python", NULL);
+ plugin_execute_scripts(plugin, dirname);
+ g_free (dirname);
+
+
+ /* Look in ~/.gnome2/planner/python/ and run the scripts that we find */
+ dirname = g_build_filename (g_get_home_dir(), ".gnome2", "planner", "python", NULL);
+ plugin_execute_scripts(plugin, dirname);
+ g_free (dirname);
+}
+
+G_MODULE_EXPORT void
plugin_exit (PlannerPlugin *plugin)
{
PlannerPluginPriv *priv;
diff --git a/src/planner-window.c b/src/planner-window.c
index 622b6c0..66e0d37 100644
--- a/src/planner-window.c
+++ b/src/planner-window.c
@@ -845,7 +845,7 @@ get_last_dir (PlannerWindow *window)
last_dir = planner_conf_get_string (CONF_LAST_DIR, NULL);
if (last_dir == NULL) {
- last_dir = g_strdup (g_get_home_dir ());
+ last_dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
}
return last_dir;
diff --git a/src/planner-xml-planner-plugin.c b/src/planner-xml-planner-plugin.c
index 6f703d7..8945407 100644
--- a/src/planner-xml-planner-plugin.c
+++ b/src/planner-xml-planner-plugin.c
@@ -63,7 +63,7 @@ get_last_dir (void)
last_dir = planner_conf_get_string (CONF_MAIN_LAST_XML_EXPORT_DIR, NULL);
if (last_dir == NULL) {
- last_dir = g_strdup (g_get_home_dir ());
+ last_dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
}
return last_dir;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]