[Xfce4-commits] <xfce4-screenshooter:master> Check if the URI in the plugin rc file is valid.
Jérôme Guelfucci
noreply at xfce.org
Mon Oct 19 23:04:01 CEST 2009
Updating branch refs/heads/master
to 368702d4b2fe1720c5ce2932335c71e4a6ee91b2 (commit)
from 434defbccea385c94567a81ab4d3a9585aa2555e (commit)
commit 368702d4b2fe1720c5ce2932335c71e4a6ee91b2
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date: Mon Oct 19 23:05:40 2009 +0200
Check if the URI in the plugin rc file is valid.
Fallback to the XDG image dir if it's not valid.
panel-plugin/screenshooter-plugin.c | 12 ++++++++++++
src/main.c | 2 +-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/panel-plugin/screenshooter-plugin.c b/panel-plugin/screenshooter-plugin.c
index 076e16a..a3dbfb6 100644
--- a/panel-plugin/screenshooter-plugin.c
+++ b/panel-plugin/screenshooter-plugin.c
@@ -331,6 +331,7 @@ screenshooter_plugin_construct (XfcePanelPlugin *plugin)
/* Initialise the data structs */
PluginData *pd = g_new0 (PluginData, 1);
ScreenshotData *sd = g_new0 (ScreenshotData, 1);
+ GFile *default_save_dir;
g_thread_init (NULL);
@@ -344,6 +345,17 @@ screenshooter_plugin_construct (XfcePanelPlugin *plugin)
TRACE ("Read the preferences file");
screenshooter_plugin_read_rc_file (plugin, pd);
+ /* Check if the directory read from the preferences is valid */
+ default_save_dir = g_file_new_for_uri (sd->screenshot_dir);
+
+ if (G_UNLIKELY (!g_file_query_exists (default_save_dir, NULL)))
+ {
+ g_free (pd->sd->screenshot_dir);
+ pd->sd->screenshot_dir = screenshooter_get_xdg_image_dir_uri ();
+ }
+
+ g_object_unref (default_save_dir);
+
/* We want to take only one screenshot as in CLI, but not to close the main
loop after taking a screenshot */
pd->sd->plugin = TRUE;
diff --git a/src/main.c b/src/main.c
index 536157e..558bda7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -217,7 +217,7 @@ int main (int argc, char **argv)
if (G_UNLIKELY (!g_file_query_exists (default_save_dir, NULL)))
{
g_free (sd->screenshot_dir);
- sd->screenshot_dir = screenshooter_get_home_uri ();
+ sd->screenshot_dir = screenshooter_get_xdg_image_dir_uri ();
}
g_object_unref (default_save_dir);
More information about the Xfce4-commits
mailing list