Commit graph

31 commits

Author SHA1 Message Date
Sophie Herold
b56d650086 code: Reformat with new rules 2023-11-29 21:16:11 +01:00
Sophie Herold
229c63719e meta: Prepare 45.2 2023-11-21 20:55:03 +01:00
Julian Hofer
831cf953c6 Preserve order when removing items from file model
The files are stored in an index map.
When removing from that map, `remove` does not guarantee to preserve order.
However `shift_remove` does.

Fixes #270
2023-11-15 15:25:07 +01:00
Sophie Herold
14fad2ffad fileModel: Do file listing after monitor init fail
Before, the code would not continue to listing the files
if connecting to the file monitor failed. Therefore, browsing
files was not available on SMB where file monitors don't work.

Closes #200
2023-08-03 21:29:41 +02:00
Sophie Herold
55551ae6a2 general: Update copyright notices
Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/258>
2023-07-18 17:48:43 +00:00
Sophie Herold
06d688e79e src: Format let-else statements 2023-07-07 19:22:51 +00:00
Christopher Davis
439286be40 general: Use std's OnceCell where possible
Rust's standard library now provides a drop-in replacement
for `OnceCell`. It requires no API changes from `once_cell`'s
version.

This commit replaces the version from `once_cell` with the
new `std` struct where possible. We still need to use
`once_cell` for properties until
https://github.com/gtk-rs/gtk-rs-core/pull/1113
is merged. We also still need it for Lazy until that lands.

Part-of: <https://gitlab.gnome.org/GNOME/Incubator/loupe/-/merge_requests/241>
2023-06-23 18:59:09 +00:00
Sophie Herold
3dd59c87ed fileModel: Correct changed checks in file monitor
Those got accidentally inverted when moving to GFile.

Close #199
2023-06-20 16:42:51 +02:00
Sophie Herold
8d8197dda4 fileModel: Add missing IS_HIDDEN file attribute 2023-06-07 23:47:58 +02:00
Sophie Herold
291fa13d1f meta: Update copyright headers 2023-06-07 23:44:20 +02:00
Gage Berz
0679d08c22 fileModel: Skip hidden files
Closes #179
2023-05-17 15:49:13 +00:00
Sophie Herold
6db58463bf imageView: Skip unsupported formats when sliding
If an image with unsupported format is opened directly,
the error is shown.

Closes #92

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/212>
2023-05-03 18:58:02 +00:00
Sophie Herold
2f9fad47a1 src: Update or add auto generated license headers
Closes #55

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/169>
2023-04-19 20:02:01 +02:00
Sophie Herold
aca49427a1 window: Support dropping multiple files
This allows to scroll through all dropped files.
No further images from directories are loaded in
this mode.

Closes #35
2023-04-18 22:29:30 +02:00
Sophie Herold
fad8bb7939 decoder: Use GFile instead of PathBuf
This allows to show images from locations that don't
have a representation with path.

This also works around not being able to read files in trash:///

Closes #56

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/174>
2023-04-18 16:22:49 +00:00
Sophie Herold
032707a210 fileModel: Use GFile with URI as key
Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/174>
2023-04-18 16:22:49 +00:00
Sophie Herold
f8cc9f5f84 i18n: Use gettext function instead of wrapper
No need to deviate from the default here.

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/170>
2023-04-12 12:58:40 +00:00
Sophie Herold
7bcc5e210b cargo: Update and cleanup dependencies
- Replace one remaining use of util::spawn with gio
- Replace pretty_env_logger with env_logger

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/149>
2023-03-25 14:01:28 +00:00
Sophie Herold
004ebd5615 cargo: Update dependencies 2023-02-15 17:04:59 +01:00
Sophie Herold
69889820cd window: Add Home/End shortcuts for first/last img
This is the same as in EOG.
Also add PageUp/Down for image navigation from EOG.
Cleanup the navigation enums as well.
2023-02-06 19:14:55 +01:00
Sophie Herold
f2357513da imageView: Use custom slide widget and IndexSet
Use IndexSet to allow direct access by Path and also allow
an arbitrary ordering that was not possible with Vec. Also
add monitoring of file changes in the directory.

