1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #| GTK Application Templage (Guile Scheme version). |#
- (import (prefix (gi) gi:)
- ;; function of gi repository can be found at:
- ;; https://spk121.github.io/guile-gi/Typelib-Introspection.html
- (prefix (gi repository) gir:))
- ;; (use-typelibs ("GLib" "2.0")
- ;; ("Gio" "2.0")
- ;; ("Gtk" "3.0"))
- ;; Load Gio in version 2.0, but only, if it is not already
- ;; loaded.
- (gir:require "Gio" "2.0")
- ;; Load GTK in version 3.0, but only, if it is not already
- ;; loaded.
- (gir:require "Gtk" "3.0")
- ;; After having loaded the Gio and Gtk libraries, generate
- ;; bindings for the specified types.
- (gir:load-by-name "Gio" "Application") ; activate, run
- (gir:load-by-name "Gio" "ApplicationFlags")
- (gir:load-by-name "Gio" "Menu") ; GMenu
- (gir:load-by-name "Gio" "MenuItem")
- (gir:load-by-name "Gtk" "Application")
- (gir:load-by-name "Gtk" "ApplicationWindow")
- (gir:load-by-name "Gtk" "init")
- (gir:load-by-name "Gtk" "Widget") ; show-all
- ;; For a more compact import consider this way of writing imports, taken from
- ;; the examples of the guile-gi repository:
- ;; (import (srfi srfi-26))
- ;; (for-each
- ;; (cute load-by-name "Gtk" <>)
- ;; '("ApplicationWindow" "Application" "Container" "Window" "Widget"))
- ;; initialize GTK
- (init!)
- (define main
- (λ ()
- application:new
- (let ([app (gi:make <GtkApplication>
- #:application-id "org.gtk.example"
- #:flags (number->application-flags 0))])
- (gi:connect app activate
- (λ ()
- menu-item:new))
- (exit
- ;; Call application:run. If there are no arguments in
- ;; the command line args, this will send the `activate'
- ;; signal.
- (run app (gi:command-line))))))
- (main)
|