Fixed ref counting problem when reading the icon-list slot in windows
[clg] / gtk / gtk.lisp
index d54aaca..bf7c8cd 100644 (file)
@@ -1,21 +1,26 @@
-;; Common Lisp bindings for GTK+ v2.0
-;; Copyright (C) 1999-2001 Espen S. Johnsen <esj@stud.cs.uit.no>
+;; Common Lisp bindings for GTK+ v2.x
+;; Copyright 1999-2005 Espen S. Johnsen <espen@users.sf.net>
 ;;
 ;;
-;; 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 2 of the License, or (at your option) any later version.
+;; Permission is hereby granted, free of charge, to any person obtaining
+;; a copy of this software and associated documentation files (the
+;; "Software"), to deal in the Software without restriction, including
+;; without limitation the rights to use, copy, modify, merge, publish,
+;; distribute, sublicense, and/or sell copies of the Software, and to
+;; permit persons to whom the Software is furnished to do so, subject to
+;; the following conditions:
 ;;
 ;;
-;; 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.
+;; The above copyright notice and this permission notice shall be
+;; included in all copies or substantial portions of the Software.
 ;;
 ;;
-;; You should have received a copy of the GNU Lesser General Public
-;; License along with this library; if not, write to the Free Software
-;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
-;; $Id: gtk.lisp,v 1.31 2005-01-13 00:17:55 espen Exp $
+;; $Id: gtk.lisp,v 1.49 2006-02-06 19:16:17 espen Exp $
 
 
 (in-package "GTK")
 
 
 (in-package "GTK")
        (format nil "Gtk+ v~A.~A" major minor) 
       (format nil "Gtk+ v~A.~A.~A" major minor micro))))
 
        (format nil "Gtk+ v~A.~A" major minor) 
       (format nil "Gtk+ v~A.~A.~A" major minor micro))))
 
-(defbinding get-default-language () (copy-of pango:language))
+(defun clg-version ()
+  "clg 0.91 version")
 
 
 ;;;; Initalization
 
 
 
 ;;;; Initalization
 
-(defbinding (gtk-init "gtk_parse_args") () nil
+(defbinding (gtk-init "gtk_parse_args") () boolean
   "Initializes the library without opening the display."
   (nil null)
   (nil null))
   "Initializes the library without opening the display."
   (nil null)
   (nil null))
   "Initializes the system and starts the event handling"
   (unless (gdk:display-get-default)
     (gdk:gdk-init)
   "Initializes the system and starts the event handling"
   (unless (gdk:display-get-default)
     (gdk:gdk-init)
-    (gtk-init)
+    (unless (gtk-init)
+      (error "Initialization of GTK+ failed."))
     (prog1
        (gdk:display-open display)
     (prog1
        (gdk:display-open display)
-      (system:add-fd-handler 
-       (gdk:display-connection-number) :input #'main-iterate-all)
-      (setq lisp::*periodic-polling-function* #'main-iterate-all)
-      (setq lisp::*max-event-to-sec* 0)
-      (setq lisp::*max-event-to-usec* 1000))))
+      (add-fd-handler (gdk:display-connection-number) :input #'main-iterate-all)
+      (setq *periodic-polling-function* #'main-iterate-all)
+      (setq *max-event-to-sec* 0)
+      (setq *max-event-to-usec* 1000))))
+
+
+;;; Misc
+
+(defbinding grab-add () nil
+  (widget widget))
+
+(defbinding grab-get-current () widget)
+
+(defbinding grab-remove () nil
+  (widget widget))
+
+(defbinding get-default-language () (copy-of pango:language))
+
+
+;;; About dialog
+
+#+gtk2.6
+(progn
+  (def-callback-marshal %about-dialog-activate-link-func 
+    (nil (dialog about-dialog) (link (copy-of string))))
+
+  (defbinding about-dialog-set-email-hook (function) nil
+    ((callback %about-dialog-activate-link-func) pointer)
+    ((register-callback-function function) unsigned-int)
+    ((callback user-data-destroy-func) pointer))
+  
+  (defbinding about-dialog-set-url-hook (function) nil
+    ((callback %about-dialog-activate-link-func) pointer)
+    ((register-callback-function function) unsigned-int)
+    ((callback user-data-destroy-func) pointer)))
 
 
 ;;; Acccel group
 
 
 ;;; Acccel group
   (gclosure gclosure))
 
 (defun accel-group-connect (group accelerator function &optional flags)
   (gclosure gclosure))
 
 (defun accel-group-connect (group accelerator function &optional flags)
-  (multiple-value-bind (key modifiers) (accelerator-parse accelerator)
+  (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
     (let ((gclosure (make-callback-closure function)))
       (%accel-group-connect group key modifiers flags gclosure)
       gclosure)))
     (let ((gclosure (make-callback-closure function)))
       (%accel-group-connect group key modifiers flags gclosure)
       gclosure)))
   (etypecase accelerator
     (gclosure (%accel-group-disconnect group accelerator))
     (string 
   (etypecase accelerator
     (gclosure (%accel-group-disconnect group accelerator))
     (string 
-     (multiple-value-bind (key modifiers) (accelerator-parse accelerator)
+     (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
        (%accel-group-disconnect-key group key modifiers)))))
 
        (%accel-group-disconnect-key group key modifiers)))))
 
