2 * Create the main window.
9 #include "mainwindow.h"
13 static GtkWidget
*edit
;
14 static GtkWidget
*set
;
15 static GtkWidget
*remove
;
17 static gint
list_sel_cb (GtkCList
*clist
,
20 GdkEventButton
*event
,
23 gtk_widget_set_sensitive(edit
, TRUE
);
24 gtk_widget_set_sensitive(set
, TRUE
);
25 gtk_widget_set_sensitive(remove
, TRUE
);
30 gint
list_unsel_cb (GtkCList
*clist
,
33 GdkEventButton
*event
,
36 gtk_widget_set_sensitive(edit
, FALSE
);
37 gtk_widget_set_sensitive(set
, FALSE
);
38 gtk_widget_set_sensitive(remove
, FALSE
);
43 void create_mainwindow() {
45 GtkWidget
*buttons_hbox
;
47 GtkWidget
*right_vbox
;
49 GtkWidget
*scrolled_window
;
56 gchar
*clist_titles
[4] = {" Status ", " Hour ", " Day ", " Message "};
59 /*** FENÊTRE PRINCIPALE ***/
60 application
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
61 gtk_window_set_title(GTK_WINDOW(application
), PACKAGE
" Config");
62 /*-- Connexion aux signaux --*/
63 gtk_signal_connect(GTK_OBJECT(application
), "delete_event",
64 GTK_SIGNAL_FUNC(quit_app
), NULL
);
65 gtk_signal_connect(GTK_OBJECT(application
), "destroy",
66 GTK_SIGNAL_FUNC(quit_app
), "WM destroy");
67 /*-- Taille de la fenêtre --*/
68 gtk_widget_set_usize(GTK_WIDGET(application
), WIN_WIDTH
, WIN_HEIGHT
);
69 gtk_widget_realize(application
);
71 /*** Zone principale de placement des widgets***/
72 main_vbox
= gtk_vbox_new(FALSE
, 1);
73 gtk_container_border_width(GTK_CONTAINER(main_vbox
), 1);
74 gtk_container_add(GTK_CONTAINER(application
), main_vbox
);
75 gtk_widget_show(main_vbox
);
79 /*** WIDGETS DE DONNÉES ***/
80 notebook
= gtk_notebook_new();
82 /*-- Zones des données simples --*/
83 left_vbox
= gtk_vbox_new(FALSE
, 1);
87 frame
= gtk_frame_new(" Startup ");
88 gtk_frame_set_shadow_type(GTK_FRAME(frame
), GTK_SHADOW_ETCHED_IN
);
89 gtk_box_pack_start(GTK_BOX(left_vbox
), frame
, FALSE
, TRUE
, 1);
90 gtk_widget_show(frame
);
92 hbox
= gtk_hbox_new(FALSE
, 1);
93 gtk_container_add(GTK_CONTAINER(frame
), hbox
);
94 gtk_widget_show(hbox
);
96 vbox
= gtk_vbox_new(FALSE
, 1);
97 gtk_box_pack_start(GTK_BOX(hbox
), vbox
, TRUE
, TRUE
, 1);
98 gtk_widget_show(vbox
);
100 wid_backlight
= gtk_check_button_new_with_label("Back (or LED) light");
101 gtk_box_pack_start(GTK_BOX(vbox
), wid_backlight
, FALSE
, TRUE
, 1);
102 gtk_widget_show(wid_backlight
);
104 wid_blink
= gtk_check_button_new_with_label("Blink");
105 gtk_box_pack_start(GTK_BOX(vbox
), wid_blink
, FALSE
, TRUE
, 1);
106 gtk_widget_show(wid_blink
);
108 wid_h12
= gtk_check_button_new_with_label("12h clock mode");
109 gtk_box_pack_start(GTK_BOX(vbox
), wid_h12
, FALSE
, TRUE
, 1);
110 gtk_widget_show(wid_h12
);
112 vbox
= gtk_vbox_new(FALSE
, 1);
113 gtk_box_pack_start(GTK_BOX(hbox
), vbox
, TRUE
, TRUE
, 1);
114 gtk_widget_show(vbox
);
116 wid_locale
= gtk_check_button_new_with_label("Use current locale");
117 gtk_box_pack_start(GTK_BOX(vbox
), wid_locale
, FALSE
, TRUE
, 1);
118 gtk_widget_show(wid_locale
);
120 wid_showcal
= gtk_check_button_new_with_label("Show calendar");
121 gtk_box_pack_start(GTK_BOX(vbox
), wid_showcal
, FALSE
, TRUE
, 1);
122 gtk_widget_show(wid_showcal
);
124 wid_calalrms
= gtk_check_button_new_with_label("Load calendar alarms");
125 gtk_box_pack_start(GTK_BOX(vbox
), wid_calalrms
, FALSE
, TRUE
, 1);
126 gtk_widget_show(wid_calalrms
);
128 vbox
= gtk_vbox_new(FALSE
, 1);
129 gtk_box_pack_start(GTK_BOX(hbox
), vbox
, TRUE
, TRUE
, 1);
130 gtk_widget_show(vbox
);
132 wid_clk
= gtk_radio_button_new_with_label(NULL
, "Normal clock");
133 gtk_box_pack_start(GTK_BOX(vbox
), wid_clk
, FALSE
, TRUE
, 1);
134 gtk_widget_show(wid_clk
);
136 wid_itm
= gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(wid_clk
), "Internet time");
137 gtk_box_pack_start(GTK_BOX(vbox
), wid_itm
, FALSE
, TRUE
, 1);
138 gtk_widget_show(wid_itm
);
140 wid_bin
= gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(wid_clk
), "Binary clock");
141 gtk_box_pack_start(GTK_BOX(vbox
), wid_bin
, FALSE
, TRUE
, 1);
142 gtk_widget_show(wid_bin
);
145 frame
= gtk_frame_new(" Look ");
146 gtk_frame_set_shadow_type(GTK_FRAME(frame
), GTK_SHADOW_ETCHED_IN
);
147 gtk_box_pack_start(GTK_BOX(left_vbox
), frame
, FALSE
, TRUE
, 1);
148 gtk_widget_show(frame
);
150 table
= gtk_table_new(2, 3, FALSE
);
151 gtk_container_set_border_width(GTK_CONTAINER(table
), 2);
152 gtk_container_add(GTK_CONTAINER(frame
), table
);
153 gtk_widget_show(table
);
155 label
= gtk_label_new("Style directory : ");
156 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
157 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 0, 1, 0, 1);
158 gtk_widget_show(label
);
160 wid_styledir
= gtk_entry_new();
161 gtk_table_attach_defaults(GTK_TABLE(table
), wid_styledir
, 1, 2, 0, 1);
162 gtk_widget_show(wid_styledir
);
164 label
= gtk_label_new("Style : ");
165 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
166 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 0, 1, 1, 2);
167 gtk_widget_show(label
);
169 wid_stylename
= gtk_entry_new();
170 gtk_table_attach_defaults(GTK_TABLE(table
), wid_stylename
, 1, 2, 1, 2);
171 gtk_widget_show(wid_stylename
);
173 label
= gtk_label_new("Color : ");
174 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
175 gtk_table_attach_defaults(GTK_TABLE(table
), label
, 0, 1, 2, 3);
176 gtk_widget_show(label
);
178 wid_color
= gtk_entry_new();
179 gtk_table_attach_defaults(GTK_TABLE(table
), wid_color
, 1, 2, 2, 3);
180 gtk_widget_show(wid_color
);
183 frame
= gtk_frame_new(" Commands ");
184 gtk_frame_set_shadow_type(GTK_FRAME(frame
), GTK_SHADOW_ETCHED_IN
);
185 gtk_box_pack_start(GTK_BOX(left_vbox
), frame
, FALSE
, FALSE
, 1);
186 gtk_widget_show(frame
);
188 vbox
= gtk_vbox_new(FALSE
, 1);
189 gtk_container_add(GTK_CONTAINER(frame
), vbox
);
190 gtk_widget_show(vbox
);
192 hbox
= gtk_hbox_new(FALSE
, 1);
193 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, TRUE
, 1);
194 gtk_widget_show(hbox
);
196 label
= gtk_label_new("Command : ");
197 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
198 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, TRUE
, 1);
199 gtk_widget_show(label
);
201 wid_command
= gtk_entry_new();
202 gtk_box_pack_start(GTK_BOX(hbox
), wid_command
, TRUE
, TRUE
, 1);
203 gtk_widget_show(wid_command
);
205 hbox
= gtk_hbox_new(FALSE
, 1);
206 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, TRUE
, 1);
207 gtk_widget_show(hbox
);
209 label
= gtk_label_new("Message command : ");
210 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
211 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, TRUE
, 1);
212 gtk_widget_show(label
);
214 wid_msgcmd
= gtk_entry_new();
215 gtk_box_pack_start(GTK_BOX(hbox
), wid_msgcmd
, TRUE
, TRUE
, 1);
216 gtk_widget_show(wid_msgcmd
);
219 label
= gtk_label_new(" Misc options ");
220 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
221 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), left_vbox
, label
);
222 gtk_widget_show(label
);
223 gtk_widget_show(left_vbox
);
226 /*-- Liste des alarmes --*/
227 right_vbox
= gtk_vbox_new(FALSE
, 1);
230 scrolled_window
= gtk_scrolled_window_new(NULL
, NULL
);
231 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window
),
232 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
234 alarmlist
= gtk_clist_new_with_titles(4, clist_titles
);
236 gtk_signal_connect(GTK_OBJECT(alarmlist
), "select-row",
237 GTK_SIGNAL_FUNC(list_sel_cb
), NULL
);
238 gtk_signal_connect(GTK_OBJECT(alarmlist
), "unselect-row",
239 GTK_SIGNAL_FUNC(list_unsel_cb
), NULL
);
240 gtk_container_add(GTK_CONTAINER(scrolled_window
), alarmlist
);
241 gtk_clist_set_auto_sort(GTK_CLIST(alarmlist
), FALSE
);
242 gtk_widget_show(alarmlist
);
244 gtk_box_pack_start(GTK_BOX(right_vbox
), scrolled_window
, TRUE
, TRUE
, 1);
245 gtk_widget_show(scrolled_window
);
248 frame
= gtk_frame_new(NULL
);
249 gtk_frame_set_shadow_type(GTK_FRAME(frame
), GTK_SHADOW_ETCHED_IN
);
250 gtk_box_pack_start(GTK_BOX(right_vbox
), frame
, FALSE
, TRUE
, 1);
251 gtk_widget_show(frame
);
253 table
= gtk_table_new(2, 2, FALSE
);
254 gtk_container_set_border_width(GTK_CONTAINER(table
), 2);
255 gtk_container_add(GTK_CONTAINER(frame
), table
);
256 gtk_widget_show(table
);
258 bouton
= gtk_button_new_with_label(" Add alarm ");
259 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
260 GTK_SIGNAL_FUNC(add_alarm
), NULL
);
261 gtk_table_attach_defaults(GTK_TABLE(table
), bouton
, 0, 1, 0, 1);
262 gtk_widget_show(bouton
);
264 bouton
= gtk_button_new_with_label(" Edit entry ");
265 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
266 GTK_SIGNAL_FUNC(edit_entry
), NULL
);
267 gtk_table_attach_defaults(GTK_TABLE(table
), bouton
, 0, 1, 1, 2);
268 gtk_widget_set_sensitive(bouton
, FALSE
);
269 gtk_widget_show(bouton
);
272 bouton
= gtk_button_new_with_label(" Switch On/Off ");
273 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
274 GTK_SIGNAL_FUNC(switch_onoff
), NULL
);
275 gtk_table_attach_defaults(GTK_TABLE(table
), bouton
, 1, 2, 1, 2);
276 gtk_widget_set_sensitive(bouton
, FALSE
);
277 gtk_widget_show(bouton
);
280 bouton
= gtk_button_new_with_label(" Remove alarm ");
281 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
282 GTK_SIGNAL_FUNC(remove_alarm
), NULL
);
283 gtk_table_attach_defaults(GTK_TABLE(table
), bouton
, 1, 2, 0, 1);
284 gtk_widget_set_sensitive(bouton
, FALSE
);
285 gtk_widget_show(bouton
);
289 label
= gtk_label_new(" Alarms ");
290 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
291 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), right_vbox
, label
);
292 gtk_widget_show(label
);
293 gtk_widget_show(right_vbox
);
296 gtk_box_pack_start(GTK_BOX(main_vbox
), notebook
, TRUE
, TRUE
, 1);
297 gtk_widget_show(notebook
);
301 /*** BOUTONS DE SAUVEGARDE ET ANNULATION ***/
302 buttons_hbox
= gtk_hbox_new(FALSE
, 1);
303 gtk_box_pack_start(GTK_BOX(main_vbox
), buttons_hbox
, FALSE
, TRUE
, 1);
304 gtk_widget_show(buttons_hbox
);
307 bouton
= gtk_button_new_with_label(" Save ");
308 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
309 GTK_SIGNAL_FUNC(save_datas
), NULL
);
310 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
311 GTK_SIGNAL_FUNC(quit_app
), NULL
);
312 gtk_box_pack_start(GTK_BOX(buttons_hbox
), bouton
, TRUE
, TRUE
, 0);
313 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
314 gtk_widget_grab_default(GTK_WIDGET(bouton
));
315 gtk_widget_draw_default(GTK_WIDGET(bouton
));
316 gtk_widget_show(bouton
);
318 bouton
= gtk_button_new_with_label(" Cancel ");
319 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
320 GTK_SIGNAL_FUNC(quit_app
), NULL
);
321 gtk_box_pack_start(GTK_BOX(buttons_hbox
), bouton
, TRUE
, TRUE
, 0);
322 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
323 gtk_widget_show(bouton
);
327 /*** AFFICHAGE DE LA FENÊTRE ***/
328 gtk_widget_show(application
);