From 3e9d5cedf701fd8957024f7ddf65238aea9a1eba Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 19 Aug 2020 00:27:06 +0200 Subject: Rebuilt the About window using Glade. --- src/gtkext/easygtk.c | 40 ----------- src/gtkext/easygtk.h | 3 - src/gui/dialogs/Makefile.am | 1 + src/gui/dialogs/about.c | 80 ++++++++-------------- src/gui/dialogs/about.h | 4 +- src/gui/dialogs/about.ui | 151 ++++++++++++++++++++++++++++++++++++++++++ src/gui/dialogs/gresource.xml | 16 +++++ src/gui/menus/help.c | 12 +++- 8 files changed, 207 insertions(+), 100 deletions(-) create mode 100644 src/gui/dialogs/about.ui diff --git a/src/gtkext/easygtk.c b/src/gtkext/easygtk.c index 7021b87..6e42556 100644 --- a/src/gtkext/easygtk.c +++ b/src/gtkext/easygtk.c @@ -141,46 +141,6 @@ GtkWidget *qck_create_scrolled_window(GObject *object, const char *name) /****************************************************************************** * * -* Paramètres : object = espace dédié à l'inscription de références. * -* name = nom à donner au nouveau composant. * -* filename = chemin d'accès complet au fichier à afficher. * -* * -* Description : Crée un composant 'GtkImage'. * -* * -* Retour : Image mise en place. * -* * -* Remarques : Si le chemin est libérable, il est libéré de la mémoire. * -* * -******************************************************************************/ - -GtkWidget *qck_create_image(GObject *object, const char *name, gchar *filename) -{ - GtkWidget *result; /* Résultat à renvoyer */ - - if (filename == NULL) - result = gtk_image_new(); - - else - { - result = gtk_image_new_from_file(filename); - g_free(filename); - } - - if (G_IS_OBJECT(object) && name != NULL) - { - g_object_ref(G_OBJECT(result)); - g_object_set_data_full(object, name, result, (GDestroyNotify)g_object_unref); - } - - gtk_widget_show(result); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : object = espace dédié à l'inscription de références. * * name = nom à donner au nouveau composant. * * caption = intitulé apparaissant sur le composant. * diff --git a/src/gtkext/easygtk.h b/src/gtkext/easygtk.h index 58f1bca..f8335ac 100644 --- a/src/gtkext/easygtk.h +++ b/src/gtkext/easygtk.h @@ -44,9 +44,6 @@ GtkWidget *qck_create_frame(const char *, GtkWidget *, guint, guint, guint, guin /* Met en place un support avec défilement automatique. */ GtkWidget *qck_create_scrolled_window(GObject *, const char *); -/* Crée un composant 'GtkImage'. */ -GtkWidget *qck_create_image(GObject *, const char *, gchar *); - /* Crée un composant 'GtkLabel'. */ GtkWidget *qck_create_label(GObject *, const char *, const char *); diff --git a/src/gui/dialogs/Makefile.am b/src/gui/dialogs/Makefile.am index 8dd3442..2fc4545 100644 --- a/src/gui/dialogs/Makefile.am +++ b/src/gui/dialogs/Makefile.am @@ -4,6 +4,7 @@ BUILT_SOURCES = resources.h resources.c noinst_LTLIBRARIES = libguidialogs.la UI_FILES = \ + about.ui \ bookmark.ui \ export_graph.ui \ identity.ui \ diff --git a/src/gui/dialogs/about.c b/src/gui/dialogs/about.c index 2b95f1d..e2836e5 100644 --- a/src/gui/dialogs/about.c +++ b/src/gui/dialogs/about.c @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * about.h - boîte de dialogue d'information sur le programme * - * Copyright (C) 2015-2019 Cyrille Bagard + * Copyright (C) 2015-2020 Cyrille Bagard * * This file is part of Chrysalide. * @@ -24,16 +24,15 @@ #include "about.h" +#include #include #include #include #include -#include -#include "../../core/paths.h" #include "../../gtkext/easygtk.h" @@ -49,6 +48,7 @@ static gboolean draw_black_background(GtkWidget *, cairo_t *, gpointer); /****************************************************************************** * * * Paramètres : parent = fenêtre parente à surpasser. * +* outb = constructeur à détruire après usage. [OUT] * * * * Description : Construit la fenêtre d'informations sur le logiciel. * * * @@ -58,81 +58,57 @@ static gboolean draw_black_background(GtkWidget *, cairo_t *, gpointer); * * ******************************************************************************/ -GtkWidget *create_about_dialog(GtkWindow *parent) +GtkWidget *create_about_dialog(GtkWindow *parent, GtkBuilder **outb) { GtkWidget *result; /* Fenêtre à renvoyer */ - GtkWidget *fixed; /* Support global */ - gchar *filename; /* Chemin d'accès au fichier */ - GtkWidget *image; /* Image chargée */ + GtkBuilder *builder; /* Constructeur utilisé */ unsigned int revision; /* Numéro de révision */ unsigned int max; /* Nbre. de boucles à effectuer*/ unsigned int i; /* Boucle de parcours */ unsigned int level; /* Unité la plus importante */ - char buffer[16]; /* Nom d'image à forger */ - GtkWidget *label; /* Etiquette inférieure */ + char buffer[64]; /* Nom d'image à forger */ + GtkImage *img; /* Composant d'affichage */ - result = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(result), _("About")); - gtk_widget_set_size_request(result, 350, 430); - gtk_container_set_border_width(GTK_CONTAINER(result), 0); - gtk_window_set_default_size(GTK_WINDOW(result), 350, 430); - gtk_window_set_type_hint(GTK_WINDOW(result), GDK_WINDOW_TYPE_HINT_DIALOG); + builder = gtk_builder_new_from_resource("/org/chrysalide/gui/dialogs/about.ui"); + *outb = builder; - gtk_window_set_modal(GTK_WINDOW(result), TRUE); - gtk_window_set_transient_for(GTK_WINDOW(result), parent); - - g_signal_connect(result, "key_press_event", G_CALLBACK(close_about_window_on_escape), NULL); - - fixed = gtk_fixed_new(); - gtk_widget_show(fixed); - gtk_container_add(GTK_CONTAINER(result), fixed); - - g_signal_connect(fixed, "draw", G_CALLBACK(draw_black_background), NULL); + result = GTK_WIDGET(gtk_builder_get_object(builder, "window")); - /* Images principales */ - - filename = find_pixmap_file("chrysalide-full.png"); - image = qck_create_image(NULL, NULL, filename); - gtk_fixed_put(GTK_FIXED(fixed), image, 10, 10); - gtk_widget_set_size_request(image, 330, 300); - - filename = find_pixmap_file("chrysalide_text.png"); - image = qck_create_image(NULL, NULL, filename); - gtk_fixed_put(GTK_FIXED(fixed), image, 48, 324); - gtk_widget_set_size_request(image, 253, 42); + gtk_window_set_transient_for(GTK_WINDOW(result), parent); /* Numéro de révision */ - filename = find_pixmap_file("revision.png"); - image = qck_create_image(NULL, NULL, filename); - gtk_fixed_put(GTK_FIXED(fixed), image, 149, 360); - gtk_widget_set_size_request(image, 14, 18); - revision = REVISION; max = log(revision) / log(10); + assert(max <= 6); + for (i = 0; i <= max; i++) { + snprintf(buffer, 64, "revision_%u", i); + + img = GTK_IMAGE(gtk_builder_get_object(builder, buffer)); + level = pow(10, max - i); - snprintf(buffer, 16, "revision_%hhu.png", revision / level); + snprintf(buffer, 64, "/org/chrysalide/gui/dialogs/about/revision_%u.png", revision / level); - filename = find_pixmap_file(buffer); - image = qck_create_image(NULL, NULL, filename); - gtk_fixed_put(GTK_FIXED(fixed), image, 163 + i * 14, 360); - gtk_widget_set_size_request(image, 14, 18); + gtk_image_set_from_resource(img, buffer); revision %= level; } - /* Copyright */ + /* Connexion des signaux */ + +#define DEFINE_CALLBACK(cb) #cb, G_CALLBACK(cb) + + gtk_builder_add_callback_symbols(builder, + DEFINE_CALLBACK(close_about_window_on_escape), + DEFINE_CALLBACK(draw_black_background), + NULL); - label = qck_create_label(NULL, NULL, "Copyright (C) 2008-2017 Cyrille Bagard"); - gtk_widget_set_halign(label, GTK_ALIGN_CENTER); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_fixed_put(GTK_FIXED(fixed), label, 0, 400); - gtk_widget_set_size_request(label, 350, 20); + gtk_builder_connect_signals(builder, builder); return result; diff --git a/src/gui/dialogs/about.h b/src/gui/dialogs/about.h index 22c2796..f119f67 100644 --- a/src/gui/dialogs/about.h +++ b/src/gui/dialogs/about.h @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * about.h - prototypes pour la boîte de dialogue d'information sur le programme * - * Copyright (C) 2015-2018 Cyrille Bagard + * Copyright (C) 2015-2020 Cyrille Bagard * * This file is part of Chrysalide. * @@ -30,7 +30,7 @@ /* Construit la fenêtre d'informations sur le logiciel. */ -GtkWidget *create_about_dialog(GtkWindow *); +GtkWidget *create_about_dialog(GtkWindow *, GtkBuilder **); diff --git a/src/gui/dialogs/about.ui b/src/gui/dialogs/about.ui new file mode 100644 index 0000000..0170508 --- /dev/null +++ b/src/gui/dialogs/about.ui @@ -0,0 +1,151 @@ + + + + + + 350 + 430 + False + 0 + About + False + True + center-on-parent + 350 + 430 + dialog + + + + True + False + + + + 350 + 20 + True + False + 10 + <span fgcolor='white'>Copyright (C) 2008-2020 Cyrille Bagard</span> + True + + + 400 + + + + + + 10 + 10 + + + + + 253 + 42 + True + False + /org/chrysalide/gui/dialogs/about/chrysalide_text.png + + + 48 + 324 + + + + + 14 + 18 + True + False + /org/chrysalide/gui/dialogs/about/revision.png + + + 149 + 360 + + + + + 14 + 18 + True + False + + + 163 + 360 + + + + + 14 + 18 + True + False + + + 177 + 360 + + + + + 14 + 18 + True + False + + + 191 + 360 + + + + + 14 + 18 + True + False + + + 205 + 360 + + + + + 14 + 18 + True + False + + + 219 + 360 + + + + + 14 + 18 + True + False + + + 233 + 360 + + + + + + diff --git a/src/gui/dialogs/gresource.xml b/src/gui/dialogs/gresource.xml index f54d5b4..0e12ef2 100644 --- a/src/gui/dialogs/gresource.xml +++ b/src/gui/dialogs/gresource.xml @@ -1,6 +1,7 @@ + about.ui bookmark.ui export_graph.ui identity.ui @@ -11,4 +12,19 @@ snapshots.ui storage.ui + + ../../../pixmaps/chrysalide-full.png + ../../../pixmaps/chrysalide_text.png + ../../../pixmaps/revision.png + ../../../pixmaps/revision_0.png + ../../../pixmaps/revision_1.png + ../../../pixmaps/revision_2.png + ../../../pixmaps/revision_3.png + ../../../pixmaps/revision_4.png + ../../../pixmaps/revision_5.png + ../../../pixmaps/revision_6.png + ../../../pixmaps/revision_7.png + ../../../pixmaps/revision_8.png + ../../../pixmaps/revision_9.png + diff --git a/src/gui/menus/help.c b/src/gui/menus/help.c index 154620a..db19758 100644 --- a/src/gui/menus/help.c +++ b/src/gui/menus/help.c @@ -161,12 +161,18 @@ static void mcb_help_bug_report(GtkMenuItem *menuitem, gpointer unused) static void mcb_help_about(GtkMenuItem *menuitem, gpointer unused) { - GtkWindow *parent; /* Fenêtre principale */ + GtkWindow *editor; /* Fenêtre graphique principale*/ + GtkBuilder *builder; /* Constructeur utilisé */ GtkWidget *dialog; /* Boîte de dialogue à montrer */ - parent = get_editor_window(); + editor = get_editor_window(); + + dialog = create_about_dialog(editor, &builder); + + g_signal_connect_swapped(dialog, "destroy", G_CALLBACK(g_object_unref), builder); - dialog = create_about_dialog(parent); gtk_widget_show(dialog); + g_object_unref(G_OBJECT(editor)); + } -- cgit v0.11.2-87-g4458