~ubuntu-branches/ubuntu/oneiric/cairo-dock-plug-ins/oneiric-updates

« back to all changes in this revision

Viewing changes to musicPlayer/src/applet-quodlibet.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Iain Lane
  • Date: 2011-10-09 00:19:16 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20111009001916-9czstskx2t6l0b3x
Tags: 2.4.0~2-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New upstream bug fix release. (LP: #859984)
* Upstream (short) ChangeLog (2.4.0~0beta2 -> 2.4.0~1):
 - Powermanager: correctly release the reference on the device object
 - logout: now works if there is no session-manager
 - Status-Notifier: fixed a small bug
    (wrong callback in cairo_dock_stop_watching_dbus_name_owner)
 - Folders: fixed the positionning of the new icon
    and the dialog when dropping a folder inside the dock
    and fixed the icon-rendering
 - Dustbin: use the default theme if no icon is found
 - Impulse: the default context seems to be ok and not an error
 - Status-Notifier: On Ubuntu Oneiric (with indicator-0.4)
    the ApplicationAdded signal has changed and has a new parameter
 - Disable MeMenu on Oneiric (no longer available with indicator-0.4)
 - CMakeLists.txt: Improved output messages
 - Slide view: fixed a small offset in vertical view
 - musicPlayer:
  + split MPRIS 1.0 and 2.0 to help debugging and finding the right
     name of the bug.
  + 'rhythmbox-client' tool is no longer available: used MPRIS
  + Disable Amazon service (it no longer work)
  + Cover: fixed corrupted icons: some players (e.g. the latest version
     of RB) copy covers on their cache forlder but it takes a few time.
  + Fixed the update the icon and its name if the player is stopped.
  + Prevent a crash if the name given by MPRIS is NULL
 - Powermanager: try to prevent to have a few dialogues at the same time
 - PowerManager and AlsaMixer: hidden gnome2 or 3 apps if not available
 - Messaging-Menu: Updated for Natty and Oneiric
    (dbus-menu gives us GVariant instead of GValue objects)
 - Alsamixer: fixed a small bug on reload
 - Dbus: Bash interface: Fixed a typo with emblem positions
 - Sys-monitor: fixed a bug which prevented from getting
    the CPU temperature in some cases
 - Compiz (0.9): type filter: replaced type=utility by type=Utility
 - Updated the version of all applets that have gauges
   in order to use the right directory
 - Wifi: Fixed the status if we are not connected
 - Dbus: removed a conflict with the Help applet
 - Messaging-Menu: updated applet-menu.c => Memory leaks on pixbufs
 - Dbus: Fixed a crash when changing dock theme if a 'third-party' applet
    is running
 - Netspeed: in /proc/net/dev, there are 8 values to drop after the card id
    except if there is whitespaces just after this ':' character
    and fixed order and value for ON_ICON display
 - dock-rendering/toto: removed a useless file
 - Clipper: fixed the loading of the remembered items
    (they had the wrong type) and fixed a bug if we reduce the list of items
 - Folders, dustbin, Network-Monitor: tried to not use cast if it's possible
 - Code cleaned and re-organised a few functions
   (e.g. emblem references has been renamed)
 - Removed useless files: powermanager-dbus*
 - Updating translations
 - Fixed a few warnings at the compilation
 - Removed a few useless output messages
 - Fixed these LP bugs:
  + Empty trash from the trashcan does not delete files
     from usb harddisks: LP: #658681
  + Switcher applet doesn't respect desktop numbers LP: #626782
* Upstream (short) ChangeLog (2.4.0~1 -> 2.4.0~2):
 - Messaging-Menu: fixed a wrong g_object_unref (double free)
    and a small memory leak
 - Folders: fixed a tiny warning at the compilation (32bits)
 - switcher: removed an unnecessary config parameter
 - Folders: file size: used English instead of French translation.
 - Indicator applet: Forced a cast to remove an annoying warning
    due to clumsy dbusmenu_gtkmenu_new() declaration
 - Fixed the detection of the screensaver
 - Fixed tiny warnings at the compilation (with CAIRO_CONTAINER)
* debian/control:
 - Updated the version of cairo-dock-[core;data;dev].
 - Added gvfs as 'Suggests' for cairo-dock-plug-ins-integration
    (Used for managing files)
 - Removed 'libthunar-vfs-1-dev' (libthunar-vfs is no longer installed
    by default since XFCE 4.8 and it is replaced by gvfs)
 - Removed 'indicator-me' (no longer available
    and the installation of Cairo-Dock produces an error)
 - Moved 'indicator-messages' to 'Recommends'
* debian/rules:
 - Updated the name of CMake extras flags
* debian/cairo-dock-plug-ins-data.lintian-overrides:
 - Deleted (now useless)
* debian/cairo-dock-plug-ins.lintian-overrides:
 - Cairo-Dock Plug-Ins are not linked to gldi
 - shlib-without-versioned-soname: forwarded to upstream.
* debian/cairo-dock-plug-ins-integration.lintian-overrides:
 - Cairo-Dock Plug-Ins are not linked to gldi
 - ldconfig and shlibs are not needed
* debian/cairo-dock-plug-ins.install:
 - Fixed lintian errors: package-installs-python-bytecode
* debian/control: Fixed lintian warnings:
 - python-script-but-no-python-dep
 - description-synopsis-starts-with-article
* debian/changelog:
 - Fixed lintian warning: old-fsf-address-in-copyright-file
* debian/patches/01-switcher-force-compact-view.patch: 
 - Forced the compact view because the other doesn't work

[ Iain Lane ]
* Fix Mono/CLI build to be ~policy compliant and use correct compiler

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
 
93
93
/* Renvoie le temps ecoule en secondes.
94
94
 */
95
 
gint64 cairo_dock_dbus_get_integer64 (DBusGProxy *pDbusProxy, const gchar *cAccessor)
 
95
static gint64 cairo_dock_dbus_get_integer64 (DBusGProxy *pDbusProxy, const gchar *cAccessor)
96
96
{
97
97
        GError *erreur = NULL;
98
98
        gint64 iValue = 0;
167
167
        cd_musicplayer_get_cover_path (NULL, TRUE);
168
168
}
169
169
 
170
 
void cd_quodlibet_getSongInfos (void)
 
170
static void cd_quodlibet_getSongInfos (void)
171
171
{
172
172
        GHashTable *data_list = NULL;
173
173
        
205
205
// Les callbacks des signaux DBus. //
206
206
/////////////////////////////////////
207
207
 
208
 
/* Fonction executée à chaque changement de musique.
 
208
/* Fonction executee à chaque changement de musique.
209
209
 */
210
210
static void onChangeSong(DBusGProxy *player_proxy, GHashTable *metadata, gpointer data)
211
211
{
215
215
        if (metadata != NULL)
216
216
        {
217
217
                _extract_metadata (metadata);
218
 
                myData.bIsRunning = TRUE;
219
218
        }
220
219
        else
221
220
        {
232
231
                myData.iSongLength = 0;
233
232
                myData.iTrackNumber = 0;
234
233
                myData.cover_exist = FALSE;
235
 
                
236
 
                cd_musicplayer_dbus_detect_player ();
237
234
        }
238
235
        cd_musicplayer_update_icon (TRUE);
239
236
        CD_APPLET_LEAVE ();
240
237
}
241
238
 
242
 
/* Fonction executée à chaque changement "paused".
 
239
/* Fonction executee à chaque changement "paused".
243
240
 */
244
 
static void onChangePlaying (DBusGProxy *player_proxy, gpointer data)  // paused
 
241
static void on_pause (DBusGProxy *player_proxy, gpointer data)  // paused
245
242
{
246
243
        CD_APPLET_ENTER;
247
244
        cd_debug ("MP : %s ()\n", __func__);
248
 
        myData.bIsRunning = TRUE;
249
245
        
250
246
        myData.iPlayingStatus = PLAYER_PAUSED;
251
247
        
266
262
        }
267
263
        CD_APPLET_LEAVE ();
268
264
}
269
 
/* Fonction executée à chaque changement "unpaused".
 
265
/* Fonction executee à chaque changement "unpaused".
270
266
 */
271
 
static void onChangePlaying2 (DBusGProxy *player_proxy, gpointer data)  // unpaused
 
267
static void on_unpaused (DBusGProxy *player_proxy, gpointer data)  // unpaused
272
268
{
273
269
        CD_APPLET_ENTER;
274
270
        cd_debug ("MP : %s ()\n", __func__);
275
 
        myData.bIsRunning = TRUE;
276
271
        
277
272
        myData.iPlayingStatus = PLAYER_PLAYING;
278
273
        
292
287
// Definition du backend. //
293
288
////////////////////////////
294
289
 
295
 
/* Fonction de connexion au bus de QL.
296
 
 */
297
 
static gboolean _cd_quodlibet_dbus_connect_to_bus (void)
298
 
{
299
 
        if (cairo_dock_dbus_is_enabled ())
300
 
        {
301
 
                myData.dbus_enable = cd_musicplayer_dbus_connect_to_bus (); // cree le proxy.
302
 
 
303
 
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "paused",
304
 
                        G_TYPE_INVALID);
305
 
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "paused",
306
 
                        G_CALLBACK(onChangePlaying), NULL, NULL);
307
 
                
308
 
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "unpaused",
309
 
                        G_TYPE_NONE,
310
 
                        G_TYPE_INVALID);  // idem.
311
 
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "unpaused",
312
 
                        G_CALLBACK(onChangePlaying2), NULL, NULL);
