diff lisp/wid-edit.el @ 107381:c97f25cea7c4

Improvements to the Custom interface. * cus-edit.el: Resort topmost custom groups. (custom-buffer-sort-alphabetically): Default to t. (customize-apropos): Use apropos-parse-pattern. (custom-search-field): New var. (custom-buffer-create-internal): Add custom-apropos search field. (custom-add-parent-links): Don't display parent doc. (custom-group-value-create): Don't sort top-level custom group. (custom-magic-value-create): Show visibility button before option name. (custom-variable-state): New fun, from custom-variable-state-set. (custom-variable-state-set): Use it. (custom-group-value-create): Hide options with standard values using the :hidden-states property. Use progress reporter. (custom-show): Simplify. (custom-visibility): Disable images by default. (custom-variable): New property :hidden-states. (custom-variable-value-create): Enable images for custom-visibility widgets. Use :hidden-states property to determine initial visibility. * wid-edit.el (widget-image-find): Give images center ascent. (visibility): Add :on-image and :off-image properties. (widget-visibility-value-create): Use them.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 12 Mar 2010 17:56:30 -0500
parents 49daa9e9669f
children 96ec3562df8f
line wrap: on
line diff
--- a/lisp/wid-edit.el	Fri Mar 12 16:42:05 2010 -0500
+++ b/lisp/wid-edit.el	Fri Mar 12 17:56:30 2010 -0500
@@ -639,8 +639,7 @@
 	   (dolist (elt widget-image-conversion)
 	     (dolist (ext (cdr elt))
 	       (push (list :type (car elt) :file (concat image ext)) specs)))
-	   (setq specs (nreverse specs))
-	   (find-image specs)))
+ 	   (find-image (nreverse specs))))
 	(t
 	 ;; Oh well.
 	 nil)))
@@ -2806,11 +2805,19 @@
 ;;; The `visibility' Widget.
 
 (define-widget 'visibility 'item
-  "An indicator and manipulator for hidden items."
+  "An indicator and manipulator for hidden items.
+
+The following properties have special meanings for this widget:
+:on-image  Image filename or spec to display when the item is visible.
+:on        Text shown if the \"on\" image is nil or cannot be displayed.
+:off-image Image filename or spec to display when the item is hidden.
+:off       Text shown if the \"off\" image is nil cannot be displayed."
   :format "%[%v%]"
   :button-prefix ""
   :button-suffix ""
+  :on-image "down"
   :on "Hide"
+  :off-image "right"
   :off "Show"
   :value-create 'widget-visibility-value-create
   :action 'widget-toggle-action
@@ -2818,21 +2825,17 @@
 
 (defun widget-visibility-value-create (widget)
   ;; Insert text representing the `on' and `off' states.
-  (let ((on (widget-get widget :on))
-	(off (widget-get widget :off)))
-    (if on
-	(setq on (concat widget-push-button-prefix
-			 on
-			 widget-push-button-suffix))
-      (setq on ""))
-    (if off
-	(setq off (concat widget-push-button-prefix
-			  off
-			  widget-push-button-suffix))
-      (setq off ""))
-    (if (widget-value widget)
-	(widget-image-insert widget on "down" "down-pushed")
-      (widget-image-insert widget off "right" "right-pushed"))))
+  (let* ((val (widget-value widget))
+	 (text (widget-get widget (if val :on :off)))
+	 (img (widget-image-find
+	       (widget-get widget (if val :on-image :off-image)))))
+    (widget-image-insert widget
+			 (if text
+			     (concat widget-push-button-prefix text
+				     widget-push-button-suffix)
+			   "")
+			 (if img
+			     (append img '(:ascent center))))))
 
 ;;; The `documentation-link' Widget.
 ;;
@@ -2935,7 +2938,7 @@
 		(widget-create-child-and-convert
 		 widget (widget-get widget :visibility-widget)
 		 :help-echo "Show or hide rest of the documentation."
-		 :on "Hide Rest"
+		 :on "Hide"
 		 :off "More"
 		 :always-active t
 		 :action 'widget-parent-action