[Goodies-commits] r3819 - in xfmpc/trunk: . po src

Mike Massonnet mmassonnet at xfce.org
Sat Jan 19 11:09:38 CET 2008


Author: mmassonnet
Date: 2008-01-19 10:09:38 +0000 (Sat, 19 Jan 2008)
New Revision: 3819

Added:
   xfmpc/trunk/.gitignore
   xfmpc/trunk/AUTHORS
   xfmpc/trunk/COPYING
   xfmpc/trunk/ChangeLog
   xfmpc/trunk/Makefile.am
   xfmpc/trunk/NEWS
   xfmpc/trunk/README
   xfmpc/trunk/THANKS
   xfmpc/trunk/autogen.sh
   xfmpc/trunk/configure.in.in
   xfmpc/trunk/po/
   xfmpc/trunk/po/ChangeLog
   xfmpc/trunk/po/LINGUAS
   xfmpc/trunk/po/POTFILES.in
   xfmpc/trunk/po/fr.po
   xfmpc/trunk/po/xfmpc.pot
   xfmpc/trunk/src/
   xfmpc/trunk/src/Makefile.am
   xfmpc/trunk/src/interface.c
   xfmpc/trunk/src/interface.h
   xfmpc/trunk/src/main.c
   xfmpc/trunk/src/mpdclient.c
   xfmpc/trunk/src/mpdclient.h
Log:
Merge /home/mike/devel/xfmpc


Added: xfmpc/trunk/.gitignore
===================================================================
--- xfmpc/trunk/.gitignore	                        (rev 0)
+++ xfmpc/trunk/.gitignore	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,22 @@
+INSTALL
+Makefile
+Makefile.in
+aclocal.m4
+compile
+config.*
+configure
+configure.in
+depcomp
+install-sh
+intltool-*
+missing
+mkinstalldirs
+stamp-h1
+autom4te.cache
+.deps
+*.swp
+*.o
+*.gmo
+po/Makefile.in.in
+po/POTFILES
+po/stamp-it

Added: xfmpc/trunk/AUTHORS
===================================================================
--- xfmpc/trunk/AUTHORS	                        (rev 0)
+++ xfmpc/trunk/AUTHORS	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1 @@
+Mike Massonnet <mmassonnet at xfce.org>

Added: xfmpc/trunk/COPYING
===================================================================
--- xfmpc/trunk/COPYING	                        (rev 0)
+++ xfmpc/trunk/COPYING	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,23 @@
+ Copyright (c) 2003 Eduard Roccatello <eduard at xfce.org>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Added: xfmpc/trunk/ChangeLog
===================================================================
--- xfmpc/trunk/ChangeLog	                        (rev 0)
+++ xfmpc/trunk/ChangeLog	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,88 @@
+2008-01-19	Mike Massonnet <mmassonnet at xfce.org>
+
+	* AUTHORS, ChangeLog, README, po/ChangeLog:
+	  - Update text files
+
+2008-01-19	Mike Massonnet <mmassonnet at xfce.org>
+
+	* src/interface.c, src/interface.h:
+	  - Set xfmpc_interface_refresh static
+	  - Add static xfmpc_interface_reconnect
+	* src/interface.c(xfmpc_interface_init),
+	  src/interface.c(xfmpc_interface_refresh),
+	  src/mpdclient.c(xfmpc_mpdclient_is_stopped):
+	  - Add messages for stopped and disconnected state
+
+2008-01-18	Mike Massonnet <mmassonnet at xfce.org>
+
+	* src/interface.c:
+	  - Merge xfmpc_interface_set_fraction inside xfmpc_interface_set_time
+
+2008-01-18	Mike Massonnet <mmassonnet at xfce.org>
+
+	* configure.in.in: Bump GTK+ version to 2.12
+	* src/interface.h, src/interface.c:
+	  - Remove xfmpc_interface_volume_scroll_event
+	  - Add xfmpc_interface_volume_changed
+	* src/interface.c(interface_init):
+	  - Insert a GtkVolumeButton as a replacement for the volume button and connect
+	  signal "value-changed" to xfmpc_interface_volume_changed
+	* src/interface.c(xfmpc_interface_set_volume),
+	  src/interface.c(xfmpc_interface_refresh_volume):
+	  - Update code to fit with the GtkVolumeButton
+	* src/interface.c(xfmpc_interface_set_fraction):
+	  - Check value to be between 0 and 1
+
+2008-01-17	Mike Massonnet <mmassonnet at xfce.org>
+
+	* src/interface.c(xfmpc_interface_init):
+	  - Connect signal on progress bar (inside event box) to seek in the track
+	* src/interface.h, src/interface.c:
+	  - New callback xfmpc_interface_progress_box_press_event
+	* src/mpdclient.h, src/mpdclient.c:
+	  - Rename xfmpc_mpdclient_set_track_position to xfmpc_mpdclient_set_song_time
+	  and complete the function
+
+2008-01-17	Mike Massonnet <mmassonnet at xfce.org>
+
+	* THANKS:
+	  - Update stuff
+	* src/Makefile.am:
+	  - Move lines out from foobar_CFLAGS inside INCLUDES
+	  - Add libxfce4util for debug macros
+	* configure.in.in, src/Makefile.am:
+	  - Add libmpd
+	* src/mpdclient.c, src/mpdclient.h:
+	  - New files
+	  - Interface with libmpd
+	* interface.c, interface.h:
+	  - Add an XfmpcMpdclient inside private structure
+	  - Connect signals + write callbacks for control buttons
+	  - Add timeout to refresh the info on the interface
+
+2008-01-16	Mike Massonnet <mmassonnet at xfce.org>
+
+	* src/interface.c, src/interface.h:
+	  - Refine the interface and add several _set methods.
+
+2008-01-15	Mike Massonnet <mmassonnet at xfce.org>
+
+	* src/Makefile.am, src/interface.c, src/main.c:
+	  - Code is runnable and compilable.
+	  - The first interface is done.
+
+2008-01-15	Mike Massonnet <mmassonnet at xfce.org>
+
+	* Makefile.am, configure.in.in, po/POTFILES.in, po/fr.po, po/xfmpc.pot:
+	  - Fix compilation for po files
+	  - Add initial pot template
+	  - Add french translation
+
+2008-01-15	Mike Massonnet <mmassonnet at xfce.org>
+
+	* src/*: Initial code
+
+2008-01-14	Mike Massonnet <mmassonnet at xfce.org>
+
+	* */*: Initial source directory
+

