diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2022-12-29 11:02:46 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2022-12-29 11:02:46 (GMT) |
commit | 41db261acccf3494aa93b71a181cde9e8605a841 (patch) | |
tree | 07a00f88920a8e601268d415131630052ef85988 /src/main.c | |
parent | c27f884ec1d18d9cff0d19d6ba8de1dd54d991c4 (diff) |
Refactor Makefiles to exclude GTK on demand.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 66 |
1 files changed, 62 insertions, 4 deletions
@@ -31,7 +31,9 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <gtk/gtk.h> +#ifdef HAVE_GTK_SUPPORT +# include <gtk/gtk.h> +#endif #include <config.h> @@ -50,9 +52,11 @@ #include "core/paths.h" #include "core/queue.h" #include "glibext/delayed.h" -#include "gui/editor.h" -#include "gui/core/core.h" -#include "gui/core/global.h" +#ifdef HAVE_GTK_SUPPORT +# include "gui/editor.h" +# include "gui/core/core.h" +# include "gui/core/global.h" +#endif #include "plugins/pglist.h" @@ -63,9 +67,13 @@ static void show_chrysalide_help(const char *); /* Affiche des indications sur la version courante du programme. */ static void show_chrysalide_version(void); +#ifdef HAVE_GTK_SUPPORT + /* Recharge le dernier projet ouvert s'il existe. */ static gboolean load_last_project(GGenConfig *); +#endif + /* Ouvre les éventuels fichiers fournis au démarrage. */ static int open_binaries(char **, int); @@ -186,16 +194,20 @@ int main(int argc, char **argv) bool show_help; /* Affichage de l'aide ? */ bool show_version; /* Affichage de la version ? */ LogMessageType verbosity; /* Niveau de filtre de message */ +#ifdef HAVE_GTK_SUPPORT bool batch_mode; /* Exécution sans GUI ? */ +#endif bool save; /* Sauvegarde du cache ? */ char *prj_filename; /* Chemin vers un projet */ int index; /* Indice d'argument */ int ret; /* Bilan d'un appel */ char *edir; /* Répertoire de base effectif */ bool status; /* Bilan d'opérations */ +#ifdef HAVE_GTK_SUPPORT GtkWidget *editor; /* Fenêtre graphique */ GGenConfig *config; /* Configuration globale */ bool welcome; /* Affichage de la bienvenue ? */ +#endif char resolved[PATH_MAX]; /* Résolution de nom de fichier*/ GStudyProject *project; /* Nouveau projet courant */ @@ -225,7 +237,9 @@ int main(int argc, char **argv) show_version = false; verbosity = LMT_INFO; +#ifdef HAVE_GTK_SUPPORT batch_mode = false; +#endif save = false; prj_filename = NULL; @@ -249,7 +263,9 @@ int main(int argc, char **argv) break; case 'b': +#ifdef HAVE_GTK_SUPPORT batch_mode = true; +#endif break; case 's': @@ -294,11 +310,15 @@ int main(int argc, char **argv) /* Initialisation de GTK */ g_set_prgname("Chrysalide"); +#ifdef HAVE_GTK_SUPPORT gtk_init(&argc, &argv); +#endif /* Initialisation du programme */ +#ifdef HAVE_GTK_SUPPORT if (batch_mode) +#endif set_batch_mode(); set_log_verbosity(verbosity); @@ -308,6 +328,8 @@ int main(int argc, char **argv) /* Création de l'interface */ +#ifdef HAVE_GTK_SUPPORT + if (!batch_mode) { editor = create_editor(); @@ -330,8 +352,12 @@ int main(int argc, char **argv) else editor = NULL; +#endif + init_all_plugins(true); +#ifdef HAVE_GTK_SUPPORT + config = get_main_configuration(); if (!batch_mode) @@ -340,6 +366,8 @@ int main(int argc, char **argv) if (!status) goto exit_complete_gui; } +#endif + /* Lancement du serveur local */ status = ensure_internal_connections_setup(); @@ -354,6 +382,8 @@ int main(int argc, char **argv) /* Charge le dernier projet ? */ +#ifdef HAVE_GTK_SUPPORT + if (batch_mode) welcome = true; else @@ -363,6 +393,9 @@ int main(int argc, char **argv) g_idle_add((GSourceFunc)load_last_project, config); else + +#endif + { if (prj_filename != NULL) { @@ -382,7 +415,11 @@ int main(int argc, char **argv) if (ret == 0) { +#ifdef HAVE_GTK_SUPPORT project = g_study_project_open(prj_filename, !batch_mode); +#else + project = g_study_project_open(prj_filename, false); +#endif if (project == NULL) goto bad_project; } @@ -410,7 +447,12 @@ int main(int argc, char **argv) result = open_binaries(argv + optind, argc - optind); +#ifdef HAVE_GTK_SUPPORT + if (batch_mode) + +#endif + { wait_for_all_global_works(); @@ -422,16 +464,22 @@ int main(int argc, char **argv) } +#ifdef HAVE_GTK_SUPPORT + else gtk_main(); +#endif + set_current_project(NULL); bad_project: no_internal_server: +#ifdef HAVE_GTK_SUPPORT exit_complete_gui: +#endif #ifdef TRACK_GOBJECT_LEAKS remember_gtypes_for_leaks(); @@ -439,6 +487,8 @@ int main(int argc, char **argv) exit_all_plugins(); +#ifdef HAVE_GTK_SUPPORT + if (!batch_mode) unload_all_gui_components(); @@ -449,6 +499,8 @@ int main(int argc, char **argv) failed_to_load_editor: +#endif + unload_all_core_components(true); #ifdef TRACK_GOBJECT_LEAKS @@ -462,6 +514,9 @@ int main(int argc, char **argv) } +#ifdef HAVE_GTK_SUPPORT + + /****************************************************************************** * * * Paramètres : cfg = configuration globale sur laquelle s'appuyer. * @@ -492,6 +547,9 @@ static gboolean load_last_project(GGenConfig *cfg) } +#endif + + /****************************************************************************** * * * Paramètres : files = noms de fichier fournis en ligne de commande. * |