3 #include <eel/eel-text-caption.h>
4 #include <libnautilus-private/nautilus-global-preferences.h>
7 text_caption_update (EelTextCaption
*text_caption
,
10 g_return_if_fail (EEL_IS_TEXT_CAPTION (text_caption
));
11 g_return_if_fail (name
!= NULL
);
13 g_print ("'%s' changed from '%d' to '%d'\n",
15 test_text_caption_get_text_as_int (text_caption
),
16 eel_preferences_get_integer (name
));
18 test_text_caption_set_text_for_int_preferences (text_caption
, name
);
22 green_changed_callback (gpointer callback_data
)
24 text_caption_update (EEL_TEXT_CAPTION (callback_data
), "green");
28 yellow_changed_callback (gpointer callback_data
)
30 text_caption_update (EEL_TEXT_CAPTION (callback_data
), "yellow");
34 red_changed_callback (gpointer callback_data
)
36 text_caption_update (EEL_TEXT_CAPTION (callback_data
), "red");
40 apple_changed_callback (gpointer callback_data
)
42 text_caption_update (EEL_TEXT_CAPTION (callback_data
), "fruits/apple");
46 orange_changed_callback (gpointer callback_data
)
48 text_caption_update (EEL_TEXT_CAPTION (callback_data
), "fruits/orange");
52 pear_changed_callback (gpointer callback_data
)
54 text_caption_update (EEL_TEXT_CAPTION (callback_data
), "fruits/pear");
58 entry_new (const char *name
,
59 GtkWidget
**caption_out
,
60 GtkWidget
**default_caption_out
)
64 g_return_val_if_fail (name
!= NULL
, NULL
);
65 g_return_val_if_fail (caption_out
!= NULL
, NULL
);
66 g_return_val_if_fail (default_caption_out
!= NULL
, NULL
);
68 hbox
= gtk_hbox_new (TRUE
, 2);
70 *caption_out
= eel_text_caption_new ();
71 eel_text_caption_set_editable (EEL_TEXT_CAPTION (*caption_out
), FALSE
);
72 eel_caption_set_title_label (EEL_CAPTION (*caption_out
), name
);
74 *default_caption_out
= eel_text_caption_new ();
75 eel_text_caption_set_editable (EEL_TEXT_CAPTION (*default_caption_out
), FALSE
);
76 eel_caption_set_title_label (EEL_CAPTION (*default_caption_out
), "default:");
78 gtk_box_pack_start (GTK_BOX (hbox
), *caption_out
, FALSE
, FALSE
, 0);
79 gtk_box_pack_start (GTK_BOX (hbox
), *default_caption_out
, FALSE
, FALSE
, 0);
81 gtk_widget_show (*caption_out
);
82 gtk_widget_show (*default_caption_out
);
88 colors_frame_new (void)
90 GtkWidget
*green_caption
;
91 GtkWidget
*green_default_caption
;
92 GtkWidget
*green_hbox
;
94 GtkWidget
*yellow_caption
;
95 GtkWidget
*yellow_default_caption
;
96 GtkWidget
*yellow_hbox
;
98 GtkWidget
*red_caption
;
99 GtkWidget
*red_default_caption
;
105 vbox
= gtk_vbox_new (FALSE
, 2);
107 frame
= gtk_frame_new ("colors");
108 gtk_container_add (GTK_CONTAINER (frame
), vbox
);
110 green_hbox
= entry_new ("green", &green_caption
, &green_default_caption
);
111 yellow_hbox
= entry_new ("yellow", &yellow_caption
, &yellow_default_caption
);
112 red_hbox
= entry_new ("red", &red_caption
, &red_default_caption
);
114 test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (green_caption
), "green");
115 test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (yellow_caption
), "yellow");
116 test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (red_caption
), "red");
118 test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (green_default_caption
), "green");
119 test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (yellow_default_caption
), "yellow");
120 test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (red_default_caption
), "red");
122 eel_preferences_add_callback ("green", green_changed_callback
, green_caption
);
123 eel_preferences_add_callback ("yellow", yellow_changed_callback
, yellow_caption
);
124 eel_preferences_add_callback ("red", red_changed_callback
, red_caption
);
126 gtk_box_pack_start (GTK_BOX (vbox
), green_hbox
, TRUE
, TRUE
, 0);
127 gtk_box_pack_start (GTK_BOX (vbox
), yellow_hbox
, TRUE
, TRUE
, 0);
128 gtk_box_pack_start (GTK_BOX (vbox
), red_hbox
, TRUE
, TRUE
, 0);
130 gtk_widget_show_all (frame
);
136 fruits_frame_new (void)
138 GtkWidget
*apple_caption
;
139 GtkWidget
*apple_default_caption
;
140 GtkWidget
*apple_hbox
;
142 GtkWidget
*orange_caption
;
143 GtkWidget
*orange_default_caption
;
144 GtkWidget
*orange_hbox
;
146 GtkWidget
*pear_caption
;
147 GtkWidget
*pear_default_caption
;
148 GtkWidget
*pear_hbox
;
153 vbox
= gtk_vbox_new (FALSE
, 2);
155 frame
= gtk_frame_new ("fruits");
156 gtk_container_add (GTK_CONTAINER (frame
), vbox
);
158 apple_hbox
= entry_new ("fruits/apple", &apple_caption
, &apple_default_caption
);
159 orange_hbox
= entry_new ("fruits/orange", &orange_caption
, &orange_default_caption
);
160 pear_hbox
= entry_new ("fruits/pear", &pear_caption
, &pear_default_caption
);
162 test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (apple_caption
), "fruits/apple");
163 test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (orange_caption
), "fruits/orange");
164 test_text_caption_set_text_for_int_preferences (EEL_TEXT_CAPTION (pear_caption
), "fruits/pear");
166 test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (apple_default_caption
), "fruits/apple");
167 test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (orange_default_caption
), "fruits/orange");
168 test_text_caption_set_text_for_default_int_preferences (EEL_TEXT_CAPTION (pear_default_caption
), "fruits/pear");
170 eel_preferences_add_callback ("fruits/apple", apple_changed_callback
, apple_caption
);
171 eel_preferences_add_callback ("fruits/orange", orange_changed_callback
, orange_caption
);
172 eel_preferences_add_callback ("fruits/pear", pear_changed_callback
, pear_caption
);
174 gtk_box_pack_start (GTK_BOX (vbox
), apple_hbox
, TRUE
, TRUE
, 0);
175 gtk_box_pack_start (GTK_BOX (vbox
), orange_hbox
, TRUE
, TRUE
, 0);
176 gtk_box_pack_start (GTK_BOX (vbox
), pear_hbox
, TRUE
, TRUE
, 0);
178 gtk_widget_show_all (frame
);
184 main (int argc
, char *argv
[])
189 GtkWidget
*colors_frame
;
190 GtkWidget
*fruits_frame
;
192 test_init (&argc
, &argv
);
194 nautilus_global_preferences_init ();
196 window
= test_window_new (NULL
, 4);
197 test_window_set_title_with_pid (GTK_WINDOW (window
), "Preferences Display");
199 vbox
= gtk_vbox_new (FALSE
, 2);
200 gtk_container_add (GTK_CONTAINER (window
), vbox
);
202 colors_frame
= colors_frame_new ();
203 fruits_frame
= fruits_frame_new ();
205 gtk_box_pack_start (GTK_BOX (vbox
), colors_frame
, TRUE
, TRUE
, 0);
206 gtk_box_pack_start (GTK_BOX (vbox
), fruits_frame
, TRUE
, TRUE
, 0);
208 gtk_widget_show_all (window
);