Added: xfmpc/trunk/Makefile.am
===================================================================
--- xfmpc/trunk/Makefile.am	                        (rev 0)
+++ xfmpc/trunk/Makefile.am	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,29 @@
+SUBDIRS =								\
+	src								\
+	po
+
+distclean-local:
+	rm -rf *.spec *.cache *~
+
+rpm: dist
+	rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
+	@rm -f $(PACKAGE)-$(VERSION).tar.gz
+
+EXTRA_DIST =								\
+	AUTHORS								\
+	ChangeLog							\
+	COPYING								\
+	INSTALL								\
+	NEWS								\
+	README								\
+	THANKS								\
+	intltool-extract.in						\
+	intltool-merge.in						\
+	intltool-update.in
+
+DISTCLEANFILES =							\
+	intltool-extract						\
+	intltool-merge							\
+	intltool-update
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:

Added: xfmpc/trunk/NEWS
===================================================================
--- xfmpc/trunk/NEWS	                        (rev 0)
+++ xfmpc/trunk/NEWS	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,2 @@
+
+

Added: xfmpc/trunk/README
===================================================================
--- xfmpc/trunk/README	                        (rev 0)
+++ xfmpc/trunk/README	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,40 @@
+ Xfmpc
+=======
+
+A graphical GTK+ MPD client focusing on low footprint.
+
+
+ Homepage
+----------
+
+http://goodies.xfce.org/projects/applications/xfmpc
+
+
+ Dependencies
+--------------
+
+* libgtk+2 2.12
+* libxfcegui4 4.4.0
+
+
+ Install
+---------
+
+% tar xf xfmpc-<version>.tar.bz2
+% ./configure
+% make
+% make install
+
+See the INSTALL file for more instructions.
+
+
+ Report bugs
+-------------
+You can report bugs and feature requests on http://bugzilla.xfce.org/.
+Select the product “Xfce Goodies” and the component “xfmpc”.
+
+Feature requests are always welcome.
+
+You can also join the Xfce Goodies mailing-list:
+http://foo-projects.org/mailman/listinfo/goodies-dev.
+

Added: xfmpc/trunk/THANKS
===================================================================
--- xfmpc/trunk/THANKS	                        (rev 0)
+++ xfmpc/trunk/THANKS	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,3 @@
+Gimmix for the code and the inspiration.
+Sonata for the effort into a clean interface.
+Ristretto and Xfce4 Mixer for the GObject inspiration.

Added: xfmpc/trunk/autogen.sh
===================================================================
--- xfmpc/trunk/autogen.sh	                        (rev 0)
+++ xfmpc/trunk/autogen.sh	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# $Id$
+#
+# Copyright (c) 2002-2006
+#         The Thunar development team. All rights reserved.
+#
+# Written for Thunar by Benedikt Meurer <benny at xfce.org>.
+#
+
+(type xdt-autogen) >/dev/null 2>&1 || {
+  cat >&2 <<EOF
+autogen.sh: You don't seem to have the Xfce development tools installed on
+            your system, which are required to build this software.
+            Please install the xfce4-dev-tools package first, it is available
+            from http://www.xfce.org/.
+EOF
+  exit 1
+}
+
+# verify that po/LINGUAS is present
+(test -f po/LINGUAS) >/dev/null 2>&1 || {
+  cat >&2 <<EOF
+autogen.sh: The file po/LINGUAS could not be found. Please check your snapshot
+            or try to checkout again.
+EOF
+  exit 1
+}
+
+# substitute revision and linguas
+linguas=`sed -e '/^#/d' po/LINGUAS`
+revision=`LC_ALL=C svn info $0 | awk '/^Revision: / {printf "%04d\n", $2}'`
+sed -e "s/@LINGUAS@/${linguas}/g" \
+    -e "s/@REVISION@/${revision}/g" \
+    < "configure.in.in" > "configure.in"
+
+exec xdt-autogen $@


