diff options
Diffstat (limited to 'src/core/global.c')
-rw-r--r-- | src/core/global.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/core/global.c b/src/core/global.c index 86c7e5f..c5f25c1 100644 --- a/src/core/global.c +++ b/src/core/global.c @@ -31,6 +31,12 @@ /* Gestionnaire de tâches parallèles */ static GWorkQueue *_queue = NULL; +/* Projet global actif */ +static GStudyProject *_project = NULL; + +/* Avertisseur de changement de projet principal */ +static current_project_change_cb _project_notify = NULL; + /****************************************************************************** @@ -71,3 +77,71 @@ GWorkQueue *get_work_queue(void) return _queue; } + + +/****************************************************************************** +* * +* Paramètres : project = éventuelle adresse du nouveau projet principal. * +* * +* Description : Définit l'adresse du projet courant. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void set_current_project(GStudyProject *project) +{ + if (_project != NULL) + { + _project_notify(_project, false); + g_object_unref(G_OBJECT(_project)); + } + + _project = project; + + if (_project != NULL) + _project_notify(_project, true); + +} + + +/****************************************************************************** +* * +* Paramètres : project = éventuel adresse à renvoyer désormais. * +* * +* Description : Fournit l'adresse du projet courant. * +* * +* Retour : Adresse du projet ouvert ou NULL si aucun (!). * +* * +* Remarques : - * +* * +******************************************************************************/ + +GStudyProject *get_current_project(void) +{ + return _project; + +} + + +/****************************************************************************** +* * +* Paramètres : notify = procédure à appeler à chaque changement de project. * +* * +* Description : Enregistre une partie de code à avertir en cas de changement.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void register_project_change_notification(current_project_change_cb notify) +{ + assert(_project_notify == NULL); + + _project_notify = notify; + +} |