313
 
                
314
 
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "song-started",
315
 
                        QL_DBUS_TYPE_SONG_METADATA,
316
 
                        G_TYPE_INVALID);
317
 
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "song-started",
318
 
                        G_CALLBACK(onChangeSong), NULL, NULL);
319
 
                
320
 
                return TRUE;
321
 
        }
322
 
        return FALSE;
323
 
}
324
 
 
325
 
/* Permet de libérer la mémoire prise par le backend.
326
 
 */
327
 
void cd_quodlibet_free_data (void)
328
 
{
329
 
        if (myData.dbus_proxy_player != NULL)
330
 
        {
331
 
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "paused",
332
 
                        G_CALLBACK(onChangePlaying), NULL);
333
 
                
334
 
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "unpaused",
335
 
                        G_CALLBACK(onChangePlaying2), NULL);
336
 
                                
337
 
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "song-started",
338
 
                        G_CALLBACK(onChangeSong), NULL);
339
 
        }
340
 
        musicplayer_dbus_disconnect_from_bus();
341
 
}
342
 
 
343
290
/* Controle du lecteur
344
291
 */
345
 
void cd_quodlibet_control (MyPlayerControl pControl, const char* song)
 
292
static void cd_quodlibet_control (MyPlayerControl pControl, const char* song)
346
293
{
347
294
        const gchar *cCommand = NULL;
348
295
                
366
313
        
367
314
        if (cCommand != NULL)
368
315
        {
369
 
                cd_debug ("MP : Handeler QuodLibet : will use '%s'", cCommand);
 
316
                cd_debug ("MP : Handler QuodLibet : will use '%s'", cCommand);
370
317
                cairo_dock_dbus_call (myData.dbus_proxy_player, cCommand);
371
318
        }
372
319
}
373
320
 