Property changes on: xfmpc/trunk/autogen.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: xfmpc/trunk/configure.in.in
===================================================================
--- xfmpc/trunk/configure.in.in	                        (rev 0)
+++ xfmpc/trunk/configure.in.in	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,86 @@
+dnl $Id$
+dnl
+dnl xfmpc - A graphical GTK+ MPD client focusing on low footprint
+dnl
+dnl 2008      Mike Massonnet <mmassonnet at xfce.org>
+dnl
+
+dnl ***************************
+dnl *** Version information ***
+dnl ***************************
+m4_define([xfmpc_version_major], [0])
+m4_define([xfmpc_version_minor], [0])
+m4_define([xfmpc_version_micro], [1])
+m4_define([xfmpc_version_build], [r at REVISION@])
+m4_define([xfmpc_version_tag], [svn]) # leave empty for release
+m4_define([xfmpc_version], [xfmpc_version_major().xfmpc_version_minor().xfmpc_version_micro()ifelse(xfmpc_version_tag(), [svn], [xfmpc_version_tag()-xfmpc_version_build()], [xfmpc_version_tag()])])
+
+dnl ***************************
+dnl *** Initialize autoconf ***
+dnl ***************************
+AC_COPYRIGHT([Copyright (c) 2008
+        The Xfce development team. All rights reserved.])
+AC_INIT([xfmpc], [xfmpc_version], [http://bugzilla.xfce.org/], [xfmpc])
+AC_PREREQ([2.50])
+AC_CANONICAL_TARGET()
+AC_REVISION([$Id$])
+
+dnl ***************************
+dnl *** Initialize automake ***
+dnl ***************************
+AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
+AM_CONFIG_HEADER([config.h])
+AM_MAINTAINER_MODE()
+
+dnl ********************************
+dnl *** Check for basic programs ***
+dnl ********************************
+AC_PROG_CC()
+AC_PROG_LD()
+AC_PROG_INSTALL()
+AC_PROG_INTLTOOL()
+
+dnl **********************************
+dnl *** Check for standard headers ***
+dnl **********************************
+AC_HEADER_STDC()
+
+dnl 
+dnl *******************************
+dnl *** Check for X11 installed ***
+dnl *******************************
+XDT_CHECK_LIBX11_REQUIRE()
+
+dnl ******************************
+dnl *** Check for i18n support ***
+dnl ******************************
+XDT_I18N([@LINGUAS@])
+
+dnl ***********************************
+dnl *** Check for required packages ***
+dnl ***********************************
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.12.0])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([LIBMPD], [libmpd], [0.15.0])
+
+dnl ***********************************
+dnl *** Check for debugging support ***
+dnl ***********************************
+XDT_FEATURE_DEBUG()
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+po/Makefile.in
+])
+
+dnl ***************************
+dnl *** Print configuration ***
+dnl ***************************
+echo
+echo "Build Configuration:"
+echo
+echo "* Debug Support:    $enable_debug"
+echo
+

Added: xfmpc/trunk/po/ChangeLog
===================================================================
--- xfmpc/trunk/po/ChangeLog	                        (rev 0)
+++ xfmpc/trunk/po/ChangeLog	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,10 @@
+2008-01-19	Mike Massonnet <mmassonnet at xfce.org>
+
+	* *.po, *.pot: make update-po
+	* fr.po: Update French translations
+
+2008-01-15	Mike Massonnet <mmassonnet at xfce.org>
+
+	* xfmpc.pot: Merge strings.
+	* fr.po: Update French translations
+

Added: xfmpc/trunk/po/LINGUAS
===================================================================
--- xfmpc/trunk/po/LINGUAS	                        (rev 0)
+++ xfmpc/trunk/po/LINGUAS	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,2 @@
+# set of available languages (in alphabetic order)
+fr

Added: xfmpc/trunk/po/POTFILES.in
===================================================================
--- xfmpc/trunk/po/POTFILES.in	                        (rev 0)
+++ xfmpc/trunk/po/POTFILES.in	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,2 @@
+src/main.c
+src/interface.c

Added: xfmpc/trunk/po/fr.po
===================================================================
--- xfmpc/trunk/po/fr.po	                        (rev 0)
+++ xfmpc/trunk/po/fr.po	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,37 @@
+# French translations for xfmpc package
+# Traductions françaises du paquet xfmpc.
+# Copyright (C) 2008 THE xfmpc'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the xfmpc package.
+# Mike Massonnet <mmassonnet at gmail.com>, 2008.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: xfmpc 0.0.1svn-r\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-01-19 10:03+0100\n"
+"PO-Revision-Date: 2008-01-15 18:44+0100\n"
+"Last-Translator: Mike Massonnet <mmassonnet at gmail.com>\n"
+"Language-Team: French\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: ../src/interface.c:123
+msgid "Xfmpc"
+msgstr ""
+
+#. override the volume changed signal
+#: ../src/interface.c:168 ../src/interface.c:354
+msgid "Not connected"
+msgstr "Déconnecté"
+
+#: ../src/interface.c:365
+msgid "Stopped"
+msgstr "Stoppé"
+
+#. subtitle
+#: ../src/interface.c:389
+#, c-format
+msgid "by \"%s\" from \"%s\" (%s)"
+msgstr "par « %s » de « %s » (%s)"

Added: xfmpc/trunk/po/xfmpc.pot
===================================================================
--- xfmpc/trunk/po/xfmpc.pot	                        (rev 0)
+++ xfmpc/trunk/po/xfmpc.pot	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,36 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-01-19 10:03+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/interface.c:123
+msgid "Xfmpc"
+msgstr ""
+
+#. override the volume changed signal
+#: ../src/interface.c:168 ../src/interface.c:354
+msgid "Not connected"
+msgstr ""
+
+#: ../src/interface.c:365
+msgid "Stopped"
+msgstr ""
+
+#. subtitle
+#: ../src/interface.c:389
+#, c-format
+msgid "by \"%s\" from \"%s\" (%s)"
+msgstr ""

