emacs-devel
[Top][All Lists]
Advanced

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

Re: tumme testing


From: Juri Linkov
Subject: Re: tumme testing
Date: Tue, 14 Feb 2006 19:45:34 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

>> Quick! - which is bigger, Enormous or Huge? Such names are opaque on their
>> own - users will need to look up what they mean anyway.
>
> Ot1h you're right...
>
>> Why not just use the size as the name, without adding the vague translation?
>> "256x256" is a perfectly good name, and it gives you a clear idea of the
>> size.
>
> ...otoh, a layer of indirection allows adapting to different screen
> resolutions and user preferences with more ease. Personally, I'd prefer
> the size names, to be able to change the mapping to real sizes as a
> whole.

Nothing prevents us from having both types of size specifications:

Index: lisp/tumme.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/tumme.el,v
retrieving revision 1.17
diff -c -r1.17 tumme.el
*** lisp/tumme.el       13 Feb 2006 14:45:58 -0000      1.17
--- lisp/tumme.el       14 Feb 2006 17:44:04 -0000
***************
*** 428,447 ****
    :type '(repeat string)
    :group 'tumme)
  
! (defcustom tumme-thumb-size (if (eq 'standard tumme-thumbnail-storage) 128 
100)
!   "Size of thumbnails, in pixels.
! This is the default size for both `tumme-thumb-width' and 
`tumme-thumb-height'."
!   :type 'integer
!   :group 'tumme)
! 
! (defcustom tumme-thumb-width tumme-thumb-size
!   "Width of thumbnails, in pixels."
!   :type 'integer
!   :group 'tumme)
! 
! (defcustom tumme-thumb-height tumme-thumb-size
!   "Height of thumbnails, in pixels."
!   :type 'integer
    :group 'tumme)
  
  (defcustom tumme-thumb-relief 2
--- 428,449 ----
    :type '(repeat string)
    :group 'tumme)
  
! (defvar tumme-thumb-size-name-geometry-alist
!   '(("Very small" .  "32x32")
!     ("Small"      .  "64x64")
!     ("Medium"     . "128x128")
!     ("Normal"     . "128x128")
!     ("Large"      . "256x256"))
!   "Size name to geometry mapping.")
! 
! (defcustom tumme-thumb-geometry "Normal"
!   "Default thumbnail geometry.
! This should have either a form like \"128x128\" where the first number is the
! thumbnail width and the second number is the thumbnail height, or a size name
! matching one of the size names in `tumme-thumb-size-name-geometry-alist'."
!   :type `(choice ,@(mapcar (lambda (e) `(const ,(car e)))
!                            tumme-thumb-size-name-geometry-alist)
!                  (string :tag "Geometry"))
    :group 'tumme)
  
  (defcustom tumme-thumb-relief 2
***************
*** 622,630 ****
                   ;; "cryptographically" good so a faster one could
                   ;; be used here.
                   (md5 (file-name-as-directory (file-name-directory f)))))
!            (format "%s%s%s.thumb.%s"
                     (file-name-as-directory (expand-file-name (tumme-dir)))
                     (file-name-sans-extension (file-name-nondirectory f))
                     (if md5-hash (concat "_" md5-hash) "")
                     (file-name-extension f))))
          ((eq 'per-directory tumme-thumbnail-storage)
--- 624,633 ----
                   ;; "cryptographically" good so a faster one could
                   ;; be used here.
                   (md5 (file-name-as-directory (file-name-directory f)))))
!            (format "%s%s_%s%s.thumb.%s"
                     (file-name-as-directory (expand-file-name (tumme-dir)))
                     (file-name-sans-extension (file-name-nondirectory f))
+                    tumme-thumb-geometry
                     (if md5-hash (concat "_" md5-hash) "")
                     (file-name-extension f))))
          ((eq 'per-directory tumme-thumbnail-storage)
***************
*** 634,643 ****
                     (file-name-sans-extension (file-name-nondirectory f))
                     (file-name-extension f))))))
  
  (defun tumme-create-thumb (original-file thumbnail-file)
    "For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE."
!   (let* ((width (int-to-string tumme-thumb-width))
!          (height (int-to-string tumme-thumb-height))
           (modif-time (format "%.0f" (float-time (nth 5 (file-attributes
                                                          original-file)))))
           (thumbnail-nq8-file (replace-regexp-in-string ".png\\'" "-nq8.png"
--- 637,660 ----
                     (file-name-sans-extension (file-name-nondirectory f))
                     (file-name-extension f))))))
  
+ (defun tumme-thumb-width-and-height (&optional geometry)
+   "Return a cons-cell of pixels for width and height of thumbnail geometry.
+ Extract these numbers either from the optional argument `geometry' or
+ the default value of `tumme-thumb-geometry'.
+ Use `tumme-thumb-size-name-geometry-alist' as the size name to geometry 
mapping."
+   (setq geometry (or (cdr (assoc (or geometry tumme-thumb-geometry)
+                                  tumme-thumb-size-name-geometry-alist))
+                      (or geometry tumme-thumb-geometry)))
+   (save-match-data
+     (if (string-match "\\([0-9]+\\)x\\([0-9]+\\)" geometry)
+         (cons (match-string 1 geometry)
+               (match-string 2 geometry)))))
+ 
  (defun tumme-create-thumb (original-file thumbnail-file)
    "For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE."
!   (let* ((width-and-height (tumme-thumb-width-and-height))
!          (width (car width-and-height))
!          (height (cdr width-and-height))
           (modif-time (format "%.0f" (float-time (nth 5 (file-attributes
                                                          original-file)))))
           (thumbnail-nq8-file (replace-regexp-in-string ".png\\'" "-nq8.png"
***************
*** 1705,1711 ****
           (/ width
              (+ (* 2 tumme-thumb-relief)
                 (* 2 tumme-thumb-margin)
!                tumme-thumb-width char-width))))
      (tumme-line-up)))
  
  (defun tumme-line-up-interactive ()
--- 1722,1728 ----
           (/ width
              (+ (* 2 tumme-thumb-relief)
                 (* 2 tumme-thumb-margin)
!                (car (tumme-thumb-width-and-height)) char-width))))
      (tumme-line-up)))
  
  (defun tumme-line-up-interactive ()

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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