diff src/evdev-plug/ed.c @ 457:f5ed9a6ad3f1 trunk

[svn] - evdev-plug: added volume->mute and win->jumptofile actions
author giacomo
date Wed, 17 Jan 2007 09:14:03 -0800
parents f757e1aa62e6
children d124034ebea3
line wrap: on
line diff
--- a/src/evdev-plug/ed.c	Wed Jan 17 08:52:04 2007 -0800
+++ b/src/evdev-plug/ed.c	Wed Jan 17 09:14:03 2007 -0800
@@ -42,9 +42,11 @@
 void ed_action_vol_down5 ( gpointer );
 void ed_action_vol_up10 ( gpointer );
 void ed_action_vol_down10 ( gpointer );
+void ed_action_vol_mute ( gpointer );
 void ed_action_win_main ( gpointer );
 void ed_action_win_playlist ( gpointer );
 void ed_action_win_equalizer ( gpointer );
+void ed_action_win_jtf ( gpointer );
 void ed_action_pl_repeat ( gpointer );
 void ed_action_pl_shuffle ( gpointer );
 
@@ -65,10 +67,12 @@
   [ED_ACTION_VOL_DOWN5] = { N_("Volume->Down_5") , ed_action_vol_down5 },
   [ED_ACTION_VOL_UP10] = { N_("Volume->Up_10") , ed_action_vol_up10 },
   [ED_ACTION_VOL_DOWN10] = { N_("Volume->Down_10") , ed_action_vol_down10 },
+  [ED_ACTION_VOL_MUTE] = { N_("Volume->Mute") , ed_action_vol_mute },
 
   [ED_ACTION_WIN_MAIN] = { N_("Window->Main") , ed_action_win_main },
   [ED_ACTION_WIN_PLAYLIST] = { N_("Window->Playlist") , ed_action_win_playlist },
-  [ED_ACTION_WIN_EQUALIZER] = { N_("Window->Equalizer") , ed_action_win_equalizer }
+  [ED_ACTION_WIN_EQUALIZER] = { N_("Window->Equalizer") , ed_action_win_equalizer },
+  [ED_ACTION_WIN_JTF] = { N_("Window->JumpToFile") , ed_action_win_jtf }
 };
 
 
@@ -221,6 +225,38 @@
 }
 
 void
+ed_action_vol_mute ( gpointer param )
+{
+  static gint vl = -1;
+  static gint vr = -1;
+
+  if ( vl == -1 ) /* no previous memory of volume before mute action */
+  {
+    xmms_remote_get_volume( ed_gp.xmms_session , &vl , &vr ); /* memorize volume before mute */
+    xmms_remote_set_volume( ed_gp.xmms_session , 0 , 0 ); /* mute */
+  }
+  else /* memorized volume values exist */
+  {
+    gint vl_now = 0;
+    gint vr_now = 0;
+
+    xmms_remote_get_volume( ed_gp.xmms_session , &vl_now , &vr_now );
+    if (( vl_now == 0 ) && ( vr_now == 0 ))
+    {
+      /* the volume is still muted, restore the old values */
+      xmms_remote_set_volume( ed_gp.xmms_session , vl , vr );
+      vl = -1; vr = -1; /* reset these for next use */
+    }
+    else
+    {
+      /* the volume has been raised with other commands, act as if there wasn't a previous memory */
+      xmms_remote_get_volume( ed_gp.xmms_session , &vl , &vr ); /* memorize volume before mute */
+      xmms_remote_set_volume( ed_gp.xmms_session , 0 , 0 ); /* mute */
+    }
+  }
+}
+
+void
 ed_action_win_main ( gpointer param )
 {
   xmms_remote_main_win_toggle( ed_gp.xmms_session ,
@@ -240,3 +276,9 @@
   xmms_remote_eq_win_toggle( ed_gp.xmms_session ,
     !xmms_remote_is_eq_win ( ed_gp.xmms_session ) );
 }
+
+void
+ed_action_win_jtf ( gpointer param )
+{
+  xmms_remote_show_jtf_box( ed_gp.xmms_session );
+}