gtk-demo: Show search entry signals

This commit is contained in:
Matthias Clasen 2014-12-27 18:53:21 -05:00
parent 3bf12c44e2
commit a0ecb44b41

View File

@ -42,6 +42,34 @@ window_key_press_event_cb (GtkWidget *widget,
return gtk_search_bar_handle_event (bar, event); 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 * GtkWidget *
do_search_entry2 (GtkWidget *do_widget) 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); gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
label = gtk_label_new ("Result:"); 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); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
label = gtk_label_new (""); label = gtk_label_new ("");
@ -108,6 +138,27 @@ do_search_entry2 (GtkWidget *do_widget)
G_CALLBACK (search_changed_cb), label); G_CALLBACK (search_changed_cb), label);
g_signal_connect (entry, "changed", g_signal_connect (entry, "changed",
G_CALLBACK (changed_cb), label); 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)) if (!gtk_widget_get_visible (window))