summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-08-17 17:10:12 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-08-17 17:10:12 +0200
commit008bc99860fd353a5da5d06e6be5937f4a358aed (patch)
treed50b38f704b90b83895a21fd610bcf78c31b2cc9 /src
parent4ec8ba6ace7234ddc24a7d362a34d9055a83812c (diff)
parent7eef6a59ba38582bed5d459974211eb1f53e1f5d (diff)
Merge branch 'release/debian/0.32.2-1'debian/0.32.2-1
Diffstat (limited to 'src')
-rw-r--r--src/AppDirs.vala17
-rw-r--r--src/MetadataWriter.vala2
-rw-r--r--src/Photo.vala18
-rw-r--r--src/ProfileBrowser.vala12
-rw-r--r--src/core/util.vala11
-rw-r--r--src/db/PhotoTable.vala14
-rw-r--r--src/main.vala7
-rw-r--r--src/photos/HeifSupport.vala2
-rw-r--r--src/photos/JfifSupport.vala2
-rw-r--r--src/util/file.vala4
-rw-r--r--src/video-support/VideoReader.vala2
-rw-r--r--src/video-support/VideoSourceCollection.vala2
12 files changed, 61 insertions, 32 deletions
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 20df920..05e172c 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -196,14 +196,21 @@ class AppDirs {
public static File get_temp_dir() {
if (tmp_dir == null) {
- tmp_dir = File.new_for_path(DirUtils.mkdtemp (Environment.get_tmp_dir() + "/shotwell-XXXXXX"));
+ var basedir = Environment.get_tmp_dir();
+ var flatpak_canary = File.new_for_path("/.flatpak-info");
+ if (flatpak_canary.query_exists() && basedir == "/tmp") {
+ basedir = Environment.get_user_cache_dir() + "/tmp";
+ }
+
+ tmp_dir = File.new_for_path(DirUtils.mkdtemp (basedir + "/shotwell-XXXXXX"));
try {
- if (!tmp_dir.query_exists(null))
- tmp_dir.make_directory_with_parents(null);
+ tmp_dir.make_directory_with_parents(null);
} catch (Error err) {
- AppWindow.panic(_("Unable to create temporary directory %s: %s").printf(
- tmp_dir.get_path(), err.message));
+ if (!(err is GLib.IOError.EXISTS)) {
+ AppWindow.panic(_("Unable to create temporary directory %s: %s").printf(
+ tmp_dir.get_path(), err.message));
+ }
}
}
diff --git a/src/MetadataWriter.vala b/src/MetadataWriter.vala
index 5fc26d1..bc220da 100644
--- a/src/MetadataWriter.vala
+++ b/src/MetadataWriter.vala
@@ -113,7 +113,7 @@ public class MetadataWriter : Object {
MetadataDateTime? metadata_exposure_date_time = metadata.get_exposure_date_time();
if (metadata_exposure_date_time != null)
metadata_exposure_time = metadata_exposure_date_time.get_timestamp();
- if (current_exposure_time != metadata_exposure_time) {
+ if (nullsafe_date_time_comperator(current_exposure_time, metadata_exposure_time) != 0) {
metadata.set_exposure_date_time(current_exposure_time != null
? new MetadataDateTime(current_exposure_time)
: null);
diff --git a/src/Photo.vala b/src/Photo.vala
index f31a17d..34cfedf 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -640,7 +640,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
File file = File.new_for_path(bpr.filepath);
FileInfo info = file.query_info(DirectoryMonitor.SUPPLIED_ATTRIBUTES,
FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
- var timestamp = info.get_modification_date_time();
+ var timestamp = coarsify_date_time(info.get_modification_date_time());
PhotoFileInterrogator interrogator = new PhotoFileInterrogator(
file, PhotoFileSniffer.Options.GET_ALL);
@@ -1185,7 +1185,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
return ImportResult.UNSUPPORTED_FORMAT;
}
- var timestamp = info.get_modification_date_time();
+ var timestamp = coarsify_date_time(info.get_modification_date_time());
// if all MD5s supplied, don't sniff for them
if (params.exif_md5 != null && params.thumbnail_md5 != null && params.full_md5 != null)
@@ -1354,7 +1354,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
return null;
}
- var modification_time = info.get_modification_date_time();
+ var modification_time = coarsify_date_time(info.get_modification_date_time());
backing.filepath = file.get_path();
backing.timestamp = modification_time;
@@ -1709,7 +1709,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
// Use this only if the master file's modification time has been changed (i.e. touched)
public void set_master_timestamp(FileInfo info) {
- var modification = info.get_modification_date_time();
+ var modification = coarsify_date_time(info.get_modification_date_time());
try {
lock (row) {
@@ -1733,7 +1733,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
// Use this only if the editable file's modification time has been changed (i.e. touched)
public void update_editable_modification_time(FileInfo info) throws Error {
- var modification = info.get_modification_date_time();
+ var modification = coarsify_date_time(info.get_modification_date_time());
bool altered = false;
lock (row) {
@@ -2296,7 +2296,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
error("Unable to read file information for %s: %s", to_string(), err.message);
}
- var timestamp = info.get_modification_date_time();
+ var timestamp = coarsify_date_time(info.get_modification_date_time());
// interrogate file for photo information
PhotoFileInterrogator interrogator = new PhotoFileInterrogator(file);
@@ -2816,7 +2816,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
lock (row) {
return row.transformations != null
|| row.orientation != backing_photo_row.original_orientation
- || (date_time != null && !row.exposure_time.equal(date_time.get_timestamp()))
+ || (date_time != null && nullsafe_date_time_comperator(row.exposure_time, date_time.get_timestamp()) != 0)
|| (get_comment() != comment)
|| (get_title() != title);
}
@@ -4014,8 +4014,8 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
return;
}
- var timestamp = info.get_modification_date_time();
-
+ var timestamp = coarsify_date_time(info.get_modification_date_time());
+
BackingPhotoTable.get_instance().update_attributes(editable_id, timestamp,
info.get_size());
lock (row) {
diff --git a/src/ProfileBrowser.vala b/src/ProfileBrowser.vala
index 4532a20..1591fce 100644
--- a/src/ProfileBrowser.vala
+++ b/src/ProfileBrowser.vala
@@ -182,6 +182,8 @@ namespace Shotwell {
label = new Gtk.Label(import_dir);
label.halign = Gtk.Align.START;
label.set_ellipsize(Pango.EllipsizeMode.END);
+ label.set_tooltip_text(import_dir);
+ label.set_selectable(true);
grid.attach(label, 1, 0, 1, 1);
label = new Gtk.Label(_("Data Folder"));
@@ -193,6 +195,8 @@ namespace Shotwell {
label.halign = Gtk.Align.START;
label.hexpand = true;
label.set_ellipsize(Pango.EllipsizeMode.END);
+ label.set_tooltip_text(profile.data_dir);
+ label.set_selectable(true);
grid.attach(label, 1, 1, 1, 1);
if (profile.id != Profile.SYSTEM && !profile.active) {
@@ -231,7 +235,7 @@ namespace Shotwell {
Object(orientation: Gtk.Orientation.VERTICAL, vexpand: true, hexpand: true);
}
- public signal void profile_activated(string? profile);
+ public signal void profile_activated(Profile profile);
public override void constructed() {
var scrollable = new Gtk.ScrolledWindow(null, null);
@@ -243,11 +247,7 @@ namespace Shotwell {
list_box.row_activated.connect((list_box, row) => {
var index = row.get_index();
var profile = (Profile) ProfileManager.get_instance().get_item(index);
- if (profile.id == Profile.SYSTEM) {
- profile_activated(null);
- } else {
- profile_activated(profile.name);
- }
+ profile_activated(profile);
});
list_box.get_style_context().add_class("rich-list");
list_box.hexpand = true;
diff --git a/src/core/util.vala b/src/core/util.vala
index 461d2c0..8e0f92f 100644
--- a/src/core/util.vala
+++ b/src/core/util.vala
@@ -198,4 +198,15 @@ public static int64 nullsafe_date_time_comperator(DateTime? time_a, DateTime? ti
return time_a.compare(time_b);
+}
+
+/*
+ * Drop microseconds from input DateTime
+ */
+public DateTime? coarsify_date_time(DateTime? dt) {
+ if (dt == null) {
+ return null;
+ }
+
+ return dt.add(-dt.get_microsecond());
} \ No newline at end of file
diff --git a/src/db/PhotoTable.vala b/src/db/PhotoTable.vala
index 4e3f672..420b209 100644
--- a/src/db/PhotoTable.vala
+++ b/src/db/PhotoTable.vala
@@ -1170,8 +1170,11 @@ public class BackingPhotoRow {
if (timestamp == null)
return false;
-
- return timestamp.equal(info.get_modification_date_time());
+
+ // Need to remove the microseconds from the FileInfo, since the database
+ // just stores second granularity, causing the file to be marked as modified all
+ // the time
+ return timestamp.equal(coarsify_date_time(info.get_modification_date_time()));
}
public bool is_touched(FileInfo info) {
@@ -1180,8 +1183,11 @@ public class BackingPhotoRow {
if (timestamp == null)
return true;
-
- return !timestamp.equal(info.get_modification_date_time());
+
+ // Need to remove the microseconds from the FileInfo, since the database
+ // just stores second granularity, causing the file to be marked as modified all
+ // the time
+ return !timestamp.equal(coarsify_date_time(info.get_modification_date_time()));
}
// Copies another backing photo row into this one.
diff --git a/src/main.vala b/src/main.vala
index cdc9b27..32e3d83 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -410,7 +410,12 @@ void main(string[] args) {
window.set_title (_("Choose Shotwell's profile"));
var browser = new Shotwell.ProfileBrowser();
browser.profile_activated.connect((profile) => {
- CommandlineOptions.profile = profile;
+ if (profile.id != Shotwell.Profile.SYSTEM) {
+ CommandlineOptions.profile = profile.name;
+ CommandlineOptions.data_dir = profile.data_dir;
+ } else {
+ CommandlineOptions.profile = null;
+ }
window.response(Gtk.ResponseType.OK);
});
window.get_content_area().add(browser);
diff --git a/src/photos/HeifSupport.vala b/src/photos/HeifSupport.vala
index 0c05e02..58b9d9d 100644
--- a/src/photos/HeifSupport.vala
+++ b/src/photos/HeifSupport.vala
@@ -5,7 +5,7 @@
*/
class HeifFileFormatProperties : PhotoFileFormatProperties {
- private static string[] KNOWN_EXTENSIONS = { "heif", "heic" };
+ private static string[] KNOWN_EXTENSIONS = { "heif", "heic", "hif" };
private static string[] KNOWN_MIME_TYPES = { "image/heif" };
private static HeifFileFormatProperties instance = null;
diff --git a/src/photos/JfifSupport.vala b/src/photos/JfifSupport.vala
index 0de45f8..27a8b11 100644
--- a/src/photos/JfifSupport.vala
+++ b/src/photos/JfifSupport.vala
@@ -223,7 +223,7 @@ namespace Jpeg {
public bool is_sof() {
// FFCn is SOF unless n is a multiple of 4 > 0 (FFC4, FFC8, FFCC)
- if ((this & 0xC0) != 0xC0) {
+ if ((this >> 4) != 0xC) {
return false;
}
diff --git a/src/util/file.vala b/src/util/file.vala
index 652a141..6d9252e 100644
--- a/src/util/file.vala
+++ b/src/util/file.vala
@@ -158,8 +158,8 @@ public void delete_all_files(File dir, Gee.Set<string>? exceptions = null, Progr
public DateTime query_file_modified(File file) throws Error {
FileInfo info = file.query_info(FileAttribute.TIME_MODIFIED, FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
null);
-
- return info.get_modification_date_time();
+
+ return coarsify_date_time(info.get_modification_date_time());
}
public bool query_is_directory(File file) {
diff --git a/src/video-support/VideoReader.vala b/src/video-support/VideoReader.vala
index 11f11e1..adb6680 100644
--- a/src/video-support/VideoReader.vala
+++ b/src/video-support/VideoReader.vala
@@ -98,7 +98,7 @@ public class VideoReader {
return ImportResult.UNSUPPORTED_FORMAT;
}
- var timestamp = info.get_modification_date_time();
+ var timestamp = coarsify_date_time(info.get_modification_date_time());
// make sure params has a valid md5
assert(params.md5 != null);
diff --git a/src/video-support/VideoSourceCollection.vala b/src/video-support/VideoSourceCollection.vala
index 89daad3..8dd75d9 100644
--- a/src/video-support/VideoSourceCollection.vala
+++ b/src/video-support/VideoSourceCollection.vala
@@ -126,7 +126,7 @@ public class VideoSourceCollection : MediaSourceCollection {
if (video.get_filesize() != info.get_size())
return;
- if (video.get_timestamp().equal(info.get_modification_date_time()))
+ if (video.get_timestamp().equal(coarsify_date_time(info.get_modification_date_time())))
matching_master.add(video);
}