summaryrefslogtreecommitdiff
path: root/src/core/global.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-12-26 11:08:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-12-26 11:08:23 (GMT)
commit181e3a9a8819ba50c74f4864c0fca111e375aa5e (patch)
tree216f46f42175618bb717659fd44d5b0cad38dd70 /src/core/global.c
parent9b5cd85f783f0174e81f22bb3333d4dfcec76532 (diff)
Registered the current project as a real global variable.
Diffstat (limited to 'src/core/global.c')
-rw-r--r--src/core/global.c74
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;
+
+}