Commit 43997658 authored by Caolan McNamara's avatar Caolan McNamara Committed by Luis Menina

Search files in XDG directories instead of old config dirs.

https://bugzilla.gnome.org/show_bug.cgi?id=596173
parent 90ab7e76
......@@ -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;
......
......@@ -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) {
......
......@@ -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);
}
......@@ -163,6 +152,33 @@ plugin_init (PlannerPlugin *plugin)
g_dir_close (dir);
}
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)
{
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
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