File: | testsuite/ctk/listbox.c |
Warning: | line 31, column 8 Although the value stored to 'n1' is used in the enclosing expression, the value is never actually read from 'n1' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | #include <ctk/ctk.h> |
2 | |
3 | static gint |
4 | sort_list (CtkListBoxRow *row1, |
5 | CtkListBoxRow *row2, |
6 | gpointer data) |
7 | { |
8 | CtkWidget *label1, *label2; |
9 | gint n1, n2; |
10 | gint *count = data; |
11 | |
12 | (*count)++; |
13 | |
14 | label1 = ctk_bin_get_child (CTK_BIN (row1)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row1)), ((ctk_bin_get_type ()))))))); |
15 | n1 = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label1), "data"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((label1)), (((GType) ((20) << (2))) ))))), "data"))); |
16 | |
17 | label2 = ctk_bin_get_child (CTK_BIN (row2)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row2)), ((ctk_bin_get_type ()))))))); |
18 | n2 = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label2), "data"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((label2)), (((GType) ((20) << (2))) ))))), "data"))); |
19 | |
20 | return (n1 - n2); |
21 | } |
22 | |
23 | static void |
24 | check_sorted (CtkListBox *list) |
25 | { |
26 | GList *children; |
27 | CtkWidget *row, *label; |
28 | gint n1, n2; |
29 | GList *l; |
30 | |
31 | n2 = n1 = 0; |
Although the value stored to 'n1' is used in the enclosing expression, the value is never actually read from 'n1' | |
32 | children = ctk_container_get_children (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ()))))))); |
33 | for (l = children; l; l = l->next) |
34 | { |
35 | row = l->data; |
36 | n1 = n2; |
37 | label = ctk_bin_get_child (CTK_BIN (row)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row)), ((ctk_bin_get_type ()))))))); |
38 | n2 = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "data"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((label)), (((GType) ((20) << (2)))) )))), "data"))); |
39 | g_assert_cmpint (n1, <=, n2)do { gint64 __n1 = (n1), __n2 = (n2); if (__n1 <= __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 39, ( (const char*) (__func__)), "n1" " " "<=" " " "n2", (guint64 )__n1, "<=", (guint64)__n2, 'i'); } while (0); |
40 | } |
41 | g_list_free (children); |
42 | } |
43 | |
44 | static void |
45 | test_sort (void) |
46 | { |
47 | CtkListBox *list; |
48 | CtkListBoxRow *row; |
49 | CtkWidget *label; |
50 | gint i, r; |
51 | gchar *s; |
52 | gint count; |
53 | |
54 | list = CTK_LIST_BOX (ctk_list_box_new ())((((CtkListBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_box_new ())), ((ctk_list_box_get_type ())))))); |
55 | g_object_ref_sink (list)((__typeof__ (list)) (g_object_ref_sink) (list)); |
56 | ctk_widget_show (CTK_WIDGET (list)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_widget_get_type ()))))))); |
57 | |
58 | for (i = 0; i < 100; i++) |
59 | { |
60 | r = g_random_int_range (0, 1000); |
61 | s = g_strdup_printf ("%d: %d", i, r); |
62 | label = ctk_label_new (s); |
63 | g_object_set_data (G_OBJECT (label)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), (((GType) ((20) << (2)))))))), "data", GINT_TO_POINTER (r)((gpointer) (glong) (r))); |
64 | g_free (s); |
65 | ctk_container_add (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ())))))), label); |
66 | } |
67 | |
68 | count = 0; |
69 | ctk_list_box_set_sort_func (list, sort_list, &count, NULL((void*)0)); |
70 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 70 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
71 | |
72 | check_sorted (list); |
73 | |
74 | count = 0; |
75 | ctk_list_box_invalidate_sort (list); |
76 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 76 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
77 | |
78 | count = 0; |
79 | row = ctk_list_box_get_row_at_index (list, 0); |
80 | ctk_list_box_row_changed (row); |
81 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 81 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
82 | |
83 | g_object_unref (list); |
84 | } |
85 | |
86 | static CtkListBoxRow *callback_row; |
87 | |
88 | static void |
89 | on_row_selected (CtkListBox *list_box G_GNUC_UNUSED__attribute__ ((__unused__)), |
90 | CtkListBoxRow *row, |
91 | gpointer data) |
92 | { |
93 | gint *i = data; |
94 | |
95 | (*i)++; |
96 | |
97 | callback_row = row; |
98 | } |
99 | |
100 | static void |
101 | test_selection (void) |
102 | { |
103 | CtkListBox *list; |
104 | CtkListBoxRow *row, *row2; |
105 | CtkWidget *label; |
106 | gint i; |
107 | gchar *s; |
108 | gint count; |
109 | gint index; |
110 | |
111 | list = CTK_LIST_BOX (ctk_list_box_new ())((((CtkListBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_box_new ())), ((ctk_list_box_get_type ())))))); |
112 | g_object_ref_sink (list)((__typeof__ (list)) (g_object_ref_sink) (list)); |
113 | ctk_widget_show (CTK_WIDGET (list)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_widget_get_type ()))))))); |
114 | |
115 | g_assert_cmpint (ctk_list_box_get_selection_mode (list), ==, CTK_SELECTION_SINGLE)do { gint64 __n1 = (ctk_list_box_get_selection_mode (list)), __n2 = (CTK_SELECTION_SINGLE); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 115, ((const char*) (__func__)), "ctk_list_box_get_selection_mode (list)" " " "==" " " "CTK_SELECTION_SINGLE" , (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); |
116 | g_assert (ctk_list_box_get_selected_row (list) == NULL)do { if (ctk_list_box_get_selected_row (list) == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 116 , ((const char*) (__func__)), "ctk_list_box_get_selected_row (list) == NULL" ); } while (0); |
117 | |
118 | for (i = 0; i < 100; i++) |
119 | { |
120 | s = g_strdup_printf ("%d", i); |
121 | label = ctk_label_new (s); |
122 | g_object_set_data (G_OBJECT (label)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), (((GType) ((20) << (2)))))))), "data", GINT_TO_POINTER (i)((gpointer) (glong) (i))); |
123 | g_free (s); |
124 | ctk_container_add (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ())))))), label); |
125 | } |
126 | |
127 | count = 0; |
128 | g_signal_connect (list, "row-selected",g_signal_connect_data ((list), ("row-selected"), (((GCallback ) (on_row_selected))), (&count), ((void*)0), (GConnectFlags ) 0) |
129 | G_CALLBACK (on_row_selected),g_signal_connect_data ((list), ("row-selected"), (((GCallback ) (on_row_selected))), (&count), ((void*)0), (GConnectFlags ) 0) |
130 | &count)g_signal_connect_data ((list), ("row-selected"), (((GCallback ) (on_row_selected))), (&count), ((void*)0), (GConnectFlags ) 0); |
131 | |
132 | row = ctk_list_box_get_row_at_index (list, 20); |
133 | g_assert (!ctk_list_box_row_is_selected (row))do { if (!ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 133, ((const char*) (__func__)), "!ctk_list_box_row_is_selected (row)"); } while (0); |
134 | ctk_list_box_select_row (list, row); |
135 | g_assert (ctk_list_box_row_is_selected (row))do { if (ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 135, ((const char*) (__func__)), "ctk_list_box_row_is_selected (row)"); } while (0); |
136 | g_assert (callback_row == row)do { if (callback_row == row) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 136, ((const char*) (__func__)), "callback_row == row"); } while (0); |
137 | g_assert_cmpint (count, ==, 1)do { gint64 __n1 = (count), __n2 = (1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 137, ( (const char*) (__func__)), "count" " " "==" " " "1", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
138 | row2 = ctk_list_box_get_selected_row (list); |
139 | g_assert (row2 == row)do { if (row2 == row) ; else g_assertion_message_expr (((gchar *) 0), "listbox.c", 139, ((const char*) (__func__)), "row2 == row" ); } while (0); |
140 | ctk_list_box_unselect_all (list); |
141 | row2 = ctk_list_box_get_selected_row (list); |
142 | g_assert (row2 == NULL)do { if (row2 == ((void*)0)) ; else g_assertion_message_expr ( ((gchar*) 0), "listbox.c", 142, ((const char*) (__func__)), "row2 == NULL" ); } while (0); |
143 | ctk_list_box_select_row (list, row); |
144 | row2 = ctk_list_box_get_selected_row (list); |
145 | g_assert (row2 == row)do { if (row2 == row) ; else g_assertion_message_expr (((gchar *) 0), "listbox.c", 145, ((const char*) (__func__)), "row2 == row" ); } while (0); |
146 | |
147 | ctk_list_box_set_selection_mode (list, CTK_SELECTION_BROWSE); |
148 | ctk_container_remove (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ())))))), CTK_WIDGET (row)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row)), ((ctk_widget_get_type ()))))))); |
149 | g_assert (callback_row == NULL)do { if (callback_row == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 149, ((const char*) (__func__)), "callback_row == NULL"); } while (0); |
150 | g_assert_cmpint (count, ==, 4)do { gint64 __n1 = (count), __n2 = (4); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 150, ( (const char*) (__func__)), "count" " " "==" " " "4", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
151 | row2 = ctk_list_box_get_selected_row (list); |
152 | g_assert (row2 == NULL)do { if (row2 == ((void*)0)) ; else g_assertion_message_expr ( ((gchar*) 0), "listbox.c", 152, ((const char*) (__func__)), "row2 == NULL" ); } while (0); |
153 | |
154 | row = ctk_list_box_get_row_at_index (list, 20); |
155 | ctk_list_box_select_row (list, row); |
156 | g_assert (ctk_list_box_row_is_selected (row))do { if (ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 156, ((const char*) (__func__)), "ctk_list_box_row_is_selected (row)"); } while (0); |
157 | g_assert (callback_row == row)do { if (callback_row == row) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 157, ((const char*) (__func__)), "callback_row == row"); } while (0); |
158 | g_assert_cmpint (count, ==, 5)do { gint64 __n1 = (count), __n2 = (5); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 158, ( (const char*) (__func__)), "count" " " "==" " " "5", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
159 | |
160 | ctk_list_box_set_selection_mode (list, CTK_SELECTION_NONE); |
161 | g_assert (!ctk_list_box_row_is_selected (row))do { if (!ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 161, ((const char*) (__func__)), "!ctk_list_box_row_is_selected (row)"); } while (0); |
162 | g_assert (callback_row == NULL)do { if (callback_row == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 162, ((const char*) (__func__)), "callback_row == NULL"); } while (0); |
163 | g_assert_cmpint (count, ==, 6)do { gint64 __n1 = (count), __n2 = (6); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 163, ( (const char*) (__func__)), "count" " " "==" " " "6", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
164 | row2 = ctk_list_box_get_selected_row (list); |
165 | g_assert (row2 == NULL)do { if (row2 == ((void*)0)) ; else g_assertion_message_expr ( ((gchar*) 0), "listbox.c", 165, ((const char*) (__func__)), "row2 == NULL" ); } while (0); |
166 | |
167 | row = ctk_list_box_get_row_at_index (list, 20); |
168 | index = ctk_list_box_row_get_index (row); |
169 | g_assert_cmpint (index, ==, 20)do { gint64 __n1 = (index), __n2 = (20); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 169, ( (const char*) (__func__)), "index" " " "==" " " "20", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
170 | |
171 | row = CTK_LIST_BOX_ROW (ctk_list_box_row_new ())((((CtkListBoxRow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_box_row_new ())), ((ctk_list_box_row_get_type ( ))))))); |
172 | g_object_ref_sink (row)((__typeof__ (row)) (g_object_ref_sink) (row)); |
173 | index = ctk_list_box_row_get_index (row); |
174 | g_assert_cmpint (index, ==, -1)do { gint64 __n1 = (index), __n2 = (-1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 174, ( (const char*) (__func__)), "index" " " "==" " " "-1", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
175 | g_object_unref (row); |
176 | |
177 | g_object_unref (list); |
178 | } |
179 | |
180 | static void |
181 | on_selected_rows_changed (CtkListBox *box G_GNUC_UNUSED__attribute__ ((__unused__)), |
182 | gpointer data) |
183 | { |
184 | gint *i = data; |
185 | |
186 | (*i)++; |
187 | } |
188 | |
189 | static void |
190 | test_multi_selection (void) |
191 | { |
192 | CtkListBox *list; |
193 | GList *l; |
194 | CtkListBoxRow *row, *row2; |
195 | CtkWidget *label; |
196 | gint i; |
197 | gchar *s; |
198 | gint count; |
199 | |
200 | list = CTK_LIST_BOX (ctk_list_box_new ())((((CtkListBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_box_new ())), ((ctk_list_box_get_type ())))))); |
201 | g_object_ref_sink (list)((__typeof__ (list)) (g_object_ref_sink) (list)); |
202 | ctk_widget_show (CTK_WIDGET (list)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_widget_get_type ()))))))); |
203 | |
204 | g_assert_cmpint (ctk_list_box_get_selection_mode (list), ==, CTK_SELECTION_SINGLE)do { gint64 __n1 = (ctk_list_box_get_selection_mode (list)), __n2 = (CTK_SELECTION_SINGLE); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 204, ((const char*) (__func__)), "ctk_list_box_get_selection_mode (list)" " " "==" " " "CTK_SELECTION_SINGLE" , (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); |
205 | g_assert (ctk_list_box_get_selected_rows (list) == NULL)do { if (ctk_list_box_get_selected_rows (list) == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 205 , ((const char*) (__func__)), "ctk_list_box_get_selected_rows (list) == NULL" ); } while (0); |
206 | |
207 | ctk_list_box_set_selection_mode (list, CTK_SELECTION_MULTIPLE); |
208 | |
209 | for (i = 0; i < 100; i++) |
210 | { |
211 | s = g_strdup_printf ("%d", i); |
212 | label = ctk_label_new (s); |
213 | g_object_set_data (G_OBJECT (label)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), (((GType) ((20) << (2)))))))), "data", GINT_TO_POINTER (i)((gpointer) (glong) (i))); |
214 | g_free (s); |
215 | ctk_container_add (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ())))))), label); |
216 | } |
217 | |
218 | count = 0; |
219 | g_signal_connect (list, "selected-rows-changed",g_signal_connect_data ((list), ("selected-rows-changed"), ((( GCallback) (on_selected_rows_changed))), (&count), ((void *)0), (GConnectFlags) 0) |
220 | G_CALLBACK (on_selected_rows_changed),g_signal_connect_data ((list), ("selected-rows-changed"), ((( GCallback) (on_selected_rows_changed))), (&count), ((void *)0), (GConnectFlags) 0) |
221 | &count)g_signal_connect_data ((list), ("selected-rows-changed"), ((( GCallback) (on_selected_rows_changed))), (&count), ((void *)0), (GConnectFlags) 0); |
222 | |
223 | row = ctk_list_box_get_row_at_index (list, 20); |
224 | |
225 | ctk_list_box_select_all (list); |
226 | g_assert_cmpint (count, ==, 1)do { gint64 __n1 = (count), __n2 = (1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 226, ( (const char*) (__func__)), "count" " " "==" " " "1", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
227 | l = ctk_list_box_get_selected_rows (list); |
228 | g_assert_cmpint (g_list_length (l), ==, 100)do { gint64 __n1 = (g_list_length (l)), __n2 = (100); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c" , 228, ((const char*) (__func__)), "g_list_length (l)" " " "==" " " "100", (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); |
229 | g_list_free (l); |
230 | g_assert (ctk_list_box_row_is_selected (row))do { if (ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 230, ((const char*) (__func__)), "ctk_list_box_row_is_selected (row)"); } while (0); |
231 | |
232 | ctk_list_box_unselect_all (list); |
233 | g_assert_cmpint (count, ==, 2)do { gint64 __n1 = (count), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 233, ( (const char*) (__func__)), "count" " " "==" " " "2", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
234 | l = ctk_list_box_get_selected_rows (list); |
235 | g_assert (l == NULL)do { if (l == ((void*)0)) ; else g_assertion_message_expr ((( gchar*) 0), "listbox.c", 235, ((const char*) (__func__)), "l == NULL" ); } while (0); |
236 | g_assert (!ctk_list_box_row_is_selected (row))do { if (!ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 236, ((const char*) (__func__)), "!ctk_list_box_row_is_selected (row)"); } while (0); |
237 | |
238 | ctk_list_box_select_row (list, row); |
239 | g_assert (ctk_list_box_row_is_selected (row))do { if (ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 239, ((const char*) (__func__)), "ctk_list_box_row_is_selected (row)"); } while (0); |
240 | g_assert_cmpint (count, ==, 3)do { gint64 __n1 = (count), __n2 = (3); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 240, ( (const char*) (__func__)), "count" " " "==" " " "3", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
241 | l = ctk_list_box_get_selected_rows (list); |
242 | g_assert_cmpint (g_list_length (l), ==, 1)do { gint64 __n1 = (g_list_length (l)), __n2 = (1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c" , 242, ((const char*) (__func__)), "g_list_length (l)" " " "==" " " "1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); |
243 | g_assert (l->data == row)do { if (l->data == row) ; else g_assertion_message_expr ( ((gchar*) 0), "listbox.c", 243, ((const char*) (__func__)), "l->data == row" ); } while (0); |
244 | g_list_free (l); |
245 | |
246 | row2 = ctk_list_box_get_row_at_index (list, 40); |
247 | g_assert (!ctk_list_box_row_is_selected (row2))do { if (!ctk_list_box_row_is_selected (row2)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 247, ((const char*) (__func__)), "!ctk_list_box_row_is_selected (row2)"); } while (0); |
248 | ctk_list_box_select_row (list, row2); |
249 | g_assert (ctk_list_box_row_is_selected (row2))do { if (ctk_list_box_row_is_selected (row2)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 249, ((const char*) (__func__)), "ctk_list_box_row_is_selected (row2)"); } while (0); |
250 | g_assert_cmpint (count, ==, 4)do { gint64 __n1 = (count), __n2 = (4); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 250, ( (const char*) (__func__)), "count" " " "==" " " "4", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
251 | l = ctk_list_box_get_selected_rows (list); |
252 | g_assert_cmpint (g_list_length (l), ==, 2)do { gint64 __n1 = (g_list_length (l)), __n2 = (2); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c" , 252, ((const char*) (__func__)), "g_list_length (l)" " " "==" " " "2", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); |
253 | g_assert (l->data == row)do { if (l->data == row) ; else g_assertion_message_expr ( ((gchar*) 0), "listbox.c", 253, ((const char*) (__func__)), "l->data == row" ); } while (0); |
254 | g_assert (l->next->data == row2)do { if (l->next->data == row2) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 254, ((const char*) (__func__)), "l->next->data == row2"); } while (0); |
255 | g_list_free (l); |
256 | |
257 | ctk_list_box_unselect_row (list, row); |
258 | g_assert (!ctk_list_box_row_is_selected (row))do { if (!ctk_list_box_row_is_selected (row)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 258, ((const char*) (__func__)), "!ctk_list_box_row_is_selected (row)"); } while (0); |
259 | g_assert_cmpint (count, ==, 5)do { gint64 __n1 = (count), __n2 = (5); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 259, ( (const char*) (__func__)), "count" " " "==" " " "5", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
260 | l = ctk_list_box_get_selected_rows (list); |
261 | g_assert_cmpint (g_list_length (l), ==, 1)do { gint64 __n1 = (g_list_length (l)), __n2 = (1); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c" , 261, ((const char*) (__func__)), "g_list_length (l)" " " "==" " " "1", (guint64)__n1, "==", (guint64)__n2, 'i'); } while ( 0); |
262 | g_assert (l->data == row2)do { if (l->data == row2) ; else g_assertion_message_expr ( ((gchar*) 0), "listbox.c", 262, ((const char*) (__func__)), "l->data == row2" ); } while (0); |
263 | g_list_free (l); |
264 | |
265 | g_object_unref (list); |
266 | } |
267 | |
268 | static gboolean |
269 | filter_func (CtkListBoxRow *row, |
270 | gpointer data) |
271 | { |
272 | gint *count = data; |
273 | CtkWidget *child; |
274 | gint i; |
275 | |
276 | (*count)++; |
277 | |
278 | child = ctk_bin_get_child (CTK_BIN (row)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row)), ((ctk_bin_get_type ()))))))); |
279 | i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), "data"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((child)), (((GType) ((20) << (2)))) )))), "data"))); |
280 | |
281 | return (i % 2) == 0; |
282 | } |
283 | |
284 | static void |
285 | check_filtered (CtkListBox *list) |
286 | { |
287 | GList *children, *l; |
288 | gint count; |
289 | CtkWidget *row; |
290 | |
291 | count = 0; |
292 | children = ctk_container_get_children (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ()))))))); |
293 | for (l = children; l; l = l->next) |
294 | { |
295 | row = l->data; |
296 | if (ctk_widget_get_child_visible (row)) |
297 | count++; |
298 | } |
299 | g_list_free (children); |
300 | g_assert_cmpint (count, ==, 50)do { gint64 __n1 = (count), __n2 = (50); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 300, ( (const char*) (__func__)), "count" " " "==" " " "50", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
301 | } |
302 | |
303 | static void |
304 | test_filter (void) |
305 | { |
306 | CtkListBox *list; |
307 | CtkListBoxRow *row; |
308 | gint i; |
309 | gchar *s; |
310 | CtkWidget *label; |
311 | gint count; |
312 | |
313 | list = CTK_LIST_BOX (ctk_list_box_new ())((((CtkListBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_box_new ())), ((ctk_list_box_get_type ())))))); |
314 | g_object_ref_sink (list)((__typeof__ (list)) (g_object_ref_sink) (list)); |
315 | ctk_widget_show (CTK_WIDGET (list)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_widget_get_type ()))))))); |
316 | |
317 | g_assert_cmpint (ctk_list_box_get_selection_mode (list), ==, CTK_SELECTION_SINGLE)do { gint64 __n1 = (ctk_list_box_get_selection_mode (list)), __n2 = (CTK_SELECTION_SINGLE); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 317, ((const char*) (__func__)), "ctk_list_box_get_selection_mode (list)" " " "==" " " "CTK_SELECTION_SINGLE" , (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); |
318 | g_assert (ctk_list_box_get_selected_row (list) == NULL)do { if (ctk_list_box_get_selected_row (list) == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 318 , ((const char*) (__func__)), "ctk_list_box_get_selected_row (list) == NULL" ); } while (0); |
319 | |
320 | for (i = 0; i < 100; i++) |
321 | { |
322 | s = g_strdup_printf ("%d", i); |
323 | label = ctk_label_new (s); |
324 | g_object_set_data (G_OBJECT (label)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), (((GType) ((20) << (2)))))))), "data", GINT_TO_POINTER (i)((gpointer) (glong) (i))); |
325 | g_free (s); |
326 | ctk_container_add (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ())))))), label); |
327 | } |
328 | |
329 | count = 0; |
330 | ctk_list_box_set_filter_func (list, filter_func, &count, NULL((void*)0)); |
331 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 331 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
332 | |
333 | check_filtered (list); |
334 | |
335 | count = 0; |
336 | ctk_list_box_invalidate_filter (list); |
337 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 337 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
338 | |
339 | count = 0; |
340 | row = ctk_list_box_get_row_at_index (list, 0); |
341 | ctk_list_box_row_changed (row); |
342 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 342 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
343 | |
344 | g_object_unref (list); |
345 | } |
346 | |
347 | static void |
348 | header_func (CtkListBoxRow *row, |
349 | CtkListBoxRow *before G_GNUC_UNUSED__attribute__ ((__unused__)), |
350 | gpointer data) |
351 | { |
352 | CtkWidget *child; |
353 | gint i; |
354 | gint *count = data; |
355 | CtkWidget *header; |
356 | gchar *s; |
357 | |
358 | (*count)++; |
359 | |
360 | child = ctk_bin_get_child (CTK_BIN (row)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row)), ((ctk_bin_get_type ()))))))); |
361 | i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), "data"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((child)), (((GType) ((20) << (2)))) )))), "data"))); |
362 | |
363 | if (i % 2 == 0) |
364 | { |
365 | s = g_strdup_printf ("Header %d", i); |
366 | header = ctk_label_new (s); |
367 | g_free (s); |
368 | } |
369 | else |
370 | header = NULL((void*)0); |
371 | |
372 | ctk_list_box_row_set_header (row, header); |
373 | } |
374 | |
375 | static void |
376 | check_headers (CtkListBox *list) |
377 | { |
378 | GList *children, *l; |
379 | gint count; |
380 | CtkListBoxRow *row; |
381 | |
382 | count = 0; |
383 | children = ctk_container_get_children (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ()))))))); |
384 | for (l = children; l; l = l->next) |
385 | { |
386 | row = l->data; |
387 | if (ctk_list_box_row_get_header (row) != NULL((void*)0)) |
388 | count++; |
389 | } |
390 | g_list_free (children); |
391 | g_assert_cmpint (count, ==, 50)do { gint64 __n1 = (count), __n2 = (50); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 391, ( (const char*) (__func__)), "count" " " "==" " " "50", (guint64 )__n1, "==", (guint64)__n2, 'i'); } while (0); |
392 | } |
393 | |
394 | static void |
395 | test_header (void) |
396 | { |
397 | CtkListBox *list; |
398 | CtkListBoxRow *row; |
399 | gint i; |
400 | gchar *s; |
401 | CtkWidget *label; |
402 | gint count; |
403 | |
404 | list = CTK_LIST_BOX (ctk_list_box_new ())((((CtkListBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_box_new ())), ((ctk_list_box_get_type ())))))); |
405 | g_object_ref_sink (list)((__typeof__ (list)) (g_object_ref_sink) (list)); |
406 | ctk_widget_show (CTK_WIDGET (list)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_widget_get_type ()))))))); |
407 | |
408 | g_assert_cmpint (ctk_list_box_get_selection_mode (list), ==, CTK_SELECTION_SINGLE)do { gint64 __n1 = (ctk_list_box_get_selection_mode (list)), __n2 = (CTK_SELECTION_SINGLE); if (__n1 == __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 408, ((const char*) (__func__)), "ctk_list_box_get_selection_mode (list)" " " "==" " " "CTK_SELECTION_SINGLE" , (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0); |
409 | g_assert (ctk_list_box_get_selected_row (list) == NULL)do { if (ctk_list_box_get_selected_row (list) == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "listbox.c", 409 , ((const char*) (__func__)), "ctk_list_box_get_selected_row (list) == NULL" ); } while (0); |
410 | |
411 | for (i = 0; i < 100; i++) |
412 | { |
413 | s = g_strdup_printf ("%d", i); |
414 | label = ctk_label_new (s); |
415 | g_object_set_data (G_OBJECT (label)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), (((GType) ((20) << (2)))))))), "data", GINT_TO_POINTER (i)((gpointer) (glong) (i))); |
416 | g_free (s); |
417 | ctk_container_add (CTK_CONTAINER (list)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list)), ((ctk_container_get_type ())))))), label); |
418 | } |
419 | |
420 | count = 0; |
421 | ctk_list_box_set_header_func (list, header_func, &count, NULL((void*)0)); |
422 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 422 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
423 | |
424 | check_headers (list); |
425 | |
426 | count = 0; |
427 | ctk_list_box_invalidate_headers (list); |
428 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 428 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
429 | |
430 | count = 0; |
431 | row = ctk_list_box_get_row_at_index (list, 0); |
432 | ctk_list_box_row_changed (row); |
433 | g_assert_cmpint (count, >, 0)do { gint64 __n1 = (count), __n2 = (0); if (__n1 > __n2) ; else g_assertion_message_cmpint (((gchar*) 0), "listbox.c", 433 , ((const char*) (__func__)), "count" " " ">" " " "0", (guint64 )__n1, ">", (guint64)__n2, 'i'); } while (0); |
434 | |
435 | g_object_unref (list); |
436 | } |
437 | |
438 | int |
439 | main (int argc, char *argv[]) |
440 | { |
441 | ctk_test_init (&argc, &argv); |
442 | |
443 | g_test_add_func ("/listbox/sort", test_sort); |
444 | g_test_add_func ("/listbox/selection", test_selection); |
445 | g_test_add_func ("/listbox/multi-selection", test_multi_selection); |
446 | g_test_add_func ("/listbox/filter", test_filter); |
447 | g_test_add_func ("/listbox/header", test_header); |
448 | |
449 | return g_test_run (); |
450 | } |