[ghex/gtk4-port: 31/91] Initial implementation of findreplace panes




commit 764ade537b352b16956a7340f0dd041e73b4ad74
Author: Logan Rathbone <poprocks gmail com>
Date:   Wed Jan 13 23:50:25 2021 -0500

    Initial implementation of findreplace panes
    
    Buggy, but it's a start.

 src/Makefile                   |    2 +-
 src/findreplace.c              | 1336 ++++++++++++++++++++--------------------
 src/findreplace.h              |  101 +--
 src/ghex-application-window.c  |  102 ++-
 src/ghex-application-window.ui |   38 +-
 src/gtkhex.c                   |   30 +-
 src/gtkhex.h                   |    7 +
 src/hex-document.h             |    2 +-
 src/preferences.h              |    4 +-
 9 files changed, 856 insertions(+), 766 deletions(-)
---
diff --git a/src/Makefile b/src/Makefile
index 670c9510..2415ecd2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -10,7 +10,7 @@ CFLAGS=-Wall -Wextra -std=c11 -pedantic \
 
 .PHONY: clean compile-resources
 
-STUB: gtkhex.o hex-document.o ghex-application-window.o hex-dialog.o resources.o
+STUB: gtkhex.o hex-document.o ghex-application-window.o hex-dialog.o findreplace.o resources.o
 
 compile-resources:
        glib-compile-resources ghex.gresource.xml --target=resources.c --generate-source
diff --git a/src/findreplace.c b/src/findreplace.c
index e35fcd4b..a3bc6377 100644
--- a/src/findreplace.c
+++ b/src/findreplace.c
@@ -1,7 +1,16 @@
+/* vim: colorcolumn=80 ts=4 sw=4
+ */
 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* findreplace.c - finding & replacing data
 
-   Copyright (C) 1998 - 2004 Free Software Foundation
+   Copyright © 1998 - 2004 Free Software Foundation
+
+   Copyright © 2005-2020 Various individual contributors, including
+   but not limited to: Jonathon Jongsma, Kalev Lember, who continued
+   to maintain the source code under the licensing terms described
+   herein and below.
+
+   Copyright © 2021 Logan Rathbone
 
    GHex is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -29,447 +38,94 @@
 #include <glib/gi18n.h>
 
 #include "findreplace.h"
-#include "ui.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);
+/* DEFINES */
+#define JUMP_DIALOG_CSS_NAME "jumpdialog"
 
-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);
+/* GOBJECT DEFINITIONS */
 
+struct _JumpDialog {
+       GtkWidget parent_instance;
 
-FindDialog *find_dialog = NULL;
-ReplaceDialog *replace_dialog = NULL;
-JumpDialog *jump_dialog = NULL;
+       GtkHex *gh;
+       GtkWidget *box;
+       GtkWidget *label;
+       GtkWidget *int_entry;
+       GtkWidget *ok, *cancel;
+};
 
-/* 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;
+G_DEFINE_TYPE (JumpDialog, jump_dialog, GTK_TYPE_WIDGET)
 
-static GtkWidget *create_hex_view(HexDocument *doc)
-{
-    GtkWidget *gh = hex_document_add_view(doc);
-
-       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;
-}
+struct _FindDialog {
+       GtkWidget parent_instance;
 
-FindDialog *create_find_dialog()
-{
-       FindDialog *dialog;
+       GtkHex *gh;
        GtkWidget *frame;
-
-       dialog = g_new0(FindDialog, 1);
-
-       dialog->window = gtk_dialog_new();
-       g_signal_connect(G_OBJECT(dialog->window), "delete_event",
-                                        G_CALLBACK(find_delete_event_cb), dialog);
+       GtkWidget *vbox;
+       GtkWidget *hbox;
+       HexDocument *f_doc;
+       GtkWidget *f_gh;
+       GtkWidget *f_next, *f_prev, *f_close;
        
-       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);
-
-       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"));
-       }
-
-       return dialog;
-}
-
-static AdvancedFind_AddDialog *create_advanced_find_add_dialog(AdvancedFindDialog *parent)
-{
-       AdvancedFind_AddDialog *dialog = g_new0(AdvancedFind_AddDialog, 1);
-       GtkWidget *button, *frame, *sep;
-
-       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);
-
-       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);
-
-       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"));
-       }
-
-       return dialog;
-}
-
-static void delete_advanced_find_add_dialog(AdvancedFind_AddDialog *dialog)
-{
-       gtk_widget_destroy(GTK_WIDGET(dialog->window));
-       g_free(dialog);
-}
-
-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;
-}
-
-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);
-}
-
-ReplaceDialog *create_replace_dialog()
-{
-       ReplaceDialog *dialog;
-       GtkWidget *frame;
+       GtkHex_AutoHighlight *auto_highlight;
+};
 
-       dialog = g_new0(ReplaceDialog, 1);
+G_DEFINE_TYPE (FindDialog, find_dialog, GTK_TYPE_WIDGET)
 
-       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);
+struct _ReplaceDialog {
+       GtkWidget parent_instance;
 
-       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);
+       GtkHex *gh;
+       GtkWidget *vbox;
+       GtkWidget *hbox;
+       GtkWidget *f_frame, *r_frame;
+       GtkWidget *f_gh, *r_gh;
+       HexDocument *f_doc, *r_doc;
+       GtkWidget *replace, *replace_all, *next, *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);
-
-       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"));
-       }
+       GtkHex_AutoHighlight *auto_highlight;
+}; 
+
+G_DEFINE_TYPE (ReplaceDialog, replace_dialog, GTK_TYPE_WIDGET)
+
+/* PRIVATE FUNCTION DECLARATIONS */
+
+//static gint find_delete_event_cb(GtkWidget *w, GdkEventAny *e,
+//             FindDialog *dialog);
+static void find_cancel_cb(GtkButton *button, gpointer user_data);
+static void 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 replace_next_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 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;
+    GtkWidget *gh = hex_document_add_view(doc);
 
-       dialog = g_new0(JumpDialog, 1);
+       // TEST
+       gtk_hex_set_group_type(GTK_HEX(gh), GROUP_BYTE);
+//     gtk_hex_set_group_type(GTK_HEX(gh), def_group_type);
 
-       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);
+       // FIXME - JUST DELETE?
+#if 0
+    if (def_metrics && def_font_desc) {
+           gtk_hex_set_font(GTK_HEX(gh), def_metrics, def_font_desc);
+    }
+#endif
 
-       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_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)
@@ -480,9 +136,11 @@ static gint get_search_string(HexDocument *doc, gchar **str)
                *str = (gchar *)hex_document_get_data(doc, 0, size);
        else
                *str = NULL;
+
        return size;
 }
 
+#if 0
 /* find and advanced find need special close dialogs, since they
  * need to do stuff with the highlights
  */
@@ -497,138 +155,191 @@ static gint find_delete_event_cb(GtkWidget *w, GdkEventAny *e, FindDialog *dialo
 
        return TRUE;
 }
+#endif
 
-static void find_cancel_cb(GtkWidget *w, FindDialog *dialog)
+// FIXME - this is kind of a crappy hack to get this to build
+// Revisit.
+static void
+cancel_cb (GtkButton *button, gpointer user_data)
 {
-       GHexWindow *win = ghex_window_get_active();
-       GtkHex *gh = win->gh;
-       
-       if (dialog->auto_highlight) gtk_hex_delete_autohighlight(gh, dialog->auto_highlight);
-       dialog->auto_highlight = NULL;
-       gtk_widget_hide(dialog->window);
-}
+       GtkWidget *widget = GTK_WIDGET(user_data);
 
-static gint advanced_find_delete_event_cb(GtkWidget *w, GdkEventAny *e,
-                                                                                 AdvancedFindDialog *dialog)
-{
-       gtk_widget_hide(w);
+       g_return_if_fail (GTK_IS_WIDGET(widget));
 
-       return TRUE;
+       (void)button;   /* unused */
+
+       gtk_widget_hide (widget);
 }
 
