summaryrefslogtreecommitdiff
path: root/demos/gtk-demo/search_entry2.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-12-27 18:53:21 -0500
committerMatthias Clasen <mclasen@redhat.com>2015-01-24 08:44:30 -0500
commita0ecb44b41ed5625aa05e101959110f09a089b5c (patch)
tree2c8b967d9713424681a3f74dab79c00b31e31d1a /demos/gtk-demo/search_entry2.c
parent3bf12c44e28076fd23c21a5e512df19070d04a0a (diff)
downloadgtk+-a0ecb44b41ed5625aa05e101959110f09a089b5c.tar.gz
gtk-demo: Show search entry signals
Diffstat (limited to 'demos/gtk-demo/search_entry2.c')
-rw-r--r--demos/gtk-demo/search_entry2.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/demos/gtk-demo/search_entry2.c b/demos/gtk-demo/search_entry2.c
index 839d4d5aa7..4d6b7a4d16 100644
--- a/demos/gtk-demo/search_entry2.c
+++ b/demos/gtk-demo/search_entry2.c
@@ -42,6 +42,34 @@ window_key_press_event_cb (GtkWidget *widget,
return gtk_search_bar_handle_event (bar, event);
}
+static void
+search_changed (GtkSearchEntry *entry,
+ GtkLabel *label)
+{
+ gtk_label_set_text (label, "search-changed");
+}
+
+static void
+next_match (GtkSearchEntry *entry,
+ GtkLabel *label)
+{
+ gtk_label_set_text (label, "next-match");
+}
+
+static void
+previous_match (GtkSearchEntry *entry,
+ GtkLabel *label)
+{
+ gtk_label_set_text (label, "previous-match");
+}
+
+static void
+stop_search (GtkSearchEntry *entry,
+ GtkLabel *label)
+{
+ gtk_label_set_text (label, "stop-search");
+}
+
GtkWidget *
do_search_entry2 (GtkWidget *do_widget)
{
@@ -99,6 +127,8 @@ do_search_entry2 (GtkWidget *do_widget)
gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
label = gtk_label_new ("Result:");
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_widget_set_margin_start (label, 6);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
label = gtk_label_new ("");
@@ -108,6 +138,27 @@ do_search_entry2 (GtkWidget *do_widget)
G_CALLBACK (search_changed_cb), label);
g_signal_connect (entry, "changed",
G_CALLBACK (changed_cb), label);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
+
+ label = gtk_label_new ("Signal:");
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_widget_set_margin_start (label, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ label = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ g_signal_connect (entry, "search-changed",
+ G_CALLBACK (search_changed), label);
+ g_signal_connect (entry, "next-match",
+ G_CALLBACK (next_match), label);
+ g_signal_connect (entry, "previous-match",
+ G_CALLBACK (previous_match), label);
+ g_signal_connect (entry, "stop-search",
+ G_CALLBACK (stop_search), label);
}
if (!gtk_widget_get_visible (window))