[gnome-screenshot] Add config variable to specify default file extension
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screenshot] Add config variable to specify default file extension
- Date: Wed, 17 Jul 2013 15:29:17 +0000 (UTC)
commit 08825563424342829028fd2dbffc0ada42e9d593
Author: Stefan Assmann <sassmann kpanic de>
Date: Fri May 3 11:05:30 2013 +0200
Add config variable to specify default file extension
By default screenshots are saved as png. Add the setting
org.gnome.gnome-screenshot default-file-type
to allow specifying other formats as default as well.
https://bugzilla.gnome.org/show_bug.cgi?id=701179
src/org.gnome.gnome-screenshot.gschema.xml.in | 11 +++++++++++
src/screenshot-config.c | 4 ++++
src/screenshot-config.h | 1 +
src/screenshot-filename-builder.c | 11 ++++++-----
4 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/src/org.gnome.gnome-screenshot.gschema.xml.in b/src/org.gnome.gnome-screenshot.gschema.xml.in
index 7252020..ea8a09a 100644
--- a/src/org.gnome.gnome-screenshot.gschema.xml.in
+++ b/src/org.gnome.gnome-screenshot.gschema.xml.in
@@ -1,4 +1,10 @@
<schemalist gettext-domain="gnome-utils-2.0">
+ <enum id="org.gnome.gnome-screenshot.file-types">
+ <value nick="bmp" value="0"/>
+ <value nick="jpg" value="1"/>
+ <value nick="png" value="2"/>
+ <value nick="tiff" value="3"/>
+ </enum>
<schema id="org.gnome.gnome-screenshot" path="/org/gnome/gnome-screenshot/">
<key name="take-window-shot" type="b">
<default>false</default>
@@ -40,5 +46,10 @@
<_summary>Border Effect</_summary>
<_description>Effect to add to the outside of a border. Possible values are "shadow", "none", and
"border".</_description>
</key>
+ <key name="default-file-type" enum="org.gnome.gnome-screenshot.file-types">
+ <default>'png'</default>
+ <_summary>Default file type extension</_summary>
+ <_description>The default file type extension for screenshots.</_description>
+ </key>
</schema>
</schemalist>
diff --git a/src/screenshot-config.c b/src/screenshot-config.c
index 55d410e..caafa91 100644
--- a/src/screenshot-config.c
+++ b/src/screenshot-config.c
@@ -32,6 +32,7 @@
#define INCLUDE_ICC_PROFILE "include-icc-profile"
#define AUTO_SAVE_DIRECTORY_KEY "auto-save-directory"
#define LAST_SAVE_DIRECTORY_KEY "last-save-directory"
+#define DEFAULT_FILE_TYPE_KEY "default-file-type"
ScreenshotConfig *screenshot_config;
@@ -124,6 +125,9 @@ screenshot_load_config (gboolean clipboard_arg,
config->copy_to_clipboard = clipboard_arg;
if (file_arg != NULL)
config->file = g_file_new_for_commandline_arg (file_arg);
+ config->file_type =
+ g_settings_get_string (config->settings,
+ DEFAULT_FILE_TYPE_KEY);
}
config->include_icc_profile =
diff --git a/src/screenshot-config.h b/src/screenshot-config.h
index d229f8f..1a4ce9e 100644
--- a/src/screenshot-config.h
+++ b/src/screenshot-config.h
@@ -29,6 +29,7 @@ typedef struct {
GSettings *settings;
gchar *save_dir;
+ gchar *file_type;
GFile *file;
gboolean copy_to_clipboard;
diff --git a/src/screenshot-filename-builder.c b/src/screenshot-filename-builder.c
index 1cc3d50..b1d8e53 100644
--- a/src/screenshot-filename-builder.c
+++ b/src/screenshot-filename-builder.c
@@ -25,6 +25,7 @@
#include <string.h>
#include "screenshot-filename-builder.h"
+#include "screenshot-config.h"
typedef enum
{
@@ -116,11 +117,11 @@ sanitize_save_directory (const gchar *save_dir)
static char *
build_path (AsyncExistenceJob *job)
{
- const gchar *base_path;
- char *retval, *file_name;
- char *origin;
+ const gchar *base_path, *file_type;
+ char *retval, *file_name, *origin;
base_path = job->base_paths[job->type];
+ file_type = screenshot_config->file_type;
if (base_path == NULL ||
base_path[0] == '\0')
@@ -141,14 +142,14 @@ build_path (AsyncExistenceJob *job)
{
/* translators: this is the name of the file that gets made up
* with the screenshot if the entire screen is taken */
- file_name = g_strdup_printf (_("Screenshot from %s.png"), origin);
+ file_name = g_strdup_printf (_("Screenshot from %s.%s"), origin, file_type);
}
else
{
/* translators: this is the name of the file that gets
* made up with the screenshot if the entire screen is
* taken */
- file_name = g_strdup_printf (_("Screenshot from %s - %d.png"), origin, job->iteration);
+ file_name = g_strdup_printf (_("Screenshot from %s - %d.%s"), origin, job->iteration, file_type);
}
retval = g_build_filename (base_path, file_name, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]