[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bongo-patches] Fix bugs in playlist-immediate playback progress meter
From: |
Daniel Brockman |
Subject: |
[bongo-patches] Fix bugs in playlist-immediate playback progress meter |
Date: |
Sat, 28 Apr 2007 00:58:08 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux) |
Fix bugs in playlist-immediate playback progress meter.
diff -rN -u old-bongo/bongo.el new-bongo/bongo.el
--- old-bongo/bongo.el 2007-04-28 00:58:05.000000000 +0200
+++ new-bongo/bongo.el 2007-04-28 00:58:05.000000000 +0200
@@ -4834,18 +4834,22 @@
(defun bongo-player-elapsed-time (player)
"Return the number of seconds PLAYER has played so far.
-If the player backend cannot report this, return nil."
- (bongo-player-call-with-default
- player 'get-elapsed-time
- 'bongo-default-player-get-elapsed-time))
+If the player backend cannot report this, return nil.
+The return value is always a floating point number or nil."
+ (let ((value (bongo-player-call-with-default
+ player 'get-elapsed-time
+ 'bongo-default-player-get-elapsed-time)))
+ (and value (>= value 0) (float value))))
(defun bongo-player-total-time (player)
"Return the total number of seconds PLAYER has and will use.
-If the player backend cannot report this, return nil."
+If the player backend cannot report this, return nil.
+The return value is always a floating point number or nil."
(let ((value (bongo-player-call-with-default
player 'get-total-time
'bongo-default-player-get-total-time)))
- (and value (> value 0) value)))
+ ;; In most cases, zero means "I don't know".
+ (and value (> value 0) (float value))))
(defun bongo-player-update-elapsed-time (player elapsed-time)
"Set PLAYER's `elapsed-time' property to ELAPSED-TIME,
@@ -8048,6 +8052,10 @@
(prog1 map
(define-key map [mouse-3] 'bongo-pop-up-context-menu))))
+(defun bongo-current-column (&optional point window)
+ (let ((posn (posn-at-point point window)))
+ (and posn (car (posn-col-row posn)))))
+
(defun bongo-redisplay-line (&optional point)
"Redisplay the line at POINT, preserving semantic text properties."
(save-excursion
@@ -8097,16 +8105,30 @@
(when (and (bongo-currently-playing-track-line-p)
(bongo-elapsed-time)
(bongo-total-time))
- (let* ((end (- (window-width) 2))
- (middle (floor (* end
- (/ (bongo-elapsed-time)
- (bongo-total-time))))))
- (insert (make-string (max 0 (- end (current-column))) 32))
- (goto-char (point-at-bol))
- (while (< (current-column) middle)
- (forward-char 1))
- (bongo-facify-region (point-at-bol) (point)
- 'bongo-elapsed-track-part)))
+ (let ((windows (get-buffer-window-list (current-buffer))))
+ (let (smallest-window)
+ (dolist (window windows)
+ (when (and (posn-at-point point window)
+ (or (null smallest-window)
+ (< (window-width window)
+ (window-width smallest-window))))
+ (setq smallest-window window)))
+ (when smallest-window
+ (let ((point (point)))
+ (save-window-excursion
+ (select-window smallest-window)
+ (goto-char point)
+ (let* ((middle (floor (* (window-width)
+ (/ (bongo-elapsed-time)
+ (bongo-total-time))))))
+ (goto-char (point-at-bol))
+ (while (let ((column (bongo-current-column)))
+ (and column (< column middle)))
+ (if (eolp)
+ (insert " ")
+ (forward-char 1)))
+ (bongo-facify-region (point-at-bol) (point)
+ 'bongo-elapsed-track-part))))))))
(when invisible
(put-text-property (bongo-point-before-line)
(bongo-point-after-line)
--
Daniel Brockman <address@hidden>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bongo-patches] Fix bugs in playlist-immediate playback progress meter,
Daniel Brockman <=