emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r112936: lisp/gnus/eww.el (eww-convert-widgets): Mak


From: Katsumi Yamaoka
Subject: [Emacs-diffs] trunk r112936: lisp/gnus/eww.el (eww-convert-widgets): Make widgets from non-tabular layouts work, too
Date: Wed, 12 Jun 2013 01:38:29 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112936
revision-id: address@hidden
parent: address@hidden
author: Lars Magne Ingebrigtsen <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Wed 2013-06-12 01:38:23 +0000
message:
  lisp/gnus/eww.el (eww-convert-widgets): Make widgets from non-tabular layouts 
work, too
  (eww-tag-select): Implement <select>
modified:
  lisp/gnus/ChangeLog            changelog-20091113204419-o5vbwnq5f7feedwu-1433
  lisp/gnus/eww.el               eww.el-20130610114603-80ap3gwnw4x4m5ix-1
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2013-06-11 07:32:25 +0000
+++ b/lisp/gnus/ChangeLog       2013-06-12 01:38:23 +0000
@@ -1,3 +1,9 @@
+2013-06-11  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * eww.el (eww-convert-widgets): Make widgets from non-tabular layouts
+       work, too.
+       (eww-tag-select): Implement <select>.
+
 2013-06-10  Albert Krewinkel  <address@hidden>
 
        * sieve-manage.el (sieve-manage-open): work with STARTTLS: shorten

=== modified file 'lisp/gnus/eww.el'
--- a/lisp/gnus/eww.el  2013-06-11 03:09:59 +0000
+++ b/lisp/gnus/eww.el  2013-06-12 01:38:23 +0000
@@ -88,7 +88,7 @@
          (shr-external-rendering-functions
           '((form . eww-tag-form)
             (input . eww-tag-input)
-            (submit . eww-tag-submit))))
+            (select . eww-tag-select))))
       (shr-insert-document document)
       (eww-convert-widgets))
     (goto-char (point-min))))
@@ -201,6 +201,7 @@
                  :notify 'eww-click-radio
                  :name (cdr (assq :name cont))
                  :checkbox-value (cdr (assq :value cont))
+                 :checkbox-type type
                  :eww-form eww-form
                  (cdr (assq :checked cont))))
           ((equal type "hidden")
@@ -222,20 +223,43 @@
        (when shr-final-table-render
          (nconc eww-form (list widget)))
       (apply 'widget-create widget))
-    (put-text-property start (point) 'eww-widget widget)))
+    (put-text-property start (point) 'eww-widget widget)
+    (insert " ")))
+
+(defun eww-tag-select (cont)
+  (shr-ensure-paragraph)
+  (let ((menu (list 'menu-choice
+                   :name (cdr (assq :name cont))
+                   :eww-form eww-form))
+       (options nil)
+       (start (point)))
+    (dolist (elem cont)
+      (when (eq (car elem) 'option)
+       (when (cdr (assq :selected (cdr elem)))
+         (nconc menu (list :value
+                           (cdr (assq :value (cdr elem))))))
+       (push (list 'item
+                   :value (cdr (assq :value (cdr elem)))
+                   :tag (cdr (assq 'text (cdr elem))))
+             options)))
+    (nconc menu options)
+    (apply 'widget-create menu)
+    (put-text-property start (point) 'eww-widget menu)
+    (shr-ensure-paragraph)))
 
 (defun eww-click-radio (widget &rest ignore)
   (let ((form (plist-get (cdr widget) :eww-form))
        (name (plist-get (cdr widget) :name)))
-    (if (widget-value widget)
-       ;; Switch all the other radio buttons off.
-       (dolist (overlay (overlays-in (point-min) (point-max)))
-         (let ((field (plist-get (overlay-properties overlay) 'button)))
-           (when (and (eq (plist-get (cdr field) :eww-form) form)
-                      (equal name (plist-get (cdr field) :name)))
-             (unless (eq field widget)
-               (widget-value-set field nil)))))
-      (widget-value-set widget t))
+    (when (equal (plist-get (cdr widget) :type) "radio")
+      (if (widget-value widget)
+         ;; Switch all the other radio buttons off.
+         (dolist (overlay (overlays-in (point-min) (point-max)))
+           (let ((field (plist-get (overlay-properties overlay) 'button)))
+             (when (and (eq (plist-get (cdr field) :eww-form) form)
+                        (equal name (plist-get (cdr field) :name)))
+               (unless (eq field widget)
+                 (widget-value-set field nil)))))
+       (widget-value-set widget t)))
     (eww-fix-widget-keymap)))
 
 (defun eww-submit (widget &rest ignore)
@@ -298,12 +322,17 @@
 (defun eww-convert-widgets ()
   (let ((start (point-min))
        widget)
+    ;; Some widgets come from different buffers (rendered for tables),
+    ;; so we need to nix out the list of widgets and recreate them.
+    (setq widget-field-list nil
+         widget-field-new nil)
     (while (setq start (next-single-property-change start 'eww-widget))
       (setq widget (get-text-property start 'eww-widget))
       (goto-char start)
       (let ((end (next-single-property-change start 'eww-widget)))
        (dolist (overlay (overlays-in start end))
-         (when (plist-get (overlay-properties overlay) 'button)
+         (when (or (plist-get (overlay-properties overlay) 'button)
+                   (plist-get (overlay-properties overlay) 'field))
            (delete-overlay overlay)))
        (delete-region start end))
       (apply 'widget-create widget))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]