summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/Makefile.am1
-rw-r--r--src/gui/dialogs/about.c80
-rw-r--r--src/gui/dialogs/about.h4
-rw-r--r--src/gui/dialogs/about.ui151
-rw-r--r--src/gui/dialogs/gresource.xml16
-rw-r--r--src/gui/menus/help.c12
6 files changed, 207 insertions, 57 deletions
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 <assert.h>
#include <math.h>
#include <stdio.h>
#include <gdk/gdkkeysyms.h>
#include <config.h>
-#include <i18n.h>
-#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, "<span fgcolor='white'>Copyright (C) 2008-2017 Cyrille Bagard</span>");
- 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.37.0 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <object class="GtkWindow" id="window">
+ <property name="width-request">350</property>
+ <property name="height-request">430</property>
+ <property name="can-focus">False</property>
+ <property name="border-width">0</property>
+ <property name="title" translatable="yes">About</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="window-position">center-on-parent</property>
+ <property name="default-width">350</property>
+ <property name="default-height">430</property>
+ <property name="type-hint">dialog</property>
+ <signal name="key-press-event" handler="close_about_window_on_escape" swapped="no"/>
+ <child>
+ <object class="GtkFixed">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <signal name="draw" handler="draw_black_background" swapped="no"/>
+ <child>
+ <object class="GtkLabel">
+ <property name="width-request">350</property>
+ <property name="height-request">20</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="margin-bottom">10</property>
+ <property name="label" translatable="yes">&lt;span fgcolor='white'&gt;Copyright (C) 2008-2020 Cyrille Bagard&lt;/span&gt;</property>
+ <property name="use-markup">True</property>
+ </object>
+ <packing>
+ <property name="y">400</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="logo">
+ <property name="width-request">330</property>
+ <property name="height-request">300</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="resource">/org/chrysalide/gui/dialogs/about/chrysalide-full.png</property>
+ </object>
+ <packing>
+ <property name="x">10</property>
+ <property name="y">10</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="text">
+ <property name="width-request">253</property>
+ <property name="height-request">42</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="resource">/org/chrysalide/gui/dialogs/about/chrysalide_text.png</property>
+ </object>
+ <packing>
+ <property name="x">48</property>
+ <property name="y">324</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="revision">
+ <property name="width-request">14</property>
+ <property name="height-request">18</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="resource">/org/chrysalide/gui/dialogs/about/revision.png</property>
+ </object>
+ <packing>
+ <property name="x">149</property>
+ <property name="y">360</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="revision_0">
+ <property name="width-request">14</property>
+ <property name="height-request">18</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="x">163</property>
+ <property name="y">360</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="revision_1">
+ <property name="width-request">14</property>
+ <property name="height-request">18</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="x">177</property>
+ <property name="y">360</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="revision_2">
+ <property name="width-request">14</property>
+ <property name="height-request">18</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="x">191</property>
+ <property name="y">360</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="revision_3">
+ <property name="width-request">14</property>
+ <property name="height-request">18</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="x">205</property>
+ <property name="y">360</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="revision_4">
+ <property name="width-request">14</property>
+ <property name="height-request">18</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="x">219</property>
+ <property name="y">360</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="revision_5">
+ <property name="width-request">14</property>
+ <property name="height-request">18</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="x">233</property>
+ <property name="y">360</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
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 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/chrysalide/gui/dialogs">
+ <file compressed="true">about.ui</file>
<file compressed="true">bookmark.ui</file>
<file compressed="true">export_graph.ui</file>
<file compressed="true">identity.ui</file>
@@ -11,4 +12,19 @@
<file compressed="true">snapshots.ui</file>
<file compressed="true">storage.ui</file>
</gresource>
+ <gresource prefix="/org/chrysalide/gui/dialogs/about">
+ <file compressed="true" alias="chrysalide-full.png">../../../pixmaps/chrysalide-full.png</file>
+ <file compressed="true" alias="chrysalide_text.png">../../../pixmaps/chrysalide_text.png</file>
+ <file compressed="true" alias="revision.png">../../../pixmaps/revision.png</file>
+ <file compressed="true" alias="revision_0.png">../../../pixmaps/revision_0.png</file>
+ <file compressed="true" alias="revision_1.png">../../../pixmaps/revision_1.png</file>
+ <file compressed="true" alias="revision_2.png">../../../pixmaps/revision_2.png</file>
+ <file compressed="true" alias="revision_3.png">../../../pixmaps/revision_3.png</file>
+ <file compressed="true" alias="revision_4.png">../../../pixmaps/revision_4.png</file>
+ <file compressed="true" alias="revision_5.png">../../../pixmaps/revision_5.png</file>
+ <file compressed="true" alias="revision_6.png">../../../pixmaps/revision_6.png</file>
+ <file compressed="true" alias="revision_7.png">../../../pixmaps/revision_7.png</file>
+ <file compressed="true" alias="revision_8.png">../../../pixmaps/revision_8.png</file>
+ <file compressed="true" alias="revision_9.png">../../../pixmaps/revision_9.png</file>
+ </gresource>
</gresources>
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));
+
}