-
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?
Conversation
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 comment
The 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 comment
The 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 comment
The 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 gtk_main
?
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.
additionally, it is already duplicating the call to gtk_init
anyways
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.
Not sure. Have not tested this yet. The documentation says one should not call gtk_main
when using GtkApplication.
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.
I'm not really sure either. I think gtk_init
might be a no-op if called twice. And those fixes also let you call gtk_main
multiple times, across multiple tasks -- although julia's COPY_STACKS
corrupts the stack if you try that :(
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.
Indeed, the gtk_init
does not seem to hurt when using gtkapplication. when scheduling gtk_main
in __init__
and afterwards calling Gtk.run(app)
I get a crash though
signal (6): Abort trap: 6
??? at ???:202552579
??? at ???:202544405
??? at ???:-1907329622
Abort trap: 6
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 comment
The 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 2.34.1
source has been removed in 2.40.0
(i'm running the newest version, but had older code lying around). now that Keno has fixed the backtrace printing, could you run it again and see if it prints a more meaningful stack trace?
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.
tobias-knopps-macbook-2:test knopp$ julia gtkapplication_tests.jl
**
GLib:ERROR:gmain.c:3069:g_main_dispatch: assertion failed: (current->dispatching_sources == ¤t_source_link)
signal (6): Abort trap: 6
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Abort trap: 6
But if gtk_main
is scheduled first and afterwards Gtk.run(app)
is called, do you really expect that this would work.
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.
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 (although rereading that code, i see i'm missing a try/catch block)
yes, can definitely add |
ccall((:gtk_application_set_app_menu, libgtk), Void, (Ptr{GObject}, Ptr{GObject}), app, app_menu) | ||
|
||
run(app::GtkApplication) = | ||
ccall((:g_application_run, libgio), Cint, (Ptr{GObject}, Cint, Ptr{Uint8}), app, 0, C_NULL) |
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 called
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.
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
Regarding GIO we won't need anything from it but to make gtkapplication useful the following submodule should be wrapped: |
I added some initial support for GActions. It almost works but I get an error
when the quit callback is invoked. So we need support for |
can you open an issue? i hadn't implemented support because I didn't know what a GVariant would look like |
I have faked a gvariant implementation and now I can quit the application from the menu. This native OSX menu integration is great! |
haha. Excellent! I was just contemplating how much would it would be to write a proper wrapper for it |
Serious support will be implemented in #117 which seeks for an assignee... ;-) Just added a simple support for accelerators and it just works. Starts to make fun. |
First, thank you to all who looked into this. I suspect it's easier generally to not use the "application" thing, but for what it's worth, this seems to work for me:
|
Ok I had a look at
GtkApplication
and got a simple example running including a global menu on OSX. Yay.But this raises questions how to move forward. Much of the functionality around
GtkApplication
is implemented inGIO
. So is it possible to autogenerate the accessors forGIO
types as well?To get the menu actually working one has to implement the
GAction
interfaces. All this looks a little complicated and I wonder if one could define this using the regularGtkMenu
in code (withoutGtkBuilder
) with regular callbacks.