-static void advanced_find_close_cb(GtkWidget *w, AdvancedFindDialog *dialog)
+static void
+find_cancel_cb(GtkButton *button, gpointer user_data)
 {
-       gtk_widget_hide(dialog->window);
+       FindDialog *self = FIND_DIALOG(user_data);
+       GtkWidget *widget = GTK_WIDGET(user_data);
+       
+       g_return_if_fail (FIND_IS_DIALOG(self));
+
+       (void)button;   /* unused */
+
+       if (self->auto_highlight)
+               gtk_hex_delete_autohighlight(self->f_gh, self->auto_highlight);
+
+       self->auto_highlight = NULL;
+
+       gtk_widget_hide(self);
 }
 
-static void find_next_cb(GtkButton *button, FindDialog *dialog)
+static void
+find_next_cb(GtkButton *button, gpointer user_data)
 {
-       GtkHex *gh;
+       FindDialog *self = FIND_DIALOG(user_data);
+       GtkWidget *widget = GTK_WIDGET(user_data);
+       HexDocument *doc;
+       guint cursor_pos;
        guint offset, str_len;
        gchar *str;
-       GHexWindow *win = ghex_window_get_active();
-
-       if(win == NULL || win->gh == NULL) {
-               display_error_dialog (win, _("There is no active document to search!"));
-               return;
-       }
-       
-       gh = win->gh;
        
-       if((str_len = get_search_string(find_dialog->f_doc, &str)) == 0) {
-               display_error_dialog (win, _("There is no string to search for!"));
+       g_return_if_fail (FIND_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+
+       (void)button;   /* unused */
+
+       doc = gtk_hex_get_document(self->gh);
+       cursor_pos = gtk_hex_get_cursor(self->gh);
+
+       if ((str_len = get_search_string(self->f_doc, &str)) == 0) {
+               // FIXME
+//             display_error_dialog (self, _("There is no string to search for!"));
                return;
        }
-       if (dialog->auto_highlight) gtk_hex_delete_autohighlight(gh, dialog->auto_highlight);
-       dialog->auto_highlight = NULL;
-       dialog->auto_highlight = gtk_hex_insert_autohighlight(gh, str, str_len, "red");
-       if(hex_document_find_forward(gh->document,
-                                                                gh->cursor_pos+1, str, str_len, &offset))
+
+       if (self->auto_highlight)
+               gtk_hex_delete_autohighlight(self->gh, self->auto_highlight);
+
+       self->auto_highlight = NULL;
+       self->auto_highlight = gtk_hex_insert_autohighlight(self->gh,
+                       str, str_len);
+       // FIXME - oh dang maybe I shouldn't gave got rid of this - maybe
+       // there's a way to replicate this with states. :(
+//                     , "red");
+
+       if (hex_document_find_forward(doc,
+                                                                cursor_pos + 1,
+                                                                str, str_len, &offset))
        {
-               gtk_hex_set_cursor(gh, offset);
+               gtk_hex_set_cursor(self->gh, offset);
        }
        else {
-               ghex_window_flash(win, _("End Of File reached"));
-               display_info_dialog(win, _("String was not found!\n"));
+               // FIXME - NOT IMPLEMENTED
+//             ghex_window_flash(win, _("End Of File reached"));
+//             display_info_dialog(self, _("String was not found!\n"));
        }
-       if(NULL != str)
+
+       if (str)
                g_free(str);
 }
 
-static void find_prev_cb(GtkButton *button, FindDialog *dialog)
+static void
+find_prev_cb(GtkButton *button, gpointer user_data)
 {
-       GtkHex *gh;
+       FindDialog *self = FIND_DIALOG(user_data);
+       GtkWidget *widget = GTK_WIDGET(user_data);
+       HexDocument *doc;
+       guint cursor_pos;
        guint offset, str_len;
        gchar *str;
-       GHexWindow *win = ghex_window_get_active();
-               
-       if(win == NULL || win->gh == NULL) {
-               display_error_dialog (win, _("There is no active document to search!"));
-               return;
-       }
        
-       gh = win->gh;
-       
-       if((str_len = get_search_string(find_dialog->f_doc, &str)) == 0) {
-               display_error_dialog (win, _("There is no string to search for!"));
+       g_return_if_fail (FIND_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+
+       (void)button;   /* unused */
+
+       doc = gtk_hex_get_document(self->gh);
+       cursor_pos = gtk_hex_get_cursor(self->gh);
+
+       if ((str_len = get_search_string(self->f_doc, &str)) == 0) {
+               // FIXME
+//             display_error_dialog (self, _("There is no string to search for!"));
                return;
        }
 
-       if (dialog->auto_highlight) gtk_hex_delete_autohighlight(gh, dialog->auto_highlight);
-       dialog->auto_highlight = NULL;
-       dialog->auto_highlight = gtk_hex_insert_autohighlight(gh, str, str_len, "red");
-       if(hex_document_find_backward(gh->document,
-                                                                 gh->cursor_pos, str, str_len, &offset))
-               gtk_hex_set_cursor(gh, offset);
+       if (self->auto_highlight)
+               gtk_hex_delete_autohighlight(self->gh, self->auto_highlight);
+
+       self->auto_highlight = NULL;
+       self->auto_highlight = gtk_hex_insert_autohighlight(self->gh,
+                       str, str_len);
+       // FIXME - restore our purdy colours
+                       //, "red");
+
+       if (hex_document_find_backward(doc,
+                               cursor_pos, str, str_len, &offset))
+       {
+               gtk_hex_set_cursor(self->gh, offset);
+       }
        else {
-               ghex_window_flash(win, _("Beginning Of File reached"));
-               display_info_dialog(win, _("String was not found!\n"));
+               // FIXME - NOT IMPLEMENTED
+//             ghex_window_flash(win, _("Beginning Of File reached"));
+//             display_info_dialog(self, _("String was not found!\n"));
        }
-       if(NULL != str)
+       if (str)
                g_free(str);
 }
 
-static void goto_byte_cb(GtkButton *button, GtkWidget *w)
+static void
+goto_byte_cb(GtkButton *button, gpointer user_data)
 {
+       JumpDialog *self = JUMP_DIALOG(user_data);
+       GtkWidget *widget = GTK_WIDGET(user_data);
+       HexDocument *doc;
+       guint cursor_pos;
+       GtkEntry *entry;
+       GtkEntryBuffer *buffer;
        guint byte = 2, len, i;
        gint is_relative = 0;
        gboolean is_hex;
-       const gchar *byte_str = gtk_entry_get_text(GTK_ENTRY(jump_dialog->int_entry));
-       GHexWindow *win = ghex_window_get_active();
-       
-       if(win == NULL || win->gh == NULL) {
-               display_error_dialog (win,
-                                                         _("There is no active document to move the "
-                                                               "cursor in!"));
-               return;
-       }
+       const gchar *byte_str;
        
+       g_return_if_fail (JUMP_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+
+       (void)button;   /* unused */
+
+       doc = gtk_hex_get_document(self->gh);
+       cursor_pos = gtk_hex_get_cursor(self->gh);
+
+       entry = GTK_ENTRY(self->int_entry);
+       buffer = gtk_entry_get_buffer (entry);
+       byte_str = gtk_entry_buffer_get_text (buffer);
+
        len = strlen(byte_str);
        
-       if(len > 1 && byte_str[0] == '+') {
+       if (len > 1 && byte_str[0] == '+') {
                is_relative = 1;
                byte_str++;
                len--;
-       } else if(len > 1 && byte_str[0] == '-') {
+       }
+       else if (len > 1 && byte_str[0] == '-') {
                is_relative = -1;
                byte_str++;
                len--;
        }
        
-       if(len == 0) {
-               display_error_dialog (win, _("No offset has been specified!"));
+       if (len == 0) {
+               // FIXME
+//             display_error_dialog (self, _("No offset has been specified!"));
                return;
        }
 
        is_hex = ((len > 2) && (byte_str[0] == '0') && (byte_str[1] == 'x'));
 
-       if(!is_hex) {
-               for(i = 0; i < len; i++)
-                       if(!(byte_str[i] >= '0' && byte_str[i] <= '9')) 
+       if (!is_hex) {
+               for (i = 0; i < len; i++)
+                       if (!(byte_str[i] >= '0' && byte_str[i] <= '9')) 
                                break;
        }
        else {
-               for(i = 2; i < len; i++)
+               for (i = 2; i < len; i++)
                        if(!((byte_str[i] >= '0' && byte_str[i] <= '9') ||
                                 (byte_str[i] >= 'A' && byte_str[i] <= 'F') ||
                                 (byte_str[i] >= 'a' && byte_str[i] <= 'f')))
@@ -639,129 +350,156 @@ static void goto_byte_cb(GtkButton *button, GtkWidget *w)
           ((sscanf(byte_str, "0x%x", &byte) == 1) ||
                (sscanf(byte_str, "%d", &byte) == 1))) {
                if(is_relative) {
-                       if(is_relative == -1 && byte > win->gh->cursor_pos) {
-                               display_error_dialog(win,
+                       if(is_relative == -1 && byte > cursor_pos) {
+                               // FIXME
+#if 0
+                               display_error_dialog(self,
                                                                 _("The specified offset is beyond the "
                                                                " file boundaries!"));
+#endif
                                return;
                        }
-                       byte = byte * is_relative + win->gh->cursor_pos;
+                       byte = byte * is_relative + cursor_pos;
                }
-               if(byte >= win->gh->document->file_size)
-                       display_error_dialog(win,
+               if (byte >= doc->file_size) {
+                       // FIXME
+#if 0
+                       display_error_dialog(self,
                                                                 _("Can not position cursor beyond the "
                                                                   "End Of File!"));
-               else
-                       gtk_hex_set_cursor(win->gh, byte);
+#endif
+               } else {
+                       gtk_hex_set_cursor(self->gh, byte);
+               }
+       }
+       else {
+               // FIXME
+#if 0
+               display_error_dialog(self,
+                               _("You may only give the offset as:\n"
+                                       "  - a positive decimal number, or\n"
+                                       "  - a hex number, beginning with '0x', or\n"
+                                       "  - a '+' or '-' sign, followed by a relative offset"));
+#endif
        }
-       else
-               display_error_dialog(win,
-                                                        _("You may only give the offset as:\n"
-                                                          "  - a positive decimal number, or\n"
-                                                          "  - a hex number, beginning with '0x', or\n"
-                                                          "  - a '+' or '-' sign, followed by a relative 
offset"));
 }
 
-static void replace_next_cb(GtkButton *button, gpointer unused)
+static void
+replace_next_cb (GtkButton *button, gpointer user_data)
 {
-       GtkHex *gh;
+       ReplaceDialog *self = REPLACE_DIALOG(user_data);
+       GtkWidget *widget = GTK_WIDGET(user_data);
+       HexDocument *doc;
+       guint cursor_pos;
        guint offset, str_len;
        gchar *str = NULL;
-       GHexWindow *win = ghex_window_get_active();
-               
-       if(win == NULL || win->gh == NULL) {
-               display_error_dialog (win, _("There is no active document to search!"));
-               return;
-       }
-       
-       gh = win->gh;
 
-       if((str_len = get_search_string(replace_dialog->f_doc, &str)) == 0) {
-               display_error_dialog (win, _("There is no string to search for!"));
+       g_return_if_fail (REPLACE_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+
+       doc = gtk_hex_get_document (self->gh);
+       cursor_pos = gtk_hex_get_cursor (self->gh);
+
+       if ((str_len = get_search_string(self->f_doc, &str)) == 0) {
+               // FIXME
+//             display_error_dialog (self, _("There is no string to search for!"));
                return;
        }
 
-       if(hex_document_find_forward(gh->document,
-                                                                gh->cursor_pos+1, str, str_len, &offset))
-               gtk_hex_set_cursor(gh, offset);
+       if (hex_document_find_forward(doc,
+                                                                cursor_pos + 1, str, str_len, &offset))
+       {
+               gtk_hex_set_cursor(self->gh, offset);
+       }
        else {
-               display_info_dialog(win, _("String was not found!\n"));
-               ghex_window_flash(win, _("End Of File reached"));
+               // FIXME - NOT IMPLEMENTED
+//             display_info_dialog (self, _("String was not found!\n"));
+//             ghex_window_flash(win, _("End Of File reached"));
        }
 
-       if(NULL != str)
+       if (str)
                g_free(str);
 }
 
-static void replace_one_cb(GtkButton *button, gpointer unused)
+static void
+replace_one_cb(GtkButton *button, gpointer user_data)
 {
+       ReplaceDialog *self = REPLACE_DIALOG(user_data);
+       GtkWidget *widget = GTK_WIDGET(user_data);
+       HexDocument *doc;
+       guint cursor_pos;
        gchar *find_str = NULL, *rep_str = NULL;
        guint find_len, rep_len, offset;
-       GtkHex *gh;
-       HexDocument *doc;
-       GHexWindow *win = ghex_window_get_active();
-       
-       if(win == NULL || win->gh == NULL) {
-               display_error_dialog (win, _("There is no active buffer to replace data in!"));
-               return;
-       }
-       
-       gh = win->gh;
 
-       doc = win->gh->document;
+       g_return_if_fail (REPLACE_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+
+       (void)button;   /* unused */
+
+       doc = gtk_hex_get_document (self->gh);
+       cursor_pos = gtk_hex_get_cursor (self->gh);
        
-       if((find_len = get_search_string(replace_dialog->f_doc, &find_str)) == 0) {
-               display_error_dialog (win, _("There is no string to search for!"));
+       if ((find_len = get_search_string(self->f_doc, &find_str)) == 0) {
+               // FIXME
+//             display_error_dialog (self, _("There is no string to search for!"));
                return;
        }
-       rep_len = get_search_string(replace_dialog->r_doc, &rep_str);
+       rep_len = get_search_string(self->r_doc, &rep_str);
        
-       if(find_len > doc->file_size - gh->cursor_pos)
+       if (find_len > doc->file_size - cursor_pos)
                goto clean_up;
        
-       if(hex_document_compare_data(doc, find_str, gh->cursor_pos, find_len) == 0)
-               hex_document_set_data(doc, gh->cursor_pos,
+       if (hex_document_compare_data(doc, find_str, cursor_pos, find_len) == 0)
+       {
+               hex_document_set_data(doc, cursor_pos,
                                                          rep_len, find_len, rep_str, TRUE);
+       }
        
-       if(hex_document_find_forward(doc, gh->cursor_pos + rep_len, find_str, find_len,
-                                                                &offset))
-               gtk_hex_set_cursor(gh, offset);
+       if (hex_document_find_forward(doc, cursor_pos + rep_len,
+                               find_str, find_len, &offset))
+       {
+               gtk_hex_set_cursor(self->gh, offset);
+       }
        else {
-               display_info_dialog(win, _("End Of File reached!"));
-               ghex_window_flash(win, _("End Of File reached!"));
+               // FIXME - NOT IMPLEMENTED
+//             display_info_dialog(self, _("End Of File reached!"));
+//             ghex_window_flash(win, _("End Of File reached!"));
        }
 
- clean_up:
-       if(NULL != find_str)
+clean_up:
+       if (find_str)
                g_free(find_str);
-       if(NULL != rep_str)
+
+       if(rep_str)
                g_free(rep_str);
 }
 
-static void replace_all_cb(GtkButton *button, gpointer unused)
+static void
+replace_all_cb (GtkButton *button, gpointer user_data)
 {
-       gchar *find_str = NULL, *rep_str = NULL, *flash;
-       guint find_len, rep_len, offset, count, cursor_pos;
-       GtkHex *gh;
+       ReplaceDialog *self = REPLACE_DIALOG(user_data);
+       GtkWidget *widget = GTK_WIDGET(user_data);
        HexDocument *doc;
-       GHexWindow *win = ghex_window_get_active();
-       
-       if(win == NULL || win->gh == NULL) {
-               display_error_dialog (win, _("There is no active document to replace data in!"));
-               return;
-       }
-       
-       gh = win->gh;
+       guint cursor_pos;
+       gchar *find_str = NULL, *rep_str = NULL, *flash;
+       guint find_len, rep_len, offset, count;
 
-       doc = gh->document;
-       
-       if((find_len = get_search_string(replace_dialog->f_doc, &find_str)) == 0) {
-               display_error_dialog (win, _("There is no string to search for!"));
+       g_return_if_fail (REPLACE_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+
+       (void)button;   /* unused */
+
+       doc = gtk_hex_get_document (self->gh);
+       cursor_pos = gtk_hex_get_cursor (self->gh);
+
+       if ((find_len = get_search_string(self->f_doc, &find_str)) == 0) {
+               // FIXME
+//             display_error_dialog (self, _("There is no string to search for!"));
                return;
        }
-       rep_len = get_search_string(replace_dialog->r_doc, &rep_str);
+       rep_len = get_search_string(self->r_doc, &rep_str);
 
-       if(find_len > doc->file_size - gh->cursor_pos)
+       if (find_len > doc->file_size - cursor_pos)
                goto clean_up;
        
        count = 0;
@@ -769,138 +507,402 @@ static void replace_all_cb(GtkButton *button, gpointer unused)
 
        while(hex_document_find_forward(doc, cursor_pos, find_str, find_len,
                                                                        &offset)) {
-               hex_document_set_data(doc, offset, rep_len, find_len, rep_str, TRUE);
+               hex_document_set_data (doc, offset, rep_len, find_len, rep_str, TRUE);
                cursor_pos = offset + rep_len;
                count++;
        }
        
-       gtk_hex_set_cursor(gh, MIN(offset, doc->file_size));  
+       gtk_hex_set_cursor(self->gh, MIN(offset, doc->file_size));  
 
        if(count == 0) {
-               display_info_dialog(win, _("No occurrences were found."));
+               // FIXME
+//             display_info_dialog (self, _("No occurrences were found."));
        }
        
        flash = g_strdup_printf(ngettext("Replaced %d occurrence.",
                                                                         "Replaced %d occurrences.",
                                                                         count), count);
-       ghex_window_flash(win, flash);
+       // FIXME - NOT IMPLEMENTED
+//     ghex_window_flash(win, flash);
        g_free(flash);
 
- clean_up:
-       if(NULL != find_str)
+clean_up:
+       if (find_str)
                g_free(find_str);
-       if(NULL != rep_str)
+
+       if (rep_str)
                g_free(rep_str);
 }
 
-static void advanced_find_add_add_cb(GtkButton *button,
-                                                                        AdvancedFind_AddDialog *dialog)
+/* PRIVATE METHOD DEFINITIONS */
+
+/* FindDialog */
+
+static void
+find_dialog_init (FindDialog *self)
 {
-       gtk_dialog_response(GTK_DIALOG(dialog->window), GTK_RESPONSE_OK);
+       /* Yes, we could use these newfangled layout managers, but I'm a bit lazy
+        * right now.
+        */
+       self->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+       gtk_widget_set_parent (self->vbox, GTK_WIDGET(self));
+
+       self->frame = gtk_frame_new(_("Find String"));
+       self->f_doc = hex_document_new();
+       self->f_gh = create_hex_view(self->f_doc);
+       gtk_frame_set_child (GTK_FRAME(self->frame), self->f_gh);
+       gtk_box_append (GTK_BOX(self->vbox), self->frame);
+       
+       self->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+       gtk_box_append (GTK_BOX(self->vbox), self->hbox);
+
+       self->f_next = gtk_button_new_with_mnemonic (_("Find _Next"));
+       g_signal_connect (G_OBJECT (self->f_next), "clicked",
+                                         G_CALLBACK(find_next_cb), self);
+       gtk_widget_set_receives_default (self->f_next, TRUE);
+       gtk_box_append (GTK_BOX(self->hbox), self->f_next);
+
+       self->f_prev = gtk_button_new_with_mnemonic (_("Find _Previous"));
+       g_signal_connect (G_OBJECT (self->f_prev), "clicked",
+                                         G_CALLBACK(find_prev_cb), self);
+       gtk_box_append (GTK_BOX(self->hbox), self->f_prev);
+
+       self->f_close = gtk_button_new_with_mnemonic (_("_Close"));
+       g_signal_connect (G_OBJECT (self->f_close), "clicked",
+                       G_CALLBACK(find_cancel_cb), self);
+       gtk_box_append (GTK_BOX(self->hbox), self->f_close);
+
+       /* FIXME / TODO - just keeping these strings alive for adaptation into
+        * the new accessibility framework if possible, since they have likely
+        * already been translated.
+        */
+       g_debug("%s: The following strings are just being preserved for "
+                       "adaptation into the new accessibility framework. Ignore.",
+                       __func__);
+
+       g_debug(_("Find Data"));
+       g_debug(_("Enter the hex data or ASCII data to search for"));
+
+       g_debug(_("Find Next"));
+       g_debug(_("Finds the next occurrence of the search string"));
+
+       g_debug(_("Find previous"));
+       g_debug(_("Finds the previous occurrence of the search string "));
+
+       g_debug(_("Cancel"));
+       g_debug(_("Closes find data window"));
 }
 
-static void advanced_find_add_cb(GtkButton *button, AdvancedFindDialog *dialog)
+
+// TODO - see: find_delete_event_cb for some possible destructor hints here?
+static void
+find_dialog_dispose(GObject *object)
 {
-       gint ret;
-       if(!gtk_widget_get_visible(dialog->addDialog->window)) {
-               gtk_window_set_position (GTK_WINDOW(dialog->addDialog->window), GTK_WIN_POS_MOUSE);
-               gtk_widget_show(dialog->addDialog->window);
-       }
+       FindDialog *self = FIND_DIALOG(object);
 
-       ret = gtk_dialog_run(GTK_DIALOG(dialog->addDialog->window));
-       gtk_widget_hide(dialog->addDialog->window);
-       if (ret != GTK_RESPONSE_NONE)
-       {
-               gchar *colour;
-               GdkRGBA rgba;
-               AdvancedFind_ListData *data = g_new0(AdvancedFind_ListData, 1);
-               GtkHex *gh = dialog->parent->gh;
-               GtkTreeIter iter;
-               
-               g_return_if_fail (gh != NULL);
-               
-               if((data->str_len = get_search_string(dialog->addDialog->f_doc, &data->str)) == 0) {
-                       display_error_dialog (dialog->parent, _("No string to search for!"));
-                       return;
-               }
-               gtk_color_selection_get_current_rgba (GTK_COLOR_SELECTION (dialog->addDialog->colour),
-                                                     &rgba);
-               colour = gdk_rgba_to_string (&rgba);
-               data->auto_highlight = gtk_hex_insert_autohighlight(gh, data->str, data->str_len);
-               gtk_list_store_append(dialog->list, &iter);
-               gtk_list_store_set(dialog->list, &iter,
-                                                  0, data->str,
-                                                  1, colour,
-                                                  2, data,
-                                                  -1);
-               g_free(colour);
-       }
+       /* Boilerplate: chain up
+        */
+       G_OBJECT_CLASS(find_dialog_parent_class)->dispose(object);
 }
 
-static void advanced_find_delete_cb(GtkButton *button, AdvancedFindDialog *dialog)
+static void
+find_dialog_finalize(GObject *gobject)
 {
-       GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->tree));
-       GtkTreeIter iter;
-       GtkTreeModel *model;
-       AdvancedFind_ListData *data;
-       GtkHex *gh = dialog->parent->gh;
+       /* here, you would free stuff. I've got nuthin' for ya. */
 
-       if (gtk_tree_selection_get_selected(selection, &model, &iter) != TRUE)
-               return;
-       
-       gtk_tree_model_get(model, &iter, 2, &data, -1);
-       gtk_hex_delete_autohighlight(gh, data->auto_highlight);
-       if(NULL != data->str)
-               g_free(data->str);
-       g_free(data);
-       gtk_list_store_remove(dialog->list, &iter);
+       /* --- */
+
+       /* Boilerplate: chain up
+        */
+       G_OBJECT_CLASS(find_dialog_parent_class)->finalize(gobject);
 }
 
-static void advanced_find_next_cb(GtkButton *button, AdvancedFindDialog *dialog)
+static void
+find_dialog_class_init(FindDialogClass *klass)
 {
-       GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->tree));
-       GtkTreeIter iter;
-       GtkTreeModel *model;
-       AdvancedFind_ListData *data;
-       GtkHex *gh = dialog->parent->gh;
-       guint offset;
-       GHexWindow *win = ghex_window_get_active();
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+       /* <boilerplate> */
+       object_class->dispose = find_dialog_dispose;
+       object_class->finalize = find_dialog_finalize;
+       /* </boilerplate> */
+
+       /* set the box-type layout manager for this Find dialog widget.
+        */
+       gtk_widget_class_set_layout_manager_type (widget_class,
+                       GTK_TYPE_BOX_LAYOUT);
+}
 
-       if (gtk_tree_selection_get_selected(selection, &model, &iter) != TRUE)
-               return;
+GtkWidget *
+find_dialog_new (void)
+{
+       return g_object_new(FIND_TYPE_DIALOG, NULL);
+}
+
+void
+find_dialog_set_hex (FindDialog *self, GtkHex *gh)
+{
+       g_return_if_fail (FIND_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(gh));
+
+       g_debug("%s: setting GtkHex of FindDialog to: %p",
+                       __func__, (void *)gh);
+
+       self->gh = gh;
+}
+
+/* ReplaceDialog */
+
+static void
+replace_dialog_init (ReplaceDialog *self)
+{
+       self->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+       gtk_widget_set_parent (self->vbox, GTK_WIDGET(self));
+
+       self->f_doc = hex_document_new ();
+       self->f_gh = create_hex_view (self->f_doc);
+
+       self->f_frame = gtk_frame_new (_("Find String"));
+       gtk_frame_set_child (GTK_FRAME(self->f_frame), self->f_gh); 
+       gtk_box_append (GTK_BOX(self->vbox), self->f_frame);
        
-       gtk_tree_model_get(model, &iter, 2, &data, -1);
-       if(hex_document_find_forward(gh->document,
-                                                                gh->cursor_pos+1, data->str, data->str_len, 
&offset))
-       {
-               gtk_hex_set_cursor(gh, offset);
-       }
-       else {
-               ghex_window_flash(win, _("End Of File reached"));
-               display_info_dialog(win, _("String was not found!\n"));
-       }
+       self->r_doc = hex_document_new();
+       self->r_gh = create_hex_view (self->r_doc);
+       self->r_frame = gtk_frame_new(_("Replace With"));
+       gtk_frame_set_child (GTK_FRAME(self->r_frame), self->r_gh);
+       gtk_box_append (GTK_BOX(self->vbox), self->r_frame);
+
+       self->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+       gtk_box_append (GTK_BOX(self->vbox), self->hbox);
+
+       self->next = gtk_button_new_with_mnemonic (_("Find _Next"));
+       g_signal_connect (G_OBJECT (self->next),
+                                         "clicked", G_CALLBACK(replace_next_cb),
+                                         NULL);
+       gtk_box_append (GTK_BOX(self->hbox), self->next);
+       gtk_widget_set_receives_default (self->next, TRUE);
+
+       self->replace = gtk_button_new_with_mnemonic (_("_Replace"));
+       g_signal_connect (G_OBJECT (self->replace),
+                                         "clicked", G_CALLBACK(replace_one_cb),
+                                         NULL);
+       gtk_box_append (GTK_BOX(self->hbox), self->replace);
+
+       self->replace_all= gtk_button_new_with_mnemonic (_("Replace _All"));
+       g_signal_connect (G_OBJECT (self->replace_all),
+                                         "clicked", G_CALLBACK(replace_all_cb),
+                                         NULL);
+       gtk_box_append (GTK_BOX(self->hbox), self->replace_all);
+
+       self->close = gtk_button_new_with_mnemonic (_("_Close"));
+       g_signal_connect (G_OBJECT (self->close),
+                                         "clicked", G_CALLBACK(cancel_cb),
+                                         self);
+       gtk_box_append (GTK_BOX(self->hbox), self->close);
+
+       /* FIXME/TODO - preserve translated strings for a11y */
+
+       g_debug("%s: preserved strings for a11y - Ignore.", __func__);
+
+       g_debug(_("Find Data"));
+       g_debug(_("Enter the hex data or ASCII data to search for"));
+
+       g_debug(_("Replace Data"));
+       g_debug(_("Enter the hex data or ASCII data to replace with"));
+
+       g_debug(_("Find next"));
+       g_debug(_("Finds the next occurrence of the search string"));
+
+       g_debug(_("Replace"));
+       g_debug(_("Replaces the search string with the replace string"));
+
+       g_debug(_("Replace All"));
+       g_debug(_("Replaces all occurrences of the search string with the replace string"));
+
+       g_debug(_("Cancel"));
+       g_debug(_("Closes find and replace data window"));
 }
 
-static void advanced_find_prev_cb(GtkButton *button, AdvancedFindDialog *dialog)
+static void
+replace_dialog_dispose(GObject *object)
 {
-       GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->tree));
-       GtkTreeIter iter;
-       GtkTreeModel *model;
-       AdvancedFind_ListData *data;
-       GtkHex *gh = dialog->parent->gh;
-       guint offset;
-       GHexWindow *win = ghex_window_get_active();
+       ReplaceDialog *self = REPLACE_DIALOG(object);
 
-       if (gtk_tree_selection_get_selected(selection, &model, &iter) != TRUE)
-               return;
+       /* Boilerplate: chain up
+        */
+       G_OBJECT_CLASS(replace_dialog_parent_class)->dispose(object);
+}
+
+static void
+replace_dialog_finalize(GObject *gobject)
+{
+       /* here, you would free stuff. I've got nuthin' for ya. */
+
+       /* --- */
+
+       /* Boilerplate: chain up
+        */
+       G_OBJECT_CLASS(replace_dialog_parent_class)->finalize(gobject);
+}
+
+static void
+replace_dialog_class_init(ReplaceDialogClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+       /* <boilerplate> */
+       object_class->dispose = replace_dialog_dispose;
+       object_class->finalize = replace_dialog_finalize;
+       /* </boilerplate> */
+
+       /* set the box-type layout manager for this Find dialog widget.
+        */
+       gtk_widget_class_set_layout_manager_type (widget_class,
+                       GTK_TYPE_BOX_LAYOUT);
+}
+
+GtkWidget *
+replace_dialog_new(void)
+{
+       return g_object_new(REPLACE_TYPE_DIALOG, NULL);
+}
+
+void
+replace_dialog_set_hex (ReplaceDialog *self, GtkHex *gh)
+{
+       g_return_if_fail (REPLACE_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(gh));
+
+       g_debug("%s: setting GtkHex of ReplaceDialog to: %p",
+                       __func__, (void *)gh);
+
+       self->gh = gh;
+}
+
+
+/* JumpDialog */
+
+static void
+jump_dialog_init (JumpDialog *self)
+{
+       GtkWidget *widget = GTK_WIDGET(self);
+       GtkStyleContext *context;
+       GtkCssProvider *provider;
+
+       /* CSS */
+
+       context = gtk_widget_get_style_context (widget);
+       provider = gtk_css_provider_new ();
+
+       gtk_css_provider_load_from_data (provider,
+                                                                        JUMP_DIALOG_CSS_NAME " {\n"
+                                                                        "   padding-left: 20px;\n"
+                                                                        "   padding-top: 6px;\n"
+                                                                        "   padding-bottom: 6px;\n"
+                                                                        "}\n", -1);
+
+       /* add the provider to our widget's style context. */
+       gtk_style_context_add_provider (context,
+                                       GTK_STYLE_PROVIDER (provider),
+                                       GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
+
+       /* Widget */
+
+       self->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+       gtk_widget_set_parent (self->box, widget);
        
-       gtk_tree_model_get(model, &iter, 2, &data, -1);
-       if(hex_document_find_backward(gh->document,
-                                                                 gh->cursor_pos, data->str, data->str_len, 
&offset))
-               gtk_hex_set_cursor(gh, offset);
-       else {
-               ghex_window_flash(win, _("Beginning Of File reached"));
-               display_info_dialog(win, _("String was not found!\n"));
-       }
+       /* FIXME/TODO - this is not very intuitive. */
+       self->label = gtk_label_new (_("Jump to byte (enter offset):"));
+       self->int_entry = gtk_entry_new();
+
+       gtk_box_append (GTK_BOX(self->box), self->label);
+       gtk_box_append (GTK_BOX(self->box), self->int_entry);
+
+       self->ok = gtk_button_new_with_mnemonic (_("_Jump"));
+       g_signal_connect (G_OBJECT (self->ok),
+                                         "clicked", G_CALLBACK(goto_byte_cb),
+                                         self);
+       gtk_box_append (GTK_BOX(self->box), self->ok);
+       gtk_widget_set_receives_default (self->ok, TRUE);
+
+       self->cancel = gtk_button_new_with_mnemonic (_("_Close"));
+       g_signal_connect (G_OBJECT (self->cancel),
+                                         "clicked", G_CALLBACK(cancel_cb),
+                                         self);
+       gtk_box_append (GTK_BOX(self->box), self->cancel);
+
+       /* FIXME/TODO - preserve strings for a11y */
+       
+       g_debug("%s: preserving strings for a11y. Safely ignore.", __func__);
+
+       g_debug(_("Jump to byte"));
+       g_debug(_("Enter the byte to jump to"));
+
+       g_debug(_("Jump"));
+       g_debug(_("Jumps to the specified byte"));
+
+       g_debug(_("Close"));
+       g_debug(_("Closes jump to byte window"));
+}
+
+static void
+jump_dialog_dispose(GObject *object)
+{
+       JumpDialog *self = JUMP_DIALOG(object);
+
+       /* Boilerplate: chain up
+        */
+       G_OBJECT_CLASS(jump_dialog_parent_class)->dispose(object);
 }
 
+static void
+jump_dialog_finalize(GObject *gobject)
+{
+       /* here, you would free stuff. I've got nuthin' for ya. */
+
+       /* --- */
+
+       /* Boilerplate: chain up
+        */
+       G_OBJECT_CLASS(jump_dialog_parent_class)->finalize(gobject);
+}
+
+static void
+jump_dialog_class_init(JumpDialogClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+       /* <boilerplate> */
+       object_class->dispose = jump_dialog_dispose;
+       object_class->finalize = jump_dialog_finalize;
+       /* </boilerplate> */
+
+       /* CSS */
+       gtk_widget_class_set_css_name (widget_class, JUMP_DIALOG_CSS_NAME);
+
+       /* set the box-type layout manager for this Find dialog widget.
+        */
+       gtk_widget_class_set_layout_manager_type (widget_class,
+                       GTK_TYPE_BOX_LAYOUT);
+}
+
+GtkWidget *
+jump_dialog_new(void)
+{
+       return g_object_new(JUMP_TYPE_DIALOG, NULL);
+}
+
+void
+jump_dialog_set_hex (JumpDialog *self, GtkHex *gh)
+{
+       g_return_if_fail (JUMP_IS_DIALOG(self));
+       g_return_if_fail (GTK_IS_HEX(gh));
+
+       g_debug("%s: setting GtkHex of JumpDialog to: %p",
+                       __func__, (void *)gh);
+
+       self->gh = gh;
+}
diff --git a/src/findreplace.h b/src/findreplace.h
index e1ee53e2..76917bcc 100644
--- a/src/findreplace.h
+++ b/src/findreplace.h
@@ -1,7 +1,11 @@
+/* vim: colorcolumn=80 ts=4 sw=4
+ */
 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* findreplace.h - types related to find and replace dialogs
 
    Copyright (C) 2004 Free Software Foundation
+   Copyright (C) 2005-2020 FIXME
+   Copyright © 2021 Logan Rathbone
 
    GHex is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -21,86 +25,39 @@
    Author: Jaka Mocnik <jaka gnu org>
 */
 
-#ifndef __FINDREPLACE_H__
-#define __FINDREPLACE_H__ 
+#ifndef FINDREPLACE_H
+#define FINDREPLACE_H 
 
 #include <gtk/gtk.h>
 
 #include "gtkhex.h"
 #include "findreplace.h"
-#include "ghex-window.h"
 
 G_BEGIN_DECLS
 
-typedef struct _JumpDialog JumpDialog;
-
-struct _JumpDialog {
-       GtkWidget *window;
-       GtkWidget *int_entry;
-       GtkWidget *ok, *cancel;
-};
-
-typedef struct _FindDialog FindDialog;
-typedef struct _ReplaceDialog ReplaceDialog;
-
-struct _ReplaceDialog {
-       GtkWidget *window;
-       GtkWidget *f_gh, *r_gh;
-       HexDocument *f_doc, *r_doc;
-       GtkWidget *replace, *replace_all, *next, *close;
-       
-       GtkHex_AutoHighlight *auto_highlight;
-}; 
-
-struct _FindDialog {
-       GtkWidget *window;
-       GtkWidget *frame;
-       GtkWidget *vbox;
-       GtkWidget *hbox;
-       HexDocument *f_doc;
-       GtkWidget *f_gh;
-       GtkWidget *f_next, *f_prev, *f_close;
-       
-       GtkHex_AutoHighlight *auto_highlight;
-};
-
-typedef struct _AdvancedFindDialog AdvancedFindDialog;
-typedef struct _AdvancedFind_AddDialog AdvancedFind_AddDialog;
-
-struct _AdvancedFindDialog {
-       GHexWindow *parent;
-       AdvancedFind_AddDialog *addDialog;
-
-       GtkWidget *window;
-       GtkWidget *hbox;
-       GtkWidget *vbox;
-       GtkListStore *list;
-       GtkWidget *tree;
-       GtkWidget *f_next, *f_prev;
-       GtkWidget *f_new, *f_remove;
-       GtkWidget *f_close;
-};
-
-struct _AdvancedFind_AddDialog {
-       AdvancedFindDialog *parent;
-  
-       GtkWidget *window;
-       GtkWidget *f_gh;
-       HexDocument *f_doc;
-       GtkWidget *colour;
-};
-
-extern FindDialog     *find_dialog;
-extern ReplaceDialog  *replace_dialog;
-extern JumpDialog     *jump_dialog;
-
-/* creation of dialogs */
-FindDialog         *create_find_dialog         (void);
-ReplaceDialog      *create_replace_dialog      (void);
-JumpDialog         *create_jump_dialog         (void);
-AdvancedFindDialog *create_advanced_find_dialog(GHexWindow *parent);
-void               delete_advanced_find_dialog (AdvancedFindDialog *dialog);
+#define JUMP_TYPE_DIALOG (jump_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (JumpDialog, jump_dialog, JUMP, DIALOG, GtkWidget)
+
+#define FIND_TYPE_DIALOG (find_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (FindDialog, find_dialog, FIND, DIALOG, GtkWidget)
+
+#define REPLACE_TYPE_DIALOG (replace_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (ReplaceDialog, replace_dialog, REPLACE, DIALOG, GtkWidget)
+
+/* PUBLIC METHOD DECLARATIONS */
+
+/* FindDialog */
+GtkWidget *find_dialog_new(void);
+void find_dialog_set_hex(FindDialog *self, GtkHex *gh);
+
+/* ReplaceDialog */
+GtkWidget *replace_dialog_new(void);
+void replace_dialog_set_hex(ReplaceDialog *self, GtkHex *gh);
+
+/* JumpDialog */
+GtkWidget *jump_dialog_new(void);
+void jump_dialog_set_hex(JumpDialog *self, GtkHex *gh);
 
 G_END_DECLS
 
-#endif /* !__FINDREPLACE_H__ */
+#endif /* FINDREPLACE_H */
diff --git a/src/ghex-application-window.c b/src/ghex-application-window.c
index 51aff460..167bc228 100644
--- a/src/ghex-application-window.c
+++ b/src/ghex-application-window.c
@@ -4,6 +4,7 @@
 #include <gtkhex.h>
 #include "ghex-application-window.h"
 #include "hex-dialog.h"
+#include "findreplace.h"
 
 struct _GHexApplicationWindow
 {
@@ -14,6 +15,12 @@ struct _GHexApplicationWindow
        GtkWidget *dialog_widget;
        guint statusbar_id;
        GtkAdjustment *adj;
+
+       // TEST - NOT 100% SURE I WANNA GO THIS ROUTE YET.
+       GtkWidget *find_dialog;
+       GtkWidget *replace_dialog;
+       GtkWidget *jump_dialog;
+
 /*
  * for i in `cat ghex-application-window.ui |grep -i 'id=' |sed -e 's,^\s*,,g' |sed -e 's,.*id=",,' |sed -e 
's,">,,'`; do echo $i >> tmp.txt; done
  */
@@ -22,6 +29,7 @@ struct _GHexApplicationWindow
  */
        GtkWidget *child_box;
        GtkWidget *conversions_box;
+       GtkWidget *findreplace_box;
        GtkWidget *pane_toggle_button;
        GtkWidget *insert_mode_button;
        GtkWidget *statusbar;
@@ -54,6 +62,61 @@ cursor_moved_cb(GtkHex *gtkhex, gpointer user_data)
 
 /* ACTIONS */
 
+static void
+show_find_pane (GtkWidget *widget,
+               const char *action_name,
+               GVariant *parameter)
+{
+       GHexApplicationWindow *self = GHEX_APPLICATION_WINDOW(widget);
+
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+       g_return_if_fail (GTK_IS_WIDGET(self->find_dialog));
+
+       (void)parameter, (void)action_name;             /* unused */
+
+       gtk_widget_hide (self->replace_dialog);
+       gtk_widget_hide (self->jump_dialog);
+
+       gtk_widget_show (self->find_dialog);
+}
+
+static void
+show_replace_pane (GtkWidget *widget,
+               const char *action_name,
+               GVariant *parameter)
+{
+       GHexApplicationWindow *self = GHEX_APPLICATION_WINDOW(widget);
+
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+       g_return_if_fail (GTK_IS_WIDGET(self->replace_dialog));
+
+       (void)parameter, (void)action_name;             /* unused */
+
+       gtk_widget_hide (self->jump_dialog);
+       gtk_widget_hide (self->find_dialog);
+
+       gtk_widget_show (self->replace_dialog);
+}
+
+static void
+show_jump_pane (GtkWidget *widget,
+               const char *action_name,
+               GVariant *parameter)
+{
+       GHexApplicationWindow *self = GHEX_APPLICATION_WINDOW(widget);
+
+       g_return_if_fail (GTK_IS_HEX(self->gh));
+       g_return_if_fail (GTK_IS_WIDGET(self->jump_dialog));
+
+       (void)parameter, (void)action_name;             /* unused */
+
+       gtk_widget_hide (self->replace_dialog);
+       gtk_widget_hide (self->find_dialog);
+
+       gtk_widget_show (self->jump_dialog);
+}
+
+
 static void
 toggle_conversions (GtkWidget *widget,
                const char *action_name,
@@ -120,7 +183,7 @@ ghex_application_window_init(GHexApplicationWindow *self)
        self->dialog_widget = hex_dialog_getview (self->dialog);
 
        gtk_box_append (GTK_BOX(self->conversions_box), self->dialog_widget);
-       gtk_widget_set_visible (self->conversions_box, FALSE);
+       gtk_widget_hide (self->conversions_box);
 
        /* CSS - conversions_box */
        context = gtk_widget_get_style_context (self->conversions_box);
@@ -136,6 +199,22 @@ ghex_application_window_init(GHexApplicationWindow *self)
                                        GTK_STYLE_PROVIDER (provider),
                                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
+       /* Get find_dialog and friends geared up */
+
+       self->find_dialog = find_dialog_new ();
+       gtk_widget_set_hexpand (self->find_dialog, TRUE);
+       gtk_box_append (GTK_BOX(self->findreplace_box), self->find_dialog);
+       gtk_widget_hide (self->find_dialog);
+
+       self->replace_dialog = replace_dialog_new ();
+       gtk_widget_set_hexpand (self->replace_dialog, TRUE);
+       gtk_box_append (GTK_BOX(self->findreplace_box), self->replace_dialog);
+       gtk_widget_hide (self->replace_dialog);
+
+       self->jump_dialog = jump_dialog_new ();
+       gtk_widget_set_hexpand (self->jump_dialog, TRUE);
+       gtk_box_append (GTK_BOX(self->findreplace_box), self->jump_dialog);
+       gtk_widget_hide (self->jump_dialog);
 
        // TEST
        set_statusbar(self, "Offset: 0x0");
@@ -186,7 +265,18 @@ ghex_application_window_class_init(GHexApplicationWindowClass *klass)
        gtk_widget_class_install_action (widget_class, "ghex.insert-mode",
                        NULL,   // GVariant string param_type
                        toggle_insert_mode);
+       
+       gtk_widget_class_install_action (widget_class, "ghex.find",
+                       NULL,   // GVariant string param_type
+                       show_find_pane);
+
+       gtk_widget_class_install_action (widget_class, "ghex.replace",
+                       NULL,   // GVariant string param_type
+                       show_replace_pane);
 
+       gtk_widget_class_install_action (widget_class, "ghex.jump",
+                       NULL,   // GVariant string param_type
+                       show_jump_pane);
        /* 
         * for i in `cat tmp.txt`; do echo "gtk_widget_class_bind_template_child (widget_class, 
GHexApplicationWindow, ${i});"; done
         */
@@ -194,6 +284,8 @@ ghex_application_window_class_init(GHexApplicationWindowClass *klass)
                        child_box);
        gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
                        conversions_box);
+       gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
+                       findreplace_box);
        gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
                        pane_toggle_button);
        gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
@@ -202,6 +294,8 @@ ghex_application_window_class_init(GHexApplicationWindowClass *klass)
                        statusbar);
        gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
                        scrollbar);
+
+
 }
 
 GtkWidget *
@@ -226,4 +320,10 @@ ghex_application_window_add_hex(GHexApplicationWindow *self, GtkHex *gh)
        /* Setup scrollbar */
        self->adj = gtk_hex_get_adjustment(gh);
        gtk_scrollbar_set_adjustment (GTK_SCROLLBAR(self->scrollbar), self->adj);
+
+       /* Setup find_dialog & friends. */
+
+       find_dialog_set_hex (FIND_DIALOG(self->find_dialog), self->gh);
+       replace_dialog_set_hex (REPLACE_DIALOG(self->replace_dialog), self->gh);
+       jump_dialog_set_hex (JUMP_DIALOG(self->jump_dialog), self->gh);
 }
diff --git a/src/ghex-application-window.ui b/src/ghex-application-window.ui
index a6a4ecb7..55921789 100644
--- a/src/ghex-application-window.ui
+++ b/src/ghex-application-window.ui
@@ -31,13 +31,15 @@
                <!-- OTHER COMMON TASKS -->
                <section>
                        <item>
-                               <attribute name="label" translatable="yes">_Go to Byte</attribute>
-                               <attribute name="icon">go-jump-symbolic</attribute>
-                               <attribute name="action">ghex.goto</attribute>
+                               <attribute name="label" translatable="yes">Find and _Replace</attribute>
+                               <attribute name="action">ghex.replace</attribute>
+                       </item>
+                       <item>
+                               <attribute name="label" translatable="yes">_Jump to Byte</attribute>
+                               <attribute name="action">ghex.jump</attribute>
                        </item>
                </section>
 
-
                <!-- SUBMENUS -->
                <section>
 
@@ -46,15 +48,11 @@
                                <attribute name="label" translatable="yes">_Tools</attribute>
                                <item>
                                        <attribute name="label" translatable="yes">_Character 
Table</attribute>
-                                       <attribute name="action">ghex.goto</attribute>
+                                       <attribute name="action">ghex.char-table</attribute>
                                </item>
                                <item>
                                        <attribute name="label" translatable="yes">_Base Converter</attribute>
-                                       <attribute name="action">ghex.goto</attribute>
-                               </item>
-                               <item>
-                                       <attribute name="label" translatable="yes">_Type 
Conversion</attribute>
-                                       <attribute name="action">ghex.goto</attribute>
+                                       <attribute name="action">ghex.base-converter</attribute>
                                </item>
                        </submenu>
 
@@ -63,15 +61,15 @@
                                <attribute name="label" translatable="yes">G_roup Data As</attribute>
                                <item>
                                        <attribute name="label" translatable="yes">_Bytes</attribute>
-                                       <attribute name="action">ghex.goto</attribute>
+                                       <attribute name="action">ghex.group-bytes</attribute>
                                </item>
                                <item>
                                        <attribute name="label" translatable="yes">_Words</attribute>
-                                       <attribute name="action">ghex.goto</attribute>
+                                       <attribute name="action">ghex.group-words</attribute>
                                </item>
                                <item>
                                        <attribute name="label" translatable="yes">_Longwords</attribute>
-                                       <attribute name="action">ghex.goto</attribute>
+                                       <attribute name="action">ghex.group-long</attribute>
                                </item>
                        </submenu>
                </section>
@@ -127,7 +125,7 @@
                                                <property name="valign">center</property>
                                                <property name="icon-name">edit-find-symbolic</property>
                                                <property name="action-name">ghex.find</property>
-                                               <property name="tooltip-text" translatable="yes">Find and 
replace</property>
+                                               <property name="tooltip-text" 
translatable="yes">Find</property>
                                        </object>
                                </child>
 
@@ -159,12 +157,24 @@
                                        </object> <!-- child_box -->
                                </child> <!-- child_box -->
 
+                               <!-- "statusbar" separator -->
                                <child>
                                        <object class="GtkSeparator">
                                                <property name="orientation">horizontal</property>
                                        </object>
                                </child>
 
+                               <child> <!-- box to put the `findreplace' dialogs. -->
+                                       <object class="GtkBox" id="findreplace_box" />
+                               </child>
+
+                               <!-- "findreplace" separator which comes and goes. -->
+                               <child>
+                                       <object class="GtkSeparator" -->
+                                               <property name="orientation">horizontal</property>
+                                       </object>
+                               </child>
+
                                <child> <!-- box just to put the conversions_pane; APPEND -->
                                        <object class="GtkBox" id="conversions_box" />
                                </child>
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 5d03efef..b68fd853 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -55,11 +55,6 @@
 
 /* LAR - defines copied from the old header. */
 
-/* how to group bytes? */
-#define GROUP_BYTE 1
-#define GROUP_WORD 2
-#define GROUP_LONG 4
-
 #define LOWER_NIBBLE TRUE
 #define UPPER_NIBBLE FALSE
 
@@ -1232,7 +1227,6 @@ recalc_displays(GtkHex *gh)
        gtk_style_context_get_border (context, &border);
 #endif
 
-
        /*
         * Only change the value of the adjustment to put the cursor on screen
         * if the cursor is currently within the displayed portion.
@@ -1296,7 +1290,9 @@ recalc_displays(GtkHex *gh)
        g_return_if_fail (gh->cpl > 0);
 #endif
 
-       if (gh->document->file_size == 0)
+       // TEST
+       if (gh->document->file_size == 0 || gh->cpl == 0)
+//     if (gh->document->file_size == 0)
                gh->lines = 1;
        else {
                gh->lines = gh->document->file_size / gh->cpl;
@@ -1334,11 +1330,19 @@ recalc_displays(GtkHex *gh)
        gh->disp_buffer = g_malloc ((xcpl + 1) * (gh->vis_lines + 1));
 
        /* calculate new display position */
-       value = MIN (gh->top_line * old_cpl / gh->cpl, gh->lines - gh->vis_lines);
+       if (gh->cpl == 0)       // TEST to avoid divide by zero
+               value = 0;
+       else
+               value = MIN (gh->top_line * old_cpl / gh->cpl, gh->lines - gh->vis_lines);
+
+       /* clamp value */
        value = MAX (0, value);
 
        /* keep cursor on screen if it was on screen before */
-       if (scroll_to_cursor &&
+       if (gh->cpl == 0) {             // TEST to avoid divide by zero
+               value = 0;
+       }
+       else if (scroll_to_cursor &&
            ((gh->cursor_pos / gh->cpl < value) ||
             (gh->cursor_pos / gh->cpl > value + gh->vis_lines - 1))) {
                value = MIN (gh->cursor_pos / gh->cpl, gh->lines - gh->vis_lines);
@@ -3517,3 +3521,11 @@ gtk_hex_get_adjustment(GtkHex *gh)
 
        return gh->adj;
 }
+
+HexDocument *
+gtk_hex_get_document (GtkHex *gh)
+{
+       g_return_val_if_fail (HEX_IS_DOCUMENT(gh->document), NULL);
+
+       return gh->document;
+}
diff --git a/src/gtkhex.h b/src/gtkhex.h
index ca1d18da..ecc6a003 100644
--- a/src/gtkhex.h
+++ b/src/gtkhex.h
@@ -42,6 +42,12 @@ G_BEGIN_DECLS
 #define GTK_TYPE_HEX (gtk_hex_get_type ())
 G_DECLARE_FINAL_TYPE(GtkHex, gtk_hex, GTK, HEX, GtkWidget)
 
+/* DEFINES */
+/* how to group bytes? */
+#define GROUP_BYTE 1
+#define GROUP_WORD 2
+#define GROUP_LONG 4
+
 /* OPAQUE DATATYPES */
 typedef struct _GtkHex_AutoHighlight GtkHex_AutoHighlight;
 
@@ -84,6 +90,7 @@ GtkHex_AutoHighlight *gtk_hex_insert_autohighlight(GtkHex *gh,
 void gtk_hex_delete_autohighlight(GtkHex *gh, GtkHex_AutoHighlight *ahl);
 
 GtkAdjustment *gtk_hex_get_adjustment(GtkHex *gh);
+HexDocument *gtk_hex_get_document (GtkHex *gh);
 
 G_END_DECLS
 
diff --git a/src/hex-document.h b/src/hex-document.h
index f8ed95f6..3bc97b67 100644
--- a/src/hex-document.h
+++ b/src/hex-document.h
@@ -34,7 +34,7 @@ G_BEGIN_DECLS
 #define HEX_DOCUMENT_TYPE          (hex_document_get_type())
 #define HEX_DOCUMENT(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, hex_document_get_type (), HexDocument)
 #define HEX_DOCUMENT_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, hex_document_get_type (), 
HexDocumentClass)
-#define IS_HEX_DOCUMENT(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, hex_document_get_type ())
+#define HEX_IS_DOCUMENT(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, hex_document_get_type ())
 
 typedef struct _HexDocument       HexDocument;
 typedef struct _HexDocumentClass  HexDocumentClass;
diff --git a/src/preferences.h b/src/preferences.h
index 3c2f5066..ef1d04a7 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -29,7 +29,9 @@ G_BEGIN_DECLS
 typedef struct _PropertyUI PropertyUI;
 struct _PropertyUI {
        GtkWidget *pbox;
-       GtkRadioButton *group_type[3];
+       GtkCheckButton *group_type[3];
+       // GONE - GTK4
+//     GtkRadioButton *group_type[3];
        GtkWidget *font_button, *undo_spin, *box_size_spin;
        GtkWidget *offset_menu, *offset_choice[3];
        GtkWidget *format, *offsets_col;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]