From 57b9b062b9b335094b96a308d46303873760270b Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Thu, 1 Nov 2018 19:23:38 +0100 Subject: [PATCH] Avoid to hard code path --- src/gs-theme-manager.c | 3 +-- src/xfce-bg.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/gs-theme-manager.c b/src/gs-theme-manager.c index c3d0c69..6249027 100644 --- a/src/gs-theme-manager.c +++ b/src/gs-theme-manager.c @@ -65,8 +65,7 @@ static const char *known_engine_locations [] = XSCREENSAVER_HACK_DIR, #endif LIBEXECDIR "/xscreensaver", - "/usr/libexec/xscreensaver", - "/usr/lib/xscreensaver", + LIBDIR "/xscreensaver", NULL }; diff --git a/src/xfce-bg.c b/src/xfce-bg.c index 8077f44..82d3edf 100644 --- a/src/xfce-bg.c +++ b/src/xfce-bg.c @@ -34,7 +34,11 @@ Authors: Soren Sandmann #include #include #include +#include +#include +#include +#include #include #include @@ -50,7 +54,7 @@ Authors: Soren Sandmann #include #define XFCE_BG_CACHE_DIR "xfce/background" -#define XFCE_BG_FALLBACK_IMG "/usr/share/backgrounds/xfce/xfce-teal.jpg" +#define XFCE_BG_FALLBACK_IMG "xfce-teal.jpg" /* We keep the large pixbufs around if the next update in the slideshow is less than 60 seconds away */ @@ -301,6 +305,26 @@ queue_transitioned (XfceBG *bg) NULL); } +static gchar * +find_system_backgrounds (void) +{ + const gchar * const *dirs; + gchar *path; + gint i; + + dirs = g_get_system_data_dirs (); + for (i = 0; dirs[i]; i++) { + path = g_build_path (G_DIR_SEPARATOR_S, dirs[i], + "backgrounds", "xfce"); + if (g_file_test (path, G_FILE_TEST_IS_DIR)) + return path; + else + g_free (path); + } + + return NULL; +} + /* This function loads the user's preferences */ void xfce_bg_load_from_preferences (XfceBG *bg, @@ -446,7 +470,9 @@ xfce_bg_load_from_xfconf (XfceBG *bg, property = g_strconcat(prop_prefix, "/image-path", NULL); } filename = NULL; - tmp = xfconf_channel_get_string(channel, property, XFCE_BG_FALLBACK_IMG); + tmp = xfconf_channel_get_string(channel, property, + g_build_filename(find_system_backgrounds(), + XFCE_BG_FALLBACK_IMG)); if (tmp && *tmp != '\0') { /* FIXME: UTF-8 checks should go away. * picture-filename is of type string, which can only be used for -- 2.14.5