Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jan 12, 2022
1 parent 08e4e62 commit 9a6d3bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/Gtk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ function __init__()
global gtk_main_task = schedule(Task(gtk_main))
end

idle(get(ENV, "GTK_START_IDLE", "true") == "true")
AUTO_IDLE[] = get(ENV, "GTK_AUTO_IDLE", "true") == "true"
idle(AUTO_IDLE[])
end

const AUTO_IDLE = Ref{Bool}(true)

"""
Gtk.idle(b::Bool = true)
Expand Down
24 changes: 12 additions & 12 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ visible(w::GtkWidget) = Bool(ccall((:gtk_widget_get_visible, libgtk), Cint, (Ptr
visible(w::GtkWidget, state::Bool) = @sigatom ccall((:gtk_widget_set_visible, libgtk), Nothing, (Ptr{GObject}, Cint), w, state)

const SHOWN_WIDGETS = WeakKeyDict()
function handle_auto_idle(w::GtkWidget)
if AUTO_IDLE[]
idle(false)
SHOWN_WIDGETS[w] = nothing
signal_connect(w, :destroy) do w
delete!(SHOWN_WIDGETS, w)
isempty(SHOWN_WIDGETS) && idle(true)
end
end
end
function show(w::GtkWidget)
idle(false)
handle_auto_idle(w)
@sigatom ccall((:gtk_widget_show, libgtk), Nothing, (Ptr{GObject},), w)
SHOWN_WIDGETS[w] = nothing
signal_connect(w, :destroy) do w
delete!(SHOWN_WIDGETS, w)
isempty(SHOWN_WIDGETS) && idle(true)
end
w
end
function showall(w::GtkWidget)
idle(false)
handle_auto_idle(w)
@sigatom ccall((:gtk_widget_show_all, libgtk), Nothing, (Ptr{GObject},), w)
SHOWN_WIDGETS[w] = nothing
signal_connect(w, :destroy) do w
delete!(SHOWN_WIDGETS, w)
isempty(SHOWN_WIDGETS) && idle(true)
end
w
end

Expand Down

0 comments on commit 9a6d3bd

Please sign in to comment.