+(defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
+  (accel-group accel-group)
+  (key unsigned-int)
+  (modifiers gdk:modifier-type)
+  (n int :out))
+
+(defun accel-group-query (accel-group accelerator)
+  (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
+    (%accel-group-query accel-group key modifiers)))
+
+(defbinding %accel-group-activate () boolean
+  (accel-group accel-group)
+  (acceleratable gobject)
+  (key unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(defun accel-group-activate (accel-group acceleratable accelerator)
+  (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
+    (%accel-group-activate accel-group acceleratable key modifiers)))
+
 (defbinding accel-group-lock () nil
   (accel-group accel-group))
 
 (defbinding accel-group-unlock () nil
   (accel-group accel-group))
 
 (defbinding accel-group-lock () nil
   (accel-group accel-group))
 
 (defbinding accel-group-unlock () nil
   (accel-group accel-group))
 
+(defbinding accel-group-from-accel-closure () accel-group
+  (closure gclosure))
+
 (defbinding %accel-groups-activate () boolean
   (object gobject)
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 
 (defun accel-groups-activate (object accelerator)
 (defbinding %accel-groups-activate () boolean
   (object gobject)
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 
 (defun accel-groups-activate (object accelerator)
-  (multiple-value-bind (key modifiers) (accelerator-parse accelerator)
+  (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
     (%accel-groups-activate object key modifiers)))
 
 (defbinding accel-groups-from-object () (gslist accel-groups)
   (object gobject))
 
     (%accel-groups-activate object key modifiers)))
 
 (defbinding accel-groups-from-object () (gslist accel-groups)
   (object gobject))
 
-(defbinding accelerator-valid-p (key &optional mask) boolean
+(defbinding accelerator-valid-p (key &optional modifiers) boolean
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 
   (key unsigned-int :out)
   (modifiers gdk:modifier-type :out))
 
   (key unsigned-int :out)
   (modifiers gdk:modifier-type :out))
 
-(defun accelerator-parse (accelerator)
+(defgeneric parse-accelerator (accelerator))
+
+(defmethod parse-accelerator ((accelerator string))
   (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
     (if (zerop key)
        (error "Invalid accelerator: ~A" accelerator)
       (values key modifiers))))
 
   (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
     (if (zerop key)
        (error "Invalid accelerator: ~A" accelerator)
       (values key modifiers))))
 
+(defmethod parse-accelerator ((accelerator cons))
+  (destructuring-bind (key modifiers) accelerator
+    (values
+     (etypecase key
+       (integer key)
+       (string
+       (or 
+        (gdk:keyval-from-name key)
+        (error "Invalid key name: ~A" key)))
+       (character (parse-accelerator key)))
+     modifiers)))
+
+(defmethod parse-accelerator ((key integer))
+  key)
+
+(defmethod parse-accelerator ((key character))
+  (or
+   (gdk:keyval-from-name (string key))
+   (error "Invalid key name: ~A" key)))
+
+
 (defbinding accelerator-name () string
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 (defbinding accelerator-name () string
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 
 ;;; Acccel label
 
 
 ;;; Acccel label
 
+(defbinding accel-label-get-accel-width () unsigned-int
+  (accel-label accel-label))
+
 (defbinding accel-label-refetch () boolean
   (accel-label accel-label))
 
 (defbinding accel-label-refetch () boolean
   (accel-label accel-label))
 
 
 ;;; Accel map
 
 
 ;;; Accel map
 
+(defbinding (accel-map-init "_gtk_accel_map_init") () nil)
+
 (defbinding %accel-map-add-entry () nil
   (path string)
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 
 (defun accel-map-add-entry (path accelerator)
 (defbinding %accel-map-add-entry () nil
   (path string)
   (key unsigned-int)
   (modifiers gdk:modifier-type))
 
 (defun accel-map-add-entry (path accelerator)
-  (multiple-value-bind (key modifiers) (accelerator-parse accelerator)
+  (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
     (%accel-map-add-entry path key modifiers)))
 
     (%accel-map-add-entry path key modifiers)))
 
-(defbinding accel-map-lookup-entry () boolean
+(defbinding %accel-map-lookup-entry () boolean
   (path string)
   (path string)
-  (key pointer)) ;accel-key))
+  ((make-instance 'accel-key) accel-key :return))
+
+(defun accel-map-lookup-entry (path)
+  (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
+    (when found-p
+      (values 
+       (slot-value accel-key 'key)
+       (slot-value accel-key 'modifiers)
+       (slot-value accel-key 'flags)))))
 
 (defbinding %accel-map-change-entry () boolean
   (path string)
 
 (defbinding %accel-map-change-entry () boolean
   (path string)
   (replace boolean))
 
 (defun accel-map-change-entry (path accelerator &optional replace)
   (replace boolean))
 
 (defun accel-map-change-entry (path accelerator &optional replace)
-  (multiple-value-bind (key modifiers) (accelerator-parse accelerator)
+  (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
     (%accel-map-change-entry path key modifiers replace)))
 
 (defbinding accel-map-load () nil
     (%accel-map-change-entry path key modifiers replace)))
 
 (defbinding accel-map-load () nil
 (defbinding accel-map-save () nil
   (filename pathname))
 
 (defbinding accel-map-save () nil
   (filename pathname))
 
+(defcallback %accel-map-foreach-func 
+    (nil
+     (callback-id unsigned-int) (accel-path (copy-of string)) 
+     (key unsigned-int) (modifiers gdk:modifier-type) (changed boolean))
+  (invoke-callback callback-id nil accel-path key modifiers changed))
+
+(defbinding %accel-map-foreach (callback-id) nil
+  (callback-id unsigned-int)
+  (%accel-map-foreach-func callback))
+
+(defbinding %accel-map-foreach-unfiltered (callback-id) nil
+  (callback-id unsigned-int)
+  (%accel-map-foreach-func callback))
+
+(defun accel-map-foreach (function &optional (filter-p t))
+  (with-callback-function (id function)
+    (if filter-p                         
+       (%accel-map-foreach id)
+      (%accel-map-foreach-unfiltered id))))
+
+(defbinding accel-map-add-filter () nil
+  (filter string))
+
 (defbinding accel-map-get () accel-map)
 
 (defbinding accel-map-lock-path () nil
 (defbinding accel-map-get () accel-map)
 
 (defbinding accel-map-lock-path () nil
 
 
 
 
 
 
-;;; Accessible
+;;; Accessibility
 
 (defbinding accessible-connect-widget-destroyed () nil
   (accessible accessible))
 
 (defbinding accessible-connect-widget-destroyed () nil
   (accessible accessible))
   (container-add bin child)
   child)
 
   (container-add bin child)
   child)
 
-(defmethod create-callback-function ((bin bin) function arg1)
-  (if (eq arg1 :child)
+(defmethod compute-signal-function ((bin bin) signal function object)
+  (declare (ignore signal))
+  (if (eq object :child)
       #'(lambda (&rest args) 
          (apply function (bin-child bin) (rest args)))
     (call-next-method)))
       #'(lambda (&rest args) 
          (apply function (bin-child bin) (rest args)))
     (call-next-method)))
   (check-menu-item check-menu-item))
 
 
   (check-menu-item check-menu-item))
 
 
-
-;;; Clipboard
-
-
 ;;; Color selection
 
 (defbinding (color-selection-is-adjusting-p
 ;;; Color selection
 
 (defbinding (color-selection-is-adjusting-p
     (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
   
 
     (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
   
 
-(defun %dialog-find-response-id-num (dialog id &optional create-p error-p)
-  (or
-   (cadr (assoc id (rest (type-expand-1 'response-type))))
-   (let ((response-ids (object-data dialog 'response-id-key)))
-    (cond
-      ((and response-ids (position id response-ids :test #'equal)))
-      (create-p
+(defun dialog-response-id (dialog response &optional create-p error-p)
+  "Returns a numeric response id"
+  (if (typep response 'response-type)
+      (response-type-to-int response)
+    (let ((responses (object-data dialog 'responses)))
+      (cond
+       ((and responses (position response responses :test #'equal)))
+       (create-p
        (cond
        (cond
-        (response-ids
-         (vector-push-extend id response-ids)
-         (1- (length response-ids)))
+        (responses
+         (vector-push-extend response responses)
+         (1- (length responses)))
         (t
          (setf 
         (t
          (setf 
-          (object-data dialog 'response-id-key)
-          (make-array 1 :adjustable t :fill-pointer t :initial-element id))
+          (object-data dialog 'responses)
+          (make-array 1 :adjustable t :fill-pointer t 
+                      :initial-element response))
          0)))
       (error-p
          0)))
       (error-p
-       (error "Invalid response: ~A" id))))))
-
-(defun %dialog-find-response-id (dialog response-id-num)
-  (if (< response-id-num 0)
-      (car
-       (rassoc
-       (list response-id-num)
-       (rest (type-expand-1 'response-type)) :test #'equal))
-    (aref (object-data dialog 'response-id-key) response-id-num )))
-
-
-(defmethod signal-connect ((dialog dialog) signal function &key object after)
-  (let ((response-id-num (%dialog-find-response-id-num dialog signal)))
-    (cond
-     (response-id-num
-      (call-next-method
-       dialog 'response
-       #'(lambda (dialog id)
-          (when (= id response-id-num)
-            (cond
-             ((eq object t) (funcall function dialog))
-             (object (funcall function object))
-             (t (funcall function)))))
-       :object t :after after))
-    ((call-next-method)))))
+       (error "Invalid response: ~A" response))))))
+
+(defun dialog-find-response (dialog id)
+  "Finds a symbolic response given a numeric id"
+  (if (< id 0)
+      (int-to-response-type id)
+    (aref (object-data dialog 'responses) id)))
+
 
 
+(defmethod compute-signal-id ((dialog dialog) signal)
+  (if (dialog-response-id dialog signal)
+      (ensure-signal-id 'response dialog)
+    (call-next-method)))
+
+(defmethod compute-signal-function ((dialog dialog) signal function object)
+  (declare (ignore function object))
+  (let ((callback (call-next-method))
+       (id (dialog-response-id dialog signal)))
+    (if id
+       #'(lambda (dialog response)
+           (when (= response id)
+             (funcall callback dialog)))
+      callback)))
 
 (defbinding dialog-run () nil
   (dialog dialog))
 
 
 (defbinding dialog-run () nil
   (dialog dialog))
 
-(defbinding dialog-response (dialog response-id) nil
+(defbinding dialog-response (dialog response) nil
   (dialog dialog)
   (dialog dialog)
-  ((%dialog-find-response-id-num dialog response-id nil t) int))
+  ((dialog-response-id dialog response nil t) int))
 
 
 (defbinding %dialog-add-button () button
   (dialog dialog)
   (text string)
 
 
 (defbinding %dialog-add-button () button
   (dialog dialog)
   (text string)
-  (response-id-num int))
+  (response-id int))
 
 (defun dialog-add-button (dialog label &optional (response label)
                          &key default object after)
   "Adds a button to the dialog."
 
 (defun dialog-add-button (dialog label &optional (response label)
                          &key default object after)
   "Adds a button to the dialog."
-  (let* ((id (if (functionp response)
-                label
-              response))
-        (id-num (%dialog-find-response-id-num dialog id t))
-        (button (%dialog-add-button dialog label id-num)))
+  (let* ((signal (if (functionp response)
+                    label
+                  response))
+        (id (dialog-response-id dialog signal t))
+        (button (%dialog-add-button dialog label id)))
     (when (functionp response)
     (when (functionp response)
-       (signal-connect dialog id response :object object :after after))
+       (signal-connect dialog signal response :object object :after after))
     (when default
     (when default
-      (%dialog-set-default-response dialog id-num))
+      (%dialog-set-default-response dialog id))
     button))
 
 
     button))
 
 
-(defbinding %dialog-add-action-widget () button
+(defbinding %dialog-add-action-widget () nil
   (dialog dialog)
   (action-widget widget)
   (dialog dialog)
   (action-widget widget)
-  (response-id-num int))
+  (response-id int))
 
 (defun dialog-add-action-widget (dialog widget &optional (response widget)
                                 &key default object after)
 
 (defun dialog-add-action-widget (dialog widget &optional (response widget)
                                 &key default object after)
-  (let* ((id (if (functionp response)
-                widget
-              response))
-        (id-num (%dialog-find-response-id-num dialog id t)))
-    (%dialog-add-action-widget dialog widget id-num)
+  (let* ((signal (if (functionp response)
+                    widget
+                  response))
+        (id (dialog-response-id dialog signal t)))
+    (unless (widget-hidden-p widget)
+      (widget-show widget))
+    (%dialog-add-action-widget dialog widget id)
     (when (functionp response)
     (when (functionp response)
-       (signal-connect dialog id response :object object :after after))
+       (signal-connect dialog signal response :object object :after after))
     (when default
     (when default
-      (%dialog-set-default-response dialog id-num))
+      (%dialog-set-default-response dialog id))
     widget))
 
 
 (defbinding %dialog-set-default-response () nil
   (dialog dialog)
     widget))
 
 
 (defbinding %dialog-set-default-response () nil
   (dialog dialog)
-  (response-id-num int))
+  (response-id int))
 
 
-(defun dialog-set-default-response (dialog response-id)
+(defun dialog-set-default-response (dialog response)
   (%dialog-set-default-response
   (%dialog-set-default-response
-   dialog (%dialog-find-response-id-num dialog response-id nil t)))
+   dialog (dialog-response-id dialog response nil t)))
 
 
-(defbinding dialog-set-response-sensitive (dialog response-id sensitive) nil
+(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
   (dialog dialog)
   (dialog dialog)
-  ((%dialog-find-response-id-num dialog response-id nil t) int)
+  ((dialog-response-id dialog response nil t) int)
   (sensitive boolean))
 
 #+gtk2.6
   (sensitive boolean))
 
 #+gtk2.6
-(defbinding alternative-dialog-button-order-p(&optional screen)
-  (screen (or null screen)))
+(defbinding alternative-dialog-button-order-p (&optional screen) boolean
+  (screen (or null gdk:screen)))
 
 #+gtk2.6
 (defbinding (dialog-set-alternative-button-order 
 
 #+gtk2.6
 (defbinding (dialog-set-alternative-button-order 
     (dialog new-order)
   (dialog dialog)
   ((length new-order) int)
     (dialog new-order)
   (dialog dialog)
   ((length new-order) int)
-  ((map 'vector #'(lambda (id)
-                   (%dialog-find-response-id-num dialog id nil t))
+  ((map 'vector #'(lambda (response)
+                   (dialog-response-id dialog response nil t))
        new-order) (vector int)))
 
 
        new-order) (vector int)))
 
 
+#+gtk2.8
+(progn
+  (defbinding %dialog-get-response-for-widget () int
+    (dialog dialog)
+    (widget widget))
+
+  (defun dialog-get-response-for-widget (dialog widget)
+    (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
+
+
 (defmethod container-add ((dialog dialog) (child widget) &rest args)
   (apply #'container-add (dialog-vbox dialog) child args))
 
 (defmethod container-add ((dialog dialog) (child widget) &rest args)
   (apply #'container-add (dialog-vbox dialog) child args))
 
+
 (defmethod container-remove ((dialog dialog) (child widget))
   (container-remove (dialog-vbox dialog) child))
 
 (defmethod container-remove ((dialog dialog) (child widget))
   (container-remove (dialog-vbox dialog) child))
 
   (completion entry-completion)
   ((callback %entry-completion-match-func) pointer)
   ((register-callback-function function) unsigned-int)
   (completion entry-completion)
   ((callback %entry-completion-match-func) pointer)
   ((register-callback-function function) unsigned-int)
-  ((callback %destroy-user-data) pointer))
+  ((callback user-data-destroy-func) pointer))
 
 (defbinding entry-completion-complete () nil
   (completion entry-completion))
 
 (defbinding entry-completion-complete () nil
   (completion entry-completion))
 
 #+gtk2.6
 (defbinding file-filter-add-pixbuf-formats () nil
 
 #+gtk2.6
 (defbinding file-filter-add-pixbuf-formats () nil
-  (filter file-filter)
-  (pattern string))
+  (filter file-filter))
 
 (def-callback-marshal %file-filter-func (boolean file-filter-info))
 
 
 (def-callback-marshal %file-filter-func (boolean file-filter-info))
 
-(defbinding file-filter-add-custom () nil
+(defbinding file-filter-add-custom (filter needed function) nil
   (filter file-filter)
   (needed file-filter-flags)
   ((callback %file-filter-func) pointer)
   ((register-callback-function function) unsigned-int)
   (filter file-filter)
   (needed file-filter-flags)
   ((callback %file-filter-func) pointer)
   ((register-callback-function function) unsigned-int)
-  ((callback %destroy-user-data) pointer))
+  ((callback user-data-destroy-func) pointer))
 
 (defbinding file-filter-get-needed () file-filter-flags
   (filter file-filter))
 
 (defbinding file-filter-get-needed () file-filter-flags
   (filter file-filter))
     ((or list vector) (make-instance 'image :pixmap source))
     (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
 
     ((or list vector) (make-instance 'image :pixmap source))
     (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
 
+#+gtk2.8
+(defbinding image-clear () nil
+  (image image))
+
+
 
 ;;; Image menu item
 
 
 ;;; Image menu item
 
 
 ;;; Label
 
 
 ;;; Label
 
+(defmethod shared-initialize ((label label) names &key pattern)
+  (declare (ignore names))
+  (call-next-method)
+  (when pattern
+    (setf (label-pattern label) pattern)))
+
 (defbinding label-get-layout-offsets () nil
   (label label)
   (x int :out)
 (defbinding label-get-layout-offsets () nil
   (label label)
   (x int :out)
   "Add BUTTON1 to the group which BUTTON2 belongs to."
   (%radio-button-set-group button1 (%radio-button-get-group button2)))
 
   "Add BUTTON1 to the group which BUTTON2 belongs to."
   (%radio-button-set-group button1 (%radio-button-get-group button2)))
 
+(defun %add-activate-callback (widget signal function object after)
+  (if object
+      (signal-connect widget signal
+       #'(lambda (object)
+          (when (slot-value widget 'active)
+            (funcall function object (slot-value widget 'value))))
+       :object object :after after)
+    (signal-connect widget signal 
+     #'(lambda ()
+        (when (slot-value widget 'active)
+          (funcall function (slot-value widget 'value))))
+     :after after)))
+
+(defmethod activate-radio-widget ((button radio-button))
+  (signal-emit button 'clicked))
+
+(defmethod add-activate-callback ((button radio-button) function &key object after)
+  (%add-activate-callback button 'clicked function object after))
+
 (defmethod initialize-instance ((button radio-button) &key group)
   (prog1
       (call-next-method)
 (defmethod initialize-instance ((button radio-button) &key group)
   (prog1
       (call-next-method)
 ;;; Menu tool button
 
 #+gtk2.6
 ;;; Menu tool button
 
 #+gtk2.6
-(defbinding menu-tool-button-set-arrow-tip () nil
+(defbinding menu-tool-button-set-arrow-tooltip () nil
   (menu-tool-button menu-tool-button)
   (tooltips tooltips)
   (tip-text string)
   (menu-tool-button menu-tool-button)
   (tooltips tooltips)
   (tip-text string)
 
 ;;; Message dialog
 
 
 ;;; Message dialog
 
-(defmethod initialize-instance ((dialog message-dialog) &rest initargs 
-                               &key (type :info) (buttons :close) ; or :ok? 
-                               flags message parent)
-  (remf initargs :parent)
+(defmethod initialize-instance ((dialog message-dialog)
+                               &key (message-type :info) (buttons :close)
+                               flags text #+gtk 2.6 secondary-text 
+                               transient-parent)
   (setf 
    (slot-value dialog 'location)
   (setf 
    (slot-value dialog 'location)
-   (%message-dialog-new parent flags type buttons nil))
-  (message-dialog-set-markup dialog message)
-  (apply #'call-next-method dialog initargs))
+   (%message-dialog-new transient-parent flags message-type buttons))
+  (when text
+    (message-dialog-set-markup dialog text))
+  #+gtk2.6
+  (when secondary-text
+    (message-dialog-format-secondary-markup dialog secondary-text))
+  (call-next-method))
 
 
 (defbinding %message-dialog-new () pointer
 
 
 (defbinding %message-dialog-new () pointer
   (flags dialog-flags)
   (type message-type)
   (buttons buttons-type)
   (flags dialog-flags)
   (type message-type)
   (buttons buttons-type)
-  (message (or null string)))
-
-(defbinding %message-dialog-new-with-markup () pointer
-  (parent (or null window))
-  (flags dialog-flags)
-  (type message-type)
-  (buttons buttons-type)
-  (message string))
+  (nil null))
 
 (defbinding message-dialog-set-markup () nil
   (message-dialog message-dialog)
 
 (defbinding message-dialog-set-markup () nil
   (message-dialog message-dialog)
   (radio-menu-item radio-menu-item)
   (group pointer))
 
   (radio-menu-item radio-menu-item)
   (group pointer))
 
+(defmethod activate-radio-widget ((item radio-menu-item))
+  (menu-item-activate item))
+
 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
   "Add ITEM1 to the group which ITEM2 belongs to."
   (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
 
 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
   "Add ITEM1 to the group which ITEM2 belongs to."
   (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
 
+(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
+  (%add-activate-callback item 'activate function object after))
+
 (defmethod initialize-instance ((item radio-menu-item) &key group)
   (prog1
       (call-next-method)
 (defmethod initialize-instance ((item radio-menu-item) &key group)
   (prog1
       (call-next-method)
   (radio-tool-button radio-tool-button)
   (group pointer))
 
   (radio-tool-button radio-tool-button)
   (group pointer))
 
+(defmethod activate-radio-widget ((button radio-tool-button))
+  (signal-emit button 'clicked))
+
 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
   "Add BUTTON1 to the group which BUTTON2 belongs to."
   (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
   "Add BUTTON1 to the group which BUTTON2 belongs to."
   (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
-
-(defmethod add-activate-callback ((widget widget) function &key object after)
-  (if object
-      (signal-connect widget 'clicked
-       #'(lambda (object)
-          (when (slot-value widget 'active)
-            (funcall function object (slot-value widget 'value))))
-       :object object :after after)
-    (signal-connect widget 'clicked 
-     #'(lambda ()
-        (when (slot-value widget 'active)
-          (funcall function (slot-value widget 'value))))
-     :after after)))
+(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
+  (%add-activate-callback button 'clicked function object after))
 
 (defmethod initialize-instance ((button radio-tool-button) &key group)
   (prog1
 
 (defmethod initialize-instance ((button radio-tool-button) &key group)
   (prog1
   (window window)
   (event gdk:key-event))
 
   (window window)
   (event gdk:key-event))
 
+#-gtk2.8
 (defbinding window-present () nil
   (window window))
 
 (defbinding window-present () nil
   (window window))
 
+#+gtk2.8
+(progn
+  (defbinding %window-present () nil
+    (window window))
+
+  (defbinding %window-present-with-time () nil
+    (window window)
+    (timespamp unsigned-int))
+
+  (defun window-present (window &optional timestamp)
+    (if timestamp
+       (%window-present-with-time window timestamp)
+      (%window-present window))))
+
 (defbinding window-iconify () nil
   (window window))
 
 (defbinding window-iconify () nil
   (window window))
 
   (width int)
   (heigth int))
 
   (width int)
   (heigth int))
 
+(defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
+  (window window))
+
 
 ;;; Window group
 
 
 ;;; Window group
 
    (scrolled-window scrolled-window)
    (child widget))
 
    (scrolled-window scrolled-window)
    (child widget))
 
-(defmethod initialize-instance ((window scrolled-window) &rest initargs 
-                               &key policy)
-  (if policy
-      (apply #'call-next-method window 
-       :vscrollbar-policy policy :hscrollbar-policy policy initargs)
-    (call-next-method)))
+(defmethod shared-initialize ((window scrolled-window) names &key policy)
+  (declare (ignore names))
+  (when policy 
+    (setf (slot-value window 'hscrollbar-policy) policy)
+    (setf (slot-value window 'vscrollbar-policy) policy))
+  (call-next-method))
 
 
 ;;; Statusbar
 
 
 ;;; Statusbar
 (defbinding notebook-reorder-child (notebook child position) nil
   (notebook notebook)
   (child widget)
 (defbinding notebook-reorder-child (notebook child position) nil
   (notebook notebook)
   (child widget)
-  ((%notebook-position notebook position) int))
+  ((%ensure-notebook-position notebook position) int))
 
 (defbinding notebook-popup-enable () nil
   (notebook notebook))
 
 (defbinding notebook-popup-enable () nil
   (notebook notebook))
 
 (defbinding notebook-query-tab-label-packing (notebook page) nil
   (notebook notebook)
 
 (defbinding notebook-query-tab-label-packing (notebook page) nil
   (notebook notebook)
-  ((%notebook-child notebook page) widget)
+  ((%ensure-notebook-child notebook page) widget)
   (expand boolean :out)
   (fill boolean :out)
   (pack-type pack-type :out))
   (expand boolean :out)
   (fill boolean :out)
   (pack-type pack-type :out))
 (defbinding notebook-set-tab-label-packing
     (notebook page expand fill pack-type) nil
   (notebook notebook)
 (defbinding notebook-set-tab-label-packing
     (notebook page expand fill pack-type) nil
   (notebook notebook)
-  ((%notebook-child notebook page) widget)
+  ((%ensure-notebook-child notebook page) widget)
   (expand boolean)
   (fill boolean)
   (pack-type pack-type))
   (expand boolean)
   (fill boolean)
   (pack-type pack-type))
   (editable editable)
   (text string)
   ((length text) int)
   (editable editable)
   (text string)
   ((length text) int)
-  (position position-type :in-out))
+  (position position :in-out))
 
 (defun editable-append-text (editable text)
   (editable-insert-text editable text nil))
 
 (defun editable-append-text (editable text)
   (editable-insert-text editable text nil))
 (defun spin-button-value-as-int (spin-button)
   (round (spin-button-value spin-button)))
 
 (defun spin-button-value-as-int (spin-button)
   (round (spin-button-value spin-button)))
 
-(defbinding spin-button-spin () nil
+(defbinding %spin-button-spin () nil
   (spin-button spin-button)
   (direction spin-type)
   (spin-button spin-button)
   (direction spin-type)
-  (increment single-float))
+  (increment double-float))
+
+(defun spin-button-spin (spin-button value)
+  (etypecase value
+    (real (%spin-button-spin spin-button :spin-user-defined value))
+    (spin-type (%spin-button-spin spin-button value 0))))
+
 
 (defbinding spin-button-update () nil
   (spin-button spin-button))
 
 (defbinding spin-button-update () nil
   (spin-button spin-button))
 
 (defun stock-lookup (stock-id)
   (let ((location 
 
 (defun stock-lookup (stock-id)
   (let ((location 
-        (allocate-memory (proxy-instance-size (find-class 'stock-item)))))
+        (allocate-memory (foreign-size (find-class 'stock-item)))))
     (unwind-protect
        (when (%stock-lookup stock-id location)
          (ensure-proxy-instance 'stock-item (%stock-item-copy location)))
     (unwind-protect
        (when (%stock-lookup stock-id location)
          (ensure-proxy-instance 'stock-item (%stock-item-copy location)))
   (current-widget widget :out))
 
 
   (current-widget widget :out))
 
 
-;;; Rc
+;;; Resource Files
 
 (defbinding rc-add-default-file (filename) nil
   ((namestring (truename filename)) string))
 
 (defbinding rc-add-default-file (filename) nil
   ((namestring (truename filename)) string))