[gtk+/wip/combo: 5/11] Reorganize combo tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/combo: 5/11] Reorganize combo tests
- Date: Fri, 26 Dec 2014 05:20:51 +0000 (UTC)
commit 347ccfeda0febb050eaf5304073b0e73acb82acb
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 25 20:56:43 2014 -0500
Reorganize combo tests
And add and example for grouping.
tests/testnewcombo.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
---
diff --git a/tests/testnewcombo.c b/tests/testnewcombo.c
index 33872b4..faf7ff0 100644
--- a/tests/testnewcombo.c
+++ b/tests/testnewcombo.c
@@ -66,12 +66,101 @@ main (int argc, char *argv[])
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_container_add (GTK_CONTAINER (window), box);
+ label = gtk_label_new ("Simple");
+ gtk_widget_set_margin_start (label, 10);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ combo = gtk_combo_new ();
+ gtk_widget_set_halign (combo, GTK_ALIGN_CENTER);
+ gtk_container_add (GTK_CONTAINER (box), combo);
+ gtk_combo_add (GTK_COMBO (combo), "1", NULL, "Value 1");
+ gtk_combo_add (GTK_COMBO (combo), "2", NULL, "Value 2");
+ gtk_combo_add (GTK_COMBO (combo), "3", NULL, "Value 3");
+ gtk_combo_set_placeholder (GTK_COMBO (combo), "None");
+ gtk_combo_set_active (GTK_COMBO (combo), "1");
+
+ gtk_container_add (GTK_CONTAINER (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+
+ label = gtk_label_new ("With search and collapsing");
+ gtk_widget_set_margin_start (label, 10);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ combo = gtk_combo_new ();
+ gtk_widget_set_halign (combo, GTK_ALIGN_CENTER);
+ gtk_container_add (GTK_CONTAINER (box), combo);
+ gtk_combo_add (GTK_COMBO (combo), "1", "Value 01", "Value 1");
+ gtk_combo_add (GTK_COMBO (combo), "2", "Value 02", "Value 2");
+ gtk_combo_add (GTK_COMBO (combo), "3", "Value 03", "Value 3");
+ gtk_combo_add (GTK_COMBO (combo), "4", "Value 04", "Value 4");
+ gtk_combo_add (GTK_COMBO (combo), "5", "Value 05", "Value 5");
+ gtk_combo_add (GTK_COMBO (combo), "6", "Value 06", "Value 6");
+ gtk_combo_add (GTK_COMBO (combo), "7", "Value 07", "Value 7");
+ gtk_combo_add (GTK_COMBO (combo), "8", "Value 08", "Value 8");
+ gtk_combo_add (GTK_COMBO (combo), "9", "Value 09", "Value 9");
+ gtk_combo_add (GTK_COMBO (combo), "10", "Value 10", "Value 10");
+ gtk_combo_add (GTK_COMBO (combo), "11", "Value 11", "Value 11");
+ gtk_combo_set_placeholder (GTK_COMBO (combo), "None");
+ gtk_combo_set_active (GTK_COMBO (combo), "1");
+
+ gtk_container_add (GTK_CONTAINER (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+
+ label = gtk_label_new ("With free-form text");
+ gtk_widget_set_margin_start (label, 10);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ combo = gtk_combo_new ();
+ gtk_widget_set_halign (combo, GTK_ALIGN_CENTER);
+ gtk_container_add (GTK_CONTAINER (box), combo);
+ gtk_combo_add (GTK_COMBO (combo), "1", NULL, "Value 1");
+ gtk_combo_add (GTK_COMBO (combo), "2", NULL, "Value 2");
+ gtk_combo_add (GTK_COMBO (combo), "3", NULL, "Value 3");
+ gtk_combo_set_placeholder (GTK_COMBO (combo), "None");
+ gtk_combo_set_allow_custom (GTK_COMBO (combo), TRUE);
+ gtk_combo_set_active (GTK_COMBO (combo), "1");
+
+ gtk_container_add (GTK_CONTAINER (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+
+ label = gtk_label_new ("With grouping");
+ gtk_widget_set_margin_start (label, 10);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ combo = gtk_combo_new ();
+ gtk_widget_set_halign (combo, GTK_ALIGN_CENTER);
+ gtk_container_add (GTK_CONTAINER (box), combo);
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 1", "1", "Value 001", "Value 1");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 1", "2", "Value 002", "Value 2");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 1", "3", "Value 003", "Value 3");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 1", "4", "Value 004", "Value 4");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 2", "5", "Value 005", "Value 5");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 2", "6", "Value 006", "Value 6");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 2", "7", "Value 007", "Value 7");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 2", "8", "Value 008", "Value 8");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "9", "Value 009", "Value 9");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "10", "Value 010", "Value 10");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "11", "Value 011", "Value 11");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "12", "Value 012", "Value 12");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "13", "Value 013", "Value 13");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "14", "Value 014", "Value 14");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "15", "Value 015", "Value 15");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "16", "Value 016", "Value 16");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "17", "Value 017", "Value 17");
+ gtk_combo_add_with_group (GTK_COMBO (combo), "Group 3", "18", "Value 018", "Value 18");
+ gtk_combo_set_active (GTK_COMBO (combo), "7");
+
+ gtk_container_add (GTK_CONTAINER (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+
+ label = gtk_label_new ("Builder");
+ gtk_widget_set_margin_start (label, 10);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
builder = gtk_builder_new_from_string (data, -1);
combo = (GtkWidget *)gtk_builder_get_object (builder, "combo");
+ gtk_widget_set_halign (combo, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (box), combo);
g_object_unref (builder);
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+ gtk_widget_set_halign (box2, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (box), box2);
button = gtk_button_new_with_label ("Add value");
g_signal_connect (button, "clicked", G_CALLBACK (add_one), combo);
@@ -83,12 +172,14 @@ main (int argc, char *argv[])
g_signal_connect (button, "clicked", G_CALLBACK (remove_active), combo);
gtk_container_add (GTK_CONTAINER (box2), button);
button = gtk_check_button_new_with_label ("Allow custom");
+ gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
g_object_bind_property (button, "active",
combo, "allow-custom",
0);
gtk_container_add (GTK_CONTAINER (box), button);
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+ gtk_widget_set_halign (box2, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (box), box2);
label = gtk_label_new ("Active:");
gtk_container_add (GTK_CONTAINER (box2), label);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]