summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
commitb86540b743f1a87a163ffb811c8fe22a01fefa38 (patch)
treeb47cb3bb83c2377234226fb3987ab3320a987dd9 /src/library
parentac6e0b731b9f0b2efd392e3309a5c07e2a66adad (diff)
parente905d8e16eec152d19797937f13ba3cf4b8f8aca (diff)
Merge branch 'release/debian/0.32.1-1'debian/0.32.1-1
Diffstat (limited to 'src/library')
-rw-r--r--src/library/BackgroundProgressBar.vala109
-rw-r--r--src/library/LibraryWindow.vala175
-rw-r--r--src/library/TrashPage.vala4
3 files changed, 145 insertions, 143 deletions
diff --git a/src/library/BackgroundProgressBar.vala b/src/library/BackgroundProgressBar.vala
new file mode 100644
index 0000000..8ad7185
--- /dev/null
+++ b/src/library/BackgroundProgressBar.vala
@@ -0,0 +1,109 @@
+/* Copyright 2016 Software Freedom Conservancy Inc.
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+internal class BackgroundProgressBar : Gtk.ProgressBar {
+ public enum Priority {
+ NONE = 0,
+ STARTUP_SCAN = 35,
+ REALTIME_UPDATE = 40,
+ REALTIME_IMPORT = 50,
+ METADATA_WRITER = 30
+ }
+
+ public bool should_be_visible { get; private set; default = false; }
+
+#if UNITY_SUPPORT
+ // UnityProgressBar: init
+ private UnityProgressBar uniprobar = UnityProgressBar.get_instance();
+#endif
+
+ private const int PULSE_MSEC = 250;
+
+ public BackgroundProgressBar() {
+ Object(show_text: true);
+ }
+
+ private Priority current_priority = Priority.NONE;
+ private uint pulse_id = 0;
+
+ public void start(string label, Priority priority) {
+ if (priority < current_priority)
+ return;
+
+ stop(priority, false);
+
+ current_priority = priority;
+ set_text(label);
+ pulse();
+ should_be_visible = true;
+ pulse_id = Timeout.add(PULSE_MSEC, on_pulse_timeout);
+ }
+
+ public void stop(Priority priority, bool clear) {
+ if (priority < current_priority)
+ return;
+
+ if (pulse_id != 0) {
+ Source.remove(pulse_id);
+ pulse_id = 0;
+ }
+
+ if (clear)
+ this.clear(priority);
+ }
+
+ public bool update(string label, Priority priority, double count, double total) {
+ if (priority < current_priority)
+ return false;
+
+ stop(priority, false);
+
+ if (count <= 0.0 || total <= 0.0 || count >= total) {
+ clear(priority);
+
+ return false;
+ }
+
+ current_priority = priority;
+
+ double fraction = count / total;
+ set_fraction(fraction);
+ set_text(_("%s (%d%%)").printf(label, (int) (fraction * 100.0)));
+ should_be_visible = true;
+
+#if UNITY_SUPPORT
+ // UnityProgressBar: try to draw & set progress
+ uniprobar.set_visible(true);
+ uniprobar.set_progress(fraction);
+#endif
+
+ return true;
+ }
+
+ public void clear(Priority priority) {
+ if (priority < current_priority)
+ return;
+
+ stop(priority, false);
+
+ current_priority = 0;
+
+ set_fraction(0.0);
+ set_text("");
+ should_be_visible = false;
+
+#if UNITY_SUPPORT
+ // UnityProgressBar: reset
+ uniprobar.reset();
+#endif
+ }
+
+ private bool on_pulse_timeout() {
+ pulse();
+
+ return true;
+ }
+}
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 53b3a7b..849ae2e 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -24,18 +24,10 @@ public class LibraryWindow : AppWindow {
"mtp:"
};
- private const int BACKGROUND_PROGRESS_PULSE_MSEC = 250;
// If we're not operating on at least this many files, don't display the progress
// bar at all; otherwise, it'll go by too quickly, giving the appearance of a glitch.
- const int MIN_PROGRESS_BAR_FILES = 20;
-
- // these values reflect the priority various background operations have when reporting
- // progress to the LibraryWindow progress bar ... higher values give priority to those reports
- private const int STARTUP_SCAN_PROGRESS_PRIORITY = 35;
- private const int REALTIME_UPDATE_PROGRESS_PRIORITY = 40;
- private const int REALTIME_IMPORT_PROGRESS_PRIORITY = 50;
- private const int METADATA_WRITER_PROGRESS_PRIORITY = 30;
+ const int MIN_PROGRESS_BAR_FILES = 1;
// This lists the order of the toplevel items in the sidebar. New toplevel items should be
// added here in the position they should appear in the sidebar. To re-order, simply move
@@ -136,11 +128,12 @@ public class LibraryWindow : AppWindow {
private SearchFilterToolbar search_toolbar;
private Gtk.Box top_section = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
- private Gtk.Frame background_progress_frame = new Gtk.Frame(null);
- private Gtk.ProgressBar background_progress_bar = new Gtk.ProgressBar();
- private bool background_progress_displayed = false;
+ private Gtk.Revealer background_progress_frame = new Gtk.Revealer();
+ private BackgroundProgressBar background_progress_bar = new BackgroundProgressBar();
- private BasicProperties basic_properties = new BasicProperties();
+ // Instantiate later in constructor because the map support loads its icons in there and we need
+ // to have the global app instance available for that
+ private BasicProperties basic_properties;
private ExtendedProperties extended_properties = new ExtendedProperties();
private Gtk.Revealer extended_properties_revealer = new Gtk.Revealer();
@@ -149,14 +142,6 @@ public class LibraryWindow : AppWindow {
private Gtk.Box right_vbox;
private Gtk.Revealer toolbar_revealer = new Gtk.Revealer ();
- private int current_progress_priority = 0;
- private uint background_progress_pulse_id = 0;
-
-#if UNITY_SUPPORT
- //UnityProgressBar: init
- UnityProgressBar uniprobar = UnityProgressBar.get_instance();
-#endif
-
public LibraryWindow(ProgressMonitor progress_monitor) {
base();
@@ -180,11 +165,12 @@ public class LibraryWindow : AppWindow {
properties_scheduler = new OneShotScheduler("LibraryWindow properties",
on_update_properties_now);
-
+
// setup search bar and add its accelerators to the window
search_toolbar = new SearchFilterToolbar(search_actions);
// create the main layout & start at the Library page
+ basic_properties = new BasicProperties();
create_layout(library_branch.photos_entry.get_page());
// settings that should persist between sessions
@@ -217,8 +203,6 @@ public class LibraryWindow : AppWindow {
CameraTable.get_instance().camera_added.connect(on_camera_added);
- background_progress_bar.set_show_text(true);
-
// Need to re-install F8 here as it will overwrite the binding created
// by the menu
const string[] accels = { "<Primary>f", "F8", null };
@@ -282,7 +266,7 @@ public class LibraryWindow : AppWindow {
{ "CommonFind", on_find },
{ "CommonNewSearch", on_new_search },
- // Toogle actions
+ // Toggle actions
{ "CommonDisplayBasicProperties", on_action_toggle, null, "false", on_display_basic_properties },
{ "CommonDisplayExtendedProperties", on_action_toggle, null, "false", on_display_extended_properties },
@@ -770,7 +754,7 @@ public class LibraryWindow : AppWindow {
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" +
- "We recommend changing this in <span weight=\"bold\">Edit %s Preferences</span>.\n" +
+ "We recommend changing this in Edit %s Preferences.\n" +
"Do you want to continue importing photos?").printf("▸"),
_("_Import"), _("Library Location"), AppWindow.get_instance());
@@ -949,15 +933,9 @@ public class LibraryWindow : AppWindow {
return;
ImportPage page = (ImportPage) entry.get_page();
- File uri_file = File.new_for_uri(camera.uri);
// find the VFS mount point
- Mount mount = null;
- try {
- mount = uri_file.find_enclosing_mount(null);
- } catch (Error err) {
- // error means not mounted
- }
+ var mount = camera.get_mount();
// don't unmount mass storage cameras, as they are then unavailable to gPhoto
if (mount != null && !camera.uri.has_prefix("file://")) {
@@ -1012,135 +990,40 @@ public class LibraryWindow : AppWindow {
sort_events_action.change_state (event_sort_val);
}
-
- private void start_pulse_background_progress_bar(string label, int priority) {
- if (priority < current_progress_priority)
- return;
-
- stop_pulse_background_progress_bar(priority, false);
-
- current_progress_priority = priority;
-
- background_progress_bar.set_text(label);
- background_progress_bar.pulse();
- show_background_progress_bar();
-
- background_progress_pulse_id = Timeout.add(BACKGROUND_PROGRESS_PULSE_MSEC,
- on_pulse_background_progress_bar);
- }
-
- private bool on_pulse_background_progress_bar() {
- background_progress_bar.pulse();
-
- return true;
- }
-
- private void stop_pulse_background_progress_bar(int priority, bool clear) {
- if (priority < current_progress_priority)
- return;
-
- if (background_progress_pulse_id != 0) {
- Source.remove(background_progress_pulse_id);
- background_progress_pulse_id = 0;
- }
-
- if (clear)
- clear_background_progress_bar(priority);
- }
-
- private void update_background_progress_bar(string label, int priority, double count,
- double total) {
- if (priority < current_progress_priority)
- return;
-
- stop_pulse_background_progress_bar(priority, false);
-
- if (count <= 0.0 || total <= 0.0 || count >= total) {
- clear_background_progress_bar(priority);
-
- return;
- }
-
- current_progress_priority = priority;
-
- double fraction = count / total;
- background_progress_bar.set_fraction(fraction);
- background_progress_bar.set_text(_("%s (%d%%)").printf(label, (int) (fraction * 100.0)));
- show_background_progress_bar();
-
-#if UNITY_SUPPORT
- //UnityProgressBar: try to draw & set progress
- uniprobar.set_visible(true);
- uniprobar.set_progress(fraction);
-#endif
- }
-
- private void clear_background_progress_bar(int priority) {
- if (priority < current_progress_priority)
- return;
-
- stop_pulse_background_progress_bar(priority, false);
-
- current_progress_priority = 0;
-
- background_progress_bar.set_fraction(0.0);
- background_progress_bar.set_text("");
- hide_background_progress_bar();
-
-#if UNITY_SUPPORT
- //UnityProgressBar: reset
- uniprobar.reset();
-#endif
- }
-
- private void show_background_progress_bar() {
- if (!background_progress_displayed) {
- top_section.pack_end(background_progress_frame, false, false, 0);
- background_progress_frame.show_all();
- background_progress_displayed = true;
- }
- }
-
- private void hide_background_progress_bar() {
- if (background_progress_displayed) {
- top_section.remove(background_progress_frame);
- background_progress_displayed = false;
- }
- }
-
+
private void on_library_monitor_discovery_started() {
- start_pulse_background_progress_bar(_("Updating library…"), STARTUP_SCAN_PROGRESS_PRIORITY);
+ background_progress_bar.start(_("Updating library…"), BackgroundProgressBar.Priority.STARTUP_SCAN);
}
private void on_library_monitor_discovery_completed() {
- stop_pulse_background_progress_bar(STARTUP_SCAN_PROGRESS_PRIORITY, true);
+ background_progress_bar.stop(BackgroundProgressBar.Priority.STARTUP_SCAN, true);
}
private void on_library_monitor_auto_update_progress(int completed_files, int total_files) {
if (total_files < MIN_PROGRESS_BAR_FILES)
- clear_background_progress_bar(REALTIME_UPDATE_PROGRESS_PRIORITY);
+ background_progress_bar.clear(BackgroundProgressBar.Priority.REALTIME_UPDATE);
else {
- update_background_progress_bar(_("Updating library…"), REALTIME_UPDATE_PROGRESS_PRIORITY,
+ background_progress_bar.update(_("Updating library…"), BackgroundProgressBar.Priority.REALTIME_UPDATE,
completed_files, total_files);
}
}
private void on_library_monitor_auto_import_preparing() {
- start_pulse_background_progress_bar(_("Preparing to auto-import photos…"),
- REALTIME_IMPORT_PROGRESS_PRIORITY);
+ background_progress_bar.start(_("Preparing to auto-import photos…"),
+ BackgroundProgressBar.Priority.REALTIME_UPDATE);
}
private void on_library_monitor_auto_import_progress(uint64 completed_bytes, uint64 total_bytes) {
- update_background_progress_bar(_("Auto-importing photos…"),
- REALTIME_IMPORT_PROGRESS_PRIORITY, completed_bytes, total_bytes);
+ background_progress_bar.update(_("Auto-importing photos…"),
+ BackgroundProgressBar.Priority.REALTIME_UPDATE, completed_bytes, total_bytes);
}
private void on_metadata_writer_progress(uint completed, uint total) {
if (total < MIN_PROGRESS_BAR_FILES)
- clear_background_progress_bar(METADATA_WRITER_PROGRESS_PRIORITY);
+ background_progress_bar.clear(BackgroundProgressBar.Priority.METADATA_WRITER);
else {
- update_background_progress_bar(_("Writing metadata to files…"),
- METADATA_WRITER_PROGRESS_PRIORITY, completed, total);
+ background_progress_bar.update(_("Writing metadata to files…"),
+ BackgroundProgressBar.Priority.METADATA_WRITER, completed, total);
}
}
@@ -1153,17 +1036,22 @@ public class LibraryWindow : AppWindow {
background_progress_frame.set_border_width(2);
background_progress_frame.add(background_progress_bar);
- background_progress_frame.get_style_context().remove_class("frame");
+ background_progress_frame.set_transition_type(Gtk.RevealerTransitionType.SLIDE_UP);
+ background_progress_frame.halign = Gtk.Align.FILL;
+ background_progress_frame.valign = Gtk.Align.END;
+ background_progress_frame.vexpand = false;
+ background_progress_frame.hexpand = true;
+ background_progress_bar.bind_property("should-be-visible", background_progress_frame, "reveal-child", GLib.BindingFlags.DEFAULT);
// pad the bottom frame (properties)
basic_properties.halign = Gtk.Align.FILL;
basic_properties.valign = Gtk.Align.CENTER;
basic_properties.hexpand = true;
- basic_properties.vexpand = false;
+ basic_properties.vexpand = true;
basic_properties.margin_top = 10;
basic_properties.margin_bottom = 10;
basic_properties.margin_start = 6;
- basic_properties.margin_end = 0;
+ basic_properties.margin_end = 6;
bottom_frame.add(basic_properties);
bottom_frame.get_style_context().remove_class("frame");
@@ -1171,6 +1059,7 @@ public class LibraryWindow : AppWindow {
// "attach" the progress bar to the sidebar tree, so the movable ridge is to resize the
// top two and the basic information pane
top_section.pack_start(scrolled_sidebar, true, true, 0);
+ top_section.pack_end(background_progress_frame, false, false, 0);
sidebar_paned.pack1(top_section, true, false);
sidebar_paned.pack2(bottom_frame, false, false);
diff --git a/src/library/TrashPage.vala b/src/library/TrashPage.vala
index 35dee4e..1e72f07 100644
--- a/src/library/TrashPage.vala
+++ b/src/library/TrashPage.vala
@@ -105,6 +105,10 @@ public class TrashPage : CheckerboardPage {
protected override string get_view_empty_message() {
return _("Trash is empty");
}
+
+ protected override string get_view_empty_icon() {
+ return "user-trash-symbolic";
+ }
private void on_delete() {
remove_from_app((Gee.Collection<MediaSource>) get_view().get_selected_sources(), _("Delete"),