Skip to content

Commit

Permalink
Set-as-wallpaper: Add support for Cinnamon and MATE
Browse files Browse the repository at this point in the history
I couldn't find an easy way to do it for Xfce (the xfconf-query propery depends on the display name.. it's a bit tedious).
  • Loading branch information
clefebvre committed Feb 4, 2016
1 parent 401a6eb commit 1686fd7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
1 change: 0 additions & 1 deletion doc/reference/xviewer-sections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ xviewer_pixbuf_get_common_suffix

<SECTION>
<FILE>xviewer-config-keys</FILE>
XVIEWER_CONF_DESKTOP_WALLPAPER
XVIEWER_CONF_DESKTOP_CAN_SAVE
XVIEWER_CONF_DESKTOP_CAN_PRINT
XVIEWER_CONF_DESKTOP_CAN_SETUP_PAGE
Expand Down
3 changes: 0 additions & 3 deletions src/xviewer-config-keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
#define XVIEWER_CONF_UI XVIEWER_CONF_DOMAIN".ui"
#define XVIEWER_CONF_VIEW XVIEWER_CONF_DOMAIN".view"

#define XVIEWER_CONF_DESKTOP_WALLPAPER_SCHEMA "org.gnome.desktop.background"
#define XVIEWER_CONF_DESKTOP_WALLPAPER "picture-uri"

#define XVIEWER_CONF_DESKTOP_LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown"
#define XVIEWER_CONF_DESKTOP_CAN_PRINT "disable-printing"
#define XVIEWER_CONF_DESKTOP_CAN_SAVE "disable-save-to-disk"
Expand Down
39 changes: 24 additions & 15 deletions src/xviewer-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2711,21 +2711,16 @@ wallpaper_info_bar_response (GtkInfoBar *bar, gint response, XviewerWindow *wind
{
if (response == GTK_RESPONSE_YES) {
GAppInfo *app_info;
gchar *path;
GError *error = NULL;

path = g_find_program_in_path ("unity-control-center");
if (path && g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)
app_info = g_app_info_create_from_commandline ("unity-control-center appearance",
"System Settings",
G_APP_INFO_CREATE_NONE,
&error);
if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Cinnamon") == 0 || g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "X-Cinnamon") == 0)
app_info = g_app_info_create_from_commandline ("cinnamon-settings backgrounds", "System Settings", G_APP_INFO_CREATE_NONE, &error);
else if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "MATE") == 0)
app_info = g_app_info_create_from_commandline ("mate-appearance-properties --show-page=background", "System Settings", G_APP_INFO_CREATE_NONE, &error);
else if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)
app_info = g_app_info_create_from_commandline ("unity-control-center appearance", "System Settings", G_APP_INFO_CREATE_NONE, &error);
else
app_info = g_app_info_create_from_commandline ("gnome-control-center background",
"System Settings",
G_APP_INFO_CREATE_NONE,
&error);
g_free (path);
app_info = g_app_info_create_from_commandline ("gnome-control-center background", "System Settings", G_APP_INFO_CREATE_NONE, &error);

if (error != NULL) {
g_warning ("%s%s", _("Error launching System Settings: "),
Expand Down Expand Up @@ -2772,9 +2767,23 @@ xviewer_window_set_wallpaper (XviewerWindow *window, const gchar *filename, cons
gchar *uri;

uri = g_filename_to_uri (filename, NULL, NULL);
settings = g_settings_new (XVIEWER_CONF_DESKTOP_WALLPAPER_SCHEMA);
g_settings_set_string (settings, XVIEWER_CONF_DESKTOP_WALLPAPER, uri);
g_object_unref (settings);

if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Cinnamon") == 0 || g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "X-Cinnamon") == 0) {
settings = g_settings_new ("org.cinnamon.desktop.background");
g_settings_set_string (settings, "picture-uri", uri);
g_object_unref (settings);
}
else if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "MATE") == 0) {
settings = g_settings_new ("org.mate.background");
g_settings_set_string (settings, "picture-filename", uri);
g_object_unref (settings);
}
else {
settings = g_settings_new ("org.gnome.desktop.background");
g_settings_set_string (settings, "picture-uri", uri);
g_object_unref (settings);
}

g_free (uri);

/* I18N: When setting mnemonics for these strings, watch out to not
Expand Down

0 comments on commit 1686fd7

Please sign in to comment.