-
Notifications
You must be signed in to change notification settings - Fork 80
WIP: GtkApplication Experiments #116
base: master
Are you sure you want to change the base?
Changes from 1 commit
c5c5ddb
d0923fb
efda568
dac461b
02e1b41
57c8b08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ function __init__() | |
|
||
# if g_main_depth > 0, a glib main-loop is already running, | ||
# so we don't need to start a new one | ||
if ccall((:g_main_depth,GLib.libglib),Cint,()) == 0 | ||
global gtk_main_task = @schedule gtk_main() | ||
end | ||
#if ccall((:g_main_depth,GLib.libglib),Cint,()) == 0 | ||
# global gtk_main_task = @schedule gtk_main() | ||
#end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can just delete this, or I'll get around to it sometime. might be good to open an issue to remind me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question is if we want to allow to automatically call it when being on the REPL, which would be nice for interactive usage but would be not so nice because one could not use GtkApplication from the REPL. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For that, I have no idea (#100 (comment)) Is it OK to start the GtkApplication main loop from inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. additionally, it is already duplicating the call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. Have not tested this yet. The documentation says one should not call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really sure either. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, the
So it seems that gtk_init can stay but gtk_main should be removed and the user simply has to call it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i checked the glib code again, and realized the concerning code i had seen in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. this indicates you are running on a version of glib prior to 2.40.0 with COPY_STACKS in julia. it also potentially indicates that I'm returning from the jl_yield callbacks in the wrong order, but I thought i fixed that in 0a63ea7#diff-8c2b506e7179e52e816713686d731068R248 |
||
end | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Gtk, Gtk.ShortNames, Gtk.GConstants | ||
|
||
app = @GtkApplication("org.julia.example", GApplicationFlags.FLAGS_NONE) | ||
|
||
const builderstr = | ||
"""<interface> | ||
<menu id="menubar"> | ||
<submenu> | ||
<attribute name="label">File</attribute> | ||
<item> | ||
<attribute name="label">Quit</attribute> | ||
<attribute name="action">app.quit</attribute> | ||
</item> | ||
</submenu> | ||
<submenu> | ||
<attribute name="label">Help</attribute> | ||
</submenu> | ||
</menu> | ||
<menu id="appmenu"> | ||
<section> | ||
<item> | ||
<attribute name="label">New</attribute> | ||
<attribute name="action">app.new</attribute> | ||
</item> | ||
<item> | ||
<attribute name="label">Quit</attribute> | ||
<attribute name="action">app.quit</attribute> | ||
</item> | ||
</section> | ||
</menu> | ||
</interface>""" | ||
|
||
signal_connect(app,"activate") do a, args... | ||
w = Gtk.@GtkApplicationWindow(a) | ||
G_.title(w, "GtkApplication Test App" ) | ||
G_.default_size(w, 400,400) | ||
builder = @GtkBuilder(buffer=builderstr) | ||
|
||
menubar = G_.object(builder,"menubar") | ||
appmenu = G_.object(builder,"appmenu") | ||
|
||
Gtk.set_menubar(app, menubar) | ||
Gtk.set_app_menu(app, appmenu) | ||
|
||
#quitIt = G_.object(builder, "menu_item_quit") | ||
#signal_connect(quitIt, :activate) do widget | ||
# exit() | ||
#end | ||
|
||
showall(w) | ||
end | ||
|
||
Gtk.run(app) # enters main loop | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:gtk_application_run
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does not exist. its the
g
function that has to be calledThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oi! apparently it existed in 3.0, then disappear before release? https://developer.gnome.org/gtk3/2.90/GtkApplication.html#gtk-application-run
carry on then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats strange