From 609770b38d8f0126017221d74f7028746c1c8723 Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Thu, 22 Nov 2012 00:00:24 -0500 Subject: Port mate-screenshot to Gsettings (based on GNOME patch) --- mate-screenshot/Makefile.am | 46 ++++----- mate-screenshot/mate-screenshot.c | 112 +++++++++------------ mate-screenshot/mate-screenshot.schemas.in | 81 --------------- mate-screenshot/org.mate.screenshot.gschema.xml.in | 29 ++++++ 4 files changed, 100 insertions(+), 168 deletions(-) delete mode 100644 mate-screenshot/mate-screenshot.schemas.in create mode 100644 mate-screenshot/org.mate.screenshot.gschema.xml.in diff --git a/mate-screenshot/Makefile.am b/mate-screenshot/Makefile.am index d83f5869..66de5dd0 100644 --- a/mate-screenshot/Makefile.am +++ b/mate-screenshot/Makefile.am @@ -5,9 +5,6 @@ INCLUDES = \ -I$(srcdir) \ -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DUIDIR=\""$(uidir)"\" \ - $(MATE_UTILS_CFLAGS) \ - $(LIBCANBERRA_GTK_CFLAGS) \ - $(GTHREAD_CFLAGS) \ $(NULL) bin_PROGRAMS = \ @@ -28,13 +25,23 @@ mate_screenshot_SOURCES = \ screenshot-xfer.h \ $(NULL) +mate_screenshot_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(GIO_CFLAGS) \ + $(LIBCANBERRA_GTK_CFLAGS) \ + $(GTHREAD_CFLAGS) \ + $(GTK_CFLAGS) \ + $(NULL) + mate_screenshot_LDFLAGS = -export-dynamic mate_screenshot_LDADD = \ $(XSHAPE_LIBS) \ - $(MATE_UTILS_LIBS) \ + $(GLIB_LIBS) \ + $(GIO_LIBS) \ $(LIBCANBERRA_GTK_LIBS) \ $(GTHREAD_LIBS) \ + $(GTK_LIBS) \ -lm \ $(NULL) @@ -50,35 +57,24 @@ ui_DATA = \ mate-screenshot.ui \ $(NULL) +gsettingsschema_in_files = org.mate.screenshot.gschema.xml.in +gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml) +.PRECIOUS: $(gsettings_SCHEMAS) + +@INTLTOOL_XML_NOMERGE_RULE@ + +@GSETTINGS_RULES@ + EXTRA_DIST = \ - $(schemas_in_files) \ + $(gsettingsschema_in_files) \ $(mate_screenshot_in_files) \ $(man_MANS) \ $(ui_DATA) \ $(NULL) -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = \ - mate-screenshot.schemas.in \ - $(NULL) -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) - -@INTLTOOL_SCHEMAS_RULE@ - -if MATECONF_SCHEMAS_INSTALL -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schemas_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/mate-screenshot/$$p ; \ - done ; \ - fi -else -install-data-local: -endif - CLEANFILES = \ $(BUILT_SOURCES) \ - $(schemas_in_files:.schemas.in=.schemas) \ + $(gsettings_SCHEMAS) \ $(mate_screenshot_DATA) \ $(sys_DATA) diff --git a/mate-screenshot/mate-screenshot.c b/mate-screenshot/mate-screenshot.c index c3c40e07..f3db5794 100644 --- a/mate-screenshot/mate-screenshot.c +++ b/mate-screenshot/mate-screenshot.c @@ -25,7 +25,6 @@ /* MAYBE I LIED... -jrb */ #include -#include #include #include #include @@ -50,13 +49,13 @@ #define SCREENSHOOTER_ICON "applets-screenshooter" -#define MATE_SCREENSHOT_MATECONF "/apps/mate-screenshot" -#define INCLUDE_BORDER_KEY MATE_SCREENSHOT_MATECONF "/include_border" -#define INCLUDE_POINTER_KEY MATE_SCREENSHOT_MATECONF "/include_pointer" -#define LAST_SAVE_DIRECTORY_KEY MATE_SCREENSHOT_MATECONF "/last_save_directory" -#define BORDER_EFFECT_KEY MATE_SCREENSHOT_MATECONF "/border_effect" -#define DELAY_KEY MATE_SCREENSHOT_MATECONF "/delay" - +#define MATE_SCREENSHOT_SCHEMA "org.mate.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" +#define CAJA_PREFERENCES_SCHEMA "org.mate.caja.preferences" enum { @@ -97,6 +96,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; @@ -548,21 +548,15 @@ create_interactive_dialog (void) } static void -save_folder_to_mateconf (ScreenshotDialog *dialog) +save_folder_to_settings (ScreenshotDialog *dialog) { - MateConfClient *mateconf_client; char *folder; - mateconf_client = mateconf_client_get_default (); - folder = screenshot_dialog_get_folder (dialog); - /* Error is NULL, as there's nothing we can do */ - mateconf_client_set_string (mateconf_client, - LAST_SAVE_DIRECTORY_KEY, folder, - NULL); + g_settings_set_string (settings, + LAST_SAVE_DIRECTORY_KEY, folder); g_free (folder); - g_object_unref (mateconf_client); } static void @@ -626,7 +620,7 @@ save_callback (TransferResult result, if (result == TRANSFER_OK) { - save_folder_to_mateconf (dialog); + save_folder_to_settings (dialog); set_recent_entry (dialog); gtk_widget_destroy (toplevel); @@ -1124,21 +1118,35 @@ prepare_screenshot_timeout (gpointer data) static gchar * get_desktop_dir (void) { - MateConfClient *mateconf_client; gboolean desktop_is_home_dir = FALSE; gchar *desktop_dir; + const char * const *schemas; + gboolean schema_exists = FALSE; + gint i; + + /* Check if caja schema is installed before trying to read settings */ + schemas = g_settings_list_schemas (); + for (i = 0; schemas[i] != NULL; i++) { + if (g_strcmp0 (schemas[i], CAJA_PREFERENCES_SCHEMA) == 0) { + schema_exists = TRUE; + break; + } + } + + if (schema_exists) { + GSettings *caja_prefs; + + caja_prefs = g_settings_new (CAJA_PREFERENCES_SCHEMA); + desktop_is_home_dir = g_settings_get_boolean (caja_prefs, "desktop-is-home-dir"); + + g_object_unref (caja_prefs); + } - mateconf_client = mateconf_client_get_default (); - desktop_is_home_dir = mateconf_client_get_bool (mateconf_client, - "/apps/caja/preferences/desktop_is_home_dir", - NULL); 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 (mateconf_client); - return desktop_dir; } @@ -1176,14 +1184,9 @@ expand_initial_tilde (const char *path) static void load_options (void) { - MateConfClient *mateconf_client; - - mateconf_client = mateconf_client_get_default (); - /* Find various dirs */ - last_save_dir = mateconf_client_get_string (mateconf_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 (); @@ -1195,46 +1198,30 @@ load_options (void) last_save_dir = tmp; } - include_border = mateconf_client_get_bool (mateconf_client, - INCLUDE_BORDER_KEY, - NULL); + include_border = g_settings_get_boolean (settings, + INCLUDE_BORDER_KEY); - include_pointer = mateconf_client_get_bool (mateconf_client, - INCLUDE_POINTER_KEY, - NULL); + include_pointer = g_settings_get_boolean (settings, + INCLUDE_POINTER_KEY); - border_effect = mateconf_client_get_string (mateconf_client, - BORDER_EFFECT_KEY, - NULL); + border_effect = g_settings_get_string (settings, + BORDER_EFFECT_KEY); if (!border_effect) border_effect = g_strdup ("none"); - delay = mateconf_client_get_int (mateconf_client, DELAY_KEY, NULL); - - g_object_unref (mateconf_client); + delay = g_settings_get_int (settings, DELAY_KEY); } static void save_options (void) { - MateConfClient *mateconf_client; - - mateconf_client = mateconf_client_get_default (); - - /* Error is NULL, as there's nothing we can do */ - - mateconf_client_set_bool (mateconf_client, - INCLUDE_BORDER_KEY, include_border, - NULL); - mateconf_client_set_bool (mateconf_client, - INCLUDE_POINTER_KEY, include_pointer, - NULL); - mateconf_client_set_int (mateconf_client, DELAY_KEY, delay, NULL); - mateconf_client_set_string (mateconf_client, - BORDER_EFFECT_KEY, border_effect, - NULL); - - g_object_unref (mateconf_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); } @@ -1325,6 +1312,7 @@ main (int argc, char *argv[]) gtk_window_set_default_icon_name (SCREENSHOOTER_ICON); screenshooter_init_stock_icons (); + settings = g_settings_new (MATE_SCREENSHOT_SCHEMA); load_options (); /* allow the command line to override options */ if (window_arg) diff --git a/mate-screenshot/mate-screenshot.schemas.in b/mate-screenshot/mate-screenshot.schemas.in deleted file mode 100644 index a8c2dca4..00000000 --- a/mate-screenshot/mate-screenshot.schemas.in +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - /schemas/apps/mate-screenshot/take_window_shot - /apps/mate-screenshot/take_window_shot - mate-screenshot - bool - false - - Window-specific screenshot (deprecated) - Grab just the current window, rather than the whole desktop. - This key has been deprecated and it is no longer in use. - - - - - /schemas/apps/mate-screenshot/delay - /apps/mate-screenshot/delay - mate-screenshot - int - 0 - - Screenshot delay - The number of seconds to wait before taking the screenshot. - - - - - /schemas/apps/mate-screenshot/last_save_directory - /apps/mate-screenshot/last_save_directory - mate-screenshot - string - - - Screenshot directory - The directory the last screenshot was saved in. - - - - - /schemas/apps/mate-screenshot/include_border - /apps/mate-screenshot/include_border - mate-screenshot - bool - true - - Include Border - Include the window manager border along with the screenshot - - - - - /schemas/apps/mate-screenshot/include_pointer - /apps/mate-screenshot/include_pointer - mate-screenshot - bool - true - - Include Pointer - Include the pointer in the screenshot - - - - - /schemas/apps/mate-screenshot/border_effect - /apps/mate-screenshot/border_effect - mate-screenshot - string - none - - Border Effect - Effect to add to the outside of a border. Possible values are "shadow", "none", and "border". - - - - - - diff --git a/mate-screenshot/org.mate.screenshot.gschema.xml.in b/mate-screenshot/org.mate.screenshot.gschema.xml.in new file mode 100644 index 00000000..fddddbb3 --- /dev/null +++ b/mate-screenshot/org.mate.screenshot.gschema.xml.in @@ -0,0 +1,29 @@ + + + + 0 + <_summary>Screenshot delay + <_description>The number of seconds to wait before taking the screenshot. + + + '' + <_summary>Screenshot directory + <_description>The directory the last screenshot was saved in. + + + true + <_summary>Include Border + <_description>Include the window manager border along with the screenshot + + + true + <_summary>Include Pointer + <_description>Include the pointer in the screenshot + + + 'none' + <_summary>Border Effect + <_description>Effect to add to the outside of a border. Possible values are "shadow", "none", and "border". + + + -- cgit v1.2.1