summaryrefslogtreecommitdiff
path: root/lisp/tumme.el
diff options
context:
space:
mode:
authorMathias Dahl <mathias.dahl@gmail.com>2006-07-19 10:35:07 +0000
committerMathias Dahl <mathias.dahl@gmail.com>2006-07-19 10:35:07 +0000
commit1ddf238f1b7d8a10e7e1ce1e7844a288dd3509f3 (patch)
tree1f92b2718c294113d31945fe73a3facf5e1631a7 /lisp/tumme.el
parentb38314e373c83bcb52aa0d0a59bb29ff3af92402 (diff)
downloademacs-1ddf238f1b7d8a10e7e1ce1e7844a288dd3509f3.tar.gz
(tumme-display-thumbnail-original-image): Make sure
image display buffer is displayed before call to `tumme-display-image. (tumme-dired-display-image): Make sure image display buffer is displayed before call to `tumme-display-image. (tumme-mouse-display-image): Make sure image display buffer is displayed before call to `tumme-display-image. (tumme-widget-list): Add. (tumme-dired-edit-comment-and-tags): Add. (tumme-save-information-from-widgets): Add.
Diffstat (limited to 'lisp/tumme.el')
-rw-r--r--lisp/tumme.el102
1 files changed, 102 insertions, 0 deletions
diff --git a/lisp/tumme.el b/lisp/tumme.el
index 2be66ba88de..8a443bc81c7 100644
--- a/lisp/tumme.el
+++ b/lisp/tumme.el
@@ -161,6 +161,10 @@
(require 'dired)
(require 'format-spec)
+(require 'widget)
+
+(eval-when-compile
+ (require 'wid-edit))
(defgroup tumme nil
"Use dired to browse your images as thumbnails, and more."
@@ -2426,6 +2430,104 @@ when using per-directory thumbnail file storage"))
(error nil))
(kill-buffer buffer)))
+(defvar tumme-widget-list nil
+ "List to keep track of meta data in edit buffer")
+
+;;;###autoload
+(defun tumme-dired-edit-comment-and-tags ()
+ "Edit comment and tags of current or marked image files.
+Edit comment and tags for all marked image files in an
+easy-to-use form."
+ (interactive)
+ (setq tumme-widget-list nil)
+ ;; Setup buffer.
+ (let ((files (dired-get-marked-files)))
+ (switch-to-buffer "*Tumme Edit Meta Data*")
+ (kill-all-local-variables)
+ (make-local-variable 'widget-example-repeat)
+ (let ((inhibit-read-only t))
+ (erase-buffer))
+ (remove-overlays)
+ ;; Some help for the user.
+ (widget-insert
+"\nEdit comments and tags for each image. Separate multiple tags
+with a comma. Move forward between fields using TAB or RET.
+Move to the previous field using backtab (S-TAB). Save by
+activating the Save button at the bottom of the form or cancel
+the operation by activating the Cancel button.\n\n")
+ ;; Here comes all images and a comment and tag field for each
+ ;; image.
+ (let (thumb-file img comment-widget tag-widget)
+
+ (dolist (file files)
+
+ (setq thumb-file (tumme-thumb-name file)
+ img (create-image thumb-file))
+
+ (insert-image img)
+ (widget-insert "\n\nComment: ")
+ (setq comment-widget
+ (widget-create 'editable-field
+ :size 60
+ :format "%v "
+ :value (or (tumme-get-comment file) "")))
+ (widget-insert "\nTags: ")
+ (setq tag-widget
+ (widget-create 'editable-field
+ :size 60
+ :format "%v "
+ :value (or (mapconcat
+ (lambda (tag)
+ tag)
+ (tumme-list-tags file)
+ ",") "")))
+ ;; Save information in all widgets so that we can use it when
+ ;; the user saves the form.
+ (setq tumme-widget-list
+ (append tumme-widget-list
+ (list (list file comment-widget tag-widget))))
+ (widget-insert "\n\n")))
+
+ ;; Footer with Save and Cancel button.
+ (widget-insert "\n")
+ (widget-create 'push-button
+ :notify
+ (lambda (&rest ignore)
+ (tumme-save-information-from-widgets)
+ (bury-buffer)
+ (message "Done."))
+ "Save")
+ (widget-insert " ")
+ (widget-create 'push-button
+ :notify
+ (lambda (&rest ignore)
+ (bury-buffer)
+ (message "Operation canceled."))
+ "Cancel")
+ (widget-insert "\n")
+ (use-local-map widget-keymap)
+ (widget-setup)
+ ;; Jump to the first widget.
+ (widget-forward 1)))
+
+(defun tumme-save-information-from-widgets ()
+ "Save information found in `tumme-widget-list'.
+Use the information in `tumme-widget-list' to save comments and
+tags to their respective image file. Internal function used by
+`tumme-dired-edit-comment-and-tags'."
+ (mapc
+ (lambda (x)
+ (let ((file (car x))
+ (comment (widget-value (cadr x)))
+ (tags (widget-value (car (cddr x)))))
+ (tumme-write-comment file comment)
+ (mapc
+ (lambda (tag)
+ (tumme-write-tag file tag))
+ (split-string tags ","))))
+ tumme-widget-list))
+
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; TEST-SECTION ;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;