From 279191e1e01875b65237d0a1bc38dbc729f262fa Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 5 May 2024 20:41:12 +0200 Subject: Create a proper (empty) application using GTK 4. --- .gitignore | 1 + configure.ac | 16 ++++ src/Makefile.am | 14 ++- src/framework.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/framework.h | 66 ++++++++++++++ 5 files changed, 364 insertions(+), 1 deletion(-) create mode 100644 src/framework.c create mode 100644 src/framework.h diff --git a/.gitignore b/.gitignore index 7fa51d9..23045d5 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,7 @@ resources.[ch] # Binaries src/chrysalide src/chrysalide-hub +src/framework src/rost tools/d2c/d2c tools/fuzzing/rost/fast-rost diff --git a/configure.ac b/configure.ac index cfb94bd..25077fe 100644 --- a/configure.ac +++ b/configure.ac @@ -395,6 +395,15 @@ else fi +PKG_CHECK_MODULES(LIBGTK4,gtk4 >= 4.8.3,[libgtk4_found=yes],[libgtk4_found=no]) + +if test "$libgtk4_found" = "yes"; then + libgtk4_version=`pkg-config gtk4 --modversion` +else + libgtk4_version='-' +fi + + if test "x$enable_gtk_support" = "xyes"; then TOOLKIT_CFLAGS="$LIBGTK_CFLAGS $LIBGTHREAD_CFLAGS $LIBGMOD_CFLAGS" @@ -403,6 +412,12 @@ if test "x$enable_gtk_support" = "xyes"; then AC_SUBST(TOOLKIT_CFLAGS) AC_SUBST(TOOLKIT_LIBS) + TOOLKIT4_CFLAGS="$LIBGTK4_CFLAGS" + TOOLKIT4_LIBS="$LIBGTK4_LIBS" + + AC_SUBST(TOOLKIT4_CFLAGS) + AC_SUBST(TOOLKIT4_LIBS) + else TOOLKIT_CFLAGS="$LIBGOBJ_CFLAGS $LIBGTHREAD_CFLAGS $LIBGMOD_CFLAGS" @@ -829,6 +844,7 @@ echo The GLib type, object and signal library..... : $libgobj_version echo The thread support for GLib.................. : $libgthread_version echo The dynamic module loader for GLib........... : $libgmod_version echo The GNU Image Manipulation Program Toolkit... : $libgtk_version +echo The GNU Image Manipulation Program Toolkit.4. : $libgtk4_version echo The XML C parser and toolkit of Gnome........ : $libxml_version echo The flexible interface for archives I/O...... : $libarchive_version echo The small, fast and reliable database engine. : $libsqlite_version diff --git a/src/Makefile.am b/src/Makefile.am index 9dc053e..c4227b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ lib_LTLIBRARIES = libchrysacore.la -bin_PROGRAMS = chrysalide chrysalide-hub rost +bin_PROGRAMS = chrysalide chrysalide-hub rost framework AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/intl @@ -95,6 +95,18 @@ chrysalide_LDADD = $(LIBINTL) +framework_SOURCES = \ + framework.h framework.c + + +framework_CFLAGS = $(TOOLKIT4_CFLAGS) + +framework_LDFLAGS = $(TOOLKIT4_LIBS) + +framework_LDADD = + + + ############################################################ # Gestionnaire de serveurs distants ############################################################ diff --git a/src/framework.c b/src/framework.c new file mode 100644 index 0000000..47e93a0 --- /dev/null +++ b/src/framework.c @@ -0,0 +1,268 @@ + +/* 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 + + +#include "framework.h" + + + +/* --------------------- 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 *); + + + +/* ---------------------------------------------------------------------------------- */ +/* 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", "re.chrysalide.framework", + "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*/ + GtkWindow *window; /* Fenêtre mise en place */ + + real_app = GTK_CHRYSALIDE_FRAMEWORK(app); + + window = GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(app))); + + real_app->main_window = GTK_APPLICATION_WINDOW(window); + g_object_ref(G_OBJECT(window)); + + gtk_window_set_title(window, "Chrysalide"); + gtk_window_set_default_size(window, 400, 300); + gtk_window_present(window); + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* 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 */ + + app = gtk_chrysalide_framework_new(); + + result = g_application_run(G_APPLICATION(app), argc, argv); + + g_object_unref(G_OBJECT(app)); + + return result; + +} diff --git a/src/framework.h b/src/framework.h new file mode 100644 index 0000000..e8e88fe --- /dev/null +++ b/src/framework.h @@ -0,0 +1,66 @@ + +/* 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 . + */ + + +#ifndef _FRAMEWORK_H +#define _FRAMEWORK_H + + +#include + + + +/* --------------------- 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 */ -- cgit v0.11.2-87-g4458