File: | tests/testscale.c |
Warning: | line 165, column 3 Value stored to 'box2' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* testscale.c - scale mark demo |
2 | * Copyright (C) 2009 Red Hat, Inc. |
3 | * Author: Matthias Clasen |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | #include <ctk/ctk.h> |
20 | |
21 | |
22 | GSList *scales; |
23 | CtkWidget *flipbox; |
24 | CtkWidget *extra_scale; |
25 | |
26 | static void |
27 | invert (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__))) |
28 | { |
29 | GSList *l; |
30 | |
31 | for (l = scales; l; l = l->next) |
32 | { |
33 | CtkRange *range = l->data; |
34 | ctk_range_set_inverted (range, !ctk_range_get_inverted (range)); |
35 | } |
36 | } |
37 | |
38 | static void |
39 | flip (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__))) |
40 | { |
41 | GSList *l; |
42 | |
43 | ctk_orientable_set_orientation (CTK_ORIENTABLE (flipbox)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((flipbox)), ((ctk_orientable_get_type ())))))), 1 - ctk_orientable_get_orientation (CTK_ORIENTABLE (flipbox)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((flipbox)), ((ctk_orientable_get_type ())))))))); |
44 | |
45 | for (l = scales; l; l = l->next) |
46 | { |
47 | CtkOrientable *o = l->data; |
48 | ctk_orientable_set_orientation (o, 1 - ctk_orientable_get_orientation (o)); |
49 | } |
50 | } |
51 | |
52 | static void |
53 | trough (CtkToggleButton *button) |
54 | { |
55 | GSList *l; |
56 | gboolean value; |
57 | |
58 | value = ctk_toggle_button_get_active (button); |
59 | |
60 | for (l = scales; l; l = l->next) |
61 | { |
62 | CtkRange *range = l->data; |
63 | ctk_range_set_range (range, 0., value ? 100.0 : 0.); |
64 | } |
65 | } |
66 | |
67 | gdouble marks[3] = { 0.0, 50.0, 100.0 }; |
68 | gdouble extra_marks[2] = { 20.0, 40.0 }; |
69 | |
70 | static void |
71 | extra (CtkToggleButton *button) |
72 | { |
73 | gboolean value; |
74 | |
75 | value = ctk_toggle_button_get_active (button); |
76 | |
77 | if (value) |
78 | { |
79 | ctk_scale_add_mark (CTK_SCALE (extra_scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extra_scale)), ((ctk_scale_get_type ())))))), extra_marks[0], CTK_POS_TOP, NULL((void*)0)); |
80 | ctk_scale_add_mark (CTK_SCALE (extra_scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extra_scale)), ((ctk_scale_get_type ())))))), extra_marks[1], CTK_POS_TOP, NULL((void*)0)); |
81 | } |
82 | else |
83 | { |
84 | ctk_scale_clear_marks (CTK_SCALE (extra_scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extra_scale)), ((ctk_scale_get_type ()))))))); |
85 | ctk_scale_add_mark (CTK_SCALE (extra_scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extra_scale)), ((ctk_scale_get_type ())))))), marks[0], CTK_POS_BOTTOM, NULL((void*)0)); |
86 | ctk_scale_add_mark (CTK_SCALE (extra_scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extra_scale)), ((ctk_scale_get_type ())))))), marks[1], CTK_POS_BOTTOM, NULL((void*)0)); |
87 | ctk_scale_add_mark (CTK_SCALE (extra_scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extra_scale)), ((ctk_scale_get_type ())))))), marks[2], CTK_POS_BOTTOM, NULL((void*)0)); |
88 | } |
89 | } |
90 | |
91 | int main (int argc, char *argv[]) |
92 | { |
93 | CtkWidget *window; |
94 | CtkWidget *box; |
95 | CtkWidget *box1; |
96 | CtkWidget *box2; |
97 | CtkWidget *button; |
98 | CtkWidget *frame; |
99 | CtkWidget *scale; |
100 | const gchar *labels[3] = { |
101 | "<small>Left</small>", |
102 | "<small>Middle</small>", |
103 | "<small>Right</small>" |
104 | }; |
105 | |
106 | gdouble bath_marks[4] = { 0.0, 33.3, 66.6, 100.0 }; |
107 | const gchar *bath_labels[4] = { |
108 | "<span color='blue' size='small'>Cold</span>", |
109 | "<span size='small'>Baby bath</span>", |
110 | "<span size='small'>Hot tub</span>", |
111 | "<span color='Red' size='small'>Hot</span>" |
112 | }; |
113 | |
114 | gdouble pos_marks[4] = { 0.0, 33.3, 66.6, 100.0 }; |
115 | const gchar *pos_labels[4] = { "Left", "Right", "Top", "Bottom" }; |
116 | |
117 | ctk_init (&argc, &argv); |
118 | |
119 | window = ctk_window_new (CTK_WINDOW_TOPLEVEL); |
120 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), "Ranges with marks"); |
121 | box1 = ctk_box_new (CTK_ORIENTATION_VERTICAL, 5); |
122 | flipbox = box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 5); |
123 | ctk_widget_set_hexpand (flipbox, TRUE(!(0))); |
124 | ctk_widget_set_vexpand (flipbox, TRUE(!(0))); |
125 | ctk_container_add (CTK_CONTAINER (box1)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box1)), ((ctk_container_get_type ())))))), box); |
126 | ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), box1); |
127 | |
128 | frame = ctk_frame_new ("No marks"); |
129 | scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
130 | scales = g_slist_prepend (scales, scale); |
131 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
132 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
133 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
134 | |
135 | frame = ctk_frame_new ("With fill level"); |
136 | scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
137 | scales = g_slist_prepend (scales, scale); |
138 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
139 | ctk_range_set_show_fill_level (CTK_RANGE (scale)((((CtkRange*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_range_get_type ())))))), TRUE(!(0))); |
140 | ctk_range_set_fill_level (CTK_RANGE (scale)((((CtkRange*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_range_get_type ())))))), 50); |
141 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
142 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
143 | |
144 | frame = ctk_frame_new ("Simple marks"); |
145 | extra_scale = scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
146 | scales = g_slist_prepend (scales, scale); |
147 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
148 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[0], CTK_POS_BOTTOM, NULL((void*)0)); |
149 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[1], CTK_POS_BOTTOM, NULL((void*)0)); |
150 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[2], CTK_POS_BOTTOM, NULL((void*)0)); |
151 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
152 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
153 | |
154 | frame = ctk_frame_new ("Simple marks up"); |
155 | scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
156 | scales = g_slist_prepend (scales, scale); |
157 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
158 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[0], CTK_POS_TOP, NULL((void*)0)); |
159 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[1], CTK_POS_TOP, NULL((void*)0)); |
160 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[2], CTK_POS_TOP, NULL((void*)0)); |
161 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
162 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
163 | |
164 | frame = ctk_frame_new ("Labeled marks"); |
165 | box2 = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); |
Value stored to 'box2' is never read | |
166 | |
167 | scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
168 | scales = g_slist_prepend (scales, scale); |
169 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
170 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[0], CTK_POS_BOTTOM, labels[0]); |
171 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[1], CTK_POS_BOTTOM, labels[1]); |
172 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[2], CTK_POS_BOTTOM, labels[2]); |
173 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
174 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
175 | |
176 | frame = ctk_frame_new ("Some labels"); |
177 | scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
178 | scales = g_slist_prepend (scales, scale); |
179 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
180 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[0], CTK_POS_TOP, labels[0]); |
181 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[1], CTK_POS_TOP, NULL((void*)0)); |
182 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), marks[2], CTK_POS_TOP, labels[2]); |
183 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
184 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
185 | |
186 | frame = ctk_frame_new ("Above and below"); |
187 | scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
188 | scales = g_slist_prepend (scales, scale); |
189 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
190 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), bath_marks[0], CTK_POS_TOP, bath_labels[0]); |
191 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), bath_marks[1], CTK_POS_BOTTOM, bath_labels[1]); |
192 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), bath_marks[2], CTK_POS_BOTTOM, bath_labels[2]); |
193 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), bath_marks[3], CTK_POS_TOP, bath_labels[3]); |
194 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
195 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
196 | |
197 | frame = ctk_frame_new ("Positions"); |
198 | scale = ctk_scale_new_with_range (CTK_ORIENTATION_HORIZONTAL, 0, 100, 1); |
199 | scales = g_slist_prepend (scales, scale); |
200 | ctk_scale_set_draw_value (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), FALSE(0)); |
201 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), pos_marks[0], CTK_POS_LEFT, pos_labels[0]); |
202 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), pos_marks[1], CTK_POS_RIGHT, pos_labels[1]); |
203 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), pos_marks[2], CTK_POS_TOP, pos_labels[2]); |
204 | ctk_scale_add_mark (CTK_SCALE (scale)((((CtkScale*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scale)), ((ctk_scale_get_type ())))))), pos_marks[3], CTK_POS_BOTTOM, pos_labels[3]); |
205 | ctk_container_add (CTK_CONTAINER (frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_container_get_type ())))))), scale); |
206 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), frame, FALSE(0), FALSE(0), 0); |
207 | |
208 | box2 = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); |
209 | ctk_container_add (CTK_CONTAINER (box1)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box1)), ((ctk_container_get_type ())))))), box2); |
210 | button = ctk_button_new_with_label ("Flip"); |
211 | g_signal_connect (button, "clicked", G_CALLBACK (flip), NULL)g_signal_connect_data ((button), ("clicked"), (((GCallback) ( flip))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
212 | ctk_container_add (CTK_CONTAINER (box2)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box2)), ((ctk_container_get_type ())))))), button); |
213 | |
214 | button = ctk_button_new_with_label ("Invert"); |
215 | g_signal_connect (button, "clicked", G_CALLBACK (invert), NULL)g_signal_connect_data ((button), ("clicked"), (((GCallback) ( invert))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
216 | ctk_container_add (CTK_CONTAINER (box2)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box2)), ((ctk_container_get_type ())))))), button); |
217 | |
218 | button = ctk_toggle_button_new_with_label ("Trough"); |
219 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_toggle_button_get_type ())))))), TRUE(!(0))); |
220 | g_signal_connect (button, "toggled", G_CALLBACK (trough), NULL)g_signal_connect_data ((button), ("toggled"), (((GCallback) ( trough))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
221 | ctk_container_add (CTK_CONTAINER (box2)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box2)), ((ctk_container_get_type ())))))), button); |
222 | ctk_widget_show_all (window); |
223 | |
224 | button = ctk_toggle_button_new_with_label ("Extra"); |
225 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_toggle_button_get_type ())))))), FALSE(0)); |
226 | g_signal_connect (button, "toggled", G_CALLBACK (extra), NULL)g_signal_connect_data ((button), ("toggled"), (((GCallback) ( extra))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
227 | ctk_container_add (CTK_CONTAINER (box2)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box2)), ((ctk_container_get_type ())))))), button); |
228 | ctk_widget_show_all (window); |
229 | |
230 | ctk_main (); |
231 | |
232 | return 0; |
233 | } |
234 | |
235 |