Skip to content

Commit

Permalink
add shortcut for closeall and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Jun 9, 2024
1 parent cbf0b86 commit 27fb192
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# New in 0.12

- switch from Gtk to Gtk4. Fixes REPL lag on Windows.
- Julia 1.6 is now required

# New in 0.11

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ImageView"
uuid = "86fae568-95e7-573e-a6b2-d8a6b900c9ef"
author = ["Tim Holy <[email protected]"]
version = "0.12.3"
version = "0.12.4"

[deps]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ To install the `ImageView` package:
Pkg.add("ImageView")
```

Note for Mac users: It is strongly recommended that you use Julia 1.3 or higher, as this release introduced a new approach for handling library dependencies like Cairo and Gtk.

## Preparation

First let's try it with a photograph. If you have an image on your computer, load it this way:
Expand Down Expand Up @@ -77,7 +75,7 @@ imshow(img, flipy=true)
imshow(img, axes=(2,1)).
```

The window can be closed using Ctrl-W (on Linux or Windows, use Cmd-W on a Mac) and fullscreen can be toggled using F11 (on Linux or Windows, use Cmd-Shift-F on a Mac).
The window can be closed using Ctrl-W (use Cmd-W on a Mac). All windows opened by ImageView can be closed using Ctrl-Shift-W (Cmd-Shift-W on a Mac). Fullscreen can be toggled using F11 (on Linux or Windows, use Cmd-Shift-F on a Mac).

For movies, 3D, and 4D images, ImageView will create a "player" widget.

Expand Down
9 changes: 8 additions & 1 deletion src/ImageView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Base.eltype(::CLim{T}) where {T} = T
"""
closeall()
Closes all windows opened by ImageView2.
Closes all windows opened by ImageView.
"""
function closeall()
for (w, _) in window_wrefs
Expand Down Expand Up @@ -318,6 +318,11 @@ function close_cb(::Ptr, par, win)
nothing
end

function closeall_cb(::Ptr, par, win)
@idle_add closeall()
nothing
end

function fullscreen_cb(aptr::Ptr, par, win)
gv=Gtk4.GLib.GVariant(par)
a=convert(Gtk4.GLib.GSimpleAction, aptr)
Expand Down Expand Up @@ -354,9 +359,11 @@ Compat.@constprop :none function imshow_gui(canvassize::Tuple{Int,Int},
m = Gtk4.GLib.GActionMap(ag)
push!(win, Gtk4.GLib.GActionGroup(ag), "win")
Gtk4.GLib.add_action(m, "close", close_cb, win)
Gtk4.GLib.add_action(m, "closeall", closeall_cb, nothing)
Gtk4.GLib.add_stateful_action(m, "fullscreen", false, fullscreen_cb, win)
sc = GtkShortcutController(win)
Gtk4.add_action_shortcut(sc,Sys.isapple() ? "<Meta>W" : "<Control>W", "win.close")
Gtk4.add_action_shortcut(sc,Sys.isapple() ? "<Meta><Shift>W" : "<Control><Shift>W", "win.closeall")
Gtk4.add_action_shortcut(sc,Sys.isapple() ? "<Meta><Shift>F" : "F11", "win.fullscreen")

window_wrefs[win] = nothing
Expand Down

0 comments on commit 27fb192

Please sign in to comment.