[ghex/expand-search-options: 5/14] findrep: Use GtkMenuButton for search options




commit a8ca35a536b4c5c7dc2640374f16b59ab53a136f
Author: Logan Rathbone <poprocks gmail com>
Date:   Wed Apr 13 23:04:51 2022 -0400

    findrep: Use GtkMenuButton for search options

 src/findreplace.c | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/src/findreplace.c b/src/findreplace.c
index c9b14d6..1fa067a 100644
--- a/src/findreplace.c
+++ b/src/findreplace.c
@@ -161,15 +161,6 @@ 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)
 {
@@ -863,12 +854,19 @@ 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);
+       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"));
+
+       f_priv->options_btn = gtk_menu_button_new ();
+       gtk_menu_button_set_icon_name (GTK_MENU_BUTTON(f_priv->options_btn),
+                       "emblem-system-symbolic");
+       gtk_menu_button_set_popover (GTK_MENU_BUTTON(f_priv->options_btn),
+                       f_priv->options_popover);
        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,
@@ -879,12 +877,6 @@ find_dialog_init (FindDialog *self)
                        _("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");


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