[ghex: 107/107] Merge branch 'gtk4-port'
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex: 107/107] Merge branch 'gtk4-port'
- Date: Mon, 6 Dec 2021 20:23:48 +0000 (UTC)
commit 084b0a816b2e72bc245e758f4307808683ed3c8b
Merge: 2bd5cb6 362000c
Author: Logan Rathbone <poprocks gmail com>
Date: Mon Dec 6 15:23:09 2021 -0500
Merge branch 'gtk4-port'
.gitlab-ci.yml | 7 +-
data/{gtkhex-3.pc.in => gtkhex-4.pc.in} | 8 +-
data/meson.build | 58 +-
...ata.xml.in => org.gnome.GHex.appdata.xml.in.in} | 17 +-
...Hex.desktop.in => org.gnome.GHex.desktop.in.in} | 4 +-
data/org.gnome.GHex.gschema.xml | 35 -
data/org.gnome.GHex.gschema.xml.in | 44 +
meson.build | 77 +-
meson_options.txt | 1 +
org.gnome.GHex.json => org.gnome.GHex.Devel.json | 5 +-
po/POTFILES.in | 2 +-
src/accessiblegtkhex.c | 512 ---
src/accessiblegtkhex.h | 63 -
src/accessiblegtkhexfactory.c | 99 -
src/accessiblegtkhexfactory.h | 64 -
src/chartable.c | 186 +-
src/chartable.h | 17 +-
src/common-ui.c | 382 ++
src/common-ui.h | 56 +
src/{config.c => configuration.c} | 155 +-
src/configuration.h | 79 +-
src/context-menu.ui | 53 +
src/converter.c | 286 +-
src/converter.h | 33 +-
src/factory.c | 65 -
src/factory.h | 30 -
src/findreplace.c | 1612 +++++----
src/findreplace.h | 119 +-
src/ghex-application-window.c | 2004 ++++++++++
src/ghex-application-window.h | 62 +
src/ghex-application-window.ui | 292 ++
src/ghex-notebook-tab.c | 252 ++
src/ghex-notebook-tab.h | 48 +
src/ghex-ui.xml | 59 -
src/ghex-window.c | 1377 -------
src/ghex-window.h | 114 -
src/ghex.gresource.xml | 36 +-
src/gtkhex-layout-manager.c | 451 +++
src/gtkhex-layout-manager.h | 63 +
src/gtkhex-paste-data.c | 133 +
src/gtkhex-paste-data.h | 47 +
src/gtkhex.c | 3824 +++++++++++---------
src/gtkhex.h | 153 +-
src/help-overlay.ui | 120 +
src/hex-dialog.c | 193 +-
src/hex-dialog.h | 48 +-
src/hex-document-ui.c | 170 -
src/hex-document.c | 491 +--
src/hex-document.h | 126 +-
src/main.c | 171 +-
src/meson.build | 37 +-
src/paste-special.c | 767 ++++
src/{gtkhex-private.h => paste-special.h} | 33 +-
src/paste-special.ui | 65 +
src/preferences.c | 939 +++--
src/preferences.h | 47 +-
src/preferences.ui | 265 ++
src/print.c | 94 +-
src/print.h | 41 +-
src/ui.c | 918 -----
src/ui.h | 93 -
61 files changed, 9737 insertions(+), 7865 deletions(-)
---
diff --cc data/org.gnome.GHex.appdata.xml.in.in
index fbc94ee,446eb01..5949e76
--- a/data/org.gnome.GHex.appdata.xml.in.in
+++ b/data/org.gnome.GHex.appdata.xml.in.in
@@@ -26,14 -26,7 +26,9 @@@
<kudo>ModernToolkit</kudo>
<kudo>UserDocs</kudo>
</kudos>
- <provides>
- <binary>ghex</binary>
- <id>ghex.desktop</id>
- <id>org.gnome.ghex</id>
- </provides>
<releases>
+ <release version="3.41.1" date="2021-12-04"/>
+ <release version="3.41.0" date="2021-09-24"/>
<release version="3.18.4" date="2019-07-13"/>
<release version="3.18.3" date="2016-10-12"/>
<release version="3.18.2" date="2016-06-13"/>
diff --cc src/findreplace.c
index 1b65baa,3f7cc3f..8fa0e26
--- a/src/findreplace.c
+++ b/src/findreplace.c
@@@ -21,514 -30,108 +30,107 @@@
Author: Jaka Mocnik <jaka gnu org>
*/
- #ifdef HAVE_CONFIG_H
- # include <config.h>
- #endif
-
- #include <gtk/gtk.h>
- #include <glib/gi18n.h>
-
#include "findreplace.h"
- #include "ui.h"
- #include "gtkhex.h"
- #include "configuration.h"
-
- static gint find_delete_event_cb(GtkWidget *w, GdkEventAny *e,
- FindDialog *dialog);
- static void find_cancel_cb(GtkWidget *w, FindDialog *dialog);
- static gint advanced_find_delete_event_cb(GtkWidget *w, GdkEventAny *e,
- AdvancedFindDialog *dialog);
- static void advanced_find_close_cb(GtkWidget *w, AdvancedFindDialog *dialog);
-
- static void find_next_cb(GtkButton *button, FindDialog *);
- static void find_prev_cb(GtkButton *button, FindDialog *);
- static void replace_next_cb(GtkButton *button, gpointer);
- static void replace_one_cb(GtkButton *button, gpointer);
- static void replace_all_cb(GtkButton *button, gpointer);
- static void goto_byte_cb(GtkButton *button, GtkWidget *);
- static gint get_search_string(HexDocument *doc, gchar **str);
-
- static void advanced_find_add_add_cb(GtkButton *button,
- AdvancedFind_AddDialog *dialog);
- static void advanced_find_add_cb(GtkButton *button, AdvancedFindDialog *);
- static void advanced_find_delete_cb(GtkButton *button, AdvancedFindDialog *dialog);
- static void advanced_find_next_cb(GtkButton *button, AdvancedFindDialog *dialog);
- static void advanced_find_prev_cb(GtkButton *button, AdvancedFindDialog *dialog);
-
-
- FindDialog *find_dialog = NULL;
- ReplaceDialog *replace_dialog = NULL;
- JumpDialog *jump_dialog = NULL;
-
- /* basic structure to hold private information to be stored in the
- * gtk list.
- */
- typedef struct
- {
- gchar *str;
- gint str_len;
- GtkHex_AutoHighlight *auto_highlight;
- } AdvancedFind_ListData;
- static GtkWidget *create_hex_view(HexDocument *doc)
- {
- GtkWidget *gh = hex_document_add_view(doc);
+ #include <config.h>
- gtk_hex_set_group_type(GTK_HEX(gh), def_group_type);
- if (def_metrics && def_font_desc) {
- gtk_hex_set_font(GTK_HEX(gh), def_metrics, def_font_desc);
- }
- gtk_hex_set_insert_mode(GTK_HEX(gh), TRUE);
- gtk_hex_set_geometry(GTK_HEX(gh), 16, 4);
- return gh;
- }
+ /* DEFINES */
- /* Helper functions to set up copy/paste keybindings */
- static gboolean
- keypress_cb (GtkWidget *dialog, GdkEventKey *event, gpointer user_data)
- {
- GtkWidget *gh = gtk_window_get_focus (GTK_WINDOW(dialog));
+ #define JUMP_DIALOG_CSS_NAME "jumpdialog"
- /* If there isn't a GtkHex widget with focus, bail out. */
- if (! GTK_IS_HEX (gh)) goto out;
+ /* GOBJECT DEFINITIONS */
- /* Otherwise, handle clipboard shortcuts. */
- if (event->state & GDK_CONTROL_MASK)
- {
- switch (event->keyval)
- {
- case 'c':
- gtk_hex_copy_to_clipboard (GTK_HEX(gh));
- return GDK_EVENT_STOP;
- break;
+ enum signal_types {
+ CLOSED,
+ LAST_SIGNAL
+ };
- case 'x':
- gtk_hex_cut_to_clipboard (GTK_HEX(gh));
- return GDK_EVENT_STOP;
- break;
-
- case 'v':
- gtk_hex_paste_from_clipboard (GTK_HEX(gh));
- return GDK_EVENT_STOP;
- break;
- }
- }
- out:
- return GDK_EVENT_PROPAGATE;
- }
+ static guint signals[LAST_SIGNAL];
- static void
- setup_clipboard_keybindings (GtkWidget *dialog)
+ typedef struct
{
- /* sanity check: all find/replace/etc. dialogs are GtkDialogs at their core */
- g_assert (GTK_IS_DIALOG (dialog));
+ GtkHex *gh;
+ GtkHex_AutoHighlight *auto_highlight;
- g_signal_connect (dialog, "key-press-event", G_CALLBACK(keypress_cb), NULL);
- }
+ } PaneDialogPrivate;
- FindDialog *create_find_dialog()
- {
- FindDialog *dialog;
- GtkWidget *frame;
+ G_DEFINE_TYPE_WITH_PRIVATE (PaneDialog, pane_dialog, GTK_TYPE_WIDGET)
- dialog = g_new0(FindDialog, 1);
+ typedef struct {
+ HexDocument *f_doc;
+ GtkWidget *f_gh;
-
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *f_next, *f_prev, *f_clear;
+ GtkWidget *close;
- dialog->window = gtk_dialog_new();
- g_signal_connect(G_OBJECT(dialog->window), "delete_event",
- G_CALLBACK(find_delete_event_cb), dialog);
-
- create_dialog_title(dialog->window, _("GHex (%s): Find Data"));
-
- dialog->f_doc = hex_document_new();
- dialog->f_gh = create_hex_view(dialog->f_doc);
- frame = gtk_frame_new(_("Find String"));
- gtk_container_add(GTK_CONTAINER(frame), dialog->f_gh);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), frame,
- TRUE, TRUE, 0);
- gtk_widget_show(frame);
- gtk_widget_show(dialog->f_gh);
-
- dialog->f_next = create_button(dialog->window, GTK_STOCK_GO_FORWARD, _("Find _Next"));
- g_signal_connect (G_OBJECT (dialog->f_next), "clicked",
- G_CALLBACK(find_next_cb), dialog);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->f_next,
- TRUE, TRUE, 0);
- gtk_widget_set_can_default(dialog->f_next, TRUE);
- gtk_widget_show(dialog->f_next);
- dialog->f_prev = create_button(dialog->window, GTK_STOCK_GO_BACK, _("Find _Previous"));
- g_signal_connect (G_OBJECT (dialog->f_prev), "clicked",
- G_CALLBACK(find_prev_cb), dialog);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->f_prev,
- TRUE, TRUE, 0);
-
- gtk_widget_set_can_default(dialog->f_prev, TRUE);
- gtk_widget_show(dialog->f_prev);
-
- dialog->f_close = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- g_signal_connect (G_OBJECT (dialog->f_close),
- "clicked", G_CALLBACK(find_cancel_cb),
- dialog);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->f_close,
- TRUE, TRUE, 0);
-
- gtk_widget_set_can_default(dialog->f_close, TRUE);
- gtk_widget_show(dialog->f_close);
-
-
gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), 2);
- gtk_box_set_spacing(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), 2);
-
- setup_clipboard_keybindings (dialog->window);
-
- if (GTK_IS_ACCESSIBLE (gtk_widget_get_accessible (dialog->f_gh))) {
- add_atk_namedesc (dialog->f_gh, _("Find Data"), _("Enter the hex data or ASCII data to search
for"));
- add_atk_namedesc (dialog->f_next, _("Find Next"), _("Finds the next occurrence of the search
string"));
- add_atk_namedesc (dialog->f_prev, _("Find previous"), _("Finds the previous occurrence of the
search string "));
- add_atk_namedesc (dialog->f_close, _("Cancel"), _("Closes find data window"));
- }
+ } FindDialogPrivate;
- return dialog;
- }
+ G_DEFINE_TYPE_WITH_PRIVATE (FindDialog, find_dialog, PANE_TYPE_DIALOG)
- static AdvancedFind_AddDialog *create_advanced_find_add_dialog(AdvancedFindDialog *parent)
- {
- AdvancedFind_AddDialog *dialog = g_new0(AdvancedFind_AddDialog, 1);
- GtkWidget *button, *frame, *sep;
+ struct _ReplaceDialog {
+ FindDialog parent_instance;
- dialog->window = gtk_dialog_new();
- gtk_widget_hide(dialog->window);
- g_signal_connect(G_OBJECT(dialog->window), "delete_event",
- G_CALLBACK(delete_event_cb), dialog->window);
+ GtkWidget *r_gh;
+ HexDocument *r_doc;
- create_dialog_title(dialog->window, _("GHex (%s): Find Data: Add search"));
-
- dialog->f_doc = hex_document_new();
- dialog->f_gh = create_hex_view(dialog->f_doc);
- frame = gtk_frame_new(_("Find String"));
- gtk_container_add(GTK_CONTAINER(frame), dialog->f_gh);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), frame,
- TRUE, TRUE, 0);
- gtk_widget_show(frame);
- gtk_widget_show(dialog->f_gh);
-
- sep = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), sep,
- FALSE, FALSE, 0);
-
- dialog->colour = gtk_color_selection_new();
- gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(dialog->colour),
- FALSE);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))),
- dialog->colour, FALSE, FALSE, 0);
- gtk_widget_show(dialog->colour);
-
- button = create_button(dialog->window, GTK_STOCK_ADD, _("Add"));
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), button,
- TRUE, TRUE, 0);
- g_signal_connect (G_OBJECT (button),
- "clicked", G_CALLBACK(advanced_find_add_add_cb),
- dialog);
- gtk_widget_set_can_default(button, TRUE);
- gtk_widget_show(button);
-
- button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
- g_signal_connect (G_OBJECT (button),
- "clicked", G_CALLBACK(cancel_cb),
- dialog->window);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), button,
- TRUE, TRUE, 0);
- gtk_widget_set_can_default(button, TRUE);
- gtk_widget_show(button);
-
- setup_clipboard_keybindings (dialog->window);
-
- return dialog;
- }
-
- AdvancedFindDialog *create_advanced_find_dialog(GHexWindow *parent)
- {
- AdvancedFindDialog *dialog;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
-
- GtkWidget *sep;
-
- dialog = g_new0(AdvancedFindDialog, 1);
-
- dialog->parent = parent;
-
- dialog->addDialog = create_advanced_find_add_dialog(dialog);
-
- dialog->window = gtk_dialog_new();
- g_signal_connect(G_OBJECT(dialog->window), "delete_event",
- G_CALLBACK(advanced_find_delete_event_cb), dialog);
-
- gtk_window_set_default_size(GTK_WINDOW(dialog->window), 300, 350);
-
- create_dialog_title(dialog->window, _("GHex (%s): Find Data"));
-
- dialog->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))),
- dialog->hbox, TRUE, TRUE, 4);
- gtk_widget_show(dialog->hbox);
-
- dialog->list = gtk_list_store_new(3,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER, G_TYPE_POINTER);
- dialog->tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list));
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->tree));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Search String"),
-
renderer,
-
"text", 0,
-
"foreground", 1,
-
NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tree), column);
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Highlight Colour"),
-
renderer,
-
"background", 1,
-
NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tree), column);
-
- gtk_box_pack_start(GTK_BOX(dialog->hbox), dialog->tree,
- TRUE, TRUE, 4);
- gtk_widget_show (dialog->tree);
-
- dialog->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(dialog->hbox), dialog->vbox,
- FALSE, FALSE, 4);
- gtk_widget_show(dialog->vbox);
-
- dialog->f_next = create_button(dialog->window, GTK_STOCK_GO_FORWARD, _("Find _Next"));
- gtk_box_pack_start(GTK_BOX(dialog->vbox), dialog->f_next,
- FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (dialog->f_next),
- "clicked", G_CALLBACK(advanced_find_next_cb),
- dialog);
- gtk_widget_set_can_default(dialog->f_next, TRUE);
- gtk_widget_show(dialog->f_next);
-
- dialog->f_prev = create_button(dialog->window, GTK_STOCK_GO_BACK, _("Find _Previous"));
- gtk_box_pack_start(GTK_BOX(dialog->vbox), dialog->f_prev,
- FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (dialog->f_prev),
- "clicked", G_CALLBACK(advanced_find_prev_cb),
- dialog);
- gtk_widget_set_can_default(dialog->f_prev, TRUE);
- gtk_widget_show(dialog->f_prev);
-
- sep = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_start(GTK_BOX(dialog->vbox), sep, FALSE, FALSE, 4);
- gtk_widget_show(sep);
-
- dialog->f_new = create_button(dialog->window, GTK_STOCK_ADD, _("_Add New"));
- gtk_box_pack_start(GTK_BOX(dialog->vbox), dialog->f_new,
- FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (dialog->f_new),
- "clicked", G_CALLBACK(advanced_find_add_cb),
- dialog);
- gtk_widget_set_can_default(dialog->f_new, TRUE);
- gtk_widget_show(dialog->f_new);
-
- dialog->f_remove = create_button(dialog->window, GTK_STOCK_REMOVE, _("_Remove Selected"));
- gtk_box_pack_start(GTK_BOX(dialog->vbox), dialog->f_remove,
- FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (dialog->f_remove),
- "clicked", G_CALLBACK(advanced_find_delete_cb),
- dialog);
- gtk_widget_set_can_default(dialog->f_remove, TRUE);
- gtk_widget_show(dialog->f_remove);
-
- dialog->f_close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
- g_signal_connect(G_OBJECT(dialog->f_close),
- "clicked", G_CALLBACK(advanced_find_close_cb),
- dialog);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))),
- dialog->f_close, TRUE, TRUE, 0);
- gtk_widget_set_can_default(dialog->f_close, TRUE);
- gtk_widget_show(dialog->f_close);
-
- if (GTK_IS_ACCESSIBLE (gtk_widget_get_accessible (dialog->f_close)))
- {
- add_atk_namedesc(dialog->f_close, _("Close"), _("Closes advanced find window"));
- }
+ GtkWidget *r_frame;
+ GtkWidget *replace, *replace_all;
+ };
- return dialog;
- }
+ G_DEFINE_TYPE (ReplaceDialog, replace_dialog, FIND_TYPE_DIALOG)
- static void delete_advanced_find_add_dialog(AdvancedFind_AddDialog *dialog)
- {
- gtk_widget_destroy(GTK_WIDGET(dialog->window));
- g_free(dialog);
- }
+ struct _JumpDialog {
+ PaneDialog parent_instance;
- static gboolean advanced_find_foreachfunc_cb (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
- {
- AdvancedFind_ListData *udata;
- GtkHex *gh = (GtkHex *)data;
- gtk_tree_model_get(model, iter, 2, &udata, -1);
- gtk_hex_delete_autohighlight(gh, udata->auto_highlight);
- if(NULL != udata->str)
- g_free(udata->str);
- g_free(udata);
- return FALSE;
- }
+ GtkWidget *box;
+ GtkWidget *label;
+ GtkWidget *int_entry;
+ GtkWidget *ok, *cancel;
+ };
- void delete_advanced_find_dialog(AdvancedFindDialog *dialog)
- {
- delete_advanced_find_add_dialog(dialog->addDialog);
- gtk_tree_model_foreach(GTK_TREE_MODEL(dialog->list),
- advanced_find_foreachfunc_cb, (gpointer
*)dialog->parent->gh);
- g_free(dialog);
- }
+ G_DEFINE_TYPE (JumpDialog, jump_dialog, PANE_TYPE_DIALOG)
- ReplaceDialog *create_replace_dialog()
- {
- ReplaceDialog *dialog;
- GtkWidget *frame;
- dialog = g_new0(ReplaceDialog, 1);
+ /* PRIVATE FUNCTION DECLARATIONS */
- dialog->window = gtk_dialog_new();
- g_signal_connect(G_OBJECT(dialog->window), "delete_event",
- G_CALLBACK(delete_event_cb), dialog->window);
-
- create_dialog_title(dialog->window, _("GHex (%s): Find & Replace Data"));
-
- dialog->f_doc = hex_document_new();
- dialog->f_gh = create_hex_view(dialog->f_doc);
- frame = gtk_frame_new(_("Find String"));
- gtk_container_add(GTK_CONTAINER(frame), dialog->f_gh);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), frame,
- TRUE, TRUE, 0);
- gtk_widget_show(frame);
- gtk_widget_show(dialog->f_gh);
-
- dialog->r_doc = hex_document_new();
- dialog->r_gh = create_hex_view(dialog->r_doc);
- frame = gtk_frame_new(_("Replace With"));
- gtk_container_add(GTK_CONTAINER(frame), dialog->r_gh);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), frame,
- TRUE, TRUE, 0);
- gtk_widget_show(frame);
- gtk_widget_show(dialog->r_gh);
-
- dialog->next = create_button(dialog->window, GTK_STOCK_GO_FORWARD, _("Find _next"));
- g_signal_connect (G_OBJECT (dialog->next),
- "clicked", G_CALLBACK(replace_next_cb),
- NULL);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->next,
- TRUE, TRUE, 0);
- gtk_widget_set_can_default(dialog->next, TRUE);
- gtk_widget_show(dialog->next);
- dialog->replace = gtk_button_new_with_mnemonic(_("_Replace"));
- g_signal_connect (G_OBJECT (dialog->replace),
- "clicked", G_CALLBACK(replace_one_cb),
- NULL);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->replace,
- TRUE, TRUE, 0);
- gtk_widget_set_can_default(dialog->replace, TRUE);
- gtk_widget_show(dialog->replace);
- dialog->replace_all= gtk_button_new_with_mnemonic(_("Replace _All"));
- g_signal_connect (G_OBJECT (dialog->replace_all),
- "clicked", G_CALLBACK(replace_all_cb),
- NULL);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))),
dialog->replace_all,
- TRUE, TRUE, 0);
- gtk_widget_set_can_default(dialog->replace_all, TRUE);
- gtk_widget_show(dialog->replace_all);
-
- dialog->close = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- g_signal_connect (G_OBJECT (dialog->close),
- "clicked", G_CALLBACK(cancel_cb),
- dialog->window);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->close,
- TRUE, TRUE, 0);
- gtk_widget_set_can_default(dialog->close, TRUE);
- gtk_widget_show(dialog->close);
-
-
gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), 2);
- gtk_box_set_spacing(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), 2);
-
- setup_clipboard_keybindings (dialog->window);
-
- if (GTK_IS_ACCESSIBLE(gtk_widget_get_accessible(dialog->f_gh))) {
- add_atk_namedesc (dialog->f_gh, _("Find Data"), _("Enter the hex data or ASCII data to search
for"));
- add_atk_namedesc (dialog->r_gh, _("Replace Data"), _("Enter the hex data or ASCII data to
replace with"));
- add_atk_namedesc (dialog->next, _("Find next"), _("Finds the next occurrence of the search
string"));
- add_atk_namedesc (dialog->replace, _("Replace"), _("Replaces the search string with the
replace string"));
- add_atk_namedesc (dialog->replace_all, _("Replace All"), _("Replaces all occurrences of the
search string with the replace string"));
- add_atk_namedesc (dialog->close, _("Cancel"), _("Closes find and replace data window"));
- }
+ static void common_cancel_cb (GtkButton *button, gpointer user_data);
+ static void find_next_cb (GtkButton *button, gpointer user_data);
+ static void find_prev_cb (GtkButton *button, gpointer user_data);
+ static void find_clear_cb (GtkButton *button, gpointer user_data);
+ static void replace_one_cb (GtkButton *button, gpointer user_data);
+ static void replace_all_cb (GtkButton *button, gpointer user_data);
+ static void replace_clear_cb (GtkButton *button, gpointer user_data);
+ static void goto_byte_cb (GtkButton *button, gpointer user_data);
+ static gint get_search_string (HexDocument *doc, gchar **str);
- return dialog;
- }
- JumpDialog *create_jump_dialog()
+ static GtkWidget *
+ create_hex_view (HexDocument *doc)
{
- JumpDialog *dialog;
-
- dialog = g_new0(JumpDialog, 1);
-
- dialog->window = gtk_dialog_new();
- g_signal_connect(G_OBJECT(dialog->window), "delete_event",
- G_CALLBACK(delete_event_cb), dialog->window);
-
- create_dialog_title(dialog->window, _("GHex (%s): Jump To Byte"));
-
- dialog->int_entry = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))),
dialog->int_entry,
- TRUE, TRUE, 0);
- g_signal_connect_swapped (G_OBJECT (dialog->int_entry),
- "activate", G_CALLBACK(gtk_window_activate_default),
- GTK_WINDOW (dialog->window));
- gtk_widget_show(dialog->int_entry);
-
- dialog->ok = gtk_button_new_from_stock (GTK_STOCK_OK);
- g_signal_connect (G_OBJECT (dialog->ok),
- "clicked", G_CALLBACK(goto_byte_cb),
- dialog->int_entry);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->ok,
- TRUE, TRUE, 0);
-
- gtk_widget_set_can_default(dialog->ok, TRUE);
- gtk_widget_show(dialog->ok);
- dialog->cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- g_signal_connect (G_OBJECT (dialog->cancel),
- "clicked", G_CALLBACK(cancel_cb),
- dialog->window);
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog->window))), dialog->cancel,
- TRUE, TRUE, 0);
-
- gtk_widget_set_can_default(dialog->cancel, TRUE);
- gtk_widget_show(dialog->cancel);
-
-
gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), 2);
- gtk_box_set_spacing(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog->window))), 2);
+ /* Not going to bother reffing, since add_view does this internally. */
+ GtkWidget *gh = hex_document_add_view (doc);
- if (GTK_IS_ACCESSIBLE (gtk_widget_get_accessible(dialog->int_entry))) {
- add_atk_namedesc (dialog->int_entry, _("Jump to byte"), _("Enter the byte to jump to"));
- add_atk_namedesc (dialog->ok, _("OK"), _("Jumps to the specified byte"));
- add_atk_namedesc (dialog->cancel, _("Cancel"), _("Closes jump to byte window"));
- }
+ gtk_widget_set_hexpand (gh, TRUE);
+ gtk_hex_set_group_type (GTK_HEX(gh), def_group_type);
+ common_set_gtkhex_font_from_settings (GTK_HEX(gh));
+ gtk_hex_set_insert_mode (GTK_HEX(gh), TRUE);
+ gtk_hex_set_geometry (GTK_HEX(gh), 16, 4);
- return dialog;
+ return gh;
}
- static gint get_search_string(HexDocument *doc, gchar **str)
+ static int
+ get_search_string (HexDocument *doc, char **str)
{
- guint size = doc->file_size;
+ int size = hex_document_get_file_size (doc);
- if(size > 0)
- *str = (gchar *)hex_document_get_data(doc, 0, size);
+ if (size > 0)
+ *str = hex_document_get_data(doc, 0, size);
else
*str = NULL;
+
return size;
}
diff --cc src/gtkhex.c
index df4efbb,bd833c5..119bdcb
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@@ -53,27 -77,38 +77,34 @@@ enum
LAST_SIGNAL
};
- enum ClipboardTargets {
- TARGET_HEXDATA,
-enum {
-- TARGET_STRING,
- N_TARGETS
--};
-
+ /* highlighting information.
+ */
+ typedef struct _GtkHex_Highlight GtkHex_Highlight;
+
+ /* start_line and end_line only have to be set (and valid) of
+ * valid is set to TRUE. */
+ struct _GtkHex_Highlight
+ {
+ int start, end;
+ int start_line, end_line;
+ GdkRGBA *bg_color; /* NULL to use the style color */
+ int min_select;
- static const GtkTargetEntry clipboard_targets[] = {
- { "HEXDATA", 0, TARGET_HEXDATA },
- { "STRING", 0, TARGET_STRING }
+ GtkHex_Highlight *prev, *next;
+ gboolean valid;
};
+ /* used to automatically highlight all visible occurrences
+ * of the string.
+ */
struct _GtkHex_AutoHighlight
{
- gint search_view;
- gchar *search_string;
- gint search_len;
+ int search_view;
+ char *search_string;
+ int search_len;
- gchar *colour;
-
- gint view_min;
- gint view_max;
+ int view_min;
+ int view_max;
GtkHex_Highlight *highlights;
GtkHex_AutoHighlight *next, *prev;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]