summaryrefslogtreecommitdiff
path: root/src/core
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
parent9b5cd85f783f0174e81f22bb3333d4dfcec76532 (diff)
Registered the current project as a real global variable.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/global.c74
-rw-r--r--src/core/global.h13
2 files changed, 87 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;
+
+}
diff --git a/src/core/global.h b/src/core/global.h
index d29cb76..9e2b8cd 100644
--- a/src/core/global.h
+++ b/src/core/global.h
@@ -25,6 +25,7 @@
#define _CORE_GLOBAL_H
+#include "../analysis/project.h"
#include "../glibext/delayed.h"
@@ -35,6 +36,18 @@ void set_work_queue(GWorkQueue *);
/* Fournit le gestionnaire de traitements parallèles courant. */
GWorkQueue *get_work_queue(void);
+/* Définit l'adresse du projet courant. */
+void set_current_project(GStudyProject *);
+
+/* Fournit l'adresse du projet courant. */
+GStudyProject *get_current_project(void);
+
+/* Réagit à un changement du projet principal. */
+typedef void (* current_project_change_cb) (GStudyProject *, bool);
+
+/* Enregistre une partie de code à avertir en cas de changement. */
+void register_project_change_notification(current_project_change_cb);
+
#endif /* _CORE_GLOBAL_H */