[shotwell/wip/phako/new-database: 1/3] Make BackingPhotoRow for a development a constructor of BackingPhotoRow



commit 0c676578b7c79dc6add4fe611b915ec4d662443f
Author: Jens Georg <mail jensge org>
Date:   Tue Dec 19 19:28:30 2017 +0100

    Make BackingPhotoRow for a development a constructor of BackingPhotoRow

 src/Photo.vala             |  4 ++--
 src/camera/ImportPage.vala |  3 +--
 src/db/PhotoTable.vala     | 29 ++++++++++++++++++++++++++++-
 src/photos/RawSupport.vala | 30 ------------------------------
 4 files changed, 31 insertions(+), 35 deletions(-)
---
diff --git a/src/Photo.vala b/src/Photo.vala
index 8c6234f1..c73fe51d 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -674,7 +674,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
             case RawDeveloper.SHOTWELL:
                 try {
                     // Create file and prep.
-                    bps = d.create_backing_row_for_development(row.master.filepath);
+                    bps = new BackingPhotoRow.for_development(d, row.master.filepath);
                     Gdk.Pixbuf? pix = null;
                     lock (readers) {
                         // Don't rotate this pixbuf before writing it out. We don't
@@ -749,7 +749,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
                     }
 
                     // Write out file.
-                    bps = d.create_backing_row_for_development(row.master.filepath);
+                    bps = new BackingPhotoRow.for_development(d, row.master.filepath);
 
                     // Peek at data. If we really have a JPEG image, just use it,
                     // otherwise do GdkPixbuf roundtrip
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index ab24df61..7f2bf1e5 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -588,8 +588,7 @@ public class ImportPage : CheckerboardPage {
             // Copy over associated file, if it exists.
             if (associated != null) {
                 try {
-                    associated_file = 
-                        RawDeveloper.CAMERA.create_backing_row_for_development(dest_file.get_path(),
+                    associated_file = new BackingPhotoRow.for_development(RawDeveloper.CAMERA, 
dest_file.get_path(),
                             associated.get_basename());
                 } catch (Error err) {
                     warning("Unable to generate backing associated file for %s: %s", associated.filename,
diff --git a/src/db/PhotoTable.vala b/src/db/PhotoTable.vala
index 72e43e79..8c5ca388 100644
--- a/src/db/PhotoTable.vala
+++ b/src/db/PhotoTable.vala
@@ -1129,7 +1129,34 @@ public class BackingPhotoRow {
     public PhotoFileFormat file_format;
     public Dimensions dim;
     public Orientation original_orientation;
-    
+
+    // Creates a backing JPEG.
+    // raw_filepath is the full path of the imported RAW file.
+    public BackingPhotoRow.for_development(RawDeveloper development, string raw_filepath, string? 
camera_development_filename = null) throws Error {
+        File master = File.new_for_path(raw_filepath);
+        string name, ext;
+        disassemble_filename(master.get_basename(), out name, out ext);
+
+        string basename;
+
+        // If this image is coming in with an existing development, use its existing
+        // filename instead.
+        if (camera_development_filename == null) {
+            basename = name + "_" + ext +
+                (development != RawDeveloper.CAMERA ? ("_" + development.to_string().down()) : "") + ".jpg";
+        } else {
+            basename = camera_development_filename;
+        }
+
+        bool c;
+        string newbasename = LibraryFiles.convert_basename(basename);
+        File? new_back = generate_unique_file(master.get_parent(), newbasename, out c);
+        claim_file(new_back);
+        this.file_format = PhotoFileFormat.JFIF;
+        this.filepath = new_back.get_path();
+
+    }
+
     public bool matches_file_info(FileInfo info) {
         if (filesize != info.get_size())
             return false;
diff --git a/src/photos/RawSupport.vala b/src/photos/RawSupport.vala
index d457aa76..2c4f91fc 100644
--- a/src/photos/RawSupport.vala
+++ b/src/photos/RawSupport.vala
@@ -325,35 +325,5 @@ public enum RawDeveloper {
         
         return false;
     }
-    
-    // Creates a backing JPEG.
-    // raw_filepath is the full path of the imported RAW file.
-    public BackingPhotoRow create_backing_row_for_development(string raw_filepath,
-        string? camera_development_filename = null) throws Error {
-        BackingPhotoRow ns = new BackingPhotoRow();
-        File master = File.new_for_path(raw_filepath);
-        string name, ext;
-        disassemble_filename(master.get_basename(), out name, out ext);
-        
-        string basename;
-        
-        // If this image is coming in with an existing development, use its existing
-        // filename instead.
-        if (camera_development_filename == null) {
-            basename = name + "_" + ext +
-                (this != CAMERA ? ("_" + this.to_string().down()) : "") + ".jpg";
-        } else {
-            basename = camera_development_filename;
-        }
-        
-        string newbasename = LibraryFiles.convert_basename(basename);
 
-        bool c;
-        File? new_back = generate_unique_file(master.get_parent(), newbasename, out c);
-        claim_file(new_back);
-        ns.file_format = PhotoFileFormat.JFIF;
-        ns.filepath = new_back.get_path();
-        
-        return ns;
-    }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]