xwem-patches
[Top] [All Lists]

[Merge-Req] steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-19

From: Steve Youngs <steve@xxxxxxxx>
Subject: [Merge-Req] steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-19
Date: Wed, 07 Dec 2005 15:19:55 +1000
Organization: The XWEM Project
User-agent: Gnus/5.110004 (No Gnus v0.4) SXEmacs/22.1.3 (BMW, linux)
Revision: xwem--steve--2.2--patch-19
Archive: steve@xxxxxxxxxxxxxx
Creator: Steve Youngs <steve@xxxxxxxx>
Date: Mon Nov 28 07:27:21 EST 2005
Standard-date: 2005-11-27 21:27:21 GMT
Modified-files: dockapp/xwem-mpd.el
New-patches: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-19
Summary: mpd volume enhancements
Keywords: enhancement, internal, newfeature, user-visible

Amongst other things, this changeset adds "unmute" being the opposite of
"mute".  When unmuting the volume it returns to the volume level that
existed before it was muted.  When the volume is muted, "MUTE" is
displayed in the dock.

You can now also specify the number of "steps" to increment/decrement the
volume with the `mpd-volume-{up,down}' functions.

Two new convenience functions have been added... `mpd-volume-max' &
`mpd-volume-min'. 

* dockapp/xwem-mpd.el (mpd-pre-mute-volume): New. Hold the volume setting
  prior to mute so unmute returns to the same volume.
  (mpd-volume-mute): Rewrite as a xwem-command so it can use a prefix arg
  to unmute.  Also use the mpd command `setvol' instead of `volume'
  because the latter is a deprecated command.
  (mpd-volume-up): Rewrite as a xwem-command, accept numeric prefix arg
  to specify the "steps" to increment the volume.  Use `setvol' instead
  of `volume'.
  (mpd-volume-down): Ditto, except we're decreasing the volume of
  course. 
  (mpd-volume-max): New.  Convenience function to set volume to maximum.
  (mpd-volume-min): New.  Convenience function to set volume to minimum.
  (mpd-muted-p): New.  Return non-nil when volume is at zero.
  (xwem-mpd-osd-setup): Use it.
  (xwem-mpd-osd-update): Ditto.

* looking for steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-18 to compare with
* build pristine tree for steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-18
* from pristine cache: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-9
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-10
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-11
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-12
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-13
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-14
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-15
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-16
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-17
* patching for revision: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-18
* comparing to steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-18

  A  
{arch}/xwem/xwem--steve/xwem--steve--2.2/steve@xxxxxxxxxxxxxx/patch-log/patch-19
  M  dockapp/xwem-mpd.el
                                                                        


* modified files

--- orig/dockapp/xwem-mpd.el
+++ mod/dockapp/xwem-mpd.el
@@ -80,7 +80,9 @@
     (lyrics :place bottom-right :depth 0 :icon "mini-lyrics.xpm")
     (volume :place right :depth 1 :font "fixed" :color "white")
     (state :place center :depth 1 :font 
"-*-helvetica-bold-r-*-*-20-*-*-*-*-*-*-*"
-           :color "red3" :format (or (and (mpd-stopped-p) "STOPPED") (and 
(mpd-paused-p) "PAUSED"))))
+           :color "red3" :format (or (and (mpd-stopped-p) "STOPPED")
+                                    (and (mpd-paused-p) "PAUSED")
+                                    (and (mpd-muted-p) "MUTE"))))
   "Mpd dockapp configuration.
 :place is not yet implemented."
   :type 'list
@@ -169,6 +171,11 @@
 (defvar **mpd-var-volume* nil)
 (defvar **mpd-var-xfade* nil)
 