374
321
/* Recupere le temps ecoule chaque seconde (pas de signal pour ca).
375
322
 */
376
 
static void cd_quodlibet_read_data (void)
 
323
static void cd_quodlibet_get_data (void)
377
324
{
378
 
        if (myData.dbus_enable)
 
325
        if (myData.iPlayingStatus == PLAYER_PLAYING)
379
326
        {
380
 
                if (myData.bIsRunning)
381
 
                {
382
 
                        if (myData.iPlayingStatus == PLAYER_PLAYING)
383
 
                        {
384
 
                                _quodlibet_get_time_elapsed ();
385
 
                                if (myData.iCurrentTime < 0)
386
 
                                        myData.iPlayingStatus = PLAYER_STOPPED;
387
 
                        }
388
 
                        else if (myData.iPlayingStatus != PLAYER_PAUSED)  // en pause le temps reste constant.
389
 
                                myData.iCurrentTime = 0;
390
 
                }
391
 
                else 
392
 
                {
393
 
                        myData.iCurrentTime = 0;
394
 
                }
395
 
                cd_message (" myData.iCurrentTime <- %d", __func__, myData.iCurrentTime);
 
327
                _quodlibet_get_time_elapsed ();
 
328
                if (myData.iCurrentTime < 0)
 
329
                        myData.iPlayingStatus = PLAYER_STOPPED;
396
330
        }
 
331
        else if (myData.iPlayingStatus != PLAYER_PAUSED)  // en pause le temps reste constant.
 
332
                myData.iCurrentTime = 0;
397
333
}
398
334
 
399
335
/* Initialise le backend de QL.
400
336
 */
401
 
static void cd_quodlibet_configure (void)
 
337
static void cd_quodlibet_start (void)
402
338
{
403
 
        myData.DBus_commands.service = "net.sacredchao.QuodLibet";
404
 
        myData.DBus_commands.path = "/net/sacredchao/QuodLibet";
405
 
        myData.DBus_commands.interface = "net.sacredchao.QuodLibet";
 
339
        // register to the signals
 
340
        dbus_g_proxy_add_signal(myData.dbus_proxy_player, "paused",
 
341
                G_TYPE_INVALID);
 
342
        dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "paused",
 
343
                G_CALLBACK(on_pause), NULL, NULL);
 
344
 
 
345
        dbus_g_proxy_add_signal(myData.dbus_proxy_player, "unpaused",
 
346
                G_TYPE_NONE,
 
347
                G_TYPE_INVALID);  // idem.
 
