summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AppDirs.vala31
-rw-r--r--src/AppWindow.vala15
-rw-r--r--src/Application.vala1
-rw-r--r--src/Commands.vala2
-rw-r--r--src/Debug.vala2
-rw-r--r--src/DirectoryMonitor.vala6
-rw-r--r--src/Event.vala5
-rw-r--r--src/Photo.vala6
-rw-r--r--src/PhotoPage.vala11
-rw-r--r--src/PixbufCache.vala8
-rw-r--r--src/Properties.vala2
-rw-r--r--src/Resources.vala6
-rw-r--r--src/TimedQueue.vala189
-rw-r--r--src/Tombstone.vala5
-rw-r--r--src/camera/ImportPage.vala2
-rw-r--r--src/db/DatabaseTable.vala51
-rw-r--r--src/db/Db.vala8
-rw-r--r--src/db/PhotoTable.vala7
-rw-r--r--src/db/VideoTable.vala9
-rw-r--r--src/dialogs/AdjustDateTimeDialog.vala2
-rw-r--r--src/dialogs/ExportDialog.vala12
-rw-r--r--src/dialogs/ProgressDialog.vala2
-rw-r--r--src/editing_tools/EditingTools.vala1
-rw-r--r--src/events/EventsBranch.vala8
-rw-r--r--src/library/LibraryWindow.vala9
-rw-r--r--src/main.vala28
-rw-r--r--src/meson.build2
-rw-r--r--src/metadata/MetadataDateTime.vala3
-rw-r--r--src/photos/AvifSupport.vala25
-rw-r--r--src/photos/HeifSupport.vala2
-rw-r--r--src/photos/JfifSupport.vala6
-rw-r--r--src/photos/PhotoFileFormat.vala1
-rw-r--r--src/photos/PhotoMetadata.vala12
-rw-r--r--src/photos/WebPSupport.vala10
-rw-r--r--src/plugins/Plugins.vala10
-rw-r--r--src/plugins/SpitInterfaces.vala2
-rw-r--r--src/searches/SavedSearchDialog.vala4
-rw-r--r--src/sidebar/Tree.vala31
-rw-r--r--src/util/image.vala38
-rw-r--r--src/util/string.vala26
-rw-r--r--src/video-support/AVIMetadataLoader.vala4
41 files changed, 394 insertions, 210 deletions
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 05e172c..fd357c2 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -193,12 +193,39 @@ class AppDirs {
public static File get_exec_dir() {
return exec_dir;
}
+
+ public enum Runtime {
+ NATIVE,
+ FLATPAK,
+ SNAP,
+ UNKNOWN
+ }
+
+ private static Runtime _runtime = Runtime.UNKNOWN;
+
+ public static Runtime get_runtime() {
+ if (_runtime == Runtime.UNKNOWN) {
+ var snap = Environment.get_variable("SNAP_NAME");
+ if (snap != null) {
+ _runtime = Runtime.SNAP;
+ }
+ else {
+ var flatpak_canary = File.new_for_path("/.flatpak-info");
+ if (flatpak_canary.query_exists()) {
+ _runtime = Runtime.FLATPAK;
+ } else {
+ _runtime = Runtime.NATIVE;
+ }
+ }
+ }
+
+ return _runtime;
+ }
public static File get_temp_dir() {
if (tmp_dir == null) {
var basedir = Environment.get_tmp_dir();
- var flatpak_canary = File.new_for_path("/.flatpak-info");
- if (flatpak_canary.query_exists() && basedir == "/tmp") {
+ if (get_runtime() == Runtime.FLATPAK && basedir == "/tmp") {
basedir = Environment.get_user_cache_dir() + "/tmp";
}
diff --git a/src/AppWindow.vala b/src/AppWindow.vala
index 7398c74..ae8bfb9 100644
--- a/src/AppWindow.vala
+++ b/src/AppWindow.vala
@@ -586,6 +586,21 @@ public abstract class AppWindow : PageWindow {
if (Resources.GIT_VERSION != null && Resources.GIT_VERSION != "" && Resources.GIT_VERSION != Resources.APP_VERSION) {
hash = " (%s)".printf(Resources.GIT_VERSION.substring(0,7));
}
+ var runtime = AppDirs.get_runtime();
+ switch (runtime) {
+ case AppDirs.Runtime.SNAP:
+ hash += " (Snap)";
+ break;
+ case AppDirs.Runtime.FLATPAK:
+ hash += " (Flatpak)";
+ break;
+ case AppDirs.Runtime.NATIVE:
+ hash += " (Native)";
+ break;
+ default:
+ hash += " (Unknown)";
+ break;
+ }
string[] artists = {"Image of the Delmenhorst Town Hall by Charlie1965nrw, source: https://commons.wikimedia.org/wiki/File:Delmenhorst_Rathaus.jpg", null};
Gtk.show_about_dialog(this,
"version", Resources.APP_VERSION + hash + " — Delmenhorst",
diff --git a/src/Application.vala b/src/Application.vala
index d9edcaf..2225f7c 100644
--- a/src/Application.vala
+++ b/src/Application.vala
@@ -74,6 +74,7 @@ public class Application {
public abstract void authenticated(HashTable<string, string> params);
}
private static Application instance = null;
+ public static TimeZone timezone = null;
private Gtk.Application system_app = null;
private int system_app_run_retval = 0;
private bool direct;
diff --git a/src/Commands.vala b/src/Commands.vala
index 76aecb4..25bdbc2 100644
--- a/src/Commands.vala
+++ b/src/Commands.vala
@@ -321,7 +321,7 @@ public abstract class MultipleDataSourceCommand : PageCommand {
private void on_source_destroyed(DataSource source) {
// as with SingleDataSourceCommand, too risky to selectively remove commands from the stack,
// although this could be reconsidered in the future
- if (source_list.contains(source))
+ if (source_list.contains(source) && get_command_manager() != null)
get_command_manager().reset();
}
diff --git a/src/Debug.vala b/src/Debug.vala
index 799a94f..186a175 100644
--- a/src/Debug.vala
+++ b/src/Debug.vala
@@ -107,7 +107,7 @@ namespace Debug {
stream.printf("%s %d %s [%s] %s\n",
log_app_version_prefix,
Posix.getpid(),
- new DateTime.now_local().format("%F %T"),
+ new DateTime.now(Application.timezone).format("%F %T"),
prefix,
message
);
diff --git a/src/DirectoryMonitor.vala b/src/DirectoryMonitor.vala
index 19992dd..87d9a2e 100644
--- a/src/DirectoryMonitor.vala
+++ b/src/DirectoryMonitor.vala
@@ -871,7 +871,7 @@ public class DirectoryMonitor : Object {
}
}
- if (local_dir_info.get_is_hidden()) {
+ if (local_dir_info.has_attribute("standard::is-hidden") && local_dir_info.get_is_hidden()) {
warning("Ignoring hidden directory %s", dir.get_path());
explore_directory_completed(in_discovery);
@@ -918,7 +918,7 @@ public class DirectoryMonitor : Object {
dir.get_uri());
}
// we don't deal with hidden files or directories
- if (info.get_is_hidden()) {
+ if (info.has_attribute("standard::is-hidden") && info.get_is_hidden()) {
warning("Skipping hidden file/directory %s",
dir.get_child(info.get_name()).get_path());
@@ -1439,7 +1439,7 @@ public class DirectoryMonitor : Object {
// Returns true if the file is not a symlink or if symlinks are supported for the file type,
// false otherwise. If an unsupported file type, returns false.
public static bool is_file_symlink_supported(FileInfo info) {
- if (!info.get_is_symlink())
+ if (info.has_attribute("standard::is-symlink") && !info.get_is_symlink())
return true;
FType ftype = get_ftype(info);
diff --git a/src/Event.vala b/src/Event.vala
index 69d27d0..4375aad 100644
--- a/src/Event.vala
+++ b/src/Event.vala
@@ -601,10 +601,11 @@ public class Event : EventSource, ContainerSource, Proxyable, Indexable {
// media sources are stored in ViewCollection from earliest to latest
MediaSource earliest_media = (MediaSource) ((DataView) view.get_at(0)).get_source();
- var earliest_tm = earliest_media.get_exposure_time().to_local();
+ var earliest_tm = earliest_media.get_exposure_time().to_timezone(Application.timezone);
// use earliest to generate the boundary hour for that day
- var start_boundary = new DateTime.local(earliest_tm.get_year(),
+ var start_boundary = new DateTime(Application.timezone,
+ earliest_tm.get_year(),
earliest_tm.get_month(),
earliest_tm.get_day_of_month(),
EVENT_BOUNDARY_HOUR,
diff --git a/src/Photo.vala b/src/Photo.vala
index f636a32..1cab22f 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -405,9 +405,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
readers.master = row.master.file_format.create_reader(row.master.filepath);
// get the file title of the Photo without using a File object, skipping the separator itself
- string? basename = String.sliced_at_last_char(row.master.filepath, Path.DIR_SEPARATOR);
- if (basename != null)
- file_title = String.sliced_at(basename, 1);
+ file_title = Path.get_basename(row.master.filepath);
if (is_string_empty(file_title))
file_title = row.master.filepath;
@@ -3725,7 +3723,7 @@ public abstract class Photo : PhotoSource, Dateable, Positionable {
if (metadata == null)
metadata = export_format.create_metadata();
- if (!export_format.can_write())
+ if (!export_format.can_write_image())
export_format = PhotoFileFormat.get_system_default_format();
PhotoFileWriter writer = export_format.create_writer(dest_file.get_path());
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 5e94c24..3ab0f6b 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -835,7 +835,9 @@ public abstract class EditingHostPage : SinglePhotoPage {
photo_changing(photo);
DataView view = get_view().get_view_for_source(photo);
- assert(view != null);
+ if (view == null) {
+ return;
+ }
// Select photo.
get_view().unselect_all();
@@ -966,7 +968,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
return photo.has_transformations() || photo.has_editable();
}
- private void on_pixbuf_fetched(Photo photo, owned Gdk.Pixbuf? pixbuf, Error? err) {
+ private void on_pixbuf_fetched(Photo photo, Gdk.Pixbuf? pixbuf, Error? err) {
// if not of the current photo, nothing more to do
if (!photo.equals(get_photo()))
return;
@@ -987,6 +989,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
if (tool_pixbuf != null) {
pixbuf = tool_pixbuf;
+ pixbuf.ref();
max_dim = tool_pixbuf_dim;
}
} catch(Error err) {
@@ -1254,6 +1257,10 @@ public abstract class EditingHostPage : SinglePhotoPage {
}
private void quick_update_pixbuf() {
+ if (get_photo() == null) {
+ return;
+ }
+
Gdk.Pixbuf? pixbuf = cache.get_ready_pixbuf(get_photo());
if (pixbuf != null) {
set_pixbuf(pixbuf, get_photo().get_dimensions());
diff --git a/src/PixbufCache.vala b/src/PixbufCache.vala
index cee33c6..76fdbd3 100644
--- a/src/PixbufCache.vala
+++ b/src/PixbufCache.vala
@@ -80,7 +80,7 @@ public class PixbufCache : Object {
private Gee.ArrayList<Photo> lru = new Gee.ArrayList<Photo>();
private Gee.HashMap<Photo, FetchJob> in_progress = new Gee.HashMap<Photo, FetchJob>();
- public signal void fetched(Photo photo, owned Gdk.Pixbuf? pixbuf, Error? err);
+ public signal void fetched(Photo photo, Gdk.Pixbuf? pixbuf, Error? err);
public PixbufCache(SourceCollection sources, PhotoType type, Scaling scaling, int max_count,
CacheFilter? filter = null) {
@@ -120,7 +120,11 @@ public class PixbufCache : Object {
}
// This call never blocks. Returns null if the pixbuf is not present.
- public Gdk.Pixbuf? get_ready_pixbuf(Photo photo) {
+ public Gdk.Pixbuf? get_ready_pixbuf(Photo? photo) {
+ if (photo == null) {
+ return null;
+ }
+
return get_cached(photo);
}
diff --git a/src/Properties.vala b/src/Properties.vala
index 7c6ab89..8eb5742 100644
--- a/src/Properties.vala
+++ b/src/Properties.vala
@@ -97,7 +97,7 @@ private abstract class Properties : Gtk.Box {
protected string get_prettyprint_date(DateTime date) {
string date_string = null;
- var today = new DateTime.now_local();
+ var today = new DateTime.now(Application.timezone);
if (date.get_day_of_year() == today.get_day_of_year() && date.get_year() == today.get_year()) {
date_string = _("Today");
} else if (date.get_day_of_year() == (today.get_day_of_year() - 1) && date.get_year() == today.get_year()) {
diff --git a/src/Resources.vala b/src/Resources.vala
index 0bd8512..a99a210 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -15,9 +15,9 @@ namespace Resources {
public const string COPYRIGHT = _("Copyright 2016 Software Freedom Conservancy Inc.");
public const string APP_GETTEXT_PACKAGE = GETTEXT_PACKAGE;
- public const string HOME_URL = "https://wiki.gnome.org/Apps/Shotwell";
- public const string FAQ_URL = "https://wiki.gnome.org/Apps/Shotwell/FAQ";
- public const string BUG_DB_URL = "https://wiki.gnome.org/Apps/Shotwell/ReportingABug";
+ public const string HOME_URL = "https://shotwell-project.org";
+ public const string FAQ_URL = "https://gitlab.gnome.org/GNOME/shotwell/-/wikis/Frequently-Asked-Questions";
+ public const string BUG_DB_URL = "https://gitlab.gnome.org/GNOME/shotwell/issues";
public const string DIR_PATTERN_URI_SYSWIDE = "help:shotwell/other-files";
private const string LIB = _LIB;
diff --git a/src/TimedQueue.vala b/src/TimedQueue.vala
index 4ea6a23..ac1aab6 100644
--- a/src/TimedQueue.vala
+++ b/src/TimedQueue.vala
@@ -18,7 +18,7 @@
public delegate void DequeuedCallback<G>(G item);
-public class TimedQueue<G> {
+public class HashTimedQueue<G> {
private class Element<G> {
public G item;
public ulong ready;
@@ -42,6 +42,7 @@ public class TimedQueue<G> {
private uint dequeue_spacing_msec = 0;
private ulong last_dequeue = 0;
private bool paused_state = false;
+ private Gee.HashMap<G, int> item_count;
public virtual signal void paused(bool is_paused) {
}
@@ -49,7 +50,8 @@ public class TimedQueue<G> {
// Initial design was to have a signal that passed the dequeued G, but bug in valac meant
// finding a workaround, namely using a delegate:
// https://bugzilla.gnome.org/show_bug.cgi?id=628639
- public TimedQueue(uint hold_msec, DequeuedCallback<G> callback,
+ public HashTimedQueue(uint hold_msec, DequeuedCallback<G> callback,
+ owned Gee.HashDataFunc<G>? hash_func = null,
owned Gee.EqualDataFunc<G>? equal_func = null, int priority = Priority.DEFAULT) {
this.hold_msec = hold_msec;
this.callback = callback;
@@ -64,9 +66,10 @@ public class TimedQueue<G> {
queue = new SortedList<Element<G>>(Element.comparator);
timer_id = Timeout.add(get_heartbeat_timeout(), on_heartbeat, priority);
+ item_count = new Gee.HashMap<G, int>((owned) hash_func, (owned) equal_func);
}
- ~TimedQueue() {
+ ~HashTimedQueue() {
if (timer_id != 0)
Source.remove(timer_id);
}
@@ -93,10 +96,6 @@ public class TimedQueue<G> {
: (dequeue_spacing_msec / 2)).clamp(10, uint.MAX);
}
- protected virtual void notify_dequeued(G item) {
- callback(item);
- }
-
public bool is_paused() {
return paused_state;
}
@@ -119,50 +118,80 @@ public class TimedQueue<G> {
paused(false);
}
- public virtual void clear() {
- queue.clear();
+ public void clear() {
+ lock(queue) {
+ item_count.clear();
+ queue.clear();
+ }
}
- public virtual bool contains(G item) {
- foreach (Element<G> e in queue) {
- if (equal_func(item, e.item))
- return true;
+ public bool contains(G item) {
+ lock(queue) {
+ return item_count.has_key(item);
}
-
- return false;
}
- public virtual bool enqueue(G item) {
- return queue.add(new Element<G>(item, calc_ready_time()));
+ public bool enqueue(G item) {
+ lock(queue) {
+ if (!queue.add(new Element<G>(item, calc_ready_time()))) {
+ return false;
+ }
+ item_count.set(item, item_count.has_key(item) ? item_count.get(item) + 1 : 1);
+
+ return true;
+ }
}
- public virtual bool enqueue_many(Gee.Collection<G> items) {
+ public bool enqueue_many(Gee.Collection<G> items) {
ulong ready_time = calc_ready_time();
Gee.ArrayList<Element<G>> elements = new Gee.ArrayList<Element<G>>();
foreach (G item in items)
elements.add(new Element<G>(item, ready_time));
- return queue.add_list(elements);
+ lock(queue) {
+ if (!queue.add_list(elements)) {
+ return false;
+ }
+
+ foreach (G item in items) {
+ item_count.set(item, item_count.has_key(item) ? item_count.get(item) + 1 : 1);
+ }
+ }
+
+ return true;
+
}
- public virtual bool remove_first(G item) {
- Gee.Iterator<Element<G>> iter = queue.iterator();
- while (iter.next()) {
- Element<G> e = iter.get();
- if (equal_func(item, e.item)) {
- iter.remove();
-
- return true;
+ public bool remove_first(G item) {
+ lock(queue) {
+ var item_removed = false;
+ var iter = queue.iterator();
+ while (iter.next()) {
+ Element<G> e = iter.get();
+ if (equal_func(item, e.item)) {
+ iter.remove();
+
+ item_removed = true;
+ break;
+ }
+ }
+
+ if (!item_removed) {
+ return false;
}
+
+ removed(item);
}
-
- return false;
+
+ return true;
}
- public virtual int size {
+ public int size {
get {
- return queue.size;
+ lock(queue) {
+ return queue.size;
+ }
}
}
@@ -180,23 +209,28 @@ public class TimedQueue<G> {
if (queue.size == 0)
break;
- Element<G>? head = queue.get_at(0);
- assert(head != null);
-
- if (now == 0)
- now = now_ms();
-
- if (head.ready > now)
- break;
-
- // if a space of time is required between dequeues, check now
- if ((dequeue_spacing_msec != 0) && ((now - last_dequeue) < dequeue_spacing_msec))
- break;
-
- Element<G>? h = queue.remove_at(0);
- assert(head == h);
-
- notify_dequeued(head.item);
+ G? item = null;
+ lock(queue) {
+ Element<G>? head = queue.get_at(0);
+ assert(head != null);
+
+ if (now == 0)
+ now = now_ms();
+
+ if (head.ready > now)
+ break;
+
+ // if a space of time is required between dequeues, check now
+ if ((dequeue_spacing_msec != 0) && ((now - last_dequeue) < dequeue_spacing_msec))
+ break;
+
+ Element<G>? h = queue.remove_at(0);
+ assert(head == h);
+
+ removed(head.item);
+ item = head.item;
+ }
+ callback(item);
last_dequeue = now;
// if a dequeue spacing is in place, it's a lock that only one item is dequeued per
@@ -207,65 +241,8 @@ public class TimedQueue<G> {
return true;
}
-}
-
-// HashTimedQueue uses a HashMap for quick lookups of elements via contains().
-public class HashTimedQueue<G> : TimedQueue<G> {
- private Gee.HashMap<G, int> item_count;
-
- public HashTimedQueue(uint hold_msec, DequeuedCallback<G> callback,
- owned Gee.HashDataFunc<G>? hash_func = null, owned Gee.EqualDataFunc<G>? equal_func = null,
- int priority = Priority.DEFAULT) {
- base (hold_msec, callback, (owned) equal_func, priority);
-
- item_count = new Gee.HashMap<G, int>((owned) hash_func, (owned) equal_func);
- }
-
- protected override void notify_dequeued(G item) {
- removed(item);
-
- base.notify_dequeued(item);
- }
-
- public override void clear() {
- item_count.clear();
-
- base.clear();
- }
-
- public override bool contains(G item) {
- return item_count.has_key(item);
- }
-
- public override bool enqueue(G item) {
- if (!base.enqueue(item))
- return false;
-
- item_count.set(item, item_count.has_key(item) ? item_count.get(item) + 1 : 1);
-
- return true;
- }
-
- public override bool enqueue_many(Gee.Collection<G> items) {
- if (!base.enqueue_many(items))
- return false;
-
- foreach (G item in items)
- item_count.set(item, item_count.has_key(item) ? item_count.get(item) + 1 : 1);
-
- return true;
- }
-
- public override bool remove_first(G item) {
- if (!base.remove_first(item))
- return false;
-
- removed(item);
-
- return true;
- }
-
+ // Not locking. This is always called with the lock hold
private void removed(G item) {
// item in question is either already removed
// or was never added, safe to do nothing here
diff --git a/src/Tombstone.vala b/src/Tombstone.vala
index 23cd984..2cae0c0 100644
--- a/src/Tombstone.vala
+++ b/src/Tombstone.vala
@@ -112,7 +112,10 @@ public class TombstoneSourceCollection : DatabaseSourceCollection {
private async void async_scan(DirectoryMonitor? monitor, Cancellable? cancellable) {
// search through all tombstones for missing files, which indicate the tombstone can go away
Marker marker = start_marking();
- foreach (DataObject object in get_all()) {
+
+ // There is an issue with modifying this list while this loop here is iterating it, source unknown
+ // Getting a copy of the list to work-around this (https://gitlab.gnome.org/GNOME/shotwell/-/issues/181)
+ foreach (DataObject object in get_dataset_copy().get_all()) {
Tombstone tombstone = (Tombstone) object;
File file = tombstone.get_file();
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index 463317b..20a6a58 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -1086,7 +1086,7 @@ public class ImportPage : CheckerboardPage {
progress_bar.set_text("");
progress_bar.visible = false;
- try_refreshing_camera(true);
+ Timeout.add_seconds(3, () => { try_refreshing_camera(true); return false; });
}
private void clear_all_import_sources() {
diff --git a/src/db/DatabaseTable.vala b/src/db/DatabaseTable.vala
index dea797a..5d84df2 100644
--- a/src/db/DatabaseTable.vala
+++ b/src/db/DatabaseTable.vala
@@ -29,10 +29,61 @@ public abstract class DatabaseTable {
public string table_name = null;
+ static Gee.HashMap<string, Regex> regex_map;
+
+ private static void regexp_replace(Sqlite.Context context, Sqlite.Value[] args) {
+ var pattern = args[0].to_text();
+ if (pattern == null) {
+ context.result_error("Missing regular expression", Sqlite.ERROR);
+ return;
+ }
+
+ var text = args[1].to_text();
+ if (text == null) {
+ return;
+ }
+
+ var replacement = args[2].to_text();
+ if (replacement == null) {
+ context.result_value(args[1]);
+ return;
+ }
+
+ Regex re;
+ if (regex_map == null) {
+ regex_map = new Gee.HashMap<string, Regex>();
+ }
+ if (regex_map.has_key(pattern)) {
+ re = regex_map[pattern];
+ } else {
+ try {
+ re = new Regex(pattern, 0, 0);
+ regex_map[pattern] = re;
+ } catch (Error err) {
+ context.result_error("Invalid pattern: %s".printf(err.message), Sqlite.ERROR);
+ return;
+ }
+ }
+
+ try {
+ var result = re.replace(text, -1, 0, replacement, RegexMatchFlags.DEFAULT);
+ context.result_text(result);
+ } catch (Error err) {
+ context.result_error("Replacement failed: %s".printf(err.message), Sqlite.ERROR);
+ }
+ }
+
+ [CCode (cname="SQLITE_DETERMINISTIC", cheader_filename="sqlite3.h")]
+ extern static int SQLITE_DETERMINISTIC;
+
private static void prepare_db(string filename) {
// Open DB.
int res = Sqlite.Database.open_v2(filename, out db, Sqlite.OPEN_READWRITE | Sqlite.OPEN_CREATE,
null);
+
+ db.create_function("regexp_replace", 3, Sqlite.UTF8 | SQLITE_DETERMINISTIC, null,
+ DatabaseTable.regexp_replace, null, null);
+
if (res != Sqlite.OK)
AppWindow.panic(_("Unable to open/create photo database %s: error code %d").printf(filename,
res));
diff --git a/src/db/Db.vala b/src/db/Db.vala
index 5072967..e537ee0 100644
--- a/src/db/Db.vala
+++ b/src/db/Db.vala
@@ -55,6 +55,14 @@ public VerifyResult verify_database(out string app_version, out int schema_versi
if (result != VerifyResult.OK)
return result;
}
+
+ try {
+ PhotoTable.clean_comments();
+ VideoTable.clean_comments();
+ } catch (DatabaseError err) {
+ debug("Ignoring database error while clean ing comments: %s", err.message);
+ }
+
return VerifyResult.OK;
}
diff --git a/src/db/PhotoTable.vala b/src/db/PhotoTable.vala
index 420b209..d74cbd1 100644
--- a/src/db/PhotoTable.vala
+++ b/src/db/PhotoTable.vala
@@ -1123,6 +1123,13 @@ public class PhotoTable : DatabaseTable {
throw_error("PhotoTable.upgrade_for_unset_timestamp", res);
}
}
+
+ public static void clean_comments() throws DatabaseError {
+ var result = db.exec("UPDATE PhotoTable SET comment = regexp_replace('^charset=\\w+\\s*', comment, '') WHERE comment like 'charset=%'");
+ if (result != Sqlite.OK) {
+ throw_error("Cleaning comments from charset", result);
+ }
+ }
}
diff --git a/src/db/VideoTable.vala b/src/db/VideoTable.vala
index 8af1278..753e02a 100644
--- a/src/db/VideoTable.vala
+++ b/src/db/VideoTable.vala
@@ -158,6 +158,8 @@ public class VideoTable : DatabaseTable {
if (res != Sqlite.DONE) {
if (res != Sqlite.CONSTRAINT)
throw_error("VideoTable.add", res);
+
+ return VideoID();
}
// fill in ignored fields with database values
@@ -480,5 +482,12 @@ public class VideoTable : DatabaseTable {
}
}
+ public static void clean_comments() throws DatabaseError {
+ var result = db.exec("UPDATE VideoTable SET comment = regexp_replace('^charset=\\w+\\s*', comment, '') WHERE comment like 'charset=%'");
+ if (result != Sqlite.OK) {
+ throw_error("Cleaning comments from charset", result);
+ }
+ }
+
}
diff --git a/src/dialogs/AdjustDateTimeDialog.vala b/src/dialogs/AdjustDateTimeDialog.vala
index f475773..2b6ae45 100644
--- a/src/dialogs/AdjustDateTimeDialog.vala
+++ b/src/dialogs/AdjustDateTimeDialog.vala
@@ -231,7 +231,7 @@ public class AdjustDateTimeDialog : Gtk.Dialog {
uint year, month, day;
calendar.get_date(out year, out month, out day);
- return new DateTime.local((int)year, (int)month + 1, (int)day, hour, (int)minute.get_value(), (int)second.get_value());
+ return new DateTime(Application.timezone, (int)year, (int)month + 1, (int)day, hour, (int)minute.get_value(), (int)second.get_value());
}
public bool execute(out TimeSpan time_shift, out bool keep_relativity,
diff --git a/src/dialogs/ExportDialog.vala b/src/dialogs/ExportDialog.vala
index 5a61dc4..1f0a581 100644
--- a/src/dialogs/ExportDialog.vala
+++ b/src/dialogs/ExportDialog.vala
@@ -71,7 +71,7 @@ public class ExportDialog : Gtk.Dialog {
format_combo = new Gtk.ComboBoxText();
format_add_option(UNMODIFIED_FORMAT_LABEL);
format_add_option(CURRENT_FORMAT_LABEL);
- foreach (PhotoFileFormat format in PhotoFileFormat.get_writeable()) {
+ foreach (PhotoFileFormat format in PhotoFileFormat.get_image_writeable()) {
format_add_option(format.get_properties().get_user_visible_name());
}
@@ -144,7 +144,7 @@ public class ExportDialog : Gtk.Dialog {
selection_ticker++;
}
- error("format_set_active_text: text '%s' isn't in combo box", text);
+ critical("format_set_active_text: text '%s' isn't in combo box", text);
}
private PhotoFileFormat get_specified_format() {
@@ -153,7 +153,7 @@ public class ExportDialog : Gtk.Dialog {
index = NUM_SPECIAL_FORMATS;
index -= NUM_SPECIAL_FORMATS;
- PhotoFileFormat[] writeable_formats = PhotoFileFormat.get_writeable();
+ PhotoFileFormat[] writeable_formats = PhotoFileFormat.get_image_writeable();
return writeable_formats[index];
}
@@ -276,7 +276,7 @@ public class ExportDialog : Gtk.Dialog {
if (format_combo.get_active_text() == UNMODIFIED_FORMAT_LABEL) {
// if the user wishes to export the media unmodified, then we just copy the original
- // files, so parameterizing size, quality, etc. is impossible -- these are all
+ // files, so parameterize size, quality, etc. is impossible -- these are all
// just as they are in the original file. In this case, we set the scale constraint to
// original and lock out all the controls
constraint_combo.set_active(0); /* 0 == original size */
@@ -303,7 +303,9 @@ public class ExportDialog : Gtk.Dialog {
constraint_combo.set_sensitive(true);
bool jpeg = get_specified_format() == PhotoFileFormat.JFIF;
quality_combo.sensitive = !original && jpeg;
- export_metadata.sensitive = true;
+
+ export_metadata.sensitive = get_specified_format().can_write_metadata();
+ export_metadata.active = get_specified_format().can_write_metadata();
}
}
diff --git a/src/dialogs/ProgressDialog.vala b/src/dialogs/ProgressDialog.vala
index 9368764..9d28551 100644
--- a/src/dialogs/ProgressDialog.vala
+++ b/src/dialogs/ProgressDialog.vala
@@ -37,6 +37,8 @@ public class ProgressDialog : Gtk.Window {
cancel_button = new Gtk.Button.with_mnemonic(Resources.CANCEL_LABEL);
cancel_button.clicked.connect(on_cancel);
delete_event.connect(on_window_closed);
+ } else {
+ delete_event.connect(hide_on_delete);
}
Gtk.Box hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
diff --git a/src/editing_tools/EditingTools.vala b/src/editing_tools/EditingTools.vala
index 3345a3f..594281e 100644
--- a/src/editing_tools/EditingTools.vala
+++ b/src/editing_tools/EditingTools.vala
@@ -2126,7 +2126,6 @@ public class RedeyeTool : EditingTool {
if (coord_in_rectangle((int)Math.lround(x * scale), (int)Math.lround(y * scale), bounds_rect)) {
- print("Motion in progress!!\n");
is_reticle_move_in_progress = true;
reticle_move_mouse_start_point.x = (int)Math.lround(x * scale);
reticle_move_mouse_start_point.y = (int)Math.lround(y * scale);
diff --git a/src/events/EventsBranch.vala b/src/events/EventsBranch.vala
index 0550eb7..1a3ac69 100644
--- a/src/events/EventsBranch.vala
+++ b/src/events/EventsBranch.vala
@@ -174,8 +174,10 @@ public class Events.Branch : Sidebar.Branch {
private void on_config_changed() {
bool value = Config.Facade.get_instance().get_events_sort_ascending();
- sort_ascending = value;
- reorder_all();
+ if (value != sort_ascending) {
+ sort_ascending = value;
+ reorder_all();
+ }
}
private void on_events_added_removed(Gee.Iterable<DataObject>? added,
@@ -456,7 +458,7 @@ public class Events.UndatedDirectoryEntry : Events.DirectoryEntry {
protected override Page create_page() {
return new SubEventsDirectoryPage(SubEventsDirectoryPage.DirectoryType.UNDATED,
- new DateTime.now_local());
+ new DateTime.now(Application.timezone));
}
}
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 280a50b..1b3f4b3 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -155,13 +155,14 @@ public class LibraryWindow : AppWindow {
sidebar_tree.selected_entry_removed.connect(on_sidebar_selected_entry_removed);
sidebar_tree.graft(library_branch, SidebarRootPosition.LIBRARY);
- sidebar_tree.graft(tags_branch, SidebarRootPosition.TAGS);
- sidebar_tree.graft(folders_branch, SidebarRootPosition.FOLDERS);
- sidebar_tree.graft(faces_branch, SidebarRootPosition.FACES);
- sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS);
sidebar_tree.graft(camera_branch, SidebarRootPosition.CAMERAS);
sidebar_tree.graft(saved_search_branch, SidebarRootPosition.SAVED_SEARCH);
+ sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS);
sidebar_tree.graft(import_roll_branch, SidebarRootPosition.IMPORT_ROLL);
+ sidebar_tree.graft(folders_branch, SidebarRootPosition.FOLDERS);
+ sidebar_tree.graft(faces_branch, SidebarRootPosition.FACES);
+ sidebar_tree.graft(tags_branch, SidebarRootPosition.TAGS);
+ sidebar_tree.finish();
properties_scheduler = new OneShotScheduler("LibraryWindow properties",
on_update_properties_now);
diff --git a/src/main.vala b/src/main.vala
index 25a0690..1ea1900 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -262,9 +262,9 @@ void library_exec(string[] mounts) {
message(" PNG : %s, gdk-pixbuf", png ? "yes" : "no");
message(" GIF : %s, gdk-pixbuf", gif ? "yes" : "no");
message(" TIFF : %s, gdk-pixbuf", tiff ? "yes" : "no");
- message(" JPEG XL: %s, gdk-pixbuf, %s meta-data", jxl ? "yes" : "no", can_read_bmff ? "yes" : "no");
- message(" AVIF : %s, gdk-pixbuf, %s meta-data", avif ? "yes" : "no", can_read_bmff ? "yes" : "no");
- message(" HEIF : %s, gdk-pixbuf, %s meta-data", heif ? "yes" : "no", can_read_bmff ? "yes" : "no");
+ message(" JPEG XL: %s, gdk-pixbuf, %s meta-data", jxl ? "yes" : "no", can_read_bmff ? "read" : "no");
+ message(" AVIF : %s, gdk-pixbuf, %s meta-data", avif ? "yes" : "no", can_read_bmff ? "read" : "no");
+ message(" HEIF : %s, gdk-pixbuf, %s meta-data", heif ? "yes" : "no", can_read_bmff ? "read" : "no");
debug("%lf seconds to Gtk.main()", startup_timer.elapsed());
@@ -346,7 +346,16 @@ void dump_metadata (string filename) {
void editing_exec(string filename, bool fullscreen) {
File initial_file = File.new_for_commandline_arg(filename);
-
+
+ if (!initial_file.get_uri().has_prefix("file://")) {
+ if (!initial_file.get_uri().has_prefix("trash://")) {
+ initial_file = File.new_for_path(initial_file.get_path());
+ } else {
+ var info = initial_file.query_info("standard::target-uri", FileQueryInfoFlags.NONE);
+ initial_file = File.new_for_uri(info.get_attribute_as_string("standard::target-uri"));
+ }
+ }
+
// preconfigure units
Direct.preconfigure(initial_file);
Db.preconfigure(null);
@@ -420,6 +429,8 @@ const OptionEntry[] entries = {
}
void main(string[] args) {
+ Application.timezone = new TimeZone.local();
+
// Call AppDirs init *before* calling Gtk.init_with_args, as it will strip the
// exec file from the array
AppDirs.init(args[0]);
@@ -540,7 +551,7 @@ void main(string[] args) {
foreach (var arg in args[1:args.length]) {
if (LibraryWindow.is_mount_uri_supported(arg)) {
mounts += arg;
- } else if (is_string_empty(filename) && !arg.contains("://")) {
+ } else if (is_string_empty(filename)) {
filename = arg;
}
}
@@ -563,9 +574,9 @@ void main(string[] args) {
message("Shotwell %s %s",
is_string_empty(filename) ? Resources.APP_LIBRARY_ROLE : Resources.APP_DIRECT_ROLE,
Resources.APP_VERSION);
- debug ("Shotwell is running in timezone %s", new
- DateTime.now_local().get_timezone_abbreviation ());
-
+
+ debug ("Shotwell is running in timezone %s", Application.timezone.get_identifier());
+ message ("Shotwell is runing inside %s", AppDirs.get_runtime().to_string());
// Have a filename here? If so, configure ourselves for direct
// mode, otherwise, default to library mode.
Application.init(!is_string_empty(filename));
@@ -591,6 +602,7 @@ void main(string[] args) {
// set up GLib environment
GLib.Environment.set_application_name(Resources.APP_TITLE);
+ GLib.Environment.set_prgname("org.gnome.Shotwell");
// in both the case of running as the library or an editor, Resources is always
// initialized
diff --git a/src/meson.build b/src/meson.build
index 25f967a..e6339f0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -41,7 +41,7 @@ face_sources = (['faces/FacesBranch.vala',
shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
gstreamer_pbu, gudev, gexiv2, gmodule, unity,
libraw, libexif, sw_plugin, webpdemux, webp, version,
- portal]
+ portal, math]
subdir('metadata')
subdir('publishing')
diff --git a/src/metadata/MetadataDateTime.vala b/src/metadata/MetadataDateTime.vala
index 9dae99b..648d44d 100644
--- a/src/metadata/MetadataDateTime.vala
+++ b/src/metadata/MetadataDateTime.vala
@@ -6,6 +6,7 @@ public errordomain MetadataDateTimeError {
public class MetadataDateTime {
private DateTime timestamp;
+ private static TimeZone local = new TimeZone.local();
public MetadataDateTime(DateTime timestamp) {
this.timestamp = timestamp;
@@ -63,7 +64,7 @@ public class MetadataDateTime {
if (tm.year <= 1900 || tm.month <= 0 || tm.day < 0 || tm.hour < 0 || tm.minute < 0 || tm.second < 0)
return false;
- timestamp = new DateTime.local(tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second);
+ timestamp = new DateTime(local, tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second);
return true;
}
diff --git a/src/photos/AvifSupport.vala b/src/photos/AvifSupport.vala
index 842f0fc..0df57a6 100644
--- a/src/photos/AvifSupport.vala
+++ b/src/photos/AvifSupport.vala
@@ -79,7 +79,7 @@ public class AvifWriter : PhotoFileWriter {
}
public override void write(Gdk.Pixbuf pixbuf, Jpeg.Quality quality) throws Error {
- pixbuf.save(get_filepath(), "avif", "quality", "90", null);
+ pixbuf.save(get_filepath(), "avif", "quality", quality.get_pct_text(), null);
}
}
@@ -89,7 +89,8 @@ public class AvifMetadataWriter : PhotoFileMetadataWriter {
}
public override void write_metadata(PhotoMetadata metadata) throws Error {
- metadata.write_to_file(get_file());
+ // TODO: Not yet implemented in gexiv2
+ // metadata.write_to_file(get_file());
}
}
@@ -99,6 +100,19 @@ public class AvifFileFormatDriver : PhotoFileFormatDriver {
public static void init() {
instance = new AvifFileFormatDriver();
AvifFileFormatProperties.init();
+
+ var formats = Gdk.Pixbuf.get_formats();
+ var seen = false;
+ can_write = true;
+
+ foreach (var format in formats) {
+ if (format.get_name() == "avif") {
+ seen = true;
+ can_write = can_write && format.is_writable();
+ }
+ }
+
+ can_write = can_write && seen;
}
public static AvifFileFormatDriver get_instance() {
@@ -112,13 +126,14 @@ public class AvifFileFormatDriver : PhotoFileFormatDriver {
public override PhotoFileReader create_reader(string filepath) {
return new AvifReader(filepath);
}
-
+
+ static bool can_write;
public override bool can_write_image() {
- return true;
+ return AvifFileFormatDriver.can_write;
}
public override bool can_write_metadata() {
- return true;
+ return false;
}
public override PhotoFileWriter? create_writer(string filepath) {
diff --git a/src/photos/HeifSupport.vala b/src/photos/HeifSupport.vala
index 58b9d9d..873e5a1 100644
--- a/src/photos/HeifSupport.vala
+++ b/src/photos/HeifSupport.vala
@@ -128,7 +128,7 @@ public class HeifFileFormatDriver : PhotoFileFormatDriver {
}
public override bool can_write_metadata() {
- return true;
+ return false;
}
public override PhotoFileWriter? create_writer(string filepath) {
diff --git a/src/photos/JfifSupport.vala b/src/photos/JfifSupport.vala
index fc43663..ceca827 100644
--- a/src/photos/JfifSupport.vala
+++ b/src/photos/JfifSupport.vala
@@ -190,7 +190,11 @@ public class JfifWriter : PhotoFileWriter {
}
public override void write(Gdk.Pixbuf pixbuf, Jpeg.Quality quality) throws Error {
- pixbuf.save(get_filepath(), "jpeg", "quality", quality.get_pct_text());
+ if (pixbuf.has_alpha) {
+ apply_alpha_channel(pixbuf).save(get_filepath(), "jpeg", "quality", quality.get_pct_text());
+ } else {
+ pixbuf.save(get_filepath(), "jpeg", "quality", quality.get_pct_text());
+ }
}
}
diff --git a/src/photos/PhotoFileFormat.vala b/src/photos/PhotoFileFormat.vala
index 4c69de3..f7abc33 100644
--- a/src/photos/PhotoFileFormat.vala
+++ b/src/photos/PhotoFileFormat.vala
@@ -251,6 +251,7 @@ public enum PhotoFileFormat {
return PhotoFileFormat.AVIF;
case "heif":
+ case "heic":
return PhotoFileFormat.HEIF;
case "jxl":
diff --git a/src/photos/PhotoMetadata.vala b/src/photos/PhotoMetadata.vala
index 3bf77d6..3bf7b37 100644
--- a/src/photos/PhotoMetadata.vala
+++ b/src/photos/PhotoMetadata.vala
@@ -1043,7 +1043,17 @@ public class PhotoMetadata : MediaMetadata {
};
public override string? get_comment() {
- return get_first_string_interpreted (COMMENT_TAGS);
+ var comment = get_first_string_interpreted (COMMENT_TAGS);
+ if (comment == null) {
+ return comment;
+ }
+
+ try {
+ var re = new Regex("^charset=\\w+\\s*");
+ return re.replace(comment, -1, 0, "", RegexMatchFlags.DEFAULT);
+ } catch (Error err) {
+ return comment;
+ }
}
public void set_comment(string? comment,
diff --git a/src/photos/WebPSupport.vala b/src/photos/WebPSupport.vala
index b467b24..543c889 100644
--- a/src/photos/WebPSupport.vala
+++ b/src/photos/WebPSupport.vala
@@ -209,8 +209,18 @@ private class WebpReader : PhotoFileReader {
uint8[] buffer;
FileUtils.get_data(this.get_filepath(), out buffer);
+ var features = WebP.BitstreamFeatures();
+ WebP.GetFeatures(buffer, out features);
+
+ if (features.has_animation) {
+ throw new IOError.INVALID_DATA("Animated WebP files are not yet supported");
+ }
+
int width, height;
var pixdata = WebP.DecodeRGBA(buffer, out width, out height);
+ if (pixdata == null) {
+ throw new IOError.INVALID_DATA("Failed to decode WebP file");
+ }
pixdata.length = width * height * 4;
return new Gdk.Pixbuf.from_data(pixdata, Gdk.Colorspace.RGB, true, 8, width, height, width * 4);
diff --git a/src/plugins/Plugins.vala b/src/plugins/Plugins.vala
index cfab7e8..7078680 100644
--- a/src/plugins/Plugins.vala
+++ b/src/plugins/Plugins.vala
@@ -300,13 +300,6 @@ public int compare_extension_point_names(ExtensionPoint a, ExtensionPoint b) {
return a.name.collate(b.name);
}
-private bool is_shared_library(File file) {
- string name, ext;
- disassemble_filename(file.get_basename(), out name, out ext);
-
- return ext == Module.SUFFIX;
-}
-
private void search_for_plugins(File dir) throws Error {
debug("Searching %s for plugins…", dir.get_path());
@@ -334,8 +327,9 @@ private void search_for_plugins(File dir) throws Error {
break;
case FileType.REGULAR:
- if (is_shared_library(file))
+ if (info.get_content_type() == "application/x-sharedlib") {
load_module(file);
+ }
break;
default:
diff --git a/src/plugins/SpitInterfaces.vala b/src/plugins/SpitInterfaces.vala
index 94e6f95..0eabdd1 100644
--- a/src/plugins/SpitInterfaces.vala
+++ b/src/plugins/SpitInterfaces.vala
@@ -172,7 +172,7 @@ public class PluggableInfo : Object {
public string? copyright {get; set; }
public string? license_blurp { get; set; default = _("LGPL v2.1 or later"); }
public string? license_url { get; set; default = "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html"; }
- public string? website_url {get; set; default = "https://wiki.gnome.org/Apps/Shotwell";}
+ public string? website_url {get; set; default = "https://shotwell-project.org";}
public string? website_name { get; set; default = _("Visit the Shotwell home page");}
public string? translators {get; set; default = _("translator-credits"); }
diff --git a/src/searches/SavedSearchDialog.vala b/src/searches/SavedSearchDialog.vala
index b08c8a8..b96a324 100644
--- a/src/searches/SavedSearchDialog.vala
+++ b/src/searches/SavedSearchDialog.vala
@@ -557,11 +557,11 @@ public class SavedSearchDialog : Gtk.Dialog {
}
private DateTime get_date_one() {
- return new DateTime.local(cal_one.year, cal_one.month + 1, cal_one.day, 0, 0, 0.0);
+ return new DateTime(Application.timezone, cal_one.year, cal_one.month + 1, cal_one.day, 0, 0, 0.0);
}
private DateTime get_date_two() {
- return new DateTime.local(cal_two.year, cal_two.month + 1, cal_two.day, 0, 0, 0.0);
+ return new DateTime(Application.timezone, cal_two.year, cal_two.month + 1, cal_two.day, 0, 0, 0.0);
}
private void set_date_one(DateTime date) {
diff --git a/src/sidebar/Tree.vala b/src/sidebar/Tree.vala
index aae81a0..b6c7f6f 100644
--- a/src/sidebar/Tree.vala
+++ b/src/sidebar/Tree.vala
@@ -75,6 +75,8 @@ public class Sidebar.Tree : Gtk.TreeView {
private bool is_internal_drag_in_progress = false;
private Sidebar.Entry? internal_drag_source_entry = null;
private Gtk.TreeRowReference? old_path_ref = null;
+ private Gee.ArrayList<unowned Branch> expand_to_child = new Gee.ArrayList<unowned Branch>();
+ private Gee.ArrayList<unowned Branch> expand_to_element = new Gee.ArrayList<unowned Branch>();
public signal void entry_selected(Sidebar.SelectableEntry selectable);
@@ -92,8 +94,7 @@ public class Sidebar.Tree : Gtk.TreeView {
public Tree(Gtk.TargetEntry[] target_entries, Gdk.DragAction actions,
ExternalDropHandler drop_handler) {
- set_model(store);
-
+
Gtk.TreeViewColumn text_column = new Gtk.TreeViewColumn();
text_column.set_expand(true);
Gtk.CellRendererPixbuf icon_renderer = new Gtk.CellRendererPixbuf();
@@ -155,6 +156,18 @@ public class Sidebar.Tree : Gtk.TreeView {
text_renderer.editing_canceled.disconnect(on_editing_canceled);
text_renderer.editing_started.disconnect(on_editing_started);
}
+
+ public void finish() {
+ set_model(store);
+ foreach (var branch in expand_to_child) {
+ expand_to_first_child(branch.get_root());
+ }
+ expand_to_child.clear();
+ foreach (var branch in expand_to_element) {
+ expand_to_entry(branch.get_root());
+ }
+ expand_to_element.clear();
+ }
public void icon_renderer_function(Gtk.CellLayout layout, Gtk.CellRenderer renderer, Gtk.TreeModel model, Gtk.TreeIter iter) {
EntryWrapper? wrapper = get_wrapper_at_iter(iter);
@@ -399,11 +412,14 @@ public class Sidebar.Tree : Gtk.TreeView {
if (branch.get_show_branch()) {
associate_branch(branch);
- if (branch.is_startup_expand_to_first_child())
- expand_to_first_child(branch.get_root());
+ if (branch.is_startup_expand_to_first_child()) {
+ expand_to_child.add(branch);
+
+ }
- if (branch.is_startup_open_grouping())
- expand_to_entry(branch.get_root());
+ if (branch.is_startup_open_grouping()) {
+ expand_to_element.add(branch);
+ }
}
branch.entry_added.connect(on_branch_entry_added);
@@ -587,9 +603,8 @@ public class Sidebar.Tree : Gtk.TreeView {
selected_wrapper = null;
Sidebar.Entry entry = wrapper.entry;
-
entry.pruned(this);
-
+
entry.sidebar_tooltip_changed.disconnect(on_sidebar_tooltip_changed);
entry.sidebar_icon_changed.disconnect(on_sidebar_icon_changed);
diff --git a/src/util/image.vala b/src/util/image.vala
index 5b78a50..e46233d 100644
--- a/src/util/image.vala
+++ b/src/util/image.vala
@@ -185,8 +185,39 @@ public Gdk.Point subtract_points(Gdk.Point p1, Gdk.Point p2) {
return result;
}
+Gdk.Pixbuf apply_alpha_channel(Gdk.Pixbuf source, bool strip = false) {
+ var dest = new Gdk.Pixbuf (source.colorspace, false, source.bits_per_sample, source.width, source.height);
+ uchar *sp = source.pixels;
+ uchar *dp = dest.pixels;
+
+ for (int j = 0; j < source.height; j++) {
+ uchar *s = sp;
+ uchar *d = dp;
+ uchar *end = s + 4 * source.width;
+ while (s < end) {
+ if (strip) {
+ d[0] = s[0];
+ d[1] = s[1];
+ d[2] = s[2];
+ } else {
+ double alpha = s[3] / 255.0;
+ d[0] = (uchar)Math.round((255.0 * (1.0 - alpha)) + (s[0] * alpha));
+ d[1] = (uchar)Math.round((255.0 * (1.0 - alpha)) + (s[1] * alpha));
+ d[2] = (uchar)Math.round((255.0 * (1.0 - alpha)) + (s[2] * alpha));
+ }
+ s += 4;
+ d += 3;
+ }
+
+ sp += source.rowstride;
+ dp += dest.rowstride;
+ }
+
+ return dest;
+}
+
// Converts XRGB/ARGB (Cairo)-formatted pixels to RGBA (GDK).
-void fix_cairo_pixbuf(Gdk.Pixbuf pixbuf) {
+void argb2rgba(Gdk.Pixbuf pixbuf) {
uchar *gdk_pixels = pixbuf.pixels;
for (int j = 0 ; j < pixbuf.height; ++j) {
uchar *p = gdk_pixels;
@@ -274,9 +305,8 @@ Gdk.Pixbuf rotate_arb(Gdk.Pixbuf source_pixbuf, double angle) {
// prepare the newly-drawn image for use by
// the rest of the pipeline.
- fix_cairo_pixbuf(dest_pixbuf);
-
- return dest_pixbuf;
+ argb2rgba(dest_pixbuf);
+ return apply_alpha_channel(dest_pixbuf, true);
}
/**
diff --git a/src/util/string.vala b/src/util/string.vala
index 976f8ee..521e2ba 100644
--- a/src/util/string.vala
+++ b/src/util/string.vala
@@ -177,30 +177,6 @@ public inline bool contains_char(string haystack, unichar needle) {
return haystack.index_of_char(needle) >= 0;
}
-public inline bool contains_str(string haystack, string needle) {
- return haystack.index_of(needle) >= 0;
-}
-
-public inline string? sliced_at(string str, int index) {
- return (index >= 0) ? str[index:str.length] : null;
-}
-
-public inline string? sliced_at_first_str(string haystack, string needle, int start_index = 0) {
- return sliced_at(haystack, haystack.index_of(needle, start_index));
-}
-
-public inline string? sliced_at_last_str(string haystack, string needle, int start_index = 0) {
- return sliced_at(haystack, haystack.last_index_of(needle, start_index));
-}
-
-public inline string? sliced_at_first_char(string haystack, unichar ch, int start_index = 0) {
- return sliced_at(haystack, haystack.index_of_char(ch, start_index));
-}
-
-public inline string? sliced_at_last_char(string haystack, unichar ch, int start_index = 0) {
- return sliced_at(haystack, haystack.last_index_of_char(ch, start_index));
-}
-
// Note that this method currently turns a word of all zeros into empty space ("000" -> "")
public string strip_leading_zeroes(string str) {
StringBuilder stripped = new StringBuilder();
@@ -227,7 +203,7 @@ public string remove_diacritics(string istring) {
case UnicodeType.FORMAT:
case UnicodeType.UNASSIGNED:
case UnicodeType.NON_SPACING_MARK:
- case UnicodeType.COMBINING_MARK:
+ case UnicodeType.SPACING_MARK:
case UnicodeType.ENCLOSING_MARK:
// Ignore those
continue;
diff --git a/src/video-support/AVIMetadataLoader.vala b/src/video-support/AVIMetadataLoader.vala
index 2b507e2..31945e9 100644
--- a/src/video-support/AVIMetadataLoader.vala
+++ b/src/video-support/AVIMetadataLoader.vala
@@ -1,5 +1,7 @@
public class AVIMetadataLoader {
+ public static TimeZone local = new TimeZone.local();
+
private File file = null;
// A numerical date string, i.e 2010:01:28 14:54:25
@@ -167,7 +169,7 @@ public class AVIMetadataLoader {
out min, out sec, out year)) {
return null; // Error
}
- parsed_date = new DateTime.local(year, month_from_string((string)monthstr), day, hour, min, sec);
+ parsed_date = new DateTime(AVIMetadataLoader.local, year, month_from_string((string)monthstr), day, hour, min, sec);
}
return parsed_date;