Commit 586cd55c authored by Ziirish's avatar Ziirish

cleaning code (part 1)

parent f069e8f6
......@@ -40,14 +40,16 @@ gboolean run = FALSE;
//static CidMeasure *pMeasureTimer = NULL;
//extern gboolean bCurrentlyDownloading, bCurrentlyDownloadingXML;
///dcop amarok playlist addMediaList [ "file:///home/benjamin/Music/aboutagirl.mp3" ]
///dcop amarok playlist addMediaList
///[ "file:///home/benjamin/Music/aboutagirl.mp3" ]
gboolean
get_amarock_musicData (CidMainContainer **pCid)
{
CidMainContainer *cid = *pCid;
CIDError *error = NULL;
gint state = cid_console_get_int_with_error_full("dcop amarok player status",-1,&error);
gint state = cid_console_get_int_with_error_full(
"dcop amarok player status",-1,&error);
musicData.opening = TRUE;
......@@ -86,8 +88,10 @@ get_amarock_musicData (CidMainContainer **pCid)
gArtist = cid_console_get_string ("dcop amarok player artist");
gAlbum = cid_console_get_string ("dcop amarok player album");
gTitle = cid_console_get_string ("dcop amarok player title");
gPlayingURI = cid_console_get_string ("dcop amarok player encodedURL");
gCoverURI = cid_console_get_string ("dcop amarok player coverImage");
gPlayingURI = cid_console_get_string (
"dcop amarok player encodedURL");
gCoverURI = cid_console_get_string (
"dcop amarok player coverImage");
g_free (musicData.playing_cover);
if (gCoverURI == NULL)
......@@ -95,7 +99,8 @@ get_amarock_musicData (CidMainContainer **pCid)
else
musicData.playing_cover = g_strdup (gCoverURI);
if (musicData.playing_uri != NULL && strcmp (musicData.playing_uri,gPlayingURI)==0)
if (musicData.playing_uri != NULL &&
strcmp (musicData.playing_uri,gPlayingURI)==0)
{
g_free (gArtist);
g_free (gAlbum);
......@@ -116,7 +121,12 @@ get_amarock_musicData (CidMainContainer **pCid)
run = TRUE;
cid_info ("\nartist : %s\nalbum : %s\ntitle : %s\nsong uri : %s\ncover uri : %s",gArtist,gAlbum,gTitle,gPlayingURI,gCoverURI);
cid_info ("\nartist : %s\n\
album : %s\n\
title : %s\n\
song uri : %s\n\
cover uri : %s",
gArtist,gAlbum,gTitle,gPlayingURI,gCoverURI);
g_free (gArtist);
g_free (gAlbum);
g_free (gTitle);
......@@ -125,29 +135,6 @@ get_amarock_musicData (CidMainContainer **pCid)
return TRUE;
}
/*
gboolean
cid_download_amarok_cover (gpointer data)
{
cid->runtime->iCheckIter++;
if (cid->runtime->iCheckIter > cid->config->iTimeToWait)
{
if (pMeasureTimer)
{
if (cid_measure_is_running(pMeasureTimer))
cid_stop_measure_timer(pMeasureTimer);
if (cid_measure_is_active(pMeasureTimer))
cid_free_measure_timer(pMeasureTimer);
}
pMeasureTimer = cid_new_measure_timer (2 SECONDES, NULL, NULL, (CidUpdateTimerFunc) _cid_proceed_download_cover, NULL);
cid_launch_measure (pMeasureTimer);
return FALSE;
}
return TRUE;
}
*/
gchar *
cid_check_amarok_cover_exists (CidMainContainer **pCid, gchar *cURI)
{
......@@ -158,11 +145,15 @@ cid_check_amarok_cover_exists (CidMainContainer **pCid, gchar *cURI)
if (g_strcasecmp(cSplitedURI[0],"nocover")==0)
{
g_free (cRet);
cRet = cid_db_search_cover (pCid, musicData.playing_artist, musicData.playing_album);
cRet = cid_db_search_cover (pCid,
musicData.playing_artist,
musicData.playing_album);
if (cRet == NULL)
{
cid->runtime->iCheckIter = 0;
g_timeout_add (1000, (GSourceFunc) _check_cover_is_present, pCid);
g_timeout_add (1000,
(GSourceFunc) _check_cover_is_present,
pCid);
cRet = g_strdup(cid->config->cDefaultImage);
}
}
......@@ -188,7 +179,9 @@ cid_amarok_cover(CidMainContainer **pCid)
{
if (musicData.playing && musicData.playing_cover != NULL)
{
gchar *cCover = cid_check_amarok_cover_exists(pCid, musicData.playing_cover);
gchar *cCover = cid_check_amarok_cover_exists(
pCid,
musicData.playing_cover);
cid_display_image (cCover);
g_free (cCover);
}
......@@ -205,7 +198,11 @@ void
cid_amarok_pipe (CidMainContainer **pCid, gint iInter)
{
CidMainContainer *cid = *pCid;
cid->runtime->iPipe = g_timeout_add_full (G_PRIORITY_HIGH, iInter,(gpointer) cid_amarok_cover, pCid, NULL);
cid->runtime->iPipe = g_timeout_add_full (G_PRIORITY_HIGH,
iInter,
(gpointer) cid_amarok_cover,
pCid,
NULL);
}
void
......
This diff is collapsed.
......@@ -35,14 +35,14 @@ G_BEGIN_DECLS
* recherche d'image
* @return URI de l'image à afficher
*/
gchar *cid_amarok_2_cover(void);
gchar *cid_amarok_2_cover (void);
/**
* Fonction permettant de se connecter
* au bus de amarok2
* @return VRAI ou FAUX
*/
gboolean amarok_2_dbus_connect_to_bus(void);
gboolean amarok_2_dbus_connect_to_bus (void);
/**
* Fonction permettant de se déconnecter
......@@ -55,25 +55,25 @@ void amarok_2_dbus_disconnect_from_bus (void);
* est lancé ou non
* @return VRAI ou FAUX en fonction
*/
gboolean dbus_detect_amarok_2(void);
gboolean dbus_detect_amarok_2 (void);
/**
* Test si amarok2 joue de la musique ou non
* @return VRAI ou FAUX
*/
gboolean amarok_2_getPlaying(void);
gboolean amarok_2_getPlaying (void);
/**
* renvoie l'URI du fichier en cours de lecture
* @return URI du fichier joué
*/
gchar *amarok_2_getPlayingUri(void);
gchar *amarok_2_getPlayingUri (void);
/**
* récupère l'ensemble des informations disponibles
* sur le fichier joué
*/
void am_getSongInfos(void);
void am_getSongInfos (void);
/**
* Fonction exécutée (automatiquement) au changement
......@@ -82,7 +82,9 @@ void am_getSongInfos(void);
* @param URI du fichier joué
* @param pointeur de données (non utilisé)
*/
void am_onChangeSong(DBusGProxy *player_proxy, GHashTable *data_list, gpointer data);
void am_onChangeSong (DBusGProxy *player_proxy,
GHashTable *data_list,
gpointer data);
/**
* Fonction exécutée (automatiquement) au changement d'état Play/Pause
......@@ -90,7 +92,9 @@ void am_onChangeSong(DBusGProxy *player_proxy, GHashTable *data_list, gpointer d
* @param flag on joue ou non
* @param pointeur de données (non utilisé)
*/
void am_onChangeState(DBusGProxy *player_proxy,GValueArray *status, gpointer data);
void am_onChangeState (DBusGProxy *player_proxy,
GValueArray *status,
gpointer data);
/**
* Fonction exécutée (automatiquement) à chaque changement d'URI
......@@ -99,7 +103,9 @@ void am_onChangeState(DBusGProxy *player_proxy,GValueArray *status, gpointer dat
* @param URI de la nouvelle image
* @param pointeur de données (non utilisé)
*/
void am_onCovertArtChanged(DBusGProxy *player_proxy,const gchar *cImageURI, gpointer data);
void am_onCovertArtChanged (DBusGProxy *player_proxy,
const gchar *cImageURI,
gpointer data);
/**
......
......@@ -28,22 +28,33 @@
///////////////
/// MEASURE ///
///////////////
#define cid_schedule_next_measure(pMeasureTimer) do {\
if (pMeasureTimer->iSidTimer == 0 && pMeasureTimer->iCheckInterval)\
pMeasureTimer->iSidTimer = g_timeout_add (pMeasureTimer->iCheckInterval, (GSourceFunc) _cid_timer, pMeasureTimer); } while (0)
#define cid_schedule_next_measure(pMeasureTimer) \
do { \
if (pMeasureTimer->iSidTimer == 0 && \
pMeasureTimer->iCheckInterval) \
pMeasureTimer->iSidTimer = \
g_timeout_add (pMeasureTimer->iCheckInterval, \
(GSourceFunc) _cid_timer, \
pMeasureTimer); \
} while (0)
#define cid_cancel_next_measure(pMeasureTimer) do {\
if (pMeasureTimer->iSidTimer != 0) {\
g_source_remove (pMeasureTimer->iSidTimer);\
pMeasureTimer->iSidTimer = 0; } } while (0)
#define cid_cancel_next_measure(pMeasureTimer) \
do { \
if (pMeasureTimer->iSidTimer != 0) { \
g_source_remove (pMeasureTimer->iSidTimer); \
pMeasureTimer->iSidTimer = 0; } \
} while (0)
#define cid_perform_measure_update(pMeasureTimer) do {\
gboolean bContinue = pMeasureTimer->update (pMeasureTimer->pUserData);\
if (! bContinue) {\
cid_cancel_next_measure (pMeasureTimer); }\
else {\
pMeasureTimer->iFrequencyState = CID_FREQUENCY_NORMAL;\
cid_schedule_next_measure (pMeasureTimer); } } while (0)
#define cid_perform_measure_update(pMeasureTimer) \
do { \
gboolean bContinue = \
pMeasureTimer->update (pMeasureTimer->pUserData); \
if (! bContinue) { \
cid_cancel_next_measure (pMeasureTimer); } \
else { \
pMeasureTimer->iFrequencyState = CID_FREQUENCY_NORMAL; \
cid_schedule_next_measure (pMeasureTimer); } \
} while (0)
static gboolean
_cid_timer (CidMeasure *pMeasureTimer)
......@@ -68,10 +79,12 @@ _cid_threaded_calculation (CidMeasure *pMeasureTimer)
static gboolean
_cid_check_for_redraw (CidMeasure *pMeasureTimer)
{
int iThreadIsRunning = g_atomic_int_get (&pMeasureTimer->iThreadIsRunning);
int iThreadIsRunning =
g_atomic_int_get (&pMeasureTimer->iThreadIsRunning);
if (! iThreadIsRunning)
{ // le thread a fini.
//\_______________________ On met a jour avec ces nouvelles donnees et on lance/arrete le timer.
//\__ On met a jour avec ces nouvelles donnees et on
//\__ lance/arrete le timer.
cid_perform_measure_update (pMeasureTimer);
pMeasureTimer->iSidTimerRedraw = 0;
......@@ -87,9 +100,18 @@ cid_launch_measure (CidMeasure *pMeasureTimer)
if (pMeasureTimer->read == NULL)
{ // pas de thread, tout est dans la fonction d'update.
cid_perform_measure_update (pMeasureTimer);
} else if (g_atomic_int_compare_and_exchange (&pMeasureTimer->iThreadIsRunning, 0, 1)) { // il etait egal a 0, on lui met 1 et on lance le thread.
}
else if (g_atomic_int_compare_and_exchange (
&pMeasureTimer->iThreadIsRunning,
0,
1))
{ // il etait egal a 0, on lui met 1 et on lance le thread.
GError *erreur = NULL;
GThread* pThread = g_thread_create ((GThreadFunc) _cid_threaded_calculation, pMeasureTimer, FALSE, &erreur);
GThread* pThread =
g_thread_create ((GThreadFunc) _cid_threaded_calculation,
pMeasureTimer,
FALSE,
&erreur);
if (erreur != NULL)
{ // on n'a pas pu lancer le thread.
cid_warning ("%s",erreur->message);
......@@ -98,10 +120,20 @@ cid_launch_measure (CidMeasure *pMeasureTimer)
}
if (pMeasureTimer->iSidTimerRedraw == 0)
pMeasureTimer->iSidTimerRedraw = g_timeout_add (MAX (150, MIN (0.15 * pMeasureTimer->iCheckInterval, 333)), (GSourceFunc) _cid_check_for_redraw, pMeasureTimer);
} else if (pMeasureTimer->iSidTimerRedraw != 0) { // le thread est deja fini.
pMeasureTimer->iSidTimerRedraw =
g_timeout_add (MAX (150,
MIN (
0.15*pMeasureTimer->iCheckInterval,
333)),
(GSourceFunc) _cid_check_for_redraw,
pMeasureTimer);
}
else if (pMeasureTimer->iSidTimerRedraw != 0)
{ // le thread est deja fini.
if (pMeasureTimer->iSidTimerRedraw != 0)
{ // on etait en attente de mise a jour, on fait la mise a jour tout de suite.
{
// on etait en attente de mise a jour,
// on fait la mise a jour tout de suite.
g_source_remove (pMeasureTimer->iSidTimerRedraw);
pMeasureTimer->iSidTimerRedraw = 0;
......@@ -126,11 +158,18 @@ _cid_one_shot_timer (CidMeasure *pMeasureTimer)
void
cid_launch_measure_delayed (CidMeasure *pMeasureTimer, double fDelay)
{
pMeasureTimer->iSidTimerRedraw = g_timeout_add (fDelay, (GSourceFunc) _cid_one_shot_timer, pMeasureTimer);
pMeasureTimer->iSidTimerRedraw =
g_timeout_add (fDelay,
(GSourceFunc) _cid_one_shot_timer,
pMeasureTimer);
}
CidMeasure *
cid_new_measure_timer (int iCheckInterval, CidAquisitionTimerFunc acquisition, CidReadTimerFunc read, CidUpdateTimerFunc update, gpointer pUserData)
cid_new_measure_timer (int iCheckInterval,
CidAquisitionTimerFunc acquisition,
CidReadTimerFunc read,
CidUpdateTimerFunc update,
gpointer pUserData)
{
CidMeasure *pMeasureTimer = g_new0 (CidMeasure, 1);
//if (read != NULL || acquisition != NULL)
......@@ -167,7 +206,8 @@ cid_stop_measure_timer (CidMeasure *pMeasureTimer)
_cid_pause_measure_timer (pMeasureTimer);
//cid_debug ("***on attend que le thread termine...(%d)", g_atomic_int_get (&pMeasureTimer->iThreadIsRunning));
//cid_debug ("***on attend que le thread termine...(%d)",
// g_atomic_int_get (&pMeasureTimer->iThreadIsRunning));
while (g_atomic_int_get (&pMeasureTimer->iThreadIsRunning) == 1)
{
cpt++;
......@@ -203,35 +243,46 @@ cid_measure_is_active (CidMeasure *pMeasureTimer)
gboolean
cid_measure_is_running (CidMeasure *pMeasureTimer)
{
return (pMeasureTimer != NULL && pMeasureTimer->iSidTimerRedraw != 0);
return (pMeasureTimer != NULL &&
pMeasureTimer->iSidTimerRedraw != 0);
}
static void
_cid_restart_timer_with_frequency (CidMeasure *pMeasureTimer, int iNewCheckInterval)
_cid_restart_timer_with_frequency (CidMeasure *pMeasureTimer,
int iNewCheckInterval)
{
gboolean bNeedsRestart = (pMeasureTimer->iSidTimer != 0);
_cid_pause_measure_timer (pMeasureTimer);
if (bNeedsRestart && iNewCheckInterval != 0)
pMeasureTimer->iSidTimer = g_timeout_add (iNewCheckInterval, (GSourceFunc) _cid_timer, pMeasureTimer);
pMeasureTimer->iSidTimer =
g_timeout_add (iNewCheckInterval,
(GSourceFunc) _cid_timer,
pMeasureTimer);
}
void
cid_change_measure_frequency (CidMeasure *pMeasureTimer, int iNewCheckInterval)
cid_change_measure_frequency (CidMeasure *pMeasureTimer,
int iNewCheckInterval)
{
g_return_if_fail (pMeasureTimer != NULL);
pMeasureTimer->iCheckInterval = iNewCheckInterval;
_cid_restart_timer_with_frequency (pMeasureTimer, iNewCheckInterval);
_cid_restart_timer_with_frequency (pMeasureTimer,
iNewCheckInterval);
}
void
cid_relaunch_measure_immediately (CidMeasure *pMeasureTimer, int iNewCheckInterval)
cid_relaunch_measure_immediately (CidMeasure *pMeasureTimer,
int iNewCheckInterval)
{
cid_stop_measure_timer (pMeasureTimer); // on stoppe avant car on ne veut pas attendre la prochaine iteration.
// on stoppe avant car on ne veut pas attendre
// la prochaine iteration.
cid_stop_measure_timer (pMeasureTimer);
if (iNewCheckInterval == -1) // valeur inchangee.
iNewCheckInterval = pMeasureTimer->iCheckInterval;
cid_change_measure_frequency (pMeasureTimer, iNewCheckInterval); // nouvelle frequence eventuelement.
// nouvelle frequence eventuelement.
cid_change_measure_frequency (pMeasureTimer, iNewCheckInterval);
cid_launch_measure (pMeasureTimer); // mesure immediate.
}
......@@ -257,8 +308,11 @@ cid_downgrade_frequency_state (CidMeasure *pMeasureTimer)
break ;
}
cid_message ("degradation de la mesure (etat <- %d/%d)", pMeasureTimer->iFrequencyState, CID_NB_FREQUENCIES-1);
_cid_restart_timer_with_frequency (pMeasureTimer, iNewCheckInterval);
cid_message ("degradation de la mesure (etat <- %d/%d)",
pMeasureTimer->iFrequencyState,
CID_NB_FREQUENCIES - 1 );
_cid_restart_timer_with_frequency (pMeasureTimer,
iNewCheckInterval);
}
}
......@@ -268,6 +322,7 @@ cid_set_normal_frequency_state (CidMeasure *pMeasureTimer)
if (pMeasureTimer->iFrequencyState != CID_FREQUENCY_NORMAL)
{
pMeasureTimer->iFrequencyState = CID_FREQUENCY_NORMAL;
_cid_restart_timer_with_frequency (pMeasureTimer, pMeasureTimer->iCheckInterval);
_cid_restart_timer_with_frequency (pMeasureTimer,
pMeasureTimer->iCheckInterval);
}
}
......@@ -47,13 +47,18 @@ typedef struct {
gint iThreadIsRunning;
/// mutex d'accessibilite a la structure des resultats.
GMutex *pMutexData;
/// fonction realisant l'acquisition des donnees. N'accede jamais a la structure des resultats.
/// fonction realisant l'acquisition des donnees.
/// N'accede jamais a la structure des resultats.
CidAquisitionTimerFunc acquisition;
/// fonction realisant la lecture des donnees precedemment acquises; stocke les resultats dans la structures des resultats.
/// fonction realisant la lecture des donnees precedemment acquises;
/// stocke les resultats dans la structures des resultats.
CidReadTimerFunc read;
/// fonction realisant la mise a jour de l'IHM en fonction des nouveaux resultats. Renvoie TRUE pour continuer, FALSE pour arreter.
/// fonction realisant la mise a jour de l'IHM en fonction des
/// nouveaux resultats. Renvoie TRUE pour continuer,
/// FALSE pour arreter.
CidUpdateTimerFunc update;
/// intervalle de temps en secondes, eventuellement nul pour une mesure unitaire.
/// intervalle de temps en secondes, eventuellement nul pour
/// une mesure unitaire.
gint iCheckInterval;
/// etat de la frequence des mesures.
CidFrequencyState iFrequencyState;
......@@ -62,70 +67,110 @@ typedef struct {
} CidMeasure;
/**
*Lance les mesures periodiques, prealablement preparee avec #cid_new_measure_timer. La 1ere iteration est executee immediatement. L'acquisition et la lecture des donnees est faite de maniere asynchrone (dans un thread secondaire), alors que le chargement des mesures se fait dans la boucle principale. La frequence est remise a son etat normal.
*@param pMeasureTimer la mesure periodique.
*/
*Lance les mesures periodiques, prealablement preparee avec
* #cid_new_measure_timer. La 1ere iteration est executee immediatement.
* L'acquisition et la lecture des donnees est faite de maniere
* asynchrone (dans un thread secondaire), alors que le chargement des
* mesures se fait dans la boucle principale.
* La frequence est remise a son etat normal.
* @param pMeasureTimer la mesure periodique.
*/
void cid_launch_measure (CidMeasure *pMeasureTimer);
/**
*Idem que ci-dessus mais après un délai.
*@param pMeasureTimer la mesure periodique.
*@param fDelay délai en ms.
*/
void cid_launch_measure_delayed (CidMeasure *pMeasureTimer, double fDelay);
*Idem que ci-dessus mais après un délai.
*@param pMeasureTimer la mesure periodique.
*@param fDelay délai en ms.
*/
void cid_launch_measure_delayed (CidMeasure *pMeasureTimer,
double fDelay);
/**
*Cree une mesure periodique.
*@param iCheckInterval l'intervalle en s entre 2 mesures, eventuellement nul pour une mesure unitaire.
*@param acquisition fonction realisant l'acquisition des donnees. N'accede jamais a la structure des resultats.
*@param read fonction realisant la lecture des donnees precedemment acquises; stocke les resultats dans la structures des resultats.
*@param update fonction realisant la mise a jour de l'interface en fonction des nouveaux resultats, lus dans la structures des resultats.
*@param pUserData structure passee en entree des fonctions read et update.
*@return la mesure nouvellement allouee. A liberer avec #cid_free_measure_timer.
*/
CidMeasure *cid_new_measure_timer (int iCheckInterval, CidAquisitionTimerFunc acquisition, CidReadTimerFunc read, CidUpdateTimerFunc update, gpointer pUserData);
* Cree une mesure periodique.
* @param iCheckInterval l'intervalle en s entre 2 mesures,
* eventuellement nul pour une mesure unitaire.
* @param acquisition fonction realisant l'acquisition des donnees.
* N'accede jamais a la structure des resultats.
* @param read fonction realisant la lecture des donnees
* precedemment acquises; stocke les resultats dans la structures
* des resultats.
* @param update fonction realisant la mise a jour de l'interface
* en fonction des nouveaux resultats, lus dans la structures
* des resultats.
* @param pUserData structure passee en entree des fonctions
* read et update.
* @return la mesure nouvellement allouee.
* A liberer avec #cid_free_measure_timer.
*/
CidMeasure *cid_new_measure_timer (int iCheckInterval,
CidAquisitionTimerFunc acquisition,
CidReadTimerFunc read,
CidUpdateTimerFunc update,
gpointer pUserData);
/**
*Stoppe les mesures. Si une mesure est en cours, le thread d'acquisition/lecture se terminera tout seul plus tard, et la mesure sera ignoree. On peut reprendre les mesures par un simple #cairo_dock_launch_measure. Ne doit _pas_ etre appelée durant la fonction 'read' ou 'update'; utiliser la sortie de 'update' pour cela.
*@param pMeasureTimer la mesure periodique.
*/
* Stoppe les mesures. Si une mesure est en cours, le thread
* d'acquisition/lecture se terminera tout seul plus tard,
* et la mesure sera ignoree. On peut reprendre les mesures
* par un simple #cid_launch_measure. Ne doit _pas_ etre appelée
* durant la fonction 'read' ou 'update';
* utiliser la sortie de 'update' pour cela.
* @param pMeasureTimer la mesure periodique.
*/
void cid_stop_measure_timer (CidMeasure *pMeasureTimer);
/**
*Stoppe et detruit une mesure periodique, liberant toutes ses ressources allouees.
*@param pMeasureTimer la mesure periodique.
*/
* Stoppe et detruit une mesure periodique, liberant toutes
* ses ressources allouees.
* @param pMeasureTimer la mesure periodique.
*/
void cid_free_measure_timer (CidMeasure *pMeasureTimer);
/**
*Dis si une mesure est active, c'est a dire si elle est appelee periodiquement.
*@param pMeasureTimer la mesure periodique.
*@return TRUE ssi la mesure est active.
*/
* Dis si une mesure est active, c'est a dire si elle est
* appelee periodiquement.
* @param pMeasureTimer la mesure periodique.
* @return TRUE ssi la mesure est active.
*/
gboolean cid_measure_is_active (CidMeasure *pMeasureTimer);
/**
*Dis si une mesure est en cours, c'est a dire si elle est soit dans le thread, soit en attente d'update.
*@param pMeasureTimer la mesure periodique.
*@return TRUE ssi la mesure est en cours.
*/
gboolean cid_measure_is_running (CidMeasure *pMeasureTimer);
* Dis si une mesure est en cours, c'est a dire si elle est soit dans
* le thread, soit en attente d'update.
* @param pMeasureTimer la mesure periodique.
* @return TRUE ssi la mesure est en cours.
*/
gboolean cid_measure_is_running (CidMeasure *pMeasureTimer);
/**
*Change la frequence des mesures. La prochaine mesure aura lien dans 1 iteration si elle etait deja active.
*@param pMeasureTimer la mesure periodique.
*@param iNewCheckInterval le nouvel intervalle entre 2 mesures, en s.
*/
void cid_change_measure_frequency (CidMeasure *pMeasureTimer, int iNewCheckInterval);
* Change la frequence des mesures. La prochaine mesure aura lien dans
* 1 iteration si elle etait deja active.
* @param pMeasureTimer la mesure periodique.
* @param iNewCheckInterval le nouvel intervalle entre 2 mesures, en s.
*/
void cid_change_measure_frequency (CidMeasure *pMeasureTimer,
int iNewCheckInterval);
/**
*Change la frequence des mesures et les relance immediatement. La prochaine mesure est donc tout de suite.
*@param pMeasureTimer la mesure periodique.
*@param iNewCheckInterval le nouvel intervalle entre 2 mesures, en s.
*/
void cid_relaunch_measure_immediately (CidMeasure *pMeasureTimer, int iNewCheckInterval);
* Change la frequence des mesures et les relance immediatement.
* La prochaine mesure est donc tout de suite.
* @param pMeasureTimer la mesure periodique.
* @param iNewCheckInterval le nouvel intervalle entre 2 mesures, en s.
*/
void cid_relaunch_measure_immediately (CidMeasure *pMeasureTimer,
int iNewCheckInterval);
/**
*Degrade la frequence des mesures. La mesure passe dans un etat moins actif (typiquement utile si la mesure a echouee).
*@param pMeasureTimer la mesure periodique.
*/
* Degrade la frequence des mesures. La mesure passe dans un etat
* moins actif (typiquement utile si la mesure a echouee).
* @param pMeasureTimer la mesure periodique.
*/
void cid_downgrade_frequency_state (CidMeasure *pMeasureTimer);
/**
*Remet la frequence des mesures a un etat normal. Notez que cela est fait automatiquement au 1er lancement de la mesure.
*@param pMeasureTimer la mesure periodique.
*/
* Remet la frequence des mesures a un etat normal. Notez que cela est
* fait automatiquement au 1er lancement de la mesure.
* @param pMeasureTimer la mesure periodique.
*/
void cid_set_normal_frequency_state (CidMeasure *pMeasureTimer);
#endif
......@@ -43,7 +43,8 @@ cid_fade_in_out (void *ptr)
if (cid->runtime->dFadeInOutAlpha > .99)
cid->runtime->dFadeInOutAlpha = 0;
cid->runtime->dFadeInOutAlpha += IN_OUT_VARIATION * cid->config->iAnimationSpeed;
cid->runtime->dFadeInOutAlpha +=
IN_OUT_VARIATION * cid->config->iAnimationSpeed;
CID_REDRAW;
......@@ -62,8 +63,10 @@ cid_focus_in(void *ptr)
cid->runtime->iCurrentlyDrawing = 1;
cid->runtime->bFocusAnimation = TRUE;
cid->config->dAlpha += cid->runtime->dFocusVariation * FADE_VARIATION;
cid->runtime->dAnimationProgress = cid->config->dAlpha / (cid->runtime->dFocusVariation > 0 ?
cid->config->dAlpha +=
cid->runtime->dFocusVariation * FADE_VARIATION;
cid->runtime->dAnimationProgress =
cid->config->dAlpha / (cid->runtime->dFocusVariation > 0 ?
cid->config->pFlyingColor->dAlpha-cid->config->pColor->dAlpha :
cid->config->pColor->dAlpha-cid->config->pFlyingColor->dAlpha);
......@@ -79,7 +82,7 @@ cid_focus_in(void *ptr)
return cid->runtime->bFocusAnimation;
}
/* On restaure la couleur de fond d'origine lorsqu'on quitte la fenêtre */
/*On restaure la couleur de fond d'origine lorsqu'on quitte la fenêtre*/
gboolean
cid_focus_out(void *ptr)
{
......@@ -87,7 +90,8 @@ cid_focus_out(void *ptr)
cid->runtime->bFocusAnimation = TRUE;
cid->config->dAlpha -= cid->runtime->dFocusVariation * FADE_VARIATION;
cid->config->dAlpha -=
cid->runtime->dFocusVariation * FADE_VARIATION;
cid->runtime->dAnimationProgress =
cid->config->dAlpha / (cid->runtime->dFocusVariation > 0 ?
cid->config->pFlyingColor->dAlpha-cid->config->pColor->dAlpha :
......@@ -114,17 +118,22 @@ cid_focus_out(void *ptr)
return cid->runtime->bCurrentlyFlying;
}
/* On appelle la fonction adéquate selon qu'on "expose" ou non la fenêtre */
/**
* On appelle la fonction adéquate selon qu'on "expose"
* ou non la fenêtre
*/
void
cid_focus (GtkWidget *pWidget, GdkEventExpose *event, gpointer *userdata)
cid_focus (GtkWidget *pWidget,
GdkEventExpose *event,
gpointer *userdata)
{
gboolean bFocusIn = GPOINTER_TO_INT (&userdata[0]);
// cid_info ("CID is currently focused %s.", bFocusIn ? "in" : "out");
// cid_info ("CID is currently focused %s.", bFocusIn ? "in" : "out");
if (cid->config->bShowAbove)
gtk_window_set_keep_below (GTK_WINDOW (cid->pWindow), !bFocusIn);
gtk_window_set_keep_below (GTK_WINDOW (cid->pWindow),!bFocusIn);
if (bFocusIn)
{
......@@ -175,11 +184,13 @@ cid_threaded_animation (AnimationType iAnim, gint iDelay)
cid_stop_measure_timer(pMeasureTimerAnimation);
cid_free_measure_timer(pMeasureTimerAnimation);
}
pMeasureTimerAnimation = cid_new_measure_timer (iDelay,
NULL,
NULL,
(CidUpdateTimerFunc) cid_rotate_on_changing_song,
NULL);
pMeasureTimerAnimation =
cid_new_measure_timer (iDelay,
NULL,
NULL,
(CidUpdateTimerFunc)
cid_rotate_on_changing_song,
NULL);
cid_launch_measure (pMeasureTimerAnimation);
break;
......@@ -190,11 +201,13 @@ cid_threaded_animation (AnimationType iAnim, gint iDelay)
cid_stop_measure_timer(pMeasureTimerAnimation);
cid_free_measure_timer(pMeasureTimerAnimation);
}
pMeasureTimerAnimation = cid_new_measure_timer (iDelay,
NULL,
NULL,
(CidUpdateTimerFunc) cid_fade_in_out,
NULL);
pMeasureTimerAnimation =
cid_new_measure_timer (iDelay,
NULL,
NULL,
(CidUpdateTimerFunc)
cid_fade_in_out,
NULL);
cid_launch_measure (pMeasureTimerAnimation);
break;
......@@ -205,11 +218,13 @@ cid_threaded_animation (AnimationType iAnim, gint iDelay)
cid_stop_measure_timer(pMeasureTimerFocus);
cid_free_measure_timer(pMeasureTimerFocus);
}
pMeasureTimerFocus = cid_new_measure_timer (iDelay,
NULL,
NULL,
(CidUpdateTimerFunc) cid_focus_in,
NULL);
pMeasureTimerFocus =
cid_new_measure_timer (iDelay,
NULL,
NULL,
(CidUpdateTimerFunc)
cid_focus_in,
NULL);
cid_launch_measure (pMeasureTimerFocus);
break;
......@@ -220,11 +235,13 @@ cid_threaded_animation (AnimationType iAnim, gint iDelay)
cid_stop_measure_timer(pMeasureTimerFocus);
cid_free_measure_timer(pMeasureTimerFocus);
}
pMeasureTimerFocus = cid_new_measure_timer (iDelay,
NULL,
NULL,
(CidUpdateTimerFunc) cid_focus_out,
NULL);
pMeasureTimerFocus =
cid_new_measure_timer (iDelay,
NULL,
NULL,