1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
#include "test.h"
#include <eel/eel-text-caption.h>
#include <libnautilus-private/nautilus-global-preferences.h>
static void
text_caption_update (EelTextCaption *text_caption,
const char *name)
{
g_return_if_fail (EEL_IS_TEXT_CAPTION (text_caption));
g_return_if_fail (name != NULL);
g_print ("'%s' changed from '%d' to '%d'\n",
name,
test_text_caption_get_text_as_int (text_caption),
eel_preferences_get_integer (name));
test_text_caption_set_text_for_int_preferences (text_caption, name);
}
static void
green_changed_callback (gpointer callback_data)
{
text_caption_update (EEL_TEXT_CAPTION (callback_data), "green");
}
static void
yellow_changed_callback (gpointer callback_data)
{
text_caption_update (EEL_TEXT_CAPTION (callback_data), "yellow");
}
static void
red_changed_callback (gpointer callback_data)
{
text_caption_update (EEL_TEXT_CAPTION (callback_data), "red");
}
static void
apple_changed_callback (gpointer callback_data)
{
text_caption_update (EEL_TEXT_CAPTION (callback_data), "fruits/apple");
}
static void
orange_changed_callback (gpointer callback_data)
{
text_caption_update (EEL_TEXT_CAPTION (callback_data), "fruits/orange");
}
static void
pear_changed_callback (gpointer callback_data)
{
text_caption_update (EEL_TEXT_CAPTION (callback_data), "fruits/pear");
}
static GtkWidget *
entry_new (const char *name,
GtkWidget **caption_out,
GtkWidget **default_caption_out)
{
GtkWidget *hbox;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (caption_out != NULL, NULL);
g_return_val_if_fail (default_caption_out != NULL, NULL);
hbox = gtk_hbox_new (TRUE, 2);
*caption_out = eel_text_caption_new ();
eel_text_caption_set_editable (EEL_TEXT_CAPTION (*caption_out), FALSE);
eel_caption_set_title_label (EEL_CAPTION (*caption_out), name);
*default_caption_out = eel_text_caption_new ();
eel_text_caption_set_editable (EEL_TEXT_CAPTION (*default_caption_out), FALSE);
eel_caption_set_title_label (EEL_CAPTION (*default_caption_out), "default:");
gtk_box_pack_start (GTK_BOX (hbox), *caption_out, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), *default_caption_out, FALSE, FALSE, 0);
gtk_widget_show (*caption_out);
gtk_widget_show (*default_caption_out);
return hbox;
}
static GtkWidget *
colors_frame_new (void)
{
GtkWidget *green_caption;
GtkWidget *green_default_caption;
GtkWidget *green_hbox;
GtkWidget *yellow_caption;
GtkWidget *yellow_default_caption;
GtkWidget *yellow_hbox;
GtkWidget *red_caption;
GtkWidget *red_default_caption;
GtkWidget *red_hbox;
GtkWidget *frame;
GtkWidget *vbox;
vbox = gtk_vbox_new (FALSE, 2);
frame = gtk_frame_new ("colors");
gtk_container_add (GTK_CONTAINER (frame), vbox);
green_hbox = entry_new ("green", &green_caption, &green_default_caption);
yellow_hbox = entry_new ("yellow", &yellow_caption, &yellow_default_caption);
red_hbox = entry_new ("red", &red_caption, &red_default_caption);
test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (green_caption), "green");
test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (yellow_caption), "yellow");
test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (red_caption), "red");
test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (green_default_caption), "green");
test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (yellow_default_caption), "yellow");
test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (red_default_caption), "red");
eel_preferences_add_callback ("green", green_changed_callback, green_caption);
eel_preferences_add_callback ("yellow", yellow_changed_callback, yellow_caption);
eel_preferences_add_callback ("red", red_changed_callback, red_caption);
gtk_box_pack_start (GTK_BOX (vbox), green_hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), yellow_hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), red_hbox, TRUE, TRUE, 0);
gtk_widget_show_all (frame);
return frame;
}
static GtkWidget *
fruits_frame_new (void)
{
GtkWidget *apple_caption;
GtkWidget *apple_default_caption;
GtkWidget *apple_hbox;
GtkWidget *orange_caption;
GtkWidget *orange_default_caption;
GtkWidget *orange_hbox;
GtkWidget *pear_caption;
GtkWidget *pear_default_caption;
GtkWidget *pear_hbox;
GtkWidget *frame;
GtkWidget *vbox;
vbox = gtk_vbox_new (FALSE, 2);
frame = gtk_frame_new ("fruits");
gtk_container_add (GTK_CONTAINER (frame), vbox);
apple_hbox = entry_new ("fruits/apple", &apple_caption, &apple_default_caption);
orange_hbox = entry_new ("fruits/orange", &orange_caption, &orange_default_caption);
pear_hbox = entry_new ("fruits/pear", &pear_caption, &pear_default_caption);
test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (apple_caption), "fruits/apple");
test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (orange_caption), "fruits/orange");
test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (pear_caption), "fruits/pear");
test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (apple_default_caption), "fruits/apple");
test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (orange_default_caption), "fruits/orange");
test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (pear_default_caption), "fruits/pear");
eel_preferences_add_callback ("fruits/apple", apple_changed_callback, apple_caption);
eel_preferences_add_callback ("fruits/orange", orange_changed_callback, orange_caption);
eel_preferences_add_callback ("fruits/pear", pear_changed_callback, pear_caption);
gtk_box_pack_start (GTK_BOX (vbox), apple_hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), orange_hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), pear_hbox, TRUE, TRUE, 0);
gtk_widget_show_all (frame);
return frame;
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *colors_frame;
GtkWidget *fruits_frame;
test_init (&argc, &argv);
nautilus_global_preferences_init ();
window = test_window_new (NULL, 4);
test_window_set_title_with_pid (GTK_WINDOW (window), "Preferences Display");
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (window), vbox);
colors_frame = colors_frame_new ();
fruits_frame = fruits_frame_new ();
gtk_box_pack_start (GTK_BOX (vbox), colors_frame, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), fruits_frame, TRUE, TRUE, 0);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
|