348
        dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "unpaused",
 
349
                G_CALLBACK(on_unpaused), NULL, NULL);
 
350
 
 
351
        dbus_g_proxy_add_signal(myData.dbus_proxy_player, "song-started",
 
352
                QL_DBUS_TYPE_SONG_METADATA,
 
353
                G_TYPE_INVALID);
 
354
        dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "song-started",
 
355
                G_CALLBACK(onChangeSong), NULL, NULL);
406
356
        
407
 
        myData.dbus_enable = _cd_quodlibet_dbus_connect_to_bus ();  // se connecte au bus et aux signaux de QL.
408
 
        if (myData.dbus_enable)
409
 
        {
410
 
                cd_musicplayer_dbus_detect_player ();  // on teste la presence de QL sur le bus <=> s'il est ouvert ou pas.
411
 
                if(myData.bIsRunning)  // player en cours d'execution, on recupere son etat.
412
 
                {
413
 
                        cd_debug ("MP : QL is running\n");
414
 
                        _quodlibet_getPlaying ();
415
 
                        cd_quodlibet_getSongInfos ();
416
 
                        cd_musicplayer_update_icon (TRUE);
417
 
                }
418
 
                else  // player eteint.
419
 
                {
420
 
                        cd_musicplayer_set_surface (PLAYER_NONE);
421
 
                }
422
 
        }
423
 
        else  // sinon on signale par l'icone appropriee que le bus n'est pas accessible.
424
 
        {
425
 
                cd_musicplayer_set_surface (PLAYER_BROKEN);
426
 
        }
 
357
        // get the current state.
 
358
        _quodlibet_getPlaying ();
 
359
        cd_quodlibet_getSongInfos ();
 
360
        cd_musicplayer_update_icon (TRUE);
427
361
}
428
362
 
429
363
 
431
365
 */
432
366
void cd_musicplayer_register_quodlibet_handler (void)
433
367
{
434
 
        MusicPlayerHandeler *pQuodlibet = g_new0 (MusicPlayerHandeler, 1);
435
 
        pQuodlibet->read_data = cd_quodlibet_read_data;
436
 
        pQuodlibet->free_data = cd_quodlibet_free_data;
437
 
        pQuodlibet->configure = cd_quodlibet_configure;  // renseigne les proprietes DBus et se connecte au bus.
438
 
        pQuodlibet->control = cd_quodlibet_control;
439
 
        pQuodlibet->get_cover = NULL;
440
 
        pQuodlibet->cCoverDir = NULL;  /// il me semble que QL gere les pochettes ...
441
 
        
442
 
        pQuodlibet->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT;
443
 
        pQuodlibet->appclass = "quodlibet";
444
 
        pQuodlibet->launch = "quodlibet";
445
 
        pQuodlibet->name = "QuodLibet";
446
 
        pQuodlibet->cMprisService = "net.sacredchao.QuodLibet";
447
 
        pQuodlibet->iPlayer = MP_QUODLIBET;
448
 
        pQuodlibet->bSeparateAcquisition = FALSE;
449
 
        pQuodlibet->iLevel = PLAYER_GOOD;  // n'a besoin d'une boucle que pour afficher le temps ecoule.
450
 
        cd_musicplayer_register_my_handler (pQuodlibet, "QuodLibet");
 
368
        MusicPlayerHandler *pHandler = g_new0 (MusicPlayerHandler, 1);
 
369
        pHandler->name = "QuodLibet";
 
370
        pHandler->get_data = cd_quodlibet_get_data;
 
371
        pHandler->stop = NULL;
 
372
        pHandler->start = cd_quodlibet_start;
 
373
        pHandler->control = cd_quodlibet_control;
 
374
        pHandler->get_cover = NULL;
 
375
        pHandler->cCoverDir = NULL;  /// il me semble que QL gere les pochettes ...
 
376
        
 
377
        pHandler->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT;
 
378
        pHandler->appclass = "quodlibet";
 
379
        pHandler->launch = "quodlibet";
 
380
        pHandler->cMprisService = "net.sacredchao.QuodLibet";
 
381
        pHandler->path = "/net/sacredchao/QuodLibet";
 
382
        pHandler->interface = "net.sacredchao.QuodLibet";
 
383
        pHandler->path2 = NULL;
 
384
        pHandler->interface2 = NULL;
 
385
        
 
386
        pHandler->bSeparateAcquisition = FALSE;
 
387
        pHandler->iLevel = PLAYER_GOOD;  // n'a besoin d'une boucle que pour afficher le temps ecoule.
 
388
        cd_musicplayer_register_my_handler (pHandler);
451
389
}