example-01-using-gtypes.scm 567 B

12345678910111213141516171819202122232425
  1. (import
  2. (prefix (gi) gi:))
  3. (gi:use-typelibs ("GLib" "2.0"))
  4. ;; From the docs: "If a typelib does not provide an explicit
  5. ;; constructor for a struct or union, an empty instance can
  6. ;; be created by using make."
  7. ;; Create a new empty <GDate> using 'make'
  8. (gi:write (gi:make <GDate>))
  9. (newline)
  10. ;; Create a new <GDate> using a constructor procedure
  11. (define dt
  12. (date:new-dmy 1
  13. (symbol->date-month 'january)
  14. 2000))
  15. ;; Modify the contents of <GDate>
  16. (add-years dt 1)
  17. ;; Compute the resulting year
  18. (gi:write (get-year dt))
  19. (newline)