bongo-devel
[Top][All Lists]
Advanced

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

[bongo-devel] Line icons


From: Daniel Jensen
Subject: [bongo-devel] Line icons
Date: Thu, 08 Feb 2007 23:47:08 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.92 (gnu/linux)

Here's a display extension I've been sitting on since October. I was
going to rewrite it or something, I don't remember exactly. Well, it
works anyway, so I'll go ahead and post it here.

Install the patch if you want to look at pretty icons in your Bongo
buffers. Example at [1]. They are disabled by default, though, and you
have to supply your own icon files. Perhaps use icons from Mark James
at famfamfam.com [2], they are free. Do post links to other free icon
sets here, if you know any. I'd appreciate that. Or even better,
create new icons for Bongo!

This will not work on Emacs 21 since `image-type-from-file-name' is
new in Emacs 22. If you want this for Emacs 21, take the function
definition from Emacs sources or edit out the function call (e.g., put
type `png' instead and use only PNG images). Maybe there's another
workaround, but I haven't bothered to look into it.

Have fun!

Footnotes:

[1] http://img206.imageshack.us/img206/4708/bongoscreenvs3.png
[2] http://www.famfamfam.com/lab/icons/mini/

diff -Naur bongo-old/bongo.el bongo-new/bongo.el
--- bongo-old/bongo.el  2007-02-08 22:38:07.000000000 +0100
+++ bongo-new/bongo.el  2007-02-08 23:27:36.000000000 +0100
@@ -661,6 +661,78 @@
   :type 'string
   :group 'bongo-display)
 
+(defgroup bongo-line-icons nil
+  "Display of line icons in Bongo playlist and library buffers."
+  :group 'bongo-display)
+
+(defcustom bongo-display-line-icons nil
+  "Whether to display line icons in Bongo buffers."
+  :type 'boolean
+  :group 'bongo-line-icons)
+
+(defcustom bongo-track-icon nil
+  "Icon file name for track lines."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defcustom bongo-cd-track-icon nil
+  "Icon file name for CD track lines."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defcustom bongo-uri-track-icon nil
+  "Icon file name for URI track lines."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defcustom bongo-playing-track-icon nil
+  "Icon file name for a currently playing track."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defcustom bongo-played-track-icon nil
+  "Icon file name for played tracks."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defcustom bongo-action-track-icon nil
+  "Icon file name for action track lines."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defcustom bongo-expanded-header-icon nil
+  "Icon file name for expanded header lines."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defcustom bongo-collapsed-header-icon nil
+  "Icon file name for collapsed header lines."
+  :type 'file
+  :group 'bongo-line-icons)
+
+(defun bongo-get-icon-for-line ()
+  "Return an image descriptor of an icon for the current line."
+  (let ((image-file
+         (cond ((bongo-header-line-p)
+                (if (bongo-collapsed-header-line-p)
+                    bongo-collapsed-header-icon
+                  bongo-expanded-header-icon))
+               ((bongo-currently-playing-track-line-p)
+                bongo-playing-track-icon)
+               ((bongo-played-track-line-p)
+                bongo-played-track-icon)
+               ((bongo-uri-p (bongo-line-file-name))
+                (if (bongo-file-name-matches-p (bongo-line-file-name)
+                                               '("cdda:" . t))
+                    bongo-cd-track-icon
+                  bongo-uri-track-icon))
+               ((bongo-action-track-line-p)
+                bongo-action-track-icon)
+               (t bongo-track-icon))))
+    (list 'image :ascent 'center
+                 :file (or image-file bongo-track-icon)
+                 :type (image-type-from-file-name image-file))))
+
 (defgroup bongo-header-line nil
   "Display of header lines in Bongo playlist buffers."
   :group 'bongo
@@ -6899,6 +6971,9 @@
           (delete-char (min (length mark-string)
                             (- (bongo-point-at-eol) (point)))))
         (bongo-end-of-line))
+      (when bongo-display-line-icons
+        (insert-image (bongo-get-icon-for-line))
+        (insert " "))
       (let* ((bongo-infoset-formatting-target
               (current-buffer))
              (bongo-infoset-formatting-target-line

reply via email to

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