Add GtkEntryCompletion
authorDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Sun, 13 Sep 2009 20:20:01 +0000 (00:20 +0400)
committerDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Sun, 13 Sep 2009 20:26:47 +0000 (00:26 +0400)
generating.lisp
gtk/gtk.demo.lisp
gtk/gtk.entry.lisp
gtk/gtk.generated-classes.lisp

index 1623ac9..e43db63 100644 (file)
         (: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)
index 35511fc..c55d37c 100644 (file)
@@ -25,7 +25,8 @@
            #:demo-class-browser
            #:demo-treeview-tree
            #:test-custom-window
-           #:test-assistant))
+           #:test-assistant
+           #:test-entry-completion))
 
 (in-package :gtk-demo)
 
                                       (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
index c21e62f..0d4300f 100644 (file)
 (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)
index ff17bed..ba64925 100644 (file)
                         (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