Use a custom LpSlidingView instead of AdwCarousel because
Carousel was never designed for this job and suffered of
bugs. LpSlidingView does not support swiping gestures yet
since they currently don't work yet anyways #24.

Use a new algorithm to fill the LpSlidingView that is
stateless and covers all potential changes in the directory.
This not only fixes bugs but would also work with changed
sorting orders.

This also adds build time template XML validation since it
was useful for the refactoring #46.

Closes #9, #11, #30, #33, #42
2023-01-30 01:08:57 +00:00
Sophie Herold
e04992b46d window: Adjust to image size when opening
Give LpImage a native with that should feel nice.
When opening a new window with a new image the window size
is determined by LpImage's natural width.
The image size and EXIF data is loaded before the image such
that the window can be shown in the right dimension while
loading the actual image.
2022-12-12 15:54:24 +00:00
Sophie Herold
68221bacba file_model: Load opened image first add dir later
- Fixes image cannot be opened when directory unreadable
- Avoids bugs with wrong images being selected for an instant.
  Mostly important for adjusting the window size to image.
- Basis for prioritizing loading the important image first
2022-12-12 15:54:24 +00:00
Sophie Herold
165861568c imageView: Fix two panics when file not exists 2022-11-04 19:28:48 +01:00
Sophie Herold
3d6564377a cargo: Update dependencies 2022-11-03 00:57:18 +01:00
Christopher Davis
5f7aa595db file_model: Use binary search to find index
Binary search is a fast method to sort for an item within
a sorted list. We have a sorted list, so we can take advantage
of binary search instead of having a linear traversal through
the list.

Because binary search requires a sorted list, we need to use
the same logic for sorting and searching. Here we factor out
the filename comparison logic into `util::compare_by_name()`.
In the future we may want to have a module for sorting algorithm
logic and checking what sorting algortihm Nautilus uses.
2022-07-14 15:25:03 -04:00
Christopher Davis
8c56e2c66a file_model: Make index_of() return a u32
We only ever use it as a u32 elsewhere, so cut out
the casting.
2022-06-29 16:58:11 -04:00
Christopher Davis
70054971d9 file_model: Add file() function
Adds a function to get the file at a given index directly,
instead of going through GListModel::item().
2022-06-29 16:51:16 -04:00
Christopher Davis
e13ecb4df4 file_model: Remove next() and previous() functions
These functions required iterating to find the
index of a file and then adding one to it.
We can be smarter, using an index we already
have and adding or subtracting where appropriate.
2022-06-29 13:37:55 -04:00
Christopher Davis
2aa480eee5 widgets: Rework image_view with AdwCarousel, add ImagePage
Previously we loaded images synchronously and manually
changed `LpImage`. This could cause freezes when loading
large images and SVGs. We also had no proper feedback for
when a corrupted or unsupported image was loaded.

This commit introduces a major rework to how we handle
images and the gallery. It introduces a swipeable gallery
that loads files asynchronously via a new widget: LpImagePage.

LpImagePage owns the file and information related to the file,
and on creation it spawns a future that either loads an error
page when it can't load something (file deleted, corrupted, or
unsupported) or the actual image via LpImage. LpImagePage
now holds the right-click popover and the associated gestures.

The gestures needed to be moved to LpImagePage in order to
rework LpImageView's overlay - instead of having an overlay
child that's a box with a few buttons, we now have the buttons
as individual overlay children. This could cause them
to overlap each other at certain sizes, but it's required
in order to allow input to reach the carousel below.

Right now this comes with a few regressions:

* Occasionally input gets blocked across the applications. It's
hard to tell if this is caused by swipes or right clicking. This
input issue can cause a crash - no Rust backtrace, so a debugger
is needed.

* The "current" page doesn't seem to be properly loaded by the
time `set_image_from_file ()` finishes, so we need to rework
resizing from image dimensions

* We need to re-implement loading different directories and
files within directories

There also seems to be an issue on touchscreens, swiping between
images on a touchscreen causes responsiveness issues not present
when swiping on a touchpad. My guess is that it's related to
the long press gesture.
2022-04-20 13:12:45 -07:00
Christopher Davis
3bb48155a0 general: Use a custom ListModel for file tracking
This is more robust than manually keeping a
vector and using indexing.
2022-02-04 16:25:44 -08:00