Skip to content

Commit bd671b6

Browse files
committed
Merge __init__() functions
1 parent 70810dc commit bd671b6

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

src/Gtk.jl

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@ const libgdk = libgdk3
99
const libgtk = libgtk3
1010

1111

12-
function __init__()
13-
# Set up environment variables so that gdk-pixbuf can find its loaders
14-
if get(ENV, "GDK_PIXBUF_MODULEDIR", "") == ""
15-
ENV["GDK_PIXBUF_MODULEDIR"] = joinpath(
16-
dirname(gdk_pixbuf_jll.libgdkpixbuf_path),
17-
"gdk-pixbuf-2.0",
18-
"2.10.0",
19-
"loaders",
20-
)
21-
end
22-
end
23-
24-
2512
const suffix = :Leaf
2613
include("GLib/GLib.jl")
2714
using .GLib
@@ -84,6 +71,30 @@ include("theme.jl")
8471
include("gio.jl")
8572
include("application.jl")
8673

74+
function __init__()
75+
# Set up environment variables so that gdk-pixbuf can find its loaders
76+
if get(ENV, "GDK_PIXBUF_MODULEDIR", "") == ""
77+
ENV["GDK_PIXBUF_MODULEDIR"] = joinpath(
78+
dirname(gdk_pixbuf_jll.libgdkpixbuf_path),
79+
"gdk-pixbuf-2.0",
80+
"2.10.0",
81+
"loaders",
82+
)
83+
end
84+
85+
GError() do error_check
86+
ccall((:gtk_init_with_args, libgtk), Bool,
87+
(Ptr{Nothing}, Ptr{Nothing}, Ptr{UInt8}, Ptr{Nothing}, Ptr{UInt8}, Ptr{GError}),
88+
C_NULL, C_NULL, "Julia Gtk Bindings", C_NULL, C_NULL, error_check)
89+
end
90+
91+
# if g_main_depth > 0, a glib main-loop is already running,
92+
# so we don't need to start a new one
93+
if ccall((:g_main_depth, GLib.libglib), Cint, ()) == 0
94+
global gtk_main_task = schedule(Task(gtk_main))
95+
end
96+
end
97+
8798
const ser_version = Serialization.ser_version
8899
let cachedir = joinpath(splitdir(@__FILE__)[1], "..", "gen")
89100
fastgtkcache = joinpath(cachedir, "gtk$(libgtk_version.major)_julia_ser$(ser_version)")

src/events.jl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ function gtk_quit()
66
ccall((:gtk_main_quit, libgtk), Nothing, ())
77
end
88

9-
function __init__()
10-
GError() do error_check
11-
ccall((:gtk_init_with_args, libgtk), Bool,
12-
(Ptr{Nothing}, Ptr{Nothing}, Ptr{UInt8}, Ptr{Nothing}, Ptr{UInt8}, Ptr{GError}),
13-
C_NULL, C_NULL, "Julia Gtk Bindings", C_NULL, C_NULL, error_check)
14-
end
15-
16-
# if g_main_depth > 0, a glib main-loop is already running,
17-
# so we don't need to start a new one
18-
if ccall((:g_main_depth, GLib.libglib), Cint, ()) == 0
19-
global gtk_main_task = schedule(Task(gtk_main))
20-
end
21-
end
22-
23-
249
add_events(widget::GtkWidget, mask::Integer) = ccall((:gtk_widget_add_events, libgtk), Nothing, (Ptr{GObject}, GEnum), widget, mask)
2510

2611
# widget[:event] = function(ptr, obj)

0 commit comments

Comments
 (0)