initial move from git to bzr
[emacs.git] / lisp / xwidget.el
blobef200048f599ad48ae619028b4e9075160a4a9fd
1 ;; xwidget.el - api functions for xwidgets
2 ;; see xwidget.c for more api functions
4 (require 'xwidget-internal)
7 (defun xwidget-insert (pos type title width height &optional id)
8 "Insert an xwidget at POS, given ID, TYPE, TITLE WIDTH and HEIGHT.
9 Return ID
10 ID will be made optional, but it isnt implemented yet!
12 currently interface is lame:
13 :type 1=button, 2=toggle btn, 3=xembed socket(id will be printed to stdout)
14 obviously these should be symbols
16 :xwidget-id 1, MUST be unique and < 100 !
17 if slightly wrong, emacs WILL CRASH
19 These issues are of course fixable but I will continue to
20 hand-wave issues like these until the hard parts are solved.
22 (goto-char pos)
23 (put-text-property (point) (+ 1 (point)) 'display (list 'xwidget ':xwidget-id id ':type type ':title title ':width width ':height height))
24 id)
27 (defun xwidget-resize-at (pos width height)
28 "Resize xwidget at postion POS to WIDTH and HEIGHT."
29 (let*
30 ((xwidget-prop (cdr (get-text-property pos 'display)))
31 (id (plist-get xwidget-prop ':xwidget-id)))
32 (setq xwidget-prop (plist-put xwidget-prop ':width width))
33 (setq xwidget-prop (plist-put xwidget-prop ':height height))
35 (put-text-property pos (+ 1 pos) 'display (cons 'xwidget xwidget-prop))
36 (message "prop %s" xwidget-prop)
37 (message "id %d w %d h %d" id width height)
38 (xwidget-resize-internal id width height)
41 ;; use declare here?
42 ;; (declare-function xwidget-resize-internal "xwidget.c" )
43 ;; check-declare-function?
45 (provide 'xwidget)