static gboolean cd_dustbin_display_result (CDSharedMemory *pSharedMemory) { myData.iMeasure = pSharedMemory->iMeasure; //g_print ("trash measure : %d\n", myData.iMeasure); if (myData.iMeasure == 0) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); if (myData.bDisplayFullIcon) { myData.bDisplayFullIcon = FALSE; CD_APPLET_SET_IMAGE_ON_MY_ICON (myConfig.cEmptyUserImage); } } else { if (! myData.bDisplayFullIcon) { myData.bDisplayFullIcon = TRUE; CD_APPLET_SET_IMAGE_ON_MY_ICON (myConfig.cFullUserImage); } if (myConfig.iQuickInfoType == CD_DUSTBIN_INFO_NB_TRASHES) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%zd%s", myData.iMeasure, (myDesklet ? D_(" trashe(s)") : "")); } else if (myConfig.iQuickInfoType == CD_DUSTBIN_INFO_NB_FILES) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%zd%s", myData.iMeasure, (myDesklet ? D_(" file(s)") : "")); } else if (myConfig.iQuickInfoType == CD_DUSTBIN_INFO_WEIGHT) { CD_APPLET_SET_SIZE_AS_QUICK_INFO (myData.iMeasure); } else // on vire les "..." { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); } } CD_APPLET_REDRAW_MY_ICON; return TRUE; }
void cd_logout_set_timer (void) { time_t t_cur = (time_t) time (NULL); if (myConfig.iShutdownTime > t_cur) { if (myData.iSidTimer == 0) myData.iSidTimer = g_timeout_add_seconds (60, _timer, NULL); _timer (NULL); } else if (myData.iSidTimer != 0) { g_source_remove (myData.iSidTimer); myData.iSidTimer = 0; CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); } }
static gboolean _take_screenshot_countdown (CDScreenshotOptions *pOptions) { if (pOptions->iDelay > 0) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%d", pOptions->iDelay); CD_APPLET_REDRAW_MY_ICON; pOptions->iDelay --; return TRUE; } else { CD_APPLET_STOP_DEMANDING_ATTENTION; CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); CD_APPLET_REDRAW_MY_ICON; _take_screenshot (pOptions); cd_screenshot_free_options (pOptions); myData.pOptions = NULL; myData.iSidTakeWithDelay = 0; return FALSE; } }
void cd_dustbin_start (GldiModuleInstance *myApplet) { // get the trash folder if not already done. if (myData.cDustbinPath == NULL) myData.cDustbinPath = cairo_dock_fm_get_trash_path (NULL, NULL); // monitor this folder. if (myData.cDustbinPath != NULL) { // try monitoring the trash folder. myData.bMonitoringOK = cairo_dock_fm_add_monitor_full (myData.cDustbinPath, TRUE, NULL, (CairoDockFMMonitorCallback) cd_dustbin_on_file_event, myApplet); if (! myData.bMonitoringOK) { cd_message ("dustbin : can't monitor trash folder\n we'll check it periodically"); } // measure the trash content once, to get the initial stats. CDSharedMemory *pSharedMemory = g_new0 (CDSharedMemory, 1); pSharedMemory->cDustbinPath = g_strdup (myData.cDustbinPath); pSharedMemory->iQuickInfoType = myConfig.iQuickInfoType; myData.pTask = gldi_task_new_full (myData.bMonitoringOK ? 0 : 10, // si le monitoring de fichiers n'est pas disponible, on execute la tache periodiquement. (GldiGetDataAsyncFunc) cd_dustbin_measure_trash, (GldiUpdateSyncFunc) cd_dustbin_display_result, (GFreeFunc) _free_shared_memory, pSharedMemory); pSharedMemory->bDiscard = &myData.pTask->bDiscard; gldi_task_launch (myData.pTask); // on la lance meme si on n'affiche rien, pour savoir si le nombre de fichiers est nul ou non. if (myConfig.iQuickInfoType == CD_DUSTBIN_INFO_WEIGHT || myConfig.iQuickInfoType == CD_DUSTBIN_INFO_NB_FILES) // operation potentiellement longue => on met un petit message discret. { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%s...", (myDesklet ? D_("calculating") : "")); } } else // no trash, set a N/A icon. { CD_APPLET_SET_IMAGE_ON_MY_ICON (myConfig.cEmptyUserImage); CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("N/A"); } }
void update_icon(void) { gboolean bNeedRedraw = FALSE; cd_message ("%s (time:%.2f -> %.2f ; charge:%.2f -> %.2f)", __func__, myData.previous_battery_time, myData.battery_time, myData.previous_battery_charge, myData.battery_charge); if(myData.battery_present) { if (myData.previous_battery_time != myData.battery_time) { if(myConfig.quickInfoType == POWER_MANAGER_TIME) { if (myData.battery_time != 0) { CD_APPLET_SET_HOURS_MINUTES_AS_QUICK_INFO (myData.battery_time); } else { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("-:--"); } } else if(myConfig.quickInfoType == POWER_MANAGER_CHARGE) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%d%%", (int)myData.battery_charge); } else { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); } bNeedRedraw = TRUE; myData.previous_battery_time = myData.battery_time; } if (myData.previously_on_battery != myData.on_battery || myData.previous_battery_charge != myData.battery_charge) { if (myData.previously_on_battery != myData.on_battery) { myData.previously_on_battery = myData.on_battery; myData.alerted = FALSE; //On a changé de statut, donc on réinitialise les alertes myData.bCritical = FALSE; } if (myConfig.iDisplayType == CD_POWERMANAGER_GAUGE || myConfig.iDisplayType == CD_POWERMANAGER_GRAPH) { double fPercent = (double) myData.battery_charge / 100.; CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (&fPercent); bNeedRedraw = FALSE; } else if (myConfig.iDisplayType == CD_POWERMANAGER_ICONS) { cd_powermanager_draw_icon_with_effect (myData.on_battery); bNeedRedraw = FALSE; } if(myData.on_battery) { //Alert when battery charge is under a configured value in % if (myData.battery_charge <= myConfig.lowBatteryValue && ! myData.alerted) { cd_powermanager_alert(POWER_MANAGER_CHARGE_LOW); if (myConfig.cSoundPath[POWER_MANAGER_CHARGE_LOW] != NULL) cairo_dock_play_sound (myConfig.cSoundPath[POWER_MANAGER_CHARGE_LOW]); } //Alert when battery charge is under 4% if (myData.battery_charge <= 4 && ! myData.bCritical) { myData.bCritical = TRUE; cd_powermanager_alert (POWER_MANAGER_CHARGE_CRITICAL); if (myConfig.cSoundPath[POWER_MANAGER_CHARGE_CRITICAL] != NULL) cairo_dock_play_sound (myConfig.cSoundPath[POWER_MANAGER_CHARGE_CRITICAL]); } //Embleme sur notre icône CD_APPLET_DRAW_EMBLEM (CAIRO_DOCK_EMBLEM_BLANK, CAIRO_DOCK_EMBLEM_MIDDLE); } else { //Alert when battery is charged if(myData.battery_charge == 100 && ! myData.alerted) cd_powermanager_alert (POWER_MANAGER_CHARGE_FULL); CD_APPLET_DRAW_EMBLEM (CAIRO_DOCK_EMBLEM_CHARGE, CAIRO_DOCK_EMBLEM_MIDDLE); } myData.previously_on_battery = myData.on_battery; myData.previous_battery_charge = myData.battery_charge; } } else { CD_APPLET_SET_LOCAL_IMAGE_ON_MY_ICON ("sector.svg"); bNeedRedraw = TRUE; } if (bNeedRedraw) CD_APPLET_REDRAW_MY_ICON; }
/* 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); } }
static void _weather_draw_current_conditions (CairoDockModuleInstance *myApplet) { g_return_if_fail (myDrawContext != NULL); if (myConfig.bCurrentConditions || myData.bErrorRetrievingData) { cd_message (" chargement de l'icone meteo (%x)", myApplet); if (myConfig.bDisplayTemperature && myData.currentConditions.cTemp != NULL/** && myConfig.iDeskletRenderer != MY_DESKLET_MAIN_ICON*/) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%s%s", myData.currentConditions.cTemp, myData.units.cTemp); } else { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL); } g_free (myIcon->acFileName); if (myData.bErrorRetrievingData) { myIcon->acFileName = g_strdup_printf ("%s/na.png", myConfig.cThemePath); if (! g_file_test (myIcon->acFileName, G_FILE_TEST_EXISTS)) { g_free (myIcon->acFileName); myIcon->acFileName = g_strdup_printf ("%s/na.svg", myConfig.cThemePath); if (! g_file_test (myIcon->acFileName, G_FILE_TEST_EXISTS)) { g_free (myIcon->acFileName); myIcon->acFileName = g_strdup (MY_APPLET_SHARE_DATA_DIR"/broken.png"); } } } else { myIcon->acFileName = g_strdup_printf ("%s/%s.png", myConfig.cThemePath, myData.currentConditions.cIconNumber); if (! g_file_test (myIcon->acFileName, G_FILE_TEST_EXISTS)) { g_free (myIcon->acFileName); myIcon->acFileName = g_strdup_printf ("%s/%s.svg", myConfig.cThemePath, myData.currentConditions.cIconNumber); } } CD_APPLET_SET_IMAGE_ON_MY_ICON (myIcon->acFileName); } else { CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE; } /**if (myConfig.iDeskletRenderer == MY_DESKLET_MAIN_ICON) { char *cTemp = NULL; if (myConfig.bDisplayTemperature && myData.currentConditions.cTemp != NULL) cTemp = g_strdup_printf ("%s%s", myData.currentConditions.cTemp, myData.units.cTemp); char *cConditions = NULL; if (myData.currentConditions.cWeatherDescription != NULL) cConditions = g_strdup (myData.currentConditions.cWeatherDescription); gpointer data[2] = {cConditions, cTemp}; cairo_dock_render_desklet_with_new_data (myDesklet, (CairoDeskletRendererDataPtr) data); if (cConditions != NULL) g_free (cConditions); if (cTemp != NULL) g_free (cTemp); }*/ }
void cd_mail_init_accounts(CairoDockModuleInstance *myApplet) { if (myData.pMailAccounts == NULL) return ; g_print ("%s (%d comptes)\n", __func__, myData.pMailAccounts->len); //\_______________________ On initialise chaque compte. CDMailAccount *pMailAccount; GList *pIconList = NULL; Icon *pIcon; int iNbIcons = 0; int r; guint i; for (i = 0; i < myData.pMailAccounts->len; i ++) { pMailAccount = g_ptr_array_index (myData.pMailAccounts, i); if( !pMailAccount ) continue; // init this account switch (pMailAccount->driver) { case POP3_STORAGE: r = pop3_mailstorage_init(pMailAccount->storage, pMailAccount->server, pMailAccount->port, NULL, pMailAccount->connection_type, pMailAccount->auth_type, pMailAccount->user, pMailAccount->password, myData.cWorkingDirPath!=NULL?TRUE:FALSE /*cached*/, myData.cWorkingDirPath /*cache_directory*/, myData.cWorkingDirPath /*flags_directory*/); break; case IMAP_STORAGE: r = imap_mailstorage_init(pMailAccount->storage, pMailAccount->server, pMailAccount->port, NULL, pMailAccount->connection_type, IMAP_AUTH_TYPE_PLAIN, pMailAccount->user, pMailAccount->password, myData.cWorkingDirPath!=NULL?TRUE:FALSE /*cached*/, myData.cWorkingDirPath /*cache_directory*/); break; case NNTP_STORAGE: r = nntp_mailstorage_init(pMailAccount->storage, pMailAccount->server, pMailAccount->port, NULL, pMailAccount->connection_type, NNTP_AUTH_TYPE_PLAIN, pMailAccount->user, pMailAccount->password, myData.cWorkingDirPath!=NULL?TRUE:FALSE /*cached*/, myData.cWorkingDirPath /*cache_directory*/, myData.cWorkingDirPath /*flags_directory*/); break; case MBOX_STORAGE: r = mbox_mailstorage_init(pMailAccount->storage, pMailAccount->path, myData.cWorkingDirPath!=NULL?TRUE:FALSE /*cached*/, myData.cWorkingDirPath /*cache_directory*/, myData.cWorkingDirPath /*flags_directory*/); break; case MH_STORAGE: r = mh_mailstorage_init(pMailAccount->storage, pMailAccount->path, myData.cWorkingDirPath!=NULL?TRUE:FALSE /*cached*/, myData.cWorkingDirPath /*cache_directory*/, myData.cWorkingDirPath /*flags_directory*/); break; case MAILDIR_STORAGE: r = maildir_mailstorage_init(pMailAccount->storage, pMailAccount->path, myData.cWorkingDirPath!=NULL?TRUE:FALSE /*cached*/, myData.cWorkingDirPath /*cache_directory*/, myData.cWorkingDirPath /*flags_directory*/); break; case FEED_STORAGE: r = feed_mailstorage_init(pMailAccount->storage, pMailAccount->path, myData.cWorkingDirPath!=NULL?TRUE:FALSE /*cached*/, myData.cWorkingDirPath /*cache_directory*/, myData.cWorkingDirPath /*flags_directory*/); break; default : r = -1; } // add an icon for this account. if (myData.pMailAccounts->len == 1) // 1 seul compte { pIcon = myIcon; } else { _add_icon (pMailAccount); } iNbIcons ++; // if all is OK, then set a timeout for this mail account if (r == MAIL_NO_ERROR) { CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("..."); pMailAccount->pAccountMailTimer = cairo_dock_new_task (pMailAccount->timeout * 60, (CairoDockGetDataAsyncFunc) cd_mail_get_folder_data, (CairoDockUpdateSyncFunc) cd_mail_update_account_status, pMailAccount); cairo_dock_launch_task (pMailAccount->pAccountMailTimer); } else { cd_warning ("mail : the mail account %s couldn't be initialized !", pMailAccount->name); CairoContainer *pContainer = (myData.pMailAccounts->len == 1 ? myContainer : CD_APPLET_MY_ICONS_LIST_CONTAINER); cairo_dock_set_quick_info (myDrawContext, "N/A", pIcon, cairo_dock_get_max_scale (pContainer)); } } //\_______________________ On efface l'ancienne liste. CD_APPLET_DELETE_MY_ICONS_LIST; //\_______________________ On charge la nouvelle liste. if (myData.pMailAccounts->len > 1) { gpointer pConfig[2] = {GINT_TO_POINTER (FALSE), GINT_TO_POINTER (FALSE)}; CD_APPLET_LOAD_MY_ICONS_LIST (pIconList, myConfig.cRenderer, (iNbIcons > 1 ? "Caroussel" : "Simple"), (iNbIcons > 1 ? pConfig : NULL)); } //\_______________ On dessine l'icone principale initialement. CD_APPLET_SET_IMAGE_ON_MY_ICON (myConfig.cNoMailUserImage); if (iNbIcons > 0) CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("..."); }
gboolean cd_sysmonitor_update_from_data (CairoDockModuleInstance *myApplet) { static double s_fValues[CD_SYSMONITOR_NB_MAX_VALUES]; if ( ! myData.bAcquisitionOK) { cd_warning ("One or more datas couldn't be retrieved"); CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("N/A"); // plus discret qu'une bulle de dialogue. if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_LABEL) CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.defaultTitle); memset (s_fValues, 0, sizeof (s_fValues)); CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (s_fValues); } else { if (! myData.bInitialized) { if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_ICON) CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (myDock ? "..." : D_("Loading")); memset (s_fValues, 0, sizeof (s_fValues)); CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (s_fValues); } else { // Copier les donnes en memoire partagee... if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_ICON || (myDock && myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_LABEL)) // on affiche les valeurs soit en info-rapide, soit sur l'etiquette en mode dock. { gboolean bOneLine = (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_LABEL); GString *sInfo = g_string_new (""); if (myConfig.bShowCpu) { g_string_printf (sInfo, (myData.fCpuPercent < 10 ? "%s%.1f%%%s" : "%s%.0f%%%s"), (myDesklet ? "CPU:" : ""), myData.fCpuPercent, (bOneLine ? " - " : "\n")); } if (myConfig.bShowRam) { g_string_append_printf (sInfo, (myData.fRamPercent < 10 ? "%s%.1f%%%s" : "%s%.0f%%%s"), (myDesklet ? "RAM:" : ""), myData.fRamPercent, (bOneLine ? " - " : "\n")); } if (myConfig.bShowSwap) { g_string_append_printf (sInfo, (myData.fSwapPercent < 10 ? "%s%.1f%%%s" : "%s%.0f%%%s"), (myDesklet ? "SWAP:" : ""), myData.fSwapPercent, (bOneLine ? " - " : "\n")); } if (myConfig.bShowNvidia) { g_string_append_printf (sInfo, "%s%d°C%s", (myDesklet ? "GPU:" : ""), myData.iGPUTemp, (bOneLine ? " - " : "\n")); } sInfo->str[sInfo->len-(bOneLine?3:1)] = '\0'; if (bOneLine) CD_APPLET_SET_NAME_FOR_MY_ICON (sInfo->str); else CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (sInfo->str); g_string_free (sInfo, TRUE); } if (myData.bNeedsUpdate || myConfig.iDisplayType == CD_SYSMONITOR_GRAPH) { int i = 0; if (myConfig.bShowCpu) { s_fValues[i++] = (double) myData.fCpuPercent / 100; } if (myConfig.bShowRam) { s_fValues[i++] = myData.fRamPercent / 100; } if (myConfig.bShowSwap) { s_fValues[i++] = (double) (myData.swapTotal ? (myConfig.bShowFreeMemory ? myData.swapFree : myData.swapUsed) / myData.swapTotal : 0.); } if (myConfig.bShowNvidia) { s_fValues[i++] = myData.fGpuTempPercent / 100; if (myData.bAlerted && myData.iGPUTemp < myConfig.iAlertLimit) myData.bAlerted = FALSE; //On réinitialise l'alerte quand la température descend en dessou de la limite. if (!myData.bAlerted && myData.iGPUTemp >= myConfig.iAlertLimit) cd_nvidia_alert (myApplet); } CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (s_fValues); } } } return myData.bAcquisitionOK; }