[ghex/expand-search-options: 1/5] findrep: Setup initial GUI for extra Find options




commit 99f4b1a74c38693c8786090094219213f2e28ee6
Author: Logan Rathbone <poprocks gmail com>
Date:   Tue Apr 12 14:57:15 2022 -0400

    findrep: Setup initial GUI for extra Find options

 src/find-options.ui       | 42 ++++++++++++++++++++++++++++++++++++++++++
 src/findreplace.c         | 39 ++++++++++++++++++++++++++++++++++++++-
 src/ghex.gresource.xml.in |  1 +
 3 files changed, 81 insertions(+), 1 deletion(-)
---
diff --git a/src/find-options.ui b/src/find-options.ui
new file mode 100644
index 0000000..ad9b6e9
--- /dev/null
+++ b/src/find-options.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- vim: ts=2 sw=2
+-->
+<!--
+   Copyright © 2022 Logan Rathbone <poprocks gmail com>
+
+   GHex is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   GHex is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GHex; see the file COPYING.
+   If not, write to the Free Software Foundation, Inc.,
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+   Original GHex Author: Jaka Mocnik <jaka gnu org>
+-->
+
+<interface>
+       <object class="GtkPopover" id="find_options_popover">
+               <child>
+                       <object class="GtkGrid" id="find_options_grid">
+                               <child>
+                                       <object class="GtkCheckButton" id="find_options_regex">
+                                               <property name="label">Regular expressions</property>
+                                               <layout>
+                                                       <property name="column">0</property>
+                                                       <property name="row">0</property>
+                                               </layout>
+                                       </object>
+                               </child>
+                       </object>
+               </child>
+       </object>
+</interface>
diff --git a/src/findreplace.c b/src/findreplace.c
index 94a89b7..c2d184c 100644
--- a/src/findreplace.c
+++ b/src/findreplace.c
@@ -69,6 +69,9 @@ typedef struct {
        GtkWidget *hbox;
        GtkWidget *f_next, *f_prev, *f_clear;
        GtkWidget *close;
+       GtkWidget *options_btn;
+       GtkWidget *options_popover;
+       GtkWidget *options_regex;
        gboolean found;
        GCancellable *cancellable;
 
@@ -157,6 +160,15 @@ pane_dialog_real_close (PaneDialog *self)
        gtk_widget_hide (GTK_WIDGET(self));
 }
 
+static void
+find_options_cb (GtkButton *button, gpointer user_data)
+{
+       FindDialog *self = FIND_DIALOG(user_data);
+       FindDialogPrivate *f_priv = find_dialog_get_instance_private (self);
+
+       gtk_popover_popup (GTK_POPOVER(f_priv->options_popover));
+}
+
 static void
 find_cancel_cb (GtkButton *button, gpointer user_data)
 {
@@ -790,6 +802,7 @@ static void
 find_dialog_init (FindDialog *self)
 {
        FindDialogPrivate *f_priv = find_dialog_get_instance_private (self);
+       GtkBuilder *builder;
 
        f_priv->cancellable = g_cancellable_new ();
 
@@ -838,9 +851,33 @@ find_dialog_init (FindDialog *self)
                        _("Clears the data you are searching for"),
                        -1);
 
+       f_priv->options_btn = gtk_button_new_from_icon_name ("emblem-system-symbolic");
+       gtk_button_set_has_frame (GTK_BUTTON(f_priv->options_btn), FALSE);
+       gtk_widget_set_hexpand (f_priv->options_btn, TRUE);
+       gtk_widget_set_halign (f_priv->options_btn, GTK_ALIGN_END);
+       g_signal_connect (G_OBJECT (f_priv->options_btn), "clicked",
+                       G_CALLBACK(find_options_cb), self);
+       gtk_box_append (GTK_BOX(f_priv->hbox), f_priv->options_btn);
+       gtk_accessible_update_property (GTK_ACCESSIBLE(f_priv->options_btn),
+                       GTK_ACCESSIBLE_PROPERTY_LABEL,
+                       _("Find options"),
+                       -1);
+       gtk_accessible_update_property (GTK_ACCESSIBLE(f_priv->options_btn),
+                       GTK_ACCESSIBLE_PROPERTY_DESCRIPTION,
+                       _("View options of the find pane"),
+                       -1);
+
+       builder = gtk_builder_new_from_resource (RESOURCE_BASE_PATH "/find-options.ui");
+       f_priv->options_popover = GTK_WIDGET(
+                       gtk_builder_get_object (builder, "find_options_popover"));
+       f_priv->options_regex = GTK_WIDGET(
+                       gtk_builder_get_object (builder, "find_options_regex"));
+       gtk_widget_set_parent (f_priv->options_popover, f_priv->options_btn);
+       g_object_unref (builder);
+
        f_priv->close = gtk_button_new_from_icon_name ("window-close-symbolic");
        gtk_button_set_has_frame (GTK_BUTTON(f_priv->close), FALSE);
-       gtk_widget_set_hexpand (f_priv->close, TRUE);
+       gtk_widget_set_hexpand (f_priv->close, FALSE);
        gtk_widget_set_halign (f_priv->close, GTK_ALIGN_END);
        g_signal_connect (G_OBJECT (f_priv->close), "clicked",
                        G_CALLBACK(common_cancel_cb), self);
diff --git a/src/ghex.gresource.xml.in b/src/ghex.gresource.xml.in
index 232a4f0..e952606 100644
--- a/src/ghex.gresource.xml.in
+++ b/src/ghex.gresource.xml.in
@@ -29,6 +29,7 @@
                <file preprocess="xml-stripblanks" compressed="true">context-menu.ui</file>
                <file preprocess="xml-stripblanks" compressed="true">preferences.ui</file>
                <file preprocess="xml-stripblanks" compressed="true">paste-special.ui</file>
+               <file preprocess="xml-stripblanks" compressed="true">find-options.ui</file>
        </gresource>
        <gresource prefix="@resource_base_path@/css">
                <file>ghex.css</file>


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