guile-gtk-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile-gnome: custom C functions


From: gregory benison
Subject: guile-gnome: custom C functions
Date: Mon, 21 Mar 2005 15:39:05 -0500
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)


What is the best way to interface guile-gnome with C functions that use GTK types? For example, say one would like to do this in guile:

(define the-window (make <gtk-window>))
(window-do-something  the-window)

Where window-do-something is a guile wrapper for a C function with this prototype:

void window_do_something(GtkWindow* window);

Here is the input to g-wrap I used to do this; seems to work. Can anyone comment?

;
; GCB 3.21.05
;
; g-wrap instructions to create a wrapset that wraps
; a single function "void window_do_something(GtkWindow*)".
;
(use-modules (oop goops)
        (g-wrap)
        (g-wrap guile)
        (g-wrap c-types)
        (gnome gw gobject-spec)
        (g-wrap guile ws standard))

(read-set! keywords 'prefix)

(define (c-local-header name)
 (string-append "#include \"" name "\"\n"))

(define-class <my-wrapset> (<gw-guile-wrapset>)
 #:dependencies '(standard gnome-gobject)
 #:id 'my-wrapset)

(define-method (global-declarations-cg (ws <my-wrapset>))
 (list
  (next-method)
  (c-local-header "extra.h")))

(define-method (initialize (ws <my-wrapset>) initargs)
 (next-method ws initargs)

 (wrap-function! ws
         :name 'window-do-something
         :returns 'void
         :c-name "window_do_something"
         :arguments '(((<gobject> caller-owned) window))
         :description "C function which manipulates a GtkWindow"))

(generate-wrapset 'guile 'my-wrapset "my_wrapset")






reply via email to

[Prev in Thread] Current Thread [Next in Thread]