X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/clg/blobdiff_plain/bbaeff4b93a5d63ce0194adf57300365f635f205..1dd03ab890afaadc72d47b304574ae9cfcbd091a:/gtk/gtk.lisp diff --git a/gtk/gtk.lisp b/gtk/gtk.lisp index 9a86062..9e39a26 100644 --- a/gtk/gtk.lisp +++ b/gtk/gtk.lisp @@ -15,14 +15,14 @@ ;; License along with this library; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -;; $Id: gtk.lisp,v 1.5 2001-05-31 21:52:57 espen Exp $ +;; $Id: gtk.lisp,v 1.23 2004-12-20 20:00:07 espen Exp $ (in-package "GTK") ;;; Gtk version -(defbinding check-version () string +(defbinding check-version () (copy-of string) (required-major unsigned-int) (required-minor unsigned-int) (required-micro unsigned-int)) @@ -39,14 +39,31 @@ (defun gtk-version () (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)) -;;; Label +;;;; Initalization -(defbinding label-select-region () nil - (label label) - (start int) - (end int)) +(defbinding (gtk-init "gtk_parse_args") () nil + "Initializes the library without opening the display." + (nil null) + (nil null)) + +(defun clg-init (&optional display) + "Initializes the system and starts the event handling" + (unless (gdk:display-get-default) + (gdk:gdk-init) + (gtk-init) + (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)))) + + +;;; Acccel group @@ -56,33 +73,91 @@ (defbinding accel-label-refetch () boolean (accel-label accel-label)) +;;; Adjustment -;;; Bin +(defmethod shared-initialize ((adjustment adjustment) names &key value) + (prog1 + (call-next-method) + ;; we need to make sure that the value is set last, otherwise it + ;; may be outside current limits + (when value + (setf (slot-value adjustment 'value) value)))) + + +(defbinding adjustment-changed () nil + (adjustment adjustment)) + +(defbinding adjustment-value-changed () nil + (adjustment adjustment)) + +(defbinding adjustment-clamp-page () nil + (adjustment adjustment) + (lower single-float) + (upper single-float)) + + +;;; Arrow -- no functions + + + +;;; Aspect frame -(defun bin-child (bin) - (first (container-children bin))) + +;;; Bin (defun (setf bin-child) (child bin) - (let ((old-child (bin-child bin))) - (when old-child - (container-remove bin old-child))) + (when-bind (current-child (bin-child bin)) + (container-remove bin current-child)) (container-add bin child) child) -(defmethod initialize-instance ((bin bin) &rest initargs &key child) - (declare (ignore initargs)) - (call-next-method) - (cond - ((consp child) - (container-add bin (first child)) - (setf - (slot-value (first child) 'child-slots) - (apply - #'make-instance - (slot-value (class-of bin) 'child-class) - :parent bin :child (first child) (cdr child)))) - (child - (container-add bin child)))) + +;;; Binding + + + +;;; Box + +(defbinding box-pack-start () nil + (box box) + (child widget) + (expand boolean) + (fill boolean) + (padding unsigned-int)) + +(defbinding box-pack-end () nil + (box box) + (child widget) + (expand boolean) + (fill boolean) + (padding unsigned-int)) + +(defun box-pack (box child &key end expand fill (padding 0)) + (if end + (box-pack-end box child expand fill padding) + (box-pack-start box child expand fill padding))) + +(defbinding box-reorder-child () nil + (box box) + (child widget) + (position int)) + +(defbinding box-query-child-packing () nil + (box box) + (child widget) + (expand boolean :out) + (fill boolean :out) + (padding unsigned-int :out) + (pack-type pack-type :out)) + +(defbinding box-set-child-packing () nil + (box box) + (child widget) + (expand boolean) + (fill boolean) + (padding unsigned-int) + (pack-type pack-type)) + ;;; Button @@ -104,25 +179,370 @@ (defbinding button-leave () nil -;;; Toggle button +;;; Calendar -(defbinding toggle-button-toggled () nil - (toggle-button toggle-button)) +(defbinding calendar-select-month () int + (calendar calendar) + (month unsigned-int) + (year unsigned-int)) +(defbinding calendar-select-day () nil + (calendar calendar) + (day unsigned-int)) + +(defbinding calendar-mark-day () int + (calendar calendar) + (day unsigned-int)) + +(defbinding calendar-unmark-day () int + (calendar calendar) + (day unsigned-int)) + +(defbinding calendar-clear-marks () nil + (calendar calendar)) + +(defbinding calendar-display-options () nil + (calendar calendar) + (options calendar-display-options)) + +(defbinding (calendar-date "gtk_calendar_get_date") () nil + (calendar calendar) + (year unsigned-int :out) + (month unsigned-int :out) + (day unsigned-int :out)) + +(defbinding calendar-freeze () nil + (calendar calendar)) + +(defbinding calendar-thaw () nil + (calendar calendar)) + + + +;;; Cell editable + + + +;;; Cell renderer + + + +;;; Cell renderer pixbuf -- no functions + + + +;;; Cell renderer text + + + +;;; Cell renderer toggle -- no functions + + + +;;; Check button -- no functions -;;; Check button -(defmethod (setf button-label) ((label string) (button check-button)) +;;; Check menu item + +(defbinding check-menu-item-toggled () nil + (check-menu-item check-menu-item)) + + + +;;; Clipboard + + +;;; Color selection + +(defbinding (color-selection-is-adjusting-p + "gtk_color_selection_is_adjusting") () boolean + (colorsel color-selection)) + + + +;;; Color selection dialog -- no functions + + + +;;;; Combo Box + +(defmethod shared-initialize ((combo-box combo-box) names &key model content) + (unless model + (setf + (combo-box-model combo-box) + (make-instance 'list-store :column-types '(string))) + (unless (typep combo-box 'combo-box-entry) + (let ((cell (make-instance 'cell-renderer-text))) + (cell-layout-pack combo-box cell :expand t) + (cell-layout-add-attribute combo-box cell :text 0))) + (when content + (map 'nil #'(lambda (text) + (combo-box-append-text combo-box text)) + content))) + (call-next-method)) + +;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active) +;; (when active +;; (signal-emit combo-box 'changed))) + +(defbinding combo-box-append-text () nil + (combo-box combo-box) + (text string)) + +(defbinding combo-box-insert-text () nil + (combo-box combo-box) + (position int) + (text string)) + +(defbinding combo-box-prepend-text () nil + (combo-box combo-box) + (text string)) + +#+gtk2.6 +(defbinding combo-box-get-active-text () string + (combo-box combo-box)) + +(defbinding combo-box-popup () nil + (combo-box combo-box)) + +(defbinding combo-box-popdown () nil + (combo-box combo-box)) + + + +;;;; Combo Box Entry + +(defmethod shared-initialize ((combo-box-entry combo-box-entry) names &key model) (call-next-method) - (setf (misc-xalign (bin-child button)) 0.0) - label) + (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)) ;;; Radio button -(defbinding (%radio-button-get-group "gtk_radio_button_group") () pointer +(defbinding %radio-button-get-group () pointer (radio-button radio-button)) (defbinding %radio-button-set-group () nil @@ -133,28 +553,13 @@ (defun radio-button-add-to-group (button1 button2) "Add BUTTON1 to the group which BUTTON2 belongs to." (%radio-button-set-group button1 (%radio-button-get-group button2))) + (defmethod initialize-instance ((button radio-button) - &rest initargs &key group) + &rest initargs &key group-with) + (declare (ignore initargs)) (call-next-method) - (when group - (radio-button-add-to-group item group))) - - -;;; Option menu - -(defbinding %option-menu-set-menu () nil - (option-menu option-menu) - (menu widget)) - -(defbinding %option-menu-remove-menu () nil - (option-menu option-menu)) - -(defun (setf option-menu-menu) (menu option-menu) - (if (not menu) - (%option-menu-remove-menu option-menu) - (%option-menu-set-menu option-menu menu)) - menu) - + (when group-with + (radio-button-add-to-group button group-with))) ;;; Item @@ -178,6 +583,11 @@ (defun (setf menu-item-label) (label menu-item) :visible t :parent menu-item) label) +(defun menu-item-label (menu-item) + (with-slots (child) menu-item + (when (typep child 'label) + (label-label child)))) + (defbinding %menu-item-set-submenu () nil (menu-item menu-item) (submenu menu)) @@ -191,23 +601,9 @@ (defun (setf menu-item-submenu) (submenu menu-item) (%menu-item-set-submenu menu-item submenu)) submenu) -(defbinding %menu-item-configure () nil +(defbinding menu-item-set-accel-path () nil (menu-item menu-item) - (show-toggle-indicator boolean) - (show-submenu-indicator boolean)) - -(defun (setf menu-item-toggle-indicator-p) (show menu-item) - (%menu-item-configure - menu-item - show - (menu-item-submenu-indicator-p menu-item)) - show) - -(defun (setf menu-item-submenu-indicator-p) (show menu-item) - (%menu-item-configure - menu-item - (menu-item-toggle-indicator-p menu-item) - show)) + (accel-path string)) (defbinding menu-item-select () nil (menu-item menu-item)) @@ -218,22 +614,19 @@ (defbinding menu-item-deselect () nil (defbinding menu-item-activate () nil (menu-item menu-item)) -(defbinding menu-item-right-justify () nil - (menu-item menu-item)) - - - -;;; Check menu item +(defbinding menu-item-toggle-size-request () nil + (menu-item menu-item) + (requisition int :out)) -(defbinding check-menu-item-toggled () nil - (check-menu-item check-menu-item)) +(defbinding menu-item-toggle-size-allocate () nil + (menu-item menu-item) + (allocation int)) ;;; Radio menu item -(defbinding (%radio-menu-item-get-group - "gtk_radio_menu_item_group") () pointer +(defbinding %radio-menu-item-get-group () pointer (radio-menu-item radio-menu-item)) (defbinding %radio-menu-item-set-group () nil @@ -245,29 +638,37 @@ (defun radio-menu-item-add-to-group (item1 item2) (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2))) (defmethod initialize-instance ((item radio-menu-item) - &rest initargs &key group) - (call-next-method) - (when group - (radio-menu-item-add-to-group item group))) + &rest initargs &key group-with) + (declare (ignore initargs)) + (prog1 + (call-next-method) + (when group-with + (radio-menu-item-add-to-group item group-with)))) +;;; Toggle button + +(defbinding toggle-button-toggled () nil + (toggle-button toggle-button)) + + + ;;; Window -(defbinding %window-set-wmclass () nil - (window window) - (wmclass-name string) - (wmclass-class string)) +(defmethod initialize-instance ((window window) &rest initargs + &key accel-group accel-groups) + (declare (ignore accel-group accel-groups)) + (prog1 + (call-next-method) + (initial-add window #'window-add-accel-group + initargs :accel-group :accel-groups))) -(defun (setf window-wmclass) (wmclass window) - (%window-set-wmclass window (svref wmclass 0) (svref wmclass 1)) - (values (svref wmclass 0) (svref wmclass 1))) -;; gtkglue.c -(defbinding window-wmclass () nil +(defbinding window-set-wmclass () nil (window window) - (wmclass-name string :out) - (wmclass-class string :out)) + (wmclass-name string) + (wmclass-class string)) (defbinding window-add-accel-group () nil (window window) @@ -283,155 +684,150 @@ (defbinding window-activate-focus () int (defbinding window-activate-default () int (window window)) -(defbinding window-set-transient-for () nil +(defbinding window-set-default-size (window width height) int (window window) - (parent window)) + ((or width -1) int) + ((or height -1) int)) ;(defbinding window-set-geometry-hints) +(defbinding window-list-toplevels () (glist (copy-of window)) + "Returns a list of all existing toplevel windows.") +(defbinding window-add-mnemonic (window key target) nil + (window window) + ((gdk:keyval-from-name key) unsigned-int) + (target widget)) -;;; File selection - -(defbinding file-selection-complete () nil - (file-selection file-selection) - (pattern string)) +(defbinding window-remove-mnemonic (window key target) nil + (window window) + ((gdk:keyval-from-name key) unsigned-int) + (target widget)) -(defbinding file-selection-show-fileop-buttons () nil - (file-selection file-selection)) +(defbinding window-mnemonic-activate (window key modifier) nil + (window window) + ((gdk:keyval-from-name key) unsigned-int) + (modifier gdk:modifier-type)) -(defbinding file-selection-hide-fileop-buttons () nil - (file-selection file-selection)) +(defbinding window-present () nil + (window window)) +(defbinding window-iconify () nil + (window window)) +(defbinding window-deiconify () nil + (window window)) -;;; Scrolled window +(defbinding window-stick () nil + (window window)) -(defun (setf scrolled-window-scrollbar-policy) (policy window) - (setf (scrolled-window-hscrollbar-policy window) policy) - (setf (scrolled-window-vscrollbar-policy window) policy)) +(defbinding window-unstick () nil + (window window)) -(defbinding scrolled-window-add-with-viewport () nil - (scrolled-window scrolled-window) - (child widget)) +(defbinding window-maximize () nil + (window window)) +(defbinding window-unmaximize () nil + (window window)) +(defbinding window-begin-resize-drag () nil + (window window) + (edge gdk:window-edge) + (button int) + (root-x int) (root-y int) + (timestamp unsigned-int)) -;;; Box +(defbinding window-begin-move-drag () nil + (window window) + (edge gdk:window-edge) + (button int) + (root-x int) (root-y int) + (timestamp unsigned-int)) -(defbinding box-pack-start () nil - (box box) - (child widget) - (expand boolean) - (fill boolean) - (padding unsigned-int)) +(defbinding window-set-frame-dimensions () nil + (window window) + (left int) (top int) (rigth int) (bottom int)) -(defbinding box-pack-end () nil - (box box) - (child widget) - (expand boolean) - (fill boolean) - (padding unsigned-int)) +(defbinding (window-default-icons "gtk_window_get_default_icon_list") + () (glist gdk:pixbuf)) -(defun box-pack (box child &key (pack :start) (expand t) (fill t) (padding 0)) - (if (eq pack :start) - (box-pack-start box child expand fill padding) - (box-pack-end box child expand fill padding))) +(defbinding %window-get-default-size () nil + (window window) + (width int :out) + (height int :out)) -(defbinding box-reorder-child () nil - (box box) - (child widget) - (position int)) +(defun window-get-default-size (window) + (multiple-value-bind (width height) (%window-get-default-size window) + (values (unless (= width -1) width) (unless (= height -1) height)))) -(defbinding box-query-child-packing () nil - (box box) - (child widget :out) - (expand boolean :out) - (fill boolean :out) - (padding unsigned-int :out) - (pack-type pack-type :out)) +(defbinding window-get-frame-dimensions () nil + (window window) + (left int :out) (top int :out) (rigth int :out) (bottom int :out)) -(defbinding box-set-child-packing () nil - (box box) - (child widget) - (expand boolean) - (fill boolean) - (padding unsigned-int) - (pack-type pack-type)) +(defbinding %window-get-icon-list () (glist gdk:pixbuf) + (window window)) +(defmethod window-icon ((window window)) + (let ((icon-list (%window-get-icon-list window))) + (if (endp (rest icon-list)) + (first icon-list) + icon-list))) +(defbinding window-get-position () nil + (window window) + (root-x int :out) + (root-y int :out)) -;;; Button box +(defbinding window-get-size () nil + (window window) + (width int :out) + (height int :out)) -(defbinding button-box-get-child-size () nil - (button-box button-box) - (min-width int :out) - (min-height int :out)) +(defbinding window-move () nil + (window window) + (x int) + (y int)) -(defbinding button-box-set-child-size () nil - (button-box button-box) - (min-width int) - (min-height int)) +(defbinding window-parse-geometry () boolean + (window window) + (geometry string)) -(defbinding button-box-get-child-ipadding () nil - (button-box button-box) - (ipad-x int :out) - (ipad-y int :out)) +(defbinding window-reshow-with-initial-size () nil + (window window)) -(defbinding button-box-set-child-ipadding () nil - (button-box button-box) - (ipad-x int) - (ipad-y int)) +(defbinding window-resize () nil + (window window) + (width int) + (heigth int)) +(defbinding %window-set-icon-list () nil + (window window) + (icon-list (glist gdk:pixbuf))) +(defmethod (setf window-icon) (icon (window window)) + (%window-set-icon-list window (mklist icon))) -;;; Color selection -; (defbinding %color-selection-get-previous-color () nil -; (colorsel color-selection) -; (color pointer)) -; (defun color-selection-previous-color (colorsel) -; (let ((color (allocate-memory (* (size-of 'double-float) 4)))) -; (%color-selection-get-previous-color colorsel color) -; (funcall (get-from-alien-function '(vector double-float 4)) color))) -; (defbinding %color-selection-set-previous-color () nil -; (colorsel color-selection) -; (color (vector double-float 4))) +;;; File chooser -; (defun (setf color-selection-previous-color) (color colorsel) -; (%color-selection-set-previous-color colorsel color) -; color) -(defbinding (color-selection-is-adjusting-p - "gtk_color_selection_is_adjusting") () boolean - (colorsel color-selection)) +;;; Scrolled window -;;; Combo +(defun (setf scrolled-window-scrollbar-policy) (policy window) + (setf (scrolled-window-hscrollbar-policy window) policy) + (setf (scrolled-window-vscrollbar-policy window) policy)) -(defbinding combo-set-value-in-list () nil - (combo combo) - (val boolean) - (ok-if-empty boolean)) +(defbinding scrolled-window-add-with-viewport () nil + (scrolled-window scrolled-window) + (child widget)) -; (defbinding ("gtk_combo_set_item_string" (setf combo-item-string)) () nil -; (combo combo) -; (item item) -; (item-value string)) -(defbinding %combo-set-popdown-strings () nil - (combo combo) - (strings (glist string))) -(defun (setf combo-popdown-strings) (strings combo) - (%combo-set-popdown-strings combo strings) - strings) -(defbinding combo-disable-activate () nil - (combo combo)) @@ -463,62 +859,63 @@ (defbinding statusbar-remove () nil (defbinding fixed-put () nil (fixed fixed) (widget widget) - (x (signed 16)) - (y (signed 16))) + (x int) (y int)) (defbinding fixed-move () nil (fixed fixed) (widget widget) - (x (signed 16)) - (y (signed 16))) + (x int) (y int)) + + + +;;; Notebook +(defun %notebook-position (notebook page) + (etypecase page + (int page) + (keyword (case page + (:first 0) + (:last -1) + (t (error "Invalid position keyword: ~A" page)))) + (widget (notebook-page-num notebook page t)))) +(defun %notebook-child (notebook position) + (typecase position + (widget position) + (t (notebook-nth-page-child notebook position)))) -;;; Notebook -(defbinding (notebook-insert-page "gtk_notebook_insert_page_menu") +(defbinding (notebook-insert "gtk_notebook_insert_page_menu") (notebook position child tab-label &optional menu-label) nil (notebook notebook) (child widget) ((if (stringp tab-label) - (label-new tab-label) + (make-instance 'label :label tab-label) tab-label) widget) ((if (stringp menu-label) - (label-new menu-label) + (make-instance 'label :label menu-label) menu-label) (or null widget)) - (position int)) + ((%notebook-position notebook position) int)) -(defun notebook-append-page (notebook child tab-label &optional menu-label) - (notebook-insert-page notebook -1 child tab-label menu-label)) +(defun notebook-append (notebook child tab-label &optional menu-label) + (notebook-insert notebook :last child tab-label menu-label)) -(defun notebook-prepend-page (notebook child tab-label &optional menu-label) - (notebook-insert-page notebook 0 child tab-label menu-label)) +(defun notebook-prepend (notebook child tab-label &optional menu-label) + (notebook-insert notebook :first child tab-label menu-label)) -(defbinding notebook-remove-page () nil - (notebook notebook) - (page-num int)) - -; (defun notebook-current-page-num (notebook) -; (let ((page-num (notebook-current-page notebook))) -; (if (= page-num -1) -; nil -; page-num))) - -(defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") () widget +(defbinding notebook-remove-page (notebook page) nil (notebook notebook) - (page-num int)) - -(defun notebook-page-child (notebook) - (notebook-nth-page-child notebook (notebook-page notebook))) + ((%notebook-position notebook page) int)) (defbinding %notebook-page-num () int (notebook notebook) (child widget)) -(defun notebook-child-num (notebook child) +(defun notebook-page-num (notebook child &optional error-p) (let ((page-num (%notebook-page-num notebook child))) (if (= page-num -1) - nil + (when error-p + (error "~A is not a child of ~A" child notebook)) page-num))) (defbinding notebook-next-page () nil @@ -527,88 +924,109 @@ (defbinding notebook-next-page () nil (defbinding notebook-prev-page () nil (notebook notebook)) +(defbinding notebook-reorder-child (notebook child position) nil + (notebook notebook) + (child widget) + ((%notebook-position notebook position) int)) + (defbinding notebook-popup-enable () nil (notebook notebook)) (defbinding notebook-popup-disable () nil (notebook notebook)) +(defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") + (notebook page) widget + (notebook notebook) + ((case page + (:first 0) + (:last -1) + (t page)) int)) + + +(defbinding %notebook-get-current-page () int + (notebook notebook)) + +(defun notebook-current-page-num (notebook) + (let ((num (%notebook-get-current-page notebook))) + (when (>= num 0) + num))) + +(defun notebook-current-page (notebook) + (let ((page-num (notebook-current-page-num notebook))) + (when page-num + (notebook-nth-page-child notebook page-num)))) + +(defbinding %notebook-set-current-page () nil + (notebook notebook) + (page-num int)) + +(defun (setf notebook-current-page) (page notebook) + (%notebook-set-current-page notebook (%notebook-position notebook page)) + page) + + (defbinding (notebook-tab-label "gtk_notebook_get_tab_label") - (notebook ref) widget + (notebook page) widget + (notebook notebook) + ((%notebook-child notebook page) widget)) + +(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text") + (notebook page) (copy-of string) (notebook notebook) - ((if (typep ref 'widget) - ref - (notebook-nth-page-child notebook ref)) - widget)) + ((%notebook-child notebook page) widget)) (defbinding %notebook-set-tab-label () nil (notebook notebook) - (reference widget) + (page widget) (tab-label widget)) -(defun (setf notebook-tab-label) (tab-label notebook reference) - (let ((tab-label-widget (if (stringp tab-label) - (label-new tab-label) - tab-label))) - (%notebook-set-tab-label - notebook - (if (typep reference 'widget) - reference - (notebook-nth-page-child notebook reference)) - tab-label-widget) - tab-label-widget)) - +(defun (setf notebook-tab-label) (tab-label notebook page) + (let ((widget (if (stringp tab-label) + (make-instance 'label :label tab-label) + tab-label))) + (%notebook-set-tab-label notebook (%notebook-child notebook page) widget) + widget)) + + (defbinding (notebook-menu-label "gtk_notebook_get_menu_label") - (notebook ref) widget + (notebook page) widget + (notebook notebook) + ((%notebook-child notebook page) widget)) + +(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text") + (notebook page) (copy-of string) (notebook notebook) - ((if (typep ref 'widget) - ref - (notebook-nth-page-child notebook ref)) - widget)) + ((%notebook-child notebook page) widget)) (defbinding %notebook-set-menu-label () nil (notebook notebook) - (reference widget) + (page widget) (menu-label widget)) -(defun (setf notebook-menu-label) (menu-label notebook reference) - (let ((menu-label-widget (if (stringp menu-label) - (label-new menu-label) - menu-label))) - (%notebook-set-menu-label - notebook - (if (typep reference 'widget) - reference - (notebook-nth-page-child notebook reference)) - menu-label-widget) - menu-label-widget)) - -(defbinding notebook-query-tab-label-packing (notebook ref) nil +(defun (setf notebook-menu-label) (menu-label notebook page) + (let ((widget (if (stringp menu-label) + (make-instance 'label :label menu-label) + menu-label))) + (%notebook-set-menu-label notebook (%notebook-child notebook page) widget) + widget)) + + +(defbinding notebook-query-tab-label-packing (notebook page) nil (notebook notebook) - ((if (typep ref 'widget) - ref - (notebook-nth-page-child notebook ref)) - widget) + ((%notebook-child notebook page) widget) (expand boolean :out) (fill boolean :out) (pack-type pack-type :out)) -(defbinding - notebook-set-tab-label-packing (notebook ref expand fill pack-type) nil +(defbinding notebook-set-tab-label-packing + (notebook page expand fill pack-type) nil (notebook notebook) - ((if (typep ref 'widget) - ref - (notebook-nth-page-child notebook ref)) - widget) + ((%notebook-child notebook page) widget) (expand boolean) (fill boolean) (pack-type pack-type)) -(defbinding notebook-reorder-child () nil - (notebook notebook) - (child widget) - (position int)) - ;;; Paned @@ -625,25 +1043,6 @@ (defbinding paned-pack2 () nil (resize boolean) (shrink boolean)) -;; gtkglue.c -(defbinding paned-child1 () widget - (paned paned) - (resize boolean :out) - (shrink boolean :out)) - -;; gtkglue.c -(defbinding paned-child2 () widget - (paned paned) - (resize boolean :out) - (shrink boolean :out)) - -(defun (setf paned-child1) (child paned) - (paned-pack1 paned child nil t)) - -(defun (setf paned-child2) (child paned) - (paned-pack2 paned child t t)) - - ;;; Layout @@ -659,49 +1058,23 @@ (defbinding layout-move () nil (x int) (y int)) -(defbinding layout-set-size () nil - (layout layout) - (width int) - (height int)) - -;; gtkglue.c -(defbinding layout-get-size () nil - (layout layout) - (width int :out) - (height int :out)) - -(defun layout-x-size (layout) - (nth-value 0 (layout-get-size layout))) - -(defun layout-y-size (layout) - (nth-value 1 (layout-get-size layout))) - -(defun (setf layout-x-size) (x layout) - (layout-set-size layout x (layout-y-size layout))) - -(defun (setf layout-y-size) (y layout) - (layout-set-size layout (layout-x-size layout) y)) - -(defbinding layout-freeze () nil - (layout layout)) - -(defbinding layout-thaw () nil - (layout layout)) - ;;; Menu shell -(defbinding menu-shell-insert () nil +(defbinding menu-shell-insert (menu-shell menu-item position) nil (menu-shell menu-shell) (menu-item menu-item) - (position int)) + ((case position + (:first 0) + (:last -1) + (t position)) int)) (defun menu-shell-append (menu-shell menu-item) - (menu-shell-insert menu-shell menu-item -1)) + (menu-shell-insert menu-shell menu-item :last)) (defun menu-shell-prepend (menu-shell menu-item) - (menu-shell-insert menu-shell menu-item 0)) + (menu-shell-insert menu-shell menu-item :fisrt)) (defbinding menu-shell-deactivate () nil (menu-shell menu-shell)) @@ -720,33 +1093,47 @@ (defbinding menu-shell-activate-item () nil -; ;;; Menu bar +;;; Menu -; (defbinding menu-bar-insert () nil -; (menu-bar menu-bar) -; (menu menu) -; (position int)) +(defun %menu-position (menu child) + (etypecase child + (int child) + (keyword (case child + (:first 0) + (:last -1) + (t (error "Invalid position keyword: ~A" child)))) + (widget (menu-child-position menu child)))) -; (defun menu-bar-append (menu-bar menu) -; (menu-bar-insert menu-bar menu -1)) -; (defun menu-bar-prepend (menu-bar menu) -; (menu-bar-insert menu-bar menu 0)) - - - -; ;;; Menu - -; (defun menu-insert (menu menu-item position) -; (menu-shell-insert menu menu-item position)) - -; (defun menu-append (menu menu-item) -; (menu-shell-append menu menu-item)) +(defbinding menu-reorder-child (menu menu-item position) nil + (menu menu) + (menu-item menu-item) + ((%menu-position menu position) int)) -; (defun menu-prepend (menu menu-item) -; (menu-shell-prepend menu menu-item)) +(def-callback-marshal %menu-popup-callback (nil (x int) (y int) (push-in boolean))) -;(defun menu-popup ...) +(defbinding %menu-popup () nil + (menu menu) + (parent-menu-shell (or null menu-shell)) + (parent-menu-item (or null menu-item)) + (callback-func (or null pointer)) + (callback-id unsigned-int) + (button unsigned-int) + (activate-time (unsigned 32))) + +(defun menu-popup (menu button activate-time &key callback parent-menu-shell + parent-menu-item) + (if callback + (with-callback-function (id callback) + (%menu-popup + menu parent-menu-shell parent-menu-item + (callback %menu-popup-callback) id button activate-time)) + (%menu-popup + menu parent-menu-shell parent-menu-item nil 0 button activate-time))) + +(defbinding menu-set-accel-path () nil + (menu menu) + (accel-path string)) (defbinding menu-reposition () nil (menu menu)) @@ -754,28 +1141,20 @@ (defbinding menu-reposition () nil (defbinding menu-popdown () nil (menu menu)) -(defbinding (menu-active "gtk_menu_get_active") () widget - (menu menu)) +(defun menu-child-position (menu child) + (position child (container-children menu))) + +(defun menu-active-num (menu) + (menu-child-position menu (menu-active menu))) (defbinding %menu-set-active () nil (menu menu) (index unsigned-int)) -(defun (setf menu-active) (menu index) - (%menu-set-active menu index)) +(defun (setf menu-active) (menu child) + (%menu-set-active menu (%menu-position menu child)) + child) -;(defun menu-attach-to-widget ...) - -(defbinding menu-detach () nil - (menu menu)) - -(defbinding (menu-attach-widget "gtk_menu_get_attach_widget") () widget - (menu menu)) - -(defbinding menu-reorder-child () nil - (menu menu) - (menu-item menu-item) - (position int)) ;;; Table @@ -786,90 +1165,79 @@ (defbinding table-resize () nil (columns unsigned-int)) (defbinding table-attach (table child left right top bottom - &key (x-options '(:expand :fill)) - (y-options '(:expand :fill)) - (x-padding 0) (y-padding 0)) nil + &key options x-options y-options + (x-padding 0) (y-padding 0)) nil (table table) (child widget) (left unsigned-int) (right unsigned-int) (top unsigned-int) (bottom unsigned-int) - (x-options attach-options) - (y-options attach-options) + ((append (mklist options) (mklist x-options)) attach-options) + ((append (mklist options) (mklist y-options)) attach-options) (x-padding unsigned-int) (y-padding unsigned-int)) + (defbinding %table-set-row-spacing () nil (table table) (row unsigned-int) (spacing unsigned-int)) -(defun (setf table-row-spacing) (spacing table row) - (%table-set-row-spacing table row spacing) +(defbinding %table-set-row-spacings () nil + (table table) + (spacing unsigned-int)) + +(defun (setf table-row-spacing) (spacing table &optional row) + (if row + (%table-set-row-spacing table row spacing) + (%table-set-row-spacings table spacing)) spacing) -;; gtkglue.c -(defbinding table-row-spacing (table row) unsigned-int +(defbinding %table-get-row-spacing () unsigned-int (table table) - ((progn - (assert (and (>= row 0) (< row (table-rows table)))) - row) unsigned-int)) + (row unsigned-int)) + +(defbinding %table-get-default-row-spacing () unsigned-int + (table table)) + +(defun table-row-spacing (table &optional row) + (if row + (%table-get-row-spacing table row) + (%table-get-default-row-spacing table))) + (defbinding %table-set-col-spacing () nil (table table) (col unsigned-int) (spacing unsigned-int)) -(defun (setf table-column-spacing) (spacing table column) - (%table-set-col-spacing table column spacing) +(defbinding %table-set-col-spacings () nil + (table table) + (spacing unsigned-int)) + +(defun (setf table-col-spacing) (spacing table &optional col) + (if col + (%table-set-col-spacing table col spacing) + (%table-set-col-spacings table spacing)) spacing) -;; gtkglue.c -(defbinding table-column-spacing (table col) unsigned-int +(defbinding %table-get-col-spacing () unsigned-int (table table) - ((progn - (assert (and (>= col 0) (< col (table-columns table)))) - col) unsigned-int)) - + (col unsigned-int)) -(defun %set-table-child-option (object slot flag value) - (let ((options (child-slot-value object slot))) - (cond - ((and value (not (member flag options))) - (setf (child-slot-value object slot) (cons flag options))) - ((and (not value) (member flag options)) - (setf (child-slot-value object slot) (delete flag options)))))) - -(macrolet ((define-option-accessor (name slot flag) - `(progn - (defun ,name (object) - (member ,flag (child-slot-value object ,slot))) - (defun (setf ,name) (value object) - (%set-table-child-option object ,slot ,flag value))))) - (define-option-accessor table-child-x-expand-p :x-options :expand) - (define-option-accessor table-child-y-expand-p :y-options :expand) - (define-option-accessor table-child-x-shrink-p :x-options :shrink) - (define-option-accessor table-child-y-shrink-p :y-options :shrink) - (define-option-accessor table-child-x-fill-p :x-options :fill) - (define-option-accessor table-child-y-fill-p :y-options :fill)) +(defbinding %table-get-default-col-spacing () unsigned-int + (table table)) +(defun table-col-spacing (table &optional col) + (if col + (%table-get-col-spacing table col) + (%table-get-default-col-spacing table))) + ;;; Toolbar -;; gtkglue.c -(defbinding toolbar-num-children () int - (toolbar toolbar)) - -(defun %toolbar-position-num (toolbar position) - (case position - (:prepend 0) - (:append (toolbar-num-children toolbar)) - (t - (assert (and (>= position 0) (< position (toolbar-num-children toolbar)))) - position))) - (defbinding %toolbar-insert-element () widget (toolbar toolbar) (type toolbar-child-type) @@ -882,80 +1250,85 @@ (defbinding %toolbar-insert-element () widget (nil null) (position int)) -(defun toolbar-insert-element (toolbar position - &key tooltip-text tooltip-private-text - type widget icon text callback) - (let* ((icon-widget (typecase icon - ((or null widget) icon) - (t (pixmap-new icon)))) - (toolbar-child - (%toolbar-insert-element - toolbar (or type (and widget :widget) :button) - widget text tooltip-text tooltip-private-text icon-widget - (%toolbar-position-num toolbar position)))) +(defbinding %toolbar-insert-stock () widget + (toolbar toolbar) + (stock-id string) + (tooltip-text string) + (tooltip-private-text string) + (nil null) + (nil null) + (position int)) + +(defun toolbar-insert (toolbar position element + &key tooltip-text tooltip-private-text + type icon group callback object) + (let* ((numpos (case position + (:first -1) + (:last 0) + (t position))) + (widget + (cond + ((or + (eq type :space) + (and (not type) (eq element :space))) + (%toolbar-insert-element + toolbar :space nil nil + tooltip-text tooltip-private-text nil numpos)) + ((or + (eq type :widget) + (and (not type) (typep element 'widget))) + (%toolbar-insert-element + toolbar :widget element nil + tooltip-text tooltip-private-text nil numpos)) + ((or + (eq type :stock) + (and + (not type) + (typep element 'string) + (stock-lookup element))) + (%toolbar-insert-stock + toolbar element tooltip-text tooltip-private-text numpos)) + ((typep element 'string) + (%toolbar-insert-element + toolbar (or type :button) (when (eq type :radio-button) group) + element tooltip-text tooltip-private-text + (etypecase icon + (null nil) + (widget icon) + ((or pathname string vector) + (make-instance 'image + :source icon ; :icon-size (toolbar-icon-size toolbar) + ))) + numpos)) + ((error "Invalid element type: ~A" element))))) (when callback - (signal-connect toolbar-child 'clicked callback)) - toolbar-child)) + (signal-connect widget 'clicked callback :object object)) + widget)) -(defun toolbar-append-element (toolbar &key tooltip-text tooltip-private-text - type widget icon text callback) - (toolbar-insert-element - toolbar :append :type type :widget widget :icon icon :text text +(defun toolbar-append (toolbar element &key tooltip-text tooltip-private-text + type icon group callback object) + (toolbar-insert + toolbar :first element :type type :icon icon :group group :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text - :callback callback)) + :callback callback :object object)) -(defun toolbar-prepend-element (toolbar &key tooltip-text tooltip-private-text - type widget icon text callback) - (toolbar-insert-element - toolbar :prepend :type type :widget widget :icon icon :text text +(defun toolbar-prepend (toolbar element &key tooltip-text tooltip-private-text + type icon group callback object) + (toolbar-insert + toolbar :last element :type type :icon icon :group group :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text - :callback callback)) + :callback callback :object object)) + (defun toolbar-insert-space (toolbar position) - (toolbar-insert-element toolbar position :type :space)) + (toolbar-insert toolbar position :space)) (defun toolbar-append-space (toolbar) - (toolbar-insert-space toolbar :append)) + (toolbar-append toolbar :space)) (defun toolbar-prepend-space (toolbar) - (toolbar-insert-space toolbar :prepend)) + (toolbar-prepend toolbar :space)) -(defun toolbar-insert-widget (toolbar widget position &key tooltip-text - tooltip-private-text callback) - (toolbar-insert-element - toolbar position :widget widget :tooltip-text tooltip-text - :tooltip-private-text tooltip-private-text :callback callback)) - -(defun toolbar-append-widget (toolbar widget &key tooltip-text - tooltip-private-text callback) - (toolbar-insert-widget - toolbar widget :append :tooltip-text tooltip-text - :tooltip-private-text tooltip-private-text :callback callback)) - -(defun toolbar-prepend-widget (toolbar widget &key tooltip-text - tooltip-private-text callback) - (toolbar-insert-widget - toolbar widget :prepend :tooltip-text tooltip-text - :tooltip-private-text tooltip-private-text :callback callback)) - -(defun toolbar-insert-item (toolbar text icon position &key tooltip-text - tooltip-private-text callback) - (toolbar-insert-element - toolbar position :text text :icon icon :callback callback - :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text)) - -(defun toolbar-append-item (toolbar text icon &key tooltip-text - tooltip-private-text callback) - (toolbar-insert-item - toolbar text icon :append :callback callback - :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text)) - - -(defun toolbar-prepend-item (toolbar text icon &key tooltip-text - tooltip-private-text callback) - (toolbar-insert-item - toolbar text icon :prepend :callback callback - :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text)) (defun toolbar-enable-tooltips (toolbar) (setf (toolbar-tooltips-p toolbar) t)) @@ -964,74 +1337,29 @@ (defun toolbar-disable-tooltips (toolbar) (setf (toolbar-tooltips-p toolbar) nil)) +(defbinding toolbar-remove-space () nil + (toolbar toolbar) + (position int)) -;;; Calendar - -(defbinding calendar-select-month () int - (calendar calendar) - (month unsigned-int) - (year unsigned-int)) - -(defbinding calendar-select-day () nil - (calendar calendar) - (day unsigned-int)) - -(defbinding calendar-mark-day () int - (calendar calendar) - (day unsigned-int)) - -(defbinding calendar-unmark-day () int - (calendar calendar) - (day unsigned-int)) - -(defbinding calendar-clear-marks () nil - (calendar calendar)) - -(defbinding calendar-display-options () nil - (calendar calendar) - (options calendar-display-options)) - -(defbinding (calendar-date "gtk_calendar_get_date") () nil - (calendar calendar) - (year unsigned-int :out) - (month unsigned-int :out) - (day unsigned-int :out)) - -(defbinding calendar-freeze () nil - (calendar calendar)) - -(defbinding calendar-thaw () nil - (calendar calendar)) - - - -;;; Drawing area - - -; (defbinding ("gtk_drawing_area_size" %drawing-area-set-size) () nil -; (drawing-area drawing-area) -; (width int) -; (height int)) - -; (defun (setf drawing-area-size) (size drawing-area) -; (%drawing-area-set-size drawing-area (svref size 0) (svref size 1)) -; (values (svref size 0) (svref size 1))) - -; ;; gtkglue.c -; (defbinding ("gtk_drawing_area_get_size" drawing-area-size) () nil -; (drawing-area drawing-area) -; (width int :out) -; (height int :out)) +(defbinding toolbar-unset-icon-size () nil + (toolbar toolbar)) +(defbinding toolbar-unset-style () nil + (toolbar toolbar)) ;;; Editable -#| + (defbinding editable-select-region (editable &optional (start 0) end) nil (editable editable) (start int) ((or end -1) int)) +(defbinding editable-get-selection-bounds (editable) nil + (editable editable) + (start int :out) + (end int :out)) + (defbinding editable-insert-text (editable text &optional (position 0)) nil (editable editable) @@ -1073,17 +1401,9 @@ (defbinding editable-copy-clipboard () nil (defbinding editable-paste-clipboard () nil (editable editable)) -; (defbinding editable-claim-selection () nil -; (editable editable) -; (claim boolean) -; (time unsigned-int)) - (defbinding editable-delete-selection () nil (editable editable)) -; (defbinding editable-changed () nil -; (editable editable)) -|# ;;; Spin button @@ -1119,106 +1439,106 @@ (defbinding ruler-draw-pos () nil ;;; Range -#| -(defbinding range-draw-background () nil - (range range)) -(defbinding range-clear-background () nil - (range range)) +(defun range-lower (range) + (adjustment-lower (range-adjustment range))) -(defbinding range-draw-trough () nil - (range range)) +(defun range-upper (range) + (adjustment-upper (range-adjustment range))) -(defbinding range-draw-slider () nil - (range range)) +(defun (setf range-lower) (value range) + (setf (adjustment-lower (range-adjustment range)) value)) -(defbinding range-draw-step-forw () nil - (range range)) +(defun (setf range-upper) (value range) + (setf (adjustment-upper (range-adjustment range)) value)) -(defbinding range-slider-update () nil - (range range)) +(defun range-page-increment (range) + (adjustment-page-increment (range-adjustment range))) -(defbinding range-trough-click () int - (range range) - (x int) - (y int) - (jump-perc single-float :out)) +(defun range-step-increment (range) + (adjustment-step-increment (range-adjustment range))) -(defbinding range-default-hslider-update () nil - (range range)) +(defun (setf range-page-increment) (value range) + (setf (adjustment-page-increment (range-adjustment range)) value)) -(defbinding range-default-vslider-update () nil - (range range)) +(defun (setf range-step-increment) (value range) + (setf (adjustment-step-increment (range-adjustment range)) value)) -(defbinding range-default-htrough-click () int +(defbinding range-set-range () nil (range range) - (x int) - (y int) - (jump-perc single-float :out)) + (lower double-float) + (upper double-float)) -(defbinding range-default-vtrough-click () int +(defbinding range-set-increments () nil (range range) - (x int) - (y int) - (jump-perc single-float :out)) + (step double-float) + (page double-float)) -(defbinding range-default-hmotion () int - (range range) - (x-delta int) - (y-delta int)) -(defbinding range-default-vmotion () int - (range range) - (x-delta int) - (y-delta int)) -|# +;;; Scale +; (defbinding scale-draw-value () nil +; (scale scale)) -;;; Scale -(defbinding scale-draw-value () nil - (scale scale)) +;;; Progress bar +(defbinding progress-bar-pulse () nil + (progress-bar progress-bar)) -;;; Progress -(defbinding progress-configure () adjustment - (progress progress) - (value single-float) - (min single-float) - (max single-float)) +;;; Size group -(defbinding (progress-text-from-value - "gtk_progress_get_text_from_value") () string - (progress progress)) +(defmethod initialize-instance ((size-group size-group) &rest initargs + &key widget widgets) + (declare (ignore widget widgets)) + (prog1 + (call-next-method) + (initial-add size-group #'size-group-add-widget + initargs :widget :widgets))) -(defbinding (progress-percentage-from-value - "gtk_progress_get_percentage_from_value") () single-float - (progress progress)) +(defbinding size-group-add-widget () nil + (size-group size-group) + (widget widget)) +(defbinding size-group-remove-widget () nil + (size-group size-group) + (widget widget)) -;;; Progress bar -(defbinding progress-bar-pulse () nil - (progress-bar progress-bar)) +;;; Stock items +(defbinding %stock-item-copy () pointer + (location pointer)) +(defbinding %stock-item-free () nil + (location pointer)) -;;; Adjustment +(defmethod reference-foreign ((class (eql (find-class 'stock-item))) location) + (%stock-item-copy location)) -(defbinding adjustment-changed () nil - (adjustment adjustment)) +(defmethod unreference-foreign ((class (eql (find-class 'stock-item))) location) + (%stock-item-free location)) -(defbinding adjustment-value-changed () nil - (adjustment adjustment)) +(defbinding stock-add (stock-item) nil + (stock-item stock-item) + (1 unsigned-int)) -(defbinding adjustment-clamp-page () nil - (adjustment adjustment) - (lower single-float) - (upper single-float)) +(defbinding stock-list-ids () (gslist string)) +(defbinding %stock-lookup () boolean + (stock-id string) + (location pointer)) + +(defun stock-lookup (stock-id) + (let ((location + (allocate-memory (proxy-instance-size (find-class 'stock-item))))) + (unwind-protect + (when (%stock-lookup stock-id location) + (ensure-proxy-instance 'stock-item (%stock-item-copy location))) + (deallocate-memory location)))) ;;; Tooltips @@ -1229,17 +1549,17 @@ (defbinding tooltips-enable () nil (defbinding tooltips-disable () nil (tooltips tooltips)) +(defun (setf tooltips-enabled-p) (enable tooltips) + (if enable + (tooltips-enable tooltips) + (tooltips-disable tooltips))) + (defbinding tooltips-set-tip () nil (tooltips tooltips) (widget widget) (tip-text string) (tip-private string)) -(defbinding tooltips-set-colors (tooltips background foreground) nil - (tooltips tooltips) - ((gdk:ensure-color background) gdk:color) - ((gdk:ensure-color foreground) gdk:color)) - (defbinding tooltips-force-window () nil (tooltips tooltips)) @@ -1265,22 +1585,6 @@ (defbinding rc-get-style () style ;;; Accelerator Groups #| -(defbinding accel-group-get-default () accel-group) - -(deftype-method alien-ref accel-group (type-spec) - (declare (ignore type-spec)) - '%accel-group-ref) - -(deftype-method alien-unref accel-group (type-spec) - (declare (ignore type-spec)) - '%accel-group-unref) - -(defbinding %accel-group-ref () accel-group - (accel-group (or accel-group pointer))) - -(defbinding %accel-group-unref () nil - (accel-group (or accel-group pointer))) - (defbinding accel-group-activate (accel-group key modifiers) boolean (accel-group accel-group) ((gdk:keyval-from-name key) unsigned-int) @@ -1357,291 +1661,3 @@ (defbinding accel-group-handle-remove ((gdk:keyval-from-name key) unsigned-int) (modifiers gdk:modifier-type)) |# - - -;;; Style - -; (defbinding style-new () style) - -; (defbinding style-copy () style -; (style style)) -#| -(defbinding %style-get-color () gdk:color - (style style) - (color-type color-type) - (state-type state-type)) - -(defbinding %style-set-color () gdk:color - (style style) - (color-type color-type) - (state-type state-type) - (color gdk:color)) - -(defun style-fg (style state) - (%style-get-color style :foreground state)) - -(defun (setf style-fg) (color style state) - (%style-set-color style :foreground state color)) - -(defun style-bg (style state) - (%style-get-color style :background state)) - -(defun (setf style-bg) (color style state) - (%style-set-color style :background state color)) - -(defun style-text (style state) - (%style-get-color style :text state)) - -(defun (setf style-text) (color style state) - (%style-set-color style :text state color)) - -(defun style-base (style state) - (%style-get-color style :base state)) - -(defun (setf style-base) (color style state) - (%style-set-color style :base state color)) - -(defun style-white (style) - (%style-get-color style :white :normal)) - -(defun (setf style-white) (color style) - (%style-set-color style :white :normal color)) - -(defun style-black (style) - (%style-get-color style :black :normal)) - -(defun (setf style-black) (color style) - (%style-set-color style :black :normal color)) - -(defbinding style-get-gc () gdk:gc - (style style) - (color-type color-type) - (state-type state-type)) - -|# -(defbinding draw-hline () nil - (style style) - (window gdk:window) - (state state-type) - (x1 int) - (x2 int) - (y int)) - -(defbinding draw-vline () nil - (style style) - (window gdk:window) - (state state-type) - (y1 int) - (y2 int) - (x int)) - -(defbinding draw-shadow () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int)) - -; (defbinding draw-polygon () nil -; (style style) -; (window gdk:window) -; (state state-type) -; (shadow shadow-type) -; (points (vector gdk:point)) -; ((length points) int) -; (fill boolean)) - -(defbinding draw-arrow () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (arrow arrow-type) - (fill boolean) - (x int) - (y int) - (width int) - (height int)) - -(defbinding draw-diamond () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int)) - -; (defbinding draw-oval () nil -; (style style) -; (window gdk:window) -; (state state-type) -; (shadow shadow-type) -; (x int) -; (y int) -; (width int) -; (height int)) - -(defbinding draw-string () nil - (style style) - (window gdk:window) - (state state-type) - (x int) - (y int) - (string string)) - -(defbinding draw-box () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int)) - -(defbinding draw-flat-box () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int)) - -(defbinding draw-check () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int)) - -(defbinding draw-option () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int)) - -; (defbinding draw-cross () nil -; (style style) -; (window gdk:window) -; (state state-type) -; (shadow shadow-type) -; (x int) -; (y int) -; (width int) -; (height int)) - -; (defbinding draw-ramp () nil -; (style style) -; (window gdk:window) -; (state state-type) -; (shadow shadow-type) -; (arrow arrow-type) -; (x int) -; (y int) -; (width int) -; (height int)) - -(defbinding draw-tab () nil - (style style) - (window gdk:window) - (state state-type) - (x int) - (y int) - (width int) - (height int)) - -(defbinding draw-shadow-gap () nil - (style style) - (window gdk:window) - (state state-type) - (x int) - (y int) - (width int) - (height int) - (gap-side position-type) - (gap-x int) - (gap-width int)) - -(defbinding draw-box-gap () nil - (style style) - (window gdk:window) - (state state-type) - (x int) - (y int) - (width int) - (height int) - (gap-side position-type) - (gap-x int) - (gap-width int)) - -(defbinding draw-extension () nil - (style style) - (window gdk:window) - (state state-type) - (x int) - (y int) - (width int) - (height int)) - -(defbinding draw-focus () nil - (style style) - (window gdk:window) - (x int) - (y int) - (width int) - (height int)) - -(defbinding draw-slider () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int) - (orientation orientation)) - -(defbinding draw-handle () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int) - (orientation orientation)) - -(defbinding draw-handle () nil - (style style) - (window gdk:window) - (state state-type) - (shadow shadow-type) - (x int) - (y int) - (width int) - (height int) - (orientation orientation)) - -(defbinding paint-hline () nil - (style style) - (window gdk:window) - (state state-type) - (x1 int) - (x2 int) - (y int))