From 6d71f7f61bd2a33766669274b3fb2a6d190cb455 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 11 Jun 2013 16:53:46 +0200 Subject: [PATCH] testgtk: Test GtkListBox placeholder widgets --- tests/testgtk.c | 58 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/tests/testgtk.c b/tests/testgtk.c index cdf86d31fa..e51e5c6d3a 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -2815,7 +2815,13 @@ list_sort_cb (GtkListBoxRow *a, GtkListBoxRow *b, gpointer data) } static gboolean -list_filter_cb (GtkListBoxRow *row, gpointer data) +list_filter_all_cb (GtkListBoxRow *row, gpointer data) +{ + return FALSE; +} + +static gboolean +list_filter_odd_cb (GtkListBoxRow *row, gpointer data) { gint value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "value")); @@ -2832,12 +2838,21 @@ list_sort_clicked_cb (GtkButton *button, } static void -list_filter_clicked_cb (GtkButton *button, - gpointer data) +list_filter_odd_clicked_cb (GtkButton *button, + gpointer data) { GtkListBox *list = data; - gtk_list_box_set_filter_func (list, list_filter_cb, NULL, NULL); + gtk_list_box_set_filter_func (list, list_filter_odd_cb, NULL, NULL); +} + +static void +list_filter_all_clicked_cb (GtkButton *button, + gpointer data) +{ + GtkListBox *list = data; + + gtk_list_box_set_filter_func (list, list_filter_all_cb, NULL, NULL); } @@ -2850,6 +2865,27 @@ list_unfilter_clicked_cb (GtkButton *button, gtk_list_box_set_filter_func (list, NULL, NULL, NULL); } +static void +add_placeholder_clicked_cb (GtkButton *button, + gpointer data) +{ + GtkListBox *list = data; + GtkWidget *label; + + label = gtk_label_new ("You filtered everything!!!"); + gtk_widget_show (label); + gtk_list_box_set_placeholder (GTK_LIST_BOX (list), label); +} + +static void +remove_placeholder_clicked_cb (GtkButton *button, + gpointer data) +{ + GtkListBox *list = data; + + gtk_list_box_set_placeholder (GTK_LIST_BOX (list), NULL); +} + static void create_listbox (GtkWidget *widget) @@ -2909,11 +2945,23 @@ create_listbox (GtkWidget *widget) button = gtk_button_new_with_label ("filter odd"); gtk_container_add (GTK_CONTAINER (vbox), button); - g_signal_connect (button, "clicked", G_CALLBACK (list_filter_clicked_cb), list); + g_signal_connect (button, "clicked", G_CALLBACK (list_filter_odd_clicked_cb), list); + + button = gtk_button_new_with_label ("filter all"); + gtk_container_add (GTK_CONTAINER (vbox), button); + g_signal_connect (button, "clicked", G_CALLBACK (list_filter_all_clicked_cb), list); button = gtk_button_new_with_label ("unfilter"); gtk_container_add (GTK_CONTAINER (vbox), button); g_signal_connect (button, "clicked", G_CALLBACK (list_unfilter_clicked_cb), list); + + button = gtk_button_new_with_label ("add placeholder"); + gtk_container_add (GTK_CONTAINER (vbox), button); + g_signal_connect (button, "clicked", G_CALLBACK (add_placeholder_clicked_cb), list); + + button = gtk_button_new_with_label ("remove placeholder"); + gtk_container_add (GTK_CONTAINER (vbox), button); + g_signal_connect (button, "clicked", G_CALLBACK (remove_placeholder_clicked_cb), list); } if (!gtk_widget_get_visible (window))