2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Rémy Robertson (for any bug report, please mail me to changfu@cairo-dock.org)
26
Fabrice Rey (fabounet@users.berlios.de)
28
******************************************************************************/
31
#include <glib/gi18n.h>
33
#include "applet-struct.h"
34
#include "applet-notifications.h"
35
#include "applet-infopipe.h"
38
void cd_xmms_prev(CairoDockModuleInstance *myApplet) {
39
GError *erreur = NULL;
40
g_free (myData.playingTitle);
41
myData.playingTitle = NULL; //Reseting the title to detect it for sure
42
switch (myConfig.iPlayer) {
44
g_spawn_command_line_async ("xmms -r", &erreur);
47
g_spawn_command_line_async ("audacious -r", &erreur);
50
g_spawn_command_line_async ("banshee --previous", &erreur);
53
g_spawn_command_line_async ("exaile -p", &erreur);
59
cd_warning ("Attention : when trying to execute 'previous on %d' : %s", myConfig.iPlayer, erreur->message);
60
g_error_free (erreur);
64
void cd_xmms_pp(CairoDockModuleInstance *myApplet) {
65
GError *erreur = NULL;
66
switch (myConfig.iPlayer) {
68
g_spawn_command_line_async ("xmms -t", &erreur);
71
g_spawn_command_line_async ("audacious -t", &erreur);
74
g_spawn_command_line_async ("banshee --toggle-playing", &erreur);
77
g_spawn_command_line_async ("exaile -t", &erreur);
83
cd_warning ("Attention : when trying to execute 'play pause on %d' : %s", myConfig.iPlayer, erreur->message);
84
g_error_free (erreur);
87
void cd_xmms_stop(CairoDockModuleInstance *myApplet) {
88
GError *erreur = NULL;
89
switch (myConfig.iPlayer) {
91
g_spawn_command_line_async ("xmms -s", &erreur);
94
g_spawn_command_line_async ("audacious -s", &erreur);
97
g_spawn_command_line_async ("exaile -s", &erreur);
99
default : // banshee n'a pas de --stop.
102
if (erreur != NULL) {
103
cd_warning ("Attention : when trying to execute 'stop on %d' : %s", myConfig.iPlayer, erreur->message);
104
g_error_free (erreur);
107
void cd_xmms_next(CairoDockModuleInstance *myApplet) {
108
GError *erreur = NULL;
109
g_free (myData.playingTitle);
110
myData.playingTitle = NULL; //Resetting the title to detect it for sure
111
switch (myConfig.iPlayer) {
113
g_spawn_command_line_async ("xmms -f", &erreur);
116
g_spawn_command_line_async ("audacious -f", &erreur);
119
g_spawn_command_line_async ("banshee --next", &erreur);
122
g_spawn_command_line_async ("exaile -n", &erreur);
127
if (erreur != NULL) {
128
cd_warning ("Attention : when trying to execute 'next on %d' : %s", myConfig.iPlayer, erreur->message);
129
g_error_free (erreur);
132
void cd_xmms_shuffle(CairoDockModuleInstance *myApplet) {
133
GError *erreur = NULL;
134
switch (myConfig.iPlayer) {
136
g_spawn_command_line_async ("xmms -S", &erreur);
139
g_spawn_command_line_async ("audtool playlist-repeat-toggle ", &erreur);
144
if (erreur != NULL) {
145
cd_warning ("Attention : when trying to execute 'shuffle on %d' : %s", myConfig.iPlayer, erreur->message);
146
g_error_free (erreur);
149
void cd_xmms_repeat(CairoDockModuleInstance *myApplet) {
150
GError *erreur = NULL;
151
switch (myConfig.iPlayer) {
153
g_spawn_command_line_async ("xmms -R", &erreur);
156
g_spawn_command_line_async ("audtool playlist-shuffle-toggle", &erreur);
161
if (erreur != NULL) {
162
cd_warning ("Attention : when trying to execute 'repeat on %d' : %s", myConfig.iPlayer, erreur->message);
163
g_error_free (erreur);
166
void cd_xmms_jumpbox(CairoDockModuleInstance *myApplet) {
167
GError *erreur = NULL;
168
switch (myConfig.iPlayer) {
170
g_spawn_command_line_async ("xmms -j", &erreur);
173
g_spawn_command_line_async ("audacious -j", &erreur);
178
if (erreur != NULL) {
179
cd_warning ("Attention : when trying to execute 'jumpbox on %d' : %s", myConfig.iPlayer, erreur->message);
180
g_error_free (erreur);
183
void cd_xmms_enqueue(CairoDockModuleInstance *myApplet, const gchar *cFile) {
184
GError *erreur = NULL;
185
gchar *cCommand = NULL;
186
switch (myConfig.iPlayer) {
188
cCommand = g_strdup_printf ("xmms -e %s", cFile);
191
cCommand = g_strdup_printf ("audacious -e %s", cFile);
194
cCommand = g_strdup_printf ("banshee --enqueue %s", cFile);
197
//Vraiment limité ce player...
202
if (cCommand != NULL && cFile != NULL) {
203
cd_debug("XMMS: will use '%s'", cCommand);
204
g_spawn_command_line_async (cCommand, &erreur);
207
if (erreur != NULL) {
208
cd_warning ("Attention : when trying to execute 'next on %d' : %s", myConfig.iPlayer, erreur->message);
209
g_error_free (erreur);
216
static void _xmms_action_by_id (CairoDockModuleInstance *myApplet, int iAction) {
219
cd_xmms_prev(myApplet);
222
cd_xmms_pp(myApplet);
225
cd_xmms_stop(myApplet);
228
cd_xmms_next(myApplet);
231
cd_warning ("no action defined");
235
CD_APPLET_ON_CLICK_BEGIN
236
if (myDesklet != NULL && pClickedContainer == myContainer && pClickedIcon != NULL && pClickedIcon != myIcon) { // clic sur une des icones du desklet.
237
_xmms_action_by_id (myApplet, pClickedIcon->iType);
240
cd_xmms_pp(myApplet);
242
CD_APPLET_ON_CLICK_END
245
static void _on_play_pause (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
247
cd_xmms_pp (myApplet);
249
static void _on_prev (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
251
cd_xmms_prev (myApplet);
253
static void _on_next (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
255
cd_xmms_next (myApplet);
257
static void _on_stop (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
259
cd_xmms_stop (myApplet);
261
static void _on_jumpbox (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
263
cd_xmms_jumpbox (myApplet);
265
static void _on_shuffle (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
267
cd_xmms_shuffle (myApplet);
269
static void _on_repeat (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
271
cd_xmms_repeat (myApplet);
274
CD_APPLET_ON_BUILD_MENU_BEGIN
275
GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
276
CD_APPLET_ADD_IN_MENU (D_("Previous"), _on_prev, CD_APPLET_MY_MENU);
277
CD_APPLET_ADD_IN_MENU (D_("Play/Pause (left-click)"), _on_play_pause, CD_APPLET_MY_MENU);
278
if (myConfig.iPlayer != MY_BANSHEE) {
279
CD_APPLET_ADD_IN_MENU (D_("Stop"), _on_stop, CD_APPLET_MY_MENU);
281
CD_APPLET_ADD_IN_MENU (D_("Next (middle-click)"), _on_next, CD_APPLET_MY_MENU);
282
if ((myConfig.iPlayer != MY_BANSHEE) && (myConfig.iPlayer != MY_EXAILE)) {
283
CD_APPLET_ADD_IN_MENU (D_("Show JumpBox"), _on_jumpbox, pSubMenu);
284
CD_APPLET_ADD_IN_MENU (D_("Toggle Shuffle"), _on_shuffle, pSubMenu);
285
CD_APPLET_ADD_IN_MENU (D_("Toggle Repeat"), _on_repeat, pSubMenu);
287
CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
288
CD_APPLET_ON_BUILD_MENU_END
291
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
292
cd_xmms_next(myApplet);
293
CD_APPLET_ON_MIDDLE_CLICK_END
296
CD_APPLET_ON_DROP_DATA_BEGIN
297
cd_message (" XMMS: %s to enqueue", CD_APPLET_RECEIVED_DATA);
298
cd_xmms_enqueue (myApplet, CD_APPLET_RECEIVED_DATA);
299
CD_APPLET_ON_DROP_DATA_END
303
CD_APPLET_ON_SCROLL_BEGIN
304
if (CD_APPLET_SCROLL_DOWN) {
305
cd_xmms_next(myApplet);
307
else if (CD_APPLET_SCROLL_UP) {
308
cd_xmms_prev(myApplet);
311
return CAIRO_DOCK_LET_PASS_NOTIFICATION;
312
CD_APPLET_ON_SCROLL_END