[gtksourceview/wip/search: 1/3] test-search-ui: clean-up the code



commit 394ed7700d8fb7cdf60d9b6237d5fcbb6cc4ad64
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Jul 4 18:06:09 2013 +0200

    test-search-ui: clean-up the code
    
    GObject class.
    Composite widget template.
    Connect callbacks in the .ui file.

 tests/test-search-ui.c  |  362 +++++++++++++++++++++-------------------
 tests/test-search-ui.ui |  425 ++++++++++++++++++++++++-----------------------
 2 files changed, 405 insertions(+), 382 deletions(-)
---
diff --git a/tests/test-search-ui.c b/tests/test-search-ui.c
index ba999cc..714538e 100644
--- a/tests/test-search-ui.c
+++ b/tests/test-search-ui.c
@@ -22,17 +22,43 @@
 #include <gtk/gtk.h>
 #include <gtksourceview/gtksource.h>
 
-typedef struct
+#define TEST_TYPE_SEARCH_UI             (test_search_ui_get_type ())
+#define TEST_SEARCH_UI(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_SEARCH_UI, 
TestSearchUI))
+#define TEST_SEARCH_UI_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_SEARCH_UI, 
TestSearchUIClass))
+#define TEST_IS_SEARCH_UI(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_SEARCH_UI))
+#define TEST_IS_SEARCH_UI_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_SEARCH_UI))
+#define TEST_SEARCH_UI_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SEARCH_UI, 
TestSearchUIClass))
+
+typedef struct _TestSearchUI        TestSearchUI;
+typedef struct _TestSearchUIClass   TestSearchUIClass;
+typedef struct _TestSearchUIPrivate TestSearchUIPrivate;
+
+struct _TestSearchUI
 {
-       GtkSourceView *view;
-       GtkSourceBuffer *buffer;
+       GtkGrid parent;
+       TestSearchUIPrivate *priv;
+};
+
+struct _TestSearchUIClass
+{
+       GtkGridClass parent_class;
+};
+
+struct _TestSearchUIPrivate
+{
+       GtkSourceView *source_view;
+       GtkSourceBuffer *source_buffer;
        GtkEntry *replace_entry;
-       GtkLabel *label;
-} TestSearchUI;
+       GtkLabel *label_occurrences;
+};
+
+GType test_search_ui_get_type (void);
+
+G_DEFINE_TYPE_WITH_PRIVATE (TestSearchUI, test_search_ui, GTK_TYPE_GRID)
 
 static void
-open_file (GtkSourceBuffer *buffer,
-          const gchar     *filename)
+open_file (TestSearchUI *search,
+          const gchar  *filename)
 {
        gchar *contents;
        GError *error = NULL;
@@ -45,21 +71,26 @@ open_file (GtkSourceBuffer *buffer,
                g_error ("Impossible to load file: %s", error->message);
        }
 
-       gtk_text_buffer_set_text (GTK_TEXT_BUFFER (buffer), contents, -1);
+       gtk_text_buffer_set_text (GTK_TEXT_BUFFER (search->priv->source_buffer),
+                                 contents,
+                                 -1);
 
        language_manager = gtk_source_language_manager_get_default ();
        language = gtk_source_language_manager_get_language (language_manager, "c");
-       gtk_source_buffer_set_language (buffer, language);
+       gtk_source_buffer_set_language (search->priv->source_buffer, language);
 
-       gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (buffer), &iter);
-       gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &iter, &iter);
+       gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (search->priv->source_buffer),
+                                       &iter);
+
+       gtk_text_buffer_select_range (GTK_TEXT_BUFFER (search->priv->source_buffer),
+                                     &iter,
+                                     &iter);
 
        g_free (contents);
 }
 
 static void
-update_label (GtkSourceBuffer *buffer,
-             GtkLabel        *label)
+update_label (TestSearchUI *search)
 {
        guint occurrences_count;
        GtkTextIter select_start;
@@ -67,13 +98,13 @@ update_label (GtkSourceBuffer *buffer,
        gint occurrence_pos;
        gchar *text;
 
-       occurrences_count = gtk_source_buffer_get_search_occurrences_count (buffer);
+       occurrences_count = gtk_source_buffer_get_search_occurrences_count (search->priv->source_buffer);
 
-       gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer),
+       gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (search->priv->source_buffer),
                                              &select_start,
                                              &select_end);
 
