mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-14 17:32:00 +01:00
fix(gui): a photo viewer bar that reads on any photo
The bar's white-on-translucent-white buttons vanished over a bright photo,
and eight look-alike icons, a floppy disk and an open-document glyph among
them, left the user guessing. The bar now holds the favorite, the details
and a menu with Slideshow, Save a Copy, Open With, Add to Album, Show on
Map and Move to Trash, on dark discs that read over white and black
alike.
A shot stored as more than one file shows a labelled pill ("RAW", "Live",
"2 of 3") instead of a paged icon, lit while the second file is shown.
The title is the localized full date instead of a raw timestamp.
Delete asks first, as the grid does: the dialog opens over the viewer,
and the album prompts can open there too. Alt+Left closes the viewer and
F10 opens the menu; the shortcuts window lists F5, F10 and Alt+Left.
This commit is contained in:
1 parent
5c184013f1
commit
5f0b15fe70
16 files changed
+2312
-2037
No files matched your search
@@ -61,14 +61,18 @@ scale.browser-status-meter trough { min-width: 140px; min-height: 6px; }
|
||||
|
||||
/* Photo viewer: always light-on-dark, whatever the system style */
|
||||
.photo-viewer-window { background-color: #111014; }
|
||||
.viewer-top-bar { background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0)); padding: 10px 16px 28px 20px; color: white; }
|
||||
.viewer-top-bar { background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.45) 60%, rgba(0, 0, 0, 0)); padding: 10px 16px 40px 20px; color: white; }
|
||||
.viewer-title { font-weight: 700; font-size: 1.05rem; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); color: white; }
|
||||
.viewer-counter { font-size: 0.8rem; color: rgba(255, 255, 255, 0.72); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
|
||||
.viewer-action-btn { color: white; background-color: rgba(255, 255, 255, 0.12); border-radius: 50%; min-width: 34px; min-height: 34px; margin-left: 4px; }
|
||||
.viewer-action-btn:hover { background-color: rgba(255, 255, 255, 0.28); color: white; }
|
||||
/* Dark discs with a white glyph read on a white photo as well as on a black one. */
|
||||
.viewer-action-btn { color: white; background-color: rgba(0, 0, 0, 0.5); border-radius: 50%; min-width: 36px; min-height: 36px; margin-left: 4px; -gtk-icon-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
|
||||
.viewer-action-btn:hover { background-color: rgba(0, 0, 0, 0.75); color: white; }
|
||||
.viewer-action-btn:checked { background-color: var(--accent-bg-color); color: var(--accent-fg-color); }
|
||||
.viewer-close-btn { background-color: rgba(255, 255, 255, 0.2); margin-left: 10px; }
|
||||
.viewer-close-btn { margin-left: 12px; }
|
||||
.viewer-close-btn:hover { background-color: var(--destructive-bg-color); color: var(--destructive-fg-color); }
|
||||
.viewer-group-pill { color: white; background-color: rgba(0, 0, 0, 0.5); border-radius: 999px; min-height: 36px; padding: 0 14px; font-weight: 700; font-size: 0.85rem; }
|
||||
.viewer-group-pill:hover { background-color: rgba(0, 0, 0, 0.75); color: white; }
|
||||
.viewer-group-pill.lit { background-color: var(--accent-bg-color); color: var(--accent-fg-color); }
|
||||
.viewer-nav-btn { background-color: rgba(0, 0, 0, 0.45); color: white; margin: 20px; min-width: 44px; min-height: 44px; border-radius: 50%; opacity: 0.7; transition: opacity 150ms ease, background-color 150ms ease; }
|
||||
.viewer-nav-btn:hover { background-color: rgba(0, 0, 0, 0.85); color: white; opacity: 1; }
|
||||
.viewer-nav-btn:disabled { opacity: 0; }
|
||||
|
||||
@@ -1339,7 +1339,7 @@ fn install_window_actions(ui: &Rc<Ui>, window: &adw::ApplicationWindow) {
|
||||
// The Albums view's New Album button.
|
||||
let new_album = gio::SimpleAction::new("new-album", None);
|
||||
let ui_album = ui.clone();
|
||||
new_album.connect_activate(move |_, _| prompt_new_album(&ui_album, Vec::new()));
|
||||
new_album.connect_activate(move |_, _| prompt_new_album(&ui_album, Vec::new(), None));
|
||||
window.add_action(&new_album);
|
||||
|
||||
let shortcuts = gio::SimpleAction::new("shortcuts", None);
|
||||
@@ -1560,8 +1560,10 @@ fn show_shortcuts(window: &adw::ApplicationWindow) {
|
||||
("Home End", gettext_noop("First / last photo")),
|
||||
("i", gettext_noop("Show details")),
|
||||
("f", gettext_noop("Fullscreen")),
|
||||
("F5", gettext_noop("Slideshow")),
|
||||
("F10", gettext_noop("More")),
|
||||
("Delete", gettext_noop("Move to Trash")),
|
||||
("Escape", gettext_noop("Close")),
|
||||
("Escape <Alt>Left", gettext_noop("Close")),
|
||||
],
|
||||
),
|
||||
];
|
||||
@@ -2032,6 +2034,33 @@ mod tests {
|
||||
assert!(next_group_member(&[], "jpeg").is_none());
|
||||
}
|
||||
|
||||
/// The pill names what kind of shot it switches through, and lights up
|
||||
/// on the file that is not the shot's main one.
|
||||
#[test]
|
||||
fn the_group_pill_names_the_kind_of_shot() {
|
||||
let pair = [
|
||||
member("jpeg", Some("IMG_1.JPG"), PhotoKind::Photo),
|
||||
member("raw", Some("IMG_1.CR2"), PhotoKind::Raw),
|
||||
];
|
||||
assert_eq!(group_pill(&pair, "jpeg"), Some(("RAW".into(), false)));
|
||||
assert_eq!(group_pill(&pair, "raw"), Some(("RAW".into(), true)));
|
||||
|
||||
let live = [
|
||||
member("still", Some("IMG_2.HEIC"), PhotoKind::Photo),
|
||||
member("clip", Some("IMG_2.MOV"), PhotoKind::Video),
|
||||
];
|
||||
assert_eq!(group_pill(&live, "still"), Some(("Live".into(), false)));
|
||||
assert_eq!(group_pill(&live, "clip"), Some(("Live".into(), true)));
|
||||
|
||||
let burst = [
|
||||
member("a", None, PhotoKind::Photo),
|
||||
member("b", None, PhotoKind::Photo),
|
||||
member("c", None, PhotoKind::Photo),
|
||||
];
|
||||
assert_eq!(group_pill(&burst, "b"), Some(("2 of 3".into(), false)));
|
||||
assert_eq!(group_pill(&burst, "elsewhere"), None);
|
||||
}
|
||||
|
||||
/// The switch names what it will show; a file whose name the daemon has not
|
||||
/// resolved still gets a sentence rather than a blank.
|
||||
#[test]
|
||||
|
||||
@@ -225,12 +225,13 @@ fn show_album_menu(ui: &Rc<Ui>, album: &AlbumInfo, anchor: >k4::Widget, x: f64
|
||||
/// while the entry is blank.
|
||||
fn prompt_album_name(
|
||||
ui: &Rc<Ui>,
|
||||
parent: Option<gtk4::Window>,
|
||||
heading: &str,
|
||||
action: &str,
|
||||
current: &str,
|
||||
on_name: impl Fn(String) + 'static,
|
||||
) {
|
||||
let win = ui_window(ui);
|
||||
let win = parent.or_else(|| ui_window(ui));
|
||||
let dialog = adw::AlertDialog::builder().heading(heading).build();
|
||||
let group = adw::PreferencesGroup::new();
|
||||
let row = adw::EntryRow::builder()
|
||||
@@ -260,10 +261,12 @@ fn prompt_album_name(
|
||||
}
|
||||
|
||||
/// Ask for a name and create an album, then add `photos` to it, if any.
|
||||
pub(crate) fn prompt_new_album(ui: &Rc<Ui>, photos: Vec<String>) {
|
||||
///
|
||||
/// The dialogs open over `parent`, or over the main window without one.
|
||||
pub(crate) fn prompt_new_album(ui: &Rc<Ui>, photos: Vec<String>, parent: Option<gtk4::Window>) {
|
||||
let ui_c = ui.clone();
|
||||
let (heading, action) = (gettext("New Album"), gettext("Create"));
|
||||
prompt_album_name(ui, &heading, &action, "", move |name| {
|
||||
prompt_album_name(ui, parent, &heading, &action, "", move |name| {
|
||||
let rx = spawn_request(ui_c.dirs.control_socket(), Request::CreateAlbum { name });
|
||||
let ui = ui_c.clone();
|
||||
let photos = photos.clone();
|
||||
@@ -296,7 +299,7 @@ pub(crate) fn prompt_new_album(ui: &Rc<Ui>, photos: Vec<String>) {
|
||||
fn prompt_rename_album(ui: &Rc<Ui>, album: &AlbumInfo) {
|
||||
let (ui_c, uid) = (ui.clone(), album.uid.clone());
|
||||
let (heading, action) = (gettext("Rename Album"), gettext("Rename"));
|
||||
prompt_album_name(ui, &heading, &action, &album.name, move |name| {
|
||||
prompt_album_name(ui, None, &heading, &action, &album.name, move |name| {
|
||||
run_album_request(
|
||||
&ui_c,
|
||||
Request::RenameAlbum {
|
||||
@@ -368,7 +371,7 @@ fn reload_album_grid(ui: &Rc<Ui>) {
|
||||
}
|
||||
|
||||
/// Offer our own albums to add `photos` to, plus a new one.
|
||||
pub(crate) fn prompt_add_to_album(ui: &Rc<Ui>, photos: Vec<String>) {
|
||||
pub(crate) fn prompt_add_to_album(ui: &Rc<Ui>, photos: Vec<String>, parent: Option<gtk4::Window>) {
|
||||
let rx = spawn_request(ui.dirs.control_socket(), Request::PhotoAlbums);
|
||||
let ui = ui.clone();
|
||||
glib::spawn_future_local(async move {
|
||||
@@ -390,7 +393,7 @@ pub(crate) fn prompt_add_to_album(ui: &Rc<Ui>, photos: Vec<String>) {
|
||||
}
|
||||
};
|
||||
if albums.is_empty() {
|
||||
prompt_new_album(&ui, photos);
|
||||
prompt_new_album(&ui, photos, parent);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -436,11 +439,11 @@ pub(crate) fn prompt_add_to_album(ui: &Rc<Ui>, photos: Vec<String>) {
|
||||
add_to_album(&ui_c, album.uid.clone(), photos_c.clone());
|
||||
}
|
||||
});
|
||||
let ui_c = ui.clone();
|
||||
let (ui_c, parent_c) = (ui.clone(), parent.clone());
|
||||
dialog.connect_response(Some("new"), move |_, _| {
|
||||
prompt_new_album(&ui_c, photos.clone())
|
||||
prompt_new_album(&ui_c, photos.clone(), parent_c.clone())
|
||||
});
|
||||
dialog.present(ui_window(&ui).as_ref());
|
||||
dialog.present(parent.or_else(|| ui_window(&ui)).as_ref());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ pub(crate) struct Viewer {
|
||||
/// uses for its pin switch, so painting a photo doesn't fire a round-trip.
|
||||
pub(crate) favorite: gtk4::ToggleButton,
|
||||
pub(crate) favorite_suppress: Cell<bool>,
|
||||
/// The button that switches between the files of one shot, and the files it
|
||||
/// The pill that switches between the files of one shot, and the files it
|
||||
/// switches between (the JPEG and the RAW of a photo, a live photo and its
|
||||
/// clip). Empty, and the button hidden, for a photo stored as one file.
|
||||
/// clip). Empty, and the pill hidden, for a photo stored as one file.
|
||||
pub(crate) group_btn: gtk4::Button,
|
||||
pub(crate) group: RefCell<Vec<PhotoItem>>,
|
||||
/// uid of the photo currently on screen.
|
||||
@@ -83,10 +83,14 @@ pub(crate) struct Viewer {
|
||||
pub(crate) chrome: Vec<gtk4::Revealer>,
|
||||
pub(crate) chrome_hover: Cell<bool>,
|
||||
pub(crate) chrome_source: RefCell<Option<glib::SourceId>>,
|
||||
/// The slideshow toggle; the timer that moves it on; and whether it put
|
||||
/// the window in fullscreen, so stopping it only leaves a fullscreen it
|
||||
/// The ⋮ button, and whether its menu is open, which keeps the controls
|
||||
/// up the way resting the pointer on them does.
|
||||
pub(crate) more: gtk4::Button,
|
||||
pub(crate) menu_open: Cell<bool>,
|
||||
/// Whether a slideshow runs; the timer that moves it on; and whether it
|
||||
/// put the window in fullscreen, so stopping it only leaves a fullscreen it
|
||||
/// entered itself.
|
||||
pub(crate) slideshow: gtk4::ToggleButton,
|
||||
pub(crate) slideshow: Cell<bool>,
|
||||
pub(crate) slide_source: RefCell<Option<glib::SourceId>>,
|
||||
pub(crate) slide_fullscreened: Cell<bool>,
|
||||
}
|
||||
@@ -163,6 +167,14 @@ fn load_photo_group(ui: &Rc<Ui>, viewer: &Rc<Viewer>, uid: &str) {
|
||||
.group_btn
|
||||
.set_tooltip_text(Some(&member_tooltip(next)));
|
||||
}
|
||||
if let Some((label, lit)) = group_pill(&items, &uid) {
|
||||
viewer.group_btn.set_label(&label);
|
||||
if lit {
|
||||
viewer.group_btn.add_css_class("lit");
|
||||
} else {
|
||||
viewer.group_btn.remove_css_class("lit");
|
||||
}
|
||||
}
|
||||
*viewer.group.borrow_mut() = items;
|
||||
viewer.group_btn.set_visible(true);
|
||||
});
|
||||
@@ -175,6 +187,34 @@ pub(crate) fn next_group_member<'a>(members: &'a [PhotoItem], uid: &str) -> Opti
|
||||
members.get((at + 1) % members.len())
|
||||
}
|
||||
|
||||
/// What the group pill reads for the shot whose files are `members`, with
|
||||
/// `uid` on screen, and whether it is lit. A raw pair reads "RAW", lit while
|
||||
/// the raw file is shown; a live photo reads "Live", lit while its clip plays;
|
||||
/// a burst counts its frames.
|
||||
pub(crate) fn group_pill(members: &[PhotoItem], uid: &str) -> Option<(String, bool)> {
|
||||
let at = members.iter().position(|item| item.uid == uid)?;
|
||||
let shown = members[at].kind;
|
||||
if members.iter().any(|item| item.kind == PhotoKind::Raw) {
|
||||
// Translators: badge on a photo tile whose shot includes a raw camera file.
|
||||
return Some((gettext("RAW"), shown == PhotoKind::Raw));
|
||||
}
|
||||
if members.len() == 2 && members.iter().any(|item| item.kind == PhotoKind::Video) {
|
||||
// Translators: the switch between a live photo and its short clip in the photo viewer.
|
||||
return Some((pgettext("live photo", "Live"), shown == PhotoKind::Video));
|
||||
}
|
||||
Some((
|
||||
// Translators: the lightbox counter, such as "12 of 340"; {position} is the photo's place, {total} how many there are.
|
||||
gettext_f(
|
||||
"{position} of {total}",
|
||||
&[
|
||||
("position", &thousands(at + 1)),
|
||||
("total", &thousands(members.len())),
|
||||
],
|
||||
),
|
||||
false,
|
||||
))
|
||||
}
|
||||
|
||||
/// What to call one file of a shot: its name, or its kind when the daemon has
|
||||
/// not resolved a name for it.
|
||||
pub(crate) fn member_label(item: &PhotoItem) -> String {
|
||||
@@ -341,13 +381,13 @@ pub(crate) fn load_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>, uid: String) {
|
||||
/// Start the slideshow: fullscreen, controls out of the way, and the photo on
|
||||
/// screen counted down once it has loaded.
|
||||
fn start_slideshow(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
if viewer.slideshow.replace(true) {
|
||||
return;
|
||||
}
|
||||
if !viewer.window.is_fullscreen() {
|
||||
viewer.window.fullscreen();
|
||||
viewer.slide_fullscreened.set(true);
|
||||
}
|
||||
viewer
|
||||
.slideshow
|
||||
.set_icon_name("media-playback-pause-symbolic");
|
||||
hide_chrome(viewer);
|
||||
if !viewer.loading.get() {
|
||||
arm_slide(ui, viewer);
|
||||
@@ -356,13 +396,19 @@ fn start_slideshow(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
|
||||
/// Stop the slideshow, leaving fullscreen only if the slideshow entered it.
|
||||
fn stop_slideshow(viewer: &Rc<Viewer>) {
|
||||
viewer.slideshow.set(false);
|
||||
disarm_slide(viewer);
|
||||
if viewer.slide_fullscreened.replace(false) {
|
||||
viewer.window.unfullscreen();
|
||||
}
|
||||
viewer.slideshow.set_icon_name("pdfs-slideshow-symbolic");
|
||||
if viewer.slideshow.is_active() {
|
||||
viewer.slideshow.set_active(false);
|
||||
}
|
||||
|
||||
/// Start the slideshow, or stop the one running.
|
||||
fn toggle_slideshow(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
if viewer.slideshow.get() {
|
||||
stop_slideshow(viewer);
|
||||
} else {
|
||||
start_slideshow(ui, viewer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +416,7 @@ fn stop_slideshow(viewer: &Rc<Viewer>) {
|
||||
/// [`SLIDESHOW_INTERVAL`] for a still, once it has played through for a video.
|
||||
fn arm_slide(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
disarm_slide(viewer);
|
||||
if !viewer.slideshow.is_active() {
|
||||
if !viewer.slideshow.get() {
|
||||
return;
|
||||
}
|
||||
let playing_video = viewer.media.visible_child_name().as_deref() == Some("video");
|
||||
@@ -790,7 +836,7 @@ fn show_chrome(viewer: &Rc<Viewer>) {
|
||||
};
|
||||
// This timer has fired, so its id must not be removed again.
|
||||
viewer.chrome_source.borrow_mut().take();
|
||||
if !viewer.chrome_hover.get() {
|
||||
if !viewer.chrome_hover.get() && !viewer.menu_open.get() {
|
||||
hide_chrome(&viewer);
|
||||
}
|
||||
});
|
||||
@@ -983,13 +1029,24 @@ pub(crate) fn position_label(index: u32, loaded: u32, more: bool, total: Option<
|
||||
}
|
||||
}
|
||||
|
||||
/// The lightbox's title: when the photo was taken, as "Wednesday, October 7,
|
||||
/// 2026, 13:42".
|
||||
fn photo_title(capture_time: i64) -> String {
|
||||
let title = dates::full(capture_time);
|
||||
if title.is_empty() {
|
||||
gettext("Unknown Date")
|
||||
} else {
|
||||
title
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the lightbox's title (the photo's date) and its "12 of 340" counter.
|
||||
fn show_photo_position(ui: &Rc<Ui>, viewer: &Rc<Viewer>, index: u32, capture_time: i64) {
|
||||
let loaded = ui.gallery.model.n_items();
|
||||
let more = ui.gallery.has_more.get();
|
||||
viewer.prev.set_sensitive(index > 0);
|
||||
viewer.next.set_sensitive(index + 1 < loaded || more);
|
||||
viewer.title.set_label(&format_capture_time(capture_time));
|
||||
viewer.title.set_label(&photo_title(capture_time));
|
||||
viewer
|
||||
.counter
|
||||
.set_label(&position_label(index, loaded, more, gallery_total(ui)));
|
||||
@@ -1125,22 +1182,18 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
favorite_btn.add_css_class("flat");
|
||||
favorite_btn.add_css_class("viewer-action-btn");
|
||||
|
||||
let slideshow_btn = gtk4::ToggleButton::builder()
|
||||
.icon_name("pdfs-slideshow-symbolic")
|
||||
.tooltip_text(gettext("Slideshow (F5)"))
|
||||
.valign(gtk4::Align::Center)
|
||||
.build();
|
||||
slideshow_btn.add_css_class("flat");
|
||||
slideshow_btn.add_css_class("viewer-action-btn");
|
||||
|
||||
// Only shown for a shot stored as more than one file; `load_photo_group`
|
||||
// decides that per photo.
|
||||
let group_btn = action("view-paged-symbolic", &gettext("Other files of this photo"));
|
||||
group_btn.set_visible(false);
|
||||
// decides that per photo and labels it ("RAW", "Live", "2 of 3").
|
||||
let group_btn = gtk4::Button::builder()
|
||||
.valign(gtk4::Align::Center)
|
||||
.visible(false)
|
||||
.build();
|
||||
group_btn.add_css_class("flat");
|
||||
group_btn.add_css_class("viewer-group-pill");
|
||||
|
||||
let download_btn = action("document-save-symbolic", &gettext("Save a Copy…"));
|
||||
let delete_btn = action("user-trash-symbolic", &gettext("Move to Trash (Delete)"));
|
||||
let open_ext_btn = action("document-open-symbolic", &gettext("Open With…"));
|
||||
// Everything used less often than the favorite and the details sits in
|
||||
// one menu, named in words rather than in icons.
|
||||
let more_btn = action("view-more-symbolic", &gettext("More"));
|
||||
let close_btn = action("window-close-symbolic", &gettext("Close (Esc)"));
|
||||
close_btn.add_css_class("viewer-close-btn");
|
||||
|
||||
@@ -1150,10 +1203,7 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
top_bar.append(&group_btn);
|
||||
top_bar.append(&favorite_btn);
|
||||
top_bar.append(&info_toggle);
|
||||
top_bar.append(&slideshow_btn);
|
||||
top_bar.append(&download_btn);
|
||||
top_bar.append(&delete_btn);
|
||||
top_bar.append(&open_ext_btn);
|
||||
top_bar.append(&more_btn);
|
||||
top_bar.append(&close_btn);
|
||||
let top_reveal = fade(top_bar.upcast_ref(), gtk4::Align::Fill, gtk4::Align::Start);
|
||||
overlay.add_overlay(&top_reveal);
|
||||
@@ -1279,7 +1329,9 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
chrome: vec![top_reveal.clone(), prev_reveal.clone(), next_reveal.clone()],
|
||||
chrome_hover: Cell::new(false),
|
||||
chrome_source: RefCell::new(None),
|
||||
slideshow: slideshow_btn.clone(),
|
||||
more: more_btn.clone(),
|
||||
menu_open: Cell::new(false),
|
||||
slideshow: Cell::new(false),
|
||||
slide_source: RefCell::new(None),
|
||||
slide_fullscreened: Cell::new(false),
|
||||
});
|
||||
@@ -1457,36 +1509,14 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
}
|
||||
});
|
||||
|
||||
let ui_slides = ui.clone();
|
||||
let viewer_slides = Rc::downgrade(&viewer);
|
||||
slideshow_btn.connect_toggled(move |toggle| {
|
||||
let Some(viewer_slides) = viewer_slides.upgrade() else {
|
||||
return;
|
||||
};
|
||||
if toggle.is_active() {
|
||||
start_slideshow(&ui_slides, &viewer_slides);
|
||||
} else {
|
||||
stop_slideshow(&viewer_slides);
|
||||
}
|
||||
});
|
||||
|
||||
let toggle_off = info_toggle.clone();
|
||||
info_close.connect_clicked(move |_| toggle_off.set_active(false));
|
||||
|
||||
let ui_map = ui.clone();
|
||||
let viewer_map = Rc::downgrade(&viewer);
|
||||
let w_map = window.downgrade();
|
||||
info_map.connect_clicked(move |_| {
|
||||
let Some(w_map) = w_map.upgrade() else {
|
||||
return;
|
||||
};
|
||||
let Some(viewer_map) = viewer_map.upgrade() else {
|
||||
return;
|
||||
};
|
||||
let coords = *viewer_map.coords.borrow();
|
||||
if let Some((lat, lon)) = coords {
|
||||
w_map.close();
|
||||
show_on_map(&ui_map, lat, lon);
|
||||
if let Some(viewer_map) = viewer_map.upgrade() {
|
||||
show_photo_on_map(&ui_map, &viewer_map);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1538,24 +1568,6 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
});
|
||||
});
|
||||
|
||||
// Deleting the photo on screen closes the lightbox: what it was showing is
|
||||
// gone, and leaving it open on a trashed photo invites a second Delete on
|
||||
// something the user cannot see.
|
||||
let ui_delete = ui.clone();
|
||||
let viewer_delete = Rc::downgrade(&viewer);
|
||||
let w_delete = window.downgrade();
|
||||
delete_btn.connect_clicked(move |_| {
|
||||
let Some(w_delete) = w_delete.upgrade() else {
|
||||
return;
|
||||
};
|
||||
let Some(viewer_delete) = viewer_delete.upgrade() else {
|
||||
return;
|
||||
};
|
||||
let uid = viewer_delete.uid.borrow().clone();
|
||||
w_delete.close();
|
||||
trash_photos(&ui_delete, vec![uid], false);
|
||||
});
|
||||
|
||||
let ui_group = ui.clone();
|
||||
let viewer_group = Rc::downgrade(&viewer);
|
||||
group_btn.connect_clicked(move |_| {
|
||||
@@ -1571,38 +1583,11 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
}
|
||||
});
|
||||
|
||||
let ui_download = ui.clone();
|
||||
let w_download = window.downgrade();
|
||||
let viewer_download = Rc::downgrade(&viewer);
|
||||
download_btn.connect_clicked(move |_| {
|
||||
let Some(w_download) = w_download.upgrade() else {
|
||||
return;
|
||||
};
|
||||
let Some(viewer_download) = viewer_download.upgrade() else {
|
||||
return;
|
||||
};
|
||||
if let Some(path) = viewer_download.path.borrow().as_deref() {
|
||||
let name = viewer_download.name.borrow();
|
||||
save_photo_to_disk(
|
||||
&ui_download,
|
||||
&w_download,
|
||||
path,
|
||||
name.as_deref().unwrap_or("photo"),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
let w_ext = window.downgrade();
|
||||
let viewer_ext = Rc::downgrade(&viewer);
|
||||
open_ext_btn.connect_clicked(move |_| {
|
||||
let Some(w_ext) = w_ext.upgrade() else {
|
||||
return;
|
||||
};
|
||||
let Some(viewer_ext) = viewer_ext.upgrade() else {
|
||||
return;
|
||||
};
|
||||
if let Some(path) = viewer_ext.path.borrow().as_deref() {
|
||||
open_with(&w_ext, path, viewer_ext.name.borrow().as_deref());
|
||||
let ui_more = ui.clone();
|
||||
let viewer_more = Rc::downgrade(&viewer);
|
||||
more_btn.connect_clicked(move |_| {
|
||||
if let Some(viewer_more) = viewer_more.upgrade() {
|
||||
open_viewer_menu(&ui_more, &viewer_more);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1680,6 +1665,7 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
return glib::Propagation::Proceed;
|
||||
};
|
||||
let ctrl = state.contains(gtk4::gdk::ModifierType::CONTROL_MASK);
|
||||
let alt = state.contains(gtk4::gdk::ModifierType::ALT_MASK);
|
||||
let playing_video = viewer_key.media.visible_child_name().as_deref() == Some("video");
|
||||
match key.name().as_deref() {
|
||||
Some("space") if playing_video => {
|
||||
@@ -1687,6 +1673,8 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
stream.set_playing(!stream.is_playing());
|
||||
}
|
||||
}
|
||||
// Alt+Left is Back everywhere else in the app.
|
||||
Some("Left") if alt => w_key.close(),
|
||||
Some("Left" | "Up" | "BackSpace") => navigate_photo(&ui_key, &viewer_key, -1),
|
||||
Some("Right" | "Down" | "space") => navigate_photo(&ui_key, &viewer_key, 1),
|
||||
Some("Home") => navigate_photo(&ui_key, &viewer_key, i32::MIN / 2),
|
||||
@@ -1695,13 +1683,10 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
Some("minus" | "KP_Subtract") => zoom_by(&viewer_key, 1.0 / ZOOM_STEP),
|
||||
Some("0" | "KP_0") => reset_zoom(&viewer_key),
|
||||
Some("1" | "KP_1") => zoom_to(&viewer_key, Some(1.0), None),
|
||||
Some("F5") => viewer_key
|
||||
.slideshow
|
||||
.set_active(!viewer_key.slideshow.is_active()),
|
||||
Some("F5") => toggle_slideshow(&ui_key, &viewer_key),
|
||||
// Escape ends a slideshow before it closes anything.
|
||||
Some("Escape") if viewer_key.slideshow.is_active() => {
|
||||
viewer_key.slideshow.set_active(false)
|
||||
}
|
||||
Some("Escape") if viewer_key.slideshow.get() => stop_slideshow(&viewer_key),
|
||||
Some("F10" | "Menu") => open_viewer_menu(&ui_key, &viewer_key),
|
||||
Some("i") => viewer_key
|
||||
.info_toggle
|
||||
.set_active(!viewer_key.info_toggle.is_active()),
|
||||
@@ -1712,11 +1697,7 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
w_key.fullscreen();
|
||||
}
|
||||
}
|
||||
Some("Delete" | "KP_Delete") => {
|
||||
let uid = viewer_key.uid.borrow().clone();
|
||||
w_key.close();
|
||||
trash_photos(&ui_key, vec![uid], false);
|
||||
}
|
||||
Some("Delete" | "KP_Delete") => trash_shown_photo(&ui_key, &viewer_key),
|
||||
Some("Escape" | "q") => w_key.close(),
|
||||
Some("w") if ctrl => w_key.close(),
|
||||
_ => return glib::Propagation::Proceed,
|
||||
@@ -1729,6 +1710,98 @@ pub(crate) fn open_photo_viewer(ui: &Rc<Ui>, initial_uid: String) -> gtk4::Windo
|
||||
window
|
||||
}
|
||||
|
||||
/// The ⋮ menu: what the lightbox can do with the photo on screen besides
|
||||
/// starring it and showing its details. Built when it opens, so it offers
|
||||
/// only what applies to this photo.
|
||||
fn open_viewer_menu(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
let weak = Rc::downgrade(viewer);
|
||||
let with_viewer = move |run: fn(&Rc<Ui>, &Rc<Viewer>), ui: &Rc<Ui>| {
|
||||
let (ui, weak) = (ui.clone(), weak.clone());
|
||||
move || {
|
||||
if let Some(viewer) = weak.upgrade() {
|
||||
run(&ui, &viewer);
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut menu = ActionMenu::new();
|
||||
menu.item(&gettext("Slideshow"), with_viewer(toggle_slideshow, ui));
|
||||
menu.section();
|
||||
// Both need the full-size file, which may still be downloading.
|
||||
if viewer.path.borrow().is_some() {
|
||||
menu.item(&gettext("Save a Copy…"), with_viewer(save_shown_photo, ui));
|
||||
menu.item(&gettext("Open With…"), with_viewer(open_shown_photo, ui));
|
||||
}
|
||||
// A RAW is not on the timeline, and an album holds the shot it belongs to.
|
||||
if find_photo_index(&ui.gallery.model, &viewer.uid.borrow()).is_some() {
|
||||
menu.item(
|
||||
&gettext("Add to Album…"),
|
||||
with_viewer(add_shown_photo_to_album, ui),
|
||||
);
|
||||
}
|
||||
if viewer.coords.borrow().is_some() {
|
||||
menu.item(&gettext("Show on Map"), with_viewer(show_photo_on_map, ui));
|
||||
}
|
||||
menu.section();
|
||||
menu.item(
|
||||
&gettext("Move to Trash…"),
|
||||
with_viewer(trash_shown_photo, ui),
|
||||
);
|
||||
|
||||
let button = &viewer.more;
|
||||
let popover = menu.popup_at(
|
||||
button,
|
||||
f64::from(button.width()) / 2.0,
|
||||
f64::from(button.height()),
|
||||
);
|
||||
viewer.menu_open.set(true);
|
||||
let weak = Rc::downgrade(viewer);
|
||||
popover.connect_closed(move |_| {
|
||||
if let Some(viewer) = weak.upgrade() {
|
||||
viewer.menu_open.set(false);
|
||||
// A slideshow started from the menu keeps the controls hidden.
|
||||
if !viewer.slideshow.get() {
|
||||
show_chrome(&viewer);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn save_shown_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
if let Some(path) = viewer.path.borrow().as_deref() {
|
||||
let name = viewer.name.borrow();
|
||||
save_photo_to_disk(ui, &viewer.window, path, name.as_deref().unwrap_or("photo"));
|
||||
}
|
||||
}
|
||||
|
||||
fn open_shown_photo(_ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
if let Some(path) = viewer.path.borrow().as_deref() {
|
||||
open_with(&viewer.window, path, viewer.name.borrow().as_deref());
|
||||
}
|
||||
}
|
||||
|
||||
fn add_shown_photo_to_album(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
let uid = viewer.uid.borrow().clone();
|
||||
prompt_add_to_album(ui, vec![uid], Some(viewer.window.clone()));
|
||||
}
|
||||
|
||||
/// Close the lightbox and show where the photo was taken.
|
||||
fn show_photo_on_map(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
let coords = *viewer.coords.borrow();
|
||||
if let Some((lat, lon)) = coords {
|
||||
viewer.window.close();
|
||||
show_on_map(ui, lat, lon);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ask, then move the photo on screen to the trash. Confirmed, the lightbox
|
||||
/// closes first: what it was showing is gone, and leaving it open on a
|
||||
/// trashed photo invites a second Delete on something the user cannot see.
|
||||
fn trash_shown_photo(ui: &Rc<Ui>, viewer: &Rc<Viewer>) {
|
||||
let uid = viewer.uid.borrow().clone();
|
||||
let window = viewer.window.clone();
|
||||
ask_trash_photos(ui, vec![uid], Some(window.clone()), move || window.close());
|
||||
}
|
||||
|
||||
/// Whether `(x, y)` — in `picture`'s coordinates — lands on the photo itself
|
||||
/// rather than the backdrop around it. [`gtk4::ContentFit::Contain`] centres the
|
||||
/// image and letterboxes the rest, so the drawn rectangle is the widget scaled
|
||||
|
||||
@@ -1441,7 +1441,7 @@ pub(crate) fn wire_gallery(
|
||||
let ui_album = ui.clone();
|
||||
selection.album.connect_clicked(move |_| {
|
||||
let uids: Vec<String> = ui_album.gallery.selected.borrow().iter().cloned().collect();
|
||||
prompt_add_to_album(&ui_album, uids);
|
||||
prompt_add_to_album(&ui_album, uids, None);
|
||||
});
|
||||
let ui_remove = ui.clone();
|
||||
selection.remove.connect_clicked(move |_| {
|
||||
@@ -2764,6 +2764,18 @@ pub(crate) fn delete_selected(ui: &Rc<Ui>) {
|
||||
|
||||
/// Confirm, then move the photos behind `uids` to Proton trash.
|
||||
pub(crate) fn confirm_trash_photos(ui: &Rc<Ui>, uids: Vec<String>) {
|
||||
ask_trash_photos(ui, uids, None, || {});
|
||||
}
|
||||
|
||||
/// [`confirm_trash_photos`] over `parent` rather than the main window, for
|
||||
/// the photo viewer, which covers it. `before` runs once the user confirms,
|
||||
/// before the photos go.
|
||||
pub(crate) fn ask_trash_photos(
|
||||
ui: &Rc<Ui>,
|
||||
uids: Vec<String>,
|
||||
parent: Option<gtk4::Window>,
|
||||
before: impl Fn() + 'static,
|
||||
) {
|
||||
if uids.is_empty() {
|
||||
return;
|
||||
}
|
||||
@@ -2803,10 +2815,11 @@ pub(crate) fn confirm_trash_photos(ui: &Rc<Ui>, uids: Vec<String>) {
|
||||
dialog.set_default_response(Some("cancel"));
|
||||
dialog.set_close_response("cancel");
|
||||
|
||||
let win = ui_window(ui);
|
||||
let win = parent.or_else(|| ui_window(ui));
|
||||
let ui = ui.clone();
|
||||
dialog.connect_response(None, move |_, response| {
|
||||
if response == "trash" {
|
||||
before();
|
||||
trash_photos(&ui, uids.clone(), false);
|
||||
}
|
||||
});
|
||||
@@ -3979,7 +3992,7 @@ fn show_photo_menu(ui: &Rc<Ui>, photo: &PhotoItem, anchor: >k4::Button, x: f64
|
||||
menu.section();
|
||||
let (ui_c, uid) = (ui.clone(), photo.uid.clone());
|
||||
menu.item(&gettext("Add to Album…"), move || {
|
||||
prompt_add_to_album(&ui_c, vec![uid.clone()])
|
||||
prompt_add_to_album(&ui_c, vec![uid.clone()], None)
|
||||
});
|
||||
let open_album = ui.gallery.album.borrow().clone();
|
||||
if let Some(album) = open_album.filter(|album| !album.shared) {
|
||||
|
||||
@@ -101,8 +101,14 @@ impl ActionMenu {
|
||||
|
||||
/// Pop the menu up over `anchor` at `(x, y)` in its coordinates. The
|
||||
/// popover removes itself once dismissed; it waits for an idle turn, so the
|
||||
/// item that closed it still finds its action.
|
||||
pub(crate) fn popup_at(self, anchor: &impl IsA<gtk4::Widget>, x: f64, y: f64) {
|
||||
/// item that closed it still finds its action. Returned for a caller that
|
||||
/// has to know when it closes.
|
||||
pub(crate) fn popup_at(
|
||||
self,
|
||||
anchor: &impl IsA<gtk4::Widget>,
|
||||
x: f64,
|
||||
y: f64,
|
||||
) -> gtk4::PopoverMenu {
|
||||
let (menu, group) = self.finish();
|
||||
let anchor = anchor.as_ref();
|
||||
let host = popover_host(anchor);
|
||||
@@ -122,6 +128,7 @@ impl ActionMenu {
|
||||
glib::idle_add_local_once(move || p.unparent());
|
||||
});
|
||||
popover.popup();
|
||||
popover
|
||||
}
|
||||
|
||||
/// A flat ⋮ button that opens this menu.
|
||||
|
||||
@@ -136,6 +136,14 @@ Existing folders stay device backups. Older builds cannot open the upgraded data
|
||||
- **A search in My files stays.** It was replaced by the folder's listing whenever files
|
||||
changed, on refresh and on coming back to the page, while the query stayed in the box.
|
||||
|
||||
- **The photo viewer's buttons are readable on any photo.** They were white on a see-through
|
||||
white, and vanished over a bright photo. The bar now keeps only the favorite star, the details
|
||||
and a menu, which names Slideshow, Save a Copy, Open With, Add to Album, Show on Map and Move to
|
||||
Trash in words where eight icons stood. A shot stored as more than one file shows a "RAW" or
|
||||
"Live" switch, or "2 of 3" for a burst, where an unlabelled icon was. The title reads
|
||||
"Wednesday, October 7, 2026, 13:42" rather than a timestamp. Delete asks first, as it does in
|
||||
the grid, and Alt+Left closes the viewer.
|
||||
|
||||
- **A date jump in Photos stops when you look elsewhere.** A jump still loading the timeline
|
||||
kept going after another filter, album or place was opened.
|
||||
|
||||
|
||||
+227
-211
File diff suppressed because it is too large.
Load diff
+221
-211
File diff suppressed because it is too large.
Load diff
+227
-211
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user