+(defvar mpd-pre-mute-volume nil
+  "Holds the value of `**mpd-var-volume* prior to muting.
+The purpose of this is so that when you unmute, it goes back to the
+volume you had it set to before you muted.")
+
 (defvar mpd-this-command nil
   "The mpd command currently executing.
 Useful to use in `mpd-after-command-hook' hooks.")
@@ -193,6 +200,8 @@
   (string= **mpd-var-state* "stop"))
 (defun mpd-paused-p ()
   (string= **mpd-var-state* "pause"))
+(defun mpd-muted-p ()
+  (zerop (string-to-number **mpd-var-volume*)))
 
 ;; (mpd-songpos)
 (defun mpd-songpos ()
@@ -202,17 +211,52 @@
         (cons (string-to-int a) (string-to-int b)))
     (cons 0 1)))                        ; todo?
 
-(define-mpd-command mpd-volume-up ()
-  (interactive)
-  (mpd-send "volume +2"))
+(define-xwem-command mpd-volume-up (step)
+  "Increase the volume by STEP increments.
+STEP can be given via numeric prefix arg and defaults to 1 if omitted."
+  (xwem-interactive "p")
+  (let* ((oldvol (string-to-number **mpd-var-volume*))
+        (newvol (+ oldvol step))
+        (mpd-this-command 'mpd-volume-down))
+    (when (>= newvol 100)
+      (setq newvol 100))
+    (mpd-send "setvol %d" newvol)
+    (run-hooks 'mpd-after-command-hook)))
+
+(define-xwem-command mpd-volume-down (step)
+  "Decrease the volume by STEP increments.
+STEP can be given via numeric prefix arg and defaults to 1 if omitted."
+  (xwem-interactive "p")
+  (let* ((oldvol (string-to-number **mpd-var-volume*))
+        (newvol (- oldvol step))
+        (mpd-this-command 'mpd-volume-down))
+    (when (<= newvol 0)
+      (setq newvol 0))
+    (mpd-send "setvol %d" newvol)
+    (run-hooks 'mpd-after-command-hook)))
+
+(define-xwem-command mpd-volume-mute (&optional unmute)
+  "Mute the volume.
+With prefix arg, UNMUTE, let the tunes blast again."
+  (xwem-interactive "P")
+  (if unmute
+      (mpd-send "setvol %s" mpd-pre-mute-volume)
+    (setq mpd-pre-mute-volume **mpd-var-volume*)
+    (mpd-send "setvol 0"))
+  (let ((mpd-this-command 'mpd-volume-mute))
+    (run-hooks 'mpd-after-command-hook)))
 
-(define-mpd-command mpd-volume-down ()
+(define-mpd-command mpd-volume-max ()
+  "Set volume to maximum."
   (interactive)
-  (mpd-send "volume -2"))
+  (mpd-send "setvol 100"))
 
-(define-mpd-command mpd-volume-mute ()
+(define-mpd-command mpd-volume-min ()
+  "Set volume to minimum.
+Sets state to \"muted\" by side effect."
   (interactive)
-  (mpd-send "volume -100"))
+  (setq mpd-pre-mute-volume **mpd-var-volume*)
+  (mpd-send "setvol 0"))
 
 (define-mpd-command mpd-seek (time)
   "Seek current track to TIME."
@@ -435,7 +479,7 @@
              (plist-get lyr-plist :depth))))
         
         ;; State
-        (when (or (mpd-stopped-p) (mpd-paused-p))
+        (when (or (mpd-stopped-p) (mpd-paused-p) (mpd-muted-p))
           (xwem-osd-set-font xwem-mpd-osd (plist-get st-plist :font))
           (let* ((txt (eval (plist-get st-plist :format)))
                  (fnt (X-Font-get (xwem-osd-xdpy xwem-mpd-osd)



* added files

--- /dev/null
+++ 
/home/steve/programming/XWEM/xwem-steve/,,what-changed.xwem--steve--2.2--patch-18--steve@xxxxxxxxxxxxxx/new-files-archive/./{arch}/xwem/xwem--steve/xwem--steve--2.2/steve@xxxxxxxxxxxxxx/patch-log/patch-19
@@ -0,0 +1,37 @@
+Revision: xwem--steve--2.2--patch-19
+Archive: steve@xxxxxxxxxxxxxx
+Creator: Steve Youngs <steve@xxxxxxxx>
+Date: Mon Nov 28 07:27:21 EST 2005
+Standard-date: 2005-11-27 21:27:21 GMT
+Modified-files: dockapp/xwem-mpd.el
+New-patches: steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-19
+Summary: mpd volume enhancements
+Keywords: enhancement, internal, newfeature, user-visible
+
+Amongst other things, this changeset adds "unmute" being the opposite of
+"mute".  When unmuting the volume it returns to the volume level that
+existed before it was muted.  When the volume is muted, "MUTE" is
+displayed in the dock.
+
+You can now also specify the number of "steps" to increment/decrement the
+volume with the `mpd-volume-{up,down}' functions.
+
+Two new convenience functions have been added... `mpd-volume-max' &
+`mpd-volume-min'. 
+
+* dockapp/xwem-mpd.el (mpd-pre-mute-volume): New. Hold the volume setting
+  prior to mute so unmute returns to the same volume.
+  (mpd-volume-mute): Rewrite as a xwem-command so it can use a prefix arg
+  to unmute.  Also use the mpd command `setvol' instead of `volume'
+  because the latter is a deprecated command.
+  (mpd-volume-up): Rewrite as a xwem-command, accept numeric prefix arg
+  to specify the "steps" to increment the volume.  Use `setvol' instead
+  of `volume'.
+  (mpd-volume-down): Ditto, except we're decreasing the volume of
+  course. 
+  (mpd-volume-max): New.  Convenience function to set volume to maximum.
+  (mpd-volume-min): New.  Convenience function to set volume to minimum.
+  (mpd-muted-p): New.  Return non-nil when volume is at zero.
+  (xwem-mpd-osd-setup): Use it.
+  (xwem-mpd-osd-update): Ditto.
+



-- 
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
|                        In space,                         |
|             No one can hear you rip a stinky             |
|---------------------------------------<steve@xxxxxxxx>---|

Attachment: pgpaifTsMm1TX.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>
  • [Merge-Req] steve@xxxxxxxxxxxxxx/xwem--steve--2.2--patch-19, Steve Youngs <=