-       occurrence_pos = gtk_source_buffer_get_search_occurrence_position (buffer,
+       occurrence_pos = gtk_source_buffer_get_search_occurrence_position (search->priv->source_buffer,
                                                                           &select_start,
                                                                           &select_end);
 
@@ -86,47 +117,42 @@ update_label (GtkSourceBuffer *buffer,
                text = g_strdup_printf ("%u occurrences", occurrences_count);
        }
 
-       gtk_label_set_text (label, text);
+       gtk_label_set_text (search->priv->label_occurrences, text);
        g_free (text);
 }
 
 static void
-on_occurrences_count_notify_cb (GtkSourceBuffer *buffer,
-                               GParamSpec      *spec,
-                               GtkLabel        *label)
-{
-       update_label (buffer, label);
-}
-
-static void
-on_search_entry_text_notify_cb (GtkEntry        *entry,
-                               GParamSpec      *spec,
-                               GtkSourceBuffer *buffer)
+search_entry_changed_cb (TestSearchUI *search,
+                        GtkEntry     *entry)
 {
        const gchar *text = gtk_entry_get_text (entry);
        gchar *unescaped_text = gtk_source_utils_unescape_search_text (text);
 
-       gtk_source_buffer_set_search_text (buffer, unescaped_text);
+       gtk_source_buffer_set_search_text (search->priv->source_buffer, unescaped_text);
        g_free (unescaped_text);
 }
 
 static void
-select_search_occurrence (GtkTextView       *view,
+select_search_occurrence (TestSearchUI      *search,
                          const GtkTextIter *match_start,
                          const GtkTextIter *match_end)
 {
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
-       g_return_if_fail (buffer != NULL);
+       GtkTextMark *insert;
+
+       gtk_text_buffer_select_range (GTK_TEXT_BUFFER (search->priv->source_buffer),
+                                     match_start,
+                                     match_end);
 
-       gtk_text_buffer_select_range (buffer, match_start, match_end);
+       insert = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (search->priv->source_buffer));
 
-       gtk_text_view_scroll_mark_onscreen (view, gtk_text_buffer_get_insert (buffer));
+       gtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW (search->priv->source_view),
+                                           insert);
 }
 
 static void
 backward_search_finished (GtkSourceBuffer *buffer,
                          GAsyncResult    *result,
-                         GtkTextView     *view)
+                         TestSearchUI    *search)
 {
        GtkTextIter match_start;
        GtkTextIter match_end;
@@ -137,27 +163,25 @@ backward_search_finished (GtkSourceBuffer *buffer,
                                                      &match_end,
                                                      NULL))
        {
-               select_search_occurrence (view, &match_start, &match_end);
+               select_search_occurrence (search, &match_start, &match_end);
        }
 }
 
 static void
-on_button_previous_clicked_cb (GtkButton   *button,
-                              GtkTextView *view)
+button_previous_clicked_cb (TestSearchUI *search,
+                           GtkButton    *button)
 {
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
-
-       gtk_source_buffer_backward_search_async (GTK_SOURCE_BUFFER (buffer),
+       gtk_source_buffer_backward_search_async (search->priv->source_buffer,
                                                 NULL,
                                                 NULL,
                                                 (GAsyncReadyCallback)backward_search_finished,
-                                                view);
+                                                search);
 }
 
 static void
 forward_search_finished (GtkSourceBuffer *buffer,
                         GAsyncResult    *result,
-                        GtkTextView     *view)
+                        TestSearchUI    *search)
 {
        GtkTextIter match_start;
        GtkTextIter match_end;
@@ -168,54 +192,52 @@ forward_search_finished (GtkSourceBuffer *buffer,
                                                     &match_end,
                                                     NULL))
        {
-               select_search_occurrence (view, &match_start, &match_end);
+               select_search_occurrence (search, &match_start, &match_end);
        }
 }
 
 static void
-on_button_next_clicked_cb (GtkButton   *button,
-                          GtkTextView *view)
+button_next_clicked_cb (TestSearchUI *search,
+                       GtkButton    *button)
 {
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
-
-       gtk_source_buffer_forward_search_async (GTK_SOURCE_BUFFER (buffer),
+       gtk_source_buffer_forward_search_async (search->priv->source_buffer,
                                                NULL,
                                                NULL,
                                                (GAsyncReadyCallback)forward_search_finished,
-                                               view);
+                                               search);
 }
 
 static void
