[gedit/wip/use-gsv-search: 6/9] ViewFrame: fix search options



commit 2c0c58617846e266202ef8cf48d05a8cab6fca8a
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Jul 10 13:18:52 2013 +0200

    ViewFrame: fix search options

 gedit/gedit-view-frame.c |   63 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 48 insertions(+), 15 deletions(-)
---
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index 5a988eb..e7bb09e 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -547,26 +547,57 @@ update_search (GeditViewFrame *frame)
 }
 
 static void
+wrap_around_toggled_cb (GtkCheckMenuItem *menu_item,
+                       GeditViewFrame   *frame)
+{
+       GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gedit_view_frame_get_document (frame));
+
+       frame->priv->search_wrap_around = gtk_check_menu_item_get_active (menu_item);
+
+       gtk_source_buffer_set_search_wrap_around (buffer, frame->priv->search_wrap_around);
+}
+
+static void
+entire_word_toggled_cb (GtkCheckMenuItem *menu_item,
+                       GeditViewFrame   *frame)
+{
+       GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gedit_view_frame_get_document (frame));
+
+       frame->priv->search_at_word_boundaries = gtk_check_menu_item_get_active (menu_item);
+
+       gtk_source_buffer_set_search_at_word_boundaries (buffer, frame->priv->search_at_word_boundaries);
+}
+
+static void
+match_case_toggled_cb (GtkCheckMenuItem *menu_item,
+                      GeditViewFrame   *frame)
+{
+       GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gedit_view_frame_get_document (frame));
+
+       frame->priv->case_sensitive_search = gtk_check_menu_item_get_active (menu_item);
+
+       gtk_source_buffer_set_case_sensitive_search (buffer, frame->priv->case_sensitive_search);
+}
+
+static void
 add_popup_menu_items (GtkWidget      *menu,
                       GeditViewFrame *frame)
 {
-       GeditDocument *doc;
        GtkWidget *menu_item;
 
-       doc = gedit_view_frame_get_document (frame);
-
        /* create "Wrap Around" menu item. */
        menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Wrap Around"));
 
        gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
 
+       g_signal_connect (menu_item,
+                         "toggled",
+                         G_CALLBACK (wrap_around_toggled_cb),
+                         frame);
+
        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
                                        frame->priv->search_wrap_around);
 
-       g_object_bind_property (menu_item, "active",
-                               doc, "search-wrap-around",
-                               G_BINDING_SYNC_CREATE);
-
        gtk_widget_show (menu_item);
 
        /* create "Match Entire Word Only" menu item. */
@@ -574,13 +605,14 @@ add_popup_menu_items (GtkWidget      *menu,
 
        gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
 
+       g_signal_connect (menu_item,
+                         "toggled",
+                         G_CALLBACK (entire_word_toggled_cb),
+                         frame);
+
        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
                                        frame->priv->search_at_word_boundaries);
 
-       g_object_bind_property (menu_item, "active",
-                               doc, "search-at-word-boundaries",
-                               G_BINDING_SYNC_CREATE);
-
        gtk_widget_show (menu_item);
 
        /* create "Match Case" menu item. */
@@ -588,13 +620,14 @@ add_popup_menu_items (GtkWidget      *menu,
 
        gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
 
+       g_signal_connect (menu_item,
+                         "toggled",
+                         G_CALLBACK (match_case_toggled_cb),
+                         frame);
+
        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
                                        frame->priv->case_sensitive_search);
 
-       g_object_bind_property (menu_item, "active",
-                               doc, "case-sensitive-search",
-                               G_BINDING_SYNC_CREATE);
-
        gtk_widget_show (menu_item);
 }
 


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