summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2024-07-21 23:04:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2024-07-21 23:04:53 (GMT)
commitd1874bdcaf52717ebf6f808010d275ca1f1693f3 (patch)
treec47941b305f6d4867e91edbb0b90e69f63778072
parente4ccb9e56e822628e299527fee0b7325f0d25662 (diff)
Separate the GTK application and the GTK main window.
-rw-r--r--src/Makefile.am25
-rw-r--r--src/app.c253
-rw-r--r--src/app.h26
-rw-r--r--src/framework.c356
-rw-r--r--src/framework.h66
-rw-r--r--src/gui/Makefile.am7
-rw-r--r--src/gui/gresource.xml1
-rw-r--r--src/gui/window-int.h57
-rw-r--r--src/gui/window.c235
-rw-r--r--src/gui/window.h51
-rw-r--r--src/gui/window.ui19
-rw-r--r--src/schemas/re.chrysalide.framework.gschema.xml4
12 files changed, 655 insertions, 445 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 66dcbdd..9355d4c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
lib_LTLIBRARIES = libchrysacore4.la libchrysacoreui.la # libchrysacore.la
-bin_PROGRAMS = framework # chrysalide chrysalide-hub rost
+bin_PROGRAMS = chrysalide # chrysalide-hub rost
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/intl
@@ -111,34 +111,33 @@ libchrysacoreui_la_LDFLAGS = \
# Programme principal
############################################################
-EXTRA_chrysalide_DEPENDENCIES = libchrysacore.la
+EXTRA_chrysalide0_DEPENDENCIES = libchrysacore.la
-chrysalide_SOURCES = \
+chrysalide0_SOURCES = \
$(GOBJECT_LEAKS_SOURCES) \
main.c
-chrysalide_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS)
+chrysalide0_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS)
-chrysalide_LDFLAGS = $(TOOLKIT_LIBS) -L/usr/X11R6/lib -ldl -lm $(LIBXML_LIBS) $(LIBPYTHON_LIBS) $(LIBARCHIVE_LIBS) $(LIBSQLITE_LIBS) \
+chrysalide0_LDFLAGS = $(TOOLKIT_LIBS) -L/usr/X11R6/lib -ldl -lm $(LIBXML_LIBS) $(LIBPYTHON_LIBS) $(LIBARCHIVE_LIBS) $(LIBSQLITE_LIBS) \
-L.libs -lchrysacore
-chrysalide_LDADD = $(LIBINTL)
+chrysalide0_LDADD = $(LIBINTL)
-EXTRA_framework_DEPENDENCIES = libchrysacore4.la libchrysacoreui.la
+EXTRA_chrysalide_DEPENDENCIES = libchrysacore4.la libchrysacoreui.la
-framework_SOURCES = \
- app.h app.c \
- framework.h framework.c
+chrysalide_SOURCES = \
+ app.h app.c
-framework_CFLAGS = $(TOOLKIT4_CFLAGS) $(LIBGIOUNIX_CFLAGS)
+chrysalide_CFLAGS = $(TOOLKIT4_CFLAGS) $(LIBGIOUNIX_CFLAGS)
-framework_LDFLAGS = $(TOOLKIT4_LIBS) $(LIBGIOUNIX_LIBS) \
+chrysalide_LDFLAGS = $(TOOLKIT4_LIBS) $(LIBGIOUNIX_LIBS) \
-L.libs -lchrysacore4 -lchrysacoreui
-framework_LDADD =
+chrysalide_LDADD =
diff --git a/src/app.c b/src/app.c
index bb0fa8a..a3a2080 100644
--- a/src/app.c
+++ b/src/app.c
@@ -33,13 +33,222 @@
#include "common/io.h"
#include "common/xdg.h"
#include "core/logs.h"
-#include "glibext/helpers.h"
+#include "gui/core/core.h"
+#include "gui/window.h"
-#define CHRYSALIDE_APP_ID "re.chrysalide.framework.gui" // REMME
+/* --------------------- DEFINITION D'APPLICATION PERSONNALISEE --------------------- */
+/* Définition de l'application principale graphique (instance) */
+struct _GtkChrysalideFramework
+{
+ GtkApplication parent; /* A laisser en premier */
+
+ GtkApplicationWindow *main_window; /* Fenêtre principale */
+
+};
+
+/* Définition de l'application principale graphique (classe) */
+struct _GtkChrysalideFrameworkClass
+{
+ GtkApplicationClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe des applications majeures de Chrysalide. */
+static void gtk_chrysalide_framework_class_init(GtkChrysalideFrameworkClass *);
+
+/* Initialise une application principale pour Chrysalide. */
+static void gtk_chrysalide_framework_init(GtkChrysalideFramework *);
+
+/* Supprime toutes les références externes. */
+static void gtk_chrysalide_framework_dispose(GtkChrysalideFramework *);
+
+/* Procède à la libération totale de la mémoire. */
+static void gtk_chrysalide_framework_finalize(GtkChrysalideFramework *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Réagit à l'activation de l'application. */
+static void gtk_chrysalide_framework_activate(GApplication *);
+
+
+
+/* ---------------------- POINT D'ENTREE PRINCIPAL D'EXECUTION ---------------------- */
+
+
+/* Installe au besoin une définition locale pour le système. */
+static void ensure_wm_icon_and_name(void);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* DEFINITION D'APPLICATION PERSONNALISEE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une application principale graphique de Chrysalide. */
+G_DEFINE_TYPE(GtkChrysalideFramework, gtk_chrysalide_framework, GTK_TYPE_APPLICATION);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des applications majeures de Chrysalide.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_chrysalide_framework_class_init(GtkChrysalideFrameworkClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GApplicationClass *app; /* Version parente de la classe*/
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)gtk_chrysalide_framework_dispose;
+ object->finalize = (GObjectFinalizeFunc)gtk_chrysalide_framework_finalize;
+
+ app = G_APPLICATION_CLASS(klass);
+
+ app->activate = gtk_chrysalide_framework_activate;
+
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : app = instance à initialiser. *
+* *
+* Description : Initialise une application principale pour Chrysalide. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_chrysalide_framework_init(GtkChrysalideFramework *app)
+{
+ app->main_window = NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : app = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_chrysalide_framework_dispose(GtkChrysalideFramework *app)
+{
+ g_clear_object(&app->main_window);
+
+ G_OBJECT_CLASS(gtk_chrysalide_framework_parent_class)->dispose(G_OBJECT(app));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : app = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_chrysalide_framework_finalize(GtkChrysalideFramework *app)
+{
+ G_OBJECT_CLASS(gtk_chrysalide_framework_parent_class)->finalize(G_OBJECT(app));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Crée une nouvelle application principale pour Chrysalide. *
+* *
+* Retour : Mécanismes mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkChrysalideFramework *gtk_chrysalide_framework_new(void)
+{
+ GtkChrysalideFramework *result; /* Instance à retourner */
+
+ result = g_object_new(GTK_TYPE_CHRYSALIDE_FRAMEWORK,
+ "application-id", FRAMEWORK_WINDOW_ID,
+ "flags", G_APPLICATION_DEFAULT_FLAGS,
+ NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : app = application concernée par l'événement. *
+* *
+* Description : Réagit à l'activation de l'application. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_chrysalide_framework_activate(GApplication *app)
+{
+ GtkChrysalideFramework *real_app; /* Version réelle de l'instance*/
+
+ real_app = GTK_CHRYSALIDE_FRAMEWORK(app);
+
+ real_app->main_window = gtk_framework_window_new(GTK_APPLICATION(app));
+ g_object_ref(G_OBJECT(real_app->main_window));
+
+ gtk_window_present(GTK_WINDOW(real_app->main_window));
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* POINT D'ENTREE PRINCIPAL D'EXECUTION */
+/* ---------------------------------------------------------------------------------- */
+
/******************************************************************************
* *
@@ -53,7 +262,7 @@
* *
******************************************************************************/
-void ensure_wm_icon_and_name(void)
+static void ensure_wm_icon_and_name(void)
{
GDesktopAppInfo *info; /* Information du système */
GKeyFile *kfile; /* Définition d'application */
@@ -66,7 +275,7 @@ void ensure_wm_icon_and_name(void)
/* Evaluation du besoin */
- info = g_desktop_app_info_new(CHRYSALIDE_APP_ID ".desktop");
+ info = g_desktop_app_info_new(FRAMEWORK_WINDOW_ID ".desktop");
/**
* Si l'exécutable n'est pas valide (inconnu de $PATH),
@@ -135,3 +344,39 @@ void ensure_wm_icon_and_name(void)
;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : argc = nombre d'arguments dans la ligne de commande. *
+* argv = arguments de la ligne de commande. *
+* *
+* Description : Point d'entrée du programme. *
+* *
+* Retour : EXIT_SUCCESS si le prgm s'est déroulé sans encombres. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int main(int argc, char **argv)
+{
+ int result; /* Bilan de l'exécution */
+ GtkChrysalideFramework *app; /* Gestion d'application GTK */
+
+ if (!load_gui_components(AGC_BUFFER_FEATURES | AGC_PANELS))
+ return EXIT_FAILURE;
+
+ ensure_wm_icon_and_name();
+
+ app = gtk_chrysalide_framework_new();
+
+ result = g_application_run(G_APPLICATION(app), argc, argv);
+
+ g_object_unref(G_OBJECT(app));
+
+ unload_gui_components(AGC_BUFFER_FEATURES | AGC_PANELS);
+
+ return result;
+
+}
diff --git a/src/app.h b/src/app.h
index 7696df5..645fa6b 100644
--- a/src/app.h
+++ b/src/app.h
@@ -25,9 +25,31 @@
#define _APP_H
+#include <gtk/gtk.h>
-/* Installe au besoin une définition locale pour le système. */
-void ensure_wm_icon_and_name(void);
+
+#include "glibext/helpers.h"
+
+
+
+/* --------------------- DEFINITION D'APPLICATION PERSONNALISEE --------------------- */
+
+
+#define GTK_TYPE_CHRYSALIDE_FRAMEWORK (gtk_chrysalide_framework_get_type())
+
+DECLARE_GTYPE(GtkChrysalideFramework, gtk_chrysalide_framework, GTK, CHRYSALIDE_FRAMEWORK);
+
+
+/* Crée une nouvelle application principale pour Chrysalide. */
+GtkChrysalideFramework *gtk_chrysalide_framework_new(void);
+
+
+
+/* ---------------------- POINT D'ENTREE PRINCIPAL D'EXECUTION ---------------------- */
+
+
+/* Point d'entrée du programme. */
+int main(int, char **);
diff --git a/src/framework.c b/src/framework.c
deleted file mode 100644
index 1c90fda..0000000
--- a/src/framework.c
+++ /dev/null
@@ -1,356 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * framework.c - fichier d'entrée du programme
- *
- * Copyright (C) 2024 Cyrille Bagard
- *
- * This file is part of Chrysalide.
- *
- * Chrysalide is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Chrysalide is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-
-#include <gtk/gtk.h>
-
-
-#include "app.h" // REMME
-#include "framework.h"
-#include "glibext/helpers.h"
-#include "gui/core/core.h"
-#include "gui/core/panels.h" // REMME
-#include "gui/panels/welcome.h" // REMME
-
-
-
-/* --------------------- DEFINITION D'APPLICATION PERSONNALISEE --------------------- */
-
-
-#define CHRYSALIDE_APP_ID "re.chrysalide.framework.gui"
-
-
-/* Définition de l'application principale graphique (instance) */
-struct _GtkChrysalideFramework
-{
- GtkApplication parent; /* A laisser en premier */
-
- GSettings *settings; /* Paramètres globaux */
-
- GtkApplicationWindow *main_window; /* Fenêtre principale */
-
-};
-
-/* Définition de l'application principale graphique (classe) */
-struct _GtkChrysalideFrameworkClass
-{
- GtkApplicationClass parent; /* A laisser en premier */
-
-};
-
-
-/* Initialise la classe des applications majeures de Chrysalide. */
-static void gtk_chrysalide_framework_class_init(GtkChrysalideFrameworkClass *);
-
-/* Initialise une application principale pour Chrysalide. */
-static void gtk_chrysalide_framework_init(GtkChrysalideFramework *);
-
-/* Supprime toutes les références externes. */
-static void gtk_chrysalide_framework_dispose(GtkChrysalideFramework *);
-
-/* Procède à la libération totale de la mémoire. */
-static void gtk_chrysalide_framework_finalize(GtkChrysalideFramework *);
-
-
-
-/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
-
-
-/* Réagit à l'activation de l'application. */
-static void gtk_chrysalide_framework_activate(GApplication *);
-
-
-
-/* ---------------------------------------------------------------------------------- */
-/* DEFINITION D'APPLICATION PERSONNALISEE */
-/* ---------------------------------------------------------------------------------- */
-
-
-/* Indique le type défini pour une application principale graphique de Chrysalide. */
-G_DEFINE_TYPE(GtkChrysalideFramework, gtk_chrysalide_framework, GTK_TYPE_APPLICATION);
-
-
-/******************************************************************************
-* *
-* Paramètres : klass = classe à initialiser. *
-* *
-* Description : Initialise la classe des applications majeures de Chrysalide.*
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_chrysalide_framework_class_init(GtkChrysalideFrameworkClass *klass)
-{
- GObjectClass *object; /* Autre version de la classe */
- GApplicationClass *app; /* Version parente de la classe*/
-
- object = G_OBJECT_CLASS(klass);
-
- object->dispose = (GObjectFinalizeFunc/* ! */)gtk_chrysalide_framework_dispose;
- object->finalize = (GObjectFinalizeFunc)gtk_chrysalide_framework_finalize;
-
- app = G_APPLICATION_CLASS(klass);
-
- app->activate = gtk_chrysalide_framework_activate;
-
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : app = instance à initialiser. *
-* *
-* Description : Initialise une application principale pour Chrysalide. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_chrysalide_framework_init(GtkChrysalideFramework *app)
-{
- app->settings = NULL;
-
- app->main_window = NULL;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : app = instance d'objet GLib à traiter. *
-* *
-* Description : Supprime toutes les références externes. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_chrysalide_framework_dispose(GtkChrysalideFramework *app)
-{
- g_clear_object(&app->settings);
-
- g_clear_object(&app->main_window);
-
- G_OBJECT_CLASS(gtk_chrysalide_framework_parent_class)->dispose(G_OBJECT(app));
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : app = instance d'objet GLib à traiter. *
-* *
-* Description : Procède à la libération totale de la mémoire. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_chrysalide_framework_finalize(GtkChrysalideFramework *app)
-{
- G_OBJECT_CLASS(gtk_chrysalide_framework_parent_class)->finalize(G_OBJECT(app));
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Crée une nouvelle application principale pour Chrysalide. *
-* *
-* Retour : Mécanismes mis en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GtkChrysalideFramework *gtk_chrysalide_framework_new(void)
-{
- GtkChrysalideFramework *result; /* Instance à retourner */
-
- result = g_object_new(GTK_TYPE_CHRYSALIDE_FRAMEWORK,
- "application-id", CHRYSALIDE_APP_ID,
- "flags", G_APPLICATION_DEFAULT_FLAGS,
- NULL);
-
- return result;
-
-}
-
-
-
-/* ---------------------------------------------------------------------------------- */
-/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
-/* ---------------------------------------------------------------------------------- */
-
-
-/******************************************************************************
-* *
-* Paramètres : app = application concernée par l'événement. *
-* *
-* Description : Réagit à l'activation de l'application. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_chrysalide_framework_activate(GApplication *app)
-{
- GtkChrysalideFramework *real_app; /* Version réelle de l'instance*/
- GSettings *settings; /* Paramètres globaux */
- GtkWindow *window; /* Fenêtre mise en place */
- GtkCssProvider *css; /* Feuille de style maison */
-
- real_app = GTK_CHRYSALIDE_FRAMEWORK(app);
-
- /* Paramètres globaux */
-
- settings = g_settings_new("re.chrysalide.framework.mainapp");
- real_app->settings = settings;
-
- /* Fenêtre principale */
-
- window = GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(app)));
-
- real_app->main_window = GTK_APPLICATION_WINDOW(window);
- g_object_ref(G_OBJECT(window));
-
- g_settings_bind(settings, "window-width", G_OBJECT(window), "default-width", G_SETTINGS_BIND_DEFAULT);
- g_settings_bind(settings, "window-height", G_OBJECT(window), "default-height", G_SETTINGS_BIND_DEFAULT);
- g_settings_bind(settings, "window-maximized", G_OBJECT(window), "maximized", G_SETTINGS_BIND_DEFAULT);
-
- gtk_window_set_title(window, "Chrysalide");
- gtk_window_present(window);
-
-
-
- do
- {
- GPanelItem *item;
- GtkTiledPanel *panel;
-
- item = find_item_panel_by_type(G_TYPE_WELCOME_PANEL);
-
- panel = g_panel_item_get_panel(item);
- gtk_window_set_child(window, GTK_WIDGET(panel));
-
- unref_object(item);
-
- }
- while (0);
-
-
-
- /* Chargement des extensions de thème */
-
- /*
- css = gtk_css_provider_new();
-
- gtk_css_provider_load_from_resource(css, "/re/chrysalide/framework/glibext/linestyle.css");
-
- gtk_style_context_add_provider_for_display(gtk_widget_get_display(GTK_WIDGET(window)),
- GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- unref_object(css);
- */
-
- css = gtk_css_provider_new();
-
- gtk_css_provider_load_from_resource(css, "/re/chrysalide/framework/gtkext/hexview.css");
-
- gtk_style_context_add_provider_for_display(gtk_widget_get_display(GTK_WIDGET(window)),
- GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- unref_object(css);
-
-
-
-
-
- css = gtk_css_provider_new();
-
- gtk_css_provider_load_from_resource(css, "/re/chrysalide/framework/gui/style.css");
-
- gtk_style_context_add_provider_for_display(gtk_widget_get_display(GTK_WIDGET(window)),
- GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- unref_object(css);
-
-
-}
-
-
-
-/* ---------------------------------------------------------------------------------- */
-/* POINT D'ENTREE PRINCIPAL D'EXECUTION */
-/* ---------------------------------------------------------------------------------- */
-
-
-/******************************************************************************
-* *
-* Paramètres : argc = nombre d'arguments dans la ligne de commande. *
-* argv = arguments de la ligne de commande. *
-* *
-* Description : Point d'entrée du programme. *
-* *
-* Retour : EXIT_SUCCESS si le prgm s'est déroulé sans encombres. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-int main(int argc, char **argv)
-{
- int result; /* Bilan de l'exécution */
- GtkChrysalideFramework *app; /* Gestion d'application GTK */
-
- if (!load_gui_components(AGC_BUFFER_FEATURES | AGC_PANELS))
- return EXIT_FAILURE;
-
- ensure_wm_icon_and_name();
-
- app = gtk_chrysalide_framework_new();
-
- result = g_application_run(G_APPLICATION(app), argc, argv);
-
- g_object_unref(G_OBJECT(app));
-
- unload_gui_components(AGC_BUFFER_FEATURES | AGC_PANELS);
-
- return result;
-
-}
diff --git a/src/framework.h b/src/framework.h
deleted file mode 100644
index e8e88fe..0000000
--- a/src/framework.h
+++ /dev/null
@@ -1,66 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * framework.h - prototypes pour le fichier d'entrée du programme
- *
- * Copyright (C) 2024 Cyrille Bagard
- *
- * This file is part of Chrysalide.
- *
- * Chrysalide is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Chrysalide is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _FRAMEWORK_H
-#define _FRAMEWORK_H
-
-
-#include <glib-object.h>
-
-
-
-/* --------------------- DEFINITION D'APPLICATION PERSONNALISEE --------------------- */
-
-
-#define GTK_TYPE_CHRYSALIDE_FRAMEWORK gtk_chrysalide_framework_get_type()
-#define GTK_CHRYSALIDE_FRAMEWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_CHRYSALIDE_FRAMEWORK, GtkChrysalideFramework))
-#define GTK_IS_CHRYSALIDE_FRAMEWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_CHRYSALIDE_FRAMEWORK))
-#define GTK_CHRYSALIDE_FRAMEWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_CHRYSALIDE_FRAMEWORK, GtkChrysalideFrameworkClass))
-#define GTK_IS_CHRYSALIDE_FRAMEWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_CHRYSALIDE_FRAMEWORK))
-#define GTK_CHRYSALIDE_FRAMEWORK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_CHRYSALIDE_FRAMEWORK, GtkChrysalideFrameworkClass))
-
-
-/* Définition de l'application principale graphique (instance) */
-typedef struct _GtkChrysalideFramework GtkChrysalideFramework;
-
-/* Définition de l'application principale graphique (classe) */
-typedef struct _GtkChrysalideFrameworkClass GtkChrysalideFrameworkClass;
-
-
-/* Indique le type défini pour une application principale graphique de Chrysalide. */
-GType gtk_chrysalide_framework_get_type(void);
-
-/* Crée une nouvelle application principale pour Chrysalide. */
-GtkChrysalideFramework *gtk_chrysalide_framework_new(void);
-
-
-
-/* ---------------------- POINT D'ENTREE PRINCIPAL D'EXECUTION ---------------------- */
-
-
-/* Point d'entrée du programme. */
-int main(int, char **);
-
-
-
-#endif /* _FRAMEWORK_H */
diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am
index 4197989..5ec43d2 100644
--- a/src/gui/Makefile.am
+++ b/src/gui/Makefile.am
@@ -29,7 +29,9 @@ libgui_la_CFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
libgui4_la_SOURCES = \
panel-int.h \
panel.h panel.c \
- resources.h resources.c
+ resources.h resources.c \
+ window-int.h \
+ window.h window.c
libgui4_la_LIBADD = \
core/libguicore4.la \
@@ -47,7 +49,8 @@ SUBDIRS = core panels # dialogs menus panels tb
RES_FILES = \
- style.css
+ style.css \
+ window.ui
resources.c: gresource.xml $(RES_FILES)
glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name gui gresource.xml
diff --git a/src/gui/gresource.xml b/src/gui/gresource.xml
index 437ec51..91d9bc9 100644
--- a/src/gui/gresource.xml
+++ b/src/gui/gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/re/chrysalide/framework/gui">
<file compressed="true">style.css</file>
+ <file compressed="true">window.ui</file>
</gresource>
<gresource prefix="/re/chrysalide/framework/images">
<file compressed="true" alias="chrysalide-logo.svg">../../pixmaps/chrysalide-logo.svg</file>
diff --git a/src/gui/window-int.h b/src/gui/window-int.h
new file mode 100644
index 0000000..d79e189
--- /dev/null
+++ b/src/gui/window-int.h
@@ -0,0 +1,57 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * window.h - prototypes internes pour la construction d'une fenêtre graphique principale
+ *
+ * Copyright (C) 2024 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _GUI_WINDOW_INT_H
+#define _GUI_WINDOW_INT_H
+
+
+#include "window.h"
+#include "../gtkext/grid.h"
+
+
+
+/* Définition de l'application principale graphique (instance) */
+struct _GtkFrameworkWindow
+{
+ GtkApplicationWindow parent; /* A laisser en premier */
+
+ GSettings *settings; /* Paramètres globaux */
+
+ GtkStack *grid; /* Réceptacle de panneaux */
+
+};
+
+/* Définition de l'application principale graphique (classe) */
+struct _GtkFrameworkWindowClass
+{
+ GtkApplicationWindowClass parent; /* A laisser en premier */
+
+};
+
+
+/* Met en place une fenêtre principale pour Chrysalide. */
+bool gtk_framework_window_create(GtkFrameworkWindow *, GtkApplication *);
+
+
+
+#endif /* _GUI_WINDOW_INT_H */
diff --git a/src/gui/window.c b/src/gui/window.c
new file mode 100644
index 0000000..dcdd4d1
--- /dev/null
+++ b/src/gui/window.c
@@ -0,0 +1,235 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * window.c - construction d'une fenêtre graphique principale
+ *
+ * Copyright (C) 2024 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "window.h"
+
+
+#include "window-int.h"
+#include "core/panels.h"
+#include "panels/welcome.h"
+
+
+
+/* Initialise la classe des applications majeures de Chrysalide. */
+static void gtk_framework_window_class_init(GtkFrameworkWindowClass *);
+
+/* Initialise une application principale pour Chrysalide. */
+static void gtk_framework_window_init(GtkFrameworkWindow *);
+
+/* Supprime toutes les références externes. */
+static void gtk_framework_window_dispose(GtkFrameworkWindow *);
+
+/* Procède à la libération totale de la mémoire. */
+static void gtk_framework_window_finalize(GtkFrameworkWindow *);
+
+
+
+/* Indique le type défini pour une fenêtre graphique principale de Chrysalide. */
+G_DEFINE_TYPE(GtkFrameworkWindow, gtk_framework_window, GTK_TYPE_APPLICATION_WINDOW);
+
+
+/******************************************************************************
+* *
+* Paramètres : class = classe à initialiser. *
+* *
+* Description : Initialise la classe des applications majeures de Chrysalide.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_framework_window_class_init(GtkFrameworkWindowClass *class)
+{
+ GObjectClass *object; /* Plus haut niveau équivalent */
+ GtkWidgetClass *widget; /* Classe de haut niveau */
+
+ object = G_OBJECT_CLASS(class);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)gtk_framework_window_dispose;
+ object->finalize = (GObjectFinalizeFunc)gtk_framework_window_finalize;
+
+ widget = GTK_WIDGET_CLASS(class);
+
+ //g_type_ensure(GTK_TYPE_TILING_GRID);
+
+ gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/window.ui");
+
+ gtk_widget_class_bind_template_child(widget, GtkFrameworkWindow, grid);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : window = instance à initialiser. *
+* *
+* Description : Initialise une application principale pour Chrysalide. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_framework_window_init(GtkFrameworkWindow *window)
+{
+ gtk_widget_init_template(GTK_WIDGET(window));
+
+ window->settings = g_settings_new(FRAMEWORK_WINDOW_ID);
+
+ g_settings_bind(window->settings, "window-width", G_OBJECT(window), "default-width", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind(window->settings, "window-height", G_OBJECT(window), "default-height", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind(window->settings, "window-maximized", G_OBJECT(window), "maximized", G_SETTINGS_BIND_DEFAULT);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : window = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_framework_window_dispose(GtkFrameworkWindow *window)
+{
+ gtk_widget_dispose_template(GTK_WIDGET(window), GTK_TYPE_FRAMEWORK_WINDOW);
+
+ g_clear_object(&window->settings);
+
+ G_OBJECT_CLASS(gtk_framework_window_parent_class)->dispose(G_OBJECT(window));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : window = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_framework_window_finalize(GtkFrameworkWindow *window)
+{
+ G_OBJECT_CLASS(gtk_framework_window_parent_class)->finalize(G_OBJECT(window));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : app = application GTK de rattachement. *
+* *
+* Description : Crée une nouvelle application principale pour Chrysalide. *
+* *
+* Retour : Mécanismes mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkApplicationWindow *gtk_framework_window_new(GtkApplication *app)
+{
+ GtkApplicationWindow *result; /* Instance à retourner */
+
+ result = g_object_new(GTK_TYPE_FRAMEWORK_WINDOW, NULL);
+
+ if (!gtk_framework_window_create(GTK_FRAMEWORK_WINDOW(result), app))
+ g_clear_object(&result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : window = instance de fenêtre principale à remplir. *
+* app = application GTK de rattachement. *
+* *
+* Description : Met en place une fenêtre principale pour Chrysalide. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool gtk_framework_window_create(GtkFrameworkWindow *window, GtkApplication *app)
+{
+ bool result; /* Bilan à retourner */
+ GPanelItem *item; /* Définition de panneau */
+ GtkTiledPanel *panel; /* Panneau d'affichage */
+ GtkCssProvider *css; /* Feuille de style maison */
+
+ result = true;
+
+ gtk_window_set_application(GTK_WINDOW(window), app);
+
+ /* Inclusion d'un écran d'accueil */
+
+ item = find_item_panel_by_type(G_TYPE_WELCOME_PANEL);
+
+ panel = g_panel_item_get_panel(item);
+ gtk_stack_add_child(window->grid, GTK_WIDGET(panel));
+
+ unref_object(item);
+
+ /* Chargement des extensions de thème */
+
+ css = gtk_css_provider_new();
+
+ gtk_css_provider_load_from_resource(css, "/re/chrysalide/framework/gtkext/hexview.css");
+
+ gtk_style_context_add_provider_for_display(gtk_widget_get_display(GTK_WIDGET(window)),
+ GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ unref_object(css);
+
+ css = gtk_css_provider_new();
+
+ gtk_css_provider_load_from_resource(css, "/re/chrysalide/framework/gui/style.css");
+
+ gtk_style_context_add_provider_for_display(gtk_widget_get_display(GTK_WIDGET(window)),
+ GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ unref_object(css);
+
+ /* Fin des chargements */
+
+ return result;
+
+}
diff --git a/src/gui/window.h b/src/gui/window.h
new file mode 100644
index 0000000..4e73a76
--- /dev/null
+++ b/src/gui/window.h
@@ -0,0 +1,51 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * window.h - prototypes pour la construction d'une fenêtre graphique principale
+ *
+ * Copyright (C) 2024 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _GUI_WINDOW_H
+#define _GUI_WINDOW_H
+
+
+#include <gtk/gtk.h>
+
+
+#include "../glibext/helpers.h"
+
+
+
+/* Définition d'un identifiant unique */
+#define FRAMEWORK_WINDOW_ID "re.chrysalide.framework.gui"
+
+
+
+#define GTK_TYPE_FRAMEWORK_WINDOW (gtk_framework_window_get_type())
+
+DECLARE_GTYPE(GtkFrameworkWindow, gtk_framework_window, GTK, FRAMEWORK_WINDOW);
+
+
+
+/* Crée une nouvelle application principale pour Chrysalide. */
+GtkApplicationWindow *gtk_framework_window_new(GtkApplication *);
+
+
+
+#endif /* _GUI_WINDOW_H */
diff --git a/src/gui/window.ui b/src/gui/window.ui
new file mode 100644
index 0000000..d9ca32c
--- /dev/null
+++ b/src/gui/window.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GtkFrameworkWindow" parent="GtkApplicationWindow">
+ <property name="title" translatable="no">Chrysalide</property>
+ <property name="default-width">800</property>
+ <property name="default-height">600</property>
+ <property name="icon-name">chrysalide-logo</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkStack" id="grid">
+ <property name="vexpand">TRUE</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/schemas/re.chrysalide.framework.gschema.xml b/src/schemas/re.chrysalide.framework.gschema.xml
index 4a16f12..e8331ff 100644
--- a/src/schemas/re.chrysalide.framework.gschema.xml
+++ b/src/schemas/re.chrysalide.framework.gschema.xml
@@ -1,10 +1,10 @@
<schemalist gettext-domain="chrysalide">
<schema id="re.chrysalide.framework" path="/re/chrysalide/framework/">
- <child schema="re.chrysalide.framework.mainapp" name="mainapp"/>
+ <child schema="re.chrysalide.framework.gui" name="gui"/>
</schema>
- <schema id="re.chrysalide.framework.mainapp" path="/re/chrysalide/framework/mainapp/">
+ <schema id="re.chrysalide.framework.gui" path="/re/chrysalide/framework/gui/">
<key name="window-width" type="i">
<default>600</default>
</key>