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 "applet-struct.h"
32
#include "applet-config.h"
33
#include "applet-notifications.h"
34
#include "applet-draw.h"
35
#include "applet-infopipe.h"
36
#include "applet-init.h"
39
CD_APPLET_DEFINITION ("xmms",
41
CAIRO_DOCK_CATEGORY_CONTROLER,
42
N_("An applet dedicated to control XMMS, Audacious, Banshee & Exaile.\n"
43
"XMMS & Audacious are fully supported, but Banshee and Exaile's monitoring is still experimental.\n"
44
"For XMMS, you have to install the 'xmms-infopipe' plug-in.\n"
45
"Launch/Play/Pause on left click, Next song on middle click.\n"
46
"You can drag and drop songs on the icon to put them in the queue.\n"
47
"Scroll up/down to play the previous/next song."),
48
"ChAnGFu (Rémy Robertson)")
50
static gchar *s_cPlayerClass[MY_NB_PLAYERS] = {"xmms", "audacious", "banshee", "exaile"};
54
if (myConfig.extendedDesklet) {
55
cd_xmms_add_buttons_to_desklet (myApplet);
56
if (myConfig.iExtendedMode == MY_DESKLET_INFO || myConfig.iExtendedMode == MY_DESKLET_INFO_AND_CONTROLER) {
57
gpointer data[3] = {"None", "None", GINT_TO_POINTER (myConfig.iExtendedMode == MY_DESKLET_INFO ? FALSE : TRUE)};
58
CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Mediaplayer", data);
61
gpointer data[2] = {GINT_TO_POINTER (TRUE), GINT_TO_POINTER (FALSE)};
62
CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Caroussel", data);
66
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
70
myData.playingStatus = PLAYER_NONE;
71
myData.previousPlayingStatus = -1;
72
myData.previousPlayingTitle = NULL;
73
myData.iPreviousTrackNumber = -1;
74
myData.iPreviousCurrentTime = -1;
75
myData.pTask = cairo_dock_new_task (1,
76
(CairoDockGetDataAsyncFunc) cd_xmms_read_pipe,
77
(CairoDockUpdateSyncFunc) cd_xmms_draw_icon,
79
cairo_dock_launch_task (myData.pTask);
81
if (myConfig.bStealTaskBarIcon) {
82
cairo_dock_inhibate_class (s_cPlayerClass[myConfig.iPlayer], myIcon);
85
CD_APPLET_REGISTER_FOR_CLICK_EVENT;
86
CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
87
CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
88
CD_APPLET_REGISTER_FOR_DROP_DATA_EVENT;
89
CD_APPLET_REGISTER_FOR_SCROLL_EVENT;
94
//\_______________ On se desabonne de nos notifications.
95
CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
96
CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
97
CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
98
CD_APPLET_UNREGISTER_FOR_DROP_DATA_EVENT;
99
CD_APPLET_UNREGISTER_FOR_SCROLL_EVENT;
101
if (myIcon->cClass != NULL)
102
cairo_dock_deinhibate_class (s_cPlayerClass[myConfig.iPlayer], myIcon);
106
CD_APPLET_RELOAD_BEGIN
107
//\_______________ On recharge les donnees qui ont pu changer.
108
if (CD_APPLET_MY_CONFIG_CHANGED && myDesklet) {
109
if ( ! myConfig.extendedDesklet && myDesklet->icons != NULL) {
110
g_list_foreach (myDesklet->icons, (GFunc) cairo_dock_free_icon, NULL);
111
g_list_free (myDesklet->icons);
112
myDesklet->icons = NULL;
114
else if (myConfig.extendedDesklet && myDesklet->icons == NULL) {
115
cd_xmms_add_buttons_to_desklet (myApplet);
120
for (i = 0; i < PLAYER_NB_STATUS; i ++) { // reset surfaces.
121
if (myData.pSurfaces[i] != NULL) {
122
cairo_surface_destroy (myData.pSurfaces[i]);
123
myData.pSurfaces[i] = NULL;
128
if (myConfig.extendedDesklet) {
129
if (myConfig.iExtendedMode == MY_DESKLET_INFO || myConfig.iExtendedMode == MY_DESKLET_INFO_AND_CONTROLER) {
130
gpointer data[3] = {"None", "None", GINT_TO_POINTER (myConfig.iExtendedMode == MY_DESKLET_INFO ? FALSE : TRUE)};
131
CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Mediaplayer", data);
134
gpointer data[2] = {GINT_TO_POINTER (TRUE), GINT_TO_POINTER (FALSE)};
135
CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Caroussel", data);
139
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
143
//\_______________ On relance avec la nouvelle config ou on redessine.
144
myData.playingStatus = PLAYER_NONE;
145
myData.previousPlayingStatus = -1;
146
myData.previousPlayingTitle = NULL;
147
myData.iPreviousTrackNumber = -1;
148
myData.iPreviousCurrentTime = -1;
149
if (CD_APPLET_MY_CONFIG_CHANGED) {
150
if (myIcon->cClass != NULL) { // on est en train d'inhiber l'appli.
151
if (! myConfig.bStealTaskBarIcon || strcmp (myIcon->cClass, s_cPlayerClass[myConfig.iPlayer]) != 0) { // on ne veut plus l'inhiber ou on veut inhiber une autre.
152
cairo_dock_deinhibate_class (myIcon->cClass, myIcon);
155
if (myConfig.bStealTaskBarIcon && myIcon->cClass == NULL) { // on comence a inhiber l'appli si on ne le faisait pas, ou qu'on s'est arrete.
156
cairo_dock_inhibate_class (s_cPlayerClass[myConfig.iPlayer], myIcon);
158
// inutile de relancer le timer, sa frequence ne change pas. Inutile aussi de faire 1 iteration ici, les modifs seront prises en compte a la prochaine iteration, dans au plus 1s.
160
else { // on redessine juste l'icone.
161
cd_xmms_draw_icon (myApplet);