[gnome-utils] screenshot: port to GSettings
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-utils] screenshot: port to GSettings
- Date: Mon, 10 Jan 2011 15:48:59 +0000 (UTC)
commit c615ae90d64eb3c75f782f3b1d2855acf102f1fc
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Jan 10 16:48:06 2011 +0100
screenshot: port to GSettings
gnome-screenshot/Makefile.am | 36 +++-----
gnome-screenshot/gnome-screenshot.c | 94 +++++++-------------
gnome-screenshot/gnome-screenshot.convert | 7 ++
gnome-screenshot/gnome-screenshot.schemas.in | 81 -----------------
.../org.gnome.gnome-screenshot.gschema.xml.in | 34 +++++++
po/POTFILES.in | 17 ++++-
6 files changed, 103 insertions(+), 166 deletions(-)
---
diff --git a/gnome-screenshot/Makefile.am b/gnome-screenshot/Makefile.am
index 5272abb..aa26b61 100644
--- a/gnome-screenshot/Makefile.am
+++ b/gnome-screenshot/Makefile.am
@@ -31,7 +31,6 @@ gnome_screenshot_CFLAGS = \
$(LIBCANBERRA_GTK_CFLAGS) \
$(GTHREAD_CFLAGS) \
$(GTK_CFLAGS) \
- $(GCONF_CFLAGS) \
$(NULL)
gnome_screenshot_LDFLAGS = -export-dynamic
@@ -43,7 +42,6 @@ gnome_screenshot_LDADD = \
$(LIBCANBERRA_GTK_LIBS) \
$(GTHREAD_LIBS) \
$(GTK_LIBS) \
- $(GCONF_LIBS) \
-lm \
$(NULL)
@@ -59,35 +57,27 @@ ui_DATA = \
gnome-screenshot.ui \
$(NULL)
+gsettingsschema_in_files = org.gnome.gnome-screenshot.gschema.xml.in
+gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
+.PRECIOUS: $(gsettings_SCHEMAS)
+
+convertdir = $(datadir)/GConf/gsettings
+convert_DATA = gnome-screenshot.convert
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+ GSETTINGS_RULES@
+
EXTRA_DIST = \
- $(schemas_in_files) \
+ $(gsettingsschema_in_files) \
$(gnome_screenshot_in_files) \
$(man_MANS) \
$(ui_DATA) \
$(NULL)
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = \
- gnome-screenshot.schemas.in \
- $(NULL)
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
-
- INTLTOOL_SCHEMAS_RULE@
-
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- if test -z "$(DESTDIR)" ; then \
- for p in $(schemas_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/gnome-screenshot/$$p ; \
- done ; \
- fi
-else
-install-data-local:
-endif
-
CLEANFILES = \
$(BUILT_SOURCES) \
- $(schemas_in_files:.schemas.in=.schemas) \
+ $(gsettings_SCHEMAS) \
$(gnome_screenshot_DATA) \
$(sys_DATA)
diff --git a/gnome-screenshot/gnome-screenshot.c b/gnome-screenshot/gnome-screenshot.c
index bc7429f..f7a6d5f 100644
--- a/gnome-screenshot/gnome-screenshot.c
+++ b/gnome-screenshot/gnome-screenshot.c
@@ -25,7 +25,6 @@
/* MAYBE I LIED... -jrb */
#include <config.h>
-#include <gconf/gconf-client.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include <sys/types.h>
@@ -50,13 +49,12 @@
#define SCREENSHOOTER_ICON "applets-screenshooter"
-#define GNOME_SCREENSHOT_GCONF "/apps/gnome-screenshot"
-#define INCLUDE_BORDER_KEY GNOME_SCREENSHOT_GCONF "/include_border"
-#define INCLUDE_POINTER_KEY GNOME_SCREENSHOT_GCONF "/include_pointer"
-#define LAST_SAVE_DIRECTORY_KEY GNOME_SCREENSHOT_GCONF "/last_save_directory"
-#define BORDER_EFFECT_KEY GNOME_SCREENSHOT_GCONF "/border_effect"
-#define DELAY_KEY GNOME_SCREENSHOT_GCONF "/delay"
-
+#define GNOME_SCREENSHOT_SCHEMA "org.gnome.gnome-screenshot"
+#define INCLUDE_BORDER_KEY "include-border"
+#define INCLUDE_POINTER_KEY "include-pointer"
+#define LAST_SAVE_DIRECTORY_KEY "last-save-directory"
+#define BORDER_EFFECT_KEY "border-effect"
+#define DELAY_KEY "delay"
enum
{
@@ -97,6 +95,7 @@ static char *last_save_dir = NULL;
static char *window_title = NULL;
static char *temporary_file = NULL;
static gboolean save_immediately = FALSE;
+static GSettings *settings = NULL;
/* Options */
static gboolean take_window_shot = FALSE;
@@ -547,21 +546,15 @@ create_interactive_dialog (void)
}
static void
-save_folder_to_gconf (ScreenshotDialog *dialog)
+save_folder_to_settings (ScreenshotDialog *dialog)
{
- GConfClient *gconf_client;
char *folder;
- gconf_client = gconf_client_get_default ();
-
folder = screenshot_dialog_get_folder (dialog);
- /* Error is NULL, as there's nothing we can do */
- gconf_client_set_string (gconf_client,
- LAST_SAVE_DIRECTORY_KEY, folder,
- NULL);
+ g_settings_set_string (settings,
+ LAST_SAVE_DIRECTORY_KEY, folder);
g_free (folder);
- g_object_unref (gconf_client);
}
static void
@@ -625,7 +618,7 @@ save_callback (TransferResult result,
if (result == TRANSFER_OK)
{
- save_folder_to_gconf (dialog);
+ save_folder_to_settings (dialog);
set_recent_entry (dialog);
gtk_widget_destroy (toplevel);
@@ -1123,20 +1116,19 @@ prepare_screenshot_timeout (gpointer data)
static gchar *
get_desktop_dir (void)
{
- GConfClient *gconf_client;
+ GSettings *nautilus_prefs;
gboolean desktop_is_home_dir = FALSE;
gchar *desktop_dir;
- gconf_client = gconf_client_get_default ();
- desktop_is_home_dir = gconf_client_get_bool (gconf_client,
- "/apps/nautilus/preferences/desktop_is_home_dir",
- NULL);
+ nautilus_prefs = g_settings_new ("org.gnome.nautilus.preferences");
+ desktop_is_home_dir = g_settings_get_boolean (nautilus_prefs, "desktop-is-home-dir");
+
if (desktop_is_home_dir)
desktop_dir = g_strconcat ("file://", g_get_home_dir (), NULL);
else
desktop_dir = g_strconcat ("file://", g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP), NULL);
- g_object_unref (gconf_client);
+ g_object_unref (nautilus_prefs);
return desktop_dir;
}
@@ -1175,14 +1167,9 @@ expand_initial_tilde (const char *path)
static void
load_options (void)
{
- GConfClient *gconf_client;
-
- gconf_client = gconf_client_get_default ();
-
/* Find various dirs */
- last_save_dir = gconf_client_get_string (gconf_client,
- LAST_SAVE_DIRECTORY_KEY,
- NULL);
+ last_save_dir = g_settings_get_string (settings,
+ LAST_SAVE_DIRECTORY_KEY);
if (!last_save_dir || !last_save_dir[0])
{
last_save_dir = get_desktop_dir ();
@@ -1194,46 +1181,30 @@ load_options (void)
last_save_dir = tmp;
}
- include_border = gconf_client_get_bool (gconf_client,
- INCLUDE_BORDER_KEY,
- NULL);
+ include_border = g_settings_get_boolean (settings,
+ INCLUDE_BORDER_KEY);
- include_pointer = gconf_client_get_bool (gconf_client,
- INCLUDE_POINTER_KEY,
- NULL);
+ include_pointer = g_settings_get_boolean (settings,
+ INCLUDE_POINTER_KEY);
- border_effect = gconf_client_get_string (gconf_client,
- BORDER_EFFECT_KEY,
- NULL);
+ border_effect = g_settings_get_string (settings,
+ BORDER_EFFECT_KEY);
if (!border_effect)
border_effect = g_strdup ("none");
- delay = gconf_client_get_int (gconf_client, DELAY_KEY, NULL);
-
- g_object_unref (gconf_client);
+ delay = g_settings_get_int (settings, DELAY_KEY);
}
static void
save_options (void)
{
- GConfClient *gconf_client;
-
- gconf_client = gconf_client_get_default ();
-
- /* Error is NULL, as there's nothing we can do */
-
- gconf_client_set_bool (gconf_client,
- INCLUDE_BORDER_KEY, include_border,
- NULL);
- gconf_client_set_bool (gconf_client,
- INCLUDE_POINTER_KEY, include_pointer,
- NULL);
- gconf_client_set_int (gconf_client, DELAY_KEY, delay, NULL);
- gconf_client_set_string (gconf_client,
- BORDER_EFFECT_KEY, border_effect,
- NULL);
-
- g_object_unref (gconf_client);
+ g_settings_set_boolean (settings,
+ INCLUDE_BORDER_KEY, include_border);
+ g_settings_set_boolean (settings,
+ INCLUDE_POINTER_KEY, include_pointer);
+ g_settings_set_int (settings, DELAY_KEY, delay);
+ g_settings_set_string (settings,
+ BORDER_EFFECT_KEY, border_effect);
}
@@ -1324,6 +1295,7 @@ main (int argc, char *argv[])
gtk_window_set_default_icon_name (SCREENSHOOTER_ICON);
screenshooter_init_stock_icons ();
+ settings = g_settings_new ("org.gnome.gnome-screenshot");
load_options ();
/* allow the command line to override options */
if (window_arg)
diff --git a/gnome-screenshot/gnome-screenshot.convert b/gnome-screenshot/gnome-screenshot.convert
new file mode 100644
index 0000000..b230664
--- /dev/null
+++ b/gnome-screenshot/gnome-screenshot.convert
@@ -0,0 +1,7 @@
+[org.gnome.gnome-screenshot]
+take-window-shot = /apps/gnome-screenshot/take_window_shot
+delay = /apps/gnome-screenshot/delay
+last-save-directory = /apps/gnome-screenshot/last_save_directory
+include-border = /apps/gnome-screenshot/include_border
+include-pointer = /apps/gnome-screenshot/include_pointer
+border-effect = /apps/gnome-screenshot/border_effect
\ No newline at end of file
diff --git a/gnome-screenshot/org.gnome.gnome-screenshot.gschema.xml.in b/gnome-screenshot/org.gnome.gnome-screenshot.gschema.xml.in
new file mode 100644
index 0000000..90311b1
--- /dev/null
+++ b/gnome-screenshot/org.gnome.gnome-screenshot.gschema.xml.in
@@ -0,0 +1,34 @@
+<schemalist gettext-domain="gnome-utils-2.0">
+ <schema id="org.gnome.gnome-screenshot" path="/apps/gnome-screenshot/">
+ <key name="take-window-shot" type="b">
+ <default>false</default>
+ <_summary>Window-specific screenshot (deprecated)</_summary>
+ <_description>Grab just the current window, rather than the whole desktop. This key has been deprecated and it is no longer in use.</_description>
+ </key>
+ <key name="delay" type="i">
+ <default>0</default>
+ <_summary>Screenshot delay</_summary>
+ <_description>The number of seconds to wait before taking the screenshot.</_description>
+ </key>
+ <key name="last-save-directory" type="s">
+ <default>''</default>
+ <_summary>Screenshot directory</_summary>
+ <_description>The directory the last screenshot was saved in.</_description>
+ </key>
+ <key name="include-border" type="b">
+ <default>true</default>
+ <_summary>Include Border</_summary>
+ <_description>Include the window manager border along with the screenshot</_description>
+ </key>
+ <key name="include-pointer" type="b">
+ <default>true</default>
+ <_summary>Include Pointer</_summary>
+ <_description>Include the pointer in the screenshot</_description>
+ </key>
+ <key name="border-effect" type="s">
+ <default>'none'</default>
+ <_summary>Border Effect</_summary>
+ <_description>Effect to add to the outside of a border. Possible values are "shadow", "none", and "border".</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9cb3eb9..a90d80a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -13,6 +13,9 @@ baobab/src/baobab-treeview.c
baobab/src/baobab-utils.c
baobab/src/baobab-ringschart.c
baobab/src/callbacks.c
+#
+# gnome-dictionary
+#
gnome-dictionary/data/default.desktop.in
gnome-dictionary/data/GNOME_DictionaryApplet.server.in.in
gnome-dictionary/data/GNOME_DictionaryApplet.xml
@@ -43,15 +46,21 @@ gnome-dictionary/src/gdict-sidebar.c
gnome-dictionary/src/gdict-source-dialog.c
gnome-dictionary/src/gdict-window.c
gnome-dictionary/src/main.c
+#
+# gnome-screenshot
+#
gnome-screenshot/gnome-screenshot.c
gnome-screenshot/gnome-screenshot.desktop.in
[type: gettext/glade]gnome-screenshot/gnome-screenshot.ui
-gnome-screenshot/gnome-screenshot.schemas.in
+gnome-screenshot/org.gnome.gnome-screenshot.gschema.xml.in
gnome-screenshot/screenshot-dialog.c
gnome-screenshot/screenshot-save.c
gnome-screenshot/screenshot-shadow.c
gnome-screenshot/screenshot-utils.c
gnome-screenshot/screenshot-xfer.c
+#
+# gsearchtool
+#
gsearchtool/gnome-search-tool.desktop.in
gsearchtool/gnome-search-tool.schemas.in
gsearchtool/gsearchtool-callbacks.c
@@ -59,6 +68,9 @@ gsearchtool/gsearchtool-support.c
gsearchtool/gsearchtool.c
libeggsmclient/eggdesktopfile.c
libeggsmclient/eggsmclient.c
+#
+# logview
+#
logview/data/gnome-system-log.desktop.in.in
logview/data/org.gnome.gnome-system-log.gschema.xml.in
[type: gettext/glade]logview/data/logview-filter.ui
@@ -70,6 +82,9 @@ logview/logview-log.c
logview/logview-loglist.c
logview/logview-main.c
logview/logview-window.c
+#
+# font-viewer
+#
font-viewer/font-thumbnailer.c
font-viewer/font-view.c
font-viewer/gnome-font-viewer.desktop.in.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]