From 68f519e0e99a023834e3bc0db73ca3ae9e40d64a Mon Sep 17 00:00:00 2001 From: espen Date: Wed, 12 Jan 2005 13:38:18 +0000 Subject: [PATCH] More widgets compoleted --- gtk/gtk.lisp | 252 ++++++++++++++++++++++++++++++++++++++++++------------ gtk/gtktypes.lisp | 130 +++++++++++++++++++++------- 2 files changed, 296 insertions(+), 86 deletions(-) diff --git a/gtk/gtk.lisp b/gtk/gtk.lisp index 3e623e2..af78c09 100644 --- a/gtk/gtk.lisp +++ b/gtk/gtk.lisp @@ -15,7 +15,7 @@ ;; 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.29 2005-01-06 21:05:46 espen Exp $ +;; $Id: gtk.lisp,v 1.30 2005-01-12 13:38:18 espen Exp $ (in-package "GTK") @@ -102,6 +102,30 @@ (upper single-float)) +;;; Alignment + +(defbinding alignment-set () nil + (alognment alignment) + (x-align single-float) + (y-align single-float) + (x-scale single-float) + (y-scale single-float)) + +(defbinding alignment-get-padding () nil + (alognment alignment) + (top unsigned-int :out) + (bottom unsigned-int :out) + (left unsigned-int :out) + (right unsigned-int :out)) + +(defbinding alignment-set-padding () nil + (alognment alignment) + (top unsigned-int) + (bottom unsigned-int) + (left unsigned-int) + (right unsigned-int)) + + ;;; Aspect frame @@ -497,6 +521,138 @@ (index int)) +;;; File Chooser + +(defmethod initialize-instance ((file-chooser file-chooser) &rest initargs + &key filter filters shortcut-folder + shortcut-folders shortcut-folder-uti + shortcut-folder-uris) + (declare (ignore filter filters shortcut-folder shortcut-folders + shortcut-folder-uti shortcut-folder-uris)) + (prog1 + (call-next-method) + (initial-add file-chooser #'file-chooser-add-filter + initargs :filer :filters) + (initial-add file-chooser #'file-chooser-add-shortcut-folder + initargs :shortcut-folder :shortcut-folders) + (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri + initargs :shortcut-folder-uri :shortcut-folders-uris))) + + +(defbinding file-chooser-select-filename () boolean + (file-chooser file-chooser) + (filename string)) + +(defbinding file-chooser-unselect-filename () nil + (file-chooser file-chooser) + (filename string)) + +(defbinding file-chooser-select-all () boolean + (file-chooser file-chooser)) + +(defbinding file-chooser-unselect-all () boolean + (file-chooser file-chooser)) + +(defbinding file-chooser-get-filenames () (gslist string) + (file-chooser file-chooser)) + +(defbinding file-chooser-select-uri () boolean + (file-chooser file-chooser) + (uri string)) + +(defbinding file-chooser-unselect-uri () nil + (file-chooser file-chooser) + (uri string)) + +(defbinding file-chooser-get-uris () (gslist string) + (file-chooser file-chooser)) + +(defbinding file-chooser-add-filter () nil + (file-chooser file-chooser) + (filter file-filter)) + +(defbinding file-chooser-remove-filter () nil + (file-chooser file-chooser) + (filter file-filter)) + +(defbinding file-chooser-list-filters () (gslist file-filter) + (file-chooser file-chooser)) + +(defbinding file-chooser-add-shortcut-folder () boolean + (file-chooser file-chooser) + (folder string) + (nil null)) + +(defbinding file-chooser-remove-shortcut-folder () nil + (file-chooser file-chooser) + (folder string) + (nil null)) + +(defbinding file-chooser-list-shortcut-folders () (gslist string) + (file-chooser file-chooser)) + +(defbinding file-chooser-add-shortcut-folder-uri () boolean + (file-chooser file-chooser) + (uri string) + (nil null)) + +(defbinding file-chooser-remove-shortcut-folder-uri () nil + (file-chooser file-chooser) + (uri string) + (nil null)) + +(defbinding file-chooser-list-shortcut-folder-uris () (gslist string) + (file-chooser file-chooser)) + + +;;; File Filter + +(defmethod initialize-instance ((file-filter file-filter) &rest initargs + &key mime-type mime-types pattern patterns + pixbuf-formats) + (declare (ignore mime-type mime-types pattern patterns)) + (prog1 + (call-next-method) + (when pixbuf-formats + #-gtk2.6(warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk") + #+gtk2.6(file-filter-add-pixbuf-formats file-filter)) + (initial-add file-filter #'file-filter-add-mime-type + initargs :mime-type :mime-types) + (initial-add file-filter #'file-filter-add-pattern + initargs :pattern :patterns))) + + +(defbinding file-filter-add-mime-type () nil + (filter file-filter) + (mime-type string)) + +(defbinding file-filter-add-pattern () nil + (filter file-filter) + (pattern string)) + +#+gtk2.6 +(defbinding file-filter-add-pixbuf-formats () nil + (filter file-filter) + (pattern string)) + +(def-callback-marshal %file-filter-func (boolean file-filter-info)) + +(defbinding file-filter-add-custom () nil + (filter file-filter) + (needed file-filter-flags) + ((callback %file-filter-func) pointer) + ((register-callback-function function) unsigned-int) + ((callback %destroy-user-data) pointer)) + +(defbinding file-filter-get-needed () file-filter-flags + (filter file-filter)) + +(defbinding file-filter-filter () boolean + (filter file-filter) + (filter-info file-filter-info)) + + + ;;; Image (defbinding image-set-from-file () nil @@ -1086,20 +1242,15 @@ ;;; Notebook -(defun %notebook-position (notebook page) +(defun %ensure-notebook-position (notebook page) (etypecase page - (int page) - (keyword (case page - (:first 0) - (:last -1) - (t (error "Invalid position keyword: ~A" page)))) + (position page) (widget (notebook-page-num notebook page t)))) -(defun %notebook-child (notebook position) +(defun %ensure-notebook-child (notebook position) (typecase position (widget position) - (t (notebook-nth-page-child notebook position)))) - + (t (notebook-get-nth-page notebook position)))) (defbinding (notebook-insert "gtk_notebook_insert_page_menu") (notebook position child tab-label &optional menu-label) nil @@ -1111,7 +1262,7 @@ ((if (stringp menu-label) (make-instance 'label :label menu-label) menu-label) (or null widget)) - ((%notebook-position notebook position) int)) + ((%ensure-notebook-position notebook position) position)) (defun notebook-append (notebook child tab-label &optional menu-label) (notebook-insert notebook :last child tab-label menu-label)) @@ -1121,7 +1272,7 @@ (defbinding notebook-remove-page (notebook page) nil (notebook notebook) - ((%notebook-position notebook page) int)) + ((%ensure-notebook-position notebook page) position)) (defbinding %notebook-page-num () int (notebook notebook) @@ -1131,7 +1282,7 @@ (let ((page-num (%notebook-page-num notebook child))) (if (= page-num -1) (when error-p - (error "~A is not a child of ~A" child notebook)) + (error "~A is not a page in ~A" child notebook)) page-num))) (defbinding notebook-next-page () nil @@ -1151,46 +1302,26 @@ (defbinding notebook-popup-disable () nil (notebook notebook)) -(defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") - (notebook page) widget +(defbinding notebook-get-nth-page () widget (notebook notebook) - ((case page - (:first 0) - (:last -1) - (t page)) int)) + (page position)) - -(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 %notebook-current-page (notebook) + (when (slot-boundp notebook 'current-page-num) + (notebook-get-nth-page notebook (notebook-current-page-num notebook)))) (defun (setf notebook-current-page) (page notebook) - (%notebook-set-current-page notebook (%notebook-position notebook page)) - page) - + (setf (notebook-current-page notebook) (notebook-page-num notebook page))) (defbinding (notebook-tab-label "gtk_notebook_get_tab_label") (notebook page) widget (notebook notebook) - ((%notebook-child notebook page) widget)) + ((%ensure-notebook-child notebook page) widget)) (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text") (notebook page) (copy-of string) (notebook notebook) - ((%notebook-child notebook page) widget)) + ((%ensure-notebook-child notebook page) widget)) (defbinding %notebook-set-tab-label () nil (notebook notebook) @@ -1201,19 +1332,19 @@ (let ((widget (if (stringp tab-label) (make-instance 'label :label tab-label) tab-label))) - (%notebook-set-tab-label notebook (%notebook-child notebook page) widget) + (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget) widget)) (defbinding (notebook-menu-label "gtk_notebook_get_menu_label") (notebook page) widget (notebook notebook) - ((%notebook-child notebook page) widget)) + ((%ensure-notebook-child notebook page) widget)) (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text") (notebook page) (copy-of string) (notebook notebook) - ((%notebook-child notebook page) widget)) + ((%ensure-notebook-child notebook page) widget)) (defbinding %notebook-set-menu-label () nil (notebook notebook) @@ -1224,7 +1355,7 @@ (let ((widget (if (stringp menu-label) (make-instance 'label :label menu-label) menu-label))) - (%notebook-set-menu-label notebook (%notebook-child notebook page) widget) + (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget) widget)) @@ -1264,16 +1395,25 @@ (defbinding layout-put () nil (layout layout) - (widget widget) + (child widget) (x int) (y int)) (defbinding layout-move () nil (layout layout) - (widget widget) + (child widget) (x int) (y int)) +(defbinding layout-set-size () nil + (layout layout) + (width unsigned-int) + (height unsigned-int)) + +(defbinding layout-get-size () nil + (layout layout) + (width unsigned-int :out) + (height unsigned-int :out)) ;;; Menu shell @@ -1687,11 +1827,12 @@ (position single-float) (max-size single-float)) -(defbinding ruler-draw-ticks () nil - (ruler ruler)) - -(defbinding ruler-draw-pos () nil - (ruler ruler)) +(defbinding ruler-get-range () nil + (ruler ruler) + (lower single-float :out) + (upper single-float :out) + (position single-float :out) + (max-size single-float :out)) @@ -1734,9 +1875,10 @@ ;;; Scale -; (defbinding scale-draw-value () nil -; (scale scale)) - +(defbinding scale-get-layout-offsets () nil + (scale scale) + (x int :out) + (y int :out)) ;;; Progress bar diff --git a/gtk/gtktypes.lisp b/gtk/gtktypes.lisp index f73eaf0..41e599d 100644 --- a/gtk/gtktypes.lisp +++ b/gtk/gtktypes.lisp @@ -15,7 +15,7 @@ ;; 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: gtktypes.lisp,v 1.29 2005-01-07 00:28:36 espen Exp $ +;; $Id: gtktypes.lisp,v 1.30 2005-01-12 13:38:18 espen Exp $ (in-package "GTK") @@ -126,7 +126,12 @@ (deftype tree-path () '(vector integer)) (register-type 'tree-path "GtkTreePath") -(deftype position () '(or int (enum (:start 0) (:end -1)))) +(deftype position () + '(or int (enum (:start 0) (:end -1) (:first 0) (:last -1)))) + +(defmethod reader-function ((type (eql 'position)) &rest args) + (declare (ignore type args)) + (reader-function 'int)) ;; Forward definitions (defclass widget (%object) @@ -158,6 +163,13 @@ :getter "gtk_widget_get_window" :reader widget-window :type gdk:window) + (parent-window + :allocation :virtual + :getter %widget-parent-window + :setter "gtk_widget_set_parent_window" + :accessor widget-parent-window + :initarg :parent-window + :type gdk:window) (state :allocation :virtual :getter "gtk_widget_get_state" @@ -190,7 +202,7 @@ :setter "gtk_widget_set_composite_name" :accessor widget-composite-name :initarg :composite-name - :type string) + :type (copy-of string)) ; will leak the string when setting (settings :allocation :virtual :getter "gtk_widget_get_settings" @@ -528,10 +540,19 @@ :slots ((current-page :allocation :virtual - :getter notebook-current-page + :getter %notebook-current-page :setter (setf notebook-current-page) + :reader notebook-current-page + :type widget :initarg :current-page) - (page :ignore t))) + (current-page-num + :allocation :virtual + :getter "gtk_notebook_get_current_page" + :setter "gtk_notebook_set_current_page" + :unbound -1 + :initarg :current-page-num + :accessor notebook-current-page-num + :type position))) ("GtkRuler" :slots @@ -644,24 +665,6 @@ :accessor radio-menu-item-value :documentation "Value passed as argument to the activate callback"))) - ("GtkFileSelection" - :slots - ((action-area - :allocation :virtual - :getter "gtk_file_selection_get_action_area" - :reader file-selection-action-area - :type widget) - (ok-button - :allocation :virtual - :getter "gtk_file_selection_get_ok_button" - :reader file-selection-ok-button - :type widget) - (cancel-button - :allocation :virtual - :getter "gtk_file_selection_get_cancel_button" - :reader file-selection-cancel-button - :type widget))) - ("GtkLayout" :slots ((bin-window @@ -724,6 +727,14 @@ :reader label-layout :type pango:layout))) + ("GtkScale" + :slots + ((layout + :allocation :virtual + :getter "gtk_scale_get_layout" + :reader scale-layout + :type pango:layout))) + ("GtkEditable" :slots ((editable @@ -758,31 +769,41 @@ (current-name :allocation :virtual :setter "gtk_file_chooser_set_current_name" - :accessor file-choser-current-name + :accessor file-chooser-current-name :initarg :current-name :type string) (current-folder :allocation :virtual :setter "gtk_file_chooser_set_current_folder" :setter "gtk_file_chooser_get_current_folder" - :accessor file-choser-current-folder + :accessor file-chooser-current-folder :initarg :current-folder :type string) (uri :allocation :virtual :getter "gtk_file_chooser_get_uri" :setter "gtk_file_chooser_set_uri" - :accessor file-choser-uri + :accessor file-chooser-uri :initarg :uri :type string) (current-folder-uri :allocation :virtual :setter "gtk_file_chooser_set_current_folder_uri" :setter "gtk_file_chooser_get_current_folder_uri" - :accessor file-choser-current-folder-uri + :accessor file-chooser-current-folder-uri :initarg :current-folder-uri :type string))) + ("GtkFileFilter" + :slots + ((name + :allocation :virtual + :getter "gtk_file_filter_get_name" + :setter "gtk_file_filter_set_name" + :accessor file-filter-name + :initarg :name + :type string))) + ("GtkTreeView" :slots ((columns @@ -950,6 +971,27 @@ :allocation :virtual :getter radio-action-value))) + ("GtkColorSelection" + :slots + ((previous-alpha + :allocation :virtual + :getter "gtk_color_selection_get_previous_alpha" + :setter "gtk_color_selection_get_previous_alpha" + :initarg :previous-alpha + :accessor color-selection-previous-alpha + :type (unsigned 16)) + (previous-color + :allocation :virtual + :getter "gtk_color_selection_get_previous_color" + :setter "gtk_color_selection_get_previous_color" + :initarg :previous-color + :accessor color-selection-previous-color + :type gdk:color))) + + ("GtkFontSelection" + :slots + ; deprecated property + ((font :ignore t))) ;; Not needed ("GtkFundamentalType" :ignore t) @@ -973,6 +1015,8 @@ ("GtkOldEditable" :ignore t) ("GtkCombo" :ignore t) ("GtkOptionMenu" :ignore t) + ("GtkFileSelection" :ignore t) + ("GtkInputDialog") ;; What are these? ("GtkFileSystemModule" :ignore t) @@ -987,7 +1031,7 @@ :allocation :virtual :getter "gtk_text_iter_get_buffer" :reader text-iter-buffer - :type text-buffer) + :type pointer) ;text-buffer) (offset :allocation :virtual :getter "gtk_text_iter_get_offset" @@ -1026,11 +1070,12 @@ :type int) ;; Workaround to get correct size (dummy14 - :allocation :alien :offset #.(* 13 (size-of 'pointer)) - :type pointer)) + :allocation :alien :offset #.(* 13 (size-of 'pointer)) + :type pointer)) (:metaclass boxed-class ;; I am pretty sure this was working in older versons on CMUCL - :size #.(* 14 (size-of 'pointer)))) +; :size #.(* 14 (size-of 'pointer)) + )) (defclass tooltips-data (struct) @@ -1051,3 +1096,26 @@ :reader tooltips-data-tip-private :type string)) (:metaclass struct-class)) + +(defclass file-filter-info (struct) + ((contains + :allocation :alien + :initarg :contains + :type file-filter-flags) + (filename + :allocation :alien + :initarg :filename + :type string) + (uri + :allocation :alien + :initarg :uri + :type string) + (display-name + :allocation :alien + :initarg :display-name + :type string) + (mime-type + :allocation :alien + :initarg :mime-type + :type string)) + (:metaclass struct-class)) -- 2.11.0