[shotwell] import: Add option to not recurse into subfolders
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] import: Add option to not recurse into subfolders
- Date: Mon, 29 May 2017 20:23:39 +0000 (UTC)
commit 82cd4ca2cb1cd6f5e382d9073a3015f4d2287f12
Author: Jens Georg <mail jensge org>
Date: Mon May 29 22:07:42 2017 +0200
import: Add option to not recurse into subfolders
https://bugzilla.gnome.org/show_bug.cgi?id=716448
help/C/import-file.page | 2 +-
src/BatchImport.vala | 21 +++++++++++++++++----
src/LibraryMonitor.vala | 2 +-
src/library/LibraryWindow.vala | 14 ++++++++++----
src/main.vala | 2 +-
5 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/help/C/import-file.page b/help/C/import-file.page
index da25e4e..82919fb 100644
--- a/help/C/import-file.page
+++ b/help/C/import-file.page
@@ -13,7 +13,7 @@
<p>To import photo files from your hard disk into Shotwell, just drag them from your file browser into
the Shotwell window.</p>
- <p>Alternatively, click <guiseq><gui>File</gui><gui>Import From Folder...</gui></guiseq> and select the
folder containing the photos you want to import.</p>
+ <p>Alternatively, click <guiseq><gui>File</gui><gui>Import From Folder...</gui></guiseq> and select the
folder containing the photos you want to import. If you do not want Shotwell to recurse into subfolders while
importing, you can check the <gui>Recurse Into Subfolders</gui> checkbox on the bottom of the file dialog.</p>
<p>Shotwell will ask whether you want to copy the photo files to your library folder (usually this is
the <file>Pictures</file> folder in your home directory) or to import them in place without copying the
files.</p>
diff --git a/src/BatchImport.vala b/src/BatchImport.vala
index f1a7cd8..fdf2a7f 100644
--- a/src/BatchImport.vala
+++ b/src/BatchImport.vala
@@ -202,16 +202,22 @@ public abstract class BatchImportJob {
public virtual time_t get_exposure_time_override() {
return 0;
}
+
+ public virtual bool recurse() {
+ return true;
+ }
}
public class FileImportJob : BatchImportJob {
private File file_or_dir;
private bool copy_to_library;
private FileImportJob? associated = null;
+ private bool _recurse;
- public FileImportJob(File file_or_dir, bool copy_to_library) {
+ public FileImportJob(File file_or_dir, bool copy_to_library, bool recurse) {
this.file_or_dir = file_or_dir;
this.copy_to_library = copy_to_library;
+ this._recurse = recurse;
}
public override string get_dest_identifier() {
@@ -255,6 +261,10 @@ public class FileImportJob : BatchImportJob {
public File get_file() {
return file_or_dir;
}
+
+ public override bool recurse() {
+ return this._recurse;
+ }
}
// A BatchImportRoll represents important state for a group of imported media. If this is shared
@@ -1553,7 +1563,7 @@ private class WorkSniffer : BackgroundImportJob {
assert(query_is_directory(dir));
try {
- search_dir(job, dir, copy_to_library);
+ search_dir(job, dir, copy_to_library, job.recurse());
} catch (Error err) {
report_error(job, dir, job.get_source_identifier(), dir.get_path(), err,
ImportResult.FILE_ERROR);
@@ -1572,7 +1582,7 @@ private class WorkSniffer : BackgroundImportJob {
}
}
- public void search_dir(BatchImportJob job, File dir, bool copy_to_library) throws Error {
+ public void search_dir(BatchImportJob job, File dir, bool copy_to_library, bool recurse) throws Error {
FileEnumerator enumerator = dir.enumerate_children("standard::*",
FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
@@ -1586,11 +1596,14 @@ private class WorkSniffer : BackgroundImportJob {
FileType file_type = info.get_file_type();
if (file_type == FileType.DIRECTORY) {
+ if (!recurse)
+ continue;
+
if (info.get_name().has_prefix("."))
continue;
try {
- search_dir(job, child, copy_to_library);
+ search_dir(job, child, copy_to_library, recurse);
} catch (Error err) {
report_error(job, child, child.get_path(), child.get_path(), err,
ImportResult.FILE_ERROR);
diff --git a/src/LibraryMonitor.vala b/src/LibraryMonitor.vala
index 75194c1..f9291d7 100644
--- a/src/LibraryMonitor.vala
+++ b/src/LibraryMonitor.vala
@@ -593,7 +593,7 @@ public class LibraryMonitor : DirectoryMonitor {
if (is_blacklisted(file))
continue;
- jobs.add(new FileImportJob(file, false));
+ jobs.add(new FileImportJob(file, false, true));
pending_imports.add(file);
}
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 8153412..0b96e18 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -95,6 +95,7 @@ public class LibraryWindow : AppWindow {
}
private string import_dir = Environment.get_home_dir();
+ private bool import_recursive = true;
private Gtk.Paned sidebar_paned = new Gtk.Paned(Gtk.Orientation.VERTICAL);
private Gtk.Paned client_paned = new Gtk.Paned(Gtk.Orientation.HORIZONTAL);
@@ -510,6 +511,10 @@ public class LibraryWindow : AppWindow {
import_dialog.set_local_only(false);
import_dialog.set_select_multiple(true);
import_dialog.set_current_folder(import_dir);
+
+ var recursive = new Gtk.CheckButton.with_label(_("Recurse Into Subfolders"));
+ recursive.active = import_recursive;
+ import_dialog.set_extra_widget(recursive);
int response = import_dialog.run();
@@ -521,11 +526,12 @@ public class LibraryWindow : AppWindow {
if (copy_files_response != Gtk.ResponseType.CANCEL) {
dispatch_import_jobs(import_dialog.get_uris(), "folders",
- copy_files_response == Gtk.ResponseType.ACCEPT);
+ copy_files_response == Gtk.ResponseType.ACCEPT, recursive.active);
}
}
import_dir = import_dialog.get_current_folder();
+ import_recursive = recursive.active;
import_dialog.destroy();
}
@@ -766,7 +772,7 @@ public class LibraryWindow : AppWindow {
ImportUI.report_manifest(manifest, true);
}
- private void dispatch_import_jobs(GLib.SList<string> uris, string job_name, bool copy_to_library) {
+ private void dispatch_import_jobs(GLib.SList<string> uris, string job_name, bool copy_to_library, bool
recurse) {
if (AppDirs.get_import_dir().get_path() == Environment.get_home_dir() && notify_library_is_home_dir)
{
Gtk.ResponseType response = AppWindow.affirm_cancel_question(
_("Shotwell is configured to import photos to your home directory.\n" +
@@ -790,7 +796,7 @@ public class LibraryWindow : AppWindow {
continue;
}
- jobs.add(new FileImportJob(file_or_dir, copy_to_library));
+ jobs.add(new FileImportJob(file_or_dir, copy_to_library, recurse));
}
if (jobs.size > 0) {
@@ -897,7 +903,7 @@ public class LibraryWindow : AppWindow {
}
}
- dispatch_import_jobs(uris, "drag-and-drop", selected_action == Gdk.DragAction.COPY);
+ dispatch_import_jobs(uris, "drag-and-drop", selected_action == Gdk.DragAction.COPY, true);
Gtk.drag_finish(context, true, false, time);
}
diff --git a/src/main.vala b/src/main.vala
index 0755f62..13e4e3d 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -216,7 +216,7 @@ public void run_system_pictures_import(ImportManifest? external_exclusion_manife
return;
Gee.ArrayList<FileImportJob> jobs = new Gee.ArrayList<FileImportJob>();
- jobs.add(new FileImportJob(AppDirs.get_import_dir(), false));
+ jobs.add(new FileImportJob(AppDirs.get_import_dir(), false, true));
LibraryWindow library_window = (LibraryWindow) AppWindow.get_instance();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]