Updating branch refs/heads/master
         to 8041e94078b70d14226c73b1843445dada008da3 (commit)
       from 48493a74f9109d6fb549a95533a07b46c5e2e1b5 (commit)

commit 8041e94078b70d14226c73b1843445dada008da3
Author: Vincent Legout <[email protected]>
Date:   Sun Jan 24 13:38:36 2010 +0800

    Update title to reflect what is playing in MPD (bug #6127)
    
    Add xfmpc_mpdclient_is_paused

 src/main-window.vala |   26 ++++++++++++++++++++++++++
 src/mpdclient.c      |    7 +++++++
 src/mpdclient.h      |    1 +
 src/mpdclient.vapi   |    1 +
 4 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/main-window.vala b/src/main-window.vala
index 20e2efd..72bb1b0 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -115,6 +115,9 @@ namespace Xfmpc {
                        ((Gtk.ToggleAction )(this.action_group.get_action 
("view-statusbar"))).set_active (this.preferences.show_statusbar);
 
                        /* === Signals === */
+                       this.mpdclient.pp_changed.connect (cb_update_title);
+                       this.mpdclient.stopped.connect (cb_update_title);
+                       this.mpdclient.song_changed.connect (cb_update_title);
                        this.mpdclient.playlist_changed.connect 
(cb_playlist_changed);
                        this.preferences.notify["show-statusbar"].connect 
(cb_show_statusbar_changed);
 
@@ -242,6 +245,29 @@ namespace Xfmpc {
 
                private void cb_playlist_changed () {
                        update_statusbar ();
+
+                       cb_update_title ();
+               }
+
+               private void cb_update_title () {
+                       if (this.mpdclient.is_playing ())
+                               set_title (get_updated_title ());
+                       else if (this.mpdclient.is_paused ())
+                               set_title ("[" + get_updated_title () + "]");
+                       else
+                               set_title (Config.PACKAGE_NAME);
+               }
+
+               private string get_updated_title () {
+                       if (this.mpdclient.get_artist () != "n/a" && 
this.mpdclient.get_title () != "n/a")
+                               return ("%s - %s").printf 
(this.mpdclient.get_artist (),
+                                                          
this.mpdclient.get_title ());
+                       else if (this.mpdclient.get_artist () == "n/a")
+                               return ("%s").printf (this.mpdclient.get_title 
());
+                       else if (this.mpdclient.get_title () == "n/a")
+                               return ("%s").printf (this.mpdclient.get_artist 
());
+                       else
+                               return Config.PACKAGE_NAME;
                }
 
                private void cb_show_statusbar_changed (ParamSpec pspec) {
diff --git a/src/mpdclient.c b/src/mpdclient.c
index eed84e8..83fced2 100644
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
@@ -660,6 +660,13 @@ xfmpc_mpdclient_is_playing (XfmpcMpdclient *mpdclient)
 }
 
 gboolean
+xfmpc_mpdclient_is_paused (XfmpcMpdclient *mpdclient)
+{
+  XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
+  return mpd_player_get_state (priv->mi) == MPD_PLAYER_PAUSE;
+}
+
+gboolean
 xfmpc_mpdclient_is_stopped (XfmpcMpdclient *mpdclient)
 {
   XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 48b8427..57a7f0c 100644
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
@@ -84,6 +84,7 @@ guint8                  xfmpc_mpdclient_get_volume            
  (XfmpcMpdclient
 gboolean                xfmpc_mpdclient_get_repeat              
(XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_get_random              
(XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_is_playing              
(XfmpcMpdclient *mpdclient);
+gboolean                xfmpc_mpdclient_is_paused               
(XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_is_stopped              
(XfmpcMpdclient *mpdclient);
 
 void                    xfmpc_mpdclient_update_status           
(XfmpcMpdclient *mpdclient);
diff --git a/src/mpdclient.vapi b/src/mpdclient.vapi
index c0f489d..d0c5ce0 100644
--- a/src/mpdclient.vapi
+++ b/src/mpdclient.vapi
@@ -26,6 +26,7 @@ namespace Xfmpc {
                public uchar get_volume ();
                public bool is_connected ();
                public bool is_playing ();
+               public bool is_paused ();
                public bool is_stopped ();
                public bool next ();
                public bool pause ();
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to