Skip to content

Commit

Permalink
Added mpd support
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Small committed Mar 22, 2011
1 parent 34a941f commit 08e13b4
Show file tree
Hide file tree
Showing 25 changed files with 461 additions and 53 deletions.
6 changes: 2 additions & 4 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
2011-03-01 gettextize <bug-gnu-gettext@gnu.org>

* configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.18.1.

Changes in 0.3.2
================
* Fixed all file headers to use standard format and GPL v2+
Expand All @@ -12,6 +8,8 @@ Changes in 0.3.2
* playlist length option now really sets the playlist length
* analysis aborts if canot expand file, Debian #60613
* Explicitly linked to dl library, Debian #615725
* configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.18.1.
* gjay can now use Music Player Daemon as a music player

Changes in 0.3.1
================
Expand Down
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ gjay_SOURCES = gjay.h songs.h prefs.h ui.h rgbhsv.h analysis.h playlist.h \
ui_playlist_view.c ui_colorwheel.c \
ui_menubar.c analysis.c playlist.c \
vorbis.c mp3.c flac.c util.c \
play_common.c play_audacious.c
play_common.c play_common.h \
play_audacious.c plaY_audacious.h \
play_mpdclient.c play_mpdclient.h
#play_exaile.h play_exaile.c

#ddui_colorbox.c
Expand Down
73 changes: 73 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# This was lifted from the Gimp, and adapted slightly by
# Raph Levien .

DIE=0

PROJECT=gjay

# Make it possible to specify path in the environment
: ${AUTOCONF=autoconf}
: ${AUTOHEADER=autoheader}
: ${AUTOMAKE=automake}
: ${ACLOCAL=aclocal}
: ${AUTOPOINT=autopoint}

($AUTOPOINT --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have gettext installed to compile $PROJECT."
echo "Get ftp://ftp.gnu.org/pub/gnu/gettext-0.14.1.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}

($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile $PROJECT."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}

($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have automake installed to compile $PROJECT."
echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.6.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}

if test "$DIE" -eq 1; then
exit 1
fi

if test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi

case $CC in
*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
esac

for dir in .
do
echo processing $dir
cd $dir
configdir="config"
test -d $configdir || mkdir $configdir
aclocalinclude="$ACLOCAL_FLAGS"
$AUTOPOINT
$ACLOCAL $aclocalinclude -I $configdir
$AUTOHEADER -Wall
$AUTOMAKE -Wall --add-missing --gnu $am_opt
$AUTOCONF -Wall
cd -
done

./configure "$@"

echo
echo "Now type 'make' to compile $PROJECT."

3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@

/* Version number of package */
#undef VERSION

/* Enable mpd music player */
#undef WITH_MPDCLIENT
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ AC_CONFIG_SRCDIR([gjay.h])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.10])

dnl Options
AC_SUBST([WITH_MPDCLIENT])
AC_ARG_ENABLE([mpdclient],
AC_HELP_STRING([--with-mpdclient], [Enable mpd client(default is YES)]),
[enable_mpdclient=$enableval],
[enable_mpdclient="yes"])
if test "$enable_mpdclient" = "yes"; then
AC_DEFINE([WITH_MPDCLIENT], [1], [Enable mpd music player])
PKG_CHECK_MODULES([MPDCLIENT], [libmpdclient])
fi


# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
Expand Down
8 changes: 4 additions & 4 deletions doc/gjay.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
.\" man page for gjay
.\"
.\" Copyright (C) 2002-2003 Chuck Groom <cgroom@users.sourceforge.net>
.\" Copyright (C) 2010 Craig Small <csmall@enc.com.au>
.\" Copyright (C) 2010-2011 Craig Small <csmall@enc.com.au>
.\"
.\" This man page 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.
.\"
.pc
.TH GJAY 1 2010-10-28
.TH GJAY 1 2011-03-22
.SH NAME
gjay \- organizes music collections
.SH SYNOPSIS
Expand Down Expand Up @@ -97,10 +97,10 @@ Set the level of how verbose
.B gjay
is.
.TP
.B \-P, \-\-play\-audacious
.B \-P, \-\-player\-start
Start the music player after making a playlist.
.TP
.B \-V, \-\-version
Show the version and copyright information for the program.
.SH "SEE ALSO"
.BR audacious (1)
.BR audacious (1) ,mpd (1)
17 changes: 9 additions & 8 deletions gjay.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "flac.h"
#include "ui.h"
#include "i18n.h"
#include "play_common.h"

GjayApp *gjay;

Expand All @@ -73,7 +74,7 @@ static void fork_or_connect_to_daemon(void);
static void run_as_ui (int argc, char * argv[]);
static void run_as_playlist ( guint playlist_minutes,
gboolean m3u_format,
gboolean playlist_in_audacious );
gboolean player_autostart );
void gjay_message_log(const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
Expand Down Expand Up @@ -115,7 +116,7 @@ parse_commandline(int *argc_p, char ***argv_p, guint *playlist_minutes, gboolean
{ "skip-verification", 's', 0, G_OPTION_ARG_NONE, &skip_verify, _("Skip file verification"), NULL },
{ "m3u-playlist", 'u', 0, G_OPTION_ARG_NONE, m3u_format, _("Use M3U playlist format"), NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_INT, &verbosity, "Set verbosity/debug level", _("LEVEL") },
{ "play-audacious", 'P', 0, G_OPTION_ARG_NONE, run_player, _("Play generated playlist in Audacious"), NULL },
{ "player-start", 'P', 0, G_OPTION_ARG_NONE, run_player, _("Start player using generated playlist"), NULL },
{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK , &print_version, _("Show version"), NULL },
{ NULL }
};
Expand Down Expand Up @@ -177,7 +178,7 @@ parse_commandline(int *argc_p, char ***argv_p, guint *playlist_minutes, gboolean

int main( int argc, char *argv[] ) {
gchar * analyze_detached_fname=NULL;
gboolean m3u_format, playlist_in_audacious;
gboolean m3u_format, player_autostart;
guint playlist_minutes;
gchar *gjay_home;

Expand All @@ -193,10 +194,10 @@ int main( int argc, char *argv[] ) {
skip_verify = 0;
playlist_minutes = 0;
m3u_format = FALSE;
playlist_in_audacious = FALSE;
player_autostart = FALSE;
gjay->prefs = load_prefs();

parse_commandline(&argc, &argv, &playlist_minutes, &m3u_format, &playlist_in_audacious, &analyze_detached_fname);
parse_commandline(&argc, &argv, &playlist_minutes, &m3u_format, &player_autostart, &analyze_detached_fname);

/* Intialize vars */
daemon_pipe_fd = -1;
Expand Down Expand Up @@ -255,7 +256,7 @@ int main( int argc, char *argv[] ) {
break;
case PLAYLIST:
read_data_file();
run_as_playlist(playlist_minutes, m3u_format, playlist_in_audacious);
run_as_playlist(playlist_minutes, m3u_format, player_autostart);
break;
case DAEMON_INIT:
case DAEMON_DETACHED:
Expand Down Expand Up @@ -514,7 +515,7 @@ static void run_as_ui(int argc, char *argv[] )


/* Playlist mode */
static void run_as_playlist(guint playlist_minutes, gboolean m3u_format, gboolean playlist_in_audacious)
static void run_as_playlist(guint playlist_minutes, gboolean m3u_format, gboolean player_autostart)
{
GList * list;
gjay->prefs->use_selected_songs = FALSE;
Expand All @@ -525,7 +526,7 @@ static void run_as_playlist(guint playlist_minutes, gboolean m3u_format, gboolea
if (playlist_minutes == 0)
playlist_minutes = gjay->prefs->time;
list = generate_playlist(playlist_minutes);
if (playlist_in_audacious) {
if (player_autostart) {
play_songs(list);
} else {
write_playlist(list, stdout, m3u_format);
Expand Down
9 changes: 7 additions & 2 deletions gjay.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Gjay - Gtk+ DJ music playlist creator
* Copyright (C) 2002-2004 Chuck Groom
* Copyright (C) 2010 Craig Small
* Copyright (C) 2010-2011 Craig Small
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -76,9 +76,13 @@ gchar * parent_dir ( const char * path );

struct _GjayApp {
GjayPrefs *prefs;

/* Player connections/handles */
DBusGConnection *connection;
DBusGProxy *player_proxy;
#ifdef WITH_MPDCLIENT
struct mpd_connection *mpdclient_connection;
#endif /* WITH_MPDCLIENT */


//GdkPixbuf * pixbufs[PM_LAST];
GdkPixbuf * pixbufs[50]; //FIXME
Expand Down Expand Up @@ -112,6 +116,7 @@ struct _GjayApp {
gboolean ogg_supported;
gboolean flac_supported;


/* Player calls */
song* (*player_get_current_song)(void);
gboolean (*player_is_running)(void);
Expand Down
22 changes: 22 additions & 0 deletions ipc.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Gjay - Gtk+ DJ music playlist creator
* Copyright (C) 2002 Chuck Groom
* Copyright (C) 2010-2011 Craig Small
*
* 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, 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */

#include <string.h>
#include "ipc.h"
#include "gjay.h"
Expand Down
12 changes: 9 additions & 3 deletions play_common.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Gjay - Gtk+ DJ music playlist creator
* Copyright (C) 2010 Craig Small
* Copyright (C) 2010-2011 Craig Small
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand All @@ -22,6 +22,9 @@

#include "gjay.h"
#include "play_audacious.h"
#ifdef WITH_MPDCLIENT
#include "play_mpdclient.h"
#endif /* WITH_MPDCLIENT */
/*#include "play_exaile.h"*/
#include "i18n.h"

Expand All @@ -36,6 +39,11 @@ player_init(void)
/*case PLAYER_EXAILE:
exaile_init();
break;*/
#ifdef WITH_MPDCLIENT
case PLAYER_MPDCLIENT:
mpdclient_init();
break;
#endif /* WITH_MPDCLIENT */
default:
g_error("Unknown music player.\n");
}
Expand Down Expand Up @@ -63,10 +71,8 @@ void play_songs (GList *slist) {

if (!gjay->player_is_running())
{
int i;
GtkWidget *dialog;
gint result;
GError *error;
gchar *msg;

msg = g_strdup_printf(_("%s is not running, start %s?"),
Expand Down
30 changes: 30 additions & 0 deletions play_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Gjay - Gtk+ DJ music playlist creator
* Copyright (C) 2010-2011 Craig Small
*
* 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, 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */

#ifndef PLAY_COMMON_H
#define PLAY_COMMON_H

void player_init(void);
void play_song(song *s);
void play_songs (GList *slist);

#endif /* PLAY_COMMON_H */
8 changes: 1 addition & 7 deletions play_exaile.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,7 @@ exaile_play_files ( GList *list) {
}
if (i == 3) /* never got running */
{
dialog = gtk_message_dialog_new(GTK_WINDOW(gjay->main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Unable to start exaile"));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
gjay_error_dialog(_("Unable to start exaile"));
return;
}

Expand Down
Loading

0 comments on commit 08e13b4

Please sign in to comment.