[Xfce4-commits] <xfmpc:master> Add support for the consume and single modes

Vincent Legout noreply at xfce.org
Thu Feb 11 11:20:02 CET 2010


Updating branch refs/heads/master
         to 6e8b1c6793913da4466ac9f8d3fc94a3d1d69834 (commit)
       from f2a9658dbb61d49567f0de93e571b1c36bca5cbb (commit)

commit 6e8b1c6793913da4466ac9f8d3fc94a3d1d69834
Author: Vincent Legout <vincent at legout.info>
Date:   Thu Feb 11 17:40:31 2010 +0800

    Add support for the consume and single modes
    
    Add accessors to set or get the single and consume modes
    Add the "single" and "consume" signals to mpdclient
    Update the mpdclient vapi file

 src/mpdclient.c    |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/mpdclient.h    |    6 ++++
 src/mpdclient.vapi |    6 ++++
 3 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/src/mpdclient.c b/src/mpdclient.c
index 83fced2..b8dade8 100644
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
@@ -44,6 +44,8 @@ enum
   SIG_PLAYLIST_CHANGED,
   SIG_REPEAT,
   SIG_RANDOM,
+  SIG_SINGLE,
+  SIG_CONSUME,
   LAST_SIGNAL
 };
 
@@ -82,6 +84,8 @@ struct _XfmpcMpdclientClass
   void (*playlist_changed)  (XfmpcMpdclient *mpdclient, gpointer user_data);
   void (*repeat)            (XfmpcMpdclient *mpdclient, gboolean repeat, gpointer user_data);
   void (*random)            (XfmpcMpdclient *mpdclient, gboolean random, gpointer user_data);
+  void (*single)            (XfmpcMpdclient *mpdclient, gboolean single, gpointer user_data);
+  void (*consume)           (XfmpcMpdclient *mpdclient, gboolean consume, gpointer user_data);
 };
 
 struct _XfmpcMpdclient
@@ -234,6 +238,24 @@ xfmpc_mpdclient_class_init (XfmpcMpdclientClass *klass)
                   g_cclosure_marshal_VOID__BOOLEAN,
                   G_TYPE_NONE, 1,
                   G_TYPE_BOOLEAN);
+
+  signals[SIG_SINGLE] =
+    g_signal_new ("single", G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (XfmpcMpdclientClass, single),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__BOOLEAN,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_BOOLEAN);
+
+  signals[SIG_CONSUME] =
+    g_signal_new ("consume", G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (XfmpcMpdclientClass, consume),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__BOOLEAN,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_BOOLEAN);
 }
 
 static void
@@ -534,6 +556,30 @@ xfmpc_mpdclient_set_random (XfmpcMpdclient *mpdclient,
     return TRUE;
 }
 
+gboolean
+xfmpc_mpdclient_set_single (XfmpcMpdclient *mpdclient,
+                            gboolean single)
+{
+  XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
+
+  if (MPD_OK != mpd_player_set_single (priv->mi, single))
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_set_consume (XfmpcMpdclient *mpdclient,
+                             gboolean consume)
+{
+  XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
+
+  if (MPD_OK != mpd_player_set_consume (priv->mi, consume))
+    return FALSE;
+  else
+    return TRUE;
+}
+
 
 
 gint
@@ -653,6 +699,20 @@ xfmpc_mpdclient_get_random (XfmpcMpdclient *mpdclient)
 }
 
 gboolean
+xfmpc_mpdclient_get_single (XfmpcMpdclient *mpdclient)
+{
+  XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
+  return mpd_player_get_single (priv->mi);
+}
+
+gboolean
+xfmpc_mpdclient_get_consume (XfmpcMpdclient *mpdclient)
+{
+  XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
+  return mpd_player_get_consume (priv->mi);
+}
+
+gboolean
 xfmpc_mpdclient_is_playing (XfmpcMpdclient *mpdclient)
 {
   XfmpcMpdclientPrivate *priv = XFMPC_MPDCLIENT (mpdclient)->priv;
@@ -725,6 +785,14 @@ cb_status_changed (MpdObj *mi,
   if (what & MPD_CST_RANDOM)
     g_signal_emit (mpdclient, signals[SIG_RANDOM], 0,
                    xfmpc_mpdclient_get_random (mpdclient));
+
+  if (what & MPD_CST_SINGLE_MODE)
+    g_signal_emit (mpdclient, signals[SIG_SINGLE], 0,
+                   xfmpc_mpdclient_get_single (mpdclient));
+
+  if (what & MPD_CST_CONSUME_MODE)
+    g_signal_emit (mpdclient, signals[SIG_CONSUME], 0,
+                   xfmpc_mpdclient_get_consume (mpdclient));
 }
 
 
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 57a7f0c..e9449ce 100644
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
@@ -71,6 +71,10 @@ gboolean                xfmpc_mpdclient_set_repeat              (XfmpcMpdclient
                                                                  gboolean repeat);
 gboolean                xfmpc_mpdclient_set_random              (XfmpcMpdclient *mpdclient,
                                                                  gboolean random);
+gboolean                xfmpc_mpdclient_set_single              (XfmpcMpdclient *mpdclient,
+                                                                 gboolean single);
+gboolean                xfmpc_mpdclient_set_consume             (XfmpcMpdclient *mpdclient,
+                                                                 gboolean consume);
 
 gint                    xfmpc_mpdclient_get_pos                 (XfmpcMpdclient *mpdclient);
 gint                    xfmpc_mpdclient_get_id                  (XfmpcMpdclient *mpdclient);
@@ -83,6 +87,8 @@ gint                    xfmpc_mpdclient_get_total_time          (XfmpcMpdclient
 guint8                  xfmpc_mpdclient_get_volume              (XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_get_repeat              (XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_get_random              (XfmpcMpdclient *mpdclient);
+gboolean                xfmpc_mpdclient_get_single              (XfmpcMpdclient *mpdclient);
+gboolean                xfmpc_mpdclient_get_consume             (XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_is_playing              (XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_is_paused               (XfmpcMpdclient *mpdclient);
 gboolean                xfmpc_mpdclient_is_stopped              (XfmpcMpdclient *mpdclient);
diff --git a/src/mpdclient.vapi b/src/mpdclient.vapi
index 8081147..833775e 100644
--- a/src/mpdclient.vapi
+++ b/src/mpdclient.vapi
@@ -19,6 +19,8 @@ namespace Xfmpc {
 		public int get_pos ();
 		public bool get_random ();
 		public bool get_repeat ();
+		public bool get_single ();
+		public bool get_consume ();
 		public unowned Xfmpc.SongInfo get_song_info (int id);
 		public int get_time ();
 		public unowned string get_title ();
@@ -44,6 +46,8 @@ namespace Xfmpc {
 		public bool set_id (int id);
 		public bool set_random (bool random);
 		public bool set_repeat (bool repeat);
+		public bool set_single (bool single);
+		public bool set_consume (bool consume);
 		public bool set_song_time (uint time);
 		public bool set_volume (uchar volume);
 		public bool stop ();
@@ -59,6 +63,8 @@ namespace Xfmpc {
 		public virtual signal void playlist_changed ();
 		public virtual signal void repeat ();
 		public virtual signal void random ();
+		public virtual signal void single ();
+		public virtual signal void consume ();
 	}
 	[Compact]
 	[CCode (cheader_filename = "mpdclient.h")]



More information about the Xfce4-commits mailing list