Commit graph

68 commits

Author SHA1 Message Date
Sophie Herold
8b3cfd000a cargo: Remove gtk-macros dependency
Using the crate is depreacted. Replaced spawn! macro
with our own spawn function
2023-04-06 21:08:33 +00:00
Sophie Herold
889c818c14 code: Use pub(super) in GObject impl structs
This helps with getting warnings for fields we no longer use

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/143>
2023-03-14 21:25:45 +00:00
Sophie Herold
f8e64d9805 trash: Use non-existing name when restoring image
We usually use the original path of the image.
For the rare case the original file name exists we create
one that is not used yet.

Closes #66

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/130>
2023-03-14 00:07:08 +00:00
Sophie Herold
f80ec7db56 decoder: Use image-rs, libheif-rs, librsvg
This adds proper support for a lot of image formats including SVGs.
It will be the basis for many features to come. The technical core
is an asynchronous renderer that can arrange textures in smaller tiles
which might be generated on demand.

Closes #34, #40, #41, #49

Basis for fixing the following issues #7, #27, #36, #43, #68, #71
2023-03-04 21:48:51 -05:00
Christopher Davis
4d4bc4bb38 application: Stop using expressions
This commit moves the logic from the expressions to the
window via GSignalGroup.
2023-03-05 02:13:41 +00:00
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
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
74a067e3b8 window: Fix Left/Right button direction for RTL
This also fixes the issue with the buttons triggering
focus changes when the action is deactivated because buttons
know have their own action.

Fixes #44
Issue #38
2023-02-06 21:07:23 +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
aa7a2dfd93 window: Add image deletion
Add Flatpak access to GVfs for trash:/// access for being
able to recover files (undo trash operation).

Closes #26
2023-02-02 00:45:40 +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
Christopher Davis
eae81ebc60 window: Use GtkFileLauncher
GtkFileLauncher handles using the portal when
appropriate.
2023-01-18 20:21:48 -05:00
Christopher Davis
2757e94e08 window: Update use of FileDialog.open_future()
Requires an updated gtk-rs
2023-01-14 14:23:54 -05: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
Christopher Davis
ba77ee1a32 window: Use new async FileDialog API
GTK 4.10 deprecates the old GtkFileChooser* APIs in favor of a
new GtkFileDialog utility. This new utility uses async functions
instead of a `response` signal, so we can make use of Rust's
async/await patterns.
2022-12-12 17:52:06 +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
c1a3cc353d image: Limit zoom to 2000% 2022-11-28 23:24:12 +01:00
Sophie Herold
f1593203a0 window: Add missing shortcuts
Add shortcuts
- F9 Image properties
- F10 Main menu
- Ctrl +/- for zoom
- Ctrl 0 for best fit
- Ctrl [Shift] R for rotate
- Escape to leave fullscrenen
Updated help overlay accordingly.
2022-11-25 15:46:35 +01:00
Christopher Davis
583794a3ec general: Use glib::Object::builder for objects w/ props
Builders are more idiomatic rust code than the old
pattern.
2022-11-24 13:06:53 -05:00
Sophie Herold
3876f55b4c about: Change app name to Loupe and update devs
- Rename to Loupe to avoid confusion during incubation
  and potentially allow for release on Flathub
- Replace GNOME as developer since it violates software policy
- Put a more useful copyright statement
- Add me as developer
2022-11-23 21:10:03 +00:00
Christopher Davis
aa781d3864 application: Use gio::ActionEntryBuilder for actions
Allows us to drop the action! macro and usage of the clone! macro
in the application file.

The first occurrence of clone! is now in window.rs, so the comment
explaining it has moved there.
2022-11-23 19:56:51 +00: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
57f573f98a ui: Fix quotation marks 2022-11-04 20:48:32 +01:00
Sophie Herold
db69cbe64e window: Do not panic on failed drag-and-drop 2022-11-04 20:12:15 +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
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
d921cd8044 window: Take toast text as impl AsRef instead of &impl AsRef 2022-08-04 01:04:04 -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
ba4661031f Implement Properties
Implement a properties sidebar. In order to prevent
the UI from freezing, we use futures to load and cancel
loading file information. We also make use of
`gdk_pixbuf` and `svg_metadata` in order to get the file's
metadata before the file fully loads, meaning there's
little to no delay between changing files and seeing
the metadata for large images.

The properties widget uses expressions and
properties to avoid glue code for setting each label,
allowing us to have a clean separation between UI
and data.
2022-08-02 19:31:44 -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
689f975bf0 window: Add copy button to top left
Allan Day's latest mockups put a copy button in the top left
of the window. This commits adds the button and the toast along
with it.
2022-07-14 16:27:38 -04:00
Christopher Davis
6e869ebb1b window: Remove unecessary String cast in pick_file()
Per clippy lints
2022-06-29 20:10:37 -04:00
Christopher Davis
f0973f6cf6 window: map().flatten() -> and_then()
Per clippy lints
2022-06-29 20:09:45 -04: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
ca3c02a5c2 window: Use GString's display implementation for toast 2022-02-05 00:11:39 +00: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
a12e7eed43 window: Use portal to open files in other apps
Calling `xdg-open` is the wrong thing to do, and has
flaky reliability. What we want is to use the portal
directly with the exact behavior we want.

When using the portal we can't just pass the uri -
we need to own a file descriptor.
2021-12-29 17:43:58 -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
be70bdafe5 window: Implement drag and drop
The main page is no longer a lie.
2021-12-27 22:05:29 -08:00