f-spot r4385 - in trunk: . src
- From: thomasvm svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4385 - in trunk: . src
- Date: Tue, 16 Sep 2008 19:38:25 +0000 (UTC)
Author: thomasvm
Date: Tue Sep 16 19:38:25 2008
New Revision: 4385
URL: http://svn.gnome.org/viewvc/f-spot?rev=4385&view=rev
Log:
2008-09-16 Thomas Van Machelen <thomas vanmachelen gmail com>
* src/f-spot.glade:
* src/CameraFileSelectionDialog.cs: Add duplicate support for the
camera import dialog
Modified:
trunk/ChangeLog
trunk/src/CameraFileSelectionDialog.cs
trunk/src/FileImportBackend.cs
trunk/src/ImportCommand.cs
trunk/src/f-spot.glade
Modified: trunk/src/CameraFileSelectionDialog.cs
==============================================================================
--- trunk/src/CameraFileSelectionDialog.cs (original)
+++ trunk/src/CameraFileSelectionDialog.cs Tue Sep 16 19:38:25 2008
@@ -15,6 +15,7 @@
using Glade;
using LibGPhoto2;
using Mono.Unix;
+using FSpot.Utils;
using FSpot.UI.Dialog;
namespace FSpot {
@@ -31,6 +32,7 @@
[Widget] Gtk.TreeView file_tree;
[Widget] Gtk.OptionMenu tag_option_menu;
[Widget] Gtk.CheckButton attach_check;
+ [Widget] Gtk.CheckButton duplicate_check;
GPhotoCamera camera;
ListStore preview_list_store;
@@ -219,7 +221,12 @@
(i + 1), index_list.Count);
progress_dialog.ProgressText = msg;
- saved.Add (SaveFile ((int)(index_list [i])));
+
+ SaveResult result = SaveFile ((int)(index_list [i]));
+
+ if (!result.IsDuplicate)
+ saved.Add (result.Path);
+
progress_dialog.Fraction = (i + 1)/(double)index_list.Count;
}
catch (System.Exception e) {
@@ -241,7 +248,7 @@
}
}
- private string SaveFile (int index)
+ private SaveResult SaveFile (int index)
{
GPhotoCameraFile camfile = (GPhotoCameraFile) camera.FileList [index];
string tempdir = FSpot.Global.PhotoDirectory;
@@ -266,12 +273,36 @@
progress_dialog.Message = msg;
camera.SaveFile (index, path);
+
+ if (duplicate_check.Active && db.Photos.CheckForDuplicate (FSpot.Utils.UriUtils.PathToFileUri (path)) != null) {
+ System.IO.File.Delete (path);
+
+ return new SaveResult (path, true);
+ } else {
+ string dest = FileImportBackend.ChooseLocation (path);
+ System.IO.File.Move (path, dest);
+
+ return new SaveResult (dest, false);
+ }
+ }
+
+ private class SaveResult {
+ private bool is_duplicate;
- string dest = FileImportBackend.ChooseLocation (path);
- System.IO.File.Move (path, dest);
- path = dest;
+ private string path;
+
+ public string Path {
+ get { return path; }
+ }
- return path;
+ public bool IsDuplicate {
+ get { return is_duplicate; }
+ }
+
+ public SaveResult (string path, bool is_duplicate) {
+ this.path = path;
+ this.is_duplicate = is_duplicate;
+ }
}
private int ImportFiles ()
Modified: trunk/src/FileImportBackend.cs
==============================================================================
--- trunk/src/FileImportBackend.cs (original)
+++ trunk/src/FileImportBackend.cs Tue Sep 16 19:38:25 2008
@@ -23,7 +23,7 @@
TagStore tag_store = FSpot.Core.Database.Tags;
bool recurse;
bool copy;
- bool include_duplicates;
+ bool detect_duplicates;
string [] base_paths;
Tag [] tags;
Gtk.Window parent;
@@ -219,7 +219,7 @@
if (info.OriginalPath == destination) {
info.DestinationPath = destination;
- if (!include_duplicates)
+ if (detect_duplicates)
photo = store.CheckForDuplicate (UriUtils.PathToFileUri (destination));
if (photo == null)
@@ -230,7 +230,7 @@
System.IO.File.Copy (info.OriginalPath, destination);
info.DestinationPath = destination;
- if (!include_duplicates)
+ if (detect_duplicates)
photo = store.CheckForDuplicate (UriUtils.PathToFileUri (destination));
if (photo == null)
@@ -366,13 +366,13 @@
public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, Tag [] tags, Gtk.Window parent) : this (store, base_paths, copy, recurse, false, null, parent) {}
- public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, bool include_duplicates, Tag [] tags, Gtk.Window parent)
+ public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, bool detect_duplicates, Tag [] tags, Gtk.Window parent)
{
this.store = store;
this.copy = copy;
this.base_paths = base_paths;
this.recurse = recurse;
- this.include_duplicates = include_duplicates;
+ this.detect_duplicates = detect_duplicates;
this.tags = tags;
this.parent = parent;
}
Modified: trunk/src/ImportCommand.cs
==============================================================================
--- trunk/src/ImportCommand.cs (original)
+++ trunk/src/ImportCommand.cs Tue Sep 16 19:38:25 2008
@@ -777,12 +777,12 @@
if (recurse_check != null)
recurse = recurse_check.Active;
- bool include_duplicates = false;
- if (include_duplicates != null)
- include_duplicates = duplicate_check.Active;
+ bool detect_duplicates = false;
+ if (duplicate_check != null)
+ detect_duplicates = duplicate_check.Active;
// importer = new FileImportBackend (store, pathimport, copy, recurse, null);
- importer = new FileImportBackend (store, pathimport, copy, recurse, include_duplicates, null, Dialog);
+ importer = new FileImportBackend (store, pathimport, copy, recurse, detect_duplicates, null, Dialog);
AllowFinish = false;
total = importer.Prepare ();
Modified: trunk/src/f-spot.glade
==============================================================================
--- trunk/src/f-spot.glade (original)
+++ trunk/src/f-spot.glade Tue Sep 16 19:38:25 2008
@@ -633,7 +633,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
- </child>
+ </child>
<child>
<widget class="GtkOptionMenu" id="tag_option_menu">
<property name="visible">True</property>
@@ -650,6 +650,21 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkCheckButton" id="duplicate_check">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Detect duplicates</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="position">1</property>
@@ -4246,7 +4261,7 @@
<widget class="GtkDialog" id="import_dialog">
<property name="title" translatable="yes">Import</property>
<property name="modal">True</property>
- <property name="default_width">640</property>
+ <property name="default_width">664</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@@ -4429,10 +4444,10 @@
<widget class="GtkCheckButton" id="duplicate_check">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Include Duplicates</property>
+ <property name="label" translatable="yes">Detect duplicates</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
- <property name="active">False</property>
+ <property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]