-on_replace_cb (GtkButton    *button,
-              TestSearchUI *data)
+button_replace_clicked_cb (TestSearchUI *search,
+                          GtkButton    *button)
 {
-       gtk_source_buffer_search_replace (data->buffer,
+       gtk_source_buffer_search_replace (search->priv->source_buffer,
                                          NULL,
                                          NULL,
-                                         gtk_entry_get_text (data->replace_entry),
+                                         gtk_entry_get_text (search->priv->replace_entry),
                                          -1);
 
-       gtk_source_buffer_forward_search_async (data->buffer,
+       gtk_source_buffer_forward_search_async (search->priv->source_buffer,
                                                NULL,
                                                NULL,
                                                (GAsyncReadyCallback)forward_search_finished,
-                                               data->view);
+                                               search);
 }
 
 static void
-on_replace_all_cb (GtkButton    *button,
-                  TestSearchUI *data)
+button_replace_all_clicked_cb (TestSearchUI *search,
+                              GtkButton    *button)
 {
-       gtk_source_buffer_search_replace_all (data->buffer,
-                                             gtk_entry_get_text (data->replace_entry),
+       gtk_source_buffer_search_replace_all (search->priv->source_buffer,
+                                             gtk_entry_get_text (search->priv->replace_entry),
                                              -1);
 }
 
 static void
-on_mark_set_cb (GtkTextBuffer *buffer,
-               GtkTextIter   *location,
-               GtkTextMark   *mark,
-               TestSearchUI  *data)
+mark_set_cb (GtkTextBuffer *buffer,
+            GtkTextIter   *location,
+            GtkTextMark   *mark,
+            TestSearchUI  *search)
 {
        GtkTextMark *insert;
        GtkTextMark *selection_bound;
@@ -225,140 +247,140 @@ on_mark_set_cb (GtkTextBuffer *buffer,
 
        if (mark == insert || mark == selection_bound)
        {
-               update_label (data->buffer, data->label);
+               update_label (search);
        }
 }
 
 static void
-create_window (void)
+match_case_toggled_cb (TestSearchUI    *search,
+                      GtkToggleButton *button)
 {
-       GtkBuilder *builder;
-       GError *error = NULL;
-       GtkWindow *window;
-       GtkSourceView *source_view;
-       GtkSourceBuffer *source_buffer;
-       GtkSearchEntry *search_entry;
-       GtkLabel *label_occurrences;
-       GtkCheckButton *match_case;
-       GtkCheckButton *at_word_boundaries;
-       GtkCheckButton *wrap_around;
-       GtkButton *button_previous;
-       GtkButton *button_next;
-       GtkEntry *replace_entry;
-       GtkButton *button_replace;
-       GtkButton *button_replace_all;
-       PangoFontDescription *font;
-       TestSearchUI *data;
+       gtk_source_buffer_set_case_sensitive_search (search->priv->source_buffer,
+                                                    gtk_toggle_button_get_active (button));
+}
 
-       builder = gtk_builder_new ();
+static void
+at_word_boundaries_toggled_cb (TestSearchUI    *search,
+                              GtkToggleButton *button)
+{
+       gtk_source_buffer_set_search_at_word_boundaries (search->priv->source_buffer,
+                                                        gtk_toggle_button_get_active (button));
+}
 
-       gtk_builder_add_from_resource (builder,
-                                      "/org/gnome/gtksourceview/tests/ui/test-search-ui.ui",
-                                      &error);
+static void
+wrap_around_toggled_cb (TestSearchUI    *search,
+                       GtkToggleButton *button)
+{
+       gtk_source_buffer_set_search_wrap_around (search->priv->source_buffer,
+                                                 gtk_toggle_button_get_active (button));
+}
 
-       if (error != NULL)
-       {
-               g_error ("Impossible to load test-search-ui.ui: %s", error->message);
-       }
+static void
+test_search_ui_finalize (GObject *object)
+{
+       TestSearchUI *search = TEST_SEARCH_UI (object);
 
-       window = GTK_WINDOW (gtk_builder_get_object (builder, "window"));
-       source_view = GTK_SOURCE_VIEW (gtk_builder_get_object (builder, "source_view"));
-       search_entry = GTK_SEARCH_ENTRY (gtk_builder_get_object (builder, "search_entry"));
-       label_occurrences = GTK_LABEL (gtk_builder_get_object (builder, "label_occurrences"));
-       match_case = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "checkbutton_match_case"));
-       at_word_boundaries = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, 
"checkbutton_at_word_boundaries"));
-       wrap_around = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "checkbutton_wrap_around"));
-       button_previous = GTK_BUTTON (gtk_builder_get_object (builder, "button_previous"));
-       button_next = GTK_BUTTON (gtk_builder_get_object (builder, "button_next"));
-       replace_entry = GTK_ENTRY (gtk_builder_get_object (builder, "entry_replace"));
-       button_replace = GTK_BUTTON (gtk_builder_get_object (builder, "button_replace"));
-       button_replace_all = GTK_BUTTON (gtk_builder_get_object (builder, "button_replace_all"));
+       g_object_unref (search->priv->source_buffer);
+
+       G_OBJECT_CLASS (test_search_ui_parent_class)->finalize (object);
+}
+
+static void
+test_search_ui_class_init (TestSearchUIClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+       object_class->finalize = test_search_ui_finalize;
+
+       gtk_widget_class_set_template_from_resource (widget_class,
+                                                    "/org/gnome/gtksourceview/tests/ui/test-search-ui.ui");
+
+       gtk_widget_class_bind_child (widget_class, TestSearchUIPrivate, source_view);
+       gtk_widget_class_bind_child (widget_class, TestSearchUIPrivate, replace_entry);
+       gtk_widget_class_bind_child (widget_class, TestSearchUIPrivate, label_occurrences);
+
+       gtk_widget_class_bind_callback (widget_class, search_entry_changed_cb);
+       gtk_widget_class_bind_callback (widget_class, button_previous_clicked_cb);
+       gtk_widget_class_bind_callback (widget_class, button_next_clicked_cb);
+       gtk_widget_class_bind_callback (widget_class, button_replace_clicked_cb);
+       gtk_widget_class_bind_callback (widget_class, button_replace_all_clicked_cb);
+
+       /* It is also possible to bind the properties with
+        * g_object_bind_property(), between the check buttons and the source
+        * buffer. But GtkBuilder and Glade don't support that yet.
+        */
+       gtk_widget_class_bind_callback (widget_class, match_case_toggled_cb);
+       gtk_widget_class_bind_callback (widget_class, at_word_boundaries_toggled_cb);
+       gtk_widget_class_bind_callback (widget_class, wrap_around_toggled_cb);
+}
+
+static void
+test_search_ui_init (TestSearchUI *search)
+{
+       PangoFontDescription *font;
+
+       search->priv = test_search_ui_get_instance_private (search);
+
+       gtk_widget_init_template (GTK_WIDGET (search));
 
        font = pango_font_description_from_string ("Monospace 10");
-       gtk_widget_override_font (GTK_WIDGET (source_view), font);
+       gtk_widget_override_font (GTK_WIDGET (search->priv->source_view), font);
+       pango_font_description_free (font);
 
-       gtk_source_view_set_tab_width (source_view, 8);
+       /* FIXME: bug? Normally the tab width is 8 by default. */
+       gtk_source_view_set_tab_width (search->priv->source_view, 8);
 
        /* Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=643732:
         * "Source view is created with a GtkTextBuffer instead of GtkSourceBuffer"
         */
-       source_buffer = gtk_source_buffer_new (NULL);
-
-       gtk_text_view_set_buffer (GTK_TEXT_VIEW (source_view),
-                                 GTK_TEXT_BUFFER (source_buffer));
+       search->priv->source_buffer = gtk_source_buffer_new (NULL);
 
-       g_object_unref (source_buffer);
+       gtk_text_view_set_buffer (GTK_TEXT_VIEW (search->priv->source_view),
+                                 GTK_TEXT_BUFFER (search->priv->source_buffer));
 
-       open_file (source_buffer, TOP_SRCDIR "/gtksourceview/gtksourcesearch.c");
+       open_file (search, TOP_SRCDIR "/gtksourceview/gtksourcesearch.c");
 
-       data = g_slice_new (TestSearchUI);
-       data->view = source_view;
-       data->buffer = source_buffer;
-       data->replace_entry = replace_entry;
-       data->label = label_occurrences;
+       g_signal_connect_swapped (search->priv->source_buffer,
+                                 "notify::search-occurrences-count",
+                                 G_CALLBACK (update_label),
+                                 search);
 
-       g_signal_connect (window,
-                         "destroy",
-                         G_CALLBACK (gtk_main_quit),
-                         NULL);
-
-       g_signal_connect (search_entry,
-                         "notify::text",
-                         G_CALLBACK (on_search_entry_text_notify_cb),
-                         source_buffer);
-
-       g_signal_connect (source_buffer,
-                         "notify::search-occurrences-count",
-                         G_CALLBACK (on_occurrences_count_notify_cb),
-                         label_occurrences);
-
-       g_signal_connect (button_previous,
-                         "clicked",
-                         G_CALLBACK (on_button_previous_clicked_cb),
-                         source_view);
-
-       g_signal_connect (button_next,
-                         "clicked",
-                         G_CALLBACK (on_button_next_clicked_cb),
-                         source_view);
-
-       g_object_bind_property (match_case, "active",
-                               source_buffer, "case-sensitive-search",
-                               G_BINDING_SYNC_CREATE);
-
-       g_object_bind_property (at_word_boundaries, "active",
-                               source_buffer, "search-at-word-boundaries",
-                               G_BINDING_SYNC_CREATE);
-
-       g_object_bind_property (wrap_around, "active",
-                               source_buffer, "search-wrap-around",
-                               G_BINDING_SYNC_CREATE);
-
-       g_signal_connect (button_replace,
-                         "clicked",
-                         G_CALLBACK (on_replace_cb),
-                         data);
-
-       g_signal_connect (button_replace_all,
-                         "clicked",
-                         G_CALLBACK (on_replace_all_cb),
-                         data);
-
-       g_signal_connect (source_buffer,
+       g_signal_connect (search->priv->source_buffer,
                          "mark-set",
-                         G_CALLBACK (on_mark_set_cb),
-                         data);
+                         G_CALLBACK (mark_set_cb),
+                         search);
+}
 
