diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2024-07-21 23:04:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2024-07-21 23:04:53 (GMT) |
commit | d1874bdcaf52717ebf6f808010d275ca1f1693f3 (patch) | |
tree | c47941b305f6d4867e91edbb0b90e69f63778072 /src/framework.c | |
parent | e4ccb9e56e822628e299527fee0b7325f0d25662 (diff) |
Separate the GTK application and the GTK main window.
Diffstat (limited to 'src/framework.c')
-rw-r--r-- | src/framework.c | 356 |
1 files changed, 0 insertions, 356 deletions
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; - -} |