imageView: Merge set_image_from_file with set_images_from_files

Also changing behavior when opening with multiple command line
arguments or when multiple images were selected from other
applications.

Old behavior: Spawn an instance of Loupe for each argument.
New behavior: One Loupe instance containing all arguments.

Closes #195
This commit is contained in:
Huan Nguyen 2023-05-30 12:52:59 +00:00 • committed by Sophie Herold
parent 6dda1eeb50
commit 735451250c
3 changed files with 12 additions and 17 deletions

View file

@ -241,20 +241,19 @@ glib::wrapper! {
#[gtk::template_callbacks]
impl LpImageView {
pub fn set_image_from_file(&self, file: gio::File) {
pub fn set_images_from_files(&self, files: Vec<gio::File>) {
// Add image to recently used file. Does not work in Flatpaks:
// <https://github.com/flatpak/xdg-desktop-portal/issues/215>
gtk::RecentManager::default().add_item(&file.uri());
self.load_file(file);
}
pub fn set_images_from_files(&self, files: Vec<gio::File>) {
let recent_manager = gtk::RecentManager::default();
for file in files.iter() {
recent_manager.add_item(&file.uri());
}
self.load_files(files);
if files.len() == 1 {
self.load_file(files[0].clone());
} else {
self.load_files(files);
}
}
fn load_files(&self, files: Vec<gio::File>) {