+ (unless model
+ (setf (combo-box-entry-text-column combo-box-entry) 0)))
+
+
+;;;; Dialog
+
+(defmethod shared-initialize ((dialog dialog) names &rest initargs
+ &key button buttons)
+ (declare (ignore button buttons))
+ (prog1
+ (call-next-method)
+ (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
+
+
+(defvar %*response-id-key* (gensym))
+
+(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
+ (cond
+ (response-ids
+ (vector-push-extend id response-ids)
+ (1- (length response-ids)))
+ (t
+ (setf
+ (object-data dialog %*response-id-key*)
+ (make-array 1 :adjustable t :fill-pointer t :initial-element id))
+ 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)))))
+
+
+(defbinding dialog-run () nil
+ (dialog dialog))
+
+(defbinding dialog-response (dialog response-id) nil
+ (dialog dialog)
+ ((%dialog-find-response-id-num dialog response-id nil t) int))
+
+
+(defbinding %dialog-add-button () button
+ (dialog dialog)
+ (text string)
+ (response-id-num int))
+
+(defun dialog-add-button (dialog label &optional (response label)
+ &key default object after)
+ "Adds a button to the dialog. If no response is given, then label
+ will be used."
+ (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)))
+ (when (functionp response)
+ (signal-connect dialog id response :object object :after after))
+ (when default
+ (%dialog-set-default-response dialog id-num))
+ button))
+
+
+(defbinding %dialog-add-action-widget () button
+ (dialog dialog)
+ (action-widget widget)
+ (response-id-num int))
+
+(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)
+ (when (functionp response)
+ (signal-connect dialog id response :object object :after after))
+ (when default
+ (%dialog-set-default-response dialog id-num))
+ widget))
+
+
+(defbinding %dialog-set-default-response () nil
+ (dialog dialog)
+ (response-id-num int))
+
+(defun dialog-set-default-response (dialog response-id)
+ (%dialog-set-default-response
+ dialog (%dialog-find-response-id-num dialog response-id nil t)))
+
+(defbinding dialog-set-response-sensitive (dialog response-id sensitive) nil
+ (dialog dialog)
+ ((%dialog-find-response-id-num dialog response-id nil t) int)
+ (sensitive boolean))
+
+
+;; Addition dialog functions
+
+(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-children ((dialog dialog))
+ (container-children (dialog-vbox dialog)))
+
+(defmethod (setf container-children) (children (dialog dialog))
+ (setf (container-children (dialog-vbox dialog)) children))
+
+
+
+;;; Drawing area
+
+(defbinding drawing-area-get-size () nil
+ (drawing-area drawing-area)
+ (width int :out)
+ (height int :out))
+
+
+;;; Entry
+
+(defbinding entry-get-layout () pango:layout
+ (entry entry))
+
+(defbinding entry-get-layout-offsets () nil
+ (entry entry)
+ (x int :out)
+ (y int :out))
+
+
+;;; Image
+
+(defbinding image-set-from-file () nil
+ (image image)
+ (filename pathname))
+
+(defbinding image-set-from-pixmap () nil
+ (image image)
+ (pixmap gdk:pixmap)
+ (mask gdk:bitmap))
+
+(defbinding image-set-from-stock () nil
+ (image image)
+ (stock-id string)
+ (icon-size icon-size))
+
+(defun image-set-from-pixmap-data (image pixmap-data)
+ (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap-data)
+ (image-set-from-pixmap image pixmap mask)))
+
+(defun image-set-from-source (image source)
+ (etypecase source
+ (pathname (image-set-from-file image source))
+ (string (if (stock-lookup source)
+ (setf (image-stock image) source)
+ (image-set-from-file image source)))
+ (vector (image-set-from-pixmap-data image source))))
+
+
+(defmethod shared-initialize ((image image) names &rest initargs
+ &key file pixmap source)
+ (prog1
+ (if (vectorp pixmap)
+ (progn
+ (remf initargs :pixmap)
+ (apply #'call-next-method image names initargs))
+ (call-next-method))
+ (cond
+ (file (image-set-from-file image file))
+ ((vectorp pixmap) (image-set-from-pixmap-data image pixmap))
+ (source (image-set-from-source image source)))))
+
+
+;;; Label
+
+(defbinding label-get-layout-offsets () nil
+ (label label)
+ (x int :out)
+ (y int :out))
+
+(defbinding label-select-region () nil
+ (label label)
+ (start int)
+ (end int))
+
+(defbinding label-get-text () string
+ (label label))
+
+(defbinding label-get-layout () pango:layout
+ (label label))
+
+(defbinding label-get-selection-bounds () boolean
+ (label label)
+ (start int :out)
+ (end int :out))