Added: xfmpc/trunk/src/Makefile.am
===================================================================
--- xfmpc/trunk/src/Makefile.am	                        (rev 0)
+++ xfmpc/trunk/src/Makefile.am	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,28 @@
+bin_PROGRAMS = xfmpc
+
+xfmpc_SOURCES =								\
+	main.c								\
+	interface.c							\
+	interface.h							\
+	mpdclient.c							\
+	mpdclient.h
+
+xfmpc_CFLAGS =								\
+	@GTK_CFLAGS@							\
+	@LIBXFCEGUI4_CFLAGS@						\
+	@LIBXFCE4UTIL_CFLAGS@						\
+	@LIBMPD_CFLAGS@							\
+	-DDATADIR=\"$(datadir)\"					\
+	-DSRCDIR=\"$(top_srcdir)\"
+
+xfmpc_LDADD =								\
+	@GTK_LIBS@							\
+	@LIBXFCEGUI4_LIBS@						\
+	@LIBXFCE4UTIL_LIBS@						\
+	@LIBMPD_LIBS@
+
+INCLUDES =								\
+	-I${top_srcdir}							\
+	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
+	-DLOCALEDIR=\"$(localedir)\"
+

Added: xfmpc/trunk/src/interface.c
===================================================================
--- xfmpc/trunk/src/interface.c	                        (rev 0)
+++ xfmpc/trunk/src/interface.c	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,414 @@
+/*
+ *  Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4util/libxfce4util.h>
+
+#include "interface.h"
+#include "mpdclient.h"
+
+#define BORDER 4
+
+
+
+static void             xfmpc_interface_class_init              (XfmpcInterfaceClass *klass);
+static void             xfmpc_interface_init                    (XfmpcInterface *interface);
+static void             xfmpc_interface_dispose                 (GObject *object);
+
+static gboolean         xfmpc_interface_refresh                 (XfmpcInterface *interface);
+
+static gboolean         xfmpc_interface_reconnect               (XfmpcInterface *interface);
+
+
+
+struct _XfmpcInterfaceClass
+{
+  GtkWindowClass        parent_class;
+};
+
+struct _XfmpcInterface
+{
+  GtkWindow             parent;
+  XfmpcInterfacePriv   *priv;
+};
+
+struct _XfmpcInterfacePriv
+{
+  XfmpcMpdclient       *mpdclient;
+  GtkWidget            *button_prev;
+  GtkWidget            *button_pp; /* play/pause */
+  GtkWidget            *button_next;
+  GtkWidget            *button_volume;
+  GtkWidget            *progress_bar; /* position in song */
+  GtkWidget            *title;
+  GtkWidget            *subtitle;
+
+  gint                  volume;
+};
+
+
+
+static GObjectClass *parent_class = NULL;
+
+
+
+GType
+xfmpc_interface_get_type ()
+{
+  static GType xfmpc_interface_type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (xfmpc_interface_type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo xfmpc_interface_info =
+        {
+          sizeof (XfmpcInterfaceClass),
+          (GBaseInitFunc) NULL,
+          (GBaseFinalizeFunc) NULL,
+          (GClassInitFunc) xfmpc_interface_class_init,
+          (GClassFinalizeFunc) NULL,
+          NULL,
+          sizeof (XfmpcInterface),
+          0,
+          (GInstanceInitFunc) xfmpc_interface_init,
+          NULL
+        };
+      xfmpc_interface_type = g_type_register_static (GTK_TYPE_WINDOW, "XfmpcInterface", &xfmpc_interface_info, 0);
+    }
+
+  return xfmpc_interface_type;
+}
+
+
+
+static void
+xfmpc_interface_class_init (XfmpcInterfaceClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->dispose = xfmpc_interface_dispose;
+}
+
+static void
+xfmpc_interface_init (XfmpcInterface *interface)
+{
+  interface->priv = g_slice_new0 (XfmpcInterfacePriv);
+  interface->priv->mpdclient = xfmpc_mpdclient_new ();
+  interface->priv->volume = -1;
+
+  /* === Window === */
+  gtk_window_set_icon_name (GTK_WINDOW (interface), "stock_volume");
+  gtk_window_set_title (GTK_WINDOW (interface), _("Xfmpc"));
+  gtk_container_set_border_width (GTK_CONTAINER (interface), BORDER);
+  g_signal_connect (G_OBJECT (interface), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
+
+  /* === Accel group === */
+  GtkAccelGroup *accel_group = gtk_accel_group_new();
+  gtk_window_add_accel_group (GTK_WINDOW (interface), accel_group);
+
+  /* === Interface widgets === */
+  GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_BUTTON);
+  GtkWidget *control = interface->priv->button_prev = gtk_button_new ();
+  gtk_button_set_relief (GTK_BUTTON (control), GTK_RELIEF_NONE);
+  gtk_container_add (GTK_CONTAINER (control), image);
+
+  image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
+  control = interface->priv->button_pp = gtk_button_new ();
+  gtk_button_set_relief (GTK_BUTTON (control), GTK_RELIEF_NONE);
+  gtk_container_add (GTK_CONTAINER (control), image);
+
+  image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_NEXT, GTK_ICON_SIZE_BUTTON);
+  control = interface->priv->button_next = gtk_button_new ();
+  gtk_button_set_relief (GTK_BUTTON (control), GTK_RELIEF_NONE);
+  gtk_container_add (GTK_CONTAINER (control), image);
+
+  control = interface->priv->button_volume = gtk_volume_button_new ();
+  gtk_button_set_relief (GTK_BUTTON (control), GTK_RELIEF_NONE);
+
+  GtkWidget *progress_box = gtk_event_box_new ();
+  control = interface->priv->progress_bar = gtk_progress_bar_new ();
+  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (control), "0:00 / 0:00");
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (control), 1.0);
+  gtk_container_add (GTK_CONTAINER (progress_box), control);
+
+  /* Title */
+  PangoAttrList* attrs = pango_attr_list_new ();
+  PangoAttribute* attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+  attr->start_index = 0;
+  attr->end_index = -1;
+  pango_attr_list_insert (attrs, attr);
+
+  attr = pango_attr_scale_new (PANGO_SCALE_X_LARGE);
+  attr->start_index = 0;
+  attr->end_index = -1;
+  pango_attr_list_insert (attrs, attr);
+
+  GtkWidget *label = interface->priv->title = gtk_label_new (_("Not connected"));
+  gtk_label_set_attributes (GTK_LABEL (label), attrs);
+  gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+  /* Subtitle */
+  attrs = pango_attr_list_new ();
+  attr = pango_attr_scale_new (PANGO_SCALE_SMALL);
+  attr->start_index = 0;
+  attr->end_index = -1;
+  pango_attr_list_insert (attrs, attr);
+
+  label = interface->priv->subtitle = gtk_label_new (PACKAGE_STRING);
+  gtk_label_set_attributes (GTK_LABEL (label), attrs);
+  gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+  /* === Containers === */
+  GtkWidget *vbox = gtk_vbox_new (FALSE, BORDER);
+  gtk_container_add (GTK_CONTAINER (interface), vbox);
+
+  GtkWidget *box = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (box), interface->priv->button_prev, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (box), interface->priv->button_pp, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (box), interface->priv->button_next, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (box), progress_box, TRUE, TRUE, BORDER);
+  gtk_box_pack_start (GTK_BOX (box), interface->priv->button_volume, FALSE, FALSE, 0);
+
+  box = gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (box), interface->priv->title);
+  gtk_container_add (GTK_CONTAINER (box), interface->priv->subtitle);
+
+  /* === Signals === */
+  g_signal_connect_swapped (interface->priv->button_prev, "clicked",
+                            G_CALLBACK (xfmpc_mpdclient_previous), interface->priv->mpdclient);
+  g_signal_connect_swapped (interface->priv->button_pp, "clicked",
+                            G_CALLBACK (xfmpc_interface_pp_clicked), interface);
+  g_signal_connect_swapped (interface->priv->button_next, "clicked",
+                            G_CALLBACK (xfmpc_mpdclient_next), interface->priv->mpdclient);
+  g_signal_connect_swapped (interface->priv->button_volume, "value-changed",
+                            G_CALLBACK (xfmpc_interface_volume_changed), interface);
+  g_signal_connect_swapped (progress_box, "button-press-event",
+                            G_CALLBACK (xfmpc_interface_progress_box_press_event), interface);
+
+  /* === Timeout === */
+  g_timeout_add (1000, (GSourceFunc)xfmpc_interface_refresh, interface);
+}
+
+static void
+xfmpc_interface_dispose (GObject *object)
+{
+  (*G_OBJECT_CLASS (parent_class)->dispose) (object);
+}
+
+GtkWidget*
+xfmpc_interface_new ()
+{
+  return g_object_new (XFMPC_TYPE_INTERFACE, NULL);
+}
+
+void
+xfmpc_interface_set_title (XfmpcInterface *interface,
+                           const gchar *title)
+{
+  gtk_label_set_text (GTK_LABEL (interface->priv->title), title);
+}
+
+void
+xfmpc_interface_set_subtitle (XfmpcInterface *interface,
+                              const gchar *subtitle)
+{
+  gtk_label_set_text (GTK_LABEL (interface->priv->subtitle), subtitle);
+}
+
+void
+xfmpc_interface_pp_clicked (XfmpcInterface *interface)
+{
+  XfmpcMpdclient *mpdclient = interface->priv->mpdclient;
+  if (G_UNLIKELY (!xfmpc_mpdclient_pp (mpdclient)))
+    return;
+  xfmpc_interface_set_pp (interface, xfmpc_mpdclient_is_playing (mpdclient));
+}
+
+void
+xfmpc_interface_set_pp (XfmpcInterface *interface,
+                        gboolean play)
+{
+  GtkWidget *image = gtk_bin_get_child (GTK_BIN (interface->priv->button_pp));
+
+  if (play == TRUE)
+    gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON);
+  else
+    gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
+}
+
+gboolean
+xfmpc_interface_progress_box_press_event (XfmpcInterface *interface,
+                                          GdkEventButton *event)
+{
+  if (G_UNLIKELY (event->type != GDK_BUTTON_PRESS && event->button != 1))
+    return FALSE;
+
+  XfmpcMpdclient *mpdclient = interface->priv->mpdclient;
+  gint time_total = xfmpc_mpdclient_get_total_time (mpdclient);
+  if (G_UNLIKELY (time_total < 0))
+    return FALSE;
+
+  gdouble time = event->x / interface->priv->progress_bar->allocation.width;
+  time *= time_total;
+
+  xfmpc_mpdclient_set_song_time (mpdclient, (guint)time);
+
+  return TRUE;
+}
+
+void
+xfmpc_interface_volume_changed (XfmpcInterface *interface,
+                                gdouble value)
+{
+  interface->priv->volume = value * 100;
+}
+
+void
+xfmpc_interface_set_volume (XfmpcInterface *interface,
+                            guint8 volume)
+{
+  gtk_scale_button_set_value (GTK_SCALE_BUTTON (interface->priv->button_volume), (gdouble)volume / 100);
+}
+
+void
+xfmpc_interface_refresh_volume (XfmpcInterface *interface)
+{
+  XfmpcMpdclient *mpdclient = interface->priv->mpdclient;
+
+  if (G_UNLIKELY (interface->priv->volume != -1))
+    {
+      xfmpc_mpdclient_set_volume (mpdclient, interface->priv->volume);
+      interface->priv->volume = -1;
+    }
+
+  xfmpc_interface_set_volume (interface, xfmpc_mpdclient_get_volume (mpdclient));
+}
+
+void
+xfmpc_interface_set_time (XfmpcInterface *interface,
+                          gint time,
+                          gint time_total)
+{
+  gint                  min, sec, min_total, sec_total;
+  gchar                *text;
+  gdouble               fraction = 1.0;
+
+  min = time / 60;
+  sec = time - (min * 60);
+
+  min_total = time_total / 60;
+  sec_total = time_total - (min_total * 60);
+
+  text = g_strdup_printf ("%d:%02d / %d:%02d", min, sec, min_total, sec_total);
+  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (interface->priv->progress_bar), text);
+  g_free (text);
+
+  if (G_LIKELY (time_total > 0))
+    fraction = (gfloat)time / (gfloat)time_total;
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (interface->priv->progress_bar), fraction);
+}
+
+static gboolean
+xfmpc_interface_refresh (XfmpcInterface *interface)
+{
+  XfmpcMpdclient       *mpdclient = interface->priv->mpdclient;
+  gchar                *text = NULL;
+
+  TRACE ("ping");
+  if (G_UNLIKELY (xfmpc_mpdclient_connect (mpdclient) == FALSE))
+    {
+      DBG ("Couldn't connect to host %s port %d", mpdclient->host, mpdclient->port);
+      xfmpc_mpdclient_disconnect (mpdclient);
+      xfmpc_interface_set_pp (interface, FALSE);
+      xfmpc_interface_set_time (interface, 0, 0);
+      xfmpc_interface_set_volume (interface, 0);
+      interface->priv->volume = -1; /* override the volume changed signal */
+      xfmpc_interface_set_title (interface, _("Not connected"));
+      xfmpc_interface_set_subtitle (interface, PACKAGE_STRING);
+      /* Return FALSE to kill the refresh timeout and start a reconnection timeout */
+      g_timeout_add (15000, (GSourceFunc)xfmpc_interface_reconnect, interface);
+      return FALSE;
+    }
+  else if (G_UNLIKELY (xfmpc_mpdclient_is_stopped (mpdclient) == TRUE))
+    {
+      xfmpc_interface_set_pp (interface, FALSE);
+      xfmpc_interface_set_time (interface, 0, 0);
+      xfmpc_interface_refresh_volume (interface);
+      xfmpc_interface_set_title (interface, _("Stopped"));
+      xfmpc_interface_set_subtitle (interface, PACKAGE_STRING);
+
+      /* Some hack to invalidate the state.  Hint: FIXME */
+      xfmpc_mpdclient_disconnect (mpdclient);
+
+      return TRUE;
+    }
+
+  /* play/pause */
+  xfmpc_interface_set_pp (interface, xfmpc_mpdclient_is_playing (mpdclient));
+
+  /* song time */
+  xfmpc_interface_set_time (interface,
+                            xfmpc_mpdclient_get_time (mpdclient),
+                            xfmpc_mpdclient_get_total_time (mpdclient));
+
+  /* volume */
+  xfmpc_interface_refresh_volume (interface);
+
+  /* title */
+  xfmpc_interface_set_title (interface, xfmpc_mpdclient_get_title (mpdclient));
+
+  /* subtitle */
+  text = g_strdup_printf (_("by \"%s\" from \"%s\" (%s)"),
+                          xfmpc_mpdclient_get_artist (mpdclient),
+                          xfmpc_mpdclient_get_album (mpdclient),
+                          xfmpc_mpdclient_get_date (mpdclient));
+  /* text = xfmpc_interface_get_subtitle (interface); to avoid "n/a" values */
+  xfmpc_interface_set_subtitle (interface, text);
+  g_free (text);
+
+  /* Some hack to invalidate the cached state.  Hint: FIXME */
+  xfmpc_mpdclient_disconnect (mpdclient);
+
+  return TRUE;
+}
+
+static gboolean
+xfmpc_interface_reconnect (XfmpcInterface *interface)
+{
+  TRACE ("pong");
+  if (G_UNLIKELY (xfmpc_mpdclient_connect (interface->priv->mpdclient) == FALSE))
+    return TRUE;
+
+  /* Return FALSE to kill the reconnection timeout and start a refresh timeout */
+  g_timeout_add (1000, (GSourceFunc)xfmpc_interface_refresh, interface);
+  return FALSE;
+}
+

Added: xfmpc/trunk/src/interface.h
===================================================================
--- xfmpc/trunk/src/interface.h	                        (rev 0)
+++ xfmpc/trunk/src/interface.h	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,66 @@
+/*
+ *  Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XFMPC_INTERFACE_H__
+#define __XFMPC_INTERFACE_H__
+
+G_BEGIN_DECLS
+
+#define XFMPC_TYPE_INTERFACE            (xfmpc_interface_get_type())
+
+#define XFMPC_INTERFACE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFMPC_TYPE_INTERFACE, XfmpcInterface))
+#define XFMPC_INTERFACE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), XFMPC_TYPE_INTERFACE, XfmpcInterfaceClass))
+
+#define XFMPC_IS_INTERFACE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFMPC_TYPE_INTERFACE))
+#define XFMPC_IS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFMPC_TYPE_INTERFACE))
+
+#define XFMPC_INTERFACE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), XFMPC_TYPE_INTERFACE, XfmpcInterfaceClass))
+
+typedef struct _XfmpcInterfaceClass     XfmpcInterfaceClass;
+typedef struct _XfmpcInterface          XfmpcInterface;
+typedef struct _XfmpcInterfacePriv      XfmpcInterfacePriv;
+
+GType                   xfmpc_interface_get_type                () G_GNUC_CONST;
+
+
+
+GtkWidget *             xfmpc_interface_new                     ();
+
+void                    xfmpc_interface_set_title               (XfmpcInterface *interface,
+                                                                 const gchar *title);
+void                    xfmpc_interface_set_subtitle            (XfmpcInterface *interface,
+                                                                 const gchar *subtitle);
+void                    xfmpc_interface_pp_clicked              (XfmpcInterface *interface);
+
+void                    xfmpc_interface_set_pp                  (XfmpcInterface *interface,
+                                                                 gboolean play);
+gboolean                xfmpc_interface_progress_box_press_event (XfmpcInterface *interface,
+                                                                 GdkEventButton *event);
+void                    xfmpc_interface_volume_changed          (XfmpcInterface *interface,
+                                                                 gdouble value);
+void                    xfmpc_interface_set_volume              (XfmpcInterface *interface,
+                                                                 guint8 volume);
+void                    xfmpc_interface_refresh_volume          (XfmpcInterface *interface);
+
+void                    xfmpc_interface_set_time                (XfmpcInterface *interface,
+                                                                 gint time,
+                                                                 gint time_total);
+G_END_DECLS
+
+#endif
+

Added: xfmpc/trunk/src/main.c
===================================================================
--- xfmpc/trunk/src/main.c	                        (rev 0)
+++ xfmpc/trunk/src/main.c	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4util/libxfce4util.h>
+
+#include "interface.h"
+
+int
+main (int argc, char *argv[])
+{
+  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+  gtk_init (&argc, &argv);
+
+  gtk_window_set_default_icon_name ("xfmpc");
+
+  GtkWidget *interface = xfmpc_interface_new ();
+
+  gtk_widget_show_all (interface);
+
+  gtk_main ();
+
+  return 0;
+}
+

Added: xfmpc/trunk/src/mpdclient.c
===================================================================
--- xfmpc/trunk/src/mpdclient.c	                        (rev 0)
+++ xfmpc/trunk/src/mpdclient.c	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,264 @@
+/*
+ *  Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libxfce4util/libxfce4util.h>
+#include <libmpd/libmpd.h>
+
+#include "mpdclient.h"
+
+#define MPD_HOST "localhost"
+#define MPD_PORT 6600
+
+
+
+XfmpcMpdclient *
+xfmpc_mpdclient_new ()
+{
+  XfmpcMpdclient *mpdclient = g_slice_new0 (XfmpcMpdclient);
+  xfmpc_mpdclient_initenv (mpdclient);
+  mpdclient->mi = mpd_new (mpdclient->host, mpdclient->port, mpdclient->passwd);
+
+  return mpdclient;
+}
+
+void
+xfmpc_mpdclient_initenv (XfmpcMpdclient *mpdclient)
+{
+  /* Hostname */
+  mpdclient->host = (g_getenv ("MPD_HOST") != NULL) ?
+      g_strdup (g_getenv ("MPD_HOST")) :
+      g_strdup (MPD_HOST);
+
+  /* Port */
+  mpdclient->port = (g_getenv ("MPD_PORT") != NULL) ?
+      (gint) g_ascii_strtoll (g_getenv ("MPD_PORT"), NULL, 0) :
+      MPD_PORT;
+
+  /* Check for password */
+  mpdclient->passwd = NULL;
+  gchar **split = g_strsplit (mpdclient->host, "@", 2);
+  if (g_strv_length (split) == 2)
+    {
+      g_free (mpdclient->host);
+      mpdclient->host = g_strdup (split[0]);
+      mpdclient->passwd = g_strdup (split[1]);
+    }
+  g_strfreev (split);
+}
+
+gboolean
+xfmpc_mpdclient_connect (XfmpcMpdclient *mpdclient)
+{
+  if (xfmpc_mpdclient_is_connected (mpdclient))
+    return TRUE;
+
+  if (mpd_connect (mpdclient->mi) != MPD_OK)
+    return FALSE;
+
+  return TRUE;
+}
+
+void
+xfmpc_mpdclient_disconnect (XfmpcMpdclient *mpdclient)
+{
+  if (xfmpc_mpdclient_is_connected (mpdclient))
+    mpd_disconnect (mpdclient->mi);
+}
+
+gboolean
+xfmpc_mpdclient_is_connected (XfmpcMpdclient *mpdclient)
+{
+  return mpd_check_connected (mpdclient->mi);
+}
+
+void
+xfmpc_mpdclient_free (XfmpcMpdclient *mpdclient)
+{
+  mpd_free (mpdclient->mi);
+}
+
+gboolean
+xfmpc_mpdclient_previous (XfmpcMpdclient *mpdclient)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  if (mpd_player_prev (mpdclient->mi) != MPD_OK)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_pp (XfmpcMpdclient *mpdclient)
+{
+  if (xfmpc_mpdclient_is_playing (mpdclient))
+    return xfmpc_mpdclient_pause (mpdclient);
+  else
+    return xfmpc_mpdclient_play (mpdclient);
+}
+
+gboolean
+xfmpc_mpdclient_play (XfmpcMpdclient *mpdclient)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  if (mpd_player_play (mpdclient->mi) != MPD_OK)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_pause (XfmpcMpdclient *mpdclient)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  if (mpd_player_pause (mpdclient->mi) != MPD_OK)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_stop (XfmpcMpdclient *mpdclient)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  if (mpd_player_stop (mpdclient->mi) != MPD_OK)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_next (XfmpcMpdclient *mpdclient)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  if (mpd_player_next (mpdclient->mi) != MPD_OK)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_set_volume (XfmpcMpdclient *mpdclient,
+                            guint8 volume)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  if (mpd_status_set_volume (mpdclient->mi, volume) < 0)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_set_song_time (XfmpcMpdclient *mpdclient,
+                               guint time)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  if (mpd_player_seek (mpdclient->mi, time) != MPD_OK)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+gboolean
+xfmpc_mpdclient_is_playing (XfmpcMpdclient *mpdclient)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  return mpd_player_get_state (mpdclient->mi) == MPD_PLAYER_PLAY;
+}
+
+gboolean
+xfmpc_mpdclient_is_stopped (XfmpcMpdclient *mpdclient)
+{
+  return mpd_player_get_state (mpdclient->mi) == MPD_PLAYER_STOP;
+}
+
+const gchar *
+xfmpc_mpdclient_get_artist (XfmpcMpdclient *mpdclient)
+{
+  mpd_Song *song = mpd_playlist_get_current_song (mpdclient->mi);
+  if (G_UNLIKELY (NULL == song))
+    return NULL;
+
+  if (G_UNLIKELY (NULL == song->artist))
+    song->artist = g_strdup (_("n/a"));
+
+  return song->artist;
+}
+
+const gchar *
+xfmpc_mpdclient_get_title (XfmpcMpdclient *mpdclient)
+{
+  mpd_Song *song = mpd_playlist_get_current_song (mpdclient->mi);
+  if (G_UNLIKELY (NULL == song))
+    return NULL;
+
+  if (G_UNLIKELY (NULL == song->title))
+    song->title = g_path_get_basename (song->file);
+
+  return song->title;
+}
+
+const gchar *
+xfmpc_mpdclient_get_album (XfmpcMpdclient *mpdclient)
+{
+  mpd_Song *song = mpd_playlist_get_current_song (mpdclient->mi);
+  if (G_UNLIKELY (NULL == song))
+    return NULL;
+
+  if (G_UNLIKELY (NULL == song->album))
+    song->album = g_strdup (_("n/a"));
+
+  return song->album;
+}
+
+const gchar *
+xfmpc_mpdclient_get_date (XfmpcMpdclient *mpdclient)
+{
+  mpd_Song *song = mpd_playlist_get_current_song (mpdclient->mi);
+  if (G_UNLIKELY (NULL == song))
+    return NULL;
+
+  if (G_UNLIKELY (NULL == song->date))
+    song->date = g_strdup (_("n/a"));
+
+  return song->date;
+}
+
+gint
+xfmpc_mpdclient_get_time (XfmpcMpdclient *mpdclient)
+{
+  return mpd_status_get_elapsed_song_time (mpdclient->mi);
+}
+
+gint
+xfmpc_mpdclient_get_total_time (XfmpcMpdclient *mpdclient)
+{
+  xfmpc_mpdclient_connect (mpdclient);
+  return mpd_status_get_total_song_time (mpdclient->mi);
+}
+
+guint8
+xfmpc_mpdclient_get_volume (XfmpcMpdclient *mpdclient)
+{
+  gint volume = mpd_status_get_volume (mpdclient->mi);
+  return (volume < 0) ? 100 : volume;
+}
+

Added: xfmpc/trunk/src/mpdclient.h
===================================================================
--- xfmpc/trunk/src/mpdclient.h	                        (rev 0)
+++ xfmpc/trunk/src/mpdclient.h	2008-01-19 10:09:38 UTC (rev 3819)
@@ -0,0 +1,84 @@
+/*
+ *  Copyright (c) 2008 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XFMPC_MPDCLIENT_H__
+#define __XFMPC_MPDCLIENT_H__
+
+#include <glib.h>
+#include <libmpd/libmpd.h>
+
+typedef struct _XfmpcMpdclient          XfmpcMpdclient;
+
+struct _XfmpcMpdclient
+{
+  MpdObj               *mi;
+  gchar                *host;
+  guint                 port;
+  gchar                *passwd;
+
+  guint8                volume;
+};
+
+XfmpcMpdclient *        xfmpc_mpdclient_new                     ();
+
+void                    xfmpc_mpdclient_initenv                 (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_connect                 (XfmpcMpdclient *mpdclient);
+
+void                    xfmpc_mpdclient_disconnect              (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_is_connected            (XfmpcMpdclient *mpdclient);
+
+void                    xfmpc_mpdclient_free                    (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_previous                (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_pp                      (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_play                    (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_pause                   (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_stop                    (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_next                    (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_set_volume              (XfmpcMpdclient *mpdclient,
+                                                                 guint8 volume);
+gboolean                xfmpc_mpdclient_set_song_time           (XfmpcMpdclient *mpdclient,
+                                                                 guint time);
+gboolean                xfmpc_mpdclient_is_playing              (XfmpcMpdclient *mpdclient);
+
+gboolean                xfmpc_mpdclient_is_stopped              (XfmpcMpdclient *mpdclient);
+
+const gchar *           xfmpc_mpdclient_get_artist              (XfmpcMpdclient *mpdclient);
+
+const gchar *           xfmpc_mpdclient_get_title               (XfmpcMpdclient *mpdclient);
+
+const gchar *           xfmpc_mpdclient_get_album               (XfmpcMpdclient *mpdclient);
+
+const gchar *           xfmpc_mpdclient_get_date                (XfmpcMpdclient *mpdclient);
+
+gint                    xfmpc_mpdclient_get_time                (XfmpcMpdclient *mpdclient);
+
+gint                    xfmpc_mpdclient_get_total_time          (XfmpcMpdclient *mpdclient);
+
+guint8                  xfmpc_mpdclient_get_volume              (XfmpcMpdclient *mpdclient);
+
+#endif
+




More information about the Goodies-commits mailing list