summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-01-21 14:34:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-01-21 14:34:53 (GMT)
commit01f20dc6887fc1d45e026306a4364c9e7b256250 (patch)
tree8df6f067fa8f5bd9adf79bf845218f0b2e005257 /src/gui
parentbd2e3f356103988001956db8588c501cd94e240f (diff)
Enabled the buffer scan again and updated its code.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/export.c97
1 files changed, 92 insertions, 5 deletions
diff --git a/src/gui/dialogs/export.c b/src/gui/dialogs/export.c
index 33fd0c5..0d7a12b 100644
--- a/src/gui/dialogs/export.c
+++ b/src/gui/dialogs/export.c
@@ -48,6 +48,9 @@ static void export_assistant_cancel(GtkAssistant *, gpointer);
/* Ferme l'assistant et déroule la procédure. */
static void export_assistant_close(GtkAssistant *, GObject *);
+/* Réalise l'exportation d'un contenu binaire comme demandé. */
+static void do_binary_export(GCodeBuffer *, const vmpa2t *, const vmpa2t *, buffer_export_context *, BufferExportType, const bool *);
+
/* ----------------------- DEFINITION DU FORMAT D'EXPORTATION ----------------------- */
@@ -187,7 +190,6 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref)
bool display[BLC_DISPLAY]; /* Affichage à garantir */
GLoadedBinary *binary; /* Binaire chargé à parcourir */
GCodeBuffer *buffer; /* Tampon de code à traiter */
- GBufferView *view; /* Vue à exporter */
GObject *support; /* Support interne à supprimer */
/* Type d'exportation */
@@ -259,9 +261,8 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref)
binary = G_LOADED_BINARY(g_object_get_data(ref, "binary"));
buffer = g_loaded_binary_get_disassembled_buffer(binary);
- view = g_buffer_view_new(buffer, NULL);
- g_buffer_view_export(view, &ctx, type, display);
+ do_binary_export(buffer, NULL, NULL, &ctx, type, display);
/* Conclusion */
@@ -277,8 +278,6 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref)
}
- g_object_unref(view);
-
support = G_OBJECT(g_object_get_data(G_OBJECT(assistant), "text_options"));
if (support != NULL) g_object_unref(support);
@@ -290,6 +289,94 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref)
}
+/******************************************************************************
+* *
+* Paramètres : buffer = tampon de données à utiliser. *
+* start = première adresse visée ou 0. *
+* end = dernière adresse visée ou VMPA_MAX. *
+* ctx = éléments à disposition pour l'exportation. *
+* type = type d'exportation attendue. *
+* display = règles d'affichage des colonnes modulables. *
+* *
+* Description : Réalise l'exportation d'un contenu binaire comme demandé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void do_binary_export(GCodeBuffer *buffer, const vmpa2t *start, const vmpa2t *end, buffer_export_context *ctx, BufferExportType type, const bool *display)
+{
+ typedef struct _export_data
+ {
+ buffer_export_context *ctx; /* Contexte d'exportation */
+ BufferExportType type; /* Type d'exportation menée */
+ const bool *display; /* Paramètres d'affichage */
+
+ } export_data;
+
+ export_data data; /* Données à faire suivre */
+ GDelayedWork *work; /* Tâche laborieuse à attendre */
+
+ switch (type)
+ {
+ case BET_HTML:
+ dprintf(ctx->fd, "<HTML>\n");
+ dprintf(ctx->fd, "<HEAD>\n");
+ dprintf(ctx->fd, "\t<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
+ dprintf(ctx->fd, "</HEAD>\n");
+ dprintf(ctx->fd, "<BODY>\n");
+ dprintf(ctx->fd, "<STYLE type=\"text/css\">\n");
+ dprintf(ctx->fd, "TABLE {\n");
+ dprintf(ctx->fd, "\tbackground-color: %s;\n", ctx->bg_color);
+ dprintf(ctx->fd, "\tborder: 0px;\n");
+ dprintf(ctx->fd, "\tfont-family: %s;\n", ctx->font_name);
+ dprintf(ctx->fd, "}\n");
+ dprintf(ctx->fd, "TD {\n");
+ dprintf(ctx->fd, "\tborder: 0px;\n");
+ dprintf(ctx->fd, "\tpadding-left: 8px;\n");
+ dprintf(ctx->fd, "\tpadding-right: 8px;\n");
+ dprintf(ctx->fd, "}\n");
+ g_buffer_segment_export_style(ctx, type);
+ dprintf(ctx->fd, "</STYLE>\n");
+ dprintf(ctx->fd, "<TABLE>\n");
+ break;
+ default:
+ break;
+ }
+
+ data.ctx = ctx;
+ data.type = type;
+ data.display = display;
+
+ bool export_line(GCodeBuffer *buf, GBufferLine *ln, export_data *d)
+ {
+ g_buffer_line_export(ln, d->ctx, d->type, d->display);
+
+ return true;
+
+ }
+
+ work = g_buffer_code_scan(buffer, start, end, _("Exporting binary content"),
+ (process_line_fc)export_line, &data);
+
+ g_delayed_work_wait_for_completion(work);
+
+ switch (type)
+ {
+ case BET_HTML:
+ dprintf(ctx->fd, "</TABLE>\n");
+ dprintf(ctx->fd, "</BODY>\n");
+ dprintf(ctx->fd, "</HTML>\n");
+ break;
+ default:
+ break;
+ }
+
+}
+
+
/* ---------------------------------------------------------------------------------- */
/* DEFINITION DU FORMAT D'EXPORTATION */