static void reload (CairoConfigIndicators *pPrevIndicators, CairoConfigIndicators *pIndicators) { CairoDock *pDock = g_pMainDock; double fMaxScale = cairo_dock_get_max_scale (pDock); cairo_t* pCairoContext = cairo_dock_create_context_from_window (CAIRO_CONTAINER (pDock)); if (cairo_dock_strings_differ (pPrevIndicators->cIndicatorImagePath, pIndicators->cIndicatorImagePath) || pPrevIndicators->bLinkIndicatorWithIcon != pIndicators->bLinkIndicatorWithIcon || pPrevIndicators->fIndicatorRatio != pIndicators->fIndicatorRatio) { cairo_dock_load_task_indicator (myTaskBar.bShowAppli && myTaskBar.bMixLauncherAppli ? pIndicators->cIndicatorImagePath : NULL, pCairoContext, fMaxScale, pIndicators->fIndicatorRatio); } if (cairo_dock_strings_differ (pPrevIndicators->cActiveIndicatorImagePath, pIndicators->cActiveIndicatorImagePath) || pPrevIndicators->iActiveCornerRadius != pIndicators->iActiveCornerRadius || pPrevIndicators->iActiveLineWidth != pIndicators->iActiveLineWidth || cairo_dock_colors_differ (pPrevIndicators->fActiveColor, pIndicators->fActiveColor)) { cairo_dock_load_active_window_indicator (pCairoContext, pIndicators->cActiveIndicatorImagePath, fMaxScale, pIndicators->iActiveCornerRadius, pIndicators->iActiveLineWidth, pIndicators->fActiveColor); } if (cairo_dock_strings_differ (pPrevIndicators->cClassIndicatorImagePath, pIndicators->cClassIndicatorImagePath)) { cairo_dock_load_class_indicator (myTaskBar.bShowAppli && myTaskBar.bGroupAppliByClass ? pIndicators->cClassIndicatorImagePath : NULL, pCairoContext, fMaxScale); } cairo_destroy (pCairoContext); cairo_dock_redraw_root_docks (FALSE); // main dock inclus. }
static void reload (CairoConfigTaskBar *pPrevTaskBar, CairoConfigTaskBar *pTaskBar) { CairoDock *pDock = g_pMainDock; gboolean bUpdateSize = FALSE; if (/**pPrevTaskBar->bUniquePid != pTaskBar->bUniquePid ||*/ pPrevTaskBar->bGroupAppliByClass != pTaskBar->bGroupAppliByClass || pPrevTaskBar->bHideVisibleApplis != pTaskBar->bHideVisibleApplis || pPrevTaskBar->bAppliOnCurrentDesktopOnly != pTaskBar->bAppliOnCurrentDesktopOnly || pPrevTaskBar->bMixLauncherAppli != pTaskBar->bMixLauncherAppli || pPrevTaskBar->bOverWriteXIcons != pTaskBar->bOverWriteXIcons || pPrevTaskBar->bShowThumbnail != pTaskBar->bShowThumbnail || pPrevTaskBar->iAppliMaxNameLength != pTaskBar->iAppliMaxNameLength || cairo_dock_strings_differ (pPrevTaskBar->cGroupException, pTaskBar->cGroupException) || cairo_dock_strings_differ (pPrevTaskBar->cOverwriteException, pTaskBar->cOverwriteException) || (cairo_dock_application_manager_is_running () && ! pTaskBar->bShowAppli)) // on ne veut plus voir les applis, il faut donc les enlever. { cairo_dock_stop_application_manager (); bUpdateSize = TRUE; } if (cairo_dock_application_manager_is_running () && pPrevTaskBar->bDrawIndicatorOnAppli != pTaskBar->bDrawIndicatorOnAppli) { cairo_dock_foreach_applis ((CairoDockForeachIconFunc) _set_indicator, FALSE, GINT_TO_POINTER (pTaskBar->bDrawIndicatorOnAppli)); gtk_widget_queue_draw (pDock->pWidget); } if (! cairo_dock_application_manager_is_running () && pTaskBar->bShowAppli) // maintenant on veut voir les applis ! { cairo_dock_start_application_manager (pDock); // va inserer le separateur si necessaire. bUpdateSize = TRUE; } else gtk_widget_queue_draw (pDock->pWidget); // pour le fVisibleAlpha if (pPrevTaskBar->bShowAppli != pTaskBar->bShowAppli || pPrevTaskBar->bGroupAppliByClass != pTaskBar->bGroupAppliByClass) { cairo_t *pCairoContext = cairo_dock_create_context_from_window (CAIRO_CONTAINER (pDock)); double fMaxScale = cairo_dock_get_max_scale (pDock); cairo_dock_load_class_indicator (pTaskBar->bShowAppli && pTaskBar->bGroupAppliByClass ? myIndicators.cClassIndicatorImagePath : NULL, pCairoContext, fMaxScale); cairo_destroy (pCairoContext); } /**if (bUpdateSize) // utile ?... { cairo_dock_calculate_dock_icons (pDock); gtk_widget_queue_draw (pDock->pWidget); // le 'gdk_window_move_resize' ci-dessous ne provoquera pas le redessin si la taille n'a pas change. cairo_dock_place_root_dock (pDock); }*/ }
/* Recupere tout chaque seconde (aucun signal). */ static void cd_exaile_read_data (void) { if (! myData.dbus_enable) { cd_warning ("couldn't connect to bus"); return; } if (! myData.bIsRunning) cd_musicplayer_dbus_detect_player (); if (myData.bIsRunning) { g_print ("Exaile is running\n"); cd_exaile_getSongInfos (); if (myData.iPlayingStatus == PLAYER_PLAYING && cairo_dock_strings_differ (myData.cRawTitle, myData.cPreviousRawTitle)) cd_exaile_getCoverPath (); else if (myData.iPlayingStatus == PLAYER_STOPPED) // en pause le temps et la chanson reste constants. { myData.iCurrentTime = 0; } cd_message (" myData.iCurrentTime <- %d", __func__, myData.iCurrentTime); } else { cd_debug ("MP : lecteur non ouvert"); myData.iPlayingStatus = PLAYER_NONE; } }
static gboolean _is_a_new_track (const gchar *cTrackID) { cd_message (" TrackId <- %s (was: %s)", cTrackID, myData.cTrackID); if (cairo_dock_strings_differ (myData.cTrackID, cTrackID)) // track has changed. { g_free (myData.cTrackID); myData.cTrackID = g_strdup (cTrackID); return TRUE; } return FALSE; }
static void reload (CairoConfigDialogs *pPrevDialogs, CairoConfigDialogs *pDialogs) { CairoDock *pDock = g_pMainDock; if (cairo_dock_strings_differ (pPrevDialogs->cButtonOkImage, pDialogs->cButtonOkImage) || cairo_dock_strings_differ (pPrevDialogs->cButtonCancelImage, pDialogs->cButtonCancelImage) || pPrevDialogs->iDialogIconSize != pDialogs->iDialogIconSize) { cairo_dock_load_dialog_buttons (CAIRO_CONTAINER (pDock), pDialogs->cButtonOkImage, pDialogs->cButtonCancelImage); } if (pDialogs->bHomogeneous) { pDialogs->dialogTextDescription.iSize = myLabels.iconTextDescription.iSize; if (pDialogs->dialogTextDescription.iSize == 0) pDialogs->dialogTextDescription.iSize = 14; pDialogs->dialogTextDescription.cFont = g_strdup (myLabels.iconTextDescription.cFont); pDialogs->dialogTextDescription.iWeight = myLabels.iconTextDescription.iWeight; pDialogs->dialogTextDescription.iStyle = myLabels.iconTextDescription.iStyle; } }
/* Recupere tout chaque seconde (aucun signal). */ static void cd_exaile_get_data (void) { cd_debug ("Exaile is running\n"); cd_exaile_getSongInfos (); if (myData.iPlayingStatus == PLAYER_PLAYING && cairo_dock_strings_differ (myData.cRawTitle, myData.cPreviousRawTitle)) cd_exaile_getCoverPath (); else if (myData.iPlayingStatus == PLAYER_STOPPED) // en pause le temps et la chanson reste constants. { myData.iCurrentTime = 0; } cd_message (" myData.iCurrentTime <- %d", __func__, myData.iCurrentTime); }
static void reload (CairoConfigViews *pPrevViews, CairoConfigViews *pViews) { CairoDock *pDock = g_pMainDock; if (cairo_dock_strings_differ (pPrevViews->cMainDockDefaultRendererName, pViews->cMainDockDefaultRendererName)) { cairo_dock_set_all_views_to_default (1); // met a jour la taille des docks. cairo_dock_redraw_root_docks (FALSE); // FALSE <=> main dock inclus. cairo_dock_reserve_space_for_all_root_docks (myAccessibility.bReserveSpace); } if (cairo_dock_strings_differ (pPrevViews->cSubDockDefaultRendererName, pViews->cSubDockDefaultRendererName) || pPrevViews->bSameHorizontality != pViews->bSameHorizontality || pPrevViews->fSubDockSizeRatio != pViews->fSubDockSizeRatio) { if (pPrevViews->bSameHorizontality != pViews->bSameHorizontality || pPrevViews->fSubDockSizeRatio != pViews->fSubDockSizeRatio) { cairo_dock_synchronize_sub_docks_position (pDock, FALSE); cairo_dock_reload_buffers_in_all_docks (TRUE); // y compris les applets. } cairo_dock_set_all_views_to_default (2); // met a jour la taille des docks. } }
static gboolean _check_cover_file_size (gpointer data) { myData.iNbCheckCover ++; if (myData.iNbCheckCover > 5) { // still no file, try to set it ourselves. g_free (myData.cCoverPath); myData.cCoverPath = _find_cover_in_common_dirs (); if (myData.cCoverPath != NULL) { if (cairo_dock_strings_differ (myData.cCoverPath, myData.cPreviousCoverPath)) // cover has changed, apply it. { cd_musiplayer_apply_cover (); } } else if (myConfig.bDownload) { cd_musicplayer_dl_cover (); } myData.iSidCheckCover = 0; return FALSE; } if (cd_musicplayer_check_size_is_constant (myData.cCoverPath)) { /// file is complete, apply it on the icon... myData.cover_exist = TRUE; if (myData.iPlayingStatus == PLAYER_PLAYING || myData.iPlayingStatus == PLAYER_PAUSED) // if it has stopped before we got the cover, don't draw it. { cd_musiplayer_apply_cover (); } myData.iSidCheckCover = 0; return FALSE; } return TRUE; }
static gboolean _check_cover_file_exists (gpointer data) { myData.iNbCheckCover ++; if (myData.iNbCheckCover > 3) { // still no file, try to set it ourselves. g_free (myData.cCoverPath); myData.cCoverPath = _find_cover_in_common_dirs (); if (myData.cCoverPath != NULL) { if (cairo_dock_strings_differ (myData.cCoverPath, myData.cPreviousCoverPath)) // cover has changed, apply it. { myData.iNbCheckCover = 0; myData.iSidCheckCover = g_timeout_add_seconds (1, (GSourceFunc)_check_cover_file_size, NULL); return FALSE; } } else if (myConfig.bDownload) { cd_musicplayer_dl_cover (); } myData.iSidCheckCover = 0; return FALSE; } if (myData.cCoverPath && g_file_test (myData.cCoverPath, G_FILE_TEST_EXISTS)) { /// file exists, now check for its size myData.iNbCheckCover = 0; myData.iSidCheckCover = g_timeout_add_seconds (1, (GSourceFunc)_check_cover_file_size, NULL); return FALSE; } return TRUE; }
static gboolean _update_from_feeds (CDSharedMemory *pSharedMemory) { GldiModuleInstance *myApplet = pSharedMemory->pApplet; CD_APPLET_ENTER; if (! myData.bInit) // pas encore initialise, on vire le message d'attente. { cd_rssreader_free_item_list (myApplet); myData.pItemList = NULL; myData.bInit = TRUE; } // On parse le flux XML. if (pSharedMemory->cTaskBridge == NULL || *pSharedMemory->cTaskBridge == '\0') { cd_warning ("RSSresader : no data"); const gchar *cErrorMessage = (myConfig.cUrl == NULL ? D_("No URL is defined.") : D_("No data (no connection?)")); _insert_error_message (myApplet, cErrorMessage); if (myDesklet) { cd_applet_update_my_icon (myApplet); } myData.bUpdateIsManual = FALSE; if (myData.pTask->iPeriod > 20) { cd_message ("no data, will re-try in 20s"); gldi_task_change_frequency (myData.pTask, 20); // on re-essaiera dans 20s. } CD_APPLET_LEAVE (TRUE); } if (myData.pTask->iPeriod != myConfig.iRefreshTime) { cd_message ("revert to normal frequency"); gldi_task_change_frequency (myData.pTask, myConfig.iRefreshTime); } //g_print (" --> RSS: '%s'\n", myData.cTaskBridge); xmlDocPtr doc = xmlParseMemory (pSharedMemory->cTaskBridge, strlen (pSharedMemory->cTaskBridge)); g_free (pSharedMemory->cTaskBridge); pSharedMemory->cTaskBridge = NULL; if (doc == NULL) { cd_warning ("RSSresader : got invalid XML data"); const gchar *cErrorMessage = D_("Invalid data (invalid RSS/Atom feed?)"); _insert_error_message (myApplet, cErrorMessage); if (myDesklet) { cd_applet_update_my_icon (myApplet); } g_free (myData.PrevFirstTitle); myData.PrevFirstTitle = NULL; myData.bUpdateIsManual = FALSE; CD_APPLET_LEAVE (TRUE); } xmlNodePtr rss = xmlDocGetRootElement (doc); if (rss == NULL || (xmlStrcmp (rss->name, BAD_CAST "rss") != 0 && xmlStrcmp (rss->name, BAD_CAST "feed") != 0 && xmlStrcmp (rss->name, BAD_CAST "RDF") != 0)) { cd_warning ("RSSresader : got invalid XML data"); ///xmlCleanupParser (); xmlFreeDoc (doc); const gchar *cErrorMessage = D_("Invalid data (invalid RSS/Atom feed?)"); _insert_error_message (myApplet, cErrorMessage); if (myDesklet) { cd_applet_update_my_icon (myApplet); } g_free (myData.PrevFirstTitle); myData.PrevFirstTitle = NULL; myData.bUpdateIsManual = FALSE; CD_APPLET_LEAVE (TRUE); } // on extrait chaque item. GList *pNewItemList = NULL; CDRssItem *pItem = g_new0 (CDRssItem, 1); // on commence au debut de la liste (c'est le titre). pNewItemList = g_list_prepend (pNewItemList, pItem); if (myConfig.cUserTitle != NULL) pItem->cTitle = g_strdup (myConfig.cUserTitle); // ne sera pas ecrase par les donnees du flux. if (xmlStrcmp (rss->name, BAD_CAST "rss") == 0) // RSS { xmlAttrPtr attr = xmlHasProp (rss, BAD_CAST "version"); if (attr && attr->children) { cd_debug ("RSS version : %s", attr->children->content); } xmlNodePtr channel; for (channel = rss->children; channel != NULL; channel = channel->next) { if (xmlStrcmp (channel->name, BAD_CAST "channel") == 0) { pNewItemList = _parse_rss_item (channel, pItem, pNewItemList); // on parse le channel comme un item, ce qui fait que le titre du flux est considere comme un simple item. break; // un seul channel. } } } else if (xmlStrcmp (rss->name, BAD_CAST "RDF") == 0) // RDF { pNewItemList = _parse_rss_item (rss, pItem, pNewItemList); // on parse le premier groupe "channel" comme un item, ce qui fait que le titre du flux est considere comme un simple item. } else // Atom { xmlNodePtr feed = rss; gchar *cBaseUrl = NULL; // on recupere la base de l'URL, pour le cas ou les link seraient exprimes relativement a elle. gchar *str = g_strstr_len(myConfig.cUrl, 10, "://"); if (str) { str = strchr (str + 3, '/'); if (str) cBaseUrl = g_strndup (myConfig.cUrl, (gpointer)str-(gpointer)myConfig.cUrl); } pNewItemList = _parse_atom_item (feed, pItem, pNewItemList, cBaseUrl); // on parse le feed comme un item, ce qui fait que le titre du flux est considere comme un simple item. g_free (cBaseUrl); } pNewItemList = g_list_reverse (pNewItemList); xmlFreeDoc (doc); // ne pas utiliser xmlCleanupParser dans un thread ! // si aucune donnee, on l'affiche et on quitte. if (pNewItemList == NULL) { cd_debug ("RSS: aucune donnee"); const gchar *cErrorMessage = D_("No data"); _insert_error_message (myApplet, cErrorMessage); if (myDesklet) { cd_applet_update_my_icon (myApplet); } g_free (myData.PrevFirstTitle); myData.PrevFirstTitle = NULL; myData.bUpdateIsManual = FALSE; CD_APPLET_LEAVE (TRUE); } // si on est arrive a ce point, c'est qu'il n'y a pas eu d'erreur. // on vide l'ancienne liste d'items. cd_rssreader_free_item_list (myApplet); myData.pItemList = pNewItemList; // on met a jour le titre. if (myIcon->cName == NULL) // il faut mettre a jour le titre { if (myDock && myConfig.cUserTitle == NULL) // en mode desklet inutile, le titre sera redessine avec le reste. { pItem = myData.pItemList->data; if (pItem != NULL && pItem->cTitle != NULL) CD_APPLET_SET_NAME_FOR_MY_ICON (pItem->cTitle); } } // si aucun changement, on le signale, et si aucune erreur precedente, on quitte. pItem = (myData.pItemList && myData.pItemList->next ? myData.pItemList->next->data : NULL); gchar *cFirstTitle = (pItem ? pItem->cTitle : NULL); if (! cairo_dock_strings_differ (myData.PrevFirstTitle, cFirstTitle)) { cd_debug ("RSS: aucune modif"); if (myData.bUpdateIsManual) // L'update a ete manuel -> On affiche donc un dialogue meme s'il n'y a pas eu de changement { gldi_dialogs_remove_on_icon (myIcon); gldi_dialog_show_temporary_with_icon (D_("No modification"), myIcon, myContainer, 2000, // Suffisant vu que la MaJ est manuelle myDock ? "same icon" : MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE); myData.bUpdateIsManual = FALSE; } if (! myData.bError) CD_APPLET_LEAVE (TRUE); } // on dessine le texte. if (myDesklet) { cd_applet_update_my_icon (myApplet); } // on avertit l'utilisateur. if (myData.PrevFirstTitle != NULL && myConfig.iNotificationType != 0) { if (myConfig.iNotificationType != 1) { gldi_dialogs_remove_on_icon (myIcon); gldi_dialog_show_temporary_with_icon (D_("This RSS feed has been modified..."), myIcon, myContainer, 1000*myConfig.iNotificationDuration, myDock ? "same icon" : MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE); } if (myConfig.iNotificationType != 2) { CD_APPLET_DEMANDS_ATTENTION (myConfig.cNotificationAnimation, 3); /// myConfig.iNotificationDuration ?... } } g_free (myData.PrevFirstTitle); myData.PrevFirstTitle = g_strdup (cFirstTitle); myData.bUpdateIsManual = FALSE; myData.bError = FALSE; CD_APPLET_LEAVE (TRUE); }
static gboolean _extract_metadata (GHashTable *pMetadata) { gboolean bTrackHasChanged = FALSE; GValue *v; const gchar *str = NULL; v = g_hash_table_lookup (pMetadata, "mpris:trackid"); // a string or a dbus object path that uniquely identifies the track within the scope of the playlist if (v != NULL) { if (G_VALUE_HOLDS (v, DBUS_TYPE_G_OBJECT_PATH)) // now this attribute should be of D-Bus type "o" str = (gchar*) g_value_get_boxed (v); else if (G_VALUE_HOLDS_STRING (v)) // but can be a string... e.g. with Rhythmbox str = g_value_get_string (v); bTrackHasChanged = _is_a_new_track (str); } v = g_hash_table_lookup (pMetadata, "mpris:length"); // length of the track, in microseconds (signed 64-bit integer) if (v != NULL) { if (G_VALUE_HOLDS_INT64 (v)) // should be a int64 myData.iSongLength = g_value_get_int64 (v) / 1000000; else if (G_VALUE_HOLDS_INT (v)) // but some players doesn't respect that... maybe a limitation? myData.iSongLength = g_value_get_int (v) / 1000000; else cd_warning ("Length has a wrong type"); cd_debug ("Length: %d", myData.iSongLength); } gchar *cOldArtist = myData.cArtist; myData.cArtist = NULL; v = (GValue *) g_hash_table_lookup(pMetadata, "xesam:artist"); if (v != NULL && G_VALUE_HOLDS(v, G_TYPE_STRV)) { gchar **artists = g_value_get_boxed(v); if (artists != NULL) myData.cArtist = g_strjoinv (NULL, artists); } cd_message (" cArtist <- %s", myData.cArtist); // maybe the user has renamed the tags of the current song... if (! bTrackHasChanged && cairo_dock_strings_differ (myData.cArtist, cOldArtist)) bTrackHasChanged = TRUE; g_free (cOldArtist); g_free (myData.cAlbum); myData.cAlbum = NULL; v = (GValue *) g_hash_table_lookup(pMetadata, "xesam:album"); if (v != NULL && G_VALUE_HOLDS_STRING(v)) { str = g_value_get_string(v); if (str && *str != '\0') myData.cAlbum = g_strdup (str); } cd_message (" cAlbum <- %s", myData.cAlbum); gchar *cOldTitle = myData.cTitle; myData.cTitle = NULL; v = (GValue *) g_hash_table_lookup(pMetadata, "xesam:title"); if (v != NULL && G_VALUE_HOLDS_STRING(v)) { str = g_value_get_string(v); if (str && *str != '\0') myData.cTitle = g_strdup (str); } cd_message (" cTitle <- %s", myData.cTitle); /* some players doesn't support (well) the trackid. Even if this is not our * problem, it can be interesting to also check if the title has changed. */ if (! bTrackHasChanged && cairo_dock_strings_differ (myData.cTitle, cOldTitle)) bTrackHasChanged = TRUE; g_free (cOldTitle); g_free (myData.cPlayingUri); myData.cPlayingUri = NULL; v = (GValue *) g_hash_table_lookup(pMetadata, "xesam:url"); if (!v) v = (GValue *) g_hash_table_lookup(pMetadata, "xesam:uri"); if (v != NULL && G_VALUE_HOLDS_STRING(v)) { str = g_value_get_string(v); if (str && *str != '\0') myData.cPlayingUri = g_strdup (str); } cd_message (" cUri <- %s", myData.cPlayingUri); myData.iTrackNumber = 0; // not really useful, it's the track-number in the album. v = (GValue *) g_hash_table_lookup(pMetadata, "xesam:trackNumber"); if (v != NULL && G_VALUE_HOLDS_INT(v)) { myData.iTrackNumber = g_value_get_int (v); } cd_message (" iTrackNumber <- %d", myData.iTrackNumber); const gchar *cCoverPath = NULL; v = g_hash_table_lookup(pMetadata, "mpris:artUrl"); if (v != NULL && G_VALUE_HOLDS_STRING(v)) { cCoverPath = g_value_get_string(v); } cd_musicplayer_set_cover_path (cCoverPath); // do it at the end (we have to know the artist and the album if (cCoverPath == NULL)) /// we miss iTrackListIndex and tracklist-length ... return bTrackHasChanged; }
static void _manage_event_on_drive (CairoDockFMEventType iEventType, const gchar *cBaseURI, GList *pIconsList, GldiContainer *pContainer, GldiModuleInstance *myApplet) { gchar *cURI = (g_strdup (cBaseURI)); cairo_dock_remove_html_spaces (cURI); cd_debug (" * event %d on '%s'", iEventType, cURI); switch (iEventType) { case CAIRO_DOCK_FILE_DELETED : // a mount point has been disconnected { Icon *pConcernedIcon = cairo_dock_get_icon_with_base_uri (pIconsList, cURI); if (pConcernedIcon == NULL) // search by name { pConcernedIcon = cairo_dock_get_icon_with_name (pIconsList, cURI); } if (pConcernedIcon == NULL) { cd_warning (" an unknown mount point was removed"); return ; } //g_print (" %s will be removed\n", pConcernedIcon->cName); CD_APPLET_REMOVE_ICON_FROM_MY_ICONS_LIST (pConcernedIcon); g_free (myData.cLastDeletedUri); myData.cLastDeletedUri = g_strdup (cURI); } break ; case CAIRO_DOCK_FILE_CREATED : // a mount point has been connected { //\_______________________does it already exist? Icon *pSameIcon = cairo_dock_get_icon_with_base_uri (pIconsList, cURI); if (pSameIcon != NULL) { cd_warning ("this mount point (%s) already exists.", pSameIcon->cName); return; // do nothing, certainly an useless/double signal } //\_______________________ create a new icon Icon *pNewIcon = cairo_dock_fm_create_icon_from_URI (cURI, pContainer, CAIRO_DOCK_FM_SORT_BY_NAME); if (pNewIcon == NULL) { cd_warning ("couldn't create an icon for this mount point"); return ; } pNewIcon->iGroup = CD_DRIVE_GROUP; //\_______________________ place it at the right position (by name) cd_shortcuts_set_icon_order_by_name (pNewIcon, pIconsList); cd_debug (" new drive : %s, %s", pNewIcon->cName, pNewIcon->cCommand); //\_______________________ added in the list CD_APPLET_ADD_ICON_IN_MY_ICONS_LIST (pNewIcon); _init_disk_usage (pNewIcon, myApplet); if (pNewIcon->cCommand) { cd_shortcuts_add_progress_bar (pNewIcon, myApplet); cd_shortcuts_display_disk_usage (pNewIcon, myApplet); } //\_______________________ display a notification gboolean bIsMounted = FALSE; gchar *cUri = cairo_dock_fm_is_mounted (pNewIcon->cBaseURI, &bIsMounted); g_free (cUri); gldi_dialog_show_temporary_with_icon_printf ( bIsMounted ? D_("%s is now mounted") : D_("%s has been connected"), pNewIcon, pContainer, 4000, NULL, // it's icon is not already loaded pNewIcon->cName); g_free (myData.cLastCreatedUri); myData.cLastCreatedUri = g_strdup (cURI); } break ; case CAIRO_DOCK_FILE_MODIFIED : // a mount point has been (un)mounted { //\_______________________ search the right icon Icon *pConcernedIcon = cairo_dock_get_icon_with_base_uri (pIconsList, cURI); if (pConcernedIcon == NULL) // search by using the name { pConcernedIcon = cairo_dock_get_icon_with_name (pIconsList, cURI); } if (pConcernedIcon == NULL) { cd_warning (" an unknown mount point was modified"); return ; } cd_debug (" %s is modified (%s)", pConcernedIcon->cName, pConcernedIcon->cCommand); //\_______________________ grab current info Icon *pNewIcon = cairo_dock_fm_create_icon_from_URI (cURI, pContainer, CAIRO_DOCK_FM_SORT_BY_NAME); if (pNewIcon == NULL) { cd_warning ("couldn't create an icon for this mount point"); return ; } pNewIcon->iGroup = CD_DRIVE_GROUP; //\_______________________ replace the icon if smthg has changed if (cairo_dock_strings_differ (pConcernedIcon->cName, pNewIcon->cName) || cairo_dock_strings_differ (pConcernedIcon->cFileName, pNewIcon->cFileName)) { //g_print (" '%s' -> '%s'\n'%s' -> '%s'\n", pConcernedIcon->cName, pNewIcon->cName, pConcernedIcon->cFileName, pNewIcon->cFileName); CD_APPLET_REMOVE_ICON_FROM_MY_ICONS_LIST (pConcernedIcon); pIconsList = CD_APPLET_MY_ICONS_LIST; cd_shortcuts_set_icon_order_by_name (pNewIcon, pIconsList); CD_APPLET_ADD_ICON_IN_MY_ICONS_LIST (pNewIcon); _init_disk_usage (pNewIcon, myApplet); if (pNewIcon->cCommand) { cd_shortcuts_add_progress_bar (pNewIcon, myApplet); } // pConcernedIcon has been distroyed, assigned the new one to display a dialogue just after pConcernedIcon = pNewIcon; } else { gldi_object_unref (GLDI_OBJECT (pNewIcon)); pNewIcon = NULL; } cd_shortcuts_display_disk_usage (pConcernedIcon, myApplet); //\_______________________ display a notification gldi_dialogs_remove_on_icon (pConcernedIcon); // avoid multiple dialogues gboolean bIsMounted = FALSE; gchar *cUri = cairo_dock_fm_is_mounted (pConcernedIcon->cBaseURI, &bIsMounted); g_free (cUri); gldi_dialog_show_temporary_with_icon_printf ( bIsMounted ? D_("%s is now mounted") : D_("%s is now unmounted"), pConcernedIcon, pContainer, 4000, "same icon", // it's possible to not have the right icon, not so important pConcernedIcon->cName); // disk has been unmounted but a icon is needed if (! bIsMounted && pNewIcon == NULL) { CDDiskUsage *pDiskUsage = CD_APPLET_GET_MY_ICON_DATA (pConcernedIcon); if (pDiskUsage != NULL) { if (pDiskUsage->iTotal != 0) { pDiskUsage->iTotal = 0; pDiskUsage->iAvail = 0; // remove the quick-info because it has been unmounted gldi_icon_set_quick_info (pConcernedIcon, NULL); } } } } break ; case CAIRO_DOCK_NB_EVENT_ON_FILES : break ; } g_free (cURI); }
void cd_musicplayer_set_cover_path (const gchar *cGivenCoverPath) { if (! myConfig.bEnableCover) // cover not welcome => abort the mission. { myData.cover_exist = FALSE; return; } if (myData.cCoverPath && ! cairo_dock_strings_differ (myData.cCoverPath, cGivenCoverPath)) // cover has not changed => nothing to do (if we are checking for it, keep doing). { return; } cd_debug ("%s (%s -> %s)", __func__, myData.cCoverPath, cGivenCoverPath); g_free (myData.cPreviousCoverPath); myData.cPreviousCoverPath = myData.cCoverPath; // remember the previous cover. myData.cCoverPath = NULL; if (cGivenCoverPath != NULL) // we got something from the service, check it. { if (strncmp (cGivenCoverPath, "file://", 7) == 0) // local URI { myData.cCoverPath = g_filename_from_uri (cGivenCoverPath, NULL, NULL); } else // local file or remote adress. { myData.cCoverPath = g_strdup (cGivenCoverPath); } if (myData.cCoverPath != NULL && cairo_dock_strings_differ (myData.cCoverPath, myData.cPreviousCoverPath)) // cover is valid and different from the previous one { _reset_cover_state (); if (! g_file_test (myData.cCoverPath, G_FILE_TEST_EXISTS)) // file does not exist, re-try a few times. { myData.iSidCheckCover = g_timeout_add_seconds (1, (GSourceFunc)_check_cover_file_exists, NULL); } else // file exists, check its size until it's constant { myData.iSidCheckCover = g_timeout_add_seconds (1, (GSourceFunc)_check_cover_file_size, NULL); } } } else // no data from the service, search by ourselves. { myData.cCoverPath = _find_cover_in_common_dirs (); if (myData.cCoverPath != NULL && cairo_dock_strings_differ (myData.cCoverPath, myData.cPreviousCoverPath)) // cover is valid and different from the previous one. { _reset_cover_state (); if (g_file_test (myData.cCoverPath, G_FILE_TEST_EXISTS)) // cover is already persent on the disk -> check it { myData.iSidCheckCover = g_timeout_add_seconds (1, (GSourceFunc)_check_cover_file_size, NULL); } else // cover is not yet on the disk (cache) -> download it. { if (myConfig.bDownload) { cd_musicplayer_dl_cover (); } } } } }
/* Update the icon on new song / status. */ void cd_musicplayer_update_icon (void) { cd_message ("%s (uri : %s / title : %s)", __func__, myData.cPlayingUri, myData.cTitle); if (myData.cPlayingUri != NULL || myData.cTitle != NULL) { if (myData.iPlayingStatus == PLAYER_PLAYING || myData.iPlayingStatus == PLAYER_PAUSED) { // display current song on the label if (myDock) { if ((!myData.cArtist || !myData.cTitle) && myData.cPlayingUri) { gchar *str = strrchr (myData.cPlayingUri, '/'); if (str) str ++; else str = myData.cPlayingUri; CD_APPLET_SET_NAME_FOR_MY_ICON (str); } else CD_APPLET_SET_NAME_FOR_MY_ICON_PRINTF ("%s - %s", myData.cArtist ? myData.cArtist : D_("Unknown artist"), myData.cTitle ? myData.cTitle : D_("Unknown title")); } // display current track on the quick-info. if (myConfig.iQuickInfoType == MY_APPLET_TRACK && myData.iTrackListLength > 0 && myData.iTrackListIndex > 0) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%s%d", (myDesklet && myDesklet->container.iWidth >= 64 ? D_("Track") : ""), myData.iTrackListIndex); // inutile de redessiner notre icone, ce sera fait plus loin. } else { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); } // animate the icon and pop-up the dialog. if (myData.iPlayingStatus == PLAYER_PLAYING) { cd_musicplayer_animate_icon (1); if(myConfig.bEnableDialogs) { cd_musicplayer_popup_info (myConfig.iDialogDuration); } } } /**else { cd_musicplayer_apply_status_surface (PLAYER_STOPPED); CD_APPLET_SET_NAME_FOR_MY_ICON (myData.cTitle ? myData.cTitle : myData.pCurrentHandler ? myData.pCurrentHandler->name : myConfig.cDefaultTitle); }*/ // re-paint the icon if needed. if (myConfig.bEnableCover && myData.cover_exist && myData.cCoverPath != NULL) // cover is available { if (cairo_dock_strings_differ (myData.cCoverPath, myData.cPreviousCoverPath)) // and cover has changed -> apply the new one cd_musiplayer_apply_cover (); } else // no cover -> set the status surface. { if ((myConfig.bEnableCover && myData.cPreviousCoverPath != NULL) // currently a cover is set || myData.pPreviousPlayingStatus != myData.iPlayingStatus) // or the status has changed cd_musicplayer_apply_status_surface (myData.iPlayingStatus); } } else // aucune donnees, c'est soit un probleme soit le lecteur qui s'est ferme. { if (myData.bIsRunning) { cd_musicplayer_apply_status_surface (PLAYER_STOPPED); if (myConfig.cDefaultTitle) { CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.cDefaultTitle); } else if (myData.pCurrentHandler->cDisplayedName != NULL) { CD_APPLET_SET_NAME_FOR_MY_ICON (myData.pCurrentHandler->cDisplayedName); } else { CD_APPLET_SET_NAME_FOR_MY_ICON (myData.pCurrentHandler->name); } } else { cd_musicplayer_apply_status_surface (PLAYER_NONE); if (myConfig.cDefaultTitle) { CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.cDefaultTitle); } else { CD_APPLET_SET_NAME_FOR_MY_ICON (myApplet->pModule->pVisitCard->cTitle); } } CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); } }