-       g_object_unref (builder);
+static TestSearchUI *
+test_search_ui_new (void)
+{
+       return g_object_new (test_search_ui_get_type (), NULL);
 }
 
-int
-main (int argc, char *argv[])
+gint
+main (gint argc, gchar *argv[])
 {
+       GtkWidget *window;
+       TestSearchUI *search;
+
        gtk_init (&argc, &argv);
 
-       create_window ();
+       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+       gtk_window_set_default_size (GTK_WINDOW (window), 700, 500);
+
+       g_signal_connect (window,
+                         "destroy",
+                         G_CALLBACK (gtk_main_quit),
+                         NULL);
+
+       search = test_search_ui_new ();
+       gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (search));
+
+       gtk_widget_show_all (window);
 
        gtk_main ();
+
        return 0;
 }
diff --git a/tests/test-search-ui.ui b/tests/test-search-ui.ui
index 4deb16f..1461727 100644
--- a/tests/test-search-ui.ui
+++ b/tests/test-search-ui.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.6 -->
+  <!-- interface-requires gtk+ 3.10 -->
   <!-- interface-requires gtksourceview 3.0 -->
   <object class="GtkImage" id="image1">
     <property name="visible">True</property>
@@ -26,36 +26,52 @@
     <property name="stock">gtk-find-and-replace</property>
     <property name="icon_size">1</property>
   </object>
