[Xfce4-commits] <xfmpc:master> Add a new mpdclient signal total_time_changed

Vincent Legout noreply at xfce.org
Tue Jan 4 21:30:01 CET 2011


Updating branch refs/heads/master
         to 72fb769f45eb7fffee6b19e10f433a09a53a7e5b (commit)
       from 0a615ceda5598df1ad8df7484f6d91ea463775e9 (commit)

commit 72fb769f45eb7fffee6b19e10f433a09a53a7e5b
Author: Vincent Legout <vincent at legout.info>
Date:   Tue Jan 4 20:37:09 2011 +0100

    Add a new mpdclient signal total_time_changed
    
    Also update the time_changed signal to deliver only the elapsed song time
    without the total song time.
    
    This should fix bug #6937.

 src/interface.vala |    9 +++++++--
 src/mpdclient.c    |   25 +++++++++++++++++++------
 src/mpdclient.vapi |    3 ++-
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/interface.vala b/src/interface.vala
index e7aca15..4eb4db6 100644
--- a/src/interface.vala
+++ b/src/interface.vala
@@ -123,6 +123,7 @@ namespace Xfmpc {
 			this.mpdclient.song_changed.connect (cb_song_changed);
 			this.mpdclient.pp_changed.connect (cb_pp_changed);
 			this.mpdclient.time_changed.connect (cb_time_changed);
+			this.mpdclient.total_time_changed.connect (cb_total_time_changed);
 			this.mpdclient.volume_changed.connect (cb_volume_changed);
 			this.mpdclient.playlist_changed.connect (cb_playlist_changed);
 			this.mpdclient.stopped.connect (cb_stopped);
@@ -240,8 +241,12 @@ namespace Xfmpc {
 			cb_song_changed ();
 		}
 
-		private void cb_time_changed (int time, int total_time) {
-			set_time (time, total_time);
+		private void cb_time_changed (int time) {
+			set_time (time, mpdclient.get_total_time());
+		}
+
+		private void cb_total_time_changed (int total_time) {
+			set_time (mpdclient.get_time(), total_time);
 		}
 
 		private void cb_volume_changed (int volume) {
diff --git a/src/mpdclient.c b/src/mpdclient.c
index b8dade8..1867541 100644
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
@@ -38,6 +38,7 @@ enum
   SIG_SONG_CHANGED,
   SIG_PP_CHANGED,
   SIG_TIME_CHANGED,
+  SIG_TOTAL_TIME_CHANGED,
   SIG_VOLUME_CHANGED,
   SIG_STOPPED,
   SIG_DATABASE_CHANGED,
@@ -77,7 +78,8 @@ struct _XfmpcMpdclientClass
   void (*connected)         (XfmpcMpdclient *mpdclient, gpointer user_data);
   void (*song_changed)      (XfmpcMpdclient *mpdclient, gpointer user_data);
   void (*pp_changed)        (XfmpcMpdclient *mpdclient, gboolean is_playing, gpointer user_data);
-  void (*time_changed)      (XfmpcMpdclient *mpdclient, gint time, gint total_time, gpointer user_data);
+  void (*time_changed)      (XfmpcMpdclient *mpdclient, gint time, gpointer user_data);
+  void (*total_time_changed)(XfmpcMpdclient *mpdclient, gint total_time, gpointer user_data);
   void (*volume_changed)    (XfmpcMpdclient *mpdclient, gint volume, gpointer user_data);
   void (*stopped)           (XfmpcMpdclient *mpdclient, gpointer user_data);
   void (*database_changed)  (XfmpcMpdclient *mpdclient, gpointer user_data);
@@ -183,9 +185,17 @@ xfmpc_mpdclient_class_init (XfmpcMpdclientClass *klass)
                   G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION,
                   G_STRUCT_OFFSET (XfmpcMpdclientClass, time_changed),
                   NULL, NULL,
-                  g_cclosure_marshal_VOID__UINT_POINTER,
-                  G_TYPE_NONE, 2,
-                  G_TYPE_INT,
+                  g_cclosure_marshal_VOID__INT,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_INT);
+
+  signals[SIG_TOTAL_TIME_CHANGED] =
+    g_signal_new ("total-time-changed", G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (XfmpcMpdclientClass, total_time_changed),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__INT,
+                  G_TYPE_NONE, 1,
                   G_TYPE_INT);
 
   signals[SIG_VOLUME_CHANGED] =
@@ -773,9 +783,12 @@ cb_status_changed (MpdObj *mi,
     g_signal_emit (mpdclient, signals[SIG_VOLUME_CHANGED], 0,
                    xfmpc_mpdclient_get_volume (mpdclient));
 
-  if (what & (MPD_CST_ELAPSED_TIME|MPD_CST_TOTAL_TIME))
+  if (what & MPD_CST_ELAPSED_TIME)
     g_signal_emit (mpdclient, signals[SIG_TIME_CHANGED], 0,
-                   xfmpc_mpdclient_get_time (mpdclient),
+                   xfmpc_mpdclient_get_time (mpdclient));
+
+  if (what & MPD_CST_TOTAL_TIME)
+    g_signal_emit (mpdclient, signals[SIG_TOTAL_TIME_CHANGED], 0,
                    xfmpc_mpdclient_get_total_time (mpdclient));
 
   if (what & MPD_CST_REPEAT)
diff --git a/src/mpdclient.vapi b/src/mpdclient.vapi
index 833775e..bae52ee 100644
--- a/src/mpdclient.vapi
+++ b/src/mpdclient.vapi
@@ -56,7 +56,8 @@ namespace Xfmpc {
 		public virtual signal void connected ();
 		public virtual signal void song_changed ();
 		public virtual signal void pp_changed (bool is_playing);
-		public virtual signal void time_changed (int time, int total_time);
+		public virtual signal void time_changed (int time);
+		public virtual signal void total_time_changed (int total_time);
 		public virtual signal void volume_changed (int volume);
 		public virtual signal void stopped ();
 		public virtual signal void database_changed ();



More information about the Xfce4-commits mailing list