1#include <gtk/gtk.h>
2
3int
4main (int argc,
5 char ** argv)
6{
7 GtkWidget *window, *revealer, *box, *widget, *entry;
8
9 gtk_init ();
10
11 window = gtk_window_new ();
12 gtk_widget_set_size_request (widget: window, width: 300, height: 300);
13
14 box = gtk_grid_new ();
15 gtk_window_set_child (GTK_WINDOW (window), child: box);
16
17 widget = gtk_label_new (str: "Some filler text to avoid\nresizing of the window");
18 gtk_widget_set_margin_top (widget, margin: 10);
19 gtk_widget_set_margin_bottom (widget, margin: 10);
20 gtk_widget_set_margin_start (widget, margin: 10);
21 gtk_widget_set_margin_end (widget, margin: 10);
22 gtk_grid_attach (GTK_GRID (box), child: widget, column: 1, row: 1, width: 1, height: 1);
23
24 widget = gtk_label_new (str: "Some filler text to avoid\nresizing of the window");
25 gtk_widget_set_margin_top (widget, margin: 10);
26 gtk_widget_set_margin_bottom (widget, margin: 10);
27 gtk_widget_set_margin_start (widget, margin: 10);
28 gtk_widget_set_margin_end (widget, margin: 10);
29 gtk_grid_attach (GTK_GRID (box), child: widget, column: 4, row: 4, width: 1, height: 1);
30
31 widget = gtk_toggle_button_new_with_label (label: "None");
32 gtk_grid_attach (GTK_GRID (box), child: widget, column: 0, row: 0, width: 1, height: 1);
33 revealer = gtk_revealer_new ();
34 gtk_widget_set_halign (widget: revealer, align: GTK_ALIGN_START);
35 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_START);
36 entry = gtk_entry_new ();
37 gtk_editable_set_text (GTK_EDITABLE (entry), text: "00000");
38 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
39 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
40 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_NONE);
41 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
42 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 1, row: 0, width: 1, height: 1);
43
44 widget = gtk_toggle_button_new_with_label (label: "Fade");
45 gtk_grid_attach (GTK_GRID (box), child: widget, column: 5, row: 5, width: 1, height: 1);
46 revealer = gtk_revealer_new ();
47 gtk_widget_set_halign (widget: revealer, align: GTK_ALIGN_END);
48 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_END);
49 entry = gtk_entry_new ();
50 gtk_editable_set_text (GTK_EDITABLE (entry), text: "00000");
51 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
52 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
53 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
54 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
55 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 4, row: 5, width: 1, height: 1);
56
57 widget = gtk_toggle_button_new_with_label (label: "Slide");
58 gtk_grid_attach (GTK_GRID (box), child: widget, column: 0, row: 2, width: 1, height: 1);
59 revealer = gtk_revealer_new ();
60 gtk_widget_set_hexpand (widget: revealer, TRUE);
61 gtk_widget_set_halign (widget: revealer, align: GTK_ALIGN_START);
62 entry = gtk_entry_new ();
63 gtk_editable_set_text (GTK_EDITABLE (entry), text: "12345");
64 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
65 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
66 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
67 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
68 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 1, row: 2, width: 1, height: 1);
69
70 widget = gtk_toggle_button_new_with_label (label: "Swing");
71 gtk_widget_set_valign (widget, align: GTK_ALIGN_START);
72 gtk_grid_attach (GTK_GRID (box), child: widget, column: 0, row: 3, width: 1, height: 1);
73 revealer = gtk_revealer_new ();
74 gtk_widget_set_hexpand (widget: revealer, TRUE);
75 gtk_widget_set_halign (widget: revealer, align: GTK_ALIGN_START);
76 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_START);
77 entry = gtk_entry_new ();
78 gtk_editable_set_text (GTK_EDITABLE (entry), text: "12345");
79 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
80 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
81 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT);
82 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
83 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 1, row: 3, width: 1, height: 1);
84
85 widget = gtk_toggle_button_new_with_label (label: "Slide");
86 gtk_grid_attach (GTK_GRID (box), child: widget, column: 2, row: 0, width: 1, height: 1);
87 revealer = gtk_revealer_new ();
88 gtk_widget_set_vexpand (widget: revealer, TRUE);
89 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_START);
90 entry = gtk_entry_new ();
91 gtk_editable_set_text (GTK_EDITABLE (entry), text: "23456");
92 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
93 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
94 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
95 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
96 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 2, row: 1, width: 1, height: 1);
97
98 widget = gtk_toggle_button_new_with_label (label: "Swing");
99 gtk_grid_attach (GTK_GRID (box), child: widget, column: 3, row: 0, width: 1, height: 1);
100 revealer = gtk_revealer_new ();
101 gtk_widget_set_vexpand (widget: revealer, TRUE);
102 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_START);
103 entry = gtk_entry_new ();
104 gtk_editable_set_text (GTK_EDITABLE (entry), text: "23456");
105 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
106 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
107 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SWING_DOWN);
108 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
109 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 3, row: 1, width: 1, height: 1);
110
111 widget = gtk_toggle_button_new_with_label (label: "Slide");
112 gtk_grid_attach (GTK_GRID (box), child: widget, column: 5, row: 2, width: 1, height: 1);
113 revealer = gtk_revealer_new ();
114 gtk_widget_set_hexpand (widget: revealer, TRUE);
115 gtk_widget_set_halign (widget: revealer, align: GTK_ALIGN_END);
116 entry = gtk_entry_new ();
117 gtk_editable_set_text (GTK_EDITABLE (entry), text: "34567");
118 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
119 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
120 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
121 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
122 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 4, row: 2, width: 1, height: 1);
123
124 widget = gtk_toggle_button_new_with_label (label: "Swing");
125 gtk_widget_set_valign (widget, align: GTK_ALIGN_START);
126 gtk_grid_attach (GTK_GRID (box), child: widget, column: 5, row: 3, width: 1, height: 1);
127 revealer = gtk_revealer_new ();
128 gtk_widget_set_hexpand (widget: revealer, TRUE);
129 gtk_widget_set_halign (widget: revealer, align: GTK_ALIGN_END);
130 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_START);
131 entry = gtk_entry_new ();
132 gtk_editable_set_text (GTK_EDITABLE (entry), text: "34567");
133 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
134 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
135 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT);
136 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
137 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 4, row: 3, width: 1, height: 1);
138
139 widget = gtk_toggle_button_new_with_label (label: "Slide");
140 gtk_grid_attach (GTK_GRID (box), child: widget, column: 2, row: 5, width: 1, height: 1);
141 revealer = gtk_revealer_new ();
142 gtk_widget_set_vexpand (widget: revealer, TRUE);
143 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_END);
144 entry = gtk_entry_new ();
145 gtk_editable_set_text (GTK_EDITABLE (entry), text: "45678");
146 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
147 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
148 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
149 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
150 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 2, row: 4, width: 1, height: 1);
151
152 widget = gtk_toggle_button_new_with_label (label: "Swing");
153 gtk_grid_attach (GTK_GRID (box), child: widget, column: 3, row: 5, width: 1, height: 1);
154 revealer = gtk_revealer_new ();
155 gtk_widget_set_vexpand (widget: revealer, TRUE);
156 gtk_widget_set_valign (widget: revealer, align: GTK_ALIGN_END);
157 entry = gtk_entry_new ();
158 gtk_editable_set_text (GTK_EDITABLE (entry), text: "45678");
159 gtk_revealer_set_child (GTK_REVEALER (revealer), child: entry);
160 g_object_bind_property (source: widget, source_property: "active", target: revealer, target_property: "reveal-child", flags: 0);
161 gtk_revealer_set_transition_type (GTK_REVEALER (revealer), transition: GTK_REVEALER_TRANSITION_TYPE_SWING_UP);
162 gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), duration: 2000);
163 gtk_grid_attach (GTK_GRID (box), child: revealer, column: 3, row: 4, width: 1, height: 1);
164
165 gtk_widget_show (widget: window);
166 while (TRUE)
167 g_main_context_iteration (NULL, TRUE);
168
169 gtk_window_destroy (GTK_WINDOW (window));
170
171 return 0;
172}
173

source code of gtk/tests/testrevealer.c