From: Dmitry Kalyanov Date: Sun, 13 Sep 2009 20:20:01 +0000 (+0400) Subject: Add GtkEntryCompletion X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=0ff51b71441ef2265a4a0eb54f14204932c1ba04;p=cl-gtk2.git Add GtkEntryCompletion --- diff --git a/generating.lisp b/generating.lisp index 1623ac9..e43db63 100644 --- a/generating.lisp +++ b/generating.lisp @@ -274,7 +274,12 @@ (:cffi gtk::cursor-hadjustment gtk::entry-cursor-hadjustment (g-object gtk::adjustment) "gtk_entry_get_cursor_hadjustment" "gtk_entry_set_cursor_hadjustment") (:cffi gtk::layout-offset gtk::entry-layout-offset nil - gtk::gtk-entry-layout-offset nil)))))) + gtk::gtk-entry-layout-offset nil)) + ("GtkEntryCompletion" + (:cffi gtk::entry gtk::entry-completion-entry (g-object gtk::entry) + "gtk_entry_completion_get_entry" nil) + (:cffi gtk::match-function gtk::entry-completion-match-function nil + nil gtk::gtk-entry-completion-set-match-function)))))) (defun gtk-generate-child-properties (filename) (with-open-file (stream filename :direction :output :if-exists :supersede) diff --git a/gtk/gtk.demo.lisp b/gtk/gtk.demo.lisp index 35511fc..c55d37c 100644 --- a/gtk/gtk.demo.lisp +++ b/gtk/gtk.demo.lisp @@ -25,7 +25,8 @@ #:demo-class-browser #:demo-treeview-tree #:test-custom-window - #:test-assistant)) + #:test-assistant + #:test-entry-completion)) (in-package :gtk-demo) @@ -840,3 +841,21 @@ (format output "Assistant ~A has ~A pages and is on ~Ath page~%" d (assistant-n-pages d) (assistant-current-page d)))) (widget-show d))))) + +(defun test-entry-completion () + (within-main-loop + (let* ((w (make-instance 'gtk-window)) + (model (make-instance 'tree-lisp-store))) + (tree-lisp-store-add-column model "gchararray" #'identity) + (tree-node-insert-at (tree-lisp-store-root model) (make-tree-node :item "Monday") 0) + (tree-node-insert-at (tree-lisp-store-root model) (make-tree-node :item "Tuesday") 0) + (tree-node-insert-at (tree-lisp-store-root model) (make-tree-node :item "Wednesday") 0) + (tree-node-insert-at (tree-lisp-store-root model) (make-tree-node :item "Thursday") 0) + (tree-node-insert-at (tree-lisp-store-root model) (make-tree-node :item "Friday") 0) + (tree-node-insert-at (tree-lisp-store-root model) (make-tree-node :item "Saturday") 0) + (tree-node-insert-at (tree-lisp-store-root model) (make-tree-node :item "Sunday") 0) + (let* ((completion (make-instance 'entry-completion :model model :text-column 0)) + (e (make-instance 'entry :completion completion))) + (setf (entry-completion-text-column completion) 0) + (container-add w e)) + (widget-show w)))) \ No newline at end of file diff --git a/gtk/gtk.entry.lisp b/gtk/gtk.entry.lisp index c21e62f..0d4300f 100644 --- a/gtk/gtk.entry.lisp +++ b/gtk/gtk.entry.lisp @@ -133,4 +133,63 @@ (defun (setf editable-editable) (is-editable editable) (gtk-editable-set-editable editable is-editable)) -(export 'editable-editable) \ No newline at end of file +(export 'editable-editable) + +;; GtkEntryCompletion + +(define-cb-methods entry-completion-match-func :boolean + ((completion (g-object entry-completion)) + (key :string) + (iter (g-boxed-foreign tree-iter)))) + +(defcfun (%gtk-entry-completion-set-match-func "gtk_entry_completion_set_match_func") :void + (completion (g-object entry-completion)) + (func :pointer) + (data :pointer) + (destroy-notify :pointer)) + +(defun gtk-entry-completion-set-match-func (completion function) + (if function + (%gtk-entry-completion-set-match-func completion + (callback entry-completion-match-func-cb) + (create-fn-ref completion function) + (callback entry-completion-match-func-destroy-notify)) + (%gtk-entry-completion-set-match-func completion + (null-pointer) + (null-pointer) + (null-pointer)))) + +(defcfun (entry-completion-complete "gtk_entry_completion_complete") :void + (completion (g-object entry-completion))) + +(export 'entry-completion-complete) + +(defcfun (entry-completion-completion-prefix "gtk_entry_completion_get_completion_prefix") (:string :free-from-foreign t) + (completion (g-object entry-completion))) + +(export 'entry-completion-completion-prefix) + +(defcfun (entry-completion-insert-prefix "gtk_entry_completion_insert_prefix") :void + (completion (g-object entry-completion))) + +(export 'entry-completion-completion-prefix) + +(defcfun (entry-completion-insert-action-text "gtk_entry_completion_insert_action_text") :void + (completion (g-object entry-completion)) + (index :int) + (text :string)) + +(export 'entry-completion-insert-action-text) + +(defcfun (entry-copmletion-insert-action-markup "gtk_entry_completion_insert_action_markup") :void + (completion (g-object entry-completion)) + (index :int) + (markup :string)) + +(export 'entry-completion-insert-action-markup) + +(defcfun (entry-completion-delete-action "gtk_entry_completion_delete_action") :void + (completion (g-object entry-completion)) + (index :int)) + +(export 'entry-completion-delete-action) diff --git a/gtk/gtk.generated-classes.lisp b/gtk/gtk.generated-classes.lisp index ff17bed..ba64925 100644 --- a/gtk/gtk.generated-classes.lisp +++ b/gtk/gtk.generated-classes.lisp @@ -2678,7 +2678,11 @@ (popup-single-match entry-completion-popup-single-match "popup-single-match" "gboolean" t t) (text-column entry-completion-text-column "text-column" - "gint" t t))) + "gint" t t) + (:cffi entry entry-completion-entry (g-object entry) + "gtk_entry_completion_get_entry" nil) + (:cffi match-function entry-completion-match-function + nil nil gtk-entry-completion-set-match-function))) (define-g-object-class "GtkIconFactory" icon-factory (:superclass g-object :export t :interfaces