Glade is an interface builder described as "a RAD tool to enable quick & easy development of user interfaces for the GTK+ toolkit and the GNOME desktop environment, released under the GNU GPL License. The user interfaces designed in Glade are saved as XML, and by using the libglade library these can be loaded by applications dynamically as needed."

The following screenshot shows the design of a simple GUI with glade

Once the XML interface description has saved in file interface.glade, the following program permits to load this description file and run the GUI. Note here that 3 callbacks have been defined: one for the OK button, one for Cancle button and one which is run when the interface window is destroyed.

(require "stklos-gtk-glade")
(import stklos-gtk-base
        stklos-gtk-glade)

;; ======================================================================
;;      Callbacks ...
;; ======================================================================

;; Dialog close
(define (dialog-destroy-cb widget data)
  (eprintf "Destroying dialog\n")
  (gtk-main-quit))

;; Button OK 
(define (ok-clicked-cb widget data)
  (eprintf "You have clicked the OK button\n")
  (gtk-main-quit))

;; Button Cancel
(define (cancel-clicked-cb widget data)
  (eprintf "You have clicked the Cancel button\n"))


;; ======================================================================
;;      Glade GUI ...
;; ======================================================================
(define (gtk-gui)
  (gtk-init (void) (void))
  (let* ((xml    (glade-xml-new "./interface.glade" (void) (void)))
         (widget (glade-xml-get-widget xml "dialog1")))
    (gtk-widget-show-all widget)
    (glade-xml-signal-autoconnect xml)
    (gtk-main)))

;; ======================================================================
(define (main args)
  (gtk-gui)
  (eprintf "GTk+ GUI is destroyed.\nBye\n")
  (exit 0))

And now the interface running:


Page last modified on April 10, 2008, at 11:53 AM