Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ...
by PaulDavisThe1st on Saturday August 19, 2023 @10:50PM
(#37195602)
GTK relies on the Glib event loop, which is in a separate library (and also used by Qt, at least optionally).
You can, if you want to, reimplement the abstract API of the Glib event loop, and use that with GTK instead.
Note also that on macOS, GTK has to integrate both the Glib event loop and the event loop used by NeXTStep/Cocoa, because it is not always the case that the same one is in control (e.g. during drag-n-drop processing). It handles this "just fine", for some definition of "just fine".
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ...
by badsectoracula on Sunday August 20, 2023 @07:45AM
(#37198215)
Yeah i was referring that is possible that toolkits to do that in general (not just GUI toolkits, AFAIK even something like Freeglut which normally uses callbacks has an API for manual main loops), not specifically about Gtk.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ...
by hsjqllzlfkf on Sunday August 20, 2023 @12:48AM
(#37196207)
You CAN try get rid of call backs if you have nice language like Julia that can inline the call back
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ...
by badsectoracula on Sunday August 20, 2023 @07:43AM
(#37198202)
You mean using anonymous functions? This is still a callback, it is just a bit nicer (at least assuming the callback code is short).
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ...
by hsjqllzlfkf on Sunday August 20, 2023 @12:20PM
(#37200552)
No, I mean by inlining.
But you could provide an API that allows the toolkit user to do their own main loop instead of having the toolkit do that. There isn't really that much of a benefit though - in theory it makes mixing with other libraries that might handle UIs easier, but in practice (having worked in a codebase that did that by mixing two toolkits - because of migration that never finished) tends to become a mess and for anything else an "idle callback" will work just fine.