diff options
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/Makefile.am | 4 | ||||
-rw-r--r-- | src/gtkext/area.c | 1 | ||||
-rw-r--r-- | src/gtkext/contentview-int.h | 44 | ||||
-rw-r--r-- | src/gtkext/contentview.c | 82 | ||||
-rw-r--r-- | src/gtkext/contentview.h | 35 | ||||
-rw-r--r-- | src/gtkext/gresource.xml | 2 | ||||
-rw-r--r-- | src/gtkext/hexview.c | 43 | ||||
-rw-r--r-- | src/gtkext/hexview.ui | 2 |
8 files changed, 161 insertions, 52 deletions
diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am index 331375f..e33e09e 100644 --- a/src/gtkext/Makefile.am +++ b/src/gtkext/Makefile.am @@ -55,7 +55,7 @@ dev_HEADERS = $(libgtkext_la_SOURCES:%c=) #SUBDIRS = graph -resources.c: gresource.xml $(UI_FILES_4_) +resources.c: gresource.xml $(RES_FILES) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name gtkext gresource.xml resources.h: gresource.xml @@ -64,4 +64,4 @@ resources.h: gresource.xml CLEANFILES = resources.h resources.c -EXTRA_DIST = gresource.xml $(UI_FILES_4_) +EXTRA_DIST = gresource.xml $(RES_FILES) diff --git a/src/gtkext/area.c b/src/gtkext/area.c index 087a726..3c59a59 100644 --- a/src/gtkext/area.c +++ b/src/gtkext/area.c @@ -25,7 +25,6 @@ #include "area-int.h" -#include "../glibext/helpers.h" diff --git a/src/gtkext/contentview-int.h b/src/gtkext/contentview-int.h index 221d796..ba1f17c 100644 --- a/src/gtkext/contentview-int.h +++ b/src/gtkext/contentview-int.h @@ -1,8 +1,8 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * gtkdisplaypanel-int.h - définitions internes propres à l'affichage de contenus de binaire + * gtkcontentview-int.h - définitions internes propres à la base d'affichage pour contenus divers * - * Copyright (C) 2016-2019 Cyrille Bagard + * Copyright (C) 2016-2024 Cyrille Bagard * * This file is part of Chrysalide. * @@ -21,13 +21,20 @@ */ -#ifndef _GTK_DISPLAYPANEL_INT_H -#define _GTK_DISPLAYPANEL_INT_H +#ifndef _GTKEXT_CONTENTVIEW_INT_H +#define _GTKEXT_CONTENTVIEW_INT_H -#include "gtkdisplaypanel.h" +#include "contentview.h" +#include "../glibext/tokenstyle.h" + + + + +#if 0 + #include <stdbool.h> #include <gtk/gtk.h> @@ -78,11 +85,18 @@ typedef void (* apply_scale_fc) (GtkDisplayPanel *, double, double); typedef void (* prepare_export_fc) (GtkDisplayPanel *, bool); +#endif + + /* Composant d'affichage générique (instance) */ -struct _GtkDisplayPanel +struct _GtkContentView { - GtkFixed parent; /* A laisser en premier */ + GtkWidget parent; /* A laisser en premier */ + + GTokenStyle *style; /* Centralisation des styles */ + +#if 0 GtkAdjustment *hadjustment; /* Barre de défilement horiz. */ GtkAdjustment *vadjustment; /* Barre de défilement vert. */ @@ -99,13 +113,17 @@ struct _GtkDisplayPanel bool export; /* Exportation du rendu ? */ +#endif + }; /* Composant d'affichage générique (classe) */ -struct _GtkDisplayPanelClass +struct _GtkContentViewClass { GtkFixedClass parent; /* A laisser en premier */ +#if 0 + compute_requested_size_fc compute_size; /* Calcul de la taille requise */ compute_scroll_inc_fc compute_inc; /* Calcul des bonds */ adjust_scroll_value_fc adjust; /* Réaction à un défilement */ @@ -125,8 +143,13 @@ struct _GtkDisplayPanelClass void (* scaled) (GtkDisplayPanel *, double, double); +#endif + }; + +#if 0 + /* Propriétés propres au composant d'affichage */ typedef enum _ViewPanelProps { @@ -160,5 +183,8 @@ void gtk_display_panel_compute_real_coord(GtkDisplayPanel *, gint *, gint *); void gtk_display_panel_compute_relative_coords(GtkDisplayPanel *, gint *, gint *); +#endif + + -#endif /* _GTK_DISPLAYPANEL_INT_H */ +#endif /* _GTKEXT_CONTENTVIEW_INT_H */ diff --git a/src/gtkext/contentview.c b/src/gtkext/contentview.c index 0f93178..e79d13c 100644 --- a/src/gtkext/contentview.c +++ b/src/gtkext/contentview.c @@ -1,8 +1,8 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * gtkdisplaypanel.c - affichage de contenus de binaire + * contentview.c - base d'affichage pour contenus divers * - * Copyright (C) 2016-2019 Cyrille Bagard + * Copyright (C) 2016-2024 Cyrille Bagard * * This file is part of Chrysalide. * @@ -21,9 +21,15 @@ */ -#include "gtkdisplaypanel.h" +#include "contentview.h" +#include "contentview-int.h" + + + +#if 0 + #include <math.h> @@ -33,21 +39,27 @@ #include "../glibext/gloadedpanel-int.h" +#endif + /* Procède à l'initialisation de l'afficheur générique. */ -static void gtk_display_panel_class_init(GtkDisplayPanelClass *); +static void gtk_content_view_class_init(GtkContentViewClass *); /* Procède à l'initialisation de l'afficheur générique. */ -static void gtk_display_panel_init(GtkDisplayPanel *); +static void gtk_content_view_init(GtkContentView *); /* Procède à l'initialisation de l'interface d'affichage. */ +#if 0 static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *); +#endif /* Supprime toutes les références externes. */ -static void gtk_display_panel_dispose(GtkDisplayPanel *); +static void gtk_content_view_dispose(GtkContentView *); /* Procède à la libération totale de la mémoire. */ -static void gtk_display_panel_finalize(GtkDisplayPanel *); +static void gtk_content_view_finalize(GtkContentView *); + +#if 0 /* Définit une propriété du composant d'affichage. */ static void gtk_display_panel_set_property(GObject *, guint, const GValue *, GParamSpec *); @@ -118,6 +130,15 @@ G_DEFINE_TYPE_WITH_CODE(GtkDisplayPanel, gtk_display_panel, GTK_TYPE_FIXED, G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, NULL) G_IMPLEMENT_INTERFACE(G_TYPE_LOADED_PANEL, gtk_display_panel_loaded_interface_init)); +#endif + + + + +/* Détermine le type du composant d'affichage générique. */ +G_DEFINE_TYPE(GtkContentView, gtk_content_view, GTK_TYPE_WIDGET); + + /****************************************************************************** * * @@ -131,16 +152,18 @@ G_DEFINE_TYPE_WITH_CODE(GtkDisplayPanel, gtk_display_panel, GTK_TYPE_FIXED, * * ******************************************************************************/ -static void gtk_display_panel_class_init(GtkDisplayPanelClass *class) +static void gtk_content_view_class_init(GtkContentViewClass *class) { GObjectClass *object; /* Plus haut niveau équivalent */ - GtkWidgetClass *widget; /* Classe de haut niveau */ - GtkDisplayPanelClass *panel; /* Classe de lus bas niveau */ + //GtkWidgetClass *widget; /* Classe de haut niveau */ + //GtkContentViewClass *panel; /* Classe de lus bas niveau */ object = G_OBJECT_CLASS(class); - object->dispose = (GObjectFinalizeFunc/* ! */)gtk_display_panel_dispose; - object->finalize = (GObjectFinalizeFunc)gtk_display_panel_finalize; + object->dispose = (GObjectFinalizeFunc/* ! */)gtk_content_view_dispose; + object->finalize = (GObjectFinalizeFunc)gtk_content_view_finalize; + +#if 0 object->set_property = gtk_display_panel_set_property; object->get_property = gtk_display_panel_get_property; @@ -167,17 +190,19 @@ static void gtk_display_panel_class_init(GtkDisplayPanelClass *class) g_signal_new("scaled", GTK_TYPE_DISPLAY_PANEL, G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(GtkDisplayPanelClass, scaled), + G_STRUCT_OFFSET(GtkContentViewClass, scaled), NULL, NULL, g_cclosure_user_marshal_VOID__DOUBLE_DOUBLE, G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE); +#endif + } /****************************************************************************** * * -* Paramètres : panel = composant GTK à initialiser. * +* Paramètres : view = composant GTK à initialiser. * * * * Description : Procède à l'initialisation de l'afficheur générique. * * * @@ -187,18 +212,25 @@ static void gtk_display_panel_class_init(GtkDisplayPanelClass *class) * * ******************************************************************************/ -static void gtk_display_panel_init(GtkDisplayPanel *panel) +static void gtk_content_view_init(GtkContentView *view) { + view->style = g_token_style_new(GTK_WIDGET(view)); + + + +#if 0 gtk_widget_set_has_window(GTK_WIDGET(panel), TRUE); gtk_widget_set_can_focus(GTK_WIDGET(panel), TRUE); panel->scale = 1.0; panel->export = false; +#endif } +#if 0 /****************************************************************************** * * * Paramètres : iface = interface GLib à initialiser. * @@ -222,11 +254,12 @@ static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *iface iface->cache_glance = (cache_loaded_glance_fc)gtk_display_panel_cache_glance; } +#endif /****************************************************************************** * * -* Paramètres : panel = instance d'objet GLib à traiter. * +* Paramètres : view = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * * * @@ -236,23 +269,28 @@ static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *iface * * ******************************************************************************/ -static void gtk_display_panel_dispose(GtkDisplayPanel *panel) +static void gtk_content_view_dispose(GtkContentView *view) { + g_clear_object(&view->style); + + + /* g_clear_object(&panel->hadjustment); g_clear_object(&panel->vadjustment); g_clear_object(&panel->options); g_clear_object(&panel->binary); + */ - G_OBJECT_CLASS(gtk_display_panel_parent_class)->dispose(G_OBJECT(panel)); + G_OBJECT_CLASS(gtk_content_view_parent_class)->dispose(G_OBJECT(view)); } /****************************************************************************** * * -* Paramètres : panel = instance d'objet GLib à traiter. * +* Paramètres : view = instance d'objet GLib à traiter. * * * * Description : Procède à la libération totale de la mémoire. * * * @@ -262,13 +300,14 @@ static void gtk_display_panel_dispose(GtkDisplayPanel *panel) * * ******************************************************************************/ -static void gtk_display_panel_finalize(GtkDisplayPanel *panel) +static void gtk_content_view_finalize(GtkContentView *view) { - G_OBJECT_CLASS(gtk_display_panel_parent_class)->finalize(G_OBJECT(panel)); + G_OBJECT_CLASS(gtk_content_view_parent_class)->finalize(G_OBJECT(view)); } +#if 0 /****************************************************************************** * * * Paramètres : object = instance de composant GTK à manipuler. * @@ -1346,3 +1385,4 @@ static void gtk_display_panel_cache_glance(GtkDisplayPanel *panel, cairo_t *cair GTK_DISPLAY_PANEL_GET_CLASS(panel)->cache_glance(panel, cairo, area, scale); } +#endif diff --git a/src/gtkext/contentview.h b/src/gtkext/contentview.h index 58d460f..e0660ff 100644 --- a/src/gtkext/contentview.h +++ b/src/gtkext/contentview.h @@ -1,8 +1,8 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * gtkdisplaypanel.h - prototypes pour l'affichage de contenus de binaire + * contentview.h - prototypes pour la base d'affichage pour contenus divers * - * Copyright (C) 2016-2019 Cyrille Bagard + * Copyright (C) 2016-2024 Cyrille Bagard * * This file is part of Chrysalide. * @@ -21,10 +21,32 @@ */ -#ifndef _GTKEXT_DISPLAYPANEL_H -#define _GTKEXT_DISPLAYPANEL_H +#ifndef _GTKEXT_CONTENTVIEW_H +#define _GTKEXT_CONTENTVIEW_H +#include <gtk/gtk.h> + + +#include "../glibext/helpers.h" + + + +#define GTK_TYPE_CONTENT_VIEW (gtk_content_view_get_type()) + +DECLARE_GTYPE(GtkContentView, gtk_content_view, GTK, CONTENT_VIEW); + + + + + + + + + + +#if 0 + #include <glib-object.h> #include <stdbool.h> @@ -74,5 +96,8 @@ GObject *gtk_display_panel_get_active_object(const GtkDisplayPanel *); void gtk_display_panel_request_move(GtkDisplayPanel *, const vmpa2t *); +#endif + + -#endif /* _GTKEXT_DISPLAYPANEL_H */ +#endif /* _GTKEXT_CONTENTVIEW_H */ diff --git a/src/gtkext/gresource.xml b/src/gtkext/gresource.xml index 2ee8977..225b2a4 100644 --- a/src/gtkext/gresource.xml +++ b/src/gtkext/gresource.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource prefix="/re/chrysalide/framework/gtkext"> - <file compressed="true">hexview.ui</file> <file compressed="true">hexview.css</file> + <file compressed="true">hexview.ui</file> </gresource> </gresources> diff --git a/src/gtkext/hexview.c b/src/gtkext/hexview.c index 7acf131..717c1bc 100644 --- a/src/gtkext/hexview.c +++ b/src/gtkext/hexview.c @@ -25,16 +25,17 @@ #include "area.h" +#include "contentview-int.h" /* ------------------------- BASES D'UN COMPOSANT GRAPHIQUE ------------------------- */ -/* Composant d'affichage générique (instance) */ +/* Composant d'affichage d'octets bruts et imprimables (instance) */ struct _GtkHexView { - GtkWidget parent; /* A laisser en premier */ + GtkContentView parent; /* A laisser en premier */ union { @@ -56,10 +57,10 @@ struct _GtkHexView }; -/* Composant d'affichage générique (classe) */ +/* Composant d'affichage d'octets bruts et imprimables (classe) */ struct _GtkHexViewClass { - GtkWidgetClass parent; /* A laisser en premier */ + GtkContentViewClass parent; /* A laisser en premier */ }; @@ -83,6 +84,7 @@ void demo_snapshot (GtkWidget *widget, GtkSnapshot *snapshot, GtkWidget *parent) + /* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ @@ -103,7 +105,7 @@ static void gtk_hex_view_measure(GtkWidget *, GtkOrientation, int, int *, int *, /* Détermine le type du composant d'affichage générique. */ -G_DEFINE_TYPE(GtkHexView, gtk_hex_view, GTK_TYPE_WIDGET); +G_DEFINE_TYPE(GtkHexView, gtk_hex_view, GTK_TYPE_CONTENT_VIEW); /****************************************************************************** @@ -235,6 +237,8 @@ void demo_snapshot (GtkWidget *widget, GtkSnapshot *snapshot, GtkWidget *parent) w = gtk_widget_get_width (widget) / 2.0; h = gtk_widget_get_height (widget) / 2.0; + h /= 2.0; + gtk_snapshot_append_color (snapshot, &red, &GRAPHENE_RECT_INIT(0, 0, w, h)); gtk_snapshot_append_color (snapshot, &green, @@ -244,16 +248,31 @@ void demo_snapshot (GtkWidget *widget, GtkSnapshot *snapshot, GtkWidget *parent) gtk_snapshot_append_color (snapshot, &blue, &GRAPHENE_RECT_INIT(w, h, w, h)); - /* - printf("[widget] CSS name: %s\n", gtk_widget_get_css_name(widget)); - char **iter; - iter = gtk_widget_get_css_classes(widget); - while (*iter) - printf("[widget] CSS classes: %s\n", *iter); - */ + cairo_t *cr; + int x; + + x = 0; + + cr = gtk_snapshot_append_cairo(snapshot, &GRAPHENE_RECT_INIT(0, 0, w * 2, h * 2)); + + g_token_style_draw_text(GTK_CONTENT_VIEW(parent)->style, + TRT_RAW_FULL, + cr, + &x, 0, + "A.A", 3); + + g_token_style_draw_text(GTK_CONTENT_VIEW(parent)->style, + TRT_RAW_NULL, + cr, + &x, 0, + "A.A", 3); + + cairo_destroy(cr); + + } diff --git a/src/gtkext/hexview.ui b/src/gtkext/hexview.ui index d2f6849..df657ca 100644 --- a/src/gtkext/hexview.ui +++ b/src/gtkext/hexview.ui @@ -1,5 +1,5 @@ <interface> - <template class="GtkHexView" parent="GtkWidget"> + <template class="GtkHexView" parent="GtkContentView"> <property name="css-name">GtkHexView</property> <child> <object class="GtkComposingArea" id="offsets"> |