[Clg-devel] can't retrieve text/image added by gtk:clipboard-set-with-data
Brought to you by:
espen
From: Chisheng H. <cp...@ch...> - 2007-12-05 18:52:15
|
Hi, I'd like to use GTK:CLIPBOARD-SET-WITH-DATA so that I can carry out some clean up operations after the data posted to the clipboard is cleared. But the problem is the text or pixbuf passed to GTK:CLIPBOARD-SET-WITH-DATA can't be retrieved by gtk:clipboard-wait-for-{text or image} and gtk:clipboard-request-{text or image}. The attached code demonstrates the problem. Any help to get around this problem will be appreciated. Best wishes, -cph ;;------------------------------------------------------------------ ;; you'll need this binding to run the test code. (in-package :gtk) (defbinding target-table-new-from-list () (vector (inlined target-entry) n-targets) (target-list target-list) (n-targets int :out)) ;;------------------------------------------------------------------ (in-package :cl-user) ;; if we use GTK:CLIPBOARD-SET-TEXT, no problem to retrieve text ;; from the clipboard. (gtk:clipboard-set-text (gtk:clipboard-get "CLIPBOARD") "text") ;; this returns "text" (gtk:clipboard-wait-for-text (gtk:clipboard-get "CLIPBOARD")) ;; this prints out (:RECEIVED-TEXT "text") (gtk:clipboard-request-text (gtk:clipboard-get "CLIPBOARD") (lambda (text) (print (list :received-text text)))) ;;------------------------------------------------------------------ (let ((target-list (make-instance 'gtk:target-list))) (gtk:target-list-add-text-targets target-list 0) (gtk:clipboard-set-with-data (gtk:clipboard-get "CLIPBOARD") (gtk::target-table-new-from-list target-list) ;; get-func #'(lambda (sd info) (print :get-func) (gtk:selection-data-set-text sd "with data") (print (list :text-in-selection-data (gtk:selection-data-get-text sd)))) ;; clear-func #'(lambda () (print :clear-func)))) ;; GET-FUNC is called but this returns NIL. (gtk:clipboard-wait-for-text (gtk:clipboard-get "CLIPBOARD")) ;; GET-FUNC is called but this prints out (:RECEIVED-TEXT NIL) (gtk:clipboard-request-text (gtk:clipboard-get "CLIPBOARD") (lambda (text) (print (list :received-text text)))) |