inspect.scm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #| GTK Application Templage (Guile Scheme version). |#
  2. (import (prefix (gi) gi:)
  3. ;; function of gi repository can be found at:
  4. ;; https://spk121.github.io/guile-gi/Typelib-Introspection.html
  5. (prefix (gi repository) gir:))
  6. ;; (use-typelibs ("GLib" "2.0")
  7. ;; ("Gio" "2.0")
  8. ;; ("Gtk" "3.0"))
  9. ;; Load Gio in version 2.0, but only, if it is not already
  10. ;; loaded.
  11. (gir:require "Gio" "2.0")
  12. ;; Load GTK in version 3.0, but only, if it is not already
  13. ;; loaded.
  14. (gir:require "Gtk" "3.0")
  15. ;; After having loaded the Gio and Gtk libraries, generate
  16. ;; bindings for the specified types.
  17. (gir:load-by-name "Gio" "Application") ; activate, run
  18. (gir:load-by-name "Gio" "ApplicationFlags")
  19. (gir:load-by-name "Gio" "Menu") ; GMenu
  20. (gir:load-by-name "Gio" "MenuItem")
  21. (gir:load-by-name "Gtk" "Application")
  22. (gir:load-by-name "Gtk" "ApplicationWindow")
  23. (gir:load-by-name "Gtk" "init")
  24. (gir:load-by-name "Gtk" "Widget") ; show-all
  25. ;; For a more compact import consider this way of writing imports, taken from
  26. ;; the examples of the guile-gi repository:
  27. ;; (import (srfi srfi-26))
  28. ;; (for-each
  29. ;; (cute load-by-name "Gtk" <>)
  30. ;; '("ApplicationWindow" "Application" "Container" "Window" "Widget"))
  31. ;; initialize GTK
  32. (init!)
  33. (define main
  34. (λ ()
  35. application:new
  36. (let ([app (gi:make <GtkApplication>
  37. #:application-id "org.gtk.example"
  38. #:flags (number->application-flags 0))])
  39. (gi:connect app activate
  40. (λ ()
  41. menu-item:new))
  42. (exit
  43. ;; Call application:run. If there are no arguments in
  44. ;; the command line args, this will send the `activate'
  45. ;; signal.
  46. (run app (gi:command-line))))))
  47. (main)