[gnome-screenshot] screenshot: don't apply some gsettings for headless mode
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screenshot] screenshot: don't apply some gsettings for headless mode
- Date: Sun, 5 Feb 2012 00:55:21 +0000 (UTC)
commit 872105d13c1bd652d00067327ad43036ee5637d0
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat Feb 4 19:49:43 2012 -0500
screenshot: don't apply some gsettings for headless mode
When we're not in interactive mode, we don't want to follow gsettings
preferences such as delay or including the window border.
Since changing options in interactive mode saves them to gsettings, we
would end up in a situation where e.g. setting a delay there would have
made that delay the default for key press invocation too.
src/screenshot-config.c | 97 ++++++++++++++++++-------------------
src/screenshot-config.h | 3 +-
src/screenshot-filename-builder.c | 6 +--
3 files changed, 49 insertions(+), 57 deletions(-)
---
diff --git a/src/screenshot-config.c b/src/screenshot-config.c
index c404327..43f9701 100644
--- a/src/screenshot-config.c
+++ b/src/screenshot-config.c
@@ -33,34 +33,6 @@
#define AUTO_SAVE_DIRECTORY_KEY "auto-save-directory"
#define LAST_SAVE_DIRECTORY_KEY "last-save-directory"
-static void
-populate_from_settings (ScreenshotConfig *config)
-{
- config->auto_save_dir =
- g_settings_get_string (config->settings,
- AUTO_SAVE_DIRECTORY_KEY);
- config->last_save_dir =
- g_settings_get_string (config->settings,
- LAST_SAVE_DIRECTORY_KEY);
- config->include_border =
- g_settings_get_boolean (config->settings,
- INCLUDE_BORDER_KEY);
- config->include_icc_profile =
- g_settings_get_boolean (config->settings,
- INCLUDE_ICC_PROFILE);
- config->include_pointer =
- g_settings_get_boolean (config->settings,
- INCLUDE_POINTER_KEY);
- config->delay =
- g_settings_get_int (config->settings, DELAY_KEY);
-
- config->border_effect =
- g_settings_get_string (config->settings,
- BORDER_EFFECT_KEY);
- if (config->border_effect == NULL)
- config->border_effect = g_strdup ("none");
-}
-
gboolean
screenshot_load_config (gboolean clipboard_arg,
gboolean window_arg,
@@ -97,32 +69,57 @@ screenshot_load_config (gboolean clipboard_arg,
config->interactive = interactive_arg;
config->settings = g_settings_new ("org.gnome.gnome-screenshot");
- populate_from_settings (config);
-
- /* override the settings with cmdline parameters */
- if (window_arg)
- config->take_window_shot = TRUE;
-
- if (area_arg)
- config->take_area_shot = TRUE;
-
- if (include_border_arg)
- config->include_border = TRUE;
-
- if (disable_border_arg)
- config->include_border = FALSE;
-
- if (border_effect_arg != NULL)
+ if (config->interactive)
{
- g_free (config->border_effect);
- config->border_effect = g_strdup (border_effect_arg);
+ config->save_dir =
+ g_settings_get_string (config->settings,
+ LAST_SAVE_DIRECTORY_KEY);
+ config->delay =
+ g_settings_get_int (config->settings, DELAY_KEY);
+ if (delay_arg > 0)
+ config->delay = delay_arg;
+
+ config->include_border =
+ g_settings_get_boolean (config->settings,
+ INCLUDE_BORDER_KEY);
+ if (include_border_arg)
+ config->include_border = TRUE;
+ if (disable_border_arg)
+ config->include_border = FALSE;
+
+ if (border_effect_arg != NULL)
+ config->border_effect =
+ g_settings_get_string (config->settings,
+ BORDER_EFFECT_KEY);
+ else
+ config->border_effect = g_strdup (border_effect_arg);
}
+ else
+ {
+ config->save_dir =
+ g_settings_get_string (config->settings,
+ AUTO_SAVE_DIRECTORY_KEY);
+ config->delay = delay_arg;
+ config->include_border = include_border_arg;
+ config->include_border = !disable_border_arg;
+ if (border_effect_arg != NULL)
+ config->border_effect = g_strdup (border_effect_arg);
+
+ config->copy_to_clipboard = clipboard_arg;
+ }
+
+ config->include_icc_profile =
+ g_settings_get_boolean (config->settings,
+ INCLUDE_ICC_PROFILE);
+ config->include_pointer =
+ g_settings_get_boolean (config->settings,
+ INCLUDE_POINTER_KEY);
- if (delay_arg > 0)
- config->delay = delay_arg;
+ if (config->border_effect == NULL)
+ config->border_effect = g_strdup ("none");
- if (clipboard_arg)
- config->copy_to_clipboard = TRUE;
+ config->take_window_shot = window_arg;
+ config->take_area_shot = area_arg;
screenshot_config = config;
diff --git a/src/screenshot-config.h b/src/screenshot-config.h
index 9eecae2..c5b1aa5 100644
--- a/src/screenshot-config.h
+++ b/src/screenshot-config.h
@@ -28,8 +28,7 @@ G_BEGIN_DECLS
typedef struct {
GSettings *settings;
- gchar *auto_save_dir;
- gchar *last_save_dir;
+ gchar *save_dir;
gboolean copy_to_clipboard;
diff --git a/src/screenshot-filename-builder.c b/src/screenshot-filename-builder.c
index b7400ac..9781301 100644
--- a/src/screenshot-filename-builder.c
+++ b/src/screenshot-filename-builder.c
@@ -265,11 +265,7 @@ screenshot_build_filename_async (GAsyncReadyCallback callback,
job = g_slice_new0 (AsyncExistenceJob);
- if (screenshot_config->interactive)
- job->base_uris[0] = sanitize_save_directory (screenshot_config->last_save_dir);
- else
- job->base_uris[0] = sanitize_save_directory (screenshot_config->auto_save_dir);
-
+ job->base_uris[0] = sanitize_save_directory (screenshot_config->save_dir);
job->base_uris[1] = get_default_screenshot_dir ();
job->iteration = 0;
job->type = TEST_SAVED_DIR;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]