Cameron Norman has proposed merging lp:~elementary-dev-community/switchboard-plug-pantheon-shell/fix-1182413 into lp:switchboard-plug-pantheon-shell.
Requested reviews: elementary Apps team (elementary-apps) Related bugs: Bug #1182413 in Desktop Plug: "Search backgrounds folder recursively" https://bugs.launchpad.net/switchboard-plug-pantheon-shell/+bug/1182413 For more details, see: https://code.launchpad.net/~elementary-dev-community/switchboard-plug-pantheon-shell/fix-1182413/+merge/227667 Based on Richard Stromer's branch, just rebased on current trunk. One notable change is that it gets rid of the WALLPAPER_DIR variable completely. The directory to load is just given to the load_wallpapers function directly. Otherwise, it is the same as Stromer's work. -- https://code.launchpad.net/~elementary-dev-community/switchboard-plug-pantheon-shell/fix-1182413/+merge/227667 Your team elementary Developer Community is subscribed to branch lp:~elementary-dev-community/switchboard-plug-pantheon-shell/fix-1182413.
=== modified file 'src/Wallpaper.vala' --- src/Wallpaper.vala 2013-11-24 00:08:31 +0000 +++ src/Wallpaper.vala 2014-07-22 05:45:12 +0000 @@ -61,8 +61,7 @@ NAME } -class Wallpaper : EventBox { - string WALLPAPER_DIR = "/usr/share/backgrounds"; +class Wallpaper : EventBox { GLib.Settings settings; @@ -216,17 +215,16 @@ void update_wallpaper_folder () { if (folder_combo.get_active () == 0) { clean_wallpapers (); - var picture_file = GLib.File.new_for_path (GLib.Environment.get_user_special_dir (GLib.UserDirectory.PICTURES)); - WALLPAPER_DIR = picture_file.get_uri (); - load_wallpapers.begin (); + var picture_dir = GLib.File.new_for_path (GLib.Environment.get_user_special_dir (GLib.UserDirectory.PICTURES)); + load_wallpapers (picture_dir.get_uri ()); } else if (folder_combo.get_active () == 1) { clean_wallpapers (); - WALLPAPER_DIR = "file:///usr/share/backgrounds"; - load_wallpapers.begin (() => { - var backgrounds_file = GLib.File.new_for_path (GLib.Environment.get_user_data_dir () + "/backgrounds"); - WALLPAPER_DIR = backgrounds_file.get_uri (); - load_wallpapers.begin (); - }); + + var system_uri = "file:///usr/share/backgrounds"; + var user_uri = GLib.File.new_for_path (GLib.Environment.get_user_data_dir () + "/backgrounds").get_uri (); + + load_wallpapers (system_uri); + load_wallpapers (user_uri); } else if (folder_combo.get_active () == 2) { var dialog = new Gtk.FileChooserDialog (_("Select a folder"), null, FileChooserAction.SELECT_FOLDER); dialog.add_button (_("Cancel"), ResponseType.CANCEL); @@ -235,8 +233,7 @@ if (dialog.run () == ResponseType.ACCEPT) { clean_wallpapers (); - WALLPAPER_DIR = dialog.get_file ().get_uri (); - load_wallpapers.begin (); + load_wallpapers (dialog.get_file ().get_uri ()); dialog.destroy (); } else { dialog.destroy (); @@ -244,10 +241,11 @@ } } - async void load_wallpapers () { + async void load_wallpapers (string basefolder) { folder_combo.set_sensitive (false); - var directory = File.new_for_uri (WALLPAPER_DIR); + var directory = File.new_for_uri (basefolder); + // The number of wallpapers we've added so far double done = 0.0; @@ -272,12 +270,18 @@ foreach (var info in files) { // We're going to add another wallpaper done++; - // Skip the file if it's not a picture - if (!IOHelper.is_valid_file_type(info)) { + + if (info.get_file_type () == FileType.DIRECTORY) { + // Spawn off another loader for the subdirectory + load_wallpapers (basefolder + "/" + info.get_name ()); + } else if (!IOHelper.is_valid_file_type (info)) { + // Skip non-picture files continue; } - var file = File.new_for_uri (WALLPAPER_DIR + "/" + info.get_name ()); + + var file = File.new_for_uri (basefolder + "/" + info.get_name ()); string filename = file.get_path (); + // Skip the default_wallpaper as seen in the description of the // default_link variable if (filename == default_link) {
-- Mailing list: https://launchpad.net/~elementary-dev-community Post to : elementary-dev-community@lists.launchpad.net Unsubscribe : https://launchpad.net/~elementary-dev-community More help : https://help.launchpad.net/ListHelp