;; gtk2.ffi				-*- Scheme -*-

;; Copyright (C) 2018 Matthew R. Wette
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
;; License as published by the Free Software Foundation; either
;; version 3 of the License, or (at your option) any later version.
;;
;; This library is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; Lesser General Public License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public License
;; along with this library; if not, see <http://www.gnu.org/licenses/>

(define-ffi-module (ffi gtk2)
  #:pkg-config "gtk+-2.0"
  #:include '("gtk/gtk.h")
  #:inc-filter (lambda (f p) (string-contains p "gtk/" 0))
  #:use-ffi-module (ffi gdk2)
  #:use-ffi-module (ffi pango)
  #:use-ffi-module (ffi gobject)
  #:use-ffi-module (ffi glib))

(define-fh-pointer-type GtkEnumValue* int*-desc
  GtkEnumValue*? make-GtkEnumValue*)
(export GtkEnumValue* GtkEnumValue*? make-GtkEnumValue*)

(define-public gtk-symval ffi-gtk2-symbol-val)
  
;; OK, some gtk programs use (lambda (widget event arg) ...) and Gtk etc does
;; not provide it so I hacek it here
(define-public GtkEventCallback-desc
  (bs:pointer
   (fh:function
    'void (list (bs:pointer 'void) (bs:pointer 'void) (bs:pointer 'void)))))
(define-fh-function*-type GtkEventCallback
  GtkEventCallback-desc  GtkEventCallback? make-GtkEventCallback)
(export GtkEventCallback GtkEventCallback? make-GtkEventCallback)

;; This is the c function.
(define-public ~gtk_widget_destroy
  (fh-find-symbol-addr "gtk_widget_destroy" (force ffi-gtk2-llibs)))

(define-public ~gtk_main_quit
  (fh-find-symbol-addr "gtk_main_quit" (force ffi-gtk2-llibs)))

;; --- last line ---