-  <object class="GtkWindow" id="window">
+  <template class="TestSearchUI" parent="GtkGrid">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="default_width">700</property>
-    <property name="default_height">500</property>
+    <property name="border_width">6</property>
+    <property name="row_spacing">6</property>
     <child>
-      <object class="GtkGrid" id="grid1">
+      <object class="GtkScrolledWindow" id="scrolledwindow1">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">6</property>
-        <property name="row_spacing">6</property>
+        <property name="can_focus">True</property>
+        <property name="shadow_type">in</property>
         <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
+          <object class="GtkSourceView" id="source_view">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkSourceView" id="source_view">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="has_tooltip">True</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="left_margin">2</property>
-                <property name="right_margin">2</property>
-                <property name="tab_width">4</property>
-                <property name="auto_indent">True</property>
-                <property name="indent_on_tab">False</property>
-              </object>
-            </child>
+            <property name="has_tooltip">True</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="left_margin">2</property>
+            <property name="right_margin">2</property>
+            <property name="tab_width">4</property>
+            <property name="auto_indent">True</property>
+            <property name="indent_on_tab">False</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkGrid" id="grid2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="column_spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="label">Search:</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
           </object>
           <packing>
             <property name="left_attach">0</property>
@@ -65,83 +81,102 @@
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid2">
+          <object class="GtkSearchEntry" id="search_entry">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="primary_icon_name">edit-find-symbolic</property>
+            <property name="primary_icon_activatable">False</property>
+            <property name="primary_icon_sensitive">False</property>
+            <signal name="changed" handler="search_entry_changed_cb" object="TestSearchUI" swapped="yes"/>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label_occurrences">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="column_spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label">Search:</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSearchEntry" id="search_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="primary_icon_name">edit-find-symbolic</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="primary_icon_sensitive">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label_occurrences">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label">0 occurrences</property>
-              </object>
-              <packing>
-                <property name="left_attach">4</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button_previous">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="image">image1</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button_next">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="image">image2</property>
-              </object>
-              <packing>
-                <property name="left_attach">3</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
+            <property name="label">0 occurrences</property>
+          </object>
+          <packing>
+            <property name="left_attach">4</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button_previous">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="image">image1</property>
+            <signal name="clicked" handler="button_previous_clicked_cb" object="TestSearchUI" swapped="yes"/>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button_next">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="image">image2</property>
+            <signal name="clicked" handler="button_next_clicked_cb" object="TestSearchUI" swapped="yes"/>
+          </object>
+          <packing>
+            <property name="left_attach">3</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">1</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkGrid" id="grid3">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkCheckButton" id="checkbutton_match_case">
+            <property name="label">Match case</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="draw_indicator">True</property>
+            <signal name="toggled" handler="match_case_toggled_cb" object="TestSearchUI" swapped="yes"/>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkCheckButton" id="checkbutton_at_word_boundaries">
+            <property name="label">At word boundaries</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="draw_indicator">True</property>
+            <signal name="toggled" handler="at_word_boundaries_toggled_cb" object="TestSearchUI" 
swapped="yes"/>
           </object>
           <packing>
             <property name="left_attach">0</property>
