1 
2 /*
3  * Osmo - a handy personal organizer
4  *
5  * Copyright (C) 2007 Tomasz Maka <pasp@users.sourceforge.net>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef _GUI_H
23 #define _GUI_H
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <unistd.h>
29 #include <fcntl.h>
30 #include <ctype.h>
31 #include <math.h>
32 
33 #include <gtk/gtk.h>
34 #include <gdk/gdk.h>
35 #include <glib/gstdio.h>
36 
37 #include <libxml/parser.h>
38 #include <libxml/xmlmemory.h>
39 #include <libxml/parserInternals.h>
40 
41 #include <config.h>
42 
43 #ifdef CONTACTS_ENABLED
44 #ifdef HAVE_LIBWEBKIT
45 #include <webkit2/webkit2.h>
46 #endif  /* LIBWEBKIT */
47 #endif  /* CONTACTS_ENABLED */
48 
49 #ifdef HAVE_LIBNOTIFY
50 #ifdef TASKS_ENABLED
51 #include <libnotify/notify.h>
52 #endif  /* TASKS_ENABLED */
53 #endif  /* HAVE_LIBNOTIFY */
54 
55 #ifdef HAVE_LIBGRINGOTTS
56 #include <libgringotts.h>
57 #endif  /* HAVE_LIBGRINGOTTS */
58 
59 #ifdef HAVE_GSPELL
60 #include <gspell/gspell.h>
61 #endif  /* HAVE_GSPELL */
62 
63 #define     TRANSLATION_DOMAIN      "osmo"
64 
65 #define     MAX_MONTHS              12
66 #define     MAX_WEEKS               6
67 #define     DAYS_PER_WEEK           7
68 #define     FULL_YEAR_COLS          37
69 #define     OPAQUE                  65535
70 #define     BUFFER_SIZE             2048
71 
72 #ifndef PATH_MAX
73 #define     PATH_MAX                1024
74 #endif
75 
76 #ifdef NOTES_ENABLED
77 #define     DEFAULT_NOTE_FONT       "Sans 12"
78 #endif  /* NOTES_ENABLED */
79 
80 enum notebook_page {
81     PAGE_CALENDAR = 0,
82 #ifdef TASKS_ENABLED
83     PAGE_TASKS,
84 #endif  /* TASKS_ENABLED */
85 #ifdef CONTACTS_ENABLED
86     PAGE_CONTACTS,
87 #endif  /* CONTACTS_ENABLED */
88 #ifdef NOTES_ENABLED
89     PAGE_NOTES,
90 #endif  /* NOTES_ENABLED */
91     NUMBER_OF_TABS
92 };
93 
94 #define MAX_VISIBLE_TASK_COLUMNS    6
95 
96 enum {                  /* tasks columns */
97     TA_COLUMN_DONE = 0,         /* V */
98     TA_COLUMN_TYPE,             /* V */
99     TA_COLUMN_DUE_DATE,         /* V */
100     TA_COLUMN_DUE_DATE_JULIAN,
101     TA_COLUMN_DUE_TIME,
102     TA_COLUMN_START_DATE_JULIAN,
103     TA_COLUMN_DONE_DATE_JULIAN,
104     TA_COLUMN_PRIORITY,         /* V */
105     TA_COLUMN_CATEGORY,         /* V */
106     TA_COLUMN_SUMMARY,          /* V */
107     TA_COLUMN_DESCRIPTION,
108     TA_COLUMN_COLOR,
109     TA_COLUMN_BOLD,
110 	TA_COLUMN_ACTIVE,
111 	TA_COLUMN_OFFLINE_IGNORE,
112 	TA_COLUMN_SOUND_ENABLE,
113 	TA_COLUMN_NDIALOG_ENABLE,
114 	TA_COLUMN_REPEAT,
115 	TA_COLUMN_REPEAT_DAY,
116 	TA_COLUMN_REPEAT_MONTH_INTERVAL,
117 	TA_COLUMN_REPEAT_DAY_INTERVAL,
118 	TA_COLUMN_REPEAT_START_DAY,
119 	TA_COLUMN_REPEAT_TIME_START,
120 	TA_COLUMN_REPEAT_TIME_END,
121 	TA_COLUMN_REPEAT_TIME_INTERVAL,
122 	TA_COLUMN_REPEAT_COUNTER,
123 	TA_COLUMN_ALARM_COMMAND,
124 	TA_COLUMN_WARNING_DAYS,
125 	TA_COLUMN_WARNING_TIME,
126 	TA_COLUMN_POSTPONE_TIME,
127 	TA_COLUMN_ID,
128     TASKS_NUM_COLUMNS
129 };
130 
131 #define MAX_VISIBLE_CONTACT_COLUMNS    3
132 
133 enum {                  /* contacts columns */
134     COLUMN_GROUP = 0    /* V */, COLUMN_FIRST_NAME  /* V */, COLUMN_LAST_NAME,  /* V */
135     COLUMN_SECOND_NAME, COLUMN_NICK_NAME, COLUMN_TAGS, COLUMN_BIRTH_DAY_DATE, COLUMN_NAME_DAY_DATE,
136 
137     COLUMN_HOME_ADDRESS, COLUMN_HOME_POST_CODE, COLUMN_HOME_CITY, COLUMN_HOME_STATE,
138     COLUMN_HOME_COUNTRY,
139 
140     COLUMN_WORK_ORGANIZATION, COLUMN_WORK_DEPARTMENT,
141 
142     COLUMN_WORK_ADDRESS, COLUMN_WORK_POST_CODE, COLUMN_WORK_CITY, COLUMN_WORK_STATE,
143     COLUMN_WORK_COUNTRY,
144 
145     COLUMN_WORK_FAX,
146 
147     COLUMN_HOME_PHONE_1, COLUMN_HOME_PHONE_2, COLUMN_HOME_PHONE_3, COLUMN_HOME_PHONE_4,
148     COLUMN_WORK_PHONE_1, COLUMN_WORK_PHONE_2, COLUMN_WORK_PHONE_3, COLUMN_WORK_PHONE_4,
149     COLUMN_CELL_PHONE_1, COLUMN_CELL_PHONE_2, COLUMN_CELL_PHONE_3, COLUMN_CELL_PHONE_4,
150     COLUMN_EMAIL_1, COLUMN_EMAIL_2, COLUMN_EMAIL_3, COLUMN_EMAIL_4,
151     COLUMN_WWW_1, COLUMN_WWW_2, COLUMN_WWW_3, COLUMN_WWW_4,
152 
153     COLUMN_IM_GG, COLUMN_IM_YAHOO, COLUMN_IM_MSN, COLUMN_IM_ICQ, COLUMN_IM_AOL,
154     COLUMN_IM_JABBER, COLUMN_IM_SKYPE, COLUMN_IM_TLEN, COLUMN_BLOG, COLUMN_PHOTO, COLUMN_INFO,
155     COLUMN_ID,
156     CONTACTS_NUM_COLUMNS
157 };
158 
159 #define MAX_VISIBLE_NOTE_COLUMNS    5
160 
161 enum {                  /* notes columns */
162     N_COLUMN_TYPE = 0,          /* V */
163     N_COLUMN_NAME,              /* V */
164     N_COLUMN_CATEGORY,          /* V */
165     N_COLUMN_LAST_CHANGES_DATE, /* V */
166     N_COLUMN_LAST_CHANGES_DATE_JULIAN,
167     N_COLUMN_LAST_CHANGES_TIME,
168     N_COLUMN_CREATE_DATE,       /* V */
169     N_COLUMN_CREATE_DATE_JULIAN,
170     N_COLUMN_CREATE_TIME,
171     N_COLUMN_REMEMBER_EDITOR_LINE,
172     N_COLUMN_EDITOR_LINE,
173     N_COLUMN_EDITOR_READONLY,
174     N_COLUMN_FILENAME,
175     N_COLUMN_FONTNAME,
176     N_COLUMN_ENCRYPTED,
177     NOTES_NUM_COLUMNS
178 };
179 
180 enum {
181     SELECTOR = 0,
182     EDITOR
183 };
184 
185 enum {
186     WRT_CALENDAR_NOTES = 1,
187     WRT_TASKS = 1 << 1,
188     WRT_CONTACTS = 1 << 2,
189     WRT_NOTES = 1 << 3
190 };
191 
192 enum {
193 	PORTRAIT = 0,
194 	LANDSCAPE
195 };
196 
197 typedef struct {
198 
199     GtkWidget *calendar;
200     gboolean dont_update;
201 
202     /* calendar toolbar */
203     GtkToolbar *calendar_toolbar;
204     GtkToolItem *notes_button;
205     GtkToolItem *quit_button;
206     GtkBox *vbox;
207     PangoFontDescription *fd_cal_font;
208 
209     /* date label */
210     GtkWidget *date_label;
211     PangoFontDescription *fd_day_name_font;
212 
213     /* current selected date */
214     GDate *date;
215 
216     /* used for 'jump to' button in date calculator */
217     guint julian_jumpto;
218 
219     /* day notes */
220     GSList *notes_list;
221     GtkWidget *notes_vbox;
222     GtkWidget *note_label;
223     GtkWidget *calendar_note_textview;
224 #ifdef HAVE_GSPELL
225     GspellTextView *calendar_note_spelltextview;
226 #endif /* HAVE_GSPELL */
227     GtkWidget *day_info_vbox;
228     GtkWidget *day_info_scrolledwindow;
229     GtkWidget *time_label;
230     GtkWidget *day_number_label;
231     GtkWidget *day_number_year_label;
232     GtkWidget *week_number_label;
233     GtkWidget *moon_icon;
234     GtkWidget *moon_phase_label;
235     GtkWidget *marked_days_label;
236     GtkWidget *weekend_days_label;
237     GtkWidget *day_category_label;
238     GtkWidget *day_desc_textview;
239     GtkTextBuffer *day_desc_text_buffer;
240     GtkTextIter day_desc_iter;
241     PangoFontDescription *fd_notes_font;
242 	GtkWidget *ta_bold_button;
243 	GtkWidget *ta_italic_button;
244 	GtkWidget *ta_underline_button;
245 	GtkWidget *ta_strikethrough_button;
246 	GtkWidget *ta_highlight_button;
247 
248     /* calendar popup menu */
249     GtkWidget *popup_menu;
250     GtkWidget *popup_menu_select_day_color_entry;
251 
252     /* month selector popup menu */
253     GtkWidget *month_selector_menu;
254 
255     /* auxilary calendars */
256     GtkWidget *aux_cal_expander;
257 	GtkWidget *aux_calendars_table;
258     GtkWidget *calendars_table;
259     GtkWidget *prev_month_label;
260     GtkWidget *next_month_label;
261     GtkWidget *calendar_prev;
262     GtkWidget *calendar_next;
263 
264     /* date selector buttons */
265     GtkWidget *prev_day_button;
266     GtkWidget *next_day_button;
267     GtkWidget *prev_month_button;
268     GtkWidget *next_month_button;
269 
270     /* day note toolbar */
271     GtkWidget *n_select_color_button;
272     GtkWidget *n_timeline_button;
273     GtkWidget *n_clear_button;
274     GtkWidget *n_close_button;
275 
276     /* day category color selector */
277     GtkWidget *select_bg_color_window;
278     GtkListStore *colors_category_store;
279     GtkTreeSelection *colors_category_select;
280 
281     /* full year calendar */
282 	gint last_selected_year;
283     GtkWidget *fullyear_window;
284     GtkWidget *fycal_table_1;
285     GtkWidget *fycal_table_2;
286     GtkWidget *fy_spinbutton;
287 	GtkWidget *fy_alternative_view_checkbutton;
288     GtkWidget *cyear_button;
289     GtkWidget *fy_calendars[MAX_MONTHS];
290     GtkWidget *calendar_buttons[MAX_MONTHS*(MAX_WEEKS*DAYS_PER_WEEK-(MAX_WEEKS-1))];
291 
292     /* jump to date */
293     GtkWidget *jumpto_window;
294     guint jday;
295     guint jmonth;
296     guint jyear;
297     GtkWidget *day_entry;
298     GtkWidget *month_entry;
299     GtkWidget *year_entry;
300 
301     /* insert timeline */
302     GtkWidget *insert_timeline_window;
303     GtkWidget *tl_start_h_spinbutton;
304     GtkWidget *tl_start_m_spinbutton;
305     GtkWidget *tl_end_h_spinbutton;
306     GtkWidget *tl_end_m_spinbutton;
307     GtkWidget *tl_step_spinbutton;
308     GtkWidget *insert_timeline_button;
309     GtkWidget *cancel_button;
310 
311     /* date calculator */
312     GtkWidget *window_date_calculator;
313     GtkWidget *spinbutton_start_year;
314     GtkWidget *spinbutton_start_month;
315     GtkWidget *spinbutton_start_day;
316     GtkWidget *spinbutton_start_hour;
317     GtkWidget *spinbutton_start_minute;
318     GtkWidget *spinbutton_start_second;
319     GtkWidget *spinbutton_end_year;
320     GtkWidget *spinbutton_end_month;
321     GtkWidget *spinbutton_end_day;
322     GtkWidget *spinbutton_end_hour;
323     GtkWidget *spinbutton_end_minute;
324     GtkWidget *spinbutton_end_second;
325     GtkWidget *label_result_1;
326     GtkWidget *label_result_1_2;
327     GtkWidget *label_result_2;
328     GtkWidget *label_result_3;
329     GtkWidget *spinbutton2_start_year;
330     GtkWidget *spinbutton2_start_month;
331     GtkWidget *spinbutton2_start_day;
332     GtkWidget *spinbutton2_start_hour;
333     GtkWidget *spinbutton2_start_minute;
334     GtkWidget *spinbutton2_start_second;
335     GtkWidget *spinbutton2_end_year;
336     GtkWidget *spinbutton2_end_month;
337     GtkWidget *spinbutton2_end_day;
338     GtkWidget *spinbutton2_end_week;
339     GtkWidget *spinbutton2_end_hour;
340     GtkWidget *spinbutton2_end_minute;
341     GtkWidget *spinbutton2_end_second;
342     GtkWidget *label2_result;
343     GtkWidget *radiobutton_add;
344 	GtkWidget *ignore_weekend_days_checkbutton;
345 	gboolean datecal_bio;
346 
347     /* iCalendar */
348     GtkWidget *events_window;
349     GtkWidget *ical_combobox;
350     GtkWidget *n_items_label;
351     GSList *ics_files_list;
352     GtkWidget *ical_events_list;
353     GtkTreeSelection *ical_events_list_selection;
354     GtkListStore *ical_events_list_store;
355 	GtkTreeModel *ical_events_sort;
356     GtkWidget *ical_export_window;
357     GtkWidget *output_file_entry;
358     GtkWidget *ical_export_vpaned;
359     GtkWidget *export_begin_period_calendar;
360     GtkWidget *export_end_period_calendar;
361     GtkWidget *export_day_note_textview;
362     GtkWidget *export_events_list_treeview;
363     GtkTreeSelection *export_events_list_selection;
364     GtkListStore *export_events_list_store;
365     GtkWidget *use_date_period_checkbutton;
366 
367     /* notes browser */
368     GtkWidget *day_notes_window;
369     GtkWidget *day_notes_list;
370     GtkTreeSelection *day_notes_list_selection;
371     GtkListStore *day_notes_list_store;
372     GtkWidget *past_notes_checkbutton;
373     GtkWidget *notes_month_spinbutton;
374     GtkWidget *notes_year_spinbutton;
375     GtkWidget *notes_filter_combobox;
376     GtkWidget *notes_search_entry;
377     GtkWidget *notes_search_checkbutton;
378 
379 	/* print */
380 	GtkWidget *window_print_options;
381 	GtkWidget *print_padding_spinbutton;
382 	GtkWidget *print_event_length_spinbutton;
383 	GtkWidget *print_tasks_checkbutton;
384 	GtkWidget *print_birthdays_checkbutton;
385 	GtkWidget *print_namedays_checkbutton;
386 	GtkWidget *print_day_notes_checkbutton;
387 	GtkWidget *print_ical_checkbutton;
388 	GtkWidget *print_month_name_font_entry;
389 	GtkWidget *print_day_name_font_entry;
390 	GtkWidget *print_day_num_font_entry;
391 	GtkWidget *print_event_font_entry;
392 	GtkWidget *print_portrait_radiobutton;
393 	GtkWidget *disable_background_checkbutton;
394 
395 #ifdef HAVE_LIBWEBKIT
396 	WebKitWebView *html_webkitview;
397 #endif  /* LIBWEBKIT */
398 
399 } CALENDAR;
400 
401 
402 #ifdef TASKS_ENABLED
403 typedef struct {
404 
405     /* tasks toolbar */
406     GtkToolItem *edit_button;
407     GtkToolItem *delete_button;
408     GtkToolItem *prev_button;
409     GtkToolItem *next_button;
410 #ifdef PRINTING_SUPPORT
411     GtkToolItem *print_button;
412 #endif
413 #ifdef HAVE_LIBICAL
414     GtkToolItem *export_button;
415 #endif
416     GtkToolItem *quit_button;
417     GtkBox *vbox;
418 
419     /* number of items label */
420     GtkWidget *n_items_label;
421 
422 	GtkWidget *tasks_find_entry;
423 	GtkWidget *tasks_find_clear_button;
424 
425     GtkWidget *desc_textview;
426     GtkWidget *tasks_desc_textview;
427     GtkWidget *tasks_list;
428     GtkTreeSelection *tasks_list_selection;
429 
430 	GtkWidget *scrolled_win;
431     GtkListStore *tasks_list_store;
432     GtkWidget *panel_hbox;
433     GtkWidget *panel_scrolledwindow;
434     GtkTreeModel *tasks_filter;
435     GtkTreeModel *tasks_sort;
436     GtkWidget *tasks_paned;
437     GtkWidget *cf_combobox;
438     GtkWidget *priority_combobox;
439     GtkWidget *category_combobox;
440     GtkTreeViewColumn *tasks_columns[TASKS_NUM_COLUMNS];
441     GtkTextTag *font_tag_object;
442     GtkCellRenderer *done_renderer;
443     gint filter_index;
444     guint next_id;
445 
446     /* tasks items */
447     GtkWidget *td_calendar;
448     GtkWidget *time_expander;
449     GtkWidget *due_date_entry;
450     GtkWidget *tasks_add_window;
451     GtkWidget *td_calendar_window;
452     gboolean tasks_accept_state, tasks_edit_state;
453     GtkWidget *tasks_ok_button;
454     GtkWidget *summary_entry;
455     guint32 tasks_due_julian_day;
456     gint tasks_due_time;
457     GtkWidget *aw_days_spinbutton;
458     GtkWidget *aw_hours_spinbutton;
459     GtkWidget *aw_minutes_spinbutton;
460     GtkWidget *postpone_spinbutton;
461     GtkWidget *alarm_cmd_entry;
462     GtkWidget *alarm_cmd_valid_image;
463     GtkWidget *recurrent_task_vbox;
464     GtkWidget *rt_enable_checkbutton;
465     GtkWidget *rt_frame;
466     GtkWidget *ignore_alarm_checkbutton;
467     GtkWidget *rt_start_hour_spinbutton;
468     GtkWidget *rt_start_minute_spinbutton;
469     GtkWidget *rt_end_hour_spinbutton;
470     GtkWidget *rt_end_minute_spinbutton;
471     GtkWidget *rt_interval_hour_spinbutton;
472     GtkWidget *rt_interval_minute_spinbutton;
473     GtkWidget *dp_1_checkbutton;
474     GtkWidget *dp_2_checkbutton;
475     GtkWidget *dp_3_checkbutton;
476     GtkWidget *dp_4_checkbutton;
477     GtkWidget *dp_5_checkbutton;
478     GtkWidget *dp_6_checkbutton;
479     GtkWidget *dp_7_checkbutton;
480     GtkWidget *rt_dp_day_spinbutton;
481     GtkWidget *rt_dp_month_spinbutton;
482     GtkWidget *repeat_counter_spinbutton;
483     GtkWidget *checkb_sound_enable;
484     GtkWidget *checkb_ndialog_enable;
485     GSList *notifications;
486     gboolean notifications_enable;
487 
488 #ifdef HAVE_LIBWEBKIT
489     WebKitWebView *html_webkitview;
490 #endif  /* LIBWEBKIT */
491 
492 } TASKS;
493 #endif  /* TASKS_ENABLED */
494 
495 #ifdef CONTACTS_ENABLED
496 typedef struct {
497 
498     /* contacts toolbar */
499     GtkToolbar *contacts_toolbar;
500     GtkToolItem *edit_toolbar_button;
501     GtkToolItem *delete_toolbar_button;
502     GtkToolItem *map_location_toolbar_button;
503     GtkToolItem *export_toolbar_button;
504     GtkToolItem *quit_toolbar_button;
505     GtkBox *vbox;
506 
507     GtkWidget *add_contact_button;
508     GtkWidget *edit_contact_button;
509     GtkWidget *delete_contact_button;
510 
511     GtkWidget *contacts_find_entry;
512 	GtkWidget *contacts_find_clear_button;
513     GtkWidget *contacts_find_combobox;
514 
515     GtkWidget *contacts_paned;
516     GtkWidget *panel_hbox;
517 
518 	GtkWidget *scrolled_win;
519     GtkWidget *contacts_list;
520     GtkTreeSelection *contacts_list_selection;
521     GtkListStore *contacts_list_store;
522     GtkTreeModel *contacts_filter;
523     GtkTreeModel *contacts_sort;
524 
525     GtkWidget *contacts_panel_scrolledwindow;
526     gint contacts_link_index;
527     gint contacts_www_link_index;
528     gint contacts_email_link_index;
529     gint contacts_blog_link_index;
530     gboolean write_flag;
531     GtkWidget *next_field_button[CONTACTS_NUM_COLUMNS];
532     GtkTreeViewColumn *contacts_columns[CONTACTS_NUM_COLUMNS];
533 
534     gchar **contact_fields_tags_name;
535 
536     GtkWidget *contacts_add_window;
537     GtkWidget *contacts_ok_button;
538     GtkWidget *contacts_browse_button;
539     GtkWidget *add_info_textview;
540     GtkWidget *photo_browse_button;
541     GtkWidget *birth_day_date_button;
542     GtkWidget *name_day_date_button;
543     GtkWidget *combobox_group;
544     GtkWidget *contact_entries[CONTACTS_NUM_COLUMNS];
545     GtkWidget *select_date_window;
546     GtkWidget *select_date_calendar;
547     gboolean contacts_accept_state;
548     gboolean contacts_edit_state;
549     guint32 birthday_date;
550     guint32 nameday_date;
551 
552     /* show birthdays */
553     GtkWidget *birthdays_window;
554     GtkWidget *birthdays_list;
555     GtkTreeSelection *birthdays_list_selection;
556     GtkListStore *birthdays_list_store;
557 
558     /* export contacts */
559     GtkWidget *export_window;
560     GtkWidget *export_button;
561     GtkWidget *output_file_entry;
562     GtkWidget *first_row_header_check_button;
563     GtkWidget *check_buttons[CONTACTS_NUM_COLUMNS];
564 
565     /* import contacts */
566     GtkWidget *import_window;
567     GtkWidget *import_sel_window;
568     GtkWidget *import_button;
569     GtkWidget *value_labels[CONTACTS_NUM_COLUMNS];
570     GtkWidget *field_type_comboboxes[CONTACTS_NUM_COLUMNS];
571     GtkWidget *first_row_as_header_check_button;
572     GtkWidget *current_record_spinbutton;
573     GtkAdjustment *current_record_spinbutton_adj;
574     GtkWidget *n_records_label;
575     gint field_type[CONTACTS_NUM_COLUMNS];
576     guint max_fields;
577     gchar *file_buffer;
578     gsize file_length;
579 
580     PangoFontDescription *fd_ai_font;
581 
582 #ifdef HAVE_LIBWEBKIT
583     WebKitWebView *html_webkitview;
584 #endif  /* LIBWEBKIT */
585 
586     GtkWidget *input_file_entry;
587     GtkWidget *import_type_combobox;
588     GtkWidget *bluetooth_radiobutton;
589     GtkWidget *usb_radiobutton;
590     GtkWidget *bluetooth_address_entry;
591     GtkWidget *file_import_vbox;
592     GtkWidget *import_vbox;
593     GtkWidget *bluetooth_params_hbox;
594     GtkWidget *usb_params_hbox;
595     GtkWidget *bluetooth_channel_spinbutton;
596     GtkWidget *usb_interface_spinbutton;
597     GtkWidget *use_wbxml_checkbutton;
598 
599 } CONTACTS;
600 #endif  /* CONTACTS_ENABLED */
601 
602 #ifdef NOTES_ENABLED
603 typedef struct {
604 
605     /* notes toolbar */
606     GtkToolItem *edit_button;
607     GtkToolItem *delete_button;
608     GtkToolItem *quit_button;
609     /* notes editor toolbar */
610     GtkToolbar *editor_toolbar;
611     GtkToolItem *save_button;
612 #ifdef HAVE_GSPELL
613     GtkToolItem *spell_check_button;
614 #endif /* HAVE_GSPELL */
615     GtkToolItem *bold_button;
616     GtkToolItem *italic_button;
617     GtkToolItem *highlight_button;
618     GtkToolItem *underline_button;
619     GtkToolItem *strikethrough_button;
620 
621     GtkBox *vbox;
622     GtkWidget *vbox_selector;
623     GtkWidget *vbox_editor;
624 	GtkWidget *scrolled_win;
625 
626     gboolean    editor_active;
627 
628     /* selector */
629     GtkWidget *notes_list;
630     GtkListStore *notes_list_store;
631     GtkTreeSelection *notes_list_selection;
632 
633     GtkWidget *notes_find_entry;
634 	GtkWidget *notes_find_clear_button;
635 
636 	GtkWidget *add_entry_window;
637     GtkWidget *edit_entry_window;
638     GtkWidget *enter_password_window;
639     GtkWidget *add_entry_ok_button;
640 
641     GtkWidget *note_name_entry;
642     GtkWidget *password_entry;
643     GtkWidget *spassword_entry;
644     GtkWidget *category_combobox;
645 	GtkWidget *note_normal_radiobutton;
646     GtkWidget *remember_cursor_checkbutton;
647     GtkTreeViewColumn *notes_columns[NOTES_NUM_COLUMNS];
648 
649     gchar *filename;
650 	gboolean encrypted;
651 
652 #ifdef HAVE_LIBGRINGOTTS
653     GRG_CTX context;
654     GRG_KEY keyholder;
655 #endif /* HAVE_LIBGRINGOTTS */
656 
657     /* category filter */
658     GtkTreeModel *notes_filter;
659     GtkTreeModel *notes_sort;
660     gint filter_index;
661     GtkWidget *cf_combobox;
662     GtkWidget *n_items_label;
663 
664     /* editor */
665     PangoFontDescription *fd_notes_font;
666 
667     GtkWidget *title_label;
668     GtkWidget *font_picker;
669     GtkWidget *editor_textview;
670 #ifdef HAVE_GSPELL
671     GspellTextView *editor_spelltextview;
672 #endif /* HAVE_GSPELL */
673     GtkWidget *editor_scrolledwindow;
674     GtkWidget *ro_editor_scrolledwindow;
675 	GtkWidget *editor_viewport;
676 	GtkWidget *ro_editor_viewport;
677     gboolean changed;
678     gboolean find_next_flag;
679     gboolean buffer_check_modify_enable;
680     gboolean find_hbox_visible;
681 	gboolean note_read_only;
682     GtkWidget *nrow_label_t;
683     GtkWidget *nrow_label;
684     GtkWidget *ncol_label_t;
685     GtkWidget *ncol_label;
686     GtkWidget *find_hbox;
687     GtkWidget *find_entry;
688     GtkWidget *find_case_checkbutton;
689     GtkWidget *readonly_checkbutton;
690 
691 #ifdef HAVE_LIBWEBKIT
692     WebKitWebView *html_webkitview;
693 #endif  /* LIBWEBKIT */
694 
695 	/* read-only: scrollbar position */
696 	gdouble htmlViewPosition;
697 
698 } NOTES;
699 #endif  /* NOTES_ENABLED */
700 
701 typedef struct {
702 
703     /* calendar */
704     GtkWidget *calendar_vbox;
705     GtkWidget *event_marker_type_combobox;
706     GtkWidget *today_marker_type_combobox;
707     GtkWidget *background_color_picker;
708     GtkWidget *header_bg_color_picker;
709     GtkWidget *header_fg_color_picker;
710     GtkWidget *weekend_color_picker;
711     GtkWidget *day_color_picker;
712     GtkWidget *pf_day_color_picker;
713     GtkWidget *selection_color_picker;
714     GtkWidget *mark_color_picker;
715     GtkWidget *mark_current_day_color_picker;
716     GtkWidget *birthday_mark_color_picker;
717     GtkWidget *cft_hscale;
718     GtkWidget *cft_label_1, *cft_label_2, *cft_label_3;
719     GtkWidget *show_day_names_checkbutton;
720     GtkWidget *no_month_change_checkbutton;
721     GtkWidget *show_week_numbers_checkbutton;
722     GtkWidget *week_start_monday_checkbutton;
723     GtkWidget *simple_view_in_fy_calendar_checkbutton;
724     GtkWidget *enable_auxilary_calendars_checkbutton;
725     GtkWidget *strikethrough_past_notes_checkbutton;
726     GtkWidget *ascending_sorting_in_day_notes_checkbutton;
727     GtkWidget *spell_checker_in_day_notes_checkbutton;
728     GtkWidget *enable_block_cursor_checkbutton;
729     GtkWidget *date_header_format_entry;
730     GtkWidget *day_marker_entry;
731     GtkWidget *day_name_font_entry;
732     GtkWidget *calendar_font_entry;
733     GtkWidget *notes_font_entry;
734     GtkWidget *calendar_category_entry;
735     GtkListStore *calendar_category_store;
736     GtkWidget *calendar_category_treeview;
737     GtkTreeSelection *calendar_category_select;
738     GtkWidget *calendar_category_add_button;
739     GtkWidget *calendar_category_edit_button;
740     GtkWidget *calendar_category_remove_button;
741     GtkWidget *day_category_color_picker;
742     GtkWidget *color_edit_window;
743     GtkWidget *color_edit_picker;
744     GtkWidget *color_edit_name_entry;
745     GtkWidget *color_edit_ok_button;
746     GtkWidget *ical_edit_window;
747     GtkWidget *ical_edit_name_entry;
748     GtkWidget *ical_edit_filename_entry;
749     GtkWidget *ical_edit_disable_checkbutton;
750     GtkWidget *ical_edit_filename_browse_button;
751     GtkWidget *ical_edit_ok_button;
752     GtkWidget *calendar_ical_files_add_button;
753     GtkWidget *calendar_ical_files_edit_button;
754     GtkWidget *calendar_ical_files_remove_button;
755     GtkWidget *calendar_ical_files_browse_button;
756     GtkWidget *calendar_ical_files_name_entry;
757     GtkWidget *calendar_ical_files_filename_entry;
758     GtkListStore *calendar_ical_files_store;
759     GtkWidget *calendar_ical_files_treeview;
760     GtkTreeSelection *calendar_ical_files_select;
761     GtkWidget *di_show_current_time_checkbutton;
762     GtkWidget *di_show_current_time_seconds_checkbutton;
763     GtkWidget *di_show_day_number_checkbutton;
764     GtkWidget *di_show_current_day_distance_checkbutton;
765     GtkWidget *di_show_marked_days_checkbutton;
766     GtkWidget *di_show_week_number_checkbutton;
767     GtkWidget *di_show_weekend_days_checkbutton;
768     GtkWidget *di_show_day_category_checkbutton;
769     GtkWidget *di_show_moon_phase_checkbutton;
770     GtkWidget *di_show_notes_checkbutton;
771     GtkWidget *di_show_zodiac_sign_checkbutton;
772 
773 #ifdef TASKS_ENABLED
774     /* tasks */
775     GtkWidget *tasks_vbox;
776     GtkWidget *ti_font_entry;
777     GtkWidget *due_today_color_picker;
778     GtkWidget *due_7days_color_picker;
779     GtkWidget *past_due_color_picker;
780     GtkWidget *tasks_category_entry;
781     GtkListStore *tasks_category_store;
782     GtkWidget *tasks_category_treeview;
783     GtkTreeSelection *tasks_category_select;
784     GtkWidget *tasks_category_add_button;
785     GtkWidget *tasks_category_remove_button;
786     GtkWidget *ct_bold_items_checkbutton;
787     GtkWidget *ct_delete_items_checkbutton;
788     GtkWidget *ct_hide_items_checkbutton;
789     GtkWidget *ct_add_item_checkbutton;
790     GtkWidget *ct_remember_category_checkbutton;
791     GtkWidget *vc_due_date_checkbutton;
792     GtkWidget *vc_type_checkbutton;
793     GtkWidget *vc_category_checkbutton;
794     GtkWidget *vc_priority_checkbutton;
795     GtkWidget *postpone_time_spinbutton;
796     GtkWidget *sound_alarm_repeat_spinbutton;
797     GtkWidget *global_notification_cmd_entry;
798     GtkWidget *global_notification_valid_image;
799 #endif  /* TASKS_ENABLED */
800 
801 #ifdef CONTACTS_ENABLED
802     /* contacts */
803     GtkWidget *contacts_vbox;
804     GtkWidget *contacts_hide_group_column_checkbutton;
805     GtkWidget *contacts_group_entry;
806     GtkListStore *contacts_group_store;
807     GtkWidget *contacts_group_treeview;
808     GtkWidget *cn_font_size_spinbutton;
809     GtkWidget *ci_font_size_spinbutton;
810     GtkTreeSelection *contacts_group_select;
811     GtkWidget *contacts_group_add_button;
812     GtkWidget *contacts_group_remove_button;
813     GtkWidget *contacts_photo_size_combobox;
814     GtkWidget *contact_tag_color_picker;
815     GtkWidget *contact_link_color_picker;
816     GtkWidget *vc_age_checkbutton;
817     GtkWidget *vc_birthday_date_checkbutton;
818     GtkWidget *vc_zodiac_sign_checkbutton;
819 #endif  /* CONTACTS_ENABLED */
820 
821 #ifdef NOTES_ENABLED
822     /* notes */
823     GtkWidget *notes_vbox;
824     GtkWidget *editor_font_entry;
825     GtkWidget *notes_enc_algorithm_combobox;
826     GtkWidget *notes_enc_hashing_combobox;
827     GtkWidget *notes_comp_algorithm_combobox;
828     GtkWidget *notes_comp_ratio_combobox;
829     GtkWidget *notes_category_entry;
830     GtkListStore *notes_category_store;
831     GtkWidget *notes_category_treeview;
832     GtkTreeSelection *notes_category_select;
833     GtkWidget *notes_category_add_button;
834     GtkWidget *notes_category_remove_button;
835     GtkWidget *nvc_type_checkbutton;
836     GtkWidget *nvc_category_checkbutton;
837     GtkWidget *nvc_last_changes_checkbutton;
838     GtkWidget *nvc_created_checkbutton;
839     GtkWidget *cn_remember_category_checkbutton;
840     GtkWidget *cn_use_system_date_checkbutton;
841 #endif  /* NOTES_ENABLED */
842 
843     /* general */
844     GtkWidget *general_vbox;
845     GtkWidget *layout_combobox;
846     GtkWidget *tabs_position_combobox;
847     GtkWidget *override_locale_label_1;
848     GtkWidget *override_locale_label_2;
849     GtkWidget *override_locale_label_3;
850     GtkWidget *date_format_combobox;
851     GtkWidget *time_format_combobox;
852     GtkWidget *entry_web_browser;
853     GtkWidget *entry_email_client;
854     GtkWidget *entry_sound_player;
855     GtkWidget *entry_spell_lang;
856     GtkWidget *enable_tooltips_checkbutton;
857     GtkWidget *override_locale_checkbutton;
858     GtkWidget *disable_underline_in_links_checkbutton;
859     GtkWidget *default_stock_icons_checkbutton;
860     GtkWidget *enable_rules_hint_checkbutton;
861     GtkWidget *remember_latest_tab_checkbutton;
862     GtkWidget *save_data_checkbutton;
863     GtkWidget *enable_systray_checkbutton;
864     GtkWidget *start_minimised_checkbutton;
865     GtkWidget *ignore_day_note_events_checkbutton;
866     GtkWidget *hide_calendar_checkbutton;
867     GtkWidget *hide_tasks_checkbutton;
868     GtkWidget *hide_contacts_checkbutton;
869     GtkWidget *hide_notes_checkbutton;
870 
871 	/* preferences */
872 	GtkWidget *window;
873 	GtkWidget *notebook;
874 	GtkWidget *general;
875 	GtkWidget *calendar;
876 	GtkWidget *tasks;
877 	GtkWidget *notes;
878 	GtkWidget *contacts;
879 
880 } OPTIONS;
881 
882 
883 typedef struct {
884 
885     /* gui */
886     GtkWidget *main_window;
887     GtkWidget *notebook;
888     gboolean all_pages_added;
889     gboolean window_visible;
890     gint current_tab;
891     gint number_of_tabs;
892 
893     /* tray icon */
894     GtkStatusIcon *osmo_trayicon;
895     GtkWidget *trayicon_popup_menu;
896     gboolean no_tray;
897 	GtkWidget *trayicon_menu_calendar_item;
898 #ifdef TASKS_ENABLED
899 	GtkWidget *trayicon_menu_tasks_item;
900 #endif  /* TASKS_ENABLED */
901 #ifdef CONTACTS_ENABLED
902 	GtkWidget *trayicon_menu_contacts_item;
903 #endif  /* CONTACTS_ENABLED */
904 #ifdef NOTES_ENABLED
905 	GtkWidget *trayicon_menu_notes_item;
906 #endif  /* NOTES_ENABLED */
907 
908     /* command line parameters */
909     gboolean calendar_only;
910     gboolean check_events;
911     gint check_ndays_events;
912 
913     /* links handling */
914     gboolean hovering_over_link;
915     GdkCursor *hand_cursor;
916     GdkCursor *regular_cursor;
917     GtkTextTag *gui_url_tag;
918 
919     /* check events */
920     GtkWidget *event_checker_window;
921     GtkWidget *event_checker_list;
922     GtkTreeSelection *event_checker_list_selection;
923     GtkListStore *event_checker_list_store;
924 
925     /* about page */
926     GtkWidget *about_radiobutton;
927     GtkWidget *license_radiobutton;
928     GtkWidget *help_radiobutton;
929     GtkWidget *scrolled_window;
930     GtkWidget *about_textview;
931     GtkBox *about_vbox;
932     gint about_counter;
933     gint about_link_index;
934     GSList *about_links_list;
935     GtkTextIter about_entry_iter;
936     GtkTextBuffer *about_entry_buffer;
937 
938     /* miscellaneous */
939     guint32 run_date;
940     gint key_counter;
941     gint run_time;
942     gint save_status;
943     gchar version[7];
944     guint timer;
945 #ifdef HAVE_LIBWEBKIT
946     gchar *stylesheet;
947 #endif  /* HAVE_LIBWEBKIT */
948 
949     /* print */
950     gint print_font_size;
951     gint print_nlines;
952     gint print_npages;
953     gint print_lines_per_page;
954 
955     /* modules */
956     CALENDAR *cal;
957 #ifdef TASKS_ENABLED
958     TASKS *tsk;
959 #endif  /* TASKS_ENABLED */
960 #ifdef CONTACTS_ENABLED
961     CONTACTS *cnt;
962 #endif  /* CONTACTS_ENABLED */
963 #ifdef NOTES_ENABLED
964     NOTES *nte;
965 #endif  /* NOTES_ENABLED */
966 
967     OPTIONS *opt;
968 
969 } GUI;
970 
971 typedef struct {
972     gpointer *data;
973     GUI *appGUI;
974 } MESSAGE;
975 
976 gboolean    gui_create_window               (GUI *appGUI);
977 void        gui_add_to_notebook             (GtkWidget *widget, gchar *text, GUI *appGUI);
978 void        gui_save_all_data               (GUI *appGUI);
979 void        gui_save_data_and_run_command   (gchar *command, GUI *appGUI);
980 void        gui_quit_osmo                   (GUI *appGUI);
981 void        gui_quit_osmo_cb                (GtkToolButton *toolbutton, gpointer data);
982 void        gui_show_about_window_cb        (GtkToolButton *toolbutton, gpointer data);
983 void        gui_systray_initialize          (GUI *appGUI);
984 void        gui_systray_update_icon         (GUI *appGUI);
985 void        gui_systray_tooltip_update      (GUI *appGUI);
986 GtkToolItem *gui_create_toolbar_button      (GUI *appGUI, const gchar *icon_name, const gchar *label,
987                                              void(*click_callback) (GtkToolButton *, gpointer));
988 GtkToolItem *gui_create_toolbar_toggle_button(GUI *appGUI, const gchar *icon_name, const gchar *label,
989                                              void(*toggle_callback) (GtkToggleToolButton *, gpointer));
990 void        gui_append_toolbar_spring       (GtkToolbar *toolbar);
991 
992 #endif /* _GUI_H */
993 
994