From 5a829a549a7c95c39402149caaa8d7353136a58d Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Wed, 25 Mar 2015 15:59:21 +0000 Subject: [PATCH] Don't hard code URI path in 'gtk_file_chooser_add_shortcut_folder_uri' function --- settings/main.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/settings/main.c b/settings/main.c index 7d6f0b4..06349f9 100644 --- a/settings/main.c +++ b/settings/main.c @@ -44,6 +44,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -172,6 +176,26 @@ static gchar *xfdesktop_settings_get_backdrop_image(AppearancePanel *panel); +const gchar * +system_data_lookup (void) +{ + const gchar * const * dirs; + const gchar *path; + guint i; + + dirs = g_get_system_data_dirs (); + for (i = 0; path == NULL && dirs[i] != NULL; ++i) { + path = g_build_path (G_DIR_SEPARATOR_S, dirs[i], "backdrops", NULL); + if (g_path_is_absolute (path) && g_file_test (path, G_FILE_TEST_IS_DIR)) + return path; + + g_free (path); + path = NULL; + } + + return path; +} + static void xfdesktop_settings_free_pdata(gpointer data) { @@ -1702,6 +1726,9 @@ xfdesktop_settings_dialog_setup_tabs(GtkBuilder *main_gxml, WnckScreen *wnck_screen; XfconfChannel *channel = panel->channel; GdkColor color; + const gchar *path; + GFile *file; + gchar *uri_path; TRACE("entering"); @@ -1840,9 +1867,19 @@ xfdesktop_settings_dialog_setup_tabs(GtkBuilder *main_gxml, gtk_file_filter_add_pixbuf_formats(filter); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(panel->btn_folder), filter); - gtk_file_chooser_add_shortcut_folder_uri(GTK_FILE_CHOOSER(panel->btn_folder), - "file:///usr/share/backgrounds", - NULL); + /* Get default wallpaper folder */ + path = system_data_lookup (); + + if (path != NULL) { + file = g_file_new_for_path (path); + uri_path = g_file_get_uri (file); + + gtk_file_chooser_add_shortcut_folder_uri (GTK_FILE_CHOOSER(panel->btn_folder), + uri_path, NULL); + + g_free (uri_path); + g_object_unref (file); + } /* Image and color style options */ panel->image_style_combo = GTK_WIDGET(gtk_builder_get_object(appearance_gxml, "combo_style")); -- 2.3.4