@@ -151,57 +186,15 @@
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid3">
+          <object class="GtkCheckButton" id="checkbutton_wrap_around">
+            <property name="label">Wrap around</property>
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkCheckButton" id="checkbutton_match_case">
-                <property name="label">Match case</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="checkbutton_at_word_boundaries">
-                <property name="label">At word boundaries</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="checkbutton_wrap_around">
-                <property name="label">Wrap around</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+            <signal name="toggled" handler="wrap_around_toggled_cb" object="TestSearchUI" swapped="yes"/>
           </object>
           <packing>
             <property name="left_attach">0</property>
@@ -210,79 +203,87 @@
             <property name="height">1</property>
           </packing>
         </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">2</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkGrid" id="grid4">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="column_spacing">6</property>
         <child>
-          <object class="GtkGrid" id="grid4">
+          <object class="GtkLabel" id="label2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="column_spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label">Replace:</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="entry_replace">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button_replace">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="image">image3</property>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button_replace_all">
-                <property name="label">All</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="image">image4</property>
-                <property name="always_show_image">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">3</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
+            <property name="xalign">0</property>
+            <property name="label">Replace:</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">3</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkEntry" id="replace_entry">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button_replace">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="image">image3</property>
+            <signal name="clicked" handler="button_replace_clicked_cb" object="TestSearchUI" swapped="yes"/>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button_replace_all">
+            <property name="label">All</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="image">image4</property>
+            <property name="always_show_image">True</property>
+            <signal name="clicked" handler="button_replace_all_clicked_cb" object="TestSearchUI" 
swapped="yes"/>
+          </object>
+          <packing>
+            <property name="left_attach">3</property>
+            <property name="top_attach">0</property>
             <property name="width">1</property>
             <property name="height">1</property>
           </packing>
         </child>
       </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">3</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
     </child>
-  </object>
+  </template>
 </interface>



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