aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJoakim Verona2011-07-18 22:45:22 +0200
committerJoakim Verona2011-07-18 22:45:22 +0200
commitd202b5a0bae129aff4af5db194603e055d29440c (patch)
tree0e147433430bf9882b5a29262cb6aa13303a8e68 /lisp
parentcd1f21dd9e794a14aa6907296c6ee95cc5f693a1 (diff)
downloademacs-d202b5a0bae129aff4af5db194603e055d29440c.tar.gz
emacs-d202b5a0bae129aff4af5db194603e055d29440c.zip
support for disabling plugins(flash is undesirable) in webkit
Diffstat (limited to 'lisp')
-rw-r--r--lisp/xwidget.el51
1 files changed, 35 insertions, 16 deletions
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index b389265692e..93dafea7df9 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -12,12 +12,17 @@ see xwidget.c for types suitable for TYPE.
12" 12"
13 (goto-char pos) 13 (goto-char pos)
14 (let ((id (make-xwidget (point) (point) type title width height nil))) 14 (let ((id (make-xwidget (point) (point) type title width height nil)))
15 (put-text-property (point) (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) 15 (put-text-property (point)
16 (+ 1 (point)) 'display (list 'xwidget ':xwidget id))
17
16 id)) 18 id))
17 19
20
18(defun xwidget-at (pos) 21(defun xwidget-at (pos)
19 (car (cdr (cdr (get-text-property pos 'display))) 22 (car (cdr (cdr (get-text-property pos 'display)))))
20)) 23
24
25
21 26
22(defun xwidget-socket-handler () 27(defun xwidget-socket-handler ()
23 "creates plug for socket. TODO" 28 "creates plug for socket. TODO"
@@ -37,9 +42,9 @@ see xwidget.c for types suitable for TYPE.
37 ;; (start-process "xembed" "*xembed*" (format "%ssrc/emacs" default-directory) "-q" "--parent-id" (number-to-string xembed-id) ) ) 42 ;; (start-process "xembed" "*xembed*" (format "%ssrc/emacs" default-directory) "-q" "--parent-id" (number-to-string xembed-id) ) )
38 ;; ((eq 5 xwidget-id) 43 ;; ((eq 5 xwidget-id)
39 ;; (start-process "xembed2" "*xembed2*" "uzbl-core" "-s" (number-to-string xembed-id) "http://www.fsf.org" ) ) 44 ;; (start-process "xembed2" "*xembed2*" "uzbl-core" "-s" (number-to-string xembed-id) "http://www.fsf.org" ) )
40 45 )))))
41 ) 46
42 )))) 47
43 48
44 49
45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -59,20 +64,25 @@ defaults to the string looking like a url around the cursor position."
59 (xwidget-webkit-goto-url url)))) 64 (xwidget-webkit-goto-url url))))
60 65
61 66
67
62;;todo. 68;;todo.
63;; - support browse-url with xwidget-webkit 69;; - support browse-url with xwidget-webkit
64;; - check that the webkit support is compiled in 70;; - check that the webkit support is compiled in
65(define-derived-mode xwidget-webkit-mode
66 special-mode "xwidget-webkit" "xwidget webkit view mode"
67 (setq buffer-read-only t))
68(defvar xwidget-webkit-mode-map 71(defvar xwidget-webkit-mode-map
69 (let ((map (make-sparse-keymap))) 72 (let ((map (make-sparse-keymap)))
70 (define-key map "g" 'xwidget-webkit-browse-url) 73 (define-key map "g" 'xwidget-webkit-browse-url)
71 (define-key map "a" 'xwidget-webkit-adjust-size-to-content) 74 (define-key map "a" 'xwidget-webkit-adjust-size-to-content)
72 (define-key map "\C-m" 'xwidget-webkit-insert-string) 75 (define-key map "\C-m" 'xwidget-webkit-insert-string)
73 map) 76 map)
77
74 "Keymap for `xwidget-webkit-mode'.") 78 "Keymap for `xwidget-webkit-mode'.")
75 79
80
81
82(define-derived-mode xwidget-webkit-mode
83 special-mode "xwidget-webkit" "xwidget webkit view mode"
84 (setq buffer-read-only t))
85
76(defvar xwidget-webkit-last-session-buffer nil) 86(defvar xwidget-webkit-last-session-buffer nil)
77 87
78(defun xwidget-webkit-last-session () 88(defun xwidget-webkit-last-session ()
@@ -86,8 +96,8 @@ defaults to the string looking like a url around the cursor position."
86 ;;xwidgets doesnt support widgets that have thoir own opinions about size well yet 96 ;;xwidgets doesnt support widgets that have thoir own opinions about size well yet
87 ;;this reads the size and sets it back 97 ;;this reads the size and sets it back
88 (let ((size (xwidget-size-request xw))) 98 (let ((size (xwidget-size-request xw)))
89 (xwidget-resize xw (car size) (cadr size))) 99 (xwidget-resize xw (car size) (cadr size))))
90 ) 100
91 101
92(defun xwidget-webkit-insert-string (xw str) 102(defun xwidget-webkit-insert-string (xw str)
93 (interactive (list (xwidget-webkit-last-session) 103 (interactive (list (xwidget-webkit-last-session)
@@ -96,8 +106,8 @@ defaults to the string looking like a url around the cursor position."
96 106
97(defun xwidget-webkit-adjust-size-to-content () 107(defun xwidget-webkit-adjust-size-to-content ()
98 (interactive) 108 (interactive)
99 ( xwidget-adjust-size-to-content ( xwidget-webkit-last-session)) 109 ( xwidget-adjust-size-to-content ( xwidget-webkit-last-session)))
100 ) 110
101 111
102(defun xwidget-webkit-new-session (url) 112(defun xwidget-webkit-new-session (url)
103 113
@@ -108,10 +118,8 @@ defaults to the string looking like a url around the cursor position."
108 (insert " ") 118 (insert " ")
109 (xwidget-insert 1 'webkit-osr bufname 1000 1000) 119 (xwidget-insert 1 'webkit-osr bufname 1000 1000)
110 (xwidget-webkit-mode) 120 (xwidget-webkit-mode)
111 (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url )) 121 (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url )))
112
113 122
114 )
115 123
116(defun xwidget-webkit-goto-url (url) 124(defun xwidget-webkit-goto-url (url)
117 (if ( xwidget-webkit-last-session) 125 (if ( xwidget-webkit-last-session)
@@ -132,7 +140,18 @@ defaults to the string looking like a url around the cursor position."
132 (redraw-display);;redraw display otherwise ghost of zombies will remain to haunt the screen 140 (redraw-display);;redraw display otherwise ghost of zombies will remain to haunt the screen
133 ) 141 )
134 142
143
144
135;;this is a workaround because I cant find the right place to put it in C 145;;this is a workaround because I cant find the right place to put it in C
136(add-hook 'window-configuration-change-hook 'xwidget-cleanup) 146(add-hook 'window-configuration-change-hook 'xwidget-cleanup)
137 147
148(defvar xwidget-webkit-kill-flash-oneshot nil)
149(defun xwidget-webkit-kill-flash ()
150 ;;you can only call this once or webkit crashes and takes emacs with it. odd.
151 (unless xwidget-webkit-kill-flash-oneshot
152 (xwidget-disable-plugin-for-mime "application/x-shockwave-flash")
153 (setq xwidget-webkit-kill-flash-oneshot t)))
154
155(xwidget-webkit-kill-flash)
156
138(provide 'xwidget) 157(provide 'xwidget)