Commit graph

76 commits

Author SHA1 Message Date
Christopher Davis
3d445f25fe window: Use GSignalGroup to watch zoom levels
This allows us to git rid of more expression code.
2023-03-05 02:13:41 +00:00
Christopher Davis
aab50af31a image_view: Switch from expressions to signal groups
Expressions have the leak issue mentioned in the previous
commit, but we were using them in a few scenarios where
they couldn't be used in UI files.

Since these expressions don't set a property but instead
trigger behavior, the appropriate API to use is GSignalGroup.
This commit switches the expressions on the image to use
GSignalGroup instead.
2023-03-05 02:13:41 +00:00
Lubosz Sarnecki
30136f9050 code: Fix some typos.
Fix some typos, mainly in comments with the power of
Builder's spell correction.
2023-02-21 00:19:05 +01:00
Sophie Herold
004ebd5615 cargo: Update dependencies 2023-02-15 17:04:59 +01:00
Sophie Herold
70d8d00a3d imageView: Reset zoom and rotation on page change
Keeping zoom or rotation would be inconsistent since it's
only preserved while images are cached.

Close #65
2023-02-12 20:39:40 +00:00
Sophie Herold
19c8d69dca code: Fix clippy warnings 2023-02-12 19:31:22 +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
7cf04d290a clipboard: Use same ContentProvider as for D+D
FileList is working in more cases than PNGs and has fewer drawbacks.
Also, it's the same that has been used elsewhere for a long time.

Closes #50
2023-01-31 05:17:39 +00:00
Sophie Herold
4eb8b939b3 application: Add shortcuts for paning the view
Closes #54
2023-01-31 04:56:58 +00: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
Christopher Davis
7b7435f50a general: Use spawn! less
Because widgets can install async actions, we can simply
turn our callbacks into async functions.
2023-01-22 19:55:42 +00:00
Sophie Herold
36000ff65c window: Put prev/next accels at window level
Tried to make things more stateless and RefCell usage for robust
- Use object properties to control the action enabled/disabled
- Borrow model RefCell for only one line or use .replace()
- Don't pass models around and borrow as short as possible instead

Fixes #20
2022-12-16 18:27:45 +00:00
Sophie Herold
01bebfef38 imageView: Include overlay controls in min size
This stops the overlay controls to overlap for very small
window sizes and properties opened.

LpImageView already does custom measure and overlay is it's
direct child. So added it here.

Fixes #32
2022-12-12 12:01:24 -05: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
d6ab100062 image: Use FileList in ContentProvider
Makes dragging an image out of Loupe work in most cases.
There seems to be an issue with dragging from flatpak to host.
Removing the png from the provider seems to avoid gdk crashes
but not 100% sure that was the cause.
2022-11-28 19:34:18 +01:00
Sophie Herold
029c0c9244 image: Add zoom and scrolling support
Zoom via
- Scroll event controller
- Zoom gesture
- Overlay buttons
- Fixed zoom level shortcuts (1=100%, 2=200%)
Scrolling via
- Scrolled window
- Drag gesture
Changes
- Implement best-fit via calculating a zoom level
- Gesture for carousel no longer working because of scrolled window
- Split control overlays into two to not steal inputs in area between

Closes #17
2022-11-23 00:57:43 +01:00
Sophie Herold
c2e3bb2f83 menus: Add rotate left and right buttons 2022-11-06 17:58:02 +01:00
Sophie Herold
165861568c imageView: Fix two panics when file not exists 2022-11-04 19:28:48 +01:00
Sophie Herold
a2e6767584 image: Add rotation and auto rotate based on exif 2022-11-04 18:52:33 +01:00
Sophie Herold
3d6564377a cargo: Update dependencies 2022-11-03 00:57:18 +01:00
Christopher Davis
20c336b17f image_view: Fix carousel scrolling when loading files in same dir
With https://gitlab.gnome.org/GNOME/libadwaita/-/merge_requests/652
merged
we no longer crash when loading files from the same directory.
Now that we don't crash, we've exposed a logic error: we were
changing the state of the carousel while scrolling through it,
which ends with the carousel in a weird state.

This commit delays clearing and refilling the carousel until
after the `page-changed` signal is emitted.
2022-08-19 12:06:07 -04:00
Elton A Rodrigues
8679734a43 general: change wallpaper to background
- Change wallpaper term to background(string and code)
- Remove toast error when cancel background portal
2022-08-18 09:42:25 -03:00
Christopher Davis
81273c736e general: Update libadwaita-rs
Allows us to clean up our imports a bit.
2022-08-06 00:48:52 -04:00
Christopher Davis
1db46013d9 general: Add translation infrastructure 2022-08-05 19:09:17 -04:00
Christopher Davis
d99215bfd1 general: Use gtk_macros::spawn!()
Makes the code a tad cleaner because we're not manually
getting `glib::MainContext` every time we want to spawn
a future.
2022-08-03 19:37:03 -04:00
Christopher Davis
1e95dd4cbb image_view: Expose file as a property instead of filename
The GFile is more useful for other data. The window can
use expressions to calculate an appropriate title, so
we no longer need to call `set_title()` or connect to
a signal manually.

This commit also adjusts the `uri()` and `print()`
functions to use `active_file()`
2022-08-02 19:30:08 -04:00
Christopher Davis
9ba6cced6c window,image_view: Move fullscreen controls to the image view
Allan Day's latest mockups have the fullscreen icon on the bottom
left of the image. This commit moves the icon there, using a
GtkExpression for the icon name.
2022-07-14 17:35:20 -04:00
Christopher Davis
d609c4e0b2 image_view: Adjust model index name
Previously we used `prev_index` everywhere, which could
get confusing - it's not really the "previous" index
until we've moved. So, only `page_changed_cb ()` refers
to it as `prev_index`. Everywhere else it's called
`current_model_index`.

In accordance with this change, we can get rid
of a call to `current_page()` and `index_of()`
since we already know the index of the current page.
2022-07-14 13:30:38 -04:00
Christopher Davis
e8511bf5d5 image_view: Pass model to update_action_state()
Due to the latest refactoring passes, it was possible
for the model to be borrowed twice when navigating
to a file. This commit makes model an argument
to update_action_state() so we don't need to acquire
another borrow. We have the model already in all cases
where we use update_action_state().
2022-06-29 18:45:45 -04:00
Christopher Davis
ddb02d0eb7 image_view: Rename N_PAGES to BUFFER
This is for better readability. Also changes the comment,
which I forgot to update while reworking how we handle the
model.
2022-06-29 18:25:45 -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
10cdb2c519 image_view: Create functions to fill and clear carousel
This way we don't need to duplicate code for this functionality.
2022-06-29 12:22:39 -04:00
Christopher Davis
8612c317ba image_view: Implement loading a file within the current model
Currently broken due to a crash in AdwAnimation
2022-06-29 12:22:28 -04:00
Christopher Davis
8acf76bd5e image_view: Clear the carousel when creating a new model
This way we properly handle switching directories within the
same window.
2022-06-28 21:28:55 -04:00
Christopher Davis
3557b15034 image_view: Rework model loading and page navigation
Rework the model loading to not care about the edges.
Now we only care about where we are in the model and
the number of buffer pages. This algorithm handles
the edges without special casing.
2022-06-28 18:59:33 -04:00
Christopher Davis
2b63f57d5b image_view: Make d-n-d gesture exclusive
Drag and drop does not work on touchscreens.
2022-04-20 13:12:47 -07:00
Christopher Davis
48b8ce9455 window: Use path instead of URI for "Open With"
Fixes an issue where paths with spaces or anything
else encoded within the URI could not be opened
externally.
2022-04-20 13:12:47 -07: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
Christopher Davis
f7151e93d1 build: Use the latest stable Rust dependencies
Now that there's a release with template callback support,
we don't need to use git.
2022-01-19 17:29:46 -08:00
Maximiliano Sandoval R
13d7a21501 Implement drag source on images
Using a 128x128 thumbnail.
2022-01-09 00:22:50 -08:00
Christopher Davis
fc6d3668c0 Update gtk-rs deps for return value nullability trust 2022-01-08 22:18:40 -08:00
Maximiliano Sandoval R
be09d49756
image: Implement Copy to clipboard 2022-01-08 23:59:56 +01:00
Christopher Davis
7b760f85f4 image_view: Use window identifier for wallpaper portal
Makes the dialog modal.
2021-12-29 18:46:55 -08:00
Christopher Davis
56a47fb447 Update gtk-rs
This brings us a neat new function, `imp()`,
that lets us drop `from_instance()` everywhere.
2021-12-29 14:02:48 -08:00
Christopher Davis
400672b6b6 window: Add ToastOverlay and use toasts for feedback 2021-12-28 16:40:58 -08:00
Christopher Davis
5893d4b764 cargo: Use gtk-rs master
Needed to take advantage of template callbacks
and new APIs.
2021-12-22 18:17:38 -08:00