Gtk.jl icon indicating copy to clipboard operation
Gtk.jl copied to clipboard

WIP: GtkApplication Experiments

Open tknopp opened this issue 11 years ago • 9 comments

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 in GIO. So is it possible to autogenerate the accessors for GIO 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 regular GtkMenu in code (without GtkBuilder) with regular callbacks.

tknopp avatar Aug 02 '14 21:08 tknopp

yes, can definitely add GIO objects to the autogenerated code database

vtjnash avatar Aug 02 '14 22:08 vtjnash

Regarding GIO we won't need anything from it but to make gtkapplication useful the following submodule should be wrapped:

https://developer.gnome.org/gio/stable/application.html

tknopp avatar Aug 03 '14 06:08 tknopp

some of the others look useful too: https://developer.gnome.org/gio/stable/icons.html https://developer.gnome.org/gio/stable/gdbus-lowlevel.html https://developer.gnome.org/gio/stable/icons.html https://developer.gnome.org/gio/stable/settings.html https://developer.gnome.org/gio/stable/permissions.html https://developer.gnome.org/gio/stable/gdbus-convenience.html

vtjnash avatar Aug 03 '14 07:08 vtjnash

I added some initial support for GActions. It almost works but I get an error

ERROR: Could not convert GValue of type GVariant to Julia type
 in error at error.jl:21
...

when the quit callback is invoked. So we need support for GVariant (and GVariantType also for GSimpleAction)

tknopp avatar Aug 03 '14 14:08 tknopp

can you open an issue? i hadn't implemented support because I didn't know what a GVariant would look like

vtjnash avatar Aug 03 '14 14:08 vtjnash

I have faked a gvariant implementation and now I can quit the application from the menu. This native OSX menu integration is great!

tknopp avatar Aug 03 '14 19:08 tknopp

haha. Excellent! I was just contemplating how much would it would be to write a proper wrapper for it

vtjnash avatar Aug 03 '14 19:08 vtjnash

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.

tknopp avatar Aug 03 '14 20:08 tknopp

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:

#!/usr/bin/env julia

import Gtk

function on_clicked(w)
  @info "clicked!" # println() doesn't work here?
end


function activate(app)
  window = Gtk.GtkApplicationWindow(app)
  Gtk.set_gtk_property!(window, :title, "Hello")

  button_box = Gtk.GtkBox(:v)
  push!(window, button_box)

  button = Gtk.GtkButton("Hello world!")
  push!(button_box, button)
  Gtk.signal_connect(on_clicked, button, :clicked)

  #Gtk.showall(app) #hangs here?
  #@info "showall() ok..?"

  Gtk.showall(window) # without this, no visible window
end

# execution starts here
app = Gtk.GtkApplication("stuff.fun.my", 
        Gtk.GConstants.GApplicationFlags.FLAGS_NONE)

Gtk.signal_connect(activate, app, :activate)

Gtk.run(app)

malbert137 avatar Aug 06 '20 23:08 malbert137