commit c8ace043040f52da4fcf152c93d437251781fc14
Author: phantomjinx <[email protected]>
Date: Sat Feb 11 09:13:01 2012 +0000
Plugin for attaching use of an external player
* Allow the user to plug in their own player to play tracks
* xmms added back as the default preference
.gitignore | 2 +
configure.ac | 1 +
libgtkpod/tools.c | 113 +++++++++------
libgtkpod/tools.h | 2 +
plugins/Makefile.am | 3 +-
plugins/external_player/Makefile.am | 45 ++++++
plugins/external_player/external_player.c | 89 ++++++++++++
plugins/external_player/external_player.h | 38 +++++
plugins/external_player/external_player.plugin.in | 4 +
plugins/external_player/external_player.ui | 7 +
plugins/external_player/external_player.xml | 109 ++++++++++++++
plugins/external_player/plugin.c | 161 +++++++++++++++++++++
plugins/external_player/plugin.h | 60 ++++++++
13 files changed, 588 insertions(+), 46 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 69a4aa7..751fbc0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -95,6 +95,7 @@ version
/data/glade/mserv.xml
/data/glade/clarity.xml
/data/glade/sjcd.xml
+/data/glade/external_player.xml
/data/ui/details_editor.ui
/data/ui/coverweb.ui
@@ -111,6 +112,7 @@ version
/data/ui/mserv.ui
/data/ui/clarity.ui
/data/ui/sjcd.ui
+/data/ui/external_player.ui
/data/rhythmbox.gep
diff --git a/configure.ac b/configure.ac
index b8ddc3f..5aeade4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -637,6 +637,7 @@ plugins/sjcd/icons/hicolor/48x48/Makefile
plugins/sjcd/icons/hicolor/48x48/places/Makefile
plugins/sjcd/icons/hicolor/scalable/Makefile
plugins/sjcd/icons/hicolor/scalable/places/Makefile
+plugins/external_player/Makefile
])
AC_OUTPUT
diff --git a/libgtkpod/tools.c b/libgtkpod/tools.c
index ae90ad8..6847444 100644
--- a/libgtkpod/tools.c
+++ b/libgtkpod/tools.c
@@ -76,17 +76,18 @@ static gboolean mutex_data = FALSE;
*
* Command may include options, like "mp3gain -q -k %s"
*
- * %s is replaced by @track_path if present, otherwise @track_path is
+ * %s is replaced by @selected_tracks if present, otherwise @selected_tracks
are
* added at the end.
*
* Return value: TRUE if the command ran successfully, FALSE if any
* error occurred.
*/
-static gboolean run_exec_on_track(const gchar *commandline, const gchar
*track_path, GError **error) {
+gboolean run_exec_on_tracks(const gchar *commandline, GList *selected_tracks,
GError **error) {
gchar *command_full_path = NULL;
gchar *command = NULL;
gchar *command_base = NULL;
gchar *buf;
+ GList *tks;
const gchar *nextarg;
gboolean success = FALSE;
gboolean percs = FALSE;
@@ -95,8 +96,8 @@ static gboolean run_exec_on_track(const gchar *commandline,
const gchar *track_p
int status, fdnull, ret;
pid_t tpid;
- g_return_val_if_fail (commandline, FALSE);
- g_return_val_if_fail (track_path, FALSE);
+ g_return_val_if_fail(commandline, FALSE);
+ g_return_val_if_fail(selected_tracks, FALSE);
/* skip whitespace */
while (g_ascii_isspace (*commandline))
@@ -113,7 +114,8 @@ static gboolean run_exec_on_track(const gchar *commandline,
const gchar *track_p
command_full_path = g_find_program_in_path(command);
if (!command_full_path) {
- buf = g_strdup_printf(_("Could not find '%s'.\nPlease specifiy the
exact path in the Tools section of the preference dialog or install the program
if it is not installed on your system.\n\n"), command);
+ buf =
+ g_strdup_printf(_("Could not find '%s'.\nPlease specifiy the
exact path in the preference dialog or install the program if it is not
installed on your system.\n\n"), command);
gtkpod_log_error(error, buf);
g_free(buf);
goto cleanup;
@@ -143,8 +145,16 @@ static gboolean run_exec_on_track(const gchar
*commandline, const gchar *track_p
if (!next)
next = commandline + strlen(commandline);
- if (strncmp(commandline, "%s", 2) == 0) { /* substitute %s with
@track_path */
- g_ptr_array_add(args, g_strdup(track_path));
+ if (strncmp(commandline, "%s", 2) == 0) { /* substitute %s with
@selected_tracks */
+ for (tks = selected_tracks; tks; tks = tks->next) {
+ Track *tr = tks->data;
+ g_return_val_if_fail(tr, FALSE);
+ gchar *path;
+ path = get_file_name_from_source(tr, SOURCE_PREFER_LOCAL);
+ if (path) {
+ g_ptr_array_add(args, path);
+ }
+ }
percs = TRUE;
}
else {
@@ -159,9 +169,18 @@ static gboolean run_exec_on_track(const gchar
*commandline, const gchar *track_p
++commandline;
}
- /* Add @track_path if "%s" was not present */
- if (!percs)
- g_ptr_array_add(args, g_strdup(track_path));
+ /* Add @selected_tracks if "%s" was not present */
+ if (!percs) {
+ for (tks = selected_tracks; tks; tks = tks->next) {
+ Track *tr = tks->data;
+ g_return_val_if_fail(tr, FALSE);
+ gchar *path;
+ path = get_file_name_from_source(tr, SOURCE_PREFER_LOCAL);
+ if (path) {
+ g_ptr_array_add(args, path);
+ }
+ }
+ }
/* need NULL pointer */
g_ptr_array_add(args, NULL);
@@ -190,10 +209,8 @@ static gboolean run_exec_on_track(const gchar
*commandline, const gchar *track_p
default: /* we are the parent, everything's fine */
tpid = waitpid(tpid, &status, 0);
g_ptr_array_free(args, TRUE);
- if (
- WIFEXITED(status))
- ret =
- WEXITSTATUS(status);
+ if (WIFEXITED(status))
+ ret = WEXITSTATUS(status);
else
ret = 2;
if (ret > 1) {
@@ -214,13 +231,15 @@ static gboolean run_exec_on_track(const gchar
*commandline, const gchar *track_p
return success;
}
+
+
/* reread the soundcheck value from the file */
static gboolean nm_get_soundcheck(Track *track, GError **error) {
gchar *path, *buf;
gchar *commandline = NULL;
FileType *filetype;
- g_return_val_if_fail (track, FALSE);
+ g_return_val_if_fail(track, FALSE);
if (read_soundcheck(track, error))
return TRUE;
@@ -241,8 +260,9 @@ static gboolean nm_get_soundcheck(Track *track, GError
**error) {
commandline = filetype_get_gain_cmd(filetype);
if (commandline) {
- if (run_exec_on_track(commandline, path, error)) {
- g_free(path);
+ GList *tks = NULL;
+ tks = g_list_append(tks, track);
+ if (run_exec_on_tracks(commandline, tks, error)) {
return read_soundcheck(track, error);
}
}
@@ -263,10 +283,10 @@ static gboolean nm_get_soundcheck(Track *track, GError
**error) {
static gpointer th_nm_get_soundcheck(gpointer data) {
struct nm *nm = data;
gboolean success = nm_get_soundcheck(nm->track, &(nm->error));
- g_mutex_lock (mutex);
+ g_mutex_lock(mutex);
mutex_data = TRUE; /* signal that thread will end */
- g_cond_signal (cond);
- g_mutex_unlock (mutex);
+ g_cond_signal(cond);
+ g_mutex_unlock(mutex);
return GUINT_TO_POINTER(success);
}
#endif
@@ -276,11 +296,11 @@ void nm_new_tracks(iTunesDB *itdb) {
GList *tracks = NULL;
GList *gl;
- g_return_if_fail (itdb);
+ g_return_if_fail(itdb);
for (gl = itdb->tracks; gl; gl = gl->next) {
Track *track = gl->data;
- g_return_if_fail (track);
+ g_return_if_fail(track);
if (!track->transferred) {
tracks = g_list_append(tracks, track);
}
@@ -292,19 +312,19 @@ void nm_new_tracks(iTunesDB *itdb) {
static void nm_report_errors_and_free(GString *errors) {
if (errors && errors->len > 0) {
gtkpod_confirmation(-1, /* gint id, */
- TRUE, /* gboolean modal, */
- _("Normalization Errors"), /* title */
- _("Errors created by track normalisation"), /* label */
- errors->str, /* scrolled text */
- NULL, 0, NULL, /* option 1 */
- NULL, 0, NULL, /* option 2 */
- TRUE, /* gboolean confirm_again, */
- "show_normalization_errors",/* confirm_again_key,*/
- CONF_NULL_HANDLER, /* ConfHandler ok_handler,*/
- NULL, /* don't show "Apply" button */
- NULL, /* cancel_handler,*/
- NULL, /* gpointer user_data1,*/
- NULL); /* gpointer user_data2,*/
+ TRUE, /* gboolean modal, */
+ _("Normalization Errors"), /* title */
+ _("Errors created by track normalisation"), /* label */
+ errors->str, /* scrolled text */
+ NULL, 0, NULL, /* option 1 */
+ NULL, 0, NULL, /* option 2 */
+ TRUE, /* gboolean confirm_again, */
+ "show_normalization_errors",/* confirm_again_key,*/
+ CONF_NULL_HANDLER, /* ConfHandler ok_handler,*/
+ NULL, /* don't show "Apply" button */
+ NULL, /* cancel_handler,*/
+ NULL, /* gpointer user_data1,*/
+ NULL); /* gpointer user_data2,*/
g_string_free(errors, TRUE);
}
@@ -362,7 +382,7 @@ void nm_tracks_list(GList *list) {
thread = g_thread_create (th_nm_get_soundcheck, nm, TRUE, NULL);
if (thread) {
- g_mutex_lock (mutex);
+ g_mutex_lock(mutex);
do {
while (widgets_blocked && gtk_events_pending())
gtk_main_iteration();
@@ -370,14 +390,14 @@ void nm_tracks_list(GList *list) {
g_get_current_time(>ime);
g_time_val_add(>ime, 20000);
- g_cond_timed_wait (cond, mutex, >ime);
+ g_cond_timed_wait(cond, mutex, >ime);
}
while (!mutex_data);
success = GPOINTER_TO_UINT(g_thread_join (thread));
- g_mutex_unlock (mutex);
+ g_mutex_unlock(mutex);
}
else {
- g_warning ("Thread creation failed, falling back to default.\n");
+ g_warning("Thread creation failed, falling back to default.\n");
success = nm_get_soundcheck(nm->track, &(nm->error));
}
@@ -390,10 +410,14 @@ void nm_tracks_list(GList *list) {
gchar *path = get_file_name_from_source(nm->track,
SOURCE_PREFER_LOCAL);
if (nm->error) {
- errors = g_string_append(errors, g_strdup_printf(_("'%s-%s'
(%s) could not be normalized. %s\n"), nm->track->artist, nm->track->title, path
? path : "", nm->error->message));
+ errors =
+ g_string_append(errors, g_strdup_printf(_("'%s-%s'
(%s) could not be normalized. %s\n"), nm->track->artist, nm->track->title,
+ path ? path : "", nm->error->message));
}
else {
- errors = g_string_append(errors, g_strdup_printf(_("'%s-%s'
(%s) could not be normalized. Unknown error.\n"), nm->track->artist,
nm->track->title, path ? path : ""));
+ errors =
+ g_string_append(errors, g_strdup_printf(_("'%s-%s'
(%s) could not be normalized. Unknown error.\n"), nm->track->artist,
nm->track->title,
+ path ? path : ""));
}
g_free(path);
@@ -437,9 +461,8 @@ void nm_tracks_list(GList *list) {
nm_report_errors_and_free(errors);
- gtkpod_statusbar_message (ngettext ("Normalized %d of %d tracks.",
- "Normalized %d of %d tracks.", n),
- count, n);
+ gtkpod_statusbar_message(ngettext ("Normalized %d of %d tracks.",
+ "Normalized %d of %d tracks.", n), count, n);
release_widgets();
}
@@ -525,7 +548,7 @@ static gboolean tools_sync_script(iTunesDB *itdb, SyncType
type) {
/* remove leading and trailing whitespace */
if (script)
- g_strstrip (script);
+ g_strstrip(script);
if (!script || (strlen(script) == 0)) {
gtkpod_warning(_("Please specify the command to be called on the
'Tools' section of the preferences dialog.\n"));
diff --git a/libgtkpod/tools.h b/libgtkpod/tools.h
index b46f192..cdd7c62 100644
--- a/libgtkpod/tools.h
+++ b/libgtkpod/tools.h
@@ -43,6 +43,8 @@
#define TRACKVOLERROR G_MININT32
+gboolean run_exec_on_tracks(const gchar *commandline, GList *selected_tracks,
GError **error);
+
void nm_new_tracks (iTunesDB *itdb);
void nm_tracks_list (GList *list);
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 391f7a6..bd61c83 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -22,6 +22,7 @@ SUBDIRS = . \
filetype_mp4 \
filetype_m4a \
clarity \
- sjcd
+ sjcd \
+ external_player
# indent
diff --git a/plugins/external_player/Makefile.am
b/plugins/external_player/Makefile.am
new file mode 100644
index 0000000..ec7df07
--- /dev/null
+++ b/plugins/external_player/Makefile.am
@@ -0,0 +1,45 @@
+plugin_name = external_player
+plugin_file = $(plugin_name).plugin
+
+# Plugin UI file
+external_player_uidir = $(gtkpod_ui_dir)
+external_player_ui_DATA = $(plugin_name).ui
+
+# Plugin Glade file
+external_player_gladedir = $(gtkpod_glade_dir)
+external_player_glade_DATA = $(plugin_name).xml
+
+# Plugin Icon file
+external_player_pixmapsdir = $(gtkpod_image_dir)
+external_player_pixmaps_DATA =
+
+# Where to install the plugin
+external_player_plugindir = $(gtkpod_plugin_dir)
+external_player_plugin_DATA =
+
+SUBDIRS =
+
+include ../plugins.mk
+external_player.plugin: build-plugin-file
+
+# The plugin
+plugin_lib = lib$(plugin_name).so
+plugin_LTLIBRARIES = libexternal_player.la
+
+# Plugin sources
+libexternal_player_la_SOURCES = plugin.c plugin.h \
+ external_player.c
external_player.h
+
+libexternal_player_la_LDFLAGS = $(GTKPOD_PLUGIN_LDFLAGS)
+
+# Plugin dependencies
+libexternal_player_la_LIBADD = \
+ $(GTKPOD_LIBS) \
+ $(LIBANJUTA_LIBS)
+
+EXTRA_DIST = \
+ $(plugin_file).in \
+ $(external_player_plugin_DATA) \
+ $(external_player_ui_DATA) \
+ $(external_player_glade_DATA) \
+ $(external_player_pixmaps_DATA)
diff --git a/plugins/external_player/external_player.c
b/plugins/external_player/external_player.c
new file mode 100644
index 0000000..4e1b83e
--- /dev/null
+++ b/plugins/external_player/external_player.c
@@ -0,0 +1,89 @@
+/*
+ |
+ | Copyright (C) 2002-2012 Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | 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 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
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libgtkpod/directories.h"
+#include "libgtkpod/prefs.h"
+#include "libgtkpod/misc.h"
+#include "libgtkpod/tools.h"
+#include "plugin.h"
+#include "external_player.h"
+
+#define PLAY_NOW_PREF "path_play_now"
+
+/*
+ * play tracks with external player.
+ *
+ * @selected_tracks: list of tracks to be played
+ */
+void external_player_play_tracks(GList *tracks) {
+ GError *error = NULL;
+ gchar *cmd = prefs_get_string ("path_play_now");
+
+ run_exec_on_tracks(cmd, tracks, &error);
+
+ if (error) {
+ gtkpod_warning_simple(error->message);
+ g_error_free(error);
+ }
+
+ g_free(cmd);
+}
+
+GtkWidget *init_external_player_preferences() {
+ GtkBuilder *prefbuilder;
+ GtkWidget *w = NULL;
+ GtkWidget *notebook;
+ GtkWidget *play_entry;
+
+ gchar *glade_path = g_build_filename(get_glade_dir(),
"external_player.xml", NULL);
+ prefbuilder = gtkpod_builder_xml_new(glade_path);
+ w = gtkpod_builder_xml_get_widget(prefbuilder, "prefs_window");
+ notebook = gtkpod_builder_xml_get_widget(prefbuilder,
"external_player_notebook");
+ play_entry = gtkpod_builder_xml_get_widget(prefbuilder,
"play_command_entry");
+ g_object_ref(notebook);
+ gtk_container_remove(GTK_CONTAINER(w), notebook);
+ gtk_widget_destroy(w);
+ g_free(glade_path);
+
+ gtk_entry_set_text(GTK_ENTRY(play_entry), prefs_get_string(PLAY_NOW_PREF));
+
+ gtk_builder_connect_signals(prefbuilder, NULL);
+ g_object_unref(prefbuilder);
+
+ return notebook;
+}
+
+/**
+ * Callback for play command entry in preference dialog
+ */
+G_MODULE_EXPORT void on_play_command_entry_changed (GtkEditable *sender,
gpointer e) {
+ prefs_set_string (PLAY_NOW_PREF, gtk_entry_get_text (GTK_ENTRY (sender)));
+}
+
diff --git a/plugins/external_player/external_player.h
b/plugins/external_player/external_player.h
new file mode 100644
index 0000000..9706e08
--- /dev/null
+++ b/plugins/external_player/external_player.h
@@ -0,0 +1,38 @@
+/*
+|
+| Copyright (C) 2002-2012 Paul Richardson <phantom_sf at
users.sourceforge.net>
+| Part of the gtkpod project.
+|
+| URL: http://gtkpod.sourceforge.net/
+|
+| 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 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
+|
+| iTunes and iPod are trademarks of Apple
+|
+| This product is not supported/written/published by Apple!
+|
+| $Id: oggfile.h 954 2007-01-16 09:45:00Z jcsjcs $
+*/
+
+#ifndef __EXTERNAL_PLAYER_H__
+#define __EXTERNAL_PLAYER_H__
+
+#include <gtk/gtk.h>
+
+void external_player_play_tracks(GList *tracks);
+
+GtkWidget *init_external_player_preferences();
+
+#endif
diff --git a/plugins/external_player/external_player.plugin.in
b/plugins/external_player/external_player.plugin.in
new file mode 100644
index 0000000..4b0bc43
--- /dev/null
+++ b/plugins/external_player/external_player.plugin.in
@@ -0,0 +1,4 @@
+[Anjuta Plugin]
+Location=external_player:ExternalPlayerPlugin
+_Name=External Media Player Plugin
+_Description=Adds track command for playing tracks in external player, eg. xmms
diff --git a/plugins/external_player/external_player.ui
b/plugins/external_player/external_player.ui
new file mode 100644
index 0000000..b141558
--- /dev/null
+++ b/plugins/external_player/external_player.ui
@@ -0,0 +1,7 @@
+<!--*- xml -*-->
+<ui>
+ <menubar name="MenuMain">
+ </menubar>
+ <toolbar name="ToolbarMain">
+ </toolbar>
+</ui>
diff --git a/plugins/external_player/external_player.xml
b/plugins/external_player/external_player.xml
new file mode 100644
index 0000000..054c42b
--- /dev/null
+++ b/plugins/external_player/external_player.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <object class="GtkWindow" id="prefs_window">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkNotebook" id="external_player_notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkFrame" id="frame4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment14">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">Command for 'play'</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="play_command_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <signal name="changed"
handler="on_play_command_entry_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Player
Command</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="display_page_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">External Media
Player</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/plugins/external_player/plugin.c b/plugins/external_player/plugin.c
new file mode 100644
index 0000000..55c44fe
--- /dev/null
+++ b/plugins/external_player/plugin.c
@@ -0,0 +1,161 @@
+/*
+ | Copyright (C) 2002-2012 Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | 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 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
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ | $Id$
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glib.h>
+#include <libanjuta/anjuta-utils.h>
+#include "libgtkpod/gtkpod_app_iface.h"
+#include "libgtkpod/prefs.h"
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+#include "libgtkpod/directories.h"
+#include "plugin.h"
+#include "external_player.h"
+
+#define TAB_NAME "External Media Player"
+
+/* Parent class. Part of standard class definition */
+static gpointer parent_class;
+
+static GtkActionEntry external_player_actions[] =
+ { };
+
+static void set_default_preferences() {
+ if (! prefs_get_string_value("path_play_now", NULL))
+ prefs_set_string ("path_play_now", "xmms -e %s");
+
+ if (! prefs_get_int_value("path_play_enqueue", NULL))
+ prefs_set_string ("path_play_enqueue", "xmms -e %s");
+}
+
+static gboolean activate_plugin(AnjutaPlugin *plugin) {
+ AnjutaUI *ui;
+ ExternalPlayerPlugin *external_player_plugin;
+ GtkActionGroup* action_group;
+
+ /* Set preferences */
+ set_default_preferences();
+
+ external_player_plugin = (ExternalPlayerPlugin*) plugin;
+ ui = anjuta_shell_get_ui(plugin->shell, NULL);
+
+ /* Add our cover_actions */
+ action_group
+ = anjuta_ui_add_action_group_entries(ui,
"ActionGroupExternalPlayer", _("External Player"), external_player_actions,
G_N_ELEMENTS (external_player_actions), GETTEXT_PACKAGE, TRUE, plugin);
+ external_player_plugin->action_group = action_group;
+
+ /* Merge UI */
+ gchar *uipath = g_build_filename(get_ui_dir(), "external_player.ui", NULL);
+ external_player_plugin->uiid = anjuta_ui_merge(ui, uipath);
+ g_free(uipath);
+
+ gtkpod_register_track_command(TRACK_COMMAND(external_player_plugin));
+
+ return TRUE; /* FALSE if activation failed */
+}
+
+static gboolean deactivate_plugin(AnjutaPlugin *plugin) {
+ AnjutaUI *ui;
+ ExternalPlayerPlugin *external_player_plugin;
+
+ external_player_plugin = (ExternalPlayerPlugin*) plugin;
+ ui = anjuta_shell_get_ui(plugin->shell, NULL);
+
+ gtkpod_unregister_track_command(TRACK_COMMAND(external_player_plugin));
+
+ /* Unmerge UI */
+ anjuta_ui_unmerge(ui, external_player_plugin->uiid);
+
+ /* Remove Action groups */
+ anjuta_ui_remove_action_group(ui, external_player_plugin->action_group);
+
+ /* FALSE if plugin doesn't want to deactivate */
+ return TRUE;
+}
+
+static void external_player_plugin_instance_init(GObject *obj) {
+ ExternalPlayerPlugin *plugin = (ExternalPlayerPlugin*) obj;
+ plugin->uiid = 0;
+ plugin->action_group = NULL;
+ plugin->prefs = NULL;
+}
+
+static void external_player_plugin_class_init(GObjectClass *klass) {
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+
+ plugin_class->activate = activate_plugin;
+ plugin_class->deactivate = deactivate_plugin;
+}
+
+static void track_command_iface_init(TrackCommandInterface *iface) {
+ iface->id = "external_player_play_track_command";
+ iface->text = _("Play with preferred app...");
+ iface->execute = external_player_play_tracks;
+}
+
+static void ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences*
prefs, GError** e) {
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *scaled;
+
+ ExternalPlayerPlugin* plugin = EXTERNAL_PLAYER_PLUGIN(ipref);
+ plugin->prefs = init_external_player_preferences();
+ if (plugin->prefs == NULL)
+ return;
+
+ pixbuf = gtk_widget_render_icon_pixbuf(plugin->prefs,
GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_LARGE_TOOLBAR);
+ if (!pixbuf) {
+ g_warning (N_("Couldn't load theme media player icon"));
+ }
+
+ scaled = gdk_pixbuf_scale_simple(pixbuf, 48, 48, GDK_INTERP_BILINEAR);
+
+ anjuta_preferences_dialog_add_page(ANJUTA_PREFERENCES_DIALOG
(anjuta_preferences_get_dialog (prefs)), "gtkpod-external-player-settings",
_(TAB_NAME), scaled, plugin->prefs);
+ g_object_unref(scaled);
+ g_object_unref(pixbuf);
+}
+
+static void ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences*
prefs, GError** e) {
+ anjuta_preferences_remove_page(prefs, TAB_NAME);
+ ExternalPlayerPlugin* plugin = EXTERNAL_PLAYER_PLUGIN(ipref);
+ gtk_widget_destroy(plugin->prefs);
+}
+
+static void ipreferences_iface_init(IAnjutaPreferencesIface* iface) {
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+ANJUTA_PLUGIN_BEGIN (ExternalPlayerPlugin, external_player_plugin);
+ANJUTA_PLUGIN_ADD_INTERFACE(track_command, TRACK_COMMAND_TYPE);
+ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_END;
+
+ANJUTA_SIMPLE_PLUGIN (ExternalPlayerPlugin, external_player_plugin);
diff --git a/plugins/external_player/plugin.h b/plugins/external_player/plugin.h
new file mode 100644
index 0000000..da9a93a
--- /dev/null
+++ b/plugins/external_player/plugin.h
@@ -0,0 +1,60 @@
+/*
+| Copyright (C) 2002-2012 Paul Richardson <phantom_sf at
users.sourceforge.net>
+| Part of the gtkpod project.
+|
+| URL: http://www.gtkpod.org/
+| URL: http://gtkpod.sourceforge.net/
+|
+| 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 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
+|
+| iTunes and iPod are trademarks of Apple
+|
+| This product is not supported/written/published by Apple!
+|
+| $Id$
+*/
+
+#ifndef PLUGIN_H_
+#define PLUGIN_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libanjuta/anjuta-plugin.h>
+
+extern GType external_player_plugin_get_type (GTypeModule *module);
+#define EXTERNAL_PLAYER_TYPE_PLUGIN (external_player_plugin_get_type
(NULL))
+#define EXTERNAL_PLAYER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
EXTERNAL_PLAYER_TYPE_PLUGIN, ExternalPlayerPlugin))
+#define EXTERNAL_PLAYER_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
EXTERNAL_PLAYER_TYPE_PLUGIN, ExternalPlayerPluginClass))
+#define EXTERNAL_PLAYER_IS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
EXTERNAL_PLAYER_TYPE_PLUGIN))
+#define EXTERNAL_PLAYER_IS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
EXTERNAL_PLAYER_TYPE_PLUGIN))
+#define EXTERNAL_PLAYER_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
EXTERNAL_PLAYER_TYPE_PLUGIN, ExternalPlayerPluginClass))
+
+typedef struct _ExternalPlayerPlugin ExternalPlayerPlugin;
+typedef struct _ExternalPlayerPluginClass ExternalPlayerPluginClass;
+
+struct _ExternalPlayerPlugin {
+ AnjutaPlugin parent;
+ gint uiid;
+ GtkActionGroup *action_group;
+ GtkWidget *prefs;
+};
+
+struct _ExternalPlayerPluginClass {
+ AnjutaPluginClass parent_class;
+};
+
+#endif /* PLUGIN_H_ */
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2