diff options
Diffstat (limited to 'calendar')
163 files changed, 0 insertions, 64992 deletions
diff --git a/calendar/.cvsignore b/calendar/.cvsignore deleted file mode 100644 index 2497bd97d5..0000000000 --- a/calendar/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -Makefile.in -Makefile -.deps -_libs -.libs -*.lo -GnomeCal-stubs.c -GnomeCal-skels.c -GnomeCal-common.c -GnomeCal.h diff --git a/calendar/AUTHORS b/calendar/AUTHORS deleted file mode 100644 index 7e482aef97..0000000000 --- a/calendar/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -Miguel de Icaza <miguel@kernel.org> -Federico Mena <federico@helixcode.com> -Arturo Esponosa <arturo@nuclecu.unam.mx> -Russell Steinthal <rms39@columbia.edu> diff --git a/calendar/ChangeLog b/calendar/ChangeLog deleted file mode 100644 index 8df21920f3..0000000000 --- a/calendar/ChangeLog +++ /dev/null @@ -1,5513 +0,0 @@ -2000-08-21 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (calendar_model_duplicate_value): Updated - function. - (calendar_model_free_value): Updated function. - (calendar_model_initialize_value): Updated function. - (calendar_model_value_is_empty): Updated function. - (remove_object): Updated function. - (obj_updated_cb): Updated function. - (calendar_model_get_cal_client): Added inline docs. - (calendar_model_delete_task): Updated. - (calendar_model_mark_task_complete): Updated. - (calendar_model_get_cal_object): Updated. - -2000-08-21 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (set_categories): New function. - (parse_time): Moved over from the old set_time_t(). This just - parses the time and leaves the warning dialog for the caller. - (set_datetime): New function. - (set_geo): Updated old function. - (set_percent): Updated old function. - (set_priority): Updated old function. - (set_summary): New function. - (set_url): New function. - (calendar_model_set_value_at): Updated function. - (calendar_model_is_cell_editable): Updated function. - (calendar_model_append_row): Updated. Added an ugly hack to - accomodate ETable's lack of a real API for adding new items. - Also, don't try to set columns that are not editable. - -2000-08-21 JP Rosevear <jpr@helixcode.com> - - * gui/e-week-view.c (e_week_view_reload_events): - Use CalObjType - - * gui/e-day-view.c (e_day_view_reload_events): ditto - -2000-08-21 JP Rosevear <jpr@helixcode.com> - - * gui/e-day-view-main-item.c (e_day_view_main_item_draw_day_event): - Use CalComponent instead of iCalObject. #if some alarm stuff - -2000-08-21 JP Rosevear <jpr@helixcode.com> - - * gui/e-day-view-top-item.c (e_day_view_top_draw_long_event): - Use CalComponent instead of iCalObject. #if some alarm stuff - -2000-08-21 JP Rosevear <jpr@helixcode.com> - - * gui/e-day-view.h: Update prototypes - - * gui/e-day-view.c (e_day_view_on_unrecur_appointment): - Remove commented out portions. - - * gui/e-week-view.c (e_week_view_on_unrecur_appointment): - Tidy. - -2000-08-21 JP Rosevear <jpr@helixcode.com> - - * gui/e-day-view.c - (e_day_view_update_event): Use CalComponent - instead of iCalObject. Work around not having a compare - dates routine for two CalComponents. - (e_day_view_reshape_long_event): Use CalComponent instead - of iCalObject, #if some alarm stuff - (e_day_view_reshape_day_event): ditto - (e_day_view_reload_events): Use revamped CalClient - (e_day_view_update_event_cb): Use CalComponent - instead of iCalObject - (e_day_view_foreach_event_with_uid): ditto - (e_day_view_remove_event_cb): ditto - (e_day_view_update_event_label): ditto - (e_day_view_find_event_from_uid): ditto - (e_day_view_on_event_click): ditto - (e_day_view_on_event_right_click): ditto - (e_day_view_on_new_appointment): ditto - (e_day_view_on_edit_appointment): ditto - (e_day_view_on_delete_occurrence): ditto - (e_day_view_on_delete_appointment): ditto - (e_day_view_on_unrecur_appointment): ditto - (e_day_view_on_top_canvas_motion): ditto - (e_day_view_on_main_canvas_motion): ditto - (e_day_view_finish_long_event_resize): ditto - (e_day_view_finish_resize): ditto - (e_day_view_free_event_array): ditto - (e_day_view_add_event): ditto - (e_day_view_key_press): ditto - (e_day_view_on_editing_stopped): ditto - (e_day_view_update_top_canvas_drag): ditto - (e_day_view_update_main_canvas_drag): ditto - (e_day_view_on_drag_data_get): ditto - (e_day_view_on_top_canvas_drag_data_received): ditto - (e_day_view_on_main_canvas_drag_data_received): ditto - -2000-08-20 JP Rosevear <jpr@helixcode.com> - - * gui/e-week-view-event-item.c (e_week_view_event_item_draw_icons): - Use CalComponent instead of iCalObject. #if some alarm stuff - -2000-08-20 JP Rosevear <jpr@helixcode.com> - - * gui/e-week-view.c (e_week_view_update_event): Use CalComponent - instead of iCalObject. Work around not having a compare - dates routine for two CalComponents. - (e_week_view_reload_events): Use revamped CalClient - (e_week_view_reshape_event_span): Use CalComponent instead - of iCalObject, #if some alarm stuff - (e_week_view_update_event_cb): Use CalComponent instead of - iCalObject - (e_week_view_foreach_event_with_uid): ditto - (e_week_view_remove_event_cb): ditto - (e_week_view_free_events): ditto - (e_week_view_add_event): ditto - (e_week_view_on_editing_stopped): ditto - (e_week_view_find_event_from_uid): ditto - (e_week_view_key_press): ditto - (e_week_view_show_popup_menu): ditto - (e_week_view_on_new_appointment): ditto - (e_week_view_on_edit_appointment): ditto - (e_week_view_on_delete_occurrence): ditto - (e_week_view_on_delete_appointment): ditto - (e_week_view_on_unrecur_appointment): ditto - - * gui/e-week-view.h: Update prototypes. - -2000-08-18 JP Rosevear <jpr@helixcode.com> - - * gui/event-editor.h: Update prototypes. - - * gui/event-editor.c: Need to come back here later to fix the - alarm stuff. The gui also needs to be completely redone to - support the fancier CalComponent settings (exrules, rdates, etc) - There are some warnings that I put in to mark some of these - spots - (event_editor_destroy): Use Calcomponent instead - of iCalObject - (make_title_from_comp): ditto - (clear_widgets): ditto - (fill_widgets): ditto - (classification_get): ditto - (dialog_to_comp_object): ditto - (save_ical_object): ditto - (close_dialog): ditto - (event_editor_set_ical_object): ditto - -2000-08-17 JP Rosevear <jpr@helixcode.com> - - * gui/gncal-todo.c (ok_button): Use CalComponent instead of - iCalObject - (cancel_button): ditto - (gncal_todo_edit): ditto - (add_todo): ditto - (edit_todo): ditto - (delete_todo): ditto - (insert_in_clist): ditto - (gncal_todo_update): ditto - - * gui/gncal-todo.h: Update prototypes - -2000-08-16 JP Rosevear <jpr@helixcode.com> - - Rework gnome-cal.c - alarms are a tad broken ATM so this - will need more cleaning later. - - * gui/gnome-cal.c (snooze): Use CalComponent instead of - iCalObject - (edit): ditto - (audio_notification): ditto - (display_notification_cb): Use CalComponent member of - alarm_notify_closure rather than iCalObject - (display_notification): ditto - (trigger_alarm_cb): ditto. Use CalComponent alarm types - (gnome_calendar_tag_calendar_cb): New - cal_client_generate_instances callback to - mark_gtk_calendar_day's - (gnome_calendar_tag_calendar): Use above callback - (save_ical_object_cb): Use CalComponent instead of - iCalObject - (gnome_calendar_edit_object): ditto - (gnome_calendar_new_appointment): ditto - -2000-08-15 JP Rosevear <jpr@helixcode.com> - - * gui/mark.c (mark_month_item_cb): Callback used to mark every - event in a month. - (mark_month_item): Use cal_client_generate_instances with - above callback - -2000-08-15 JP Rosevear <jpr@helixcode.com> - - * gui/print.c (print_month_small): Use - cal_client_get_objects_in_range - (print_day_details_cb): Callback used to create columns and fill - events into a day view. Code should be shared with e-day-view - in reality. Maybe need to go back to layout.[hc] a bit later - (print_day_details): Use cal_client_generate_instances with - above callback. Iterate over results to expand events to fit. - (print_day_summary_cb): Callback to build list of event info - for a day - (print_day_summary): Use cal_client_generate_instances with - above callback to generate the required event info for printing - (print_todo_details_cb): Callback used create list of todo info - (print_todo_details): Use cal_client_generate_instances with - above callback to generate required todo info for printing. - - * gui/layout.[hc]: No longer used. - -2000-08-12 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (get_is_overdue): Finished implementing. - (calendar_model_value_at): Handle the color field. - -2000-08-11 Seth Alves <alves@hungry.com> - - * cal-util/cal-component.c (cal_component_get_pilot_id): - (cal_component_set_pilot_id): stubs for pilot id accessors - (cal_component_get_pilot_status): - (cal_component_set_pilot_status): stubs for pilot status accessors - - * conduits/calendar/calendar-conduit.c (transmit): start to - convert to cal-component interface - - * conduits/todo/todo-conduit.c (transmit): same - -2000-08-11 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (get_geo): Generate a prettier string for - the geographical position. - (get_classification): New function. - (get_categories): New function. - (get_completed): New function. - (get_dtend): New function. - (get_dtstart): New function. - (get_due): New function. - (get_percent): New function. - (get_priority): New function. - (get_summary): New function. - (get_transparency): New function. - (get_url): New function. - (get_has_alarms): New function. - (get_has_recurrences): New function. - (get_is_complete): New function. - (get_is_overdue): New function. - - * cal-util/cal-component.c (scan_property): Handle the GEO - property. - (free_icalcomponent): Likewise. - (cal_component_get_geo): Likewise. - (cal_component_set_geo): Likewise. - (cal_component_free_geo): Likewise. - (cal_component_set_exdate_list): Removed incorrect assertion. - (cal_component_set_exrule_list): Removed incorrect assertion. - (cal_component_get_next_alarm): Oops, this had not been - implemented at all. - (cal_component_has_rdates): New function. - (cal_component_has_rrules): New function. - - * cal-util/cal-component.h (CalComponentField): Added the GEO - property. - -2000-08-11 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (scan_property): Handle the - PERCENT-COMPLETE property. - (free_icalcomponent): Likewise. - (cal_component_get_percent): Likewise. - (cal_component_set_percent): Likewise. - (cal_component_free_percent): Likewise. - (scan_property): Handle the PRIORITY property. - (free_icalcomponent): Likewise. - (cal_component_get_priority): Likewise. - (cal_component_set_priority): Likewise. - (cal_component_free_priority): Likewise. - - * cal-util/cal-component.h (CalComponentField): New enumeration - with the list of fields we support for ETable. - -2000-08-10 Dan Winship <danw@helixcode.com> - - * gui/component-factory.c (owner_set_cb): Update prototype. - -2000-08-10 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (gnome_calendar_new_appointment): New function. - Mostly moved over from calendar-commands.c:display_objedit(). - - * gui/calendar-commands.c (calendar_iterate): Removed. Wheee! - (display_objedit): Removed. - (new_appointment_cb): New function. Just call - gnome_calendar_new_appointment(). - (display_objedit_today): Removed. - (calendar_control_activate): Removed the "New appointment for - today" option, since it is pretty useless. - -2000-08-10 Federico Mena Quintero <federico@helixcode.com> - - * cal-client/cal-client.c (cal_client_generate_instances): There. - A pretty function to generate recurrence instances atomically so - that clients don't have to jump through hoops. Now we can get rid - of the ugly calendar_iterate() function. - -2000-08-09 Cody Russell <bratsche@gnome.org> - - * gui/calendar-commands.c: Make the toolbar honor the user's - gnomecc settings for detachable toolbars. - -2000-08-09 Federico Mena Quintero <federico@helixcode.com> - - * gui/alarm.c (pop_alarm): Oops, subtract the new alarm's trigger - time from the current time. - -2000-08-09 Christopher James Lahey <clahey@helixcode.com> - - * cal-client/cal-client.c: Fixed a warning. - -2000-08-09 Christopher James Lahey <clahey@helixcode.com> - - * cal-client/cal-client.c, gui/e-calendar-table.c, pcs/cal.c: - Fixed some warnings. - -2000-08-08 Federico Mena Quintero <federico@helixcode.com> - - * idl/evolution-calendar.idl (Cal): Added a get_objects_in_range() - method. Takes in a time range and the type of component we are - interested in; returns a list of UIDs. The idea is that - ocurrences get computed in the client; we can have multiple - recurrences in iCalendar and we cannot identify them trivially - across the wire. - (Cal): Removed the get_events_in_range() method. - - * pcs/cal-backend.c (cal_backend_free_uid_list): New function. - (cal_backend_get_objects_in_range): New function. - (cal_backend_get_events_in_range): Removed. - - * pcs/cal-backend-file.c (cal_backend_file_get_objects_in_range): - Implemented new method. - (cal_backend_file_get_events_in_range): Removed. - - * pcs/cal.c (Cal_get_events_in_range): Removed. - (uncorba_obj_type): New function. - (Cal_get_uids): Use uncorba_obj_type(). - (Cal_get_n_objects): Likewise. - (Cal_get_objects_in_range): Implemented new method. - - * cal-client/cal-client.c (cal_client_get_events_in_range): Removed. - (cal_client_get_objects_in_range): Implemented. - (corba_obj_type): New function. - (cal_client_get_n_objects): Use corba_obj_type(). - (cal_client_get_uids): Likewise. - -2000-08-07 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_clone): New function. - (cal_component_get_icalcomponent): Ensure that the SEQUENCE - property does not need incrementing. - - * gui/dialogs/alarm-notify-dialog.c (alarm_notify_dialog): Use - CalComponent. Deal with an empty summary property. - -2000-08-07 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_get_as_string): Doh, - libical owns the string's memory, so do not free it. - - * cal-client/client-test.c (create_client): Connect to the destroy - signal of the client here. - - * cal-client/test.ics: New test file, modified from Eric Busboom's - test file from RFC 2445. - -2000-08-05 Federico Mena Quintero <federico@helixcode.com> - - * cal-client/client-test.c (dump_component): This was gone for - some reason. - (main): Load a new test file. - -2000-08-04 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_commit_sequence): New - function to commit changes to the SEQUENCE property. - (cal_component_get_as_string): Ensure that the sequence has been - committed. - - * cal-client/cal-client.c (cal_client_get_object): Use - CalComponent instead of the old iCalObject. - (cal_client_update_object): Use iCalObject. Commit the SEQUENCE - property before stringifying the object and piping it over to the - Wombat. - -2000-08-04 Seth Alves <alves@hungry.com> - - * conduits/todo/todo-conduit.c (conduit_get_gpilot_conduit): if - oaf isn't initialized by the time the conduit starts, start it - up. we do this because we need to start wombat with oaf, and - gpilotd doesn't currently start oaf. - -2000-08-04 Michael Meeks <michael@helixcode.com> - - * gui/calendar-commands.c (calendar_control_activate): unref. - -2000-08-02 Federico Mena Quintero <federico@helixcode.com> - - * pcs/cal-backend-file.c (cal_backend_file_get_uid_by_pilot_id): - Added stub for now. - (cal_backend_file_update_pilot_id): Likewise. - - * pcs/Makefile.am (libpcs_a_SOURCES): Removed cal-backend-imc.[ch] - from the list of sources. The idea is to move vCalendar importing - to the GUI as a convenience function. - -2000-08-02 Seth Alves <alves@hungry.com> - - * pcs/cal-backend-imc.c (cal_backend_imc_update_pilot_id): call - save (cbimc) after setting the pilot id and status. - -2000-08-02 Joe Shaw <joe@helixcode.com> - - * pcs/cal-backend-file.c (cal_backend_file_update_pilot_id): - Fixed a g_return_if_fail that had two parameters and thus - wouldn't build. - -2000-08-03 Damon Chaplin <damon@helixcode.com> - - * gui/calendar-model.c (calendar_model_append_row): updated to match - the new ETableModel append_row. This meant we could also get rid of - the row_being_added and idle_id hack. - -2000-08-02 Christopher James Lahey <clahey@helixcode.com> - - * gui/calendar-model.c: Emit "model_pre_change" signals as - appropriate. - -2000-08-02 Federico Mena Quintero <federico@helixcode.com> - - * pcs/cal-backend-file.[ch]: New files for the iCalendar file - backend. - - * pcs/Makefile.am (libpcs_a_SOURCES): Added cal-backend-file.[ch]. - - * cal-util/cal-component.c (cal_component_set_icalcomponent): - Return an operation success code for if we are passed a component - of a type we don't support. - -2000-07-31 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-recur.c (*): Use CalComponent and the new property - types instead of the old iCalObject stuff. - (cal_recur_generate_instances): Renamed from - cal_object_generate_events(). Ensure that the component has the - DTSTART property. - (generate_instances_for_year): Renamed from - cal_object_generate_events_for_year(). - (cal_obj_expand_recurrence): Made static. - (cal_recur_from_icalrecurrencetype): New function. We should - really convert this whole file to use struct icalrecurrencetype - instead. - (cal_recur_free): New function. - - * cal-util/cal-recur.h (CalRecurType): Renamed from CalObjRecurType. - (CalRecurrence): Renamed from CalObjRecurrence. - - * cal-util/timeutil.c (time_from_icaltimetype): New function. - - * cal-util/Makefile.am: Commented out the test-recur program. - -2000-08-01 Damon Chaplin <damon@helixcode.com> - - * Removed doc directory, since it is the old gnome-pim docs which - aren't used any more. - - * Makefile.am (SUBDIRS): removed doc. - -2000-07-26 Peter Williams <peterw@helixcode.com> - - * gui/calendar-model.c: compile fix for Solaris - (works under Linux, too; don't know about others) - - * this is a test of whether CVS merge does what I - think it will do. - -2000-07-26 Federico Mena Quintero <federico@helixcode.com> - - OK, it seems that we have all the interesting properties for - single-user calendars now. RFC 2445 can bite me. - - * cal-util/cal-component.c (scan_property): Handle the RRULE - property. Yay!. - (scan_recur): Likewise, yow! - (get_recur_list): Likewise, yeehaw! - (get_recur_list): Likewise, honk honk! - (set_recur_list): Likewise, booooga booooga! - (cal_component_get_rrule_list): Likewise, squeek squeek! - (cal_component_set_rrule_list): That's it, I ran out of sounds. - (cal_component_free_recur_list): Likewise. - (scan_property): Handle the EXRULE property. - (free_icalcomponent): Likewise. - (cal_component_get_exrule_list): Likewise. - (cal_component_set_exrule_list): Likewise. - (set_period_list): Oops, free the old properties as well as - removing them. - (set_text_list): Ditto. - (cal_component_set_exdate_list): Ditto. - - * cal-util/cal-component.c: Put all the functions used to free - returned values all together. - (cal_component_set_rdate_list): Oops, mark SEQUENCE property to be - incremented since the RFC requires it. - (scan_property): Handle the EXDATE property. - (scan_exdate): Likewise. - (free_icalcomponent): Likewise. - (cal_component_get_exdate_list): Likewise. - (cal_component_set_exdate_list): Likewise. - (cal_component_free_exdate_list): Likewise. - -2000-07-26 Jeffrey Stedfast <fejj@helixcode.com> - - * gui/Makefile.am: Fixed a typo - -2000-07-26 Jeffrey Stedfast <fejj@helixcode.com> - - * gui/Makefile.am: Added a few xpm files to the EXTRA DIST section - -2000-07-25 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_free_period_list): New function. - (scan_property): Handle the RDATE property. - (scan_period): Likewise. - (free_icalcomponent): Likewise. - (get_period_list): Likewise. - (set_period_list): Likewise. - (cal_component_get_rdate_list): Likewise. - (cal_component_set_rdate_list): Likewise. - (scan_text): Simplify a bit since we only handle the ALTREP - parameter; there is no need to iterate over all parameters. - (scan_datetime): Simplify; just handle the TZID parameter. - (scan_summary): Simplify; just handle the ALTREP parameter. - (cal_component_get_as_string): New function. - - * idl/evolution-calendar.idl (CalObjType): Removed the TYPE_OTHER; - now we only expose the types of objects we know about. - - * cal-util/cal-util.h (CalObjType): Likewise. - - * cal-client/cal-client.c (cal_client_get_n_objects): Likewise. - (cal_client_get_uids): Likewise. - - * conduits/calendar/calendar-conduit.c (get_calendar_objects): Likewise. - (check_for_slow_setting): Likewise. - - * pcs/cal-backend-imc.c (count_objects): Likewise. - (build_uids_list): Likewise. - - * pcs/cal.c (Cal_get_uids): Likewise. - (Cal_get_n_objects): Likewise. - -2000-07-25 Damon Chaplin <damon@helixcode.com> - - * gui/e-calendar-table.[hc]: new ECalendarTable to show an ETable view - for Todo/Event items. - - * gui/task-assigned-to.xpm: - * gui/task-recurring.xpm: - * gui/task-assigned.xpm: - * gui/task.xpm: new pixmaps (all the same at present) to go in the - icon column of the ETable. - - * gui/event-editor.c: hid the silly 'Calendar' labels on the - GnomeDateEdits and hid the times when you select 'All day event'. - Also adjusted the time_t's so that when an all day event finishes on - say midnight 13th May, we show 12th May in the dialog, since it - implicitly includes all of that day up to midnight. - - * gui/dialogs/task-editor-dialog.glade: - * gui/dialogs/task-editor.[hc]: unfinished dialog to edit tasks. - - * gui/gncal-todo.c: temporary hack so that we can use the simple dialog - with our new ETable. - -2000-07-23 Damon Chaplin <damon@helixcode.com> - - * cal-util/calobj.h: added a few more fields. - - * cal-util/calobj.c (ical_object_create_from_vobject): check for a - NULL return from vObjectUStringZValue for URL property to avoid SEGV. - For some reason an empty 'URL:' property appears and causes trouble. - -2000-07-20 Ettore Perazzoli <ettore@helixcode.com> - - * gui/component-factory.c (factory_fn): Update for the new - `evolution_shell_component_new()' arg. - -2000-07-19 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_alarm_set_trigger): - Finish filling the trigger. What a pain, again. - (cal_component_alarm_free_trigger): Implemented. - -2000-07-19 Fatih Demir <kabalak@gmx.net> - - * conduits/calendar/calendar-conduit-control-applet.desktop: - - * conduits/todo/todo-conduit-control-applet.desktop: - Added the Turkish desktop entries. - -2000-07-18 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_alarm_free): Free the - icalcomponent if this is an unattached alarm. - (scan_alarm_property): Handle the TRIGGER property. - (cal_component_alarm_get_trigger): Ditto. Royal pain. - (cal_component_alarm_set_trigger): Ditto. Less pain. - -2000-07-17 Federico Mena Quintero <federico@helixcode.com> - - * cal-client/cal-client.c (cal_client_get_object): Fixed inline - docs. - (cal_client_new): Ditto. - (cal_client_get_n_objects): Added inline docs. - -2000-07-14 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (CalComponentAlarm): New internal - represntation for alarm components. We really don't map them to a - CalComponent because it is more convenient to handle them as - "child" structures. - (make_alarm): New function to create a CalComponentAlarm from an - icalcomponent representing a VALARM. - (scan_alarm_property): New function to scan a property from an - alarm component. We support ACTION. - (cal_component_get_first_alarm): New function to start an iterator - over the alarms in a calendar component. - (cal_component_alarm_get_action): New function. - (cal_component_alarm_set_action): New function. - -2000-07-13 Seth Alves <alves@hungry.com> - - * conduits/todo/todo-conduit.c: conduit based on the calendar conduit. - this conduit syncs a pilot's ToDoDB database to wombat's list of "todo" - events. - - * gui/gncal-todo.c (simple_todo_editor): set todo's priority control - based on value from ical object during edit. - -2000-07-12 Federico Mena Quintero <federico@helixcode.com> - - * gui/print.c: Revert Michael's GnomeFont patch until the - gnome-print API stabilizes. - -2000-07-12 Michael Meeks <michael@helixcode.com> - - * gui/print.c (titled_box, print_text, print_month_small), - (bound_text): GnomeFont update. - -2000-07-12 Seth Alves <alves@hungry.com> - - * conduits/calendar/calendar-conduit.c: fixed various problems - - * cal-client/Makefile.am: build a static version of the library - to link with the conduits - - * cal-util/Makefile.am: same - -2000-07-11 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (scan_property): Handle the COMPLETED - property. - (free_icalcomponent): Ditto. - (cal_component_get_completed): Ditto. - (cal_component_set_completed): Ditto. - (scan_property): Handle the TRANSPARENCY property. - (free_icalcomponent): Ditto. - (cal_component_get_transparency): Ditto. - (cal_component_set_transparency): Ditto. - (scan_property): Handle the URL property. - (free_icalcomponent): Ditto. - (cal_component_get_url): Ditto. - (cal_component_set_url): Ditto. - - * pcs/cal-factory.c (queue_load_create_job): Removed unneeded - check for the URI. - (load_fn): Be more paranoid about the URI and notify the listener - if we got passed a bad URI. Simplify the termination code a bit. - (create_fn): Likewise. - (queue_load_create_job): Be more paranoid about the URI. - -2000-07-10 Ettore Perazzoli <ettore@helixcode.com> - - * gui/Makefile.am: Remove pilot stuff for now. - - * Makefile.am (SUBDIRS): Remove `conduits'. - -2000-07-10 Dan Winship <danw@helixcode.com> - - * gui/Makefile.am (EXTRA_DIST): remove gnomecal.conduit - - * conduits/calendar/Makefile.am (EXTRA_DIST): We want - calendar.conduit.in, not calendar.conduit. - -2000-07-10 Seth Alves <alves@hungry.com> - - * gui/Makefile.am (SUBDIRS): - * conduits/calendar/Makefile.am: moved calendar-conduit stuff from - the gui directory to here. - - * Makefile.am (SUBDIRS): added conduits to SIBDIRS - -2000-07-08 Ettore Perazzoli <ettore@helixcode.com> - - * gui/calendar-commands.c (calendar_control_activate): Remove - "close calendar" command. - -2000-07-08 Anders Carlsson <andersca@gnu.org> - - * gui/e-week-view.c (e_week_view_on_button_press): Handle mouse wheel scrolling. - - * gui/e-day-view.c (e_day_view_on_time_canvas_button_press): New function to handle - mouse wheel scrolling. - (e_day_view_on_main_canvas_button_press): Handle mouse wheel scrolling. - -2000-07-07 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (scan_property): Handle the SEQUENCE - property. - (free_icalcomponent): Ditto. - (cal_component_get_sequence): Ditto. - (cal_component_set_sequence): Ditto. - (cal_component_free_sequence): Ditto. - (cal_component_set_last_modified): Removed incorrect assertion. - (CalComponentPrivate): New need_sequence_inc flag. The sequence - number must be incremented when certain properties change, so we - store a flag that says if we need to bump it when piping the - object over the wire. - (free_icalcomponent): Reset need_sequence_inc. - (cal_component_set_dtstart): Set need_sequence_inc. - (cal_component_set_dtend): Ditto. - (cal_component_set_due): Ditto. - -2000-07-06 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (scan_property): Handle the - LAST-MODIFIED property. - (free_icalcomponent): Ditto. - (cal_component_get_last_modified): Ditto. - (cal_component_set_last_modified): Ditto. - (get_icaltimetype): New function to get struct icaltimetype - values. - (cal_component_get_created): Use get_icaltimetype(). - (set_icaltimetype): New function to set struct icaltimetype - values. - (cal_component_set_created): Use set_icaltimetype(). - - * cal-util/cal-component.c (scan_property): Handle the CREATED - property. - (free_icalcomponent): Ditto. - (cal_component_free_icaltimetype): Ditto. - (cal_component_get_created): Ditto. - (cal_component_set_created): Ditto. - (cal_component_init): Do not create an UID here. - (ensure_mandatory_properties): New function to ensure that the - mandatory RFC properties are indeed in the component. If they are - not, we create them on the fly. - (cal_component_set_new_vtype): Use ensure_mandatory_properties(). - (cal_component_set_icalcomponent): Ditto. - (cal_component_get_uid): Return the UID in a parameter, not as a - function return value, for consistency's sake. - (scan_property): Handle the DTSTAMP property. - (free_icalcomponent): Ditto. - (cal_component_get_dtstamp): Ditto. - (cal_component_set_dtstamp): Ditto. - -2000-07-04 Damon Chaplin <damon@helixcode.com> - - * gui/gncal-todo.c (gncal_todo_update): Use &obj instead of &ico in - the call to cal_client_get_object(). The ToDo list should work now. - - * gui/event-editor-dialog.glade: set the toplevel GnomeApp to invisible - so it doesn't appear and then resize. - -2000-07-03 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_get_summary): Use - CalComponentText instead of CalComponentPropSummary. Removed the - latter typedef. - (cal_component_set_summary): Likewise. - (scan_property): Handle the CLASSIFICATION property. - (cal_component_get_classification): Ditto. - (cal_component_set_classification): Ditto. - - * cal-util/cal-component.c (cal_component_free_text_list): Renamed - from cal_component_free_description_list(). We can share this - function since both comments and descriptions have the same form. - (scan_text): Ditto. - (get_text_list): New function. - (set_text_list): New function. - (cal_component_get_description_list): Use get_text_list(). - (cal_component_set_description_list): Use set_text_list(). - (cal_component_set_uid): Add sanity check. - (cal_component_get_summary): Ditto. - (cal_component_get_description_list): Ditto. - (cal_component_get_dtstart): Ditto. - (cal_component_get_dtend): Ditto. - (cal_component_get_due): Ditto. - (scan_property): Handle the COMMENT property. - (cal_component_get_comment_list): Ditto. - (cal_component_set_comment_list): Ditto. - -2000-07-02 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (scan_categories): Handle CATEGORIES. - This can appear multiple times, so we maintain a list. We - compress them later to a single property with multiple values. - (cal_component_get_categories_list): Ditto. - (cal_component_set_categories_list): Ditto. - (cal_component_free_categories_list): Ditto. - (free_icalcomponent): Properly free the mappings. - -2000-07-02 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (scan_datetime): Handle date/time and - timezone pairs. - (scan_property): Handle DTSTART and DTEND. - (cal_component_free_datetime): Ditto. - (get_datetime): Ditto. - (cal_component_get_dtstart): Ditto. - (set_datetime): Ditto. - (cal_component_set_dtstart): Ditto. - (cal_component_get_dtend): Ditto. - (cal_component_set_dtend): Ditto. - (scan_property): Handle DUE date. - (cal_component_get_due): Ditto. - (cal_component_set_due): Ditto. - -2000-07-01 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_get_description_list): - Handle the DESCRIPTION property. There can be multiple - descriptions with parameters each, so we deal with a list instead - of a single structure. - (cal_component_set_description_list): Ditto. - (cal_component_free_description_list): Ditto. - (scan_property): Ditto. - (scan_description): Ditto. - -2000-06-30 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c (cal_component_get_summary): To avoid - passing a million parameters to setters/getters for properties - that support parameters, we now pass client-side structures - instead. Here we use CalComponentPropSummary. - (cal_component_set_summary): Ditto. - -2000-06-29 Christopher James Lahey <clahey@helixcode.com> - - * gui/component-factory.c: Make calendar die when evolution quits. - -2000-06-30 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.c: Change of plans. We use an - icalcomponent from libical as our core representation so that we - can preserve extension fields and fields that we don't (yet) - support. CalComponent is just a wrapper with a nice API that - provides non-iterative, random access to the ical's fields. - (cal_component_destroy): Free the thing correctly. - (cal_component_get_vtype): Re-implement in terms of icalcomponent. - (cal_component_set_icalcomponent): New function to set the - CalComponent's data from an existing icalcomponent. - (cal_component_get_icalcomponent): New function. - (cal_component_set_new_vtype): New convenience function to create - an empty component. - (scan_icalcomponent): Core scanning function. - (scan_property): Another core scanning function. - (cal_component_get_uid): Use the property directly. - (cal_component_get_summary): Ditto. Handle the altrep parameter - as well. - (cal_component_set_summary): Ditto. Feel the pain, motherfucker. - It is ridiculous how much code this involves. - (scan_summary): Ditto. - -2000-06-29 Ettore Perazzoli <ettore@helixcode.com> - - * gui/component-factory.c (owner_set_cb): Get an - EvolutionShellClient instead of an Evolution_Shell to match the - changes in libeshell. - -2000-06-29 Federico Mena Quintero <federico@helixcode.com> - - * gui/Makefile.am: Do not link and include the pilot stuff for the - calendar component, just for the Pilot conduit. Commented out the - Pilot part so that Evolution can build. Sigh, we'll have to - modify gnome-pilot to use OAF. - -2000-06-29 Peter Williams <peterw@helixcode.com> - - * gui/Makefile.am (LINK_FLAGS): Make the calendar-pilot-sync - program conditional on HAVE_GNOME_PILOT, and add - GNOME_PILOT_CFLAGS, GNOME_PILOT_LIBS, and PISOCK_LIBS in the - appropriate places. - -2000-06-29 Seth Alves <alves@hungry.com> - - * pcs/cal.c (Cal_get_uid_by_pilot_id): - (Cal_update_pilot_id): - * pcs/cal-backend-imc.c (cal_backend_imc_update_pilot_id): - (cal_backend_imc_get_uid_by_pilot_id): - * pcs/cal-backend.c (cal_backend_get_uid_by_pilot_id): - (cal_backend_update_pilot_id): server code to service these: - - * gui/calendar-pilot-sync.c: updated to make use of cal-client. - also uses dirty bits on both sides to aid in syncing. - - * cal-client/cal-client.c (cal_client_get_uid_by_pilot_id): new - function -- ask the cal server to return uid given an object's - pilot id. - (cal_client_update_pilot_id): new function -- inform the - cal server of an objects pilot id and pilot dirty-flag. - -2000-06-28 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/cal-component.[ch]: New files for the new iCalendar - component object. Today's properties: basic component type, UID, - SUMMARY. - - * cal-util/Makefile.am: Added cal-component.[ch] to the list of - sources. - -2000-06-27 Michael Meeks <michael@helixcode.com> - - * pcs/Makefile.am (INCLUDES): use BONOBO_VFS_GNOME_CFLAGS. - -2000-06-26 Christopher James Lahey <clahey@helixcode.com> - - * gui/calendar-model.c: Added an #ifdefed value_to_string handler - assignment. - -2000-06-26 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (calendar_model_duplicate_value): - Implement. - (calendar_model_initialize_value): Implement. - (calendar_model_value_is_empty): Implement. - -2000-06-21 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view.c (e_day_view_reshape_long_event): set event before - using it! - (e_day_view_init): used new colors from tigert. - -2000-06-21 Christopher James Lahey <clahey@helixcode.com> - - * gui/e-day-view.c, gui/e-week-view.c: Remove the usage of the "x" - and "y" arguments. - -2000-06-21 Damon Chaplin <damon@helixcode.com> - - * gui/gnome-cal.c (gnome_calendar_direction): changed so it keeps the - selection range. It just moves it on one day/week etc. This makes - it very handy for the keyboard shortcut code. - - * gui/calendar-commands.c (calendar_control_activate): fixed bug - setting the radio button active. - - * gui/e-day-view.[hc]: added support for keyboard navigation and - selection of the time range. - -2000-06-20 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (calendar_model_set_value_at): Implemented. - (calendar_model_is_cell_editable): Implemented. - - * cal-client/cal-client.c (cal_client_update_object): Take in an - iCalObject instead of a stringified version. - - * gui/gnome-cal.c (gnome_calendar_update_object): Removed. - (gnome_calendar_remove_object): Removed. - (save_ical_object_cb): Use the CalClient function. - - * gui/e-day-view.c (e_day_view_on_delete_occurrence): Likewise. - (e_day_view_on_unrecur_appointment): Likewise. - (e_day_view_finish_long_event_resize): Likewise. - (e_day_view_finish_resize): Likewise. - (e_day_view_key_press): Likewise. - (e_day_view_on_editing_stopped): Likewise. - (e_day_view_on_top_canvas_drag_data_received): Likewise. - (e_day_view_on_main_canvas_drag_data_received): Likewise. - (e_day_view_on_delete_appointment): Likewise. - - * gui/e-week-view.c (e_week_view_on_editing_stopped): Likewise. - (e_week_view_key_press): Likewise. - (e_week_view_on_delete_occurrence): Likewise. - (e_week_view_on_unrecur_appointment): Likewise. - (e_week_view_on_delete_appointment): Likewise. - - * gui/gncal-todo.c (ok_button): Likewise. - (delete_todo): Likewise. - -2000-06-19 Damon Chaplin <damon@helixcode.com> - - * gui/event-editor-dialog.glade: tidied up dialog a bit, adding - space etc. - - * gui/e-week-view.c (e_week_view_reshape_events): removed debug msg. - -2000-06-18 Ettore Perazzoli <ettore@helixcode.com> - - * cal-util/Makefile.am (INCLUDES): Include from - `$(top_builddir)/libical/src/libical' too. [For the generated - libical `icalversion.h' header.] - * cal-client/Makefile.am (INCLUDES): Likewise. - -2000-06-18 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view.c (e_day_view_on_top_canvas_drag_data_received): - fixed a DnD bug. - -2000-06-17 Dan Winship <danw@helixcode.com> - - * cal-client/Makefile.am (INCLUDES): Fix to not depend on - installed ical.h - -2000-06-17 Damon Chaplin <damon@helixcode.com> - - * gui/e-week-view.c: added little buttons which are shown when there - are more events than will fit in a day. Clicking on the button takes - the user to the 1-Day view and shows the full day. - - * gui/e-day-view.c: - * gui/e-week-view.c: set the "use_ellipsis" arg to TRUE for the EText - items so we get tooltips automatically. Though we may want to use our - own code to show tooltips so we can show the tips when the mouse is - around the edges of the event box, and we may want to show the start - and end times of the event in full. - - * gui/calendar-commands.c (calendar_control_activate): - * gui/gnome-cal.h: added view_toolbar_buttons[] so we can access the - radio buttons in the code easily. We need this if we want to jump to - another view programmatically. - -2000-06-16 Damon Chaplin <damon@helixcode.com> - - * gui/jump.xpm: new icon for the EWeekView to jump to the day. - - * gui/Makefile.am (EXTRA_DIST): added jump.xpm - -2000-06-16 Damon Chaplin <damon@helixcode.com> - - * gui/calendar-model.c (calendar_model_class_init): #ifdef'ed out - references to functions which don't exist yet, so evolution still - compiles. - -2000-06-16 Damon Chaplin <damon@helixcode.com> - - * cal-util/test-recur.c: updated. - - * cal-util/cal-recur.[hc]: mostly finished, though it depends on the - iCalObject struct being updated to support more of iCalendar. - -2000-06-16 Damon Chaplin <damon@helixcode.com> - - * pcs/.cvsignore: added icalendar-test. - -2000-06-15 Damon Chaplin <damon@helixcode.com> - - * cal-util/Makefile.am (test_recur_LDADD): use libical.a - -2000-06-15 Dan Winship <danw@helixcode.com> - - * cal-util/Makefile.am (noinst_PROGRAMS): merge the two separate - noinst_PROGRAMS declarations into one so automake accepts it. - (INCLUDES): include libical src dir so we don't depend on having - ical.h already installed - -2000-06-14 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c: GPtrArray cannot insert stuff in the - middle of the array (!), so use plain GArray everywhere. Sigh. - -2000-06-13 Federico Mena Quintero <federico@helixcode.com> - - * cal-client/cal-client.c (cal_client_get_object): Use vCalendar - again. - - * cal-util/calobj.c (ical_object_find_in_string): From Seth, make - it use vCalendar again. - -2000-06-13 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (obj_updated_cb): Juggle some eggs in - asynchronous fashion. Finished implementing. - (obj_removed_cb): Implemented. This one needs no juggling. - (calendar_model_set_cal_client): Only load the objects if we have - a client. - (calendar_model_destroy): Disconnect from the client's signals. - - * gui/Makefile.am (evolution_calendar_SOURCES): Added - calendar-model.[ch] to the list of sources. - - * pcs/cal-backend-imc.c (cal_backend_imc_get_n_objects): Doh, - return the computed value. - -2000-06-13 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-model.c (CalendarModelPrivate): Added the array of - objects and the hash table of UID->array index. - (calendar_model_row_count): Return the length directly from the - array instead of asking the Wombat. - (calendar_model_value_at): Implemented. - (calendar_model_new): Create an empty model. We provide a new - setter function now. - (calendar_model_construct): Removed function. - (calendar_model_set_cal_client): New function to set the calendar - client and object type at any time. This lets us reuse a calendar - model object. - - * cal-util/calobj.h (iCalObjectField): Just report whether the - object has alarms; not every single alarm. - -2000-06-13 Ettore Perazzoli <ettore@helixcode.com> - - * gui/Makefile.am (SHELL_OBJS): Removed. - (evolution_calendar_LDADD): Link with - `$(top_builddir)/shell/libeshell.a'. - -2000-06-09 Ettore Perazzoli <ettore@helixcode.com> - - * gui/component-factory.c (factory_fn): Pass NULL for the new args - @create_folder_fn and @remove_folder_fn. - (create_view): Updated to match the new - `EvolutionShellComponentCreateViewFn'. Return - `EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE' if type is not - "calendar". - -2000-06-09 Federico Mena Quintero <federico@helixcode.com> - - * idl/evolution-calendar.idl (Cal): Added a get_n_objects() - method. - - * pcs/cal-backend.c (cal_backend_get_n_objects): New function. - - * pcs/cal-backend-imc.c (cal_backend_imc_get_n_objects): - Implemented. - - * pcs/cal.c (Cal_get_n_objects): Implemented. - - * cal-client/cal-client.c (cal_client_get_uids): Free the ev. - (cal_client_get_n_objects): Implemented. - - * cal-util/calobj.h (iCalObjectField): New enumeration to identify - the fields in an iCalObject. - -2000-06-08 Federico Mena Quintero <federico@helixcode.com> - - * gui/event-editor.c (event_editor_destroy): Free the private - structure. - -2000-06-08 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/calobj.c (ical_object_to_vobject): Allow for NULL - summaries. - -2000-06-07 Federico Mena Quintero <federico@helixcode.com> - - * gui/event-editor.c (toolbar): Added missing tooltips. We still - need icons, though. - -2000-06-07 Seth Alves <alves@hungry.com> - - * cal-util/calobj.c (ical_object_find_in_string): put this back in, - it's still used in cal-backend-imc.c:cal_backend_imc_update_object - - * cal-client/cal-client.c (cal_client_get_object): instead of - returning a text representation, decode the text and return an - iCalObject. Also added CalClientGetStatus which indicates - success or type of failure. - - * cal-util/calobj.c (ical_object_find_in_string): #ifed out - ical_object_find_in_string since it is unused now. - - * cal-client/client-test.c (list_uids): track get_object change - * gui/calendar-commands.c (calendar_iterate): same - * gui/e-day-view.c (e_day_view_update_event): same - * gui/e-week-view.c (e_week_view_update_event): same - * gui/print.c (print_day_details): same - (print_day_summary): same - (print_todo_details): same - * gui/gnome-cal.c (trigger_alarm_cb): same - * gui/gncal-todo.c (gncal_todo_update): same - -2000-06-06 Seth Alves <alves@hungry.com> - - * cal-util/icalendar.c, icalendar-save.c: fixed a bunch of problems - * cal-util/calobj.c (ical_object_find_in_string): use libical - instead of libversit - (ical_object_to_string): same - (dump_icalobject): prints the contents of an icalobject for debugging - - * gui/Makefile.am (LINK_FLAGS): link libical.a instead of libical.la - so we don't have to modify the build system of the released libical - * cal-client/Makefile.am (client_test_LDADD): same - * cal-util/Makefile.am (icalendar_test_LDADD): same - -2000-06-06 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/calobj.c (ical_object_destroy): Removed from the public - header; made static. Now everyone should use refcounting. - - * pcs/cal-backend-imc.c (free_ical_object): Use - ical_object_unref(). - (remove_object): Likewise. - -2000-06-02 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-commands.c (print): New function to call the print - engine. - (calendar_toolbar): Added the Print button. - (calendar_control_activate): Added the File/Print item. - - * gui/e-day-view.c (e_day_view_get_selected_time_range): Allow - start_time and end_time to be NULL. - - * gui/e-week-view.c (e_week_view_get_selected_time_range): - Likewise. - - * gui/print.c (range_selector_new): Show the range selector - widgets. Use the correct radio group for all of them! - (print_calendar): Do the dialog box here. We may want to split - this function later into smaller chunks. - -2000-06-05 Damon Chaplin <damon@helixcode.com> - - * gui/e-week-view-event-item.c (e_week_view_event_item_button_press): - allow the right button to popup the menu, even when the event is - being edited. - - * gui/e-week-view.c: - * gui/e-day-view.c: Set the keyboard focus to the EDayView/EWeekView - when the right button is clicked, so that any event being edited is - saved before any action (e.g. opening the Event Editor dialog) is - started. Note that this won't work if we switch to asynchronous - notification. - -2000-06-02 Federico Mena Quintero <federico@helixcode.com> - - * gui/event-editor.c (tb_save_and_close_cb): Implemented. - (toolbar): Added an icon for the Save and Close command. - (save_ical_object): Recompute the title of the window here. Maybe - it would be better to do it when we actually get the - "object_changed" signal from the CalClient. - (file_close_cb): Implemented. - -2000-06-02 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (save_ical_object_cb): Implemented. - (gnome_calendar_add_object): Removed function, since it was - identical to gnome_calendar_update_object(). Modified the rest - of the code to use only the latter. - (gnome_calendar_remove_object): Be more paranoid about the UID. - (gnome_calendar_update_object): Ditto. Also, renamed this - function from gnome_calendar_object_changed(), for consistency - with the lower-level CalClient interface. - - * gui/event-editor.c (event_editor_class_init): New - "save_ical_object" signal to ask that our parent store the - calendar object to the backend. - (save_ical_object): New function to save the calendar object, - actually if just emits the signal. - (file_save_cb): Implemented. - (dialog_to_ical_object): We want priv-> - alarm_program_run_program_entry (i.e. the entry inside the - GnomeFileEntry), not the file entry itself. - (dialog_to_ical_object): Only insert the recurrence ending date if - the event is recurrent! - -2000-06-02 Christopher James Lahey <clahey@helixcode.com> - - * gui/Makefile.am: Fixed EXTRA_DIST. - -2000-06-01 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (editor_closed_cb): Handler for the - "editor_closed" signal of the event editor; we just destroy it - then. - - * gui/event-editor.c (app_delete_event_cb): Callback used when the - dialog is closed. Release the iCalObject here instead of the - event editor's destroy handler, and emit the new "editor_closed" - signal. - -2000-06-01 Federico Mena Quintero <federico@helixcode.com> - - * gui/event-editor-dialog.glade: Change of plans. The toplevel - GnomeApp is now generated with Glade instead of being created in - the program code. Otherwise we can't migrate the accelerators to - the new toplevel and they won't work. - - * gui/event-editor.[ch]: EventEditor now derives from GtkObject. - This lets us use the GnomeApp created by libglade and still have - signals and stuff. - - * gui/event-editor.c (create_menu): Tell the UI handler that the - menubar is the GnomeApp's existing one, not to create a new one. - (create_toolbar): Tell the UI handler to use the GnomeApp's - existing toolbar. - (event_editor_focus): New function to raise/focus an event editor. - - * gui/gnome-cal.c (gnome_calendar_edit_object): Use - event_editor_focus(). - -2000-06-01 Ettore Perazzoli <ettore@helixcode.com> - - * gui/calendar-commands.c (calendar_control_activate): Put the - toolbar into a frame to make it look like standard GNOME toolbars. - Also, set `GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL' so that it does not - do evil things when its moved to the left or the right of the - window. - -2000-05-31 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.h (GnomeCalendar): Added a hash table to map - calendar objects to their respective event editors. - - * gui/gnome-cal.c (gnome_calendar_init): Create the - object_editor_hash. - (gnome_calendar_destroy): Free the object_editor_hash. - (gnome_calendar_edit_object): New function to centralize the - launching of event editors; if one already exists for a particular - calendar object, we just raise its window. - (edit): Use gnome_calendar_edit_object(). - - * gui/calendar-commands.c (display_objedit): Use - gnome_calendar_edit_object(). - (display_objedit_today): Likewise. - - * gui/e-day-view.c (e_day_view_on_new_appointment): Likewise. - (e_day_view_on_edit_appointment): Likewise. - - * gui/e-week-view.c (e_week_view_on_new_appointment): Likewise. - (e_week_view_on_edit_appointment): Likewise. - - * gui/event-editor.c (event_editor_new): Do not take in an - iCalObject; rather provide an event_editor_set_ical_object() - function. We need this because a single editor may be switched - between different calendar objects. Also, do not show the event - editor; leave it up to the client code. - (event_editor_construct): Likewise. - (clear_widgets): New function to clear the widgets to default - values. - (fill_widgets): New function to fill in the widgets from the - iCalObject. We don't do this in init_widgets() anymore. - (free_exception_clist_data): New function to free the exceptions - clist data. We were leaking the row data. - (init_widgets): Hook to the destroy signal of the exceptions - clist. - (event_editor_set_ical_object): New function. Now it also makes a - copy of the calendar object for the event editor; clients do not - need to copy it anymore. - (event_editor_destroy): Unref the UI handler as well. - (event_editor_class_init): New "ical_object_released" signal to - notify the parent that we are no longer editing the calendar - object. - (make_title_from_ico): Handle NULL objects. - - * gui/event-editor.h (EventEditor): Removed fields that are no - longer used. - -2000-05-31 Damon Chaplin <damon@helixcode.com> - - * cal-util/Makefile.am: added test-recur test program. - - * cal-util/test-recur.c: new file to test the recurrence code. - - * cal-util/.cvsignore: added test-recur. - - * cal-util/cal-recur.c: updated. - -2000-05-30 Federico Mena Quintero <federico@helixcode.com> - - * gui/event-editor.c (event_editor_construct): Create the UI - handler after we have constructed the parent GnomeApp. - (main_menu): Menu template is now in place. - (toolbar): Tollbar template is now in place. - (create_toolbar): Turn off labels in the toolbar since it sucks; - it should support non-homogeneous buttons with horizontal icons - and text. - -2000-05-29 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (gnome_calendar_object_changed): Removed the - flags argument, since now we just proxy the calendar object to the - calendar client. - - * gui/event-editor.c (alarm_unit_get): Moved over from - event-editor-utils.c. - - * gui/event-editor-utils.[ch]: Removed files, since the two - functions that were left there (i.e. the ones not present in - e-dialog-widgets) can simply be moved to event-editor.c. - - * gui/Makefile.am (evolution_calendar_SOURCES): Removed - event-editor-utils.[ch] from the list of sources. - -2000-05-27 Federico Mena Quintero <federico@helixcode.com> - - * gui/event-editor-utils.c: Moved many functions to - e-util/e-dialog-widgets.c. - -2000-05-25 Federico Mena Quintero <federico@helixcode.com> - - * gui/event-editor-dialog.glade: Put the main notebook directly - under a simple GtkWindow. We are going to pull out the notebook - and slap it into our custom-built GnomeApp, anwyays. - - * gui/event-editor.c: Made the EventEditor derive from GnomeApp. - Added a BonoboUIHandler for its menu and toolbar. - (make_title_from_ico): Create a nice title for the window. - (get_widgets): Fetch the Glade widgets here instead of all over - the place. - (event_editor_new): Temporary hack to show the dialog here, just - so that I can test it. - - * gui/Makefile.am (EXTRA_DIST): Added the Glade messages file. - -2000-05-25 Federico Mena Quintero <federico@helixcode.com> - - * gui/main.c (init_bonobo): Do not initialize libglade twice. - - * gui/component-factory.c (create_view): Set the folder_uri - property, otherwise the calendar will not get loaded into the - view. - -2000-05-25 Christopher James Lahey <clahey@helixcode.com> - - * gui/main.c: Make it so that warnings don't crash calendar. - -2000-05-25 Ettore Perazzoli <ettore@helixcode.com> - - * gui/evolution-calendar-control.c: Removed. - - * gui/main.c: New. - - * gui/control-factory.c: New. - * gui/control-factory.h: New. - - * gui/calendar-component-factory.c: New. - * gui/calendar-component-factory.c: New. - - * gui/evolution-calendar-control.c (calendar_control_factory): - Renamed from `calendar_factory'. - (calendar_control_factory_init): Renamed from - `calendar_factory_init'. - - * gui/Makefile.am: Link with the files from `$(builddir)/shell'. - - * gui/evolution-calendar.gnorba: New. - * gui/evolution-calendar.oafinfo: New. - -2000-05-24 Federico Mena Quintero <federico@helixcode.com> - - * gui/print.c (range_selector_new): New function to create the - custom range selector. - (print_dialog): New function to show the print dialog. - (print_calendar): Use the print dialog. - -2000-05-24 Christopher James Lahey <clahey@helixcode.com> - - * gui/Makefile.am: Added libepaned.a. - - * gui/gnome-cal.c: Switched from GtkPaned to EPaned. - -2000-05-22 Federico Mena Quintero <federico@helixcode.com> - - * gui/calendar-commands.c (calendar_get_events_in_range): Removed - function. - - * gui/mark.c (mark_month_item): Use - cal_client_get_events_in_range(). - - * gui/calendar-commands.c (show_year_view_clicked): Comment out, - since we don't have a year view. - - * gui/gnome-cal.c (setup_widgets): Removed the year view stuff. - (gnome_calendar_get_current_view_name): Likewise. - (gnome_calendar_update_view_times): Likewise. - (gnome_calendar_direction): Likewise. - (gnome_calendar_set_view): Likewise. - (gnome_calendar_update_all): Likewise. - (gnome_calendar_object_updated_cb): Likewise. - (gnome_calendar_object_removed_cb): Likewise. - (gnome_calendar_time_format_changed): Likewise. - (gnome_calendar_get_current_time_range): Likewise. - - * gui/gnome-cal.h (GnomeCalendar): Removed the year view stuff. - - * gui/Makefile.am (evolution_calendar_SOURCES): Added layout.[ch], - print.[ch]. Removed quick-view.[ch], year-view.[ch] since they - are no longer used. Removed all the old Pilot crap. - -2000-05-20 Damon Chaplin <damon@helixcode.com> - - * cal-util/cal-recur.[hc]: new files to implement iCalendar recurrence - rules. These are only part finished, but people may like to check that - the architecture seems OK. - -2000-05-17 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view.c (e_day_view_on_delete_occurrence): - * gui/e-week-view.c (e_week_view_on_delete_occurrence): use a copy of - the iCalObject so we detect the change in the "update_event" callback. - Maybe we should just update the view ourselves and then we wouldn't - need to detect any change in the callback. - - * cal-util/calobj.c (ical_object_reset_recurrence): new function to - get rid of any recurrence rules. Used when we 'unrecur' an event. - - * gui/e-day-view.c (e_day_view_key_press): don't add a new event if it - won't fit, or we end up adding a new event for each key press. - (e_day_view_update_event_label): don't update it if it doesn't have - an EText item (i.e. it isn't visible). - - * gui/e-day-view-time-item.c: allow selection of times using this - column. - -2000-05-19 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/timeutil.c (time_add_minutes): Fixed warning message. - (time_add_day): Likewise. - (time_add_month): Likewise. - (time_add_year): Likewise. - (time_from_day): Of all functions, *this* one had to have a bug. - Set the tm.tm_isdst to -1 to specify that we don't know whether - the time is in DST or not. This fixes *many* bugs upstream. - (time_week_begin): Likewise. We never noticed this since the week - functions are never used. - (time_week_end): Likewise. - -2000-05-17 Seth Alves <alves@hungry.com> - - * gui/event-editor.c: hooked up more widget signals to callbacks - to the gladified dialog acts more like the original one. - -2000-05-16 Seth Alves <alves@hungry.com> - - * gui/event-editor.c (recurrence_toggled): hook the radio buttons - to the pages of the notebook. - (append_exception): - (recurrence_exception_added): - (recurrence_exception_deleted): - (recurrence_exception_changed): code to deal with the recurrence - exception list. - -2000-05-15 Seth Alves <alves@hungry.com> - - * gui/event-editor.[ch]: gladeified replacement for eventedit.c - - * gui/event-editor-utils.[ch]: utilities used by event-editor.c - - * gui/event-editor-dialog.glade: glade file used by event-editor.c - -2000-05-14 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (display_notification): Use the alarm - notification dialog. - (display_notification_cb): New callback for the result of the - alarm notification dialog. - - * gui/dialogs/alarm-notify.glade: New file with the alarm - notification dialog. - - * gui/dialogs/alarm-notify-dialog.[ch]: New file. - - * gui/dialogs/Makefile.am: New file. - - * gui/Makefile.am (SUBDIRS): Added the dialogs directory. - -2000-05-13 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (trigger_alarm_cb): Better error checking, and - plug leaks of str_ico and ico. - - * gui/evolution-calendar-control.c (main): Initialize libglade. - -2000-05-13 Ettore Perazzoli <ettore@helixcode.com> - - * pcs/Makefile.am (INCLUDES): Add - `-I$(top_builddir)/libical/src/libical'. - -2000-05-12 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/calobj.c (generate): Use a (dtend - dtstart) offset to - compute the ending time of the occurrence. This takes care of - recurring events that span multiple days. Also, removed the DST - condition since it did not look right at all: if you have a daily - appointment at 18:00, it still should happen at 18:00 even during - daylight savings. - - * gui/gnome-cal.c (gnome_calendar_tag_calendar): Use the timeutil - functions instead of calculating the month's times by hand. Use - cal_obj_instance_list_free() instead of freeing the list by hand. - Clip the range we pass to mark_gtk_calendar_day(). - (mark_gtk_calendar_day): Fixed off-by-one error at the end of the - month by adding real day offsets. - -2000-05-11 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (add_alarms_for_object): New function to add - today's alarms for a single object. - (gnome_calendar_object_updated_cb): Update the object's alarms. - - * idl/evolution-calendar.idl (Cal): Added a - get_alarms_for_object() method. - - * pcs/cal.c (Cal_get_alarms_for_object): Implemented method. - - * pcs/cal-backend.c (cal_backend_get_alarms_for_object): New - function. - - * pcs/cal-backend-imc.c (cal_backend_imc_get_alarms_for_object): - Implemented. - - * cal-client/cal-client.c (cal_client_get_alarms_for_object): New - function. - -2000-05-11 Dan Winship <danw@helixcode.com> - - * gui/calendar-commands.c (calendar_control_activate): Now that we - depend on current gnome-libs we can make the toolbar detachable - again. - - * pcs/icalendar-save.c (timet_to_icaltime): remove unused timezone - variable to make this compile on BSD systems (where timezone is - the name of a function) - -2000-05-11 Federico Mena Quintero <federico@helixcode.com> - - * gui/gnome-cal.c (gnome_calendar_update_all): Removed unused - arguments. Load the initial alarms here. - (load_alarms): New function to load a day's worth of alarms. - (gnome_calendar_class_init): Eeeek! This was taking in an - incorrect argument type. - (gnome_calendar_init): Now the calendar keeps a hash table of - UIDs->queued alarms. Create the hash table here. - (gnome_calendar_destroy): Destroy the alarms hash table. - (gnome_calendar_object_updated_cb): Remove the alarms for the - object and regenerate them. - (gnome_calendar_object_removed_cb): Remove the alarms for the - object. - - * gui/alarm.c (alarm_add): Do not take in a CalendarAlarm, just - the trigger time, the callback and the closure data. Return an - opaque identifier for the alarm so that it can be removed by the - client code if needed. Use the queue_alarm() helper function. - (queue_alarm): Helper function to actually queue the alarm and set - up the itimer. Deal with a nonzero return value from - setitimer(). - (alarm_remove): New function to remove an alarm based on its ID. - (pop_alarm): New helper function; pops the first alarm of the - queue and resets the timer as appropriate. - (alarm_ready): Simplified a lot by using pop_alarm(). - - * idl/evolution-calendar.idl (Cal): Added get_alarms_in_range(). - - * pcs/cal.c (build_instance_seq): New function to build a CORBA - sequence from the internal list of instances. - (Cal_get_events_in_range): Use build_instance_seq(). - (Cal_get_alarms_in_range): Implemented new method. - - * pcs/cal-backend.c (cal_backend_get_alarms_in_range): New - function with the get_alarms_in_range() engine. - - * pcs/cal-backend-imc.c (cal_backend_imc_get_alarms_in_range): - Implemented the get_alarms_in_range() method. - - * cal-client/cal-client.c (cal_client_get_alarms_in_range): New - client-side function for getting the alarms. - (build_instance_list): New helper function to build the - CalObjInstance list from the CORBA sequence. - (cal_client_get_events_in_range): Use build_instance_list(). - - * gui/calendar-commands.h: #include <cal-util/calobj.h>. #include - "gnome-cal.h". - - * gui/e-week-view.c: #include "calendar-commands.h" instead of - main.h; the latter is an obsolete file and will be killed. - - * gui/evolution-calendar-control.c (main): Call init_bonobo() - before anything else. We need the GTK+ object system initialized. - - * gui/Makefile.am (evolution_calendar_SOURCES): Do not use main.h. - - * cal-util/cal-util.c (cal_alarm_instance_list_free): New function. - -2000-05-10 Matt Loper <matt@helixcode.com> - - * gui/calendar-commands.c (calendar_control_activate): Move - "about" menuitem to the help menu. - -2000-05-10 Christopher James Lahey <clahey@helixcode.com> - - * gui/Makefile.am: Added main.h. Combined the two EXTRA_DIST - sections. - -2000-05-09 Christopher James Lahey <clahey@helixcode.com> - - * pcs/cal-backend-imc.c: Set the format when creating a new - calendar. - -2000-05-09 Christopher James Lahey <clahey@helixcode.com> - - * pcs/cal-factory.c: Removed double free of method_string in - uri->method_string. - -2000-05-08 Ettore Perazzoli <ettore@helixcode.com> - - * pcs/cal.h: Include "calendar/pcs/evolution-calendar.h" instead - of "evolution-calendar.h". - - * pcs/cal-backend.h: Include "calendar/pcs/evolution-calendar.h" - instead of "evolution-calendar.h". - -2000-05-08 Seth Alves <alves@hungry.com> - - * gui/e-day-view.c (e_day_view_on_delete_appointment): call - e_day_view_stop_editing_event here to avoid a divide by zero - a bit further on. i'm not sure if this is the best fix for this. - -2000-05-08 Federico Mena Quintero <federico@helixcode.com> - - * pcs/cal-backend.h (CalBackendClass): CalBackendClass now is just - an interface for calendar backends; this is an abstract class. - Put in the vtable for the backend methods. - - * pcs/cal-backend.c (cal_backend_new): Removed function, since - CalBackend is not just an abstract class. - Removed implementation-specific functions and made public - functions call the virtual methods instead. - - * pcs/cal-backend-imc.[ch]: New files with the CalBackendIMC - implementation; this implements a backend for iCalendar and - vCalendar files. Moved the implementation-specific stuff from - cal-backend.[ch] to here. - - * pcs/cal-backend-imc.c (CalendarFormat): Moved enumeration to - here. Added a CAL_UNKNOWN value for when the backend is not - loaded yet. - (cal_backend_imc_init): Initialize priv->format as CAL_UNKNOWN. - (save_to_vcal): Use the same VCProdIdProp value as in - cal-util/calobj.c. Use "1.0" as the VCVersionProp as per the - vCalendar spec. - (ensure_uid): Return nothing, since the result value need not be - used anymore. - (add_object): Since we mark the calendar as dirty anyways, we do - not need to check the result value of ensure_uid() anymore. - (remove_object): Asssert that we know how to handle the object's - type. We do this in add_object() anyways. - - * pcs/Makefile.am (libpcs_a_SOURCES): Added cal-backend-imc.[ch]. - - * gui/gnome-cal.c: Replaced debugging printf()s with g_message() - so that we can see the line number where they occur. - - * gui/gnome-cal.c (gnome_calendar_load_cb): Sort of handle the - LOAD_METHOD_NOT_SUPPORTED result code, and added a default for the - switch. - - * cal-client/cal-listener.h (CalListenerLoadStatus): Removed - enumeration; it is stupid to translate all values for the - CalClient when it is going to translate them again. - (CalListenerClass::cal_loaded): This signal now passes the - LoadStatus directly from the CORBA side. - - * cal-client/cal-listener.c (Listener_cal_loaded): Do not - translate the status value. - - * cal-client/cal-client.h (CalClientLoadStatus): Added the - CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED error code. - - * cal-client/cal-client.c (cal_loaded_cb): Translate the CORBA - version of the LoadStatus result code. - - * pcs/cal-factory.c (CalFactoryPrivate): New methods field for the - hash table from method strings to the GtkTypes for backend class - types. - (cal_factory_init): Create the priv->methods hash table. - (cal_factory_destroy): Free the priv->methods hash table. - (cal_factory_register_method): New function to register a backend - class for a particular URI method. - (launch_backend_for_uri): New function to launch a backend for a - particular URI's method. - (load_backend): Use launch_backend_for_uri(). Move the error - notification code from load_fn() to here. - (create_backend): Use launch_backend_for_uri(). Move the error - notification code form create_fn() to here; it is #ifdefed out - since currently cal_backend_create() does not have any error - reporting capabilities. - - * idl/evolution-calendar.idl (Listener::LoadStatus): Added a - PROTOCOL_NOT_SUPPORTED error code. - - * pcs/cal-factory.c (cal_factory_load cal_factory_create): Removed - functions, since they were supposed to be internal only. - (CalFactory_load): Call queue_load_create_job() directly. - (CalFactory_create): Likewise. - -2000-05-08 Damon Chaplin <damon@helixcode.com> - - * gui/e-week-view.c (e_week_view_remove_event_cb): - * gui/e-day-view.c (e_day_view_remove_event_cb): don't set the ico->uid - to NULL or we won't find any other occurrences of the event. Set the - editing_event_day/num to -1 instead. - - * gui/e-week-view-event-item.c (e_week_view_event_item_draw): fixed the - positioning of the icons for long events. - - * cal-util/calobj.c (ical_object_normalize_summary): forgot to - terminate the string. - -2000-05-07 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view.c (e_day_view_on_main_canvas_drag_data_received): - (e_day_view_on_top_canvas_drag_data_received): show the EText item, - just in case it hasn't moved, otherwise it won't appear. - - * gui/e-day-view.h (E_DAY_VIEW_BAR_WIDTH): increased from 6 to 8 to - make it easier to drag an event. Also increased E_DAY_VIEW_GAP_WIDTH - since it must be >= the BAR_WIDTH. - -2000-05-07 Matt Loper <matt@helixcode.com> - - * gui/evolution-calendar-control.c (PROPERTY_CALENDAR_URI): - Changed to "folder_uri" from "calendar_uri". - (set_prop): The uri given to us is a directory, so we append a - filename onto the end before we use it. - -2000-05-06 Damon Chaplin <damon@helixcode.com> - - * cal-util/timeutil.c (time_day_begin): - (time_day_end): changed these so they just do a simple localtime(), - update the struct tm, then do a mktime(). I don't know why it used to - look at the tm_isdst flags etc. From a little test program I wrote - which steps through testing every hour for a year it wasn't working - correctly, and the new code does. - (time_add_day): also got rid of the stuff that looked at tm_isdst here. - My test program now works better. - -2000-05-06 Chris Toshok <toshok@helixcode.com> - * gui/.cvsignore: ignore evolution-calendar.pure - - * gui/Makefile.am: add support for building evolution-calendar.pure - -2000-05-06 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view.c: - * gui/e-week-view.c: finish editing event when user hits Return key. - (e_week_view_on_text_item_event): stop event signals after doing any - other calls, since otherwise it will also stop any other resulting - event signals. - - * gui/e-week-view-event-item.c (e_week_view_event_item_draw): don't - draw the start/end times while editing. - - * gui/eventedit.c: changed the Summary field to a GtkEntry, since we - now only want a single line of text. - - * cal-util/calobj.c (ical_object_normalize_summary): new function to - convert the summary field to a single line of text, by converting any - sequence of CR & LF characters to a single space. - (ical_object_create_from_vobject): call the above function. I think - all functions that load iCalObjects go through this. - (ical_new): called it here as well just in case. - -2000-05-06 Damon Chaplin <damon@helixcode.com> - - * gui/week-view.[hc]: removed. - -2000-05-06 Damon Chaplin <damon@helixcode.com> - - * gui/gncal-day-panel.[hc]: - * gui/gncal-day-view.[hc]: - * gui/gncal-full-day.[hc]: - * gui/gncal-week-view.[hc]: - * gui/layout.[hc]: - * gui/view-utils.[hc]: removed old calendar view files. - -2000-05-06 Damon Chaplin <damon@helixcode.com> - - * cal-util/calobj.[hc]: added guint ref_count to iCalObject struct, - and ical_object_ref/unref() functions. I've updated all the gui/ - stuff to use ref_counts but I haven't touched the pcs/ stuff. Maybe - just using ical_object_destroy() is OK there. - - * gui/gncal-todo.c: - * gui/calendar-commands.c: - * gui/eventedit.c: - * gui/e-week-view.c: - * gui/e-day-view.c: use refcounting for iCalObjects. - - * gui/e-day-view-main-item.c: - * gui/e-day-view-top-item.c: - * gui/e-day-view.c: try not to ever draw outside the event, even when - the event is very small. - -2000-05-05 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view.c: don't allow recurring events to be resized or - dragged, and don't show the resize/drag cursors. Actually it may be - better to let the user do the resize/drag and then ask them what they - want to do - change the single occurrence or the entire series. - - * gui/e-day-view-time-item.c (e_day_view_time_item_show_popup_menu): - use e_auto_kill_popup_menu_on_hide() to destroy the popup menu. - - * gui/popup-menu.c: include e-gui-utils.h - -2000-05-04 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view.c (e_day_view_foreach_event_with_uid): for the long - events pass E_DAY_VIEW_LONG_EVENT as the day. Fixes SEGV. - - * gui/calendar-commands.c: when we switch views, grab the focus. - - * gui/gnome-cal.c (gnome_calendar_tag_calendar): - (gnome_calendar_mark_gtk_calendar_day): changed this so it uses - cal_client_get_events_in_range(), and doesn't load any objects. - Also just return if it isn't visible. - - * gui/calendar-commands.c (calendar_get_events_in_range): call - g_list_sort() to sort the list rather than g_list_insert_sorted() for - each element. It is much more efficient. - Also changed it so that the co->ev_start/end fields are copied from - the CalObjInstance rather than the parameters to the function - (that is right, isn't it?) - Also freed the list elements, and finally the list. - (calendar_iterate): changed this to use cal_client_get_events_in_range - since that is more efficient than getting all the uids and then loading - and parsing all the events. - - * pcs/cal-backend.c (save): output the '... saved' message before - freeing the string! - - * gui/gncal-todo.c (gncal_todo_update): - * gui/e-week-view.c (e_week_view_update_event): - * gui/e-day-view.c (e_day_view_update_event): - * gui/calendar-commands.c (calendar_get_events_in_range): - (calendar_iterate): free obj_string after it is parsed. - -2000-05-02 Damon Chaplin <damon@helixcode.com> - - * gui/calendar-commands.c (calendar_control_activate): set the active - radio button here. Oops - it wasn't a Bonobo problem after all. - - * gui/popup-menu.c (popup_menu): added call to - e_auto_kill_popup_menu_on_hide() to destroy the menu. - - * gui/e-week-view.c (e_week_view_show_popup_menu): - * gui/e-day-view.c (e_day_view_on_event_right_click): ico->user_data - isn't useful any more, since the event editor keeps its own iCalObject. - So for now we make the menu commands available even when the event is - being edited in the event editor. - Also corrected misspellings of 'occurance' -> 'occurrence'. - - * gui/eventedit.c (event_editor_destroy): destroy the iCalObject. - The event editor now uses its own independent iCalObject. - - * gui/e-week-view.c (e_week_view_on_unrecur_appointment): - * gui/e-day-view.c (e_day_view_on_unrecur_appointment): create a new - uid for the new single instance. I'm not sure what we should do about - the creation/last modification times of the objects. - - * gui/e-week-view.c (e_week_view_on_edit_appointment): - * gui/e-day-view.c (e_day_view_on_edit_appointment): duplicate the - iCalObject before passing it to the event editor, since it will change - the fields. If we don't duplicate it we won't know what has changed - when we get the "update_event" callback. - - * gui/e-week-view.c (e_week_view_key_press): - * gui/e-day-view.c (e_day_view_key_press): set the created and last_mod - times of the new iCalObject. We may want to set the default alarm as - well. - - * cal-util/calobj.c (ical_gen_uid): made this function public so we - can generate new uids if necessary. - -2000-05-01 Damon Chaplin <damon@helixcode.com> - - * gui/gnome-cal.[hc] (gnome_calendar_get_current_time_range): new - function to get the currently seleted time range form the current view. - - * gui/calendar-commands.c (display_objedit): use the above function - to get the time for the new appointment. - - * gui/e-week-view.c: - * gui/e-day-view.c: use a shallow copy of the ico when we update the - times (when resizing/dragging). Otherwise we won't detect that the - time has changed in the "update_event" callback. - - Also added functions to get the currently selected time range. - -2000-04-30 Seth Alves <alves@hungry.com> - - * pcs/icalendar-save.c (icalcomponent_create_from_ical_object): set - attendee and contact address correctly. - - * pcs/cal-backend.c (icalendar_calendar_load): init priv->object_hash - when loading. - (cal_get_type_from_filename): if file extension is .ical, consider - the file an ical file. - -2000-05-01 Damon Chaplin <damon@helixcode.com> - - * cal-util/calobj.c (ical_object_compare_dates): new function to see - if the event dates have changed (including any recurrence rules). - It is used for optimization when we get the "object_changed" signal. - We have to do far less work if the dates are unchanged. - - * gui/e-week-view.c: - * gui/e-day-view.c: only draw the selection when we have the keyboard - focus, since the user expects to be able to type in a new event when - the selection is shown. Also keep the selection when we lose focus, - but just don't show it. - - Also quite a few changes to cope with the new client/server - architecture. - - * gui/e-day-view-top-item.c (e_day_view_top_item_draw): - * gui/e-day-view-main-item.c (e_day_view_main_item_draw): - * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day): - only draw the selection if the widget has the keyboard focus. - - * gui/gnome-cal.c (mark_gtk_calendar_day): fixed so it works with - events longer than one day. And changed the code for updating events - in the new views. - -2000-04-27 Ettore Perazzoli <ettore@helixcode.com> - - * gui/evolution-calendar-control.c - (init_bonobo): OAFized. - - * gui/main.c (main): Initialize with OAF if `USING_OAF'. - - * gui/evolution-calendar-control.c: New #define - `CONTROL_FACTORY_ID', varying according to whether we are - `USING_OAF'. - (calendar_factory_init): Use `CONTROL_FACTORY_ID'. - - * gui/Makefile.am: Updated for OAF. - - * pcs/cal-factory.h: Explicitly #include - "calendar/pcs/evolution-calendar.h" instead of just - "evolution-calendar.h". - - * cal-client/cal-client.c (cal_client_construct) [USING_OAF]: Use - OAF. - - * cal-client/client-test.c (init_corba): New function, implemented - differently depending on `USING_OAF'. - -2000-04-27 <alves@hungry.com> - - * pcs/cal-backend.c (cal_backend_load): fix memory leak - (save_to_vcal): same - (save): same - (cal_backend_load): same - -2000-04-26 Christopher James Lahey <clahey@helixcode.com> - - * cal-util/.cvsignore: Replaced libcal-util.la with *.la - - * pcs/.cvsignore: Added *.la and *.lo. - -2000-04-25 Federico Mena Quintero <federico@helixcode.com> - - * pcs/cal-factory.c (backend_last_client_gone_cb): Renamed from - backend_destroy_cb. Now we use it for the "last_client_gone" - signal from the backend. Also, unref the backend to destroy it. - (add_backend): Connect to the "last_client_gone" signal of the - backend. - (cal_factory_get_n_backends): New function to query the number of - running backends. - - * pcs/cal-backend.c (cal_backend_class_init): Register the new - "last_client_gone" signal. It is emitted when the last Cal client - goes away. It is used to notify the factory when a backend may be - safely destroyed. - (cal_destroy_cb): Emit the "last_client_gone" signal when the last - client disconnects from the backend. - -2000-04-25 Seth Alves <alves@hungry.com> - - * gui/e-day-view.c (e_day_view_find_event_from_ico): compare - iCalObjects by their UIDs instead of by their pointers. - - * pcs/cal-backend.c (cal_backend_destroy): don't save on destroy. - -2000-04-25 Ettore Perazzoli <ettore@helixcode.com> - - * cal-client/Makefile.am: Add `$(datadir)/idl'. - - * pcs/Makefile.am (idl_flags): Add `$(datadir)/idl'. - (INCLUDES): Use `$(BONOBO_GNOME_CFLAGS)'. - -2000-04-25 Seth Alves <alves@hungry.com> - - * gui/gnome-cal.c (gnome_calendar_destroy): hook for widget - destroy -- used to unref the CalClient so wombat knows we are gone. - (gnome_calendar_class_init): added a class init for this widget. - - * gui/e-day-view.c (e_day_view_update_event): allow for null ico - - * gui/e-week-view.c (e_week_view_update_event): allow for null ico - -2000-04-24 Federico Mena Quintero <federico@helixcode.com> - - * cal-client/client-test.c (main): The path to the test calendar - changed when we moved stuff around. Users will have to tweak this - for their CVS setup, anyways. - (create_client): Create or load the calendar as appropriate. - (client_destroy_cb): Exit the main loop if both clients are gone. - (main): Connect to the "destroy" signal of the clients so that we - can terminate the test program. - -2000-04-24 Seth Alves <alves@hungry.com> - - * pcs/icalendar.c (parse_person): allow for null CN - (parse_person): allow for null sent_by - - * pcs/Makefile.am: build icalendar-test - - * pcs/icalendar-test.c: a test which loads an ical file and - converts it to our internal format, and then saves it back out. - -2000-04-24 Damon Chaplin <damon@helixcode.com> - - * gui/Makefile.am: added new source files and pixmaps, and removed - old source files, which can be deleted. - - * gui/e-week-view-titles-item.[hc]: - * gui/e-week-view-main-item.[hc]: - * gui/e-week-view-event-item.[hc]: - * gui/e-week-view.[hc]: new files implementing the week/month views. - - * gui/yearview.xpm: - * gui/monthview.xpm: - * gui/weekview.xpm: - * gui/workweekview.xpm: - * gui/dayview.xpm: new pixmaps for the toolbar buttons. These aren't - intended to be the final pixmaps. - - * gui/calendar-commands.c: added radio buttons to the toolbar to - switch between the calendar views, and moved the am_pm_flag here so we - can get rid of view-utils.c. - - * gui/gnome-cal.[hc]: made it a subclass of GtkVBox, rearranged the - widgets into 2 notebooks, and added the selection_start_time and - selection_end_time fields. - - * gui/goto.c: updated to use new selection time range. - - * gui/quick-view.c: added '#include <gtk/gtkwindow.h>' so it compiles. - - * gui/e-day-view.[hc]: changed the interface to support the new - selection time range, got rid of a few debugging messages and changed - a few bits. - -2000-04-21 Seth Alves <alves@hungry.com> - - * pcs/icalendar-save.c: start on code to do the opposite of - icalendar.c (convert from iCalObjects to libical's icalcomponents). - - * gui/calendar-commands.c (calendar_control_activate): moved - "About Calendar" into the View menu so it shows up. - -2000-04-20 Seth Alves <alves@hungry.com> - - * gui/gnome-cal.c (gnome_calendar_changed_cb): new function: callback - for listener's object updated signal. - (gnome_calendar_object_removed_cb): new function: callback for - listener's object removed signal. - (gnome_calendar_new): hook up listener's "obj_updated" and - "obj_removed" signals so if evolution is running twice, - they will both see changes right away. - (gnome_calendar_object_changed): don't call update_all, since - it will be called by the listener. - (gnome_calendar_remove_object): don't call update_all - (gnome_calendar_add_object): don't call update_all - - * gui/gncal-full-day.c (child_realize): create fullday's gcs - even if pixmap_bell has already been created. this was - causing crashes if the calendar was run twice. - -2000-04-19 Seth Alves <alves@hungry.com> - - * gui/eventedit.c (ee_rp_init_rule): changed the order around - a bit to avoid a Gtk-CRITICAL crash - - * gui/gncal-todo.c (gncal_todo_update): fixed code to populate - the todo clist - - * cal-client/cal-client.c (cal_client_get_uids): don't check - type against CALOBJ_TYPE_ANY since it will always match. - (cal_client_get_uids): same (re: CALOBJ_TYPE_ANY) - - * pcs/cal-backend.c (build_uids_list): same (re: CALOBJ_TYPE_ANY) - - * pcs/cal.c (Cal_get_uids): same (re: CALOBJ_TYPE_ANY) - - * pcs/cal-backend.c (remove_object): don't call save from here - because in all cases the caller of remove_object calls save - - * gui/calendar-commands.c (calendar_set_uri): calls gnome_calendar_open - instead of checking on disk and calling load or create. - - * gui/gnome-cal.c (gnome_calendar_object_changed): fixed to use - cal_client_update_object -- editing and dragging events works again - (gnome_calendar_open): collapsed gnome_calendar_load and - gnome_calendar_create into this function. added new type - GnomeCalendarOpenMode which has the value CALENDAR_OPEN or - CALENDAR_OPEN_OR_CREATE. - - * gui/evolution-calendar-control.c (calendar_properties_init): create - a property bag for this control - (set_prop): callback for property sets - (get_prop): callback for proprety gets - - * gui/calendar-commands.c (calendar_set_uri): new function, - called when the "calendar_uri" property is set on the calendar- - control's property bag. - -2000-04-18 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/Makefile.am (INCLUDES): Fix include path. - -2000-04-16 Federico Mena Quintero <federico@helixcode.com> - - * pcs/cal-factory.h (CalFactoryClass): We have a new - "last_calendar_gone" signal that Wombat can use to terminate - itself properly. - - * pcs/cal-factory.c (cal_factory_class_init): Register the - "last_calendar_gone" signal. - (backend_destroy_cb): Emit the "last_calendar_gone" signal instead - of killing the factory. - - * pcs/Makefile.am: Added $(CORBA_GENERATED) to BUILT_SOURCES. - (INCLUDES): Make the log domain be "wombat-pcs". - -2000-04-17 Seth Alves <alves@hungry.com> - - * pcs/cal-backend.c (add_object): removed implicit save, since - we don't want to save as we load from disk. - (cal_backend_update_object): added a call to save, since it - isn't done by add_object now. - -2000-04-16 Federico Mena Quintero <federico@helixcode.com> - - * cal-util/Makefile.am: Renamed library from libcalutil to - libcal-util, to be consistent with libcal-client. Install header - files in $(includedir)/evolution/cal-util. - (INCLUDES): Add "cal-util" log domain for glib. - (libcal_clientincludedir): The header files are now installed in - $(includedir)/evolution/cal-client. - - * cal-util/cal-util.h: Fix includes. - - * cal-client/client-test.c: Fix includes. - - * pcs/Makefile.am: Create libpcs.a, not a shared library, because - it is for internal use by Wombat only. The header files should - not be installed, either. Removed all the old Tlacuache stuff. - - * gui/Makefile.am (EXTRA_DIST): We no longer distribute - gncal.desktop. - (evolution_calendar_INCLUDES): Add "calendar-gui" for the glib log - domain. - - * gui/*.[ch]: Fix cal-util and cal-client includes. - - * pcs/Makefile.am (INCLUDES): Added "pcs" log domain for glib. - - * pcs/*.[ch]: Fix cal-util includes. - -2000-04-11 Chris Toshok <toshok@helixcode.com> - - * pcs/icalendar.c (icaltime_to_timet): use HAVE_TIMEZONE to switch - between linux's timezone variable and *bsd's method of getting the - gmt offset. - -2000-04-10 Seth Alves <alves@hungry.com> - - * pcs/cal-backend.c (save_to_vcal): create and save an actual - vcalendar instead of a list of vcal objects. - -2000-04-10 Damon Chaplin <damon@helixcode.com> - - * gui/Makefile.am (INCLUDES): moved srcdir directories to the top so - we search headers in the evolution tree before installed headers. - (Otherwise when you do 'make install' lots of files in gui/ get - rebuilt, since they depend on the installed cal-client.h which has just - been updated.) - -2000-04-09 Seth Alves <alves@hungry.com> - - * gui/gnome-cal.c (gnome_calendar_load): catch cal_loaded signal - on the cal client. - (gnome_calendar_load_cb): callback for cal_loaded signal. moved - gnome_calendar_update_all from gnome_calendar_load to here. - - * gui/calendar-commands.c: minor cleanups - - * pcs/cal-backend.c (save_to_vcal): copied code from gnome-pim - to write vcal to a file - (save): filled it with more gnome-pim code - (add_object): call save () after changing - (remove_object): same - (cal_backend_create): same - (cal_backend_remove_object): same - -2000-04-08 Christopher James Lahey <clahey@helixcode.com> - - * gui/Makefile.am: Removed linking with libetable and libeminicard - since they weren't being used. - -2000-04-08 Seth Alves <alves@hungry.com> - - * gui/gnome-cal.c (gnome_calendar_create): new function: - friendly wrapper for cal_client_create_calendar - - * gui/calendar-commands.c (new_calendar): call gnome_calendar_create - if no filename is provided - - * gui/prop.c (properties): calendar is a frame - - * gui/calendar-commands.c (calendar_control_activate): sort out the - menus a bit, more of them show up now. - - * gui/Makefile.am: don't build library or test, just the bonobo control - - * gui/gncal-todo.c (simple_todo_editor): calendar is a frame instead - of a window, now. - - * gui/gnome-cal.c (gnome_calendar_new): same - - * gui/goto.c (goto_dialog): same - -2000-04-06 Seth Alves <alves@hungry.com> - - * gui/calendar-commands.c (calendar_control_activate): removed - uih from the argument list, added cal. use cal as user_data - in callbacks rather than the control. - (calendar_control_deactivate): removed uih from argument list - -2000-04-05 Seth Alves <alves@hungry.com> - - * gui/calendar-commands.c (setup_menu): removed - (setup_appbar): removed - (calendar_control_activate): new function -- does the work - that setup_appbar and setup_menu used to do. - (calendar_control_deactivate): undoes what calendar_control_activate - does by removing the toolbar items and menu items. - - * gui/Makefile.am: build test-calendar-widget and evolution-calendar, - common stuff is in a library - - * gui/gnome-cal.c (gnome_calendar_get_type): made the calendar widget - based on a gtk_frame rather than a gnome_app - - * gui/calendar-commands.c: split out some of main.c - - * gui/evolution-calendar-control.c: bonobo bung so evolution - can use the calendar widget - -2000-04-01 Matt Loper <matt@helixcode.com> - - * pcs/.cvsignore: Added *.lo. - -2000-03-30 Seth Alves <alves@hungry.com> - - * gui/main.c (calendar_get_events_in_range): - cal_client_get_events_in_range returns a list of CalObjInstance *, not - a list of (char *) uid. - - * Makefile.am (SUBDIRS): readded the gui directory - - * gui/main.c: temporarily added alarm_defaults back in, - since the calendar doesn't link without it - -2000-03-29 Matt Loper <matt@helixcode.com> - - * Makefile.am: remove the gui directory, which doesn't compile. - -2000-03-28 Matt Loper <matt@helixcode.com> - - * pcs/Makefile.am: create a libpcs.la library, for use in the - wombat. - -2000-03-28 Seth Alves <alves@hungry.com> - - * gui/Makefile.am (LINK_FLAGS): added libeutil.la and libetext.a - - * gui/main.c (calendar_iterate): switch from string_to_ical_object to - ical_object_find_in_string - (calendar_get_events_in_range): same - (session_save_state): commented out references - to gcal->client->filename - -2000-03-27 Federico Mena Quintero <federico@helixcode.com> - - * pcs/cal-backend.c (cal_backend_get_object): Use - ical_object_to_string(). - - * cal-util/calobj.c (ical_object_to_string): Moved over from - pcs/cal-backend.c (was string_from_ical_object). - (get_calendar_base_vobject): Likewise, moved over from - pcs/cal-backend.c. - - * cal-util/cal-util.c: Removed string_to_ical_object(); the - correct function is in calobj.[ch], called - ical_object_find_in_string(). Removed ical_object_to_string, - since we now implement it in calobj.c. - - * cal-util/calobj.c: Removed ical_object_new_from_string(); see - above. - - * idl/evolution-calendar.idl (CalObjInstance): Calendar object - instances now contain only the UID for the object, not the whole - string representation of the object. This allows clients to - implement caching of objects if they wish. - - * pcs/cal.c (Cal_get_events_in_range): Likewise. - - * pcs/cal-backend.c (build_event_list): Likewise. - - * cal-client/cal-client.c (cal_client_get_events_in_range): - Likewise. - - * cal-util/cal-util.h (CalObjInstance): Likewise. - - * cal-util/cal-util.c (cal_obj_instance_list_free): Likewise. - (cal_obj_uid_list_free): Assert that the UIDs in the list are not - NULL. - - * pcs/tlacuache.gnorba (repo_id): The calendar factory also - supports the Unknown interface. - -2000-03-17 Federico Mena Quintero <federico@helixcode.com> - - * gui/e-day-view.c: Fix includes. - (e_day_view_on_delete_occurance): Do not call save_default_calendar(). - (e_day_view_on_delete_appointment): Likewise. - (e_day_view_on_unrecur_appointment): Likewise. - (e_day_view_finish_long_event_resize): Likewise. - (e_day_view_finish_resize): Likewise. - (e_day_view_key_press): Likewise. - (e_day_view_on_editing_stopped): Likewise. - (e_day_view_on_top_canvas_drag_data_received): Likewise. - (e_day_view_on_main_canvas_drag_data_received): Likewise. - -2000-03-13 Damon Chaplin <damon@helixcode.com> - - * gui/e-day-view*.[hc]: new files for the Day/Work-Week views. - -2000-03-12 Federico Mena Quintero <federico@helixcode.com> - - * gui/main.c (gnome_calendar_locate): Removed function now that it - is no CORBA server in the GUI. - (save_default_calendar): Removed function. Now the personal - calendar server will take care of saving modified calendars when - appropriate. - (close_cmd): Do not call unregister_calendar_services(). - - * gui/eventedit.c (ee_ok): Do not save the calendar. - - * gui/gncal-day-panel.c (day_view_range_activated): Likewise. - - * gui/gncal-todo.c (ok_button): Likewise. - (delete_todo): Likewise. - - * gui/gncal-full-day.c (delete_occurance): Likewise. - (delete_appointment): Likewise. - (unrecur_appointment): Likewise. - (child_focus_out): Likewise. - (update_from_drag_info): Likewise. - - * gui/gnome-cal.c (gnome_calendar_new): Removed obsolete call to - create the CORBA server. - - * gui/gnome-cal.h (GnomeCalendar): Renamed `calc' field to - `client'. - - * cal-client/cal-client.h (CalClient): Removed filename and - corba_server fields. - -2000-03-10 Federico Mena Quintero <federico@helixcode.com> - - * gui/main.c (main): Do not pass the INIT_SERVER flag to - gnome_CORBA_init_with_popt_table(). Check for exceptions - properly. - (main): Initialize Bonobo. - (main): Call process_dates() to parse the dates from the command - line before we dump the events or the TODOs. - (main): Use bonobo_main() instead of gtk_main(). - - * cal-util/calobj.c (ical_new): Initialize the alarm types here. - Do not call default_alarm() anymore, since that is a GUI issue. - (default_alarm): Removed function. - (alarm_defaults): Removed defaults data. - - * pcs/tlacuache.c (calendar_notify): Removed stubs for - alarm_defaults, calendar_notify(), debug_alarms. - -2000-03-09 Federico Mena Quintero <federico@helixcode.com> - - * gui/Makefile.am: Removed the corba-cal stuff. Commented out the - Pilot conduit stuff for now. - - * gui/calendar.c: Random #ifdefs to make it build, although this - file is going away. - - * gui/Makefile.am: Removed referenes to calobj.[ch] and timeutil.[ch]. - - * gui/calendar-conduit.c: Fixup includes. - - * gui/calendar-conduit.h: Fixup includes. - -2000-03-09 Seth Alves <alves@hungry.com> - - * gui/gnome-cal.h: replaced "Calendar *cal" with "CalClient *calc" - in the GnomeCalendar struct. - - * gui/*.c: tracked change from Calendar * to CalClient - - * gui/main.c: moved alarm_defaults from here to cal-util/calobj.c - (calendar_get_events_in_range): pulled this out of calendar.c and - fixed it up to use cal-client stuff. i'm not sure where to put it yet. - - * gui/main.c (calendar_iterate): pulled this one out of calendar.c also - -2000-03-07 Federico Mena Quintero <federico@helixcode.com> - - * cal-client/Makefile.am: Removed cal-client-alarm.[ch] from the - list of sources. This was a miscommunication on our part. - -2000-03-05 Seth Alves <alves@hungry.com> - - * cal-client/cal-client-alarm.c: stubs for client side - access to alarm structures. this will probably change, - since i don't know what i'm doing. - - * cal-util/alarm-enums.h: enums for alarms needed by - both the client and the server - - * remaining source files in calendar/... have been moved - to calendar/gui. - - * gui/alarm.c: start to decouple the view from the model - in the alarm editing code - -2000-03-03 Seth Alves <alves@hungry.com> - - * cal-util/Makefile.am: new file -- things shared between - the client and server go in this directory - - * calobj.c calobj.h icalendar.c icalendar.h - timeutil.c timeutil.h cal-util.c cal-util.h where moved - backend stuff went into pcs. shared stuff went into - cal-util. - -2000-03-02 Federico Mena Quintero <federico@helixcode.com> - - At this point the calendar client and personal calendar server - files were moved to the idl/, cal-client/, and pcs/ directories. - - * idl/Makefile.am: New file. - - * cal-client/Makefile.am: New file. Moved the libcal-client stuff - from calendar/Makefile.am to here. - - * pcs/Makefile.am: New file. Moved the tlacuache stuff from - calendar/Makefile.am to here. - - * Makefile.am (SUBDIRS): Added the idl and cal-client directories. - - * calendar.h: Removed the references to cal-backend.h and its - stuff. This file is going away soon! - - * icalendar.c: #include <config.h>. Also, we don't need to - include cal-backend.h or gnome.h. - - * icalendar.h: Protect from multiple inclusions. - -2000-03-01 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am: Use the gnome-config flags for orbit-idl. - Create a libcal-client library with the calendar client object. - -2000-02-29 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am: Removed stale rule for the conduit. - -2000-02-21 Matt Loper <matt@helixcode.com> - - * .cvsignore: Added *.lo. - -2000-02-19 Matt Loper <matt@helixcode.com> - - * .cvsignore: Added tlacuache and tl-test. - -2000-02-18 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * Makefile.am (INCLUDES): Use BONOBO_VFS_GNOME_CFLAGS instead of - GNOMEUI_INCLUDES, as we use Bonobo and VFS. - -2000-02-17 Seth Alves <alves@hungry.com> - - * cal-backend.h: moved CalendarFormat type def here - - * cal-backend.c (cal_backend_load): if extension suggests - an ical file, attempt to load an iCal file. - (cal_get_type_from_filename): returns CAL_ICAL if file - extension is 'ics' or 'ifb', else returns CAL_VCAL - (icalendar_calendar_load): moved this here from - icalendar.c because it needs to call the static function - add_object. - -2000-02-17 Federico Mena Quintero <federico@helixcode.com> - - * cal-client.c (cal_client_remove_object): Implemented. - - * cal.c (cal_notify_remove): Implemented. - (Cal_remove_object): Implemented. - (cal_get_epv): Fill in the remove_object field in the epv. - - * cal-backend.c (cal_backend_remove_object): Implemented. - (notify_remove): New function to notify clients that an object was - removed. - -2000-02-16 Russell Steinthal <rms39@columbia.edu> - - * calobj.[ch], eventedit.c, main.c: Change iCalObject.organizer - from char* to iCalPerson* - - * calobj.[ch]: Change iCalObject.related from list of char* to - list of iCalRelation*; assorted related fixes - - * icalendar.c: interface between libical and the gnomecal - internal representation - -2000-02-11 Federico Mena Quintero <federico@helixcode.com> - - * cal-client.c (cal_client_update_object): Implemented. - - * cal.c (cal_notify_update): New function to notify the listener - about an updated object. - (Cal_update_object): Implemented. - (Cal_get_uids): set_release() the sequence to TRUE. - (Cal_get_events_in_range): Likewise. - - * cal-backend.c (remove_object): New function to remove objects - from a calendar backend. - (cal_backend_update_object): New public function to update an - object and notify clients about it. - - * evolution-calendar.idl (Cal): Added update_object() and - delete_object() methods. - (Listener): Removed the obj_changed method and renamed obj_added - to obj_updated. We now only have updated and removed notifiers. - - * cal-listener.[ch]: Removed the "changed" notification code. - Changed the "added" notification code to the "updated" - notification. - - * cal-client.c: Likewise. - - * tlacuache.c (create_cal_factory): Connect to "destroy" on the - factory and exit the main loop when the factory is destroyed. - - * cal-factory.c (backend_destroy_cb): New callback used when a - backend is destroyed. Removes the backend from the factory's hash - table and unrefs the factory if all backends go away. - (add_calendar_client): Free the environment. - - * cal.c (cal_new): Use bonobo_object_unref() if we fail to - initialize. - - * cal-listener.c (cal_listener_new): Likewise. - - * layout.c (layout_events): Plug li.partition memory leak. - -2000-02-10 Federico Mena Quintero <federico@helixcode.com> - - * cal-backend.c (cal_backend_add_cal): Connect to the Cal's - destroy signal. - (cal_backend_remove_cal): Killed function now that removal of Cal - objects is done in their destroy callback. - (cal_destroy_cb): New callback to remove a Cal from the backend's - list of clients. Also, the backend destroys itself when there are - no more clients connected to it. - (save): New placeholder function to save a backend. - (destroy): New function to destroy a backend's data. - (cal_backend_destroy): Save the calendar and destroy it. - - * cal.c (cal_destroy): Reset the priv->backend to NULL. - - * cal-factory.c (add_calendar_client): There is no need to call - cal_backend_remove_cal(); we can now just destroy the Cal object. - (create_fn): Make sure we always unref the URI. - (load_fn): Move the URI unref to the end of the function for - safety. - - * cal-factory.c (add_calendar_client): Unref the Cal only if - notification of the listener was unsuccessful. Otherwise, the - calendar user agent (Listener side) keeps the reference. - - * tl-test.c (list_uids): Free the calobj. - - * cal-client.c (cal_loaded_cb): Use bonobo_object_unref() to get - rid of the listener. - (load_or_create): Likewise. - (destroy_factory): New function to get rid of the factory. - (destroy_listener): New function to get rid of the listener. - (destroy_cal): New function to get rid of the calendar client - interface object. - (cal_client_destroy): Free all resources. - (cal_client_get_object): CORBA_free() the calobj string. Boy, I - love memprof. - - * cal-listener.c (cal_listener_destroy): Reset the priv->cal to - CORBA_OBJECT_NIL. - - * cal-backend.c (cal_backend_remove_cal): Do not unref the Cal, - since the calendar user agent owns it. - (cal_backend_add_cal): Do not ref the Cal, since the calendar user - agent owns it. - - * cal-factory.c (add_calendar_client): Use bonobo_object_unref() - to get rid of the calendar client interface object. - - * calobj.c (ical_object_create_from_vobject): Duplicate the - default "PUBLIC" string. - -2000-02-09 Federico Mena Quintero <federico@helixcode.com> - - * cal-factory.c (cal_factory_load): Added documentation comment. - (load_fn): Do not print a message if the backend could not be - loaded due to a non-fatal error. - (queue_load_create_job): Moved the stuff from cal_factory_load() - to here. Now this function serves to queue load or create - requests. - (cal_factory_load): Use queue_load_create_job(). - (cal_factory_create): Implemented; use queue_load_create_job(). - (create_fn): New job handler for creating new calendars. - (create_backend): New function to create a new backend with a new - calendar. - (add_backend): New helper function to add backends to the - factory's hash table. - (load_backend): Use add_backend() instead of adding the backend by - ourselves. - - * cal-client.c (load_or_create): Moved the functionality from - cal_client_load_calendar() to here, and added an option to create - a new calendar instead of loading an existing one. - (cal_client_load_calendar): Use load_or_create(). - (cal_client_create_calendar): Implemented. - - * cal-backend.c (cal_backend_create): Implemented. - - * evolution-calendar.idl (LoadStatus): Added an IN_USE error for - create requests. - - * cal-listener.h (CalListenerLoadStatus): Added CAL_LISTENER_LOAD_IN_USE. - - * cal-listener.c (Listener_cal_loaded): Convert the IN_USE error. - - * cal-client.h (CalClientLoadStatus): Added CAL_CLIENT_LOAD_IN_USE. - - * cal-client.c (cal_loaded_cb): Handle CAL_LISTENER_LOAD_IN_USE. - - * tl-test.c: New test program for the calendar client side; it - also exercises the server side by sending commands to it. - - * Makefile.am: Added the tl-test program. - - * tlacuache.gnorba: Updated. - - * tlacuache.c (create_cal_factory): Use the right GOAD id. - - * cal-client.c (cal_client_construct): Use the right GOAD id. - -2000-02-08 Federico Mena Quintero <federico@helixcode.com> - - * evolution-calendar.idl (Cal): Added get_uids() method to get a - list of UIDs based on object types. - - * cal-backend.c (cal_backend_get_uids): Implemented get_uids() in - the backend. - - * cal.c (Cal_get_uids): Implemented get_uids() method. - - * cal-client.c (cal_client_get_uids): Implemented client-side - function. - - * cal-util.c (cal_obj_instance_list_free): Doh. Free the list, - not the last link. - (cal_obj_uid_list_free): New function to free a list of UIDs. - - * GnomeCal.idl (Repository): Removed unused method - get_object_by_id_list(). This is just for cleanup purposes and to - remind me exactly of what needs to be moved over to - evolution-calendar.idl. - (Repository): Removed unused get_objects() method. - - * corba-cal.c (init_calendar_repo_class): Removed the unused - get_objects method. - - * calobj.h (CalObjFindStatus): New status value enumeration for - the find function. - - * calobj.c (ical_object_find_in_string): New function to parse a - complete calendar and find a calendar object in it. This should - be used instead ical_object_new_from_string() in the future. - - * evolution-calendar.idl (CalObjInstance): Added an uid field. - Now the idea is that whenever calendar object strings are passed - around, their UIDs are passed along with them so that the actual - object can be pulled from the whole VCAL object using its UID to - identify it. - - * cal-util.h (CalObjInstance): Added uid field. - - * cal-util.c (cal_obj_instance_list_free): Free the UIDs. - - * cal-backend.c (build_event_list): Store the object's UID in the - instance structure. - - * cal.c (Cal_get_events_in_range): Copy the UID field to the CORBA - structure. - - * cal-client.c (cal_client_get_events_in_range): Copy the UID - field from the CORBA structure. - - * main.c (gnome_cal_file_menu): Removed unfinished html-month stuff. - - * Makefile.am (gnomecal_SOURCES): Removed html-month.c. - - * gnome-cal.c: #include "alarm.h" - (mail_notify): Made static. - - * alarm.h: #include "calobj.h" - - * corba-cal-factory.h (init_corba_server): Fixed prototype. - - * quick-view.c (create_items_for_event): Made static. - - * gncal-todo.c (column_resized): Made static. - - * layout.c (find_index): Made static. - -2000-02-08 Federico Mena Quintero <federico@helixcode.com> - - * evolution-calendar.idl (CalObjInstance): New struct to wrap - instances of calendar objects for recurrencies and alarms. - (Cal::get_events_in_range): New method to get ocurring and - recurring events by time range. - - * cal-backend.c (cal_backend_get_events_in_range): New function to - get a list of event instances in a time range. - (string_from_ical_object): New internal function. - (cal_backend_get_object): Use string_from_ical_object() instead of - doing everything ourselves. - (cal_backend_get_events_in_range): New function to get a list of - the events that occur or recur in a specified time range. - - * cal-client.c (cal_client_get_events_in_range): Implemented - client-side function. - - * cal-util.h: - * cal-util.c: New files with utilities and types common to the - client and server parts. - (CalObjInstance): New structure to hold an instance of an actual - occurrence, recurrence, or alarm trigger of a calendar object. - (cal_obj_instance_list_free): New function to free a list of - calendar object instances. - - * cal.c (Cal_get_events_in_range): Implemented new method. - - * corba-cal.c (cal_repo_get_updated_objects): Free `str' with - free(), not g_free(), since calendar_get_as_vcal_string() uses - writeMemVObject(), which uses realloc(). Fixed in gnome-pim as - well. - -2000-02-04 Federico Mena Quintero <federico@helixcode.com> - - * cal-backend.c (get_calendar_base_vobject): New function to - create the base VObject for a calendar. - (cal_backend_get_object): Create the base calendar and add the - sought object to it, then stringify it. - - * evolution-calendar.idl (Listener::obj_added - Listener::obj_changed): Now these pass in just the UIDs, not the - complete objects. - - * cal-listener.c (Listener_obj_added): Changed to pass in the uid, - not the object. - (Listener_obj_changed): Likewise. - - * cal-client.h (CalClientClass): Made the obj_added and - obj_changed signals take in the UIDs, not the full objects. - - * cal-client.c (obj_added_cb): Likewise. - (obj_changed_cb): Likewise. - -2000-02-04 Federico Mena Quintero <federico@helixcode.com> - - * cal-backend.c (CalBackendPrivate): Renamed the event_hash field - to object_hash. Now we hash all the calendar's objects here based - on their UIDs. - (ensure_uid): New function to create UIDs for calendar objects - that don't have them. - (add_object): Ensure the object has an UID before inserting it in - the calendar. - (cal_backend_get_object): New function. - -2000-02-03 Federico Mena Quintero <federico@helixcode.com> - - * evolution-calendar.idl (Cal): Added the get_object() method. - - * cal-client.c (cal_client_get_object): New function to get a - calendar object by its UID. - - * cal.c (Cal_get_object): Implemented. - - * cal-backend.c (cal_backend_get_object): New unfinished backend - function. We need some reorganizing of how the calendar objects - are stored. - -2000-02-02 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am (gnomecal_SOURCES): Added the CORBA generated - sources. - -2000-02-01 Federico Mena Quintero <federico@helixcode.com> - - * cal-client.c (cal_loaded): Handle the cal_loaded signal from the - listener. Store the calendar client interface object, and emit - our own cal_loaded signal. - (cal_client_load_calendar): Connect to the listener's signals. - (cal_client_class_init): Added the "obj_added", "obj_removed", - öbj_changed" signals. - (obj_added_cb): Handle the signal from the listener. - (obj_removed_cb): Likewise. - (obj_changed_cb): Likewise. - -2000-01-30 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am (gnomecal_SOURCES): Added cal-client.[ch] and - cal-listener.[ch]. - -2000-01-30 Federico Mena Quintero <federico@helixcode.com> - - * evolution-calendar.idl: Changed the namespace from - GNOME::Calendar to Evolution::Calendar. - (Listener::LoadStatus): Fixed SUCESSS -> SUCCESS typo. And I - never noticed it in the implementation. Ain't M-/ grand? - - * Makefile.am: Changed ocurrences of gnome-calendar.idl to - evolution-calendar.idl. - - * *.[ch]: Changed GNOME_Calendar_foo identifiers to - Evolution_Calendar_foo. - -2000-01-25 Federico Mena Quintero <federico@helixcode.com> - - * cal-client.c cal-client.h: New files with the calendar client - object. - -2000-01-25 Federico Mena Quintero <federico@helixcode.com> - - * cal-factory.c (CalFactory_load): Check that the listener is not - nil and emit and exception if it is. - - * gnome-calendar.idl (CalFactory::load CalFactory::create): Now - these raise the NilListener exception. - - * tlacuache.c (calendar_notify): Error stub for alarms. - (alarm_defaults): Stub array. - (debug_alarms): Stub variable. - (main): Initialize gnome-vfs. - -2000-01-24 Federico Mena Quintero <federico@helixcode.com> - - * tlacuache.c: New main module for the Tlacuache personal calendar - server. - - * tlacuache.gnorba: New gnorba file for Tlacuache, the GNOME - personal calendar server. - - * Makefile.am: Added the stuff necessary to build Tlacuache. - - * cal.c (Cal_get_uri): Convert the URI to a string before - returning it. - - * cal-factory.c (CalFactory_create): Doh, this function is void. - - * job.c (job_add): Use g_idle_add(), not gtk_idle_add(). - -2000-01-24 Federico Mena Quintero <federico@helixcode.com> - - * cal-backend.c (cal_backend_remove_cal): New function to remove a - calendar client interface object from a backend. - (cal_backend_load): Convert the URI to string and use - Parse_MIME_FromFileName(). The conversion is not very smart, - though. - - * cal-factory.c (load_backend): Moved most of the error handling - upstream to load_fn(). - (load_fn): Handle failure in case the backend could not be loaded. - (cal_factory_destroy): Free the backends and the backend hash - table. - (add_calendar_client): Implemented. We create a Cal client - interface object and attach it to the backend, and we notify the - listener. - -2000-01-22 Federico Mena Quintero <federico@helixcode.com> - - * cal-factory.c (lookup_backend): Renamed from lookup_calendar(). - Also, return a backend instead of a Cal client object. - - * cal-backend.c (cal_backend_load): Take in a GnomeVFSURI, not a - string. - - * cal-listener.c (Listener_cal_loaded): Pass the load status to - the signal. - (cal_listener_destroy): Better error checking. - (cal_listener_new): Better error checking. - - * cal-listener.h (CalListenerLoadStatus): New enum for the load - status of a calendar. - (CalListenerClass): Added the status argument to the cal_loaded - signal. - - * gnome-calendar.idl (cal_loaded): Added a load status code. - - * cal-backend.h (CalBackendLoadStatus): Renamed from - CalBackendLoadResult. - -2000-01-18 Federico Mena Quintero <federico@helixcode.com> - - * cal-backend.c cal-backend.h: Moved the calendar backend here. - This is the actual calendar-handling object. - (load_from_vobject): Moved over from calendar.c. Modified to use - a CalBackend instead of the old Calendar structure. - (add_object): Likewise. - - * cal.c: Now the Cal object is just a calendar client interface - object; we use it as a "viewport" onto a CalBackend. This also - lets us do correct resource management. - - * cal-common.h: New file with common forward declarations; we - can't have circular dependencies between headers. - -2000-01-18 Federico Mena Quintero <federico@helixcode.com> - - * cal-factory.c (cal_factory_load): Queue a load job. - (load_fn): Load job handler. Lookup the calendar by URI, load it - if it is not loaded, or just report it to the new listener if it is. - - * job.c job.h: New files with a simple job queue manager. - - * gnome-calendar.idl (Listener::cal_loaded): Do not return the - whole calendar object string. The client will be able to query - the calendar for the events it needs. - - * cal-listener.c (Listener_cal_loaded): Ref the calendar GNOME - object. We unref it when the listener is destroyed. - -2000-01-17 Federico Mena Quintero <federico@helixcode.com> - - The files from the gncal directory of the gnome-pim module on CVS - were moved here, to evolution/calendar, in preparation for the - Evolution work. The calendar is being split into a model/view - architecture. The model is a personal calendar server (PAS): it - provides storage, notification, and event generation; the - views/controllers are the calendar user agents and things like - Pilot synchronizers. - -2000-01-11 Federico Mena Quintero <federico@helixcode.com> - - * cal.c: Removed the CORBA listener methods, adjusted for the new - IDL. - - * cal-listener.c (cal_listener_init): Create the private - structure. In it we hold a reference to the calendar the listener - is watching. - (cal_listener_destroy): Destroy the private structure and unref - the calendar. - (Listener_cal_loaded): Stuff the calendar into our private data. - (Listener_obj_added): Adjusted for new IDL. - (Listener_obj_removed): Likewise. - - * gnome-calendar.idl: New IDL for the personal calendar server. - - * cal.h cal.c: New files with the calendar object. - - * cal-listener.h cal-listener.c: New files with the calendar - listener object. - - * cal-factory.h cal-factory.c: New files with the calendar factory - object. - -2000-01-09 Eskil Heyn Olsen <deity@eskil.dk> - - * Makefile.am: Changes to remove todo capplet stuff from distro. - -2000-01-08 Vadim Strizhevsky <vadim@optonline.net> - - * calendar-conduit-control-applet.c: Added pilotID argument to - gpilotd_conduit_mgmt_new. - - -2000-01-05 Eskil Heyn Olsen <deity@eskil.dk> - - * GnomeCal.idl: Added an argument to get_number_of_objects, so you - can choose which state the object should have - (any/new/modified/...). Will also add one to choose type - (event/journal etc). - - * corba-cal.c (cal_repo_get_number_of_objects): Implemented the - new version of get_number_of_objects. - - * calendar-conduit.c (pre_sync): Calls various - gnome_pilot_conduit_standard_abs_set_num_yadayda to get progress bars. - -2000-01-04 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit.c (start_calendar_server): Let's not call - g_error, but g_warning instead. - (pre_sync): Get record numbers info, total, new, deleted etc, and - tell gpilotd. - -1999-12-31 Eskil Heyn Olsen <deity@eskil.dk> - - * eventedit.c (ee_store_recur_end_to_ical): Adds 86400 secs (1 - day) to the date chooses by the user. This ensures the recurrence - also occurs on that date. - (ee_rp_init_ending_date): And subtracts 86400 secs when about to - redisplay the box. - - * calendar.h: Added an argument to calendar_new, to enable certain - features, such as initing alarms or nor. - - * calendar.c (calendar_new): Implemented support for the - CALENDAR_INIT_ALARMS option to calendar_new. - - * corba-cal.c (cal_repo_get_updated_objects): Added - CALENDAR_INIT_ALARMS to calendar_new calls. - - * main.c: Added CALENDAR_INIT_ALARMS to calendar_new calls. This - should probably be CALENDAR_INIT_NIL, but I'm not sure, guess - steintr should check it. - - * gnome-cal.c: Added CALENDAR_INIT_ALARMS to calendar_new calls. - - * calendar-pilot-sync.c: Added CALENDAR_INIT_NIL to calendar_new calls. - -1999-12-10 Russell Steinthal <rms39@columbia.edu> - - * eventedit.c (ee_create_ae): Fix sensitivity bug when used to - create default alarm box (widgets in that box should always be - sensitive, even if the enabled checkbutton is not set) - -1999-12-08 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit-control-applet.c (setSettings): Capplets now - sets first_sync on enable, this should make the conduit copy old - entries from the pilot to gnomecal. - -1999-12-07 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit.c (pre_sync): Check if local store is - empty. If, force slow sync. - - * GnomeCal.idl (GNOME): Added get_number_of_objects. - - * corba-cal.c (cal_repo_get_number_of_objects): implemented the - get_number_of_objects. - - * calendar-conduit-control-applet.c (setStateCfg): Fixed bug that - caused the capplet to always set the sync action to Disable upon start. - -1999-12-05 Eskil Heyn Olsen <deity@eskil.dk> - - * Makefile.am (Conduits_second_DATA): Also install .desktop files - for conduit capplets in the gnome/apps menu dir. - -1999-12-04 Eskil Heyn Olsen <deity@eskil.dk> - - * Makefile.am (EXTRA_DIST): Added .desktop files to EXTRA_DIST. - -1999-10-12 Clifford R. Conover <rusty@zootweb.com> - - * gncal-todo.c Todo List improvements. - - Cleaned up todo item highlighting, added support for highlighting - events due today, and events not due yet. Colors are configurable - on the Colors Tab of the properties window. - - Renamed Frame in Properties window to Colors rather then Month - Colors since we are now asking for Todo item colors. - - Added ability to display time until todo item is due in list, it - automatically selects the best denomination of time (up to weeks) - and down to seconds to display. This should be made configurable - in a future version. - - Changed Todo dialog to ask for time that event is due. This - allows more accurate tracking of then the item is due, before the - dialog was only asking for the date of the todo item. - -1999-12-03 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit.c: undef DEBUG_CALCONDUT, suppresses debug output. - -1999-12-02 Russell Steinthal <rms39@columbia.edu> - - * alarm.c: Enhanced debug support: can be toggled on and off by - SIGUSR1, reports alarms which could not be added - - * gnome-cal.c, main.[ch], prop.c: Add snooze capability for audio - and display alarms. Snooze interval can be configured in the - Properties box. - -1999-11-30 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit.c (compare): Fixed compare bug. Also neated up - some of the if's in set_status. - -1999-11-22 Russell Steinthal <rms39@columbia.edu> - - * Merged todo list coloring patch from stable - * Added myself to AUTHORS, about box (per Miguel) - -1999-11-22 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit.c (pre_sync): Writes some warning - messages when pre_sync fails. - -1999-11-14 Eskil Heyn Olsen <deity@eskil.dk> - - * Makefile.am: Stupid misplaced endif cause gncal to depend on an - install gnome-pilot... fixed... sorry. - -1999-11-12 Eskil Heyn Olsen <deity@eskil.dk> - - * Makefile.am (extra_pilot_bins): Fixed the if then else problem, - using solution suggested by James Henstridge, appears to be caused - by a (by now fixed) bug in my automake. - -1999-11-12 Russell Steinthal <rms39@columbia.edu> - - * prop.c: Config code for timeout, make Alarms property page use a - vbox instead of an hbox so that the propbox stays a reasonable width. - - * gnome-cal.c, main.[ch]: Add timeout for audio alarms, code to load - from config file - - * eventedit.c: Give some static functions external linkage so they - can be used elsewhere (make_spin_button); add some prototypes to - appease gcc. - -1999-11-11 Russell Steinthal <rms39@columbia.edu> - - * calendar.c (calendar_day_change): Add call to - calendar_init_alarms() to schedule another day change alarm. - -1999-11-09 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit.c: Enabled debug output. Sets a g_log_domain, - now version 0.8.5. Consistent use of GSList/GList. Implemented - compare, default uses one that compares the contents of a struct - Appointment, but also has #ifdeffed code that does a field level - comparison, not complete, but perhaps educational. - - * Makefile.am (#todo_conduit_control_applet_SOURCES): Fixed an - unwanted conditional on libcalendar_conduit_la_LDFLAGS - -1999-11-05 Eskil Heyn Olsen <deity@eskil.dk> - - * calendar-conduit-control-applet.c (readStateCfg): Commented the - code out, thus the capplet works again. - -1999-11-04 Eskil Olsen <deity@eskil.dk> - - * Makefile.am: Uses the PISOCK_LIBDIR, for people with odd install - dirs for their pilot-link. Also install a pretty icon for the - calendar-conduit. - - * calendar-conduit-control-applet.c: Modfied the - try/revert/ok/cancel scheme to be more intuitive, also uses a - GtkOptionMenu for the possible sync methods. - - * calendar-conduit-control-applet.desktop: use the nice icon... - - * calendar-conduit.c: Ack, had to define debug_alarms and - alarm_default, otherwise they are undefined. Is gncal code messy - or is this considered a way of configuring the cal engine ? - Implemented delete_all syncabs methods. - - * calendar-pilot-sync.c: also had to declare debug_alarms and - alarm_defaults, just as ugly. - -1999-11-02 Russell Steinthal <rms39@columbia.edu> - - * prop.c: Add new alarm page to properties box - - * prop.c, calobj.c, main.[ch] eventedit.c: New support for default - alarms, configurable in the properties box. - - * gnome-cal.c, prop.c, main.[ch]: add option to beep on Display - alarms - -1999-10-23 Russell Steinthal <rms39@columbia.edu> - - * calendar.c (calendar_new): Correctly initialize calendar_day_end - and calendar_day_begin *before* installing day-change alarm. - -1999-10-21 Russell Steinthal <rms39@columbia.edu> - - * alarm.c, main.c: Added alarm debugging code - - * main.c (open_ok): Show an error box if the user tries to open a - non-existent file; fixes bug #1818 - -1999-10-19 Russell Steinthal <rms39@columbia.edu> - - * gnome-cal.c (calendar_notify): Fix typos which were causing - invalid times in audio notification dialogs; fixes Bug #2561 - -1999-10-18 Russell Steinthal <rms39@columbia.edu> - - * gncal-day-panel.c (gncal_day_panel_new): Placed the various - elements of the day view in paned windows so that the user can - adjust the relative sizes of the daily schedule, monthly calendar, - and to-do list. - -1999-10-18 Martin Norbäck <norpan@bigfoot.com> - - * gncal.desktop: Added swedish translation - -1999-10-13 Eskil Olsen <deity@eskil.dk> - - * Makefile.am: Hopefully the fixes the much-hated - gnome-pilot dependency. - -1999-10-07 Eskil Olsen <deity@eskil.dk> - - * calendar.c (calendar_object_changed): moved the pilot_status = - MOD up, so even a CHANGE_SUMMARY will set the modified flag. - - * calendar-conduit.c: more _free calls, vamped the noise on output. - -1999-10-06 Eskil Olsen <deity@eskil.dk> - - * *conduit*[ch]: checks return values from gpilotd_init/connect. - - * calender.c (vcalendar_create_from_calendar): removed a set - of cleanVObject cleanStrTbl, since the freed memory that the - function returned. - -1999-09-27 Timur Bakeyev <mc@bat.ru> - - * timeutil.c (time_from_isodate): Use tm.gmtoff or timezone to get - correct offset from UTC, according to HAVE_TM_GMTOFF or HAVE_TIMEZONE. - See also 1999-07-19 Matt Martin <matt@abacusnet.net> - -1999-09-27 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * month-view.c (add_event): ditto - (mark_current_day): ditto - (month_view_set): ditto - - * goto.c (goto_dialog): ditto. - - * gnome-month-item.c (gnome_month_item_init): ditto. - - * gncal-day-panel.c (gncal_day_panel_new): ditto. - - * getdate.c (RelativeDate): ditto. - - * eventedit.c (set_all_day): ditto. - (ee_rp_init_rule): ditto. - - * calendar.c (vcalendar_create_from_calendar): ditto. - - * calendar-conduit.c (update_record): ditto. - - * calobj.c (ical_object_generate_events): Get rid of pointers to - values returned from localtime, as it uses a static buffer. - -1999-09-26 Eskil Olsen <deity@eskil.dk> - - * corba-cal.c: the g_free that was commented out since glib said - was a duplicate free, was supposed to be a free. - - * GnomeCal.idl/corba-cal.c: added a get_object_id_list and a - get_objects_by_id_list. Latter is not done. - - * calendar-conduit.c: rewrote the way the conduit iterates over - records. It no longers fetches all entries (since that didn't work - with more then 285 entries. It now fetches the id list, and gets - each record. (will be using get_objects_by_id_list to get records - in amounts of 10 or so later, to reduce amount of corba calls). - - * calendar-conduit.c: now sets alarm parameters when transferring - from gnomecal to pilot. - -1999-09-23 Eskil Olsen <deity@eskil.dk> - - * calendar-conduit.c: better merge of summary/description - when doing ical_from_remote (update_record), also handles - import from gnomecal to pilot better, and on both ways, repeat - events are much better now. - -1999-09-22 Eskil Olsen <deity@eskil.dk> - - * corba-cal.c: commented out a g_free that glib reported - as being a duplicate free. - * calendar-conduit.c: got gnomecal->pilot up and runnning. - -1999-02-06 Lauris Kaplinski <lauris@ariman.ee> - - * gncal.desktop: Added Estonian translations. - -1999-09-14 Federico Mena Quintero <federico@redhat.com> - - * gncal-full-day.c (child_popup_menu): Set the data pointers for - all the items. - -1999-09-14 Kjartan Maraas <kmaraas@online.no> - - * doc/C/gnomecal.sgml: Merge from gnome-pim-1-0. Synced with newest - user-guide. - -1999-09-01 Miguel de Icaza <miguel@gnu.org> - - * eventedit.c (ee_create_buttons): Make the OK button the default - button per Russell's suggestion. - -1999-08-30 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calendar.c (calendar_object_changed): Modify the - object->last_mod field. - (calendar_add_object): Ditto. - - Closes bug #676 - - * main.c (save_calendar_cmd): Fix problem in which we warned the - user about the calendar being modified the first time the calendar - was used. - -1999-08-22 Tomas Ogren <stric@ing.umu.se> - - * gnomecal.gnorba: "GenericFactoy" is wrong... - -1999-08-15 Miguel de Icaza <miguel@gnu.org> - - * calobj.c (ical_gen_uid): Fix the hostname part. - -1999-08-07 Peter Teichman <pat4@acpub.duke.edu> - - * calendar-pilot-sync.c (sync_pilot): sync correctly for objects - created on the pilot, but not dirty (because they have been synced - with some other program in the past) - -1999-07-30 Miguel de Icaza <miguel@gnu.org> - - * month-view.c (month_view_init): Release points here. - -1999-08-02 Peter Teichman <pat4@acpub.duke.edu> - - * Makefile.am (libcalendar_conduit_la_LDFLAGS): - libcalendar_conduit now installs - - * calendar-pilot-sync.c (sync_pilot): do deletion of appointments - correctly, when they are deleted on the pilot - (conduit_free_Appointment): protect against double-freeing parts - of the Appointment structure - (update_record): all-day events from the pilot are handled a bit - more reasonably - -1999-08-01 Peter Teichman <pat4@acpub.duke.edu> - - * calendar-pilot-sync.c (sync_object_to_pilot): The multi-day - appointment corruption bug is dead. Whoo! - -1999-07-31 Peter Teichman <pat4@acpub.duke.edu> - - * Makefile.am: fixed this up slightly with respect to pilot conduits - -1999-07-30 Jonathan Blandford <jrb@redhat.com> - - * Makefile.am (libcalendar_conduit_la_LIBADD): More autoconf-stuff - -1999-07-29 Jonathan Blandford <jrb@redhat.com> - - * gnome-cal.c (setup_widgets): Add scrolling to the yearview. - -1999-07-28 Miguel de Icaza <miguel@gnu.org> - - * calendar-pilot-sync.c: (sync_object_to_pilot): If the enddate is - not set, set the repeatForever to 1. This fixes all of the - birthdays problems I had. - - Make the code not take arguments - (sync_cal_to_pilot): Nice event update information - - * calendar.c (calendar_new): Add Event UID hash table. - (calendar_add_object): Add events to the hash table here. - (calendar_remove_object): Remove events here. - (calendar_object_find_event): Use the hash table here. - - * main.c (save_calendar_cmd): The object is already destroyed by - gnome_dialog_run. - - * calendar-pilot-sync.c (sync_object_to_pilot): Do not turn - archived bit on. - - * calobj.c (ical_gen_uid): Use the hostname, not the domain name. - (ical_gen_uid): Add a serial number. Isodates can be small. - - * corba-cal.c (cal_repo_update_pilot_id): New method to update the - pilot status. - (cal_repo_get_updated_objects): New method. Returns a list of - modified and not-sycned objects - - * calendar-pilot-sync.c (sync_cal_to_pilot): New function to sync - from the GnomeCalendar to the pilot. - (sync_object_to_pilot): Sync a single event to the pilot. - (try_alarm): Alarm syncing code. - -1999-07-27 Miguel de Icaza <miguel@gnu.org> - - * calendar-pilot-sync.c: New file. Implements PalmPilot - syncronization with the Gnome Calendar. - - * calobj.c (ical_object_new_from_string): New function. Creates - an iCalObject from a vCalendar string that is supposed to contain - only one vEvent. - - * calendar.c: - (calendar_save): Split this routine in two. - - * gnome-cal.c (gnome_calendar_new): Create the corba server here. - - * main.c: Include gnorba.h, and corba-cal-factory.h here - (close_cmd): Kill the calendar server on shutdown. - - * calobj.c (load_recur_yearly_day): Added a fixme comment. WE - need to handle intervals in the years. - - * calendar.c (calendar_object_find_in_list, calendar_object_find, - calendar_object_find_todo, calendar_object_find_event): New - functions for looking up information. - - * main.c (gnome_calendar_locate): New function. - - * corba-cal.c (calendar_create_object): New file. Implements the - corba server. - - * calendar.c (calendar_object_changed): Flag pilot-status as changed. - - * calobj.c (ical_object_to_vobject): Save pilot information for syncing. - (ical_object_create_from_vobject): Load syncing information for - pilot. Do it in a way compatible with KOrganizer. - -1999-07-26 Miguel de Icaza <miguel@gnu.org> - - * calobj.c (ical_object_create_from_vobject): Generate unique IDs - on Vevents we load that lack it. WE need this for the old - gnome calendar generated files (ie, before now :-). - - Required to sync with the Palm - -1999-07-26 Miguel de Icaza <miguel@gnu.org> - - * calobj.c (ical_object_create_from_vobject): Generate unique IDs - on Vevents we load that lack it. WE need this for the old - gnome calendar generated files (ie, before now :-). - - Required to sync with the Palm - -1999-07-19 Matt Martin <matt@abacusnet.net> - - * timeutil.c (time_from_isodate): Handle the 'Z' parameter to the - ISO date format to convert from GMT time. - -1999-07-17 Nat Friedman <nat@gnome-support.com> - - * calendar.c (calendar_add_object): Copy the new UID into the - iCalObject structure. - -1999-07-16 Miguel de Icaza <miguel@gnu.org> - - * gnome-month-item.c (gnome_month_item_set_arg): Merge fix from - gnome-pim-1-0: Fixed cut&paste bug for day fontsets. - -1999-07-14 Miguel de Icaza <miguel@gnu.org> - - * calobj.c (ical_gen_uid): Returns a UID. - (ical_object_new): Use a UID when creating an event. Should get - syncing done easier. - -1999-07-14 Nicholas J Kreucher <nick@poetic.com> - - * calobj.c (skip_numbers): Actually skip over the numbers. - (ical_object_to_vobject): Test the proper variable for storing the - proper information. - -1999-07-14 Jean-Noel Guiheneuf <jean-noel.guiheneuf@wanadoo.fr> - - * timeutil.c (time_add_month): Fixed the problem with next month - going from a 31-day to a 30-day by adjusting the date to the - closest day at the end of the month. - -1999-06-07 Mike McEwan <mike@lotusland.demon.co.uk> - - * timeutil.c (time_add_month): Tell ktime' that we don't know - about daylight saving time so that it does *not* make adjustments - when we traverse a DST boundary. - (time_year_begin): ditto. - (time_year_end): ditto. - (time_month_begin): ditto. - (time_month_end): ditto. - -1999-06-16 Anders Carlsson <anders.carlsson@tordata.se> - - * main.c (new_calendar): Realize the toplevel widget when - --hidden is passed to gnomecal. This fixes a segfault. - -1999-06-04 Robert Brady <rwb197@ecs.soton.ac.uk> - - * gnome-cal.h, gnome-cal.c: Fix abort() problem with the year view. - (Bug #1367). Thanks to Owen Cliffe <oc197@ecs.soton.ac.uk> for - helping track it down. - -1999-06-03 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (daynumberlist): One line bug fix from Sergey I Panov. - -1999-06-02 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * view-utils.c (nicetime): Use %H instead of %k, as %k is a GNU - extension, not available in other systems. - -1999-06-01 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (daynumberlist): Work around broken software that - writes a broken month-of-day as "zero". Use the dtstart date for - this on this event. - -1999-05-28 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * Makefile.am (install-data-local): help files be gone. They are - now installed from the Docbook stuff. - -1999-05-26 Russell Steinthal <steintr@condor.penguinpowered.com> - - * gncal-todo.c main.c main.h prop.c: Added support for priorities - for todo items. Doesn't do much, but you can set them and sort by - them. (Use the properties box to enable them; should they be on - by default?) - -1999-05-25 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * main.c (parse_an_arg): Added missing break here. It was causing - core dumps when invoked with --userfile. - - * gnome-cal.c (gnome_calendar_set_view): Add some assertions here, - to pin point the bug reported on gnome-list. - - * calobj.c (load_recurrence): Make intervals always exist. a 0 - interval is wrong. - -1999-05-25 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * year-view.c: Removed unused macro CALENDAR_HEIGHT. - -1999-05-25 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * year-view.c (idle_handler): Set the canvas scroll region here, - not in size_allocate(). Also, use the correct width and height - based on the allocation and the precomputed minimum width/height - values. - - * gnome-cal.c (setup_widgets): Set the scrollbar policy of the - scrolled window. - - * main.c (setup_appbar): Use the correct type for the appbar. - - * gncal-day-view.c: Removed unused function switch_to_day(). - - * gncal-day-panel.c (calendar_day_selected): Removed unused variable. - -1999-05-25 Nat Friedman <nat@nat.org> - - * doc/C/gnomecal.sgml: Fixed a typo. - - * gnome-cal.c (setup_widgets): Added a scrolled window widget into - which the year view is placed. - - * year-view.c (CALENDAR_HEIGHT): The height of the total year view - inside the scrolled window. - (idle_handler): Set the height of the year view to - CALENDAR_HEIGHT. - (year_view_size_allocate): Set the scroll region of the year view - canvas to allocation->width, CALENDAR_HEIGHT. - -1999-04-25 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * main.c (dump_todo): Add --todo flag to dump the todo contents. - -1999-04-19 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-todo.c (add_activated): Use same hack used in edit_activated - -1999-04-16 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-todo.c (edit_activated): Kill all grabs from the CList - before running the new dialog box. - - This fixes the problem of button-3/Edit on the todo item blocking - the GUI (actually, the main window responds, but not the todo - window). - -1999-04-08 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-todo.c (gncal_todo_init): Make sure we can get events for - button3. The code for the nice popup menu was there but was not - getting invoked. - -1999-04-01 Steve Murphy <murf@e-tools.com> - - * calobj.c (weekdaynum): Added this routine so Monthly recurrences - use the weekday field as a simple integer for a single weekday. - - * calobj.c (load_recur_monthly_pos): Call weekdaynum instead of - weekdaylist. The interface only lets the user input a single value - anyway. - - * calobj.c (ical_object_to_vobject): instead of code to output day - names from a bit array, use instead the value as an int and output - a single dayname. - - * calobj.c (ical_object_generate_events): first_week_day gets the - day int instead of the first entry in the bit field. I inserted a - fair chunk of code to avoid calling generate if the day is out of - range for a month. It may be unneccessary, because mktime will - turn the extra days into a valid date the next month. But not all - mktimes are equal, I fear. - - * eventedit.c (ee_store_recur_rule_to_ical): For case 3, - (Monthly), I added code to set the interval slot of the recur - struct; without this value, selecting a monthly recursing, by - date, would lead to an infinite loop broken only by a failure to - alloc more memory. Also, in the "by position" case, both - u.month_pos and u.month_day were being assigned values. This is a - mistake, as they are both part of an union, and the same - thing. The weekday field should get the recur_rr_month_weekday - value. - - * eventedit.c (ee_rp_init_rule): set default day from the weekday - field instead of the u.month_day field, which is really the - month_pos value. - - * gnome-cal.c (gnome_calendar_tag_calendar): Month days start with - 1, not 0; thus, setting tm.tm_mday = 0, and then calling mktime - will generate a time corresponding to the end of the previous - month, which may have a mday anywhere from 28 to 31. The end time - just adds 1 to the month, so your end time may not cover the last - few days of this month, depending on what the biggest mday of last - month was. I changed it so tm_mday is set to 1 instead. - -1999-03-30 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-todo.c (convert_time_t_to_char): Made static. Make it use - the full year format for strftime(). - -1999-03-27 Nuno Ferreira <nmrf@rnl.ist.utl.pt> - - * calobj.c: Include <config.h> So that strings get translated. - -1999-03-26 Tomas Ogren <stric@ing.umu.se> - - * prop.c (build_hours_menu): Made it respect 12/24h settings.. - Doesn't show until next time you open the dialog.. yet.. - -1999-03-24 Tomas Ogren <stric@ing.umu.se> - - * gncal-week-view.c (gncal_week_view_set): Did some i18n work - * eventedit.c (get_exception_string): Did some i18n work - -1999-03-24 Tomas Ogren <stric@ing.umu.se> - - * gncal-todo.c (gncal_todo_init): Made clist titles i18n:able - * main.c (poptOption): Added which views that are possible for - --view in the --help text (closes #367) - * main.c (dump_events): Added (short) month to the strftime and made - the strings i18n:able - -1999-03-23 Tomas Ogren <stric@ing.umu.se> - - * gncal/calobj.c: Added 2 paranthesis.. - "foobar = d / 60*60" is _NOT_ the same as "foobar = d / (60*60)" - which caused heavy alarm-corruption with alarms between 2 hrs and - 2 days. - -1999-03-23 Nat Friedman <nat@nat.org> - - * eventedit.c (ee_store_recur_rule_to_ical): Set the - recur->interval to the value of the recur_rr_month_period spin - button if the event is being set "by day." This closes bug #675 - as reported by bagfors@hpc2n.umu.se. Thanks for the report! - -1999-03-10 Clifford R. Conover <rconover@montana.edu> - - * gncal-todo.c (simple_todo_editor): Add support for Due Date when - adding a TODO item here. - (column_resized): New function - (init_column_sorting): New function. - (todo_click_column): New function. - (convert_time_t_to_char, make_overdue_todo_style): New functions. - - * gnome-cal.c (gnome_calendar_todo_properties_changed): New - function used to update the TODO when the properties have been - chagned for it. - - * prop.c (prop_apply_todo): Apply TODO properties. - - * gncal-day-panel.c (todo_list_properties_changed): Update the - TODO display here. - - * eventedit.c (date_edit_new): Made public - -1999-03-10 Craig A Soules (soules+@andrew.cmu.edu) - - * timeutil.c, calendar.c, calobj.c, gncal-day-panel.c: Add support - for daylight time savings. - -1999-02-28 Martin Baulig <martin@home-of-linux.org> - - * gncal-full-day.c (recompute_motion): For DRAG_MOVE, DRAG_SIZE_TOP - and DRAG_SIZE_BOTTOM: call child_focus_out () if the child currently - has the focus. - -1999-02-27 Changwoo Ryu <cwryu@adam.kaist.ac.kr> - - * quick-view.c (QUICK_VIEW_FONTSET): Added Korean font to the - fontset string. - * mark.h (*_FONTSET): Likewise. - -1999-02-23 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (ical_object_to_vobject): Save the owner/organizer of - the event. - (ical_object_create_from_vobject): Load the owner/organizer of the event. - - * gncal-full-day.c (delete_occurance): Assign child to data (fixes - crash on "delete this occurrance"). - -1999-02-22 Timur Bakeyev <mc@bat.ru> - - * calendar.c: According to configured values, use either tm.tm_zone - or tzname. In last case, also declare it extern. - - * prop.c: langinfo.h not available everywhere. Wrapped. BTW, works - fine without it. - -1999-02-20 Tomas Ogren <stric@ing.umu.se> - - * main.c (init_username): Made use of g_get_{user,real}_name() instead - of our own home-brew... - -1999-02-17 Sergey Panov <sipan@mit.edu> - - * gnome-month-item.c,gnome-month-item.h,goto.c,mark.h, - month-view.c,prop.c,quick-view.c,year-view.c: will define - fonts via fontset. Friendlier to locales that use iso8859-[^1] - and koi8-r encodings. Does not solve problem for Asian languiges - --- better solution is needed (e.g. standart GNOME fontstyles - defined in gtkrc). - -1999-02-16 Sergey Panov <sipan@mit.edu> - - * main.c: Use N_() macro for color settings labels in - color_props structure. - -1999-02-15 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * goto.c (goto_dialog): Indentation fixes. - -1999-02-15 Tomas Ogren <stric@ing.umu.se> - - * goto.c: Made a private copy of what localtime() returns, to be able - to keep the data after more calls to localtime(). - -1999-02-11 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * main.c (save_default_calendar): New function. Saves the - calendar if it is the user's default calendar - - * gncal-full-day.c (unrecur_appointment): - * gncal-day-panel.c (day_view_range_activated): - * eventedit.c (ee_ok): - * gncal-todo.c (ok_button): Added autosave for the default - calendar. - -1999-02-09 Tomas Ogren <stric@ing.umu.se> - - * main.c: Removed the gtk_widget_realize call. - -1999-02-06 Changwoo Ryu <cwryu@adam.kaist.ac.kr> - - * gncal.desktop: Added Korean translations. - -1999-02-04 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (date_edit_new): New convenience function to create - a properly-configured date editor widget. - -1999-02-03 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-week-view.c (gncal_week_view_new): Make the calendar start - weeks on Monday if appropriate. - (gncal_week_view_time_format_changed): New function to notify the - week view that the time format has changed. - - * gncal-day-panel.c (gncal_day_panel_new): Make the calendar start - weeks on Monday if appropriate. - (gncal_day_panel_time_format_changed): New function to notify the - day panel that the time format has changed. - - * gnome-cal.c (gnome_calendar_time_format_changed): Tell the day - and week views that the time format has changed. - -1999-02-01 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (event_editor_init): Set the title of the event - editor window. - -1999-01-31 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-day-view.c (gncal_day_view_expose): Do not remove the - clipping rectangle here. - - * view-utils.c (view_utils_draw_events): Remove the clipping - rectangle here, since the user of this function should not know - about it. - -1999-01-30 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * view-utils.c (view_utils_draw_events): Improve this draw - routine. Now it can split the text in lines and fit as many - events as possible. - (nicetime): Return strings without spaces at the beginning. - - * gncal-day-view.c (gncal_day_view_expose): Move clip-clear - operation here. - -1999-01-29 Jason Tackaberry <tack@dok.org> - - * gncal-full-day.c (child_popup_menu): if the user clicks on an - event that is an occurance, the menu will allow the user to delete - all occurances of this event, or just the selected occurance. - (delete_occurance): added. - - * eventedit.c (append_exception): force the clist to select the - new exception. (fixes segfault) - (delete_exception): if the last exception in the clist is deleted, - move the selection index up. (fixes segfault) - -1999-01-28 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * main.c (parse_an_arg): Add --hidden key to hide the calendar at - startup. Only works with GNOME window managers though :-( - - * calendar.c (calendar_day_change): Reschedule alarms for the new day. - - (calendar_init_alarms): Schedule an alarm for midnight to change - the calendar_day_begin/calendar_day_end. - - * alarm.c (alarm_ready): If we reschedule, there is no need to - activate any pending alarms. - -1999-01-28 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (child_new): Insert the summary text here. - (child_focus_in): No need to raise the window, since we have - Spiffo(tm) layout code. Boy, this is old code. - (gncal_full_day_focus_child): Now that GtkText works better, we - can avoid synthesizing a click which was causing grief, anyway. - (child_button_press): Grab the focus before popping up the menu. - - * layout.c (find_index): Added a sanity check. - - * gncal-full-day.c (child_destroy): Unmap and unrealize the child - before unparenting/destroying it. - (child_unrealize): Unrealize the widget. What was I thinking? - (child_new): Save the focus_out_event signal connection id in - Child structure (in a new field). - (child_destroy): Disconnect from the focus_out_event signal, since - we don't want to get such an event when the widget is destroyed. - (gncal_full_day_destroy): Destroy the children properly; it was - leaking memory. - -1999-01-27 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * main.c (save_calendar_cmd): Warn if the calendar file has - changed. - - * calendar.c (calendar_load, calendar_save): Keep track of the - modification time for the calendar file. - -1999-01-20 Nat Friedman <nat@nat.org> - - * gncal-full-day.c (gncal_full_day_key_press): Only trap printable - characters such that hotkeys work. - (UNSELECT_TIMEOUT): Changed to 0. Much saner behavior. - - * prop.c (properties): Connect gnome_help_pbox_display to the - GnomePropertyBox help button. - -1999-01-19 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * quick-view.c (quick_view_do_popup): Do not grab the mouse here - (it was being grabbed incorrectly, anyways). - (quick_view_map_event): Grab the mouse when the window is mapped. - This avoids the ugly "while (xGrabPointer () != Success)" hack. - (quick_view_button_release): Handle button releases here. - -1999-01-19 Tomas Ogren <stric@ing.umu.se> - - * main.c: do gtk_widget_realize on the toplevel window.. - -1999-01-13 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-day-panel.c (gncal_day_panel_new): Make the little - calendar start up with the correct date. - - * gncal-week-view.c (gncal_week_view_set): Add the month to the - date range display label. - -1999-01-08 Nat Friedman <nat@nat.org> - - * main.c: Converted some more stuff to use the standards. - -1999-01-08 Nat Friedman <nat@nat.org> - - * main.c (setup_appbar): New function to create the status bar. - (setup_menu): Install menu hints. - - Menu items updated to match the standards. New Settings menu - created. - -1998-12-30 Jeff Garzik <jgarzik@pobox.com> - - * gncal/calendar.c, gncal/gnome-cal.c, gncal/main.c, - gncal/quick-view.c: - s/g_copy_strings/g_strconcat/ - -1998-12-16 Miguel de Icaza <miguel@nuclecu.unam.mx> - - Rewrote the old and broken alarm system. It never actually - worked properly. Now it works properly, and I figured a nice way - to get the Audio alarm do something nicer (it is now like an alarm - clock :-). - - * gnome-cal.c (calendar_notify): Now we take a CalendarAlarm to - actually distinguish which alarm was triggered. - - * alarm.c (alarm_ready): The code was only activating the first - alarm. Reschedule the timer upon delivery of an alarm. - -1998-12-14 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * year-view.c (idle_handler): Use the allocation size instead of - the old fields in the canvas structure. - - * goto.c (create_days): Use gtk_widget_set_usize() instead of - gnome_canvas_set_size(). - * quick-view.c (setup_event_list): Likewise. - -1998-12-09 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-todo.c (simple_todo_editor): Use gnome_dialog_set_parent. - * goto.c (goto_dialog): ditto - * prop.c (properties): ditto. - -1998-11-23 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * eventedit.c (ee_rp_init_exceptions): Update GtkClist usage. - -1998-11-23 Andrew T. Veliath <andrewtv@usa.net> - - * gncal-day-panel.c (gncal_day_panel_new): Use - gtk_scrolled_window_add_with_viewport instead of - gtk_container_add (gtk changes). - -1998-11-23 Herbert V. Riedel <hvr@hvrlab.ml.org> - - * eventedit.c: use GPOINTER_TO_INT - - * gncal-todo.c: same. - -1998-11-22 Matthew Wilson <msw@redhat.com> - - * main.c: Fixed the popt event parsing callback to have the - correct number of arguments. This stops it from segfaulting. - -1998-11-16 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (ee_classification_widgets): Doh. Fixed stupid bug - where the classification buttons were not being set correctly. - (ee_store_general_values_to_ical): Take into account the fact that - radio group lists are stored in reverse order of insertion. - - * gncal-todo.c (gncal_todo_init): Use a scrolled window to put the - clist into. - -1998-11-11 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calendar.c (calendar_save): Backup the old file before saving - the caledar. - -1998-11-06 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c: Add ctype.h - -1998-10-31 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gnome-cal.c (gnome_calendar_direction): Add the offset from the - beginning of the current time unit (day/month/etc), otherwise it - does not work right, for example, you are on the 31st day of a - month and the next month is a 30-day one and you jump to the next - month. - -1998-10-16 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * month-view.c: Changed a lot of stuff not to use the layout code - -- the month view's days are too small to display layout - usefully. Now they display a little list of the events in each - day. We also have a popup menu for the days in the month view. - - * calendar.c (calendar_get_objects_in_range): Reverse the list so - that it is returned in increasing order. - - * eventedit.c (event_editor_new_whole_day): New public function to - create an event for the complete span of day_begin to day_end. - - * year-view.c (new_appointment): Use event_editor_new_whole_day(). - - * year-view.c (yv_popup_menu): Mark strings for i18n. - -1998-10-12 Ji Lee <g@ucsd.edu> - - * eventedit.c (ee_store_recur_rule_to_ical): The interval was - never being loaded from the spin button. - -1998-10-09 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * month-view.c (month_view_update): Create a list of children and - lay them out nicely. Lots of functions added for this purpose. - (adjust_segment): Main event segment adjustment routine. - (adjust_children): Adjusts all the children in the month view. - (child_create_segments): Creates the segments for a particular event. - (layout_children): Uses the generic layout engine to organize the children. - -1998-10-08 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-todo.c (clist_row_selected): Set the sensitivity of the - edit/delete buttons. - (gncal_todo_update): Likewise. Thanks to Dirk Luetjens for the - bug report. - - * layout.c: Do some cleanup; now we pass a struct with the layout - algorithm's state instead of passing a trillion parameters around. - - * gncal-full-day.c (layout_children): Use the new generic layout - engine. - (child_compare): Sort keys are start time then end time, not just - start time. This produces somewhat nicer results for the layout - algorithm. - - The new layout code uses a partition of the time range occupied by - the events, rather than using a fixed time granularity. This is - better since the different parts of the program that use the - layout module will have different semantics regarding snapping the - event bounds to a fixed "time grid". - -1998-10-07 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * layout.[ch]: New files that abstract the event layout code from - gncal-full-day.c into something useful for other parts of the - program. Now all event layout is done here. - - * Makefile.am (gnomecal_SOURCES): Added layout.[ch] to the list of - sources. - -1998-10-07 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de> - - * main.c (main): Replaced the 'gnome_client_new_default' call with - 'gnome_master_client'. - -1998-10-02 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * timeutil.c (time_day_begin): Changed name from - time_start_of_day() to be consistent with the other begin/end functions. - (time_day_end): Likewise. - - * calobj.c (ical_object_get_first_weekday): New public function to - get the first toggled day in a weekday mask. Since we do not - support multiple weekdays in a monthly-by-pos rule, we just fetch - the first toggled one. - (ical_object_generate_events): Added a missing break statement. - - * timeutil.c (time_month_end): Made it consistent with the rest of - the time begin/end functions -- now it returns the first second of - the *next* month. - (time_week_end): Actually implemented this function. It will be - used when the week view is rewritten. - - * calobj.c (time_in_range): Fix off-by-one in the comparison of - the time against the end time. - - * gncal-full-day.c (expand_space): Fixed bug where the columns not - were being expanded due to a missing "slot + j". - -1998-10-01 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * month-view.c (month_view_init): Use the font #defines. - (month_view_new): Set the colors of the month view upon creation. - (mark_current_day): New function to mark the current day in the - month view. - (month_view_set): Mark the current day. - (month_view_colors_changed): Mark the current day and colorify the - month item appropriately. - - * month-view.h: Added year and month fields to the MonthView - structure. - - * main.c: Renamed the Appointments color property, since it will - be used by the month view as well. - - * goto.c (update): Set the current day's font and color. - - * year-view.c (year_view_init): Set the fonts of the month items - when creating them. - - * mark.h: Added new #defines for HEADING_FONT and TITLE_FONT. - - * year-view.c (year_view_init): Use the new font #defines. - - * prop.c (prop_apply_colors): Fixed to work with the - I-am-paranoid-and-I-need-to-size-my-ints changes to - GnomeColorPicker. - (color_spec_from_picker): Likewise. - -1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * goto.c (create_days): Colorify the month item and prepare it for - prelighting here. - - * main.c (color_props): Changed the default colors to something - not dull. - - * year-view.c (compute_min_size): New function to compute the - minimum size of the year view properly. - (year_view_size_request): Added two new fields to the year view - structure that contain the minimum size. Return this in the - size_request method. - (year_view_new): Call compute_min_size to save the minimum size - for later use. - (idle_handler): Make it resize the items correctly. - - * gnome-month-item.c (gnome_month_item_set_arg): Reshape when - necessary. This is needed becaues we now actually calculate a - minimum size for the month item based on the font sizes and paddings. - (check_heading_sizes): New function to calculate a minimum size - based on the headings' dimensions. - (check_day_sizes): New function to calculate a minimum size based - on the day number labels' dimensions. - (check_sizes): New function that computes a minimum size for the - month item. - (reshape): Now calls check_sizes() to ensure a minimum size for - the month item. - - * year-view.c (mark_current_day): New function to mark the current - day in the year view. - - * mark.c: Removed mark_current_day from here. - -1998-09-29 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * prop.c (fetch_color_spec): Changed name from fetch_prelight_spec - and made it conform to the new prelighting mechanism. - (fake_mark_days): Set the proper day attributes. - (reconfigure_month): Use colorify_month_item(). - (fake_mark_days): Use mark_month_item_index(). - - * mark.c (colorify_month_item): New public function to reset the - colors in a month item. - (get_attributes): New internal function that creates an array of - attributes for the days in a month item. This is the basis of all - the new optimizations to month item marking. - (unmark_month_item): Now it uses the attributes array to unmark - only the days that need unmarking. - (mark_event_in_month): Update the day attributes array. - (month_item_prepare_prelight): Changed the definition of the - prelight color query function. Use the new function. - (day_event): Do color changes based on the day attributes array. - (mark_month_item_index): New public function to mark a single day - by index. - (mark_event_in_month): Use mark_month_item_index(). - - * gnome-month-item.c (gnome_month_item_num2child): Now takes an - int, not a GnomeMonthItemChild. - (gnome_month_item_child2num): Now returns an int, not a - GnomeMonthItemChild. - (gnome_month_item_num2day): Now takes an int, not a - GnomeMonthItemChild. - - * goto.c (goto_dialog): Create the days before the year spin - button, because the year_changed callback expects the month item - to be created. The new semantics of the spin button cause it to - emit a value_changed signal on the adjustment upon creation -- is - this the behavior we want from it? - (goto_dialog): Use gtk_window_set_modal() instead of the - deprectaed gnome_dialog_set_modal(). - - * quick-view.c (quick_view_new): Make it look not as crappy by - putting the title inside the frame. - (quick_view_do_popup): Fixed the pointer grab and added a cursor. - (create_items_for_event): Query the text width/height from the - text item using the new object arguments, so that the size of the - popup window can be set properly. - - * year-view.c (do_quick_view_popup): Calculate a nice date string - for the popup window. - -1998-09-28 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * quick-view.[ch]: New file that presents a quick view of the - events in a particular day when the mouse is clicked on the year - view. Work in progress. - - * year-view.c (do_quick_view_popup): New function that creates a - quick view for the events in a day. - - * Makefile.am (gnomecal_SOURCES): Added quick-view.[ch] to the - list of sources. - -1998-09-27 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * main.c: Hotkey for File/Exit should be C-q, not C-x. - -1998-09-24 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * year-view.c (do_popup_menu): New function to execute the popup - menu in the year view. - (day_event): Invoke the popup menu with the context set to days. - (new_appointment): New function to create a new appointment from - the year view. - (do_jump): New function to do the appropriate view/date jumping - from the popup menu. - - * main.c: Fixed two icons in the File menu. - -1998-09-21 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * main.c: Added underlined shortcuts and accelerators to the main menu. - -1998-09-16 Raja R Harinath <harinath@cs.umn.edu> - - * gncal-week-view.c (<gtk/gtklabel.h>): Include. - * gncal-week-view.h (<gtk/gtkvbox.h>): Include. - -1998-09-06 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gnome-cal.c (mail_notify): Fixed the bug reported about the mail - notification not beint sent until the program was terminated. - -1998-09-03 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (gncal_full_day_forall): Updated foreach -> - forall from Gtk changes, bleah. - - * year-view.c (day_event): New function to handle events from - days. Jumps to the day that is clicked. - - * main.c: Use a watch cursor while the previous/today/next - functions are doing their job. - - * mark.c (month_item_prepare_prelight): New public utility - function to prepare a month item for prelighting. It will store - the proper prelight information and attach the appropriate signals. - (mark_current_day): Make the current day bold as well (useful for - color-blind people, I guess). - - * prop.c (set_current_day): Reset the date in the sample calendar - and mark the current day. - (fake_mark_days): Mark fake events in the sample calendar. - - * year-view.c (year_view_set): Use the general prelighting engine. - - * goto.c (day_event): Just process button presses, as prelighting - is done behind the scenes now. - (update): Use the general prelighting engine. - - * prop.c (create_colors_page): We can now configure the colors of - the monthly calendars! Wheeeeee! There are still some nits to be - fixed, which are listed in the TODO file. - (build_color_spec): New function to build color specifications. - (parse_color_spec): New function to parse color specifications. - - * mark.c: Modified all functions to use the configured colors. - * goto.c: Likewise. - - * main.c (colors_changed): New function that notifies all - calendars that colors have changed. - - * gnome-cal.c (gnome_calendar_colors_changed): New function that - notifies all the views that the colors have changed. - - * month-view.c (month_view_colors_changed): New function that - notifies the month view that colors have changed. - - * year-view.c (year_view_colors_changed): New function that - notifies the year view that colors have changed. - - * gnome-month-item.h (struct _GnomeMonthItem): Added fields for - outline and day box colors. - - * gnome-month-item.c (gnome_month_item_set_arg): Added - outline_color, outline_color_gdk, day_box_color, and - day_box_color_gdk arguments to month items. These are convenient - to quickly set the colors of the month item. - (gnome_month_item_get_arg): Likewise. - - * main.[ch]: Added a global array of structures for color preferences. - -1998-08-31 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * goto.c: Small code cleanup. - (day_event): Upon receiving a LeaveNotify event, Reset the day's - background to the correct color. - -1998-08-29 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * mark.[ch]: New files with utility functions to mark calendars - with their events. - - * mark.c (mark_month_item): New public function to mark a month - item with events. - (unmark_month_item): New public function to unmark all the days in - a month item to their default appearance. - - * year-view.c (year_view_set): Use the new unmark_month_item() and - mark_month_item() to mark the months with events. - - * goto.c (update): New function that updates the calendar in the - Go-to dialog by marking the days. - - * timeutil.c (time_year_begin): Modified to take a time_t value. - (time_year_end): Likewise. - (time_month_begin): Actually implemented this function, which was - in the header file but not here. - (time_days_in_month): New public function that returns the number - of days in a month. - - * Makefile.am (gnomecal_SOURCES): Added mark.[ch] to the sources. - - * year-view.c (unmark_days): Use unmark_month_item(). - - * gncal-full-day.c (gncal_full_day_destroy): Fixed crash when - destroying the full day view. The full day's destroy method is - unusual in that it destroys the list of child widgets itself, as - it does not have a remove method, so it needs to reset the list to - NULL. - -1998-08-27 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gnome-month-item.c (build_month): Now does the correct thing - when the user wants weeks to start on Monday. Now all the Monday - special casing, as far as day numbering is concerned, is only in - this function. - - * year-view.c (mark_days): This function marks the days that have - events in them. It also fixes a memory leak in the old - implementation (it was leaking the whole list). - (unmark_days): New function used to unmark all the days in the - year view. - (mark_event): New function that marks all the days that are - spanned by a time range. It also fixes the bug in the old - implementation where it could possibly mark days past the ends of - the year (if the event crosses year boundaries, for example). - - * timeutil.c (time_year_begin): Take the year parameter since year - 1, not 1900. - (time_year_end): Likewise. - - * year-view.c (year_view_size_allocate): Now changing the size of - the calendars is done in the idle loop. - (idle_handler): This function actually does the resizing of the items. - - * year-view.h (struct _YearView): Added idle_id and need_resize - fields. - -1998-08-26 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * year-view.c: Beginning of the new year view. Sizing and event - marking needs to be finished. - - * gnome-cal.c: Updated for year-view. - (gnome_calendar_time_format_changed): Use year_view_time_format_changed(). - - * year-view.[ch]: Renamed the gncal-year-view.[ch] files to - year-view.[ch]. - - * Makefile.am (gnomecal_SOURCES): Updated year-view.[ch] in the - list of source files. - -1998-08-25 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * goto.c (create_days): Set the heading color of the month item. - - * main.c: Use GNOME_STOCK_PIXMAP_JUMP_TO, now that it exists, - instead of goto.xpm. Also, removed goto.xpm from cvs. - - * gnome-month-item.h (struct _GnomeMonthItem): Added fields for - the heading and day number fonts. Added fields for heading and - day number label colors. - - * gnome-month-item.c (gnome_month_item_class_init): ARG_DAY_NAMES - should be write-only. Also, added arguments for heading and day - number fonts. Added arguments for heading and day number colors. - -1998-08-24 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * prop.c (build_two_radio_group): Doh. Set the state of the radio - buttons properly. - - * month-view.c (month_view_time_format_changed): New public - function that notifies the month view of a time format change. - - * gnome-cal.c (gnome_calendar_time_format_changed): New public - function that notifies the calendar of a time format change. - - * main.c (time_format_changed): Use gnome_calendar_time_format_changed(). - - * month-view.c (month_view_update): New public function to update - the month view when an event changes. This is still unfinished. - (month_view_set): New public function to set the month in the - month view. - - * gnome-cal.c (gnome_calendar_direction): Add case for month view. - (gnome_calendar_set_view): Likewise. - (gnome_calendar_update_all): Likewise. - - * timeutil.c (time_add_week): Implemented the time_add_week() - function, which was on the header file. - (time_add_month): Added public month-adding routine. - - * gnome-cal.c (gnome_calendar_get_current_view_name): Add case for - month view. - (gnome_calendar_goto): Likewise, and set the time on the month view. - - * month-view.c (month_view_new): Now it takes the calendar plus - the time_t representing the month. - - * gnome-month-item.h: Added documentation on the object arguments - for the month item. - - * month-view.c (month_view_init): Added a month/year heading to - the month view. - - * TODO: Updated the TODO list a bit. - - * main.c (gnome_cal_file_menu): The preferences menu option should - go in the File menu. - (gnome_cal_edit_menu): Added stock pixmaps to the menu items. - (gnome_cal_menu): Renamed the Calendar menu to Edit. - (gnome_cal_help_menu): Use "About Gnomecal", not just "About". - - * prop.c (hour_activated): Notify the property box that it has changed. - - * main.c: Changed the Properties menu item to Preferences. These - are global application preferences, not a single calendar's - properties. - - * prop.c (prop_apply): Save the week_starts_on_monday flag to the - configuration file. - (properties): Added a check button for weeks starting on Monday. - (properties): Beautified the Preferences dialog. - - * month-view.c (month_view_init): - * goto.c (create_days): Set the month item to start weeks on - Monday if appropriate. - - * main.c (init_calendar): A boolean is not an hour, so don't - range_check_hour() on it. - (init_calendar): Added a global week_starts_on_monday flag. - - * main.h: Added global week_starts_on_monday flag. - -1998-08-21 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (ical_object_create_from_vobject): If mail alarm or - program alarm are missing the action, then set an empty default. - -1998-08-18 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gnome-month-item.c (gnome_month_item_day2index): New public - function to get the displayed day index of the specified date. - - * gnome-cal.c (gnome_calendar_goto_today): New public function to - jump to the current day. - - * goto.c (day_event): Jump to the selected day when the user - clicks the mouse, and prelight days as appropriate. - - * timeutil.c (time_from_day): New public function to build a - time_t from a year/month/day triplet. - - * gnome-month-item.c (gnome_month_item_num2child): - (gnome_month_item_child2num): New public functions to convert an - index into a child and vice-versa, respectively. - (gnome_month_item_num2day): New public function to convert a child - number into a displayed day number. - - * goto.c (goto_dialog): Doh, use gnome-dialog properly :-) - - * gnome-month-item.c (create_items): Use g_strdup()ed day names - from the start. - -1998-08-17 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * main.c (gnome_toolbar): Made it use goto.xpm. - - * Makefile.am (EXTRA_DIST): Added goto.xpm to the list of files. - -1998-08-13 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gnome-month-item.c (gnome_month_item_set_arg): Doh. Actually - recalculate the days using the month and year. - - * main.c: Added "Go to" button to quickly jump to a specific date. - - * goto.c: New file that defines the quick go-to date dialog. - - * Makefile.am (gnomecal_SOURCES): Added goto.c to the sources. - -1998-08-11 Nuno Ferreira <nmrf@rnl.ist.utl.pt> - - * main.c (new_calendar): Made title i18n friendly. This was bug - #215. - - * eventedit.c (ee_store_recur_end_to_ical): Set recur->enddate to - recur->_enddate, not to itself, when adding recurring event and - supplying an end date. This fixes (at least part of) bug #99. - -1998-08-10 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * month-view.[ch]: Start of the month view widget. This will use - the generic month item and extend it to have the semantics desired - for the gnomecal month view. - - * gnome-month-item.[ch]: New generic canvas item for the month - view and the "small calendars". This is intended to be a - high-level display engine for monthly calendars. This is a work - in progress. - - * gnome-cal.h (GnomeCalendar): Added a month_view field. - - * gnome-cal.c (setup_widgets): Create the month view and insert it - into the notebook. - - * Makefile.am: Added month-view.[ch] and gnome-month-item.[ch] to - the sources. - -1998-08-03 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * main.c (about_calendar_cmd): Use an array of const strings to - keep gcc happy. - - * alarm.c (alarm_compare_by_time): Use gconstpointer to keep gcc happy. - * calendar.c (calendar_object_compare_by_start): Likewise. - * gncal-full-day.c (child_compare_by_start): Likewise. - -1998-07-07 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * main.c: Add support for --view flag. - (session_save_state): Save the view mode; - (new_calendar): Now takes a view mode flag. - - * gnome-cal.c (gnome_calendar_get_current_view_name): New - function for enhancing the session management support for - gnomecal. - (gnome_calendar_set_view): New function that makes a given page - active. - -1998-07-01 Nuno Ferreira <nmrf@rnl.ist.utl.pt> - - * gncal.desktop: Added Portuguese translation. - -Mon Jun 22 13:01:16 1998 Havoc Pennington <hp@pobox.com> - - * main.c (session_save_state): Use gnome_geometry_string to get - the geometry string. - -1998-06-04 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (ee_rp_init_rule): Do not subtract 1 from - tm->tm_mday for the default_day. - - * gnome-cal.c (gnome_calendar_new): - (gnome_calendar_goto): Use the start of the day -- things expect - it to be that way. - -1998-05-27 Nuno Ferreira <nmrf@rnl.ist.utl.pt> - - * eventedit.c (ee_store_recur_rule_to_ical): Fill in - ical->recur->interval from value in spin_button. This ixed an - infinnite loop. - -1998-05-30 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (child_draw): Paint the decorations correctly. - (child_draw_decor): Paint the recurrence/bell icons correctly. - -1998-05-25 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * eventedit.c (ee_rp_init_rule): Use the contents of - ee->ical->dtstart for computing the predefined values of the recurrence. - - * gncal-full-day.c (gncal_full_day_unrealize): Fix the gc - destruction in the unrealization code and fix the pixmap unrefing. - - * main.c (close_cmd): Remove a bad hack that disabled calendar - widget destruction. - - * calobj.c (ical_object_generate_events): Fix for the weekly event - generation. Was reported on the bug tracking system. - -1998-05-18 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-full-day.c (layout_children): Implemented ultra-cool - layout for the events that share the same time range. Gals and - guys you can now drop Outlook on the recycle bin. - - Which reminds me. We do not have a recycle bin. How could that - happen in a project as cool as this one? Someone explain this to - me. - -1998-05-18 Federico Mena <federico@nuclecu.unam.mx> - - * gncal-full-day.c (paint_back): Eliminated unnecessary border repainting. - -Sun May 17 17:55:03 1998 Havoc Pennington <hp@pobox.com> - - * gncal-todo.c (simple_todo_editor): Close dialog when return is pressed. - -1998-05-15 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gnome-cal.c (mark_gtk_calendar_day): Bug free version of the - range computation in place. - - * gncal-year-view.c (year_view_mark_day): Use the same new version - of the range computation here. - - * calobj.c (ical_object_generate_events): Fix the begin/end - condition. - -1998-05-14 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * timeutil.c (isodate_from_time_t): Do not add the spurious - padding. - - * calobj.c (store_date_list): Bug fix: I was using the wrong - pointer when saving the exception date list. - (set_date_list): Bug fix: load correctly the complete exception - date list. - (set_date_list): Use ',' for the exception date separator as the - versit people can not get their standard right. - - * gncal-full-day.c (unrecur_appointment): Support for making an - existing recurrent event `movable' for a day. - - * calobj.c (ical_object_add_exdate): New routine, used to add - exception dates. - (ical_object_duplicate): New routine: used to do the magic - recur->no-recur event. - -1998-05-08 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-full-day.c (new_appointment): Use gtk_calendar freeze/thaw - - * gncal-year-view.c (gncal_year_view_set_year): Use gtkcalendar freeze/thaw. - - * eventedit.c (event_editor_init): Use gnome_dialog_set_close to - avoid the ugly warning. - - * main.c (display_objedit): Default to the day the user is looking - at. - -1998-05-05 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-day-panel.c (full_day_size_allocated): Do not emit a value - changed signal if the value is the same. - -1998-05-04 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * prop.c (prop_apply): Only run the apply code once. - -1998-05-03 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-day-panel.c (update): Draw the day at startup. - (gncal_day_panel_set): Fix selected-day display. - (gncal_day_panel_new): Switch day on double clicks, not on single - clicks. - - * calobj.c (ical_object_compute_end): Removed debug messages. - -1998-04-30 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * prop.c (prop_apply): Do not call prop_cancel, ths is now using - GnomePropertyDialog. - -1998-04-29 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-week-view.c (sync_week): Use gnome_calendar_tag_calendar. - - * gnome-cal.c (gnome_calendar_tag_calendar): New routine used to - fill a gtk_calendar with the events on a GnomeCalendar object. - - * gncal-week-view.c (gncal_week_view_new): Set the week to the day - we double clicked. - -1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gnome-cal.c (calendar_notify): Apply black magic to get mail - notifications to work. - - * gncal-full-day.c (child_focus_out): Temporary optimization, the - child_focus_out is constantly calling the - gnome_calendar_object_changed when the property editor has been - invoked. This happens every time the mouse moves crosses the main - window. - - * calendar.c (calendar_object_changed): Reschedule alarms when a - calendar object has changed its times. - -Sat Apr 25 22:20:45 1998 Havoc Pennington <hp@pobox.com> - - * eventedit.c, eventedit.h: Descend from GnomeDialog. Took vbox - out of class structure; use GnomeDialog vbox - instead. gnome_dialog_set_destroy instead of destroying in button - callbacks. Don't create buttons, separator, or vbox manually. - #include <libgnomeui/gnome-dialog.h>. - -1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (ical_object_create_from_vobject): Fixed alarm loading; - Load snooze time and snooze count - -1998-04-23 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * calendar.c (calendar_save): Actually save the to-do entries. - - * gncal-todo.c (simple_todo_editor): Now you can add and edit - to-do entries. - -1998-04-22 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c: Made it use popup_menu(). - - * popup-menu.c: New file with utility functions for creating popup - menus. Maybe such a thing would be useful in libgnomeui, a la - gnome-app-helper? - - * Makefile.am (gnomecal_SOURCES): Added popup-menu.[ch] to the sources. - -1998-04-22 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * prop.c (properties): Added Calendar properties editor. - (properties): Make the code use a propery box. - - * main.c: Save/load properties (fix to old commit). - -1998-04-21 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-todo.c: New widget for editing TODO lists. This will be - worked on a lot. - - * Makefile.am (gnomecal_SOURCES): Added gncal-todo.[ch] to the sources. - - * gncal-day-panel.c: Make it use the new TODO widget. - -1998-04-21 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * timeutil.c (isodate_from_time_t): Do not save with the global - time flag (Z at the end of the isodate). When we figure out a way - to load times in GMT time, we will add this back - - * view-utils.c (popup_menu): Moved this routine here as there are - more users of this code. - - * gncal-day-view.c (gncal_day_view_class_init): Add button press - handler. - (new_appointment): New routine for creating appointments on a day. - - - - * main.c (save_ok): Added call to gtk_window_set_wmclass. - - * gncal-day-panel.c (calendar_day_selected): Fix, years for mktime - should substract 1900 and gtk_calendar stores years relative to - year 0. - - * gncal-week-view.c (gncal_week_view_new): Make the week view - descend from VBox so that we can add a label to it. - (gncal_week_view_set): Display the ending day of the week - correctly. - - Added a label that displays the week range. - -1998-04-21 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gnome-cal.c: Made it use GncalDayPanel. - - * gncal-day-panel.c: New widget for the day view in the main - calendar toplevel. It basically takes care of everything - gnome-cal did by hand with respect to the day view. - - * Makefile.am (gnomecal_SOURCES): Added gncal-day-panel.[ch] to - the rules. - - * main.c: Added a separator between the About menu item and the - help topics. - -1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * eventedit.c (ee_ok): Mark the event as non-new after accepting changes. - -1998-04-20 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (gncal_full_day_get_day_start_yoffset): New - public function that returns the y offset for the row - corresponding to the "day begin" time. - - * gncal-full-day.c (gncal_full_day_key_press): Now any printable - keystroke (not just Return) will activate the selected range. - - * gncal-full-day.c (paint_back): Made it use the new paint_row - function instead of painting everything directly. We calculate - areas in a smarter way so there is even less flicker than before, - especially when selecting regions. - - * eventedit.c: Sensitize recurrence widgets properly. - - * calobj.c (duration_callback): Pass the correct pointer type to - is_date_in_list(). - -1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (duration_callback): Take exception dates into - account. - - * gncal-full-day.c (new_appointment): Setup the event editor dates - to those of the currently displayed day. - (gncal_full_day_selection_range): Use sensible values in the case - no range is selected. - (new_appointment): Events now use the current day for event creation. - - * view-utils.c: Pretty up the time display. - - * calobj.c (ical_object_compute_end): Initialize - ico->recur->enddate, otherwise we loop forever during final date computation. - - * eventedit.c: Now recurrence is toggled by a radio button in the - recurrence page, as the checkbox is confusing. - - * calobj.c (is_date_in_list): Add support for the exclussion - dates. - -1998-04-18 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-year-view.c (double_click): Fix this routine as well. - - * gncal-week-view.c (jump_to_day): Bind the gtkcalendar signals to - the week. - - * gncal-year-view.c (gncal_year_view_set_year): Put things in the - proper range. Now the year view actually matches this year. - - * gnome-cal.html: Added small documentation. - - * main.c: Add more icons to the menus; Rename some menubar - entries; Add `new' icon to the toolbar. - (dump_events): Added argument handling and dumping of events from - the command line. Extremely cool. - - * getdate.y: Taken from the CVS source code. Used for date - parsing in the command line. - - Internationalized getdate.y. Wee! It even works with spanish. - - * calobj.c (ical_object_to_vobject): Add Quoted printable property - to items containing new lines. - (duration): Use unsigned integers, to work around buggy calendar - files generated by korganizer. - - * main.c (save_calendar_cmd): Do not ask for file name if we are - saving. - (save_as_calendar_cmd): New command. - - -1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * alarm.c (alarm_kill, alarm_init, alarm_add): Implement the alarm - management framework. - -1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * calobj.c (ical_new): Added mandatory status property. - (ical_object_to_vobject): Only store "related" list if it exists. - (store_list): Add terminating null char and free the correct data. - - * main.c (save_calendar_cmd): Implemented calendar saving. - (open_calendar_cmd): Implemented calendar loading. - (new_calendar_cmd): Implemented calendar creation. - (new_calendar): Don't load our test calendar by default. - - * gncal-full-day.c (delete_appointment): Delete appointment implemented. - - * eventedit.c (ee_store_recur_values_to_ical): Free/create - ical's recurrence appropriately. - (ee_rp_init_rule): Initialize all missing parameters from ical. - (ee_rp_init_ending_date): Initialize missing fields from ical. - -1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gnome-cal.c (gnome_calendar_remove_object): Add support for - removing objects. - -1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (ee_init_recurrence_page): New function that creates - the recurrence page in the toplevel notebook. - (ee_store_recur_values_to_ical): Now we can also store the recurrences. - -1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (ical_object_generate_events): Implement - RECUR_MONTHLY_BY_POS implemented. - (ical_object_create_from_vobject): Fix the alarm - initialization code. - (save_alarm): Save alarms. - (ical_object_generate_events): Fixed the recurrent code to take - into account the recur->endate field (if at all specified). - - (ical_object_to_vobject): Implement recurrence rule saving. - -1998-04-16 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (ee_store_alarm): Use menu_shell->children, not - menu->children. Why does GtkMenu have a children field in the - object structure? - (check_dates): New function that insures that start_date < end_date. - (check_times): In addition to checking whether the event spans the - whole day, now it insures that start_time < end_time. - - * gncal-full-day.c (child_set_size): Now children get bigger - temporarily while they are focused. This allows the handles not - to "overlap" the rows used by the child and thus allow editing of - very thin events. - (recompute_motion): Fix for new child coordinates. - (gncal_full_day_expose): Make it use find_child_by_window() - instead of looking for it by hand. - - * bell.xpm recur.xpm: XPM files for events with alarm and - recurrence, respectively. - -1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (button_1): Preserve the up/down cursor while dragging. - - * gncal-full-day.c (child_draw): Now children have a vertical - handle as well. This can be used to move the child anytime, not - only when it is focused. - (recompute_motion): Modified for new drag behavior. - - * eventedit.c (ee_init_general_page): The general_owner may be - null. Do the proper thing when creating the label. - (ee_ok): Update the gnome calendar appropriately. - - * timeutil.h: - * gncal-year-view.h: Add some missing prototypes. - - * gncal-full-day.c (child_popup_menu): Set the sensitivity of menu - items according to whether the ical object is being edited or not. - - * eventedit.c (event_editor_new): Set the "being edited" flag on - the ical object (stored as the ical object's user data). - (event_editor_destroy): Release the flag. - - * calobj.h: The iCalObject structure now has a generic user_data pointer. - * calobj.c (ical_object_set_user_data ical_object_get_user_data): - Functions to set this data. - - * gncal-full-day.c (child_button_press): Do child popup menu correctly. - - * main.c (about_calendar_cmd): Fixed my address and added Arturo - to the authors in the about box. - - * gncal-full-day.c (find_child_by_window): Compare child's widget - windows by user_data (which will be the parent widget, that is, - the text widget). We cannot assume that child->widget->window - will be *the* window we are interested on because there may be - child widgets with multiple windows. - -1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * calobj.c (ical_foreach): Define iterator routine. - -1998-04-15 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx> - - * gncal-year-view.[hc]: Now using time_t for new and set. - Random fixes, as well. - -1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (button_3): New popup menus activated with - mouse button 3. - (create_appointment): Create a new appointment from the popup - menus. See the FIXME. - -1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-full-day.c (layout_kill_rows): Routine to destory rows - array properly. - - * gncal-year-view.c (gncal_year_view_new): Add missing year in - call to strftime. - - * calobj.c (ical_object_create_from_vobject): Fixed memory leaks - from the return values of versit's fakeCString. - -1998-04-14 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx> - - * gncal-year-view.[hc]: New widget for the year view. - * Makefile.am: added required compilation of the new files. - -1998-04-14 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (event_editor_setup_time_frame): Fixed some table - expansions to make the dialog look nicer when resized. - - * calobj.c (ignore_space): Fixed compiler warning about unused - computed value. - (ocurrencelist): Replace str by p confusion. Removed unused - variables value and q. - (daynumber): Fixed a couple of warnings about unused values. - (load_recurrence): Removed unused variable c. Added a default - clause to the switch(type). - - * eventedit.c (ee_rp_init_frequency): Removed unused variable content. - Fixed a compiler warning by adding a missing cast. - - * calobj.c (ical_object_create_from_vobject): Make the - load_recurrence() part work correctly. Eliminated use of - syntax_error variable. - -1998-04-13 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (child_key_press): Unfocus the child and focus - the parent fullday widget when the user presses Esc. - - * gncal-week-view.c (gncal_week_view_update): Now takes object and - flags parameters. - * gncal-day-view.c (gncal_day_view_update): Likewise. - * gncal-full-day.c (gncal_full_day_update): Likewise. - (child_focus_in): New function. In conjunction with - child_focus_out(), these only display the handles in the child - when it is focused. The result is that the user can see more of - the child's text when nothing is focused, and we can also display - fatter and nicer drag handles. - - * gnome-cal.c (gnome_calendar_object_changed): Now takes an - additional flags parameter - (gnome_calendar_update_all): Made function static. Now takes - changed object and flags parameters as well. - (gnome_calendar_object_changed): Now takes additional flags - parameter to indicate what changed in the specified object. - - * calobj.h (CalObjectChange): New enum with flags to describe what - has been changed in an object. - - * gncal-full-day.h: - * gncal-full-day.c (gncal_full_day_focus_child): New function to - let the outside world decide which child to focus. - (gncal_full_day_focus_child): Bleah. We have to synthesize a - click because GtkText will not set the cursor when you focus it. - - * gnome-cal.c (day_view_range_activated): Focus the new child in - the full day widget. - - * eventedit.c (event_editor_setup_time_frame): Re-aligned some - widgets to make it look prettier. - (ee_alarm_widgets): Likewise. - (ee_init_general_page): Likewise. - (ee_classification_widgets): Likewise. - (event_editor_init_widgets): Likewise. - - * gnome-cal.c (day_view_range_activated): Create new object and - add it to the calendar. You can now select a range in the - full-day view, hit Return, and a new event will be added at the - selected range. I still have to figure out how to focus this new child. - - * gncal-full-day.c (paint_back): Rewrote function to avoid - painting an area more than once -- eliminate flicker. - (paint_back_rows): New function that calls paint_back() only for - the area of the specified rows. - (gncal_full_day_button_press): - (gncal_full_day_button_release): - (gncal_full_day_motion): Made these functions use - paint_back_rows() instead of paint_back(), to eliminate flicker. Wheee! - -1998-04-12 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gnome-cal.c (setup_day_view): We now connect to the - range_activated signal of the fullday widget instead of catching - key presses ourselves. - (day_view_range_activated): New function that creates a new - iCalObject and inserts it into the calendar, not finished yet. - -1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (get_time_from_rows): New function, calculates - a pair of time_t values from the specified start and number of rows. - - * gncal-full-day.h (GncalFullDayClass): New signal - "range_activated". It is emitted when a range is selected and the - user hits Return. - (gncal_full_day_selection_range): New function, returns the - selected range. - - * gncal-full-day.c (struct drag_info): Moved selection information - to their own fields instead of sharing the child's drag fields. - This allows us to keep the selection when a child is moved. - (recompute_motion): Made the case when (row < di->sel_click_row) - work correctly. - -1998-04-11 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gnome-cal.c (gnome_calendar_goto): Add support for navigating - on the day view. - - * timeutil.c (time_start_of_day, time_end_of_day, time_day_hour): - New time manipulation functions. - - * eventedit.c (ee_rp_init_frequency): Add the different frequency - editors to a notebook. Make the notebook startup on the entry - selected recurrence type; - -1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c (recompute_motion): Now we support selecting a - range in the main window (by clicking+dragging). It flickers - horribly and is not perfect, but it is a start. - -1998-04-09 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c: #include <string.h> - - * gncal-full-day.c (child_map): Show instead of just map the child - widget (otherwise the text widget gets confused and will not focus). - - * calobj.c (ical_object_to_vobject): Quote chars as 'x', not "x". - - * calobj.h: Added prototype for ical_object_to_vobject(). - - * gnome-cal.c (gnome_calendar_object_changed): New function. This - should be called when a calendar object is changed. - - * gncal-full-day.c (update_from_drag_info): Call - gnome_calendar_object_changed() instead of updating manually. - - * calendar.c (calendar_add_object): - (calendar_remove_object): Set the modified flag to true. - - * gncal-full-day.c (gncal_full_day_draw): Finished implementing - this function. - -1998-04-08 Raja R Harinath <harinath@cs.umn.edu> - - * gncal.c (update_calendar): Say `#if 0', not `#ifdef 0'. - -1998-04-07 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c: Removed unused global variable parent_class. - - * eventedit.h: Renamed gtk_window field to window. - Made the parent_class field in the EventEditorClass structure be a - GtkWindowClass, not a gnome property box class. - Added prototype for event_editor_get_type(). - -1998-04-06 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-week-view.c (gncal_week_view_new): Use the new - gtk_table_set_homogeneous() instead of setting the variable directly. - -1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * eventedit.c (ee_create_ae): Make it return void. - (ee_alarm_widgets): Remove some unused variables. - (ee_store_alarm): Make it return void. - #include <string.h> - - * eventedit.h: #include "gnome-cal.h" - - * calobj.c (list_free): Don't use g_free in the g_list_foreach. - - * calendar.h: Add prototype for calendar_load(). - - * timeutil.h: Add prototypes for time_add_*(). - - * calendar.c: - * calobj.c: - * eventedit.c: - * gnome-cal.c: #include "timeutil.h" - - * gncal-day-view.c (gncal_day_view_size_request): Make the minimum - width equal or larger to the title width. - - * main.c: #include "eventedit.h" - (main): Add a return statement. - (new_calendar): Show stuff *after* the calendar has been loaded. - - * gnome-cal.c (gnome_calendar_load): Update the day view. - (setup_widgets): Hackish setup of a day view widget - will fix later. - (gnome_calendar_init): Initialize all fields. - - * gnome-cal.h: Added day_view field. Maybe this should be changed - when the a complete day view panel is complete. - - * gncal-day-view.c (gncal_day_view_update): Draw after update, not - before. - -1998-04-06 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de> - - * versit/.cvsignore: New file. - -Fri Apr 3 22:31:54 1998 Tom Tromey <tromey@cygnus.com> - - * calendar.c: Include <config.h>. - -1998-04-03 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * timeutil.c (time_add_year, time_add_year, time_add_week): - Routines for time manipulation. - - * calobj.c (ical_object_destroy): Full destruction of the object. - - * eventedit.c: Finished the main event editor form; It still - lacks the details and the recurrence bits. It now adds events - and cancels. - -1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * view-utils.c (view_utils_draw_events): The "better" format - string for strftime() wasn't better, after all :-( - -1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-full-day.c: New full-day widget. It is still a work in - progress. It will be similar to M$ Schedule's nifty full day view - widget, but with Gtk's elegance :-) - - * Makefile.am (gnomecal_SOURCES): Added gncal-full-day.[ch] to the sources. - -1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * eventedit.c: Object editor widget. We dropped ObjEdit. - - * timeutil.c (time_from_isodate): Fix. - - * view-utils.c (view_utils_draw_events): Changed the display - formats. - -1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * view-utils.c (view_utils_draw_events): Use better format - specifier for strftime(). - (view_utils_draw_textured_frame): Ultra-nifty function to draw - textured "metal" frames, like Netscape's handles. - -1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * gncal-day-view.c (gncal_day_view_update): Day events are now - cached inside the widget. They get initialized at this time. - - * view-utils.c (view_utils_draw_events): Use the list of events. - -1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-day-view.c (gncal_day_view_set_shadow): New customization - function. We can't decide on a stupid border type :-) - (gncal_day_view_init): Made GTK_SHADOW_ETCHED_IN be the default - shadow type. Looks good. - -1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * main.c: New main program that uses our new datatypes and - objects. - - * calendar.c (calendar_load_from_vobject, calendar_load): - Implement loading of vCalendar objects and vCalendar files. - - * calobj.c (ical_object_create_from_vobject): Implement loading of - vCalendar event and todo objects. - - * timeutil.c (isodate_from_time_t): New function. - - * gnome-cal.c, gnome-cal.h: Implement a toplevel widget, derived - from GnomeApp. It holds all of the day views and arbitrates the - display. - -1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-week-view.[ch]: New week view composite widget. This - provides a full week view (7 day views plus busy time display -- - the latter is currently unimplemented). - -1998-04-01 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal-day-view.c: New day view widget. It is intended to be a - child widget of the week view composite widget. - - * calendar.c (calendar_get_objects_in_range): - (calendar_get_events_in_range): - (calendar_get_journal_in_range): - (calendar_get_journal_in_range): These functions now take a - sort_func parameter, which is of type GCompareFunc. If the - specified value is non-NULL, it will return a sorted list. - Otherwise, it will return an unordered list. - (calendar_compare_by_dtstart): Provide a generic sorting routine - for calendar objects. - -1998-04-01 Miguel de Icaza <miguel@kernel.org> - - * Start from scratch - -Tue Mar 31 23:46:50 1998 Tom Tromey <tromey@cygnus.com> - - * timeutil.c (format_simple_hour): `buf' now static. - -1998-03-31 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal.c: Removed #include "gtkcalendar.h", because it now comes - from libgnomeui. - - * Makefile.am (gncal_SOURCES): Added new source files to the rules. - - * timeutil.c (format_simple_hour): New function, formats an - hour/am_pm pair into a string of the form "3am", "12pm", "05h", - "19h", etc. It is used by the day view widget for its labels. - -1998-03-31 Craig Small <csmall@small.dropbear.id.au> - - * Now has (non working) session maangement - * Uses a clist for the dailylist like gtt - -Sat Mar 21 15:43:20 1998 Tom Tromey <tromey@cygnus.com> - - * gncal.c: Use gnome_message_box_*, not gnome_messagebox_*. - -1998-03-12 Craig Small <csmall@small.dropbear.id.au> - - * Now linked (in some horrible way) to the gtkcalendar widget. - -Sun Mar 8 16:38:10 1998 Tom Tromey <tromey@cygnus.com> - - * Makefile.am (INCLUDES): Added GNOME_INCLUDEDIR. - (gncal_LDADD): Don't include libsupport.a. - - * gncal.c (main): Use new gnome_init. - -1998-02-19 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal.c (main): Added app_id "gncal". - -1998-02-19 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de> - - * Makefile.am (gncal_LDADD): Added '$(INTLLIBS)' - -1998-02-18 Raja R Harinath <harinath@cs.umn.edu> - - * Makefile.am (gncal_LDADD): Include `libsupport.a'. - - * calcs.c (month_atoi): Replace buggy explicit loop string compare - with strcasecmp. - (day_atoi): Likewise. - -Sun Jan 25 23:38:30 1998 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * menus.c: Replace "Quit" with "Exit". diff --git a/calendar/Makefile.am b/calendar/Makefile.am deleted file mode 100644 index 82accbfda5..0000000000 --- a/calendar/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -SUBDIRS = idl cal-util pcs cal-client -#SUBDIRS = idl cal-util pcs cal-client gui conduits diff --git a/calendar/TODO b/calendar/TODO deleted file mode 100644 index 4a5dd6c6ff..0000000000 --- a/calendar/TODO +++ /dev/null @@ -1,88 +0,0 @@ -Cal-util: - -- calobj.h depends on libversit/vcc.h, because it uses a VObject for - ical_object_create_from_vobject(). This should be an internal - function in the PCS and nothing else (we do not install libversit, - so our public libraries should not depend on it). - -- Or maybe we *should* install libversit, since the addressbook code - uses it as well. - -- timeutil has a lot of crap and some namespace pollution. Clean it - up. - -PCS: - -- When loading a calendar, substitute duplicated UIDs by new ones, and - possibly print out a warning message. - ------ Old Gnomecal TODO starts here ----- - -Pilot: - -* Better support for untimed events (we have none now). - -* Hash objects based on their UIDs. - -* Add placeholders for deleted events, so that we can kill those - when syncing to the pilot. - -BUGS: - -- Recurrence end date is wrong. An event that repeats daily will not - be included in the ending date of the recurrence (off-by-one - error?). - -- X-fields (extensions) are stripped from a vCal file when it is - saved. They should be preserved. - -Features: - -- Add a calendar-week so that people know which week of the year it is - -Year view: - -- See why it is so fucking slow when opening its notebook page for the - first time. - -Month view: - -- Popup menu like in the year view. - -- Double click on a day takes you to the day view. - -- DnD of appointments to move them around. - -Week view: - -- Nice display as in the Palm Pilot. - -Day view: - -- Rewrite in terms of the canvas and make it pretty. - -Preferences: - -- BUG: 12/24 hours stuff is not consistent - I remember that on editing - new appointment you get the time-selectors always on 12-hr format - -Event editor dialog: - -- Make it figure out whether the alarm is in - minutes/hours/days/etc. (via a cascade of conditions) and set the - widgets appropriately. - -Gnome date selection widget: - -- Make the displayed date be localized properly -- use strftime(). - -General: - -- Write online help. Nice help. Lots of help. - -- If you leave the calendar running overnight, the "current day" - marker in the GnomeMonthItems does not get updated. - -- Add categories support. Color-coded categories. - -- Untimed events diff --git a/calendar/cal-client/.cvsignore b/calendar/cal-client/.cvsignore deleted file mode 100644 index 6ac95f13c4..0000000000 --- a/calendar/cal-client/.cvsignore +++ /dev/null @@ -1,17 +0,0 @@ -Makefile.in -.deps -.libs -.pure -Makefile -evolution-calendar-stubs.c -evolution-calendar-skels.c -evolution-calendar-common.c -evolution-calendar.h -evolution-calendar-common.lo -evolution-calendar-skels.lo -evolution-calendar-stubs.lo -cal-client.lo -cal-listener.lo -libcal-client.la -client-test -libcal-client-static.la
\ No newline at end of file diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am deleted file mode 100644 index 8a88215257..0000000000 --- a/calendar/cal-client/Makefile.am +++ /dev/null @@ -1,71 +0,0 @@ -# -# libcal-client -# - -CORBA_GENERATED = \ - evolution-calendar.h \ - evolution-calendar-common.c \ - evolution-calendar-skels.c \ - evolution-calendar-stubs.c - -idls = \ - $(srcdir)/../idl/evolution-calendar.idl - -idl_flags = `$(GNOME_CONFIG) --cflags idl` -I $(datadir)/idl - -$(CORBA_GENERATED): $(idls) - $(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/evolution-calendar.idl - -INCLUDES = \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - -DG_LOG_DOMAIN=\"cal-client\" \ - -I$(top_srcdir)/calendar \ - -I$(srcdir) -I$(top_srcdir) \ - -I. \ - -I.. \ - -I$(top_builddir) \ - -I$(top_builddir)/libical/src/libical \ - -I$(top_srcdir)/libical/src/libical \ - $(BONOBO_GNOME_CFLAGS) - -lib_LTLIBRARIES = libcal-client.la - -libcal_clientincludedir = $(includedir)/evolution/cal-client - -libcal_client_la_SOURCES = \ - $(CORBA_GENERATED) \ - cal-client.c \ - cal-listener.c \ - cal-listener.h - -libcal_clientinclude_HEADERS = \ - cal-client.h - - -# -# make a static library for use by calendar conduit's shared library -# -noinst_LTLIBRARIES = libcal-client-static.la -libcal_client_static_la_SOURCES = $(libcal_client_la_SOURCES) -libcal_client_static_la_LDFLAGS = --all-static - - -# -# client-test program -# - -noinst_PROGRAMS = client-test - -client_test_SOURCES = \ - client-test.c - -client_test_INCLUDES = \ - $(INCLUDES) \ - -DG_LOG_DOMAIN=\"client-test\" - -client_test_LDADD = \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical.a \ - libcal-client.la diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c deleted file mode 100644 index b038c26752..0000000000 --- a/calendar/cal-client/cal-client.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar client - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - -#include "cal-client.h" -#include "cal-listener.h" - - - -/* Loading state for the calendar client */ -typedef enum { - LOAD_STATE_NOT_LOADED, - LOAD_STATE_LOADING, - LOAD_STATE_LOADED -} LoadState; - -/* Private part of the CalClient structure */ -typedef struct { - /* Load state to avoid multiple loads */ - LoadState load_state; - - /* The calendar factory we are contacting */ - Evolution_Calendar_CalFactory factory; - - /* Our calendar listener */ - CalListener *listener; - - /* The calendar client interface object we are contacting */ - Evolution_Calendar_Cal cal; -} CalClientPrivate; - - - -/* Signal IDs */ -enum { - CAL_LOADED, - OBJ_UPDATED, - OBJ_REMOVED, - LAST_SIGNAL -}; - -static void cal_client_class_init (CalClientClass *class); -static void cal_client_init (CalClient *client); -static void cal_client_destroy (GtkObject *object); - -static guint cal_client_signals[LAST_SIGNAL]; - -static GtkObjectClass *parent_class; - - - -/** - * cal_client_get_type: - * @void: - * - * Registers the #CalClient class if necessary, and returns the type ID assigned - * to it. - * - * Return value: The type ID of the #CalClient class. - **/ -GtkType -cal_client_get_type (void) -{ - static GtkType cal_client_type = 0; - - if (!cal_client_type) { - static const GtkTypeInfo cal_client_info = { - "CalClient", - sizeof (CalClient), - sizeof (CalClientClass), - (GtkClassInitFunc) cal_client_class_init, - (GtkObjectInitFunc) cal_client_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_client_type = gtk_type_unique (GTK_TYPE_OBJECT, &cal_client_info); - } - - return cal_client_type; -} - -/* Class initialization function for the calendar client */ -static void -cal_client_class_init (CalClientClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - cal_client_signals[CAL_LOADED] = - gtk_signal_new ("cal_loaded", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalClientClass, cal_loaded), - gtk_marshal_NONE__ENUM, - GTK_TYPE_NONE, 1, - GTK_TYPE_ENUM); - cal_client_signals[OBJ_UPDATED] = - gtk_signal_new ("obj_updated", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalClientClass, obj_updated), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, - GTK_TYPE_STRING); - cal_client_signals[OBJ_REMOVED] = - gtk_signal_new ("obj_removed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalClientClass, obj_removed), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, - GTK_TYPE_STRING); - - gtk_object_class_add_signals (object_class, cal_client_signals, LAST_SIGNAL); - - object_class->destroy = cal_client_destroy; -} - -/* Object initialization function for the calendar client */ -static void -cal_client_init (CalClient *client) -{ - CalClientPrivate *priv; - - priv = g_new0 (CalClientPrivate, 1); - client->priv = priv; - - priv->factory = CORBA_OBJECT_NIL; - priv->load_state = LOAD_STATE_NOT_LOADED; -} - -/* Gets rid of the factory that a client knows about */ -static void -destroy_factory (CalClient *client) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - int result; - - priv = client->priv; - - CORBA_exception_init (&ev); - result = CORBA_Object_is_nil (priv->factory, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("destroy_factory(): could not see if the factory was nil"); - priv->factory = CORBA_OBJECT_NIL; - CORBA_exception_free (&ev); - return; - } - CORBA_exception_free (&ev); - - if (result) - return; - - CORBA_exception_init (&ev); - CORBA_Object_release (priv->factory, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("destroy_factory(): could not release the factory"); - - CORBA_exception_free (&ev); - priv->factory = CORBA_OBJECT_NIL; -} - -/* Gets rid of the listener that a client knows about */ -static void -destroy_listener (CalClient *client) -{ - CalClientPrivate *priv; - - priv = client->priv; - - if (!priv->listener) - return; - - bonobo_object_unref (BONOBO_OBJECT (priv->listener)); - priv->listener = NULL; -} - -/* Gets rid of the calendar client interface object that a client knows about */ -static void -destroy_cal (CalClient *client) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - int result; - - priv = client->priv; - - CORBA_exception_init (&ev); - result = CORBA_Object_is_nil (priv->cal, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("destroy_cal(): could not see if the " - "calendar client interface object was nil"); - priv->cal = CORBA_OBJECT_NIL; - CORBA_exception_free (&ev); - return; - } - CORBA_exception_free (&ev); - - if (result) - return; - - CORBA_exception_init (&ev); - Evolution_Calendar_Cal_unref (priv->cal, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("destroy_cal(): could not unref the calendar client interface object"); - - CORBA_exception_free (&ev); - - CORBA_exception_init (&ev); - CORBA_Object_release (priv->cal, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("destroy_cal(): could not release the calendar client interface object"); - - CORBA_exception_free (&ev); - priv->cal = CORBA_OBJECT_NIL; - -} - -/* Destroy handler for the calendar client */ -static void -cal_client_destroy (GtkObject *object) -{ - CalClient *client; - CalClientPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_CLIENT (object)); - - client = CAL_CLIENT (object); - priv = client->priv; - - destroy_factory (client); - destroy_listener (client); - destroy_cal (client); - - priv->load_state = LOAD_STATE_NOT_LOADED; - - g_free (priv); - client->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* Signal handlers for the listener's signals */ - -/* Handle the cal_loaded signal from the listener */ -static void -cal_loaded_cb (CalListener *listener, - Evolution_Calendar_Listener_LoadStatus status, - Evolution_Calendar_Cal cal, - gpointer data) -{ - CalClient *client; - CalClientPrivate *priv; - CORBA_Environment ev; - Evolution_Calendar_Cal cal_copy; - CalClientLoadStatus client_status; - - client = CAL_CLIENT (data); - priv = client->priv; - - g_assert (priv->load_state == LOAD_STATE_LOADING); - - client_status = CAL_CLIENT_LOAD_ERROR; - - switch (status) { - case Evolution_Calendar_Listener_SUCCESS: - CORBA_exception_init (&ev); - cal_copy = CORBA_Object_duplicate (cal, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_loaded(): could not duplicate the calendar client interface"); - CORBA_exception_free (&ev); - goto error; - } - CORBA_exception_free (&ev); - - priv->cal = cal_copy; - priv->load_state = LOAD_STATE_LOADED; - - client_status = CAL_CLIENT_LOAD_SUCCESS; - goto out; - - case Evolution_Calendar_Listener_ERROR: - client_status = CAL_CLIENT_LOAD_ERROR; - goto error; - - case Evolution_Calendar_Listener_IN_USE: - client_status = CAL_CLIENT_LOAD_IN_USE; - goto error; - - case Evolution_Calendar_Listener_METHOD_NOT_SUPPORTED: - client_status = CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED; - goto error; - - default: - g_assert_not_reached (); - } - - error: - - bonobo_object_unref (BONOBO_OBJECT (priv->listener)); - priv->listener = NULL; - priv->load_state = LOAD_STATE_NOT_LOADED; - - out: - - g_assert (priv->load_state != LOAD_STATE_LOADING); - - gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED], - client_status); -} - -/* Handle the obj_updated signal from the listener */ -static void -obj_updated_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data) -{ - CalClient *client; - - client = CAL_CLIENT (data); - gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_UPDATED], uid); -} - -/* Handle the obj_removed signal from the listener */ -static void -obj_removed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data) -{ - CalClient *client; - - client = CAL_CLIENT (data); - gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_REMOVED], uid); -} - - - -/** - * cal_client_construct: - * @client: A calendar client. - * - * Constructs a calendar client object by contacting the calendar factory of the - * calendar server. - * - * Return value: The same object as the @client argument, or NULL if the - * calendar factory could not be contacted. - **/ -CalClient * -cal_client_construct (CalClient *client) -{ - CalClientPrivate *priv; - Evolution_Calendar_CalFactory factory, factory_copy; - CORBA_Environment ev; - int result; - - CORBA_exception_init (&ev); - g_return_val_if_fail (client != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); - - priv = client->priv; - -#ifdef USING_OAF - factory = (Evolution_Calendar_CalFactory) oaf_activate_from_id ( - "OAFIID:evolution:calendar-factory:1c915858-ece3-4a6f-9d81-ea0f108a9554", - OAF_FLAG_NO_LOCAL, NULL, &ev); -#else - factory = (Evolution_Calendar_CalFactory) goad_server_activate_with_id ( - NULL, - "evolution:calendar-factory", - GOAD_ACTIVATE_REMOTE, - NULL); -#endif - - result = CORBA_Object_is_nil (factory, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_construct(): could not see if the factory is NIL"); - CORBA_exception_free (&ev); - return NULL; - } - CORBA_exception_free (&ev); - - if (result) { - g_message ("cal_client_construct(): could not contact Wombat, " - "the personal calendar server"); - return NULL; - } - - CORBA_exception_init (&ev); - factory_copy = CORBA_Object_duplicate (factory, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_construct(): could not duplicate the calendar factory"); - CORBA_exception_free (&ev); - return NULL; - } - CORBA_exception_free (&ev); - - priv->factory = factory_copy; - return client; -} - -/** - * cal_client_new: - * - * Creates a new calendar client. It should be initialized by calling - * cal_client_load_calendar() or cal_client_create_calendar(). - * - * Return value: A newly-created calendar client, or NULL if the client could - * not be constructed because it could not contact the calendar server. - **/ -CalClient * -cal_client_new (void) -{ - CalClient *client; - - client = gtk_type_new (CAL_CLIENT_TYPE); - - if (!cal_client_construct (client)) { - g_message ("cal_client_new(): could not construct the calendar client"); - gtk_object_unref (GTK_OBJECT (client)); - return NULL; - } - - return client; -} - -/* Issues a load or create request */ -static gboolean -load_or_create (CalClient *client, const char *str_uri, gboolean load) -{ - CalClientPrivate *priv; - Evolution_Calendar_Listener corba_listener; - CORBA_Environment ev; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_NOT_LOADED, FALSE); - - g_return_val_if_fail (str_uri != NULL, FALSE); - - priv->listener = cal_listener_new (); - if (!priv->listener) { - g_message ("load_or_create(): could not create the listener"); - return FALSE; - } - - gtk_signal_connect (GTK_OBJECT (priv->listener), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), - client); - gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_updated", - GTK_SIGNAL_FUNC (obj_updated_cb), - client); - gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_removed", - GTK_SIGNAL_FUNC (obj_removed_cb), - client); - - corba_listener = (Evolution_Calendar_Listener) bonobo_object_corba_objref ( - BONOBO_OBJECT (priv->listener)); - - CORBA_exception_init (&ev); - - priv->load_state = LOAD_STATE_LOADING; - - if (load) - Evolution_Calendar_CalFactory_load (priv->factory, str_uri, corba_listener, &ev); - else - Evolution_Calendar_CalFactory_create (priv->factory, str_uri, corba_listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("load_or_create(): load/create request failed"); - bonobo_object_unref (BONOBO_OBJECT (priv->listener)); - priv->listener = NULL; - priv->load_state = LOAD_STATE_NOT_LOADED; - CORBA_exception_free (&ev); - return FALSE; - } - CORBA_exception_free (&ev); - - return TRUE; -} - -/** - * cal_client_load_calendar: - * @client: A calendar client. - * @str_uri: URI of calendar to load. - * - * Makes a calendar client initiate a request to load a calendar. The calendar - * client will emit the "cal_loaded" signal when the response from the server is - * received. - * - * Return value: TRUE on success, FALSE on failure to issue the load request. - **/ -gboolean -cal_client_load_calendar (CalClient *client, const char *str_uri) -{ - return load_or_create (client, str_uri, TRUE); -} - -/** - * cal_client_create_calendar: - * @client: A calendar client. - * @str_uri: URI that will contain the calendar data. - * - * Makes a calendar client initiate a request to create a new calendar. The - * calendar client will emit the "cal_loaded" signal when the response from the - * server is received. - * - * Return value: TRUE on success, FALSE on failure to issue the create request. - **/ -gboolean -cal_client_create_calendar (CalClient *client, const char *str_uri) -{ - return load_or_create (client, str_uri, FALSE); -} - -/* Converts our representation of a calendar component type into its CORBA representation */ -static Evolution_Calendar_CalObjType -corba_obj_type (CalObjType type) -{ - return (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0) - | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0) - | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0)); -} - -/** - * cal_client_get_n_objects: - * @client: A calendar client. - * @type: Type of objects that will be counted. - * - * Counts the number of calendar components of the specified @type. This can be - * used to count how many events, to-dos, or journals there are, for example. - * - * Return value: Number of components. - **/ -int -cal_client_get_n_objects (CalClient *client, CalObjType type) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - int n; - int t; - - g_return_val_if_fail (client != NULL, -1); - g_return_val_if_fail (IS_CAL_CLIENT (client), -1); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, -1); - - t = corba_obj_type (type); - - CORBA_exception_init (&ev); - n = Evolution_Calendar_Cal_get_n_objects (priv->cal, t, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_get_n_objects(): could not get the number of objects"); - CORBA_exception_free (&ev); - return -1; - } - - CORBA_exception_free (&ev); - return n; -} - -/** - * cal_client_get_object: - * @client: A calendar client. - * @uid: Unique identifier for a calendar component. - * @comp: Return value for the calendar component object. - * - * Queries a calendar for a calendar component object based on its unique - * identifier. - * - * Return value: Result code based on the status of the operation. - **/ -CalClientGetStatus -cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - Evolution_Calendar_CalObj calobj_str; - CalClientGetStatus retval; - icalcomponent *icalcomp; - - g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND); - g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_GET_NOT_FOUND); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, CAL_CLIENT_GET_NOT_FOUND); - - g_return_val_if_fail (uid != NULL, CAL_CLIENT_GET_NOT_FOUND); - g_return_val_if_fail (comp != NULL, CAL_CLIENT_GET_NOT_FOUND); - - retval = CAL_CLIENT_GET_NOT_FOUND; - *comp = NULL; - - CORBA_exception_init (&ev); - calobj_str = Evolution_Calendar_Cal_get_object (priv->cal, (char *) uid, &ev); - - if (ev._major == CORBA_USER_EXCEPTION - && strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0) - goto out; - else if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_get_object(): could not get the object"); - goto out; - } - - icalcomp = icalparser_parse_string (calobj_str); - CORBA_free (calobj_str); - - if (!icalcomp) { - retval = CAL_CLIENT_GET_SYNTAX_ERROR; - goto out; - } - - *comp = cal_component_new (); - if (!cal_component_set_icalcomponent (*comp, icalcomp)) { - icalcomponent_free (icalcomp); - gtk_object_unref (GTK_OBJECT (*comp)); - *comp = NULL; - - retval = CAL_CLIENT_GET_SYNTAX_ERROR; - goto out; - } - - retval = CAL_CLIENT_GET_SUCCESS; - - out: - - CORBA_exception_free (&ev); - return retval; -} - -CalClientGetStatus -cal_client_get_uid_by_pilot_id (CalClient *client, - unsigned long pilot_id, - char **uid) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - CalClientGetStatus retval; - char *uid_str; - - g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND); - g_return_val_if_fail (IS_CAL_CLIENT (client), - CAL_CLIENT_GET_NOT_FOUND); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, - CAL_CLIENT_GET_NOT_FOUND); - - retval = CAL_CLIENT_GET_NOT_FOUND; - *uid = NULL; - - CORBA_exception_init (&ev); - uid_str = Evolution_Calendar_Cal_get_uid_by_pilot_id (priv->cal, pilot_id, &ev); - - if (ev._major == CORBA_USER_EXCEPTION && - strcmp (CORBA_exception_id (&ev), - ex_Evolution_Calendar_Cal_NotFound) == 0) - goto out; - else if (ev._major != CORBA_NO_EXCEPTION) { - //g_message ("cal_client_get_object(): could not get the object"); - goto out; - } - - if (uid_str) { - retval = CAL_CLIENT_GET_SUCCESS; - (*uid) = g_strdup (uid_str); - CORBA_free (uid_str); - } - - out: - - CORBA_exception_free (&ev); - return retval; -} - - - -void cal_client_update_pilot_id (CalClient *client, char *uid, - unsigned long pilot_id, - unsigned long pilot_status) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); - - priv = client->priv; - g_return_if_fail (priv->load_state == LOAD_STATE_LOADED); - - CORBA_exception_init (&ev); - Evolution_Calendar_Cal_update_pilot_id (priv->cal, uid, - pilot_id, pilot_status, - &ev); - - CORBA_exception_free (&ev); -} - -/* Builds an UID list out of a CORBA UID sequence */ -static GList * -build_uid_list (Evolution_Calendar_CalObjUIDSeq *seq) -{ - GList *uids; - int i; - - uids = NULL; - - for (i = 0; i < seq->_length; i++) - uids = g_list_prepend (uids, g_strdup (seq->_buffer[i])); - - return uids; -} - -/** - * cal_client_get_uids: - * @client: A calendar client. - * @type: Bitmask with types of objects to return. - * - * Queries a calendar for a list of unique identifiers corresponding to calendar - * objects whose type matches one of the types specified in the @type flags. - * - * Return value: A list of strings that are the sought UIDs. - **/ -GList * -cal_client_get_uids (CalClient *client, CalObjType type) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - Evolution_Calendar_CalObjUIDSeq *seq; - int t; - GList *uids; - - g_return_val_if_fail (client != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); - - t = corba_obj_type (type); - - CORBA_exception_init (&ev); - - seq = Evolution_Calendar_Cal_get_uids (priv->cal, t, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_get_uids(): could not get the list of UIDs"); - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - uids = build_uid_list (seq); - CORBA_free (seq); - - return uids; -} - -/* FIXME: Not used? */ -#if 0 -/* Builds a GList of CalObjInstance structures from the CORBA sequence */ -static GList * -build_object_instance_list (Evolution_Calendar_CalObjInstanceSeq *seq) -{ - GList *list; - int i; - - /* Create the list in reverse order */ - - list = NULL; - for (i = 0; i < seq->_length; i++) { - Evolution_Calendar_CalObjInstance *corba_icoi; - CalObjInstance *icoi; - - corba_icoi = &seq->_buffer[i]; - icoi = g_new (CalObjInstance, 1); - - icoi->uid = g_strdup (corba_icoi->uid); - icoi->start = corba_icoi->start; - icoi->end = corba_icoi->end; - - list = g_list_prepend (list, icoi); - } - - list = g_list_reverse (list); - return list; -} -#endif - -/** - * cal_client_get_objects_in_range: - * @client: A calendar client. - * @type: Bitmask with types of objects to return. - * @start: Start time for query. - * @end: End time for query. - * - * Queries a calendar for the objects that occur or recur in the specified range - * of time. - * - * Return value: A list of UID strings. This should be freed using the - * cal_obj_uid_list_free() function. - **/ -GList * -cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t start, time_t end) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - Evolution_Calendar_CalObjUIDSeq *seq; - GList *uids; - int t; - - g_return_val_if_fail (client != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); - - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - CORBA_exception_init (&ev); - - t = corba_obj_type (type); - - seq = Evolution_Calendar_Cal_get_objects_in_range (priv->cal, t, start, end, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_get_objects_in_range(): could not get the objects"); - CORBA_exception_free (&ev); - return NULL; - } - CORBA_exception_free (&ev); - - uids = build_uid_list (seq); - CORBA_free (seq); - - return uids; -} - -/* Callback used when an object is updated and we must update the copy we have */ -static void -generate_instances_obj_updated_cb (CalClient *client, const char *uid, gpointer data) -{ - GHashTable *uid_comp_hash; - CalComponent *comp; - CalClientGetStatus status; - const char *comp_uid; - - uid_comp_hash = data; - - comp = g_hash_table_lookup (uid_comp_hash, uid); - if (!comp) - /* OK, so we don't care about new objects that may indeed be in - * the requested time range. We only care about the ones that - * were returned by the first query to - * cal_client_get_objects_in_range(). - */ - return; - - g_hash_table_remove (uid_comp_hash, uid); - gtk_object_unref (GTK_OBJECT (comp)); - - status = cal_client_get_object (client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* The hash key comes from the component's internal data */ - cal_component_get_uid (comp, &comp_uid); - g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp); - break; - - case CAL_CLIENT_GET_NOT_FOUND: - /* No longer in the server, too bad */ - break; - - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_message ("obj_updated_cb(): Syntax error when getting " - "object `%s'; ignoring...", uid); - break; - - } -} - -/* Callback used when an object is removed and we must delete the copy we have */ -static void -generate_instances_obj_removed_cb (CalClient *client, const char *uid, gpointer data) -{ - GHashTable *uid_comp_hash; - CalComponent *comp; - - uid_comp_hash = data; - - comp = g_hash_table_lookup (uid_comp_hash, uid); - if (!comp) - return; - - g_hash_table_remove (uid_comp_hash, uid); - gtk_object_unref (GTK_OBJECT (comp)); -} - -/* Adds a component to the list; called from g_hash_table_foreach() */ -static void -add_component (gpointer key, gpointer value, gpointer data) -{ - CalComponent *comp; - GList **list; - - comp = CAL_COMPONENT (value); - list = data; - - *list = g_list_prepend (*list, comp); -} - -/* Gets a list of components that recur within the specified range of time. It - * ensures that the resulting list of CalComponent objects contains only objects - * that are actually in the server at the time the initial - * cal_client_get_objects_in_range() query ends. - */ -static GList * -get_objects_atomically (CalClient *client, CalObjType type, time_t start, time_t end) -{ - GList *uids; - GHashTable *uid_comp_hash; - GList *objects; - guint obj_updated_id; - guint obj_removed_id; - GList *l; - - uids = cal_client_get_objects_in_range (client, type, start, end); - - uid_comp_hash = g_hash_table_new (g_str_hash, g_str_equal); - - /* While we are getting the actual object data, keep track of changes */ - - obj_updated_id = gtk_signal_connect (GTK_OBJECT (client), "obj_updated", - GTK_SIGNAL_FUNC (generate_instances_obj_updated_cb), - uid_comp_hash); - - obj_removed_id = gtk_signal_connect (GTK_OBJECT (client), "obj_removed", - GTK_SIGNAL_FUNC (generate_instances_obj_removed_cb), - uid_comp_hash); - - /* Get the objects */ - - for (l = uids; l; l = l->next) { - CalComponent *comp; - CalClientGetStatus status; - char *uid; - const char *comp_uid; - - uid = l->data; - - status = cal_client_get_object (client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* The hash key comes from the component's internal data - * instead of the duped UID from the list of UIDS. - */ - cal_component_get_uid (comp, &comp_uid); - g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp); - break; - - case CAL_CLIENT_GET_NOT_FOUND: - /* Object disappeared from the server, so don't log it */ - break; - - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_message ("get_objects_atomically(): Syntax error when getting " - "object `%s'; ignoring...", uid); - break; - - default: - g_assert_not_reached (); - } - } - - cal_obj_uid_list_free (uids); - - /* Now our state is consistent with the server, so disconnect from the - * notification signals and generate the final list of components. - */ - - gtk_signal_disconnect (GTK_OBJECT (client), obj_updated_id); - gtk_signal_disconnect (GTK_OBJECT (client), obj_removed_id); - - objects = NULL; - g_hash_table_foreach (uid_comp_hash, add_component, &objects); - g_hash_table_destroy (uid_comp_hash); - - return objects; -} - -struct comp_instance { - CalComponent *comp; - time_t start; - time_t end; -}; - -/* Called from cal_recur_generate_instances(); adds an instance to the list */ -static gboolean -add_instance (CalComponent *comp, time_t start, time_t end, gpointer data) -{ - GList **list; - struct comp_instance *ci; - - list = data; - - ci = g_new (struct comp_instance, 1); - - ci->comp = comp; - gtk_object_ref (GTK_OBJECT (ci->comp)); - - ci->start = start; - ci->end = end; - - return TRUE; -} - -/* Used from g_list_sort(); compares two struct comp_instance structures */ -static gint -compare_comp_instance (gconstpointer a, gconstpointer b) -{ - const struct comp_instance *cia, *cib; - time_t diff; - - cia = a; - cib = b; - - diff = cia->start - cib->start; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - -/** - * cal_client_generate_instances: - * @client: A calendar client. - * @type: Bitmask with types of objects to return. - * @start: Start time for query. - * @end: End time for query. - * @cb: Callback for each generated instance. - * @cb_data: Closure data for the callback. - * - * Does a combination of cal_client_get_objects_in_range() and - * cal_recur_generate_instances(). It fetches the list of objects in an atomic - * way so that the generated instances are actually in the server at the time - * the initial cal_client_get_objects_in_range() query ends. - * - * The callback function should do a gtk_object_ref() of the calendar component - * it gets passed if it intends to keep it around. - **/ -void -cal_client_generate_instances (CalClient *client, CalObjType type, - time_t start, time_t end, - CalRecurInstanceFn cb, gpointer cb_data) -{ - CalClientPrivate *priv; - GList *objects; - GList *instances; - GList *l; - - g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); - - priv = client->priv; - g_return_if_fail (priv->load_state == LOAD_STATE_LOADED); - - g_return_if_fail (start != -1 && end != -1); - g_return_if_fail (start <= end); - g_return_if_fail (cb != NULL); - - /* Generate objects */ - - objects = get_objects_atomically (client, type, start, end); - instances = NULL; - - for (l = objects; l; l = l->next) { - CalComponent *comp; - - comp = l->data; - cal_recur_generate_instances (comp, start, end, add_instance, &instances); - } - - g_list_free (objects); - - /* Generate instances and spew them out */ - - instances = g_list_sort (instances, compare_comp_instance); - - for (l = instances; l; l = l->next) { - struct comp_instance *ci; - gboolean result; - - ci = l->data; - - result = (* cb) (ci->comp, ci->start, ci->end, cb_data); - - if (!result) - break; - } - - /* Clean up */ - - for (l = instances; l; l = l->next) { - struct comp_instance *ci; - - ci = l->data; - gtk_object_unref (GTK_OBJECT (ci->comp)); - g_free (ci); - } - - g_list_free (instances); -} - - -#if 0 -/* Translates the CORBA representation of an AlarmType */ -static enum AlarmType -uncorba_alarm_type (Evolution_Calendar_AlarmType corba_type) -{ - switch (corba_type) { - case Evolution_Calendar_MAIL: - return ALARM_MAIL; - - case Evolution_Calendar_PROGRAM: - return ALARM_PROGRAM; - - case Evolution_Calendar_DISPLAY: - return ALARM_DISPLAY; - - case Evolution_Calendar_AUDIO: - return ALARM_AUDIO; - - default: - g_assert_not_reached (); - return ALARM_DISPLAY; - } -} -#endif - -/* Builds a GList of CalAlarmInstance structures from the CORBA sequence */ -static GList * -build_alarm_instance_list (Evolution_Calendar_CalAlarmInstanceSeq *seq) -{ - GList *list; - int i; - - /* Create the list in reverse order */ - - list = NULL; - for (i = 0; i < seq->_length; i++) { - Evolution_Calendar_CalAlarmInstance *corba_ai; - CalAlarmInstance *ai; - - corba_ai = &seq->_buffer[i]; - ai = g_new (CalAlarmInstance, 1); - - ai->uid = g_strdup (corba_ai->uid); -#if 0 - ai->type = uncorba_alarm_type (corba_ai->type); -#endif - ai->trigger = corba_ai->trigger; - ai->occur = corba_ai->occur; - - list = g_list_prepend (list, ai); - } - - list = g_list_reverse (list); - return list; -} - -/** - * cal_client_get_alarms_in_range: - * @client: A calendar client. - * @start: Start time for query. - * @end: End time for query. - * - * Queries a calendar for the alarms that trigger in the specified range of - * time. - * - * Return value: A list of #CalAlarmInstance structures. - **/ -GList * -cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - Evolution_Calendar_CalAlarmInstanceSeq *seq; - GList *alarms; - - g_return_val_if_fail (client != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); - - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - CORBA_exception_init (&ev); - - seq = Evolution_Calendar_Cal_get_alarms_in_range (priv->cal, start, end, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_get_alarms_in_range(): could not get the alarm range"); - CORBA_exception_free (&ev); - return NULL; - } - CORBA_exception_free (&ev); - - alarms = build_alarm_instance_list (seq); - CORBA_free (seq); - - return alarms; -} - -/** - * cal_client_get_alarms_for_object: - * @client: A calendar client. - * @uid: Unique identifier for a calendar object. - * @start: Start time for query. - * @end: End time for query. - * @alarms: Return value for the list of alarm instances. - * - * Queries a calendar for the alarms of a particular object that trigger in the - * specified range of time. - * - * Return value: TRUE on success, FALSE if the object was not found. - **/ -gboolean -cal_client_get_alarms_for_object (CalClient *client, const char *uid, - time_t start, time_t end, - GList **alarms) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - Evolution_Calendar_CalAlarmInstanceSeq *seq; - gboolean retval; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (start != -1 && end != -1, FALSE); - g_return_val_if_fail (start <= end, FALSE); - g_return_val_if_fail (alarms != NULL, FALSE); - - *alarms = NULL; - retval = FALSE; - - CORBA_exception_init (&ev); - - seq = Evolution_Calendar_Cal_get_alarms_for_object (priv->cal, (char *) uid, start, end, &ev); - if (ev._major == CORBA_USER_EXCEPTION - && strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0) - goto out; - else if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_get_alarms_for_object(): could not get the alarm range"); - goto out; - } - - retval = TRUE; - *alarms = build_alarm_instance_list (seq); - CORBA_free (seq); - - out: - CORBA_exception_free (&ev); - return retval; - -} - -/** - * cal_client_update_object: - * @client: A calendar client. - * @comp: A calendar component object. - * - * Asks a calendar to update a component. Any existing component with the - * specified component's UID will be replaced. The client program should not - * assume that the object is actually in the server's storage until it has - * received the "obj_updated" notification signal. - * - * Return value: TRUE on success, FALSE on specifying an invalid component. - **/ -gboolean -cal_client_update_object (CalClient *client, CalComponent *comp) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - gboolean retval; - char *obj_string; - const char *uid; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE); - - g_return_val_if_fail (comp != NULL, FALSE); - - retval = FALSE; - - cal_component_commit_sequence (comp); - obj_string = cal_component_get_as_string (comp); - - cal_component_get_uid (comp, &uid); - - CORBA_exception_init (&ev); - Evolution_Calendar_Cal_update_object (priv->cal, (char *) uid, obj_string, &ev); - g_free (obj_string); - - if (ev._major == CORBA_USER_EXCEPTION && - strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_InvalidObject) == 0) - goto out; - else if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_update_object(): could not update the object"); - goto out; - } - - retval = TRUE; - - out: - CORBA_exception_free (&ev); - return retval; -} - -gboolean -cal_client_remove_object (CalClient *client, const char *uid) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - gboolean retval; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - - retval = FALSE; - - CORBA_exception_init (&ev); - Evolution_Calendar_Cal_remove_object (priv->cal, (char *) uid, &ev); - - if (ev._major == CORBA_USER_EXCEPTION && - strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0) - goto out; - else if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_remove_object(): could not remove the object"); - goto out; - } - - retval = TRUE; - - out: - CORBA_exception_free (&ev); - return retval; -} diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h deleted file mode 100644 index 24cc170350..0000000000 --- a/calendar/cal-client/cal-client.h +++ /dev/null @@ -1,122 +0,0 @@ -/* Evolution calendar client - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_CLIENT_H -#define CAL_CLIENT_H - -#include <libgnome/gnome-defs.h> -#include <gtk/gtkobject.h> -#include <cal-util/cal-recur.h> -#include <cal-util/cal-util.h> - -BEGIN_GNOME_DECLS - - - -#define CAL_CLIENT_TYPE (cal_client_get_type ()) -#define CAL_CLIENT(obj) (GTK_CHECK_CAST ((obj), CAL_CLIENT_TYPE, CalClient)) -#define CAL_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_CLIENT_TYPE, CalClientClass)) -#define IS_CAL_CLIENT(obj) (GTK_CHECK_TYPE ((obj), CAL_CLIENT_TYPE)) -#define IS_CAL_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_CLIENT_TYPE)) - -typedef struct _CalClient CalClient; -typedef struct _CalClientClass CalClientClass; - -/* Load status for the cal_loaded signal */ -typedef enum { - CAL_CLIENT_LOAD_SUCCESS, - CAL_CLIENT_LOAD_ERROR, - CAL_CLIENT_LOAD_IN_USE, - CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED -} CalClientLoadStatus; - -typedef enum { - CAL_CLIENT_GET_SUCCESS, - CAL_CLIENT_GET_NOT_FOUND, - CAL_CLIENT_GET_SYNTAX_ERROR -} CalClientGetStatus; - - -struct _CalClient { - GtkObject object; - - /* Private data */ - gpointer priv; -}; - -struct _CalClientClass { - GtkObjectClass parent_class; - - /* Notification signals */ - - void (* cal_loaded) (CalClient *client, CalClientLoadStatus status); - - void (* obj_updated) (CalClient *client, const char *uid); - void (* obj_removed) (CalClient *client, const char *uid); -}; - -GtkType cal_client_get_type (void); - -CalClient *cal_client_construct (CalClient *client); - -CalClient *cal_client_new (void); - -gboolean cal_client_load_calendar (CalClient *client, const char *str_uri); -gboolean cal_client_create_calendar (CalClient *client, const char *str_uri); - -int cal_client_get_n_objects (CalClient *client, CalObjType type); - -CalClientGetStatus cal_client_get_object (CalClient *client, - const char *uid, - CalComponent **comp); - -CalClientGetStatus cal_client_get_uid_by_pilot_id (CalClient *client, - unsigned long pilot_id, - char **uid); - -void cal_client_update_pilot_id (CalClient *client, char *uid, - unsigned long pilot_id, - unsigned long pilot_status); - -GList *cal_client_get_uids (CalClient *client, CalObjType type); - -GList *cal_client_get_objects_in_range (CalClient *client, CalObjType type, - time_t start, time_t end); - -void cal_client_generate_instances (CalClient *client, CalObjType type, - time_t start, time_t end, - CalRecurInstanceFn cb, gpointer cb_data); - -GList *cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end); - -gboolean cal_client_get_alarms_for_object (CalClient *client, const char *uid, - time_t start, time_t end, - GList **alarms); - -gboolean cal_client_update_object (CalClient *client, CalComponent *comp); - -gboolean cal_client_remove_object (CalClient *client, const char *uid); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c deleted file mode 100644 index d9a028b20d..0000000000 --- a/calendar/cal-client/cal-listener.c +++ /dev/null @@ -1,403 +0,0 @@ -/* Evolution calendar listener - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include "cal-listener.h" - - - -/* Private part of the CalListener structure */ -typedef struct { - /* The calendar this listener refers to */ - Evolution_Calendar_Cal cal; -} CalListenerPrivate; - - - -/* Signal IDs */ -enum { - CAL_LOADED, - OBJ_UPDATED, - OBJ_REMOVED, - LAST_SIGNAL -}; - -static void cal_listener_class_init (CalListenerClass *class); -static void cal_listener_init (CalListener *listener); -static void cal_listener_destroy (GtkObject *object); - -static void marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args); - -static POA_Evolution_Calendar_Listener__vepv cal_listener_vepv; - -static guint cal_listener_signals[LAST_SIGNAL]; - -static BonoboObjectClass *parent_class; - - - -/** - * cal_listener_get_type: - * @void: - * - * Registers the #CalListener class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalListener class. - **/ -GtkType -cal_listener_get_type (void) -{ - static GtkType cal_listener_type = 0; - - if (!cal_listener_type) { - static const GtkTypeInfo cal_listener_info = { - "CalListener", - sizeof (CalListener), - sizeof (CalListenerClass), - (GtkClassInitFunc) cal_listener_class_init, - (GtkObjectInitFunc) cal_listener_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_listener_type = gtk_type_unique (bonobo_object_get_type (), &cal_listener_info); - } - - return cal_listener_type; -} - -/* CORBA class initialization function for the calendar listener */ -static void -init_cal_listener_corba_class (void) -{ - cal_listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - cal_listener_vepv.Evolution_Calendar_Listener_epv = cal_listener_get_epv (); -} - -/* Class initialization function for the calendar listener */ -static void -cal_listener_class_init (CalListenerClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (bonobo_object_get_type ()); - - cal_listener_signals[CAL_LOADED] = - gtk_signal_new ("cal_loaded", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded), - marshal_cal_loaded, - GTK_TYPE_NONE, 2, - GTK_TYPE_ENUM, - GTK_TYPE_POINTER); - cal_listener_signals[OBJ_UPDATED] = - gtk_signal_new ("obj_updated", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalListenerClass, obj_updated), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - cal_listener_signals[OBJ_REMOVED] = - gtk_signal_new ("obj_removed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalListenerClass, obj_removed), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - gtk_object_class_add_signals (object_class, cal_listener_signals, LAST_SIGNAL); - - object_class->destroy = cal_listener_destroy; - - init_cal_listener_corba_class (); -} - -/* Object initialization function for the calendar listener */ -static void -cal_listener_init (CalListener *listener) -{ - CalListenerPrivate *priv; - - priv = g_new0 (CalListenerPrivate, 1); - listener->priv = priv; - - priv->cal = CORBA_OBJECT_NIL; -} - -/* Destroy handler for the calendar listener */ -static void -cal_listener_destroy (GtkObject *object) -{ - CalListener *listener; - CalListenerPrivate *priv; - CORBA_Environment ev; - gboolean result; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_LISTENER (object)); - - listener = CAL_LISTENER (object); - priv = listener->priv; - - CORBA_exception_init (&ev); - result = CORBA_Object_is_nil (priv->cal, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("cal_listener_destroy(): could not see if the calendar was NIL"); - else if (!result) { - CORBA_exception_free (&ev); - - CORBA_exception_init (&ev); - CORBA_Object_release (priv->cal, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("cal_listener_destroy(): could not release the calendar"); - - priv->cal = CORBA_OBJECT_NIL; - } - CORBA_exception_free (&ev); - - g_free (priv); - listener->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* Marshalers */ - -typedef void (* CalLoadedFunc) (GtkObject *object, gint status, gpointer cal, gpointer data); - -static void -marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args) -{ - CalLoadedFunc rfunc; - - rfunc = (CalLoadedFunc) func; - (* rfunc) (object, GTK_VALUE_ENUM (args[0]), GTK_VALUE_POINTER (args[1]), data); -} - - - -/* CORBA servant implementation */ - -/* Listener::cal_loaded method */ -static void -Listener_cal_loaded (PortableServer_Servant servant, - Evolution_Calendar_Listener_LoadStatus status, - Evolution_Calendar_Cal cal, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - CORBA_Environment aev; - Evolution_Calendar_Cal cal_copy; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (priv->cal != CORBA_OBJECT_NIL) { - g_message ("Listener_cal_loaded(): calendar was already loaded!"); - return; - } - - CORBA_exception_init (&aev); - cal_copy = CORBA_Object_duplicate (cal, &aev); - - if (aev._major != CORBA_NO_EXCEPTION) { - g_message ("Listener_cal_loaded(): could not duplicate the calendar"); - CORBA_exception_free (&aev); - return; - } - CORBA_exception_free (&aev); - - priv->cal = cal_copy; - - gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED], - status, cal); -} - -/* Listener::obj_updated method */ -static void -Listener_obj_updated (PortableServer_Servant servant, - Evolution_Calendar_CalObjUID uid, - CORBA_Environment *ev) -{ - CalListener *listener; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_UPDATED], - uid); -} - -/* Listener::obj_removed method */ -static void -Listener_obj_removed (PortableServer_Servant servant, - Evolution_Calendar_CalObjUID uid, - CORBA_Environment *ev) -{ - CalListener *listener; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_REMOVED], - uid); -} - -/** - * cal_listener_get_epv: - * @void: - * - * Creates an EPV for the Listener CORBA class. - * - * Return value: A newly-allocated EPV. - **/ -POA_Evolution_Calendar_Listener__epv * -cal_listener_get_epv (void) -{ - POA_Evolution_Calendar_Listener__epv *epv; - - epv = g_new0 (POA_Evolution_Calendar_Listener__epv, 1); - epv->cal_loaded = Listener_cal_loaded; - epv->obj_updated = Listener_obj_updated; - epv->obj_removed = Listener_obj_removed; - return epv; -} - - - -/** - * cal_listener_construct: - * @listener: A calendar listener. - * @corba_listener: CORBA object for the calendar listener. - * - * Constructs a calendar listener by binding the corresponding CORBA object to - * it. - * - * Return value: the same object as the @listener argument. - **/ -CalListener * -cal_listener_construct (CalListener *listener, Evolution_Calendar_Listener corba_listener) -{ - g_return_val_if_fail (listener != NULL, NULL); - g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL); - - bonobo_object_construct (BONOBO_OBJECT (listener), corba_listener); - return listener; -} - -/** - * cal_listener_corba_object_create: - * @object: #BonoboObject that will wrap the CORBA object. - * - * Creates and activates the CORBA object that is wrapped by the specified - * calendar listener @object. - * - * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of - * failure. - **/ -Evolution_Calendar_Listener -cal_listener_corba_object_create (BonoboObject *object) -{ - POA_Evolution_Calendar_Listener *servant; - CORBA_Environment ev; - - g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (IS_CAL_LISTENER (object), CORBA_OBJECT_NIL); - - servant = (POA_Evolution_Calendar_Listener *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &cal_listener_vepv; - - CORBA_exception_init (&ev); - POA_Evolution_Calendar_Listener__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - return (Evolution_Calendar_Listener) bonobo_object_activate_servant (object, servant); -} - -/** - * cal_listener_new: - * @void: - * - * Creates a new #CalListener object. - * - * Return value: A newly-created #CalListener, or NULL if its corresponding - * CORBA object could not be created. - **/ -CalListener * -cal_listener_new (void) -{ - CalListener *listener; - CORBA_Environment ev; - Evolution_Calendar_Listener corba_listener; - gboolean result; - - listener = gtk_type_new (CAL_LISTENER_TYPE); - - corba_listener = cal_listener_corba_object_create (BONOBO_OBJECT (listener)); - - CORBA_exception_init (&ev); - result = CORBA_Object_is_nil (corba_listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION || result) { - g_message ("cal_listener_new(): could not create the CORBA listener"); - bonobo_object_unref (BONOBO_OBJECT (listener)); - CORBA_exception_free (&ev); - return NULL; - } - CORBA_exception_free (&ev); - - return cal_listener_construct (listener, corba_listener); -} - -/** - * cal_listener_get_calendar: - * @listener: A calendar listener. - * - * Queries the calendar that a listener is watching. - * - * Return value: The calendar that the listener is watching. - **/ -Evolution_Calendar_Cal -cal_listener_get_calendar (CalListener *listener) -{ - CalListenerPrivate *priv; - - g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (IS_CAL_LISTENER (listener), CORBA_OBJECT_NIL); - - priv = listener->priv; - return priv->cal; -} diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h deleted file mode 100644 index 171da0d5c3..0000000000 --- a/calendar/cal-client/cal-listener.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Evolution calendar listener - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_LISTENER_H -#define CAL_LISTENER_H - -#include <libgnome/gnome-defs.h> -#include <bonobo/bonobo-object.h> -#include "evolution-calendar.h" - -BEGIN_GNOME_DECLS - - - -#define CAL_LISTENER_TYPE (cal_listener_get_type ()) -#define CAL_LISTENER(obj) (GTK_CHECK_CAST ((obj), CAL_LISTENER_TYPE, CalListener)) -#define CAL_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_LISTENER_TYPE, \ - CalListenerClass)) -#define IS_CAL_LISTENER(obj) (GTK_CHECK_TYPE ((obj), CAL_LISTENER_TYPE)) -#define IS_CAL_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_LISTENER_TYPE)) - -typedef struct _CalListener CalListener; -typedef struct _CalListenerClass CalListenerClass; - -struct _CalListener { - BonoboObject object; - - /* Private data */ - gpointer priv; -}; - -struct _CalListenerClass { - BonoboObjectClass parent_class; - - /* Notification signals */ - - void (* cal_loaded) (CalListener *listener, - Evolution_Calendar_Listener_LoadStatus status, - Evolution_Calendar_Cal cal); - void (* obj_updated) (CalListener *listener, const Evolution_Calendar_CalObjUID uid); - void (* obj_removed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid); -}; - -GtkType cal_listener_get_type (void); - -CalListener *cal_listener_construct (CalListener *listener, - Evolution_Calendar_Listener corba_listener); - -Evolution_Calendar_Listener cal_listener_corba_object_create (BonoboObject *object); - -CalListener *cal_listener_new (void); - -Evolution_Calendar_Cal cal_listener_get_calendar (CalListener *listener); - -POA_Evolution_Calendar_Listener__epv *cal_listener_get_epv (void); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/cal-client/client-test.c b/calendar/cal-client/client-test.c deleted file mode 100644 index 7f79b58266..0000000000 --- a/calendar/cal-client/client-test.c +++ /dev/null @@ -1,243 +0,0 @@ -/* Evolution calendar client - test program - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <bonobo.h> -#include <gnome.h> -#include <cal-client/cal-client.h> - -static CalClient *client1; -static CalClient *client2; - -/* Prints a message with a client identifier */ -static void -cl_printf (CalClient *client, const char *format, ...) -{ - va_list args; - - va_start (args, format); - printf ("Client %s: ", - client == client1 ? "1" : - client == client2 ? "2" : - "UNKNOWN"); - vprintf (format, args); - va_end (args); -} - -/* Dumps some interesting data from a component */ -static void -dump_component (CalComponent *comp) -{ - const char *uid; - CalComponentText summary; - - cal_component_get_uid (comp, &uid); - - printf ("UID %s\n", uid); - - cal_component_get_summary (comp, &summary); - if (summary.value) - printf ("\tSummary: `%s', altrep `%s'\n", - summary.value, - summary.altrep ? summary.altrep : "NONE"); - else - printf ("\tNo summary\n"); -} - -/* Lists the UIDs of objects in a calendar, called as an idle handler */ -static gboolean -list_uids (gpointer data) -{ - CalClient *client; - GList *uids; - GList *l; - - client = CAL_CLIENT (data); - - uids = cal_client_get_uids (client, CALOBJ_TYPE_ANY); - - cl_printf (client, "UIDs: "); - - if (!uids) - printf ("none\n"); - else { - for (l = uids; l; l = l->next) { - char *uid; - - uid = l->data; - printf ("`%s' ", uid); - } - - printf ("\n"); - - for (l = uids; l; l = l->next) { - char *uid; - CalComponent *comp; - CalClientGetStatus status; - - uid = l->data; - status = cal_client_get_object (client, uid, &comp); - - if (status == CAL_CLIENT_GET_SUCCESS) { - printf ("------------------------------\n"); - dump_component (comp); - printf ("------------------------------\n"); - gtk_object_unref (GTK_OBJECT (comp)); - } else { - printf ("FAILED: %d\n", status); - } - } - } - - cal_obj_uid_list_free (uids); - - gtk_object_unref (GTK_OBJECT (client)); - - return FALSE; -} - -/* Callback used when a calendar is loaded */ -static void -cal_loaded (CalClient *client, CalClientLoadStatus status, gpointer data) -{ - cl_printf (client, "Load/create %s\n", - ((status == CAL_CLIENT_LOAD_SUCCESS) ? "success" : - (status == CAL_CLIENT_LOAD_ERROR) ? "error" : - (status == CAL_CLIENT_LOAD_IN_USE) ? "in use" : - "unknown status value")); - - if (status == CAL_CLIENT_LOAD_SUCCESS) - g_idle_add (list_uids, client); - else - gtk_object_unref (GTK_OBJECT (client)); -} - -/* Callback used when an object is updated */ -static void -obj_updated (CalClient *client, const char *uid, gpointer data) -{ - cl_printf (client, "Object updated: %s\n", uid); -} - -/* Callback used when a client is destroyed */ -static void -client_destroy_cb (GtkObject *object, gpointer data) -{ - if (CAL_CLIENT (object) == client1) - client1 = NULL; - else if (CAL_CLIENT (object) == client2) - client2 = NULL; - else - g_assert_not_reached (); - - if (!client1 && !client2) - gtk_main_quit (); -} - -/* Creates a calendar client and tries to load the specified URI into it */ -static void -create_client (CalClient **client, const char *uri, gboolean load) -{ - gboolean result; - - *client = cal_client_new (); - if (!*client) { - g_message ("create_client(): could not create the client"); - exit (1); - } - - gtk_signal_connect (GTK_OBJECT (*client), "destroy", - client_destroy_cb, - NULL); - - gtk_signal_connect (GTK_OBJECT (*client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded), - NULL); - gtk_signal_connect (GTK_OBJECT (*client), "obj_updated", - GTK_SIGNAL_FUNC (obj_updated), - NULL); - - printf ("Calendar loading `%s'...\n", uri); - - if (load) - result = cal_client_load_calendar (*client, uri); - else - result = cal_client_create_calendar (*client, uri); - - if (!result) { - g_message ("create_client(): failure when issuing calendar %s request `%s'", - load ? "load" : "create", - uri); - exit (1); - } -} - -#ifdef USING_OAF - -#include <liboaf/liboaf.h> - -static void -init_corba (int *argc, char **argv) -{ - gnome_init ("tl-test", VERSION, *argc, argv); - oaf_init (*argc, argv); -} - -#else - -#include <libgnorba/gnorba.h> - -static void -init_corba (int *argc, char **argv) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - gnome_CORBA_init ("tl-test", VERSION, &argc, argv, 0, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("main(): could not initialize the ORB"); - CORBA_exception_free (&ev); - exit (1); - } - CORBA_exception_free (&ev); -} - -#endif - -int -main (int argc, char **argv) -{ - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); - - init_corba (&argc, argv); - - if (!bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) { - g_message ("main(): could not initialize Bonobo"); - exit (1); - } - - create_client (&client1, "/cvs/evolution/calendar/cal-client/test.ics", TRUE); - create_client (&client2, "/cvs/evolution/calendar/cal-client/test.ics", FALSE); - - bonobo_main (); - return 0; -} diff --git a/calendar/cal-client/test.ics b/calendar/cal-client/test.ics deleted file mode 100644 index 128251ee11..0000000000 --- a/calendar/cal-client/test.ics +++ /dev/null @@ -1,318 +0,0 @@ -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:-//hacksw/handcal//NONSGML v1.0//EN - -BEGIN:VEVENT -DTSTART:19970714T170000Z -DTEND:19970715T035959Z -SUMMARY:Bastille Day Party -END:VEVENT - -BEGIN:VEVENT -UID:19970901T130000Z-123401@host.com -DTSTAMP:19970901T1300Z -DTSTART:19970903T163000Z -DTEND:19970903T190000Z -SUMMARY:Annual Employee Review -CLASS:PRIVATE -CATEGORIES:BUSINESS,HUMAN RESOURCES -END:VEVENT - -BEGIN:VEVENT -UID:19970901T130000Z-123402@host.com -DTSTAMP:19970901T1300Z -DTSTART:19970401T163000Z -DTEND:19970402T010000Z -SUMMARY:Laurel is in sensitivity awareness class. -CLASS:PUBLIC -CATEGORIES:BUSINESS,HUMAN RESOURCES -TRANSP:TRANSPARENT -END:VEVENT - -BEGIN:VEVENT -UID:19970901T130000Z-123403@host.com -DTSTAMP:19970901T1300Z -DTSTART:19971102 -SUMMARY:Our Blissful Anniversary -CLASS:CONFIDENTIAL -CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION -RRULE:FREQ=YEARLY -END:VEVENT - -BEGIN:VTODO -UID:19970901T130000Z-123404@host.com -DTSTAMP:19970901T1300Z -DTSTART:19970415T133000Z -DUE:19970416T045959Z -SUMMARY:1996 Income Tax Preparation -CLASS:CONFIDENTIAL -CATEGORIES:FAMILY,FINANCE -PRIORITY:1 -STATUS:NEEDS-ACTION -END:VTODO - -BEGIN:VJOURNAL -UID:19970901T130000Z-123405@host.com -DTSTAMP:19970901T1300Z -DTSTART;VALUE=DATE:19970317 -SUMMARY:Staff meeting minutes -DESCRIPTION:1. Staff meeting: Participants include Joe\, Lisa - and Bob. Aurora project plans were reviewed. There is currently - no budget reserves for this project. Lisa will escalate to - management. Next meeting on Tuesday.\n - 2. Telephone Conference: ABC Corp. sales representative called - to discuss new printer. Promised to get us a demo by Friday.\n - 3. Henry Miller (Handsoff Insurance): Car was totaled by tree. - Is looking into a loaner car. 654-2323 (tel). -END:VJOURNAL - -BEGIN:VFREEBUSY -ORGANIZER:MAILTO:jane_doe@host1.com -ATTENDEE:MAILTO:john_public@host2.com -DTSTART:19971015T050000Z -DTEND:19971016T050000Z -DTSTAMP:19970901T083000Z -END:VFREEBUSY - -BEGIN:VFREEBUSY -ORGANIZER:MAILTO:jane_doe@host1.com -ATTENDEE:MAILTO:john_public@host2.com -DTSTAMP:19970901T100000Z -FREEBUSY;VALUE=PERIOD:19971015T050000Z/PT8H30M, - 19971015T160000Z/PT5H30M,19971015T223000Z/PT6H30M -URL:http://host2.com/pub/busy/jpublic-01.ifb -COMMENT:This iCalendar file contains busy time information for - the next three months. -END:VFREEBUSY - -BEGIN:VFREEBUSY -ORGANIZER:jsmith@host.com -DTSTART:19980313T141711Z -DTEND:19980410T141711Z -FREEBUSY:19980314T233000Z/19980315T003000Z -FREEBUSY:19980316T153000Z/19980316T163000Z -FREEBUSY:19980318T030000Z/19980318T040000Z -URL:http://www.host.com/calendar/busytime/jsmith.ifb -END:VFREEBUSY - -BEGIN:VTIMEZONE -TZID:US-Eastern -LAST-MODIFIED:19870101T000000Z -BEGIN:STANDARD -DTSTART:19971026T020000 -RDATE:19971026T020000 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19971026T020000 -RDATE:19970406T020000 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VTIMEZONE -TZID:US-Eastern -LAST-MODIFIED:19870101T000000Z -TZURL:http://zones.stds_r_us.net/tz/US-Eastern -BEGIN:STANDARD -DTSTART:19671029T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19870405T020000 -RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VTIMEZONE -TZID:US--Fictitious-Eastern -LAST-MODIFIED:19870101T000000Z -BEGIN:STANDARD -DTSTART:19671029T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19870405T020000 -RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;UNTIL=19980404T070000Z -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VTIMEZONE -TZID:US--Fictitious-Eastern -LAST-MODIFIED:19870101T000000Z -BEGIN:STANDARD -DTSTART:19671029T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19870405T020000 -RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;UNTIL=19980404T070000Z -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -BEGIN:DAYLIGHT -DTSTART:19990424T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=4 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VALARM -TRIGGER;VALUE=DATE-TIME:19970317T133000Z -REPEAT:4 -DURATION:PT15M -ACTION:AUDIO -ATTACH;FMTTYPE=audio/basic:ftp://host.com/pub/sounds/bell-01.aud -END:VALARM -BEGIN:VALARM -TRIGGER:-PT30M -REPEAT:2 -DURATION:PT15M -ACTION:DISPLAY -DESCRIPTION:Breakfast meeting with executive\n - team at 8:30 AM EST. -END:VALARM - -BEGIN:VALARM -TRIGGER:-P2D -ACTION:EMAIL -ATTENDEE:MAILTO:john_doe@host.com -SUMMARY:*** REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING *** -DESCRIPTION:A draft agenda needs to be sent out to the attendees - to the weekly managers meeting (MGR-LIST). Attached is a - pointer the document template for the agenda file. -ATTACH;FMTTYPE=application/binary:http://host.com/templates/agen - da.doc -END:VALARM - -BEGIN:VALARM -TRIGGER;VALUE=DATE-TIME:19980101T050000Z -REPEAT:23 -DURATION:PT1H -ACTION:PROCEDURE -ATTACH;FMTTYPE=application/binary:ftp://host.com/novo- - procs/felizano.exe -END:VALARM - -BEGIN:VTIMEZONE -TZID:US-Eastern -BEGIN:STANDARD -DTSTART:19981025T020000 -RDATE:19981025T020000 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19990404T020000 -RDATE:19990404T020000 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VEVENT -DTSTAMP:19980309T231000Z -UID:guid-1.host1.com -ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com -ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP: - MAILTO:employee-A@host.com -DESCRIPTION:Project XYZ Review Meeting -CATEGORIES:MEETING -CLASS:PUBLIC -CREATED:19980309T130000Z -SUMMARY:XYZ Project Review -DTSTART;TZID=US-Eastern:19980312T083000 -DTEND;TZID=US-Eastern:19980312T093000 -LOCATION:1CP Conference Room 4350 -END:VEVENT - -BEGIN:VEVENT -DTSTAMP:19970324T1200Z -SEQUENCE:0 -UID:uid3@host1.com -ORGANIZER:MAILTO:jdoe@host1.com -DTSTART:19970324T123000Z -DTEND:19970324T210000Z -CATEGORIES:MEETING,PROJECT -CLASS:PUBLIC -SUMMARY:Calendaring Interoperability Planning Meeting -DESCRIPTION:Discuss how we can test c&s interoperability\n - using iCalendar and other IETF standards. -LOCATION:LDB Lobby -ATTACH;FMTTYPE=application/postscript:ftp://xyzCorp.com/pub/ - conf/bkgrnd.ps -END:VEVENT - -BEGIN:VTODO -DTSTAMP:19980130T134500Z -SEQUENCE:2 -UID:uid4@host1.com -ORGANIZER:MAILTO:unclesam@us.gov -ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:jqpublic@host.com -DUE:19980415T235959 -STATUS:NEEDS-ACTION -SUMMARY:Submit Income Taxes -BEGIN:VALARM -ACTION:AUDIO -TRIGGER:19980403T120000 -ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio- - files/ssbanner.aud -REPEAT:4 -DURATION:PT1H -END:VALARM -END:VTODO - -BEGIN:VJOURNAL -DTSTAMP:19970324T120000Z -UID:uid5@host1.com -ORGANIZER:MAILTO:jsmith@host.com -STATUS:DRAFT -CLASS:PUBLIC -CATEGORIES:Project Report, XYZ, Weekly Meeting -DESCRIPTION:Project xyz Review Meeting Minutes\n - Agenda\n1. Review of project version 1.0 requirements.\n2. - Definition - of project processes.\n3. Review of project schedule.\n - Participants: John Smith\, Jane Doe\, Jim Dandy\n-It was - decided that the requirements need to be signed off by - product marketing.\n-Project processes were accepted.\n - -Project schedule needs to account for scheduled holidays - and employee vacation time. Check with HR for specific - dates.\n-New schedule will be distributed by Friday.\n- - Next weeks meeting is cancelled. No meeting until 3/23. -END:VJOURNAL - -BEGIN:VFREEBUSY -ORGANIZER:MAILTO:jsmith@host.com -DTSTART:19980313T141711Z -DTEND:19980410T141711Z -FREEBUSY:19980314T233000Z/19980315T003000Z -FREEBUSY:19980316T153000Z/19980316T163000Z -FREEBUSY:19980318T030000Z/19980318T040000Z -URL:http://www.host.com/calendar/busytime/jsmith.ifb -END:VFREEBUSY -END:VCALENDAR diff --git a/calendar/cal-util/.cvsignore b/calendar/cal-util/.cvsignore deleted file mode 100644 index edf21e8e74..0000000000 --- a/calendar/cal-util/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.libs -Makefile.in -Makefile -.deps -*.lo -*.la -test-recur -icalendar-test diff --git a/calendar/cal-util/Makefile.am b/calendar/cal-util/Makefile.am deleted file mode 100644 index 2c95bcaec5..0000000000 --- a/calendar/cal-util/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -noinst_PROGRAMS = icalendar-test -#noinst_PROGRAMS = test-recur icalendar-test - -INCLUDES = \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - -DG_LOG_DOMAIN=\"cal-util\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I. \ - -I.. \ - -I$(top_builddir) \ - -I$(top_srcdir)/libical/src/libical \ - -I$(top_builddir)/libical/src/libical \ - $(GNOME_INCLUDEDIR) - -# -# cal util library -# - -lib_LTLIBRARIES = libcal-util.la - -libcal_util_la_SOURCES = \ - cal-component.c \ - cal-recur.c \ - cal-util.c \ - calobj.c \ - icalendar.c \ - icalendar.h \ - icalendar-save.c \ - icalendar-save.h \ - timeutil.c - -libcal_utilincludedir = $(includedir)/evolution/cal-util - -libcal_utilinclude_HEADERS = \ - cal-component.h \ - cal-recur.h \ - cal-util.h \ - calobj.h \ - timeutil.h - -# -# static library for use in conduits' shared libraries -# -noinst_LTLIBRARIES = libcal-util-static.la -libcal_util_static_la_SOURCES = $(libcal_util_la_SOURCES) -libcal_util_static_la_LDFLAGS = --all-static - - -# -# test program -# - -icalendar_test_SOURCES = \ - icalendar-test.c \ - icalendar.c \ - icalendar-save.c - -icalendar_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical.a - -# $(top_builddir)/calendar/cal-util/libcal-util.la \ - -#test_recur_SOURCES = \ -# test-recur.c -# -#test_recur_LDADD = \ -# libcal-util.la \ -# $(top_builddir)/libversit/libversit.la \ -# $(top_builddir)/libical/src/libical/libical.a \ -# $(EXTRA_GNOME_LIBS) diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c deleted file mode 100644 index 7db5e348e4..0000000000 --- a/calendar/cal-util/cal-component.c +++ /dev/null @@ -1,3480 +0,0 @@ -/* Evolution calendar - iCalendar component object - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include "cal-component.h" -#include "timeutil.h" - - - -/* Private part of the CalComponent structure */ -struct _CalComponentPrivate { - /* The icalcomponent we wrap */ - icalcomponent *icalcomp; - - /* Properties */ - - icalproperty *uid; - - struct categories { - icalproperty *prop; - }; - GSList *categories_list; /* list of struct categories */ - - icalproperty *classification; - - struct text { - icalproperty *prop; - icalparameter *altrep_param; - }; - - GSList *comment_list; /* list of struct text */ - - icalproperty *completed; - icalproperty *created; - - GSList *description_list; /* list of struct text */ - - struct datetime { - icalproperty *prop; - icalparameter *tzid_param; - }; - - struct datetime dtstart; - struct datetime dtend; - - icalproperty *dtstamp; - - struct datetime due; - - GSList *exdate_list; /* list of icalproperty objects */ - GSList *exrule_list; /* list of icalproperty objects */ - - icalproperty *geo; - icalproperty *last_modified; - icalproperty *percent; - icalproperty *priority; - - struct period { - icalproperty *prop; - icalparameter *value_param; - }; - - GSList *rdate_list; /* list of struct period */ - - GSList *rrule_list; /* list of icalproperty objects */ - - icalproperty *sequence; - - struct { - icalproperty *prop; - icalparameter *altrep_param; - } summary; - - icalproperty *transparency; - icalproperty *url; - - /* Whether we should increment the sequence number when piping the - * object over the wire. - */ - guint need_sequence_inc : 1; -}; - -/* Private structure for alarms */ -struct _CalComponentAlarm { - /* Our parent component */ - CalComponent *parent; - - /* Alarm icalcomponent we wrap */ - icalcomponent *icalcomp; - - /* Properties */ - - icalproperty *action; - icalproperty *trigger; -}; - - - -static void cal_component_class_init (CalComponentClass *class); -static void cal_component_init (CalComponent *comp); -static void cal_component_destroy (GtkObject *object); - -static GtkObjectClass *parent_class; - - - -/** - * cal_component_get_type: - * - * Registers the #CalComponent class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalComponent class. - **/ -GtkType -cal_component_get_type (void) -{ - static GtkType cal_component_type = 0; - - if (!cal_component_type) { - static const GtkTypeInfo cal_component_info = { - "CalComponent", - sizeof (CalComponent), - sizeof (CalComponentClass), - (GtkClassInitFunc) cal_component_class_init, - (GtkObjectInitFunc) cal_component_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_component_type = gtk_type_unique (GTK_TYPE_OBJECT, &cal_component_info); - } - - return cal_component_type; -} - -/* Class initialization function for the calendar component object */ -static void -cal_component_class_init (CalComponentClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - object_class->destroy = cal_component_destroy; -} - -/* Object initialization function for the calendar component object */ -static void -cal_component_init (CalComponent *comp) -{ - CalComponentPrivate *priv; - - priv = g_new0 (CalComponentPrivate, 1); - comp->priv = priv; -} - -/* Does a simple g_free() of the elements of a GSList and then frees the list - * itself. Returns NULL. - */ -static GSList * -free_slist (GSList *slist) -{ - GSList *l; - - for (l = slist; l; l = l->next) - g_free (l->data); - - g_slist_free (slist); - return NULL; -} - -/* Frees the internal icalcomponent only if it does not have a parent. If it - * does, it means we don't own it and we shouldn't free it. - */ -static void -free_icalcomponent (CalComponent *comp) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - if (!priv->icalcomp) - return; - - /* Free the icalcomponent */ - - if (icalcomponent_get_parent (priv->icalcomp) != NULL) - icalcomponent_free (priv->icalcomp); - - priv->icalcomp = NULL; - - /* Free the mappings */ - - priv->uid = NULL; - - priv->categories_list = free_slist (priv->categories_list); - - priv->classification = NULL; - priv->comment_list = NULL; - priv->completed = NULL; - priv->created = NULL; - - priv->description_list = free_slist (priv->description_list); - - priv->dtend.prop = NULL; - priv->dtend.tzid_param = NULL; - - priv->dtstamp = NULL; - - priv->dtstart.prop = NULL; - priv->dtstart.tzid_param = NULL; - - priv->due.prop = NULL; - priv->due.tzid_param = NULL; - - g_slist_free (priv->exdate_list); - priv->exdate_list = NULL; - - g_slist_free (priv->exrule_list); - priv->exrule_list = NULL; - - priv->geo = NULL; - priv->last_modified = NULL; - priv->percent = NULL; - priv->priority = NULL; - - priv->rdate_list = free_slist (priv->rdate_list); - - g_slist_free (priv->rrule_list); - priv->rrule_list = NULL; - - priv->sequence = NULL; - - priv->summary.prop = NULL; - priv->summary.altrep_param = NULL; - - priv->transparency = NULL; - priv->url = NULL; - - /* Clean up */ - - priv->need_sequence_inc = FALSE; -} - -/* Destroy handler for the calendar component object */ -static void -cal_component_destroy (GtkObject *object) -{ - CalComponent *comp; - CalComponentPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_COMPONENT (object)); - - comp = CAL_COMPONENT (object); - priv = comp->priv; - - free_icalcomponent (comp); - - g_free (priv); - comp->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/** - * cal_component_gen_uid: - * - * Generates a unique identifier suitable for calendar components. - * - * Return value: A unique identifier string. Every time this function is called - * a different string is returned. - **/ -char * -cal_component_gen_uid (void) -{ - static char *hostname; - time_t t = time (NULL); - static int serial; - - if (!hostname) { - static char buffer [512]; - - if ((gethostname (buffer, sizeof (buffer) - 1) == 0) && - (buffer [0] != 0)) - hostname = buffer; - else - hostname = "localhost"; - } - - return g_strdup_printf ( - "%s-%d-%d-%d-%d@%s", - isodate_from_time_t (t), - getpid (), - getgid (), - getppid (), - serial++, - hostname); -} - -/** - * cal_component_new: - * - * Creates a new empty calendar component object. You should set it from an - * #icalcomponent structure by using cal_component_set_icalcomponent() or with a - * new empty component type by using cal_component_set_new_vtype(). - * - * Return value: A newly-created calendar component object. - **/ -CalComponent * -cal_component_new (void) -{ - return CAL_COMPONENT (gtk_type_new (CAL_COMPONENT_TYPE)); -} - -/** - * cal_component_clone: - * @comp: A calendar component object. - * - * Creates a new calendar component object by copying the information from - * another one. - * - * Return value: A newly-created calendar component with the same values as the - * original one. - **/ -CalComponent * -cal_component_clone (CalComponent *comp) -{ - CalComponentPrivate *priv; - CalComponent *new_comp; - icalcomponent *new_icalcomp; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL); - - new_comp = cal_component_new (); - - if (priv->icalcomp) { - new_icalcomp = icalcomponent_new_clone (priv->icalcomp); - cal_component_set_icalcomponent (new_comp, new_icalcomp); - } - - return new_comp; -} - -/* Scans the categories property */ -static void -scan_categories (CalComponent *comp, icalproperty *prop) -{ - CalComponentPrivate *priv; - struct categories *categ; - - priv = comp->priv; - - categ = g_new (struct categories, 1); - categ->prop = prop; - - priv->categories_list = g_slist_append (priv->categories_list, categ); -} - -/* Scans a date/time and timezone pair property */ -static void -scan_datetime (CalComponent *comp, struct datetime *datetime, icalproperty *prop) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - datetime->prop = prop; - datetime->tzid_param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); -} - -/* Scans an exception date property */ -static void -scan_exdate (CalComponent *comp, icalproperty *prop) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - priv->exdate_list = g_slist_append (priv->exdate_list, prop); -} - -/* Scans an icalperiodtype property */ -static void -scan_period (CalComponent *comp, GSList **list, icalproperty *prop) -{ - struct period *period; - - period = g_new (struct period, 1); - period->prop = prop; - period->value_param = icalproperty_get_first_parameter (prop, ICAL_VALUE_PARAMETER); - - *list = g_slist_append (*list, period); -} - -/* Scans an icalrecurtype property */ -static void -scan_recur (CalComponent *comp, GSList **list, icalproperty *prop) -{ - *list = g_slist_append (*list, prop); -} - -/* Scans the summary property */ -static void -scan_summary (CalComponent *comp, icalproperty *prop) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - priv->summary.prop = prop; - priv->summary.altrep_param = icalproperty_get_first_parameter (prop, ICAL_ALTREP_PARAMETER); -} - -/* Scans a text (i.e. text + altrep) property */ -static void -scan_text (CalComponent *comp, GSList **text_list, icalproperty *prop) -{ - struct text *text; - - text = g_new (struct text, 1); - text->prop = prop; - text->altrep_param = icalproperty_get_first_parameter (prop, ICAL_ALTREP_PARAMETER); - - *text_list = g_slist_append (*text_list, text); -} - -/* Scans an icalproperty and adds its mapping to the component */ -static void -scan_property (CalComponent *comp, icalproperty *prop) -{ - CalComponentPrivate *priv; - icalproperty_kind kind; - - priv = comp->priv; - - kind = icalproperty_isa (prop); - - switch (kind) { - case ICAL_CATEGORIES_PROPERTY: - scan_categories (comp, prop); - break; - - case ICAL_CLASS_PROPERTY: - priv->classification = prop; - break; - - case ICAL_COMMENT_PROPERTY: - scan_text (comp, &priv->comment_list, prop); - break; - - case ICAL_COMPLETED_PROPERTY: - priv->completed = prop; - break; - - case ICAL_CREATED_PROPERTY: - priv->created = prop; - break; - - case ICAL_DESCRIPTION_PROPERTY: - scan_text (comp, &priv->description_list, prop); - break; - - case ICAL_DTEND_PROPERTY: - scan_datetime (comp, &priv->dtend, prop); - break; - - case ICAL_DTSTAMP_PROPERTY: - priv->dtstamp = prop; - break; - - case ICAL_DTSTART_PROPERTY: - scan_datetime (comp, &priv->dtstart, prop); - break; - - case ICAL_DUE_PROPERTY: - scan_datetime (comp, &priv->due, prop); - break; - - case ICAL_EXDATE_PROPERTY: - scan_exdate (comp, prop); - break; - - case ICAL_EXRULE_PROPERTY: - scan_recur (comp, &priv->exrule_list, prop); - break; - - case ICAL_GEO_PROPERTY: - priv->geo = prop; - break; - - case ICAL_LASTMODIFIED_PROPERTY: - priv->last_modified = prop; - break; - - case ICAL_PERCENTCOMPLETE_PROPERTY: - priv->percent = prop; - break; - - case ICAL_PRIORITY_PROPERTY: - priv->priority = prop; - break; - - case ICAL_RDATE_PROPERTY: - scan_period (comp, &priv->rdate_list, prop); - break; - - case ICAL_RRULE_PROPERTY: - scan_recur (comp, &priv->rrule_list, prop); - break; - - case ICAL_SEQUENCE_PROPERTY: - priv->sequence = prop; - break; - - case ICAL_SUMMARY_PROPERTY: - scan_summary (comp, prop); - break; - - case ICAL_TRANSP_PROPERTY: - priv->transparency = prop; - break; - - case ICAL_UID_PROPERTY: - priv->uid = prop; - break; - - case ICAL_URL_PROPERTY: - priv->url = prop; - break; - - default: - break; - } -} - -/* Scans an icalcomponent for its properties so that we can provide - * random-access to them. - */ -static void -scan_icalcomponent (CalComponent *comp) -{ - CalComponentPrivate *priv; - icalproperty *prop; - - priv = comp->priv; - - g_assert (priv->icalcomp != NULL); - - for (prop = icalcomponent_get_first_property (priv->icalcomp, ICAL_ANY_PROPERTY); - prop; - prop = icalcomponent_get_next_property (priv->icalcomp, ICAL_ANY_PROPERTY)) - scan_property (comp, prop); - - /* We don't scan for alarm subcomponents since they can be iterated - * through using cal_component_get_{first,next}_alarm(). - */ -} - -/* Ensures that the mandatory calendar component properties (uid, dtstamp) do - * exist. If they don't exist, it creates them automatically. - */ -static void -ensure_mandatory_properties (CalComponent *comp) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - g_assert (priv->icalcomp != NULL); - - if (!priv->uid) { - char *uid; - - uid = cal_component_gen_uid (); - priv->uid = icalproperty_new_uid (uid); - g_free (uid); - - icalcomponent_add_property (priv->icalcomp, priv->uid); - } - - if (!priv->dtstamp) { - time_t tim; - struct icaltimetype t; - - tim = time (NULL); - t = icaltimetype_from_timet (tim, FALSE); - - priv->dtstamp = icalproperty_new_dtstamp (t); - icalcomponent_add_property (priv->icalcomp, priv->dtstamp); - } -} - -/** - * cal_component_set_new_vtype: - * @comp: A calendar component object. - * @type: Type of calendar component to create. - * - * Clears any existing component data from a calendar component object and - * creates a new #icalcomponent of the specified type for it. The only property - * that will be set in the new component will be its unique identifier. - **/ -void -cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type) -{ - CalComponentPrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - - free_icalcomponent (comp); - - if (type == CAL_COMPONENT_NO_TYPE) - return; - - /* Figure out the kind and create the icalcomponent */ - - switch (type) { - case CAL_COMPONENT_EVENT: - kind = ICAL_VEVENT_COMPONENT; - break; - - case CAL_COMPONENT_TODO: - kind = ICAL_VTODO_COMPONENT; - break; - - case CAL_COMPONENT_JOURNAL: - kind = ICAL_VJOURNAL_COMPONENT; - break; - - case CAL_COMPONENT_FREEBUSY: - kind = ICAL_VFREEBUSY_COMPONENT; - break; - - case CAL_COMPONENT_TIMEZONE: - kind = ICAL_VTIMEZONE_COMPONENT; - break; - - default: - g_assert_not_reached (); - kind = ICAL_NO_COMPONENT; - } - - icalcomp = icalcomponent_new (kind); - if (!icalcomp) { - g_message ("cal_component_set_new_vtype(): Could not create the icalcomponent!"); - return; - } - - /* Scan the component to build our mapping table */ - - priv->icalcomp = icalcomp; - scan_icalcomponent (comp); - - /* Add missing stuff */ - - ensure_mandatory_properties (comp); -} - -/** - * cal_component_set_icalcomponent: - * @comp: A calendar component object. - * @icalcomp: An #icalcomponent. - * - * Sets the contents of a calendar component object from an #icalcomponent - * structure. If the @comp already had an #icalcomponent set into it, it will - * will be freed automatically if the #icalcomponent does not have a parent - * component itself. - * - * Supported component types are VEVENT, VTODO, VJOURNAL, VFREEBUSY, and VTIMEZONE. - * - * Return value: TRUE on success, FALSE if @icalcomp is an unsupported component - * type. - **/ -gboolean -cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp) -{ - CalComponentPrivate *priv; - icalcomponent_kind kind; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - - if (priv->icalcomp == icalcomp) - return TRUE; - - free_icalcomponent (comp); - - if (!icalcomp) { - priv->icalcomp = NULL; - return TRUE; - } - - kind = icalcomponent_isa (icalcomp); - - if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT - || kind == ICAL_VFREEBUSY_COMPONENT - || kind == ICAL_VTIMEZONE_COMPONENT)) - return FALSE; - - priv->icalcomp = icalcomp; - - scan_icalcomponent (comp); - ensure_mandatory_properties (comp); - - return TRUE; -} - -/** - * cal_component_get_icalcomponent: - * @comp: A calendar component object. - * - * Queries the #icalcomponent structure that a calendar component object is - * wrapping. - * - * Return value: An #icalcomponent structure, or NULL if the @comp has no - * #icalcomponent set to it. - **/ -icalcomponent * -cal_component_get_icalcomponent (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL); - - return priv->icalcomp; -} - -/** - * cal_component_get_vtype: - * @comp: A calendar component object. - * - * Queries the type of a calendar component object. - * - * Return value: The type of the component, as defined by RFC 2445. - **/ -CalComponentVType -cal_component_get_vtype (CalComponent *comp) -{ - CalComponentPrivate *priv; - icalcomponent_kind kind; - - g_return_val_if_fail (comp != NULL, CAL_COMPONENT_NO_TYPE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), CAL_COMPONENT_NO_TYPE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, CAL_COMPONENT_NO_TYPE); - - kind = icalcomponent_isa (priv->icalcomp); - switch (kind) { - case ICAL_VEVENT_COMPONENT: - return CAL_COMPONENT_EVENT; - - case ICAL_VTODO_COMPONENT: - return CAL_COMPONENT_TODO; - - case ICAL_VJOURNAL_COMPONENT: - return CAL_COMPONENT_JOURNAL; - - case ICAL_VFREEBUSY_COMPONENT: - return CAL_COMPONENT_FREEBUSY; - - case ICAL_VTIMEZONE_COMPONENT: - return CAL_COMPONENT_TIMEZONE; - - default: - /* We should have been loaded with a supported type! */ - g_assert_not_reached (); - return CAL_COMPONENT_NO_TYPE; - } -} - -/** - * cal_component_get_as_string: - * @comp: A calendar component. - * - * Gets the iCalendar string representation of a calendar component. You should - * call cal_component_commit_sequence() before this function to ensure that the - * component's sequence number is consistent with the state of the object. - * - * Return value: String representation of the calendar component according to - * RFC 2445. - **/ -char * -cal_component_get_as_string (CalComponent *comp) -{ - CalComponentPrivate *priv; - char *str, *buf; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - /* Ensure that the user has committed the new SEQUENCE */ - g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL); - - /* We dup the string; libical owns that memory */ - - str = icalcomponent_as_ical_string (priv->icalcomp); - - if (str) - buf = g_strdup (str); - else - buf = NULL; - - return buf; -} - -/** - * cal_component_commit_sequence: - * @comp: - * - * Increments the sequence number property in a calendar component object if it - * needs it. This needs to be done when any of a number of properties listed in - * RFC 2445 change values, such as the start and end dates of a component. - * - * This function must be called before calling cal_component_get_as_string() to - * ensure that the component is fully consistent. - **/ -void -cal_component_commit_sequence (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->need_sequence_inc) - return; - - if (priv->sequence) { - int seq; - - seq = icalproperty_get_sequence (priv->sequence); - icalproperty_set_sequence (priv->sequence, seq + 1); - } else { - /* The component had no SEQUENCE property, so assume that the - * default would have been zero. Since it needed incrementing - * anyways, we use a value of 1 here. - */ - priv->sequence = icalproperty_new_sequence (1); - icalcomponent_add_property (priv->icalcomp, priv->sequence); - } - - priv->need_sequence_inc = FALSE; -} - -/** - * cal_component_get_uid: - * @comp: A calendar component object. - * @uid: Return value for the UID string. - * - * Queries the unique identifier of a calendar component object. - **/ -void -cal_component_get_uid (CalComponent *comp, const char **uid) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (uid != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->uid != NULL); - - *uid = icalproperty_get_uid (priv->uid); -} - -/** - * cal_component_set_uid: - * @comp: A calendar component object. - * @uid: Unique identifier. - * - * Sets the unique identifier string of a calendar component object. - **/ -void -cal_component_set_uid (CalComponent *comp, const char *uid) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (uid != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->uid != NULL); - - icalproperty_set_uid (priv->uid, (char *) uid); -} - -/** - * cal_component_get_categories_list: - * @comp: A calendar component object. - * @categ_list: Return value for the list of strings, where each string is a - * category. This should be freed using cal_component_free_categories_list(). - * - * Queries the list of categories of a calendar component object. Each element - * in the returned categ_list is a string with the corresponding category. - **/ -void -cal_component_get_categories_list (CalComponent *comp, GSList **categ_list) -{ - CalComponentPrivate *priv; - const char *categories; - const char *p; - const char *cat_start; - char *str; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (categ_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->categories_list) { - *categ_list = NULL; - return; - } - - categories = icalproperty_get_categories (priv->categories_list); - g_assert (categories != NULL); - - cat_start = categories; - - *categ_list = NULL; - - for (p = categories; *p; p++) - if (*p == ',') { - str = g_strndup (cat_start, p - cat_start); - *categ_list = g_slist_prepend (*categ_list, str); - - cat_start = p + 1; - } - - str = g_strndup (cat_start, p - cat_start); - *categ_list = g_slist_prepend (*categ_list, str); - - *categ_list = g_slist_reverse (*categ_list); -} - -/* Creates a comma-delimited string of categories */ -static char * -stringify_categories (GSList *categ_list) -{ - GString *s; - GSList *l; - char *str; - - s = g_string_new (NULL); - - for (l = categ_list; l; l = l->next) { - g_string_append (s, l->data); - - if (l->next != NULL) - g_string_append (s, ","); - } - - str = s->str; - g_string_free (s, FALSE); - - return str; -} - -/** - * cal_component_set_categories_list: - * @comp: A calendar component object. - * @categ_list: List of strings, one for each category. - * - * Sets the list of categories of a calendar component object. - **/ -void -cal_component_set_categories_list (CalComponent *comp, GSList *categ_list) -{ - CalComponentPrivate *priv; - struct categories *cat; - char *categories_str; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* Free the old list */ - - if (!categ_list) { - if (priv->categories_list) { - GSList *l; - - for (l = priv->categories_list; l; l = l->next) { - struct categories *c; - - c = l->data; - icalcomponent_remove_property (priv->icalcomp, c->prop); - icalproperty_free (c->prop); - - g_free (c); - } - - g_slist_free (priv->categories_list); - priv->categories_list = NULL; - } - - return; - } - - /* Create a single string of categories */ - - categories_str = stringify_categories (categ_list); - - /* Set the categories */ - - cat = g_new (struct categories, 1); - cat->prop = icalproperty_new_categories (categories_str); - g_free (categories_str); - - icalcomponent_add_property (priv->icalcomp, cat->prop); -} - -/** - * cal_component_get_classification: - * @comp: A calendar component object. - * @classif: Return value for the classification. - * - * Queries the classification of a calendar component object. If the - * classification property is not set on this component, this function returns - * #CAL_COMPONENT_CLASS_NONE. - **/ -void -cal_component_get_classification (CalComponent *comp, CalComponentClassification *classif) -{ - CalComponentPrivate *priv; - const char *class; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (classif != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->classification) { - *classif = CAL_COMPONENT_CLASS_NONE; - return; - } - - class = icalproperty_get_class (priv->classification); - - if (strcasecmp (class, "PUBLIC") == 0) - *classif = CAL_COMPONENT_CLASS_PUBLIC; - else if (strcasecmp (class, "PRIVATE") == 0) - *classif = CAL_COMPONENT_CLASS_PRIVATE; - else if (strcasecmp (class, "CONFIDENTIAL") == 0) - *classif = CAL_COMPONENT_CLASS_CONFIDENTIAL; - else - *classif = CAL_COMPONENT_CLASS_UNKNOWN; -} - -/** - * cal_component_set_classification: - * @comp: A calendar component object. - * @classif: Classification to use. - * - * Sets the classification property of a calendar component object. To unset - * the property, specify CAL_COMPONENT_CLASS_NONE for @classif. - **/ -void -cal_component_set_classification (CalComponent *comp, CalComponentClassification classif) -{ - CalComponentPrivate *priv; - char *str; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (classif != CAL_COMPONENT_CLASS_UNKNOWN); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (classif == CAL_COMPONENT_CLASS_NONE) { - if (priv->classification) { - icalcomponent_remove_property (priv->icalcomp, priv->classification); - icalproperty_free (priv->classification); - priv->classification = NULL; - } - - return; - } - - switch (classif) { - case CAL_COMPONENT_CLASS_PUBLIC: - str = "PUBLIC"; - break; - - case CAL_COMPONENT_CLASS_PRIVATE: - str = "PRIVATE"; - break; - - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - str = "CONFIDENTIAL"; - break; - - default: - g_assert_not_reached (); - str = NULL; - } - - if (priv->classification) - icalproperty_set_class (priv->classification, str); - else { - priv->classification = icalproperty_new_class (str); - icalcomponent_add_property (priv->icalcomp, priv->classification); - } -} - -/* Gets a text list value */ -static void -get_text_list (GSList *text_list, - char *(* get_prop_func) (icalproperty *prop), - GSList **tl) -{ - GSList *l; - - *tl = NULL; - - if (!text_list) - return; - - for (l = text_list; l; l = l->next) { - struct text *text; - CalComponentText *t; - - text = l->data; - g_assert (text->prop != NULL); - - t = g_new (CalComponentText, 1); - t->value = (* get_prop_func) (text->prop); - - if (text->altrep_param) - t->altrep = icalparameter_get_altrep (text->altrep_param); - else - t->altrep = NULL; - - *tl = g_slist_prepend (*tl, t); - } - - *tl = g_slist_reverse (*tl); -} - -/* Sets a text list value */ -static void -set_text_list (CalComponent *comp, - icalproperty *(* new_prop_func) (char *value), - GSList **text_list, - GSList *tl) -{ - CalComponentPrivate *priv; - GSList *l; - - priv = comp->priv; - - /* Remove old texts */ - - for (l = *text_list; l; l = l->next) { - struct text *text; - - text = l->data; - g_assert (text->prop != NULL); - - icalcomponent_remove_property (priv->icalcomp, text->prop); - icalproperty_free (text->prop); - g_free (text); - } - - g_slist_free (*text_list); - *text_list = NULL; - - /* Add in new texts */ - - for (l = tl; l; l = l->next) { - CalComponentText *t; - struct text *text; - - t = l->data; - g_return_if_fail (t->value != NULL); - - text = g_new (struct text, 1); - - text->prop = (* new_prop_func) ((char *) t->value); - icalcomponent_add_property (priv->icalcomp, text->prop); - - if (t->altrep) { - text->altrep_param = icalparameter_new_altrep ((char *) t->altrep); - icalproperty_add_parameter (text->prop, text->altrep_param); - } else - text->altrep_param = NULL; - - *text_list = g_slist_prepend (*text_list, text); - } - - *text_list = g_slist_reverse (*text_list); -} - -/** - * cal_component_get_comment_list: - * @comp: A calendar component object. - * @text_list: Return value for the comment properties and their parameters, as - * a list of #CalComponentText structures. This should be freed using the - * cal_component_free_text_list() function. - * - * Queries the comment of a calendar component object. The comment property can - * appear several times inside a calendar component, and so a list of - * #CalComponentText is returned. - **/ -void -cal_component_get_comment_list (CalComponent *comp, GSList **text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (text_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_text_list (priv->comment_list, icalproperty_get_comment, text_list); -} - -/** - * cal_component_set_comment_list: - * @comp: A calendar component object. - * @text_list: List of #CalComponentText structures. - * - * Sets the comment of a calendar component object. The comment property can - * appear several times inside a calendar component, and so a list of - * #CalComponentText structures is used. - **/ -void -cal_component_set_comment_list (CalComponent *comp, GSList *text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_text_list (comp, icalproperty_new_comment, &priv->comment_list, text_list); -} - -/* Gets a struct icaltimetype value */ -static void -get_icaltimetype (icalproperty *prop, - struct icaltimetype (* get_prop_func) (icalproperty *prop), - struct icaltimetype **t) -{ - if (!prop) { - *t = NULL; - return; - } - - *t = g_new (struct icaltimetype, 1); - **t = (* get_prop_func) (prop); -} - -/* Sets a struct icaltimetype value */ -static void -set_icaltimetype (CalComponent *comp, icalproperty **prop, - icalproperty *(* prop_new_func) (struct icaltimetype v), - void (* prop_set_func) (icalproperty *prop, struct icaltimetype v), - struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - if (!t) { - if (*prop) { - icalcomponent_remove_property (priv->icalcomp, *prop); - icalproperty_free (*prop); - *prop = NULL; - } - - return; - } - - if (*prop) - (* prop_set_func) (*prop, *t); - else { - *prop = (* prop_new_func) (*t); - icalcomponent_add_property (priv->icalcomp, *prop); - } -} - -/** - * cal_component_get_completed: - * @comp: A calendar component object. - * @t: Return value for the completion date. This should be freed using the - * cal_component_free_icaltimetype() function. - * - * Queries the date at which a calendar compoment object was completed. - **/ -void -cal_component_get_completed (CalComponent *comp, struct icaltimetype **t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_icaltimetype (priv->completed, icalproperty_get_completed, t); -} - -/** - * cal_component_set_completed: - * @comp: A calendar component object. - * @t: Value for the completion date. - * - * Sets the date at which a calendar component object was completed. - **/ -void -cal_component_set_completed (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_icaltimetype (comp, &priv->completed, - icalproperty_new_completed, - icalproperty_set_completed, - t); -} - - -/** - * cal_component_get_created: - * @comp: A calendar component object. - * @t: Return value for the creation date. This should be freed using the - * cal_component_free_icaltimetype() function. - * - * Queries the date in which a calendar component object was created in the - * calendar store. - **/ -void -cal_component_get_created (CalComponent *comp, struct icaltimetype **t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_icaltimetype (priv->created, icalproperty_get_created, t); -} - -/** - * cal_component_set_created: - * @comp: A calendar component object. - * @t: Value for the creation date. - * - * Sets the date in which a calendar component object is created in the calendar - * store. This should only be used inside a calendar store application, i.e. - * not by calendar user agents. - **/ -void -cal_component_set_created (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_icaltimetype (comp, &priv->created, - icalproperty_new_created, - icalproperty_set_created, - t); -} - -/** - * cal_component_get_description_list: - * @comp: A calendar component object. - * @text_list: Return value for the description properties and their parameters, - * as a list of #CalComponentText structures. This should be freed using the - * cal_component_free_text_list() function. - * - * Queries the description of a calendar component object. Journal components - * may have more than one description, and as such this function returns a list - * of #CalComponentText structures. All other types of components can have at - * most one description. - **/ -void -cal_component_get_description_list (CalComponent *comp, GSList **text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (text_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_text_list (priv->description_list, icalproperty_get_description, text_list); -} - -/** - * cal_component_set_description_list: - * @comp: A calendar component object. - * @text_list: List of #CalComponentSummary structures. - * - * Sets the description of a calendar component object. Journal components may - * have more than one description, and as such this function takes in a list of - * #CalComponentDescription structures. All other types of components can have - * at most one description. - **/ -void -cal_component_set_description_list (CalComponent *comp, GSList *text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_text_list (comp, icalproperty_new_description, &priv->description_list, text_list); -} - -/* Gets a date/time and timezone pair */ -static void -get_datetime (struct datetime *datetime, - struct icaltimetype (* get_prop_func) (icalproperty *prop), - CalComponentDateTime *dt) -{ - if (datetime->prop) { - dt->value = g_new (struct icaltimetype, 1); - *dt->value = (* get_prop_func) (datetime->prop); - } else - dt->value = NULL; - - if (datetime->tzid_param) - dt->tzid = icalparameter_get_tzid (datetime->tzid_param); - else - dt->tzid = NULL; -} - -/* Sets a date/time and timezone pair */ -static void -set_datetime (CalComponent *comp, struct datetime *datetime, - icalproperty *(* prop_new_func) (struct icaltimetype v), - void (* prop_set_func) (icalproperty * prop, struct icaltimetype v), - CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - if (!dt) { - if (datetime->prop) { - icalcomponent_remove_property (priv->icalcomp, datetime->prop); - icalproperty_free (datetime->prop); - - datetime->prop = NULL; - datetime->tzid_param = NULL; - } - - return; - } - - g_return_if_fail (dt->value != NULL); - - if (datetime->prop) - (* prop_set_func) (datetime->prop, *dt->value); - else { - datetime->prop = (* prop_new_func) (*dt->value); - icalcomponent_add_property (priv->icalcomp, datetime->prop); - } - - if (dt->tzid) { - g_assert (datetime->prop != NULL); - - if (datetime->tzid_param) - icalparameter_set_tzid (datetime->tzid_param, (char *) dt->tzid); - else { - datetime->tzid_param = icalparameter_new_tzid ((char *) dt->tzid); - icalproperty_add_parameter (datetime->prop, datetime->tzid_param); - } - } else if (datetime->tzid_param) { -#if 0 - /* FIXME: this fucking routine will assert(0) since it is not implemented */ - icalproperty_remove_parameter (datetime->prop, ICAL_TZID_PARAMETER); - icalparameter_free (datetime->tzid_param); -#endif - datetime->tzid_param = NULL; - } -} - -/** - * cal_component_get_dtend: - * @comp: A calendar component object. - * @dt: Return value for the date/time end. This should be freed with the - * cal_component_free_datetime() function. - * - * Queries the date/time end of a calendar component object. - **/ -void -cal_component_get_dtend (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (dt != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_datetime (&priv->dtend, icalproperty_get_dtend, dt); -} - -/** - * cal_component_set_dtend: - * @comp: A calendar component object. - * @dt: End date/time. - * - * Sets the date/time end property of a calendar component object. - **/ -void -cal_component_set_dtend (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_datetime (comp, &priv->dtend, - icalproperty_new_dtend, - icalproperty_set_dtend, - dt); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_get_dtstamp: - * @comp: A calendar component object. - * @t: Return value for the date/timestamp. - * - * Queries the date/timestamp property of a calendar component object, which is - * the last time at which the object was modified by a calendar user agent. - **/ -void -cal_component_get_dtstamp (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->dtstamp != NULL); - - *t = icalproperty_get_dtstamp (priv->dtstamp); -} - -/** - * cal_component_set_dtstamp: - * @comp: A calendar component object. - * @t: Date/timestamp value. - * - * Sets the date/timestamp of a calendar component object. This should be - * called whenever a calendar user agent makes a change to a component's - * properties. - **/ -void -cal_component_set_dtstamp (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->dtstamp != NULL); - - icalproperty_set_dtstamp (priv->dtstamp, *t); -} - -/** - * cal_component_get_dtstart: - * @comp: A calendar component object. - * @dt: Return value for the date/time start. This should be freed with the - * cal_component_free_datetime() function. - * - * Queries the date/time start of a calendar component object. - **/ -void -cal_component_get_dtstart (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (dt != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_datetime (&priv->dtstart, icalproperty_get_dtstart, dt); -} - -/** - * cal_component_set_dtstart: - * @comp: A calendar component object. - * @dt: Start date/time. - * - * Sets the date/time start property of a calendar component object. - **/ -void -cal_component_set_dtstart (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_datetime (comp, &priv->dtstart, - icalproperty_new_dtstart, - icalproperty_set_dtstart, - dt); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_get_due: - * @comp: A calendar component object. - * @dt: Return value for the due date/time. This should be freed with the - * cal_component_free_datetime() function. - * - * Queries the due date/time of a calendar component object. - **/ -void -cal_component_get_due (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (dt != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_datetime (&priv->due, icalproperty_get_due, dt); -} - -/** - * cal_component_set_due: - * @comp: A calendar component object. - * @dt: End date/time. - * - * Sets the due date/time property of a calendar component object. - **/ -void -cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_datetime (comp, &priv->due, - icalproperty_new_due, - icalproperty_set_due, - dt); - - priv->need_sequence_inc = TRUE; -} - -/* Builds a list of CalComponentPeriod structures based on a list of icalproperties */ -static void -get_period_list (GSList *period_list, - struct icalperiodtype (* get_prop_func) (icalproperty *prop), - GSList **list) -{ - GSList *l; - - *list = NULL; - - if (!period_list) - return; - - for (l = period_list; l; l = l->next) { - struct period *period; - CalComponentPeriod *p; - struct icalperiodtype ip; - - period = l->data; - g_assert (period->prop != NULL); - - p = g_new (CalComponentPeriod, 1); - - /* Get value parameter */ - - if (period->value_param) { - icalparameter_value value_type; - - value_type = icalparameter_get_value (period->value_param); - - if (value_type == ICAL_VALUE_DATE || value_type == ICAL_VALUE_DATETIME) - p->type = CAL_COMPONENT_PERIOD_DATETIME; - else if (value_type == ICAL_VALUE_DURATION) - p->type = CAL_COMPONENT_PERIOD_DURATION; - else { - g_message ("get_period_list(): Unknown value for period %d; " - "using DATETIME", value_type); - p->type = CAL_COMPONENT_PERIOD_DATETIME; - } - } else - p->type = CAL_COMPONENT_PERIOD_DATETIME; - - /* Get start and end/duration */ - - ip = (* get_prop_func) (period->prop); - - p->start = ip.start; - - if (p->type == CAL_COMPONENT_PERIOD_DATETIME) - p->u.end = ip.end; - else if (p->type == CAL_COMPONENT_PERIOD_DURATION) - p->u.duration = ip.duration; - else - g_assert_not_reached (); - - /* Put in list */ - - *list = g_slist_prepend (*list, p); - } - - *list = g_slist_reverse (*list); -} - -/* Sets a period list value */ -static void -set_period_list (CalComponent *comp, - icalproperty *(* new_prop_func) (struct icalperiodtype period), - GSList **period_list, - GSList *pl) -{ - CalComponentPrivate *priv; - GSList *l; - - priv = comp->priv; - - /* Remove old periods */ - - for (l = *period_list; l; l = l->next) { - struct period *period; - - period = l->data; - g_assert (period->prop != NULL); - - icalcomponent_remove_property (priv->icalcomp, period->prop); - icalproperty_free (period->prop); - g_free (period); - } - - g_slist_free (*period_list); - *period_list = NULL; - - /* Add in new periods */ - - for (l = pl; l; l = l->next) { - CalComponentPeriod *p; - struct period *period; - struct icalperiodtype ip; - icalparameter_value value_type; - - g_assert (l->data != NULL); - p = l->data; - - /* Create libical value */ - - ip.start = p->start; - - if (p->type == CAL_COMPONENT_PERIOD_DATETIME) { - value_type = ICAL_VALUE_DATETIME; - ip.end = p->u.end; - } else if (p->type == CAL_COMPONENT_PERIOD_DURATION) { - value_type = ICAL_VALUE_DURATION; - ip.duration = p->u.duration; - } else { - g_assert_not_reached (); - return; - } - - /* Create property */ - - period = g_new (struct period, 1); - - period->prop = (* new_prop_func) (ip); - period->value_param = icalparameter_new_value (value_type); - icalproperty_add_parameter (period->prop, period->value_param); - - /* Add to list */ - - *period_list = g_slist_prepend (*period_list, period); - } - - *period_list = g_slist_reverse (*period_list); -} - -/** - * cal_component_get_exdate_list: - * @comp: A calendar component object. - * @exdate_list: Return value for the list of exception dates, as a list of - * struct #icaltimetype structures. This should be freed using the - * cal_component_free_exdate_list() function. - * - * Queries the list of exception date properties in a calendar component object. - **/ -void -cal_component_get_exdate_list (CalComponent *comp, GSList **exdate_list) -{ - CalComponentPrivate *priv; - GSList *l; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (exdate_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - *exdate_list = NULL; - - for (l = priv->exdate_list; l; l = l->next) { - icalproperty *prop; - struct icaltimetype *t; - - prop = l->data; - - t = g_new (struct icaltimetype, 1); - *t = icalproperty_get_exdate (prop); - - *exdate_list = g_slist_prepend (*exdate_list, t); - } - - *exdate_list = g_slist_reverse (*exdate_list); -} - -/** - * cal_component_set_exdate_list: - * @comp: A calendar component object. - * @exdate_list: List of struct #icaltimetype structures. - * - * Sets the list of exception dates in a calendar component object. - **/ -void -cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list) -{ - CalComponentPrivate *priv; - GSList *l; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* Remove old exception dates */ - - for (l = priv->exdate_list; l; l = l->next) { - icalproperty *prop; - - prop = l->data; - icalcomponent_remove_property (priv->icalcomp, prop); - icalproperty_free (prop); - } - - g_slist_free (priv->exdate_list); - priv->exdate_list = NULL; - - /* Add in new exception dates */ - - for (l = exdate_list; l; l = l->next) { - icalproperty *prop; - struct icaltimetype *t; - - g_assert (l->data != NULL); - t = l->data; - - prop = icalproperty_new_exdate (*t); - icalcomponent_add_property (priv->icalcomp, prop); - - priv->exdate_list = g_slist_prepend (priv->exdate_list, prop); - } - - priv->exdate_list = g_slist_reverse (priv->exdate_list); - - priv->need_sequence_inc = TRUE; -} - -/* Gets a list of recurrence rules */ -static void -get_recur_list (GSList *recur_list, - struct icalrecurrencetype (* get_prop_func) (icalproperty *prop), - GSList **list) -{ - GSList *l; - - *list = NULL; - - for (l = recur_list; l; l = l->next) { - icalproperty *prop; - struct icalrecurrencetype *r; - - prop = l->data; - - r = g_new (struct icalrecurrencetype, 1); - *r = (* get_prop_func) (prop); - - *list = g_slist_prepend (*list, r); - } - - *list = g_slist_reverse (*list); -} - -/* Sets a list of recurrence rules */ -static void -set_recur_list (CalComponent *comp, - icalproperty *(* new_prop_func) (struct icalrecurrencetype recur), - GSList **recur_list, - GSList *rl) -{ - CalComponentPrivate *priv; - GSList *l; - - priv = comp->priv; - - /* Remove old recurrences */ - - for (l = *recur_list; l; l = l->next) { - icalproperty *prop; - - prop = l->data; - icalcomponent_remove_property (priv->icalcomp, prop); - icalproperty_free (prop); - } - - g_slist_free (*recur_list); - *recur_list = NULL; - - /* Add in new recurrences */ - - for (l = rl; l; l = l->next) { - icalproperty *prop; - struct icalrecurrencetype *recur; - - g_assert (l->data != NULL); - recur = l->data; - - prop = (* new_prop_func) (*recur); - icalcomponent_add_property (priv->icalcomp, prop); - - *recur_list = g_slist_prepend (*recur_list, prop); - } - - *recur_list = g_slist_reverse (*recur_list); -} - -/** - * cal_component_get_exrule_list: - * @comp: A calendar component object. - * @recur_list: List of exception rules as struct #icalrecurrencetype - * structures. This should be freed using the cal_component_free_recur_list() - * function. - * - * Queries the list of exception rule properties of a calendar component - * object. - **/ -void -cal_component_get_exrule_list (CalComponent *comp, GSList **recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_recur_list (priv->exrule_list, icalproperty_get_exrule, recur_list); -} - -/** - * cal_component_set_exrule_list: - * @comp: A calendar component object. - * @recur_list: List of struct #icalrecurrencetype structures. - * - * Sets the list of exception rules in a calendar component object. - **/ -void -cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_recur_list (comp, icalproperty_new_exrule, &priv->exrule_list, recur_list); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_get_geo: - * @comp: A calendar component object. - * @geo: Return value for the geographic position property. This should be - * freed using the cal_component_free_geo() function. - * - * Sets the geographic position property of a calendar component object. - **/ -void -cal_component_get_geo (CalComponent *comp, struct icalgeotype **geo) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (geo != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->geo) { - *geo = g_new (struct icalgeotype, 1); - **geo = icalproperty_get_geo (priv->geo); - } else - *geo = NULL; -} - -/** - * cal_component_set_geo: - * @comp: A calendar component object. - * @geo: Value for the geographic position property. - * - * Sets the geographic position property on a calendar component object. - **/ -void -cal_component_set_geo (CalComponent *comp, struct icalgeotype *geo) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!geo) { - if (priv->geo) { - icalcomponent_remove_property (priv->icalcomp, priv->geo); - icalproperty_free (priv->geo); - priv->geo = NULL; - } - - return; - } - - if (priv->geo) - icalproperty_set_geo (priv->geo, *geo); - else { - priv->geo = icalproperty_new_geo (*geo); - icalcomponent_add_property (priv->icalcomp, priv->geo); - } -} - -/** - * cal_component_get_last_modified: - * @comp: A calendar component object. - * @t: Return value for the last modified time value. - * - * Queries the time at which a calendar component object was last modified in - * the calendar store. - **/ -void -cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_icaltimetype (priv->last_modified, icalproperty_get_lastmodified, t); -} - -/** - * cal_component_set_last_modified: - * @comp: A calendar component object. - * @t: Value for the last time modified. - * - * Sets the time at which a calendar component object was last stored in the - * calendar store. This should not be called by plain calendar user agents. - **/ -void -cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_icaltimetype (comp, &priv->last_modified, - icalproperty_new_lastmodified, - icalproperty_set_lastmodified, - t); -} - -/** - * cal_component_get_percent: - * @comp: A calendar component object. - * @percent: Return value for the percent-complete property. This should be - * freed using the cal_component_free_percent() function. - * - * Queries the percent-complete property of a calendar component object. - **/ -void -cal_component_get_percent (CalComponent *comp, int **percent) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (percent != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->percent) { - *percent = g_new (int, 1); - **percent = icalproperty_get_percentcomplete (priv->percent); - } else - *percent = NULL; -} - -/** - * cal_component_set_percent: - * @comp: A calendar component object. - * @percent: Value for the percent-complete property. - * - * Sets the percent-complete property of a calendar component object. - **/ -void -cal_component_set_percent (CalComponent *comp, int *percent) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!percent) { - if (priv->percent) { - icalcomponent_remove_property (priv->icalcomp, priv->percent); - icalproperty_free (priv->percent); - priv->percent = NULL; - } - - return; - } - - g_return_if_fail (*percent >= 0 && *percent <= 100); - - if (priv->percent) - icalproperty_set_percentcomplete (priv->percent, *percent); - else { - priv->percent = icalproperty_new_percentcomplete (*percent); - icalcomponent_add_property (priv->icalcomp, priv->percent); - } -} - -/** - * cal_component_get_priority: - * @comp: A calendar component object. - * @priority: Return value for the priority property. This should be freed using - * the cal_component_free_priority() function. - * - * Queries the priority property of a calendar component object. - **/ -void -cal_component_get_priority (CalComponent *comp, int **priority) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (priority != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->priority) { - *priority = g_new (int, 1); - **priority = icalproperty_get_priority (priv->priority); - } else - *priority = NULL; -} - -/** - * cal_component_set_priority: - * @comp: A calendar component object. - * @priority: Value for the priority property. - * - * Sets the priority property of a calendar component object. - **/ -void -cal_component_set_priority (CalComponent *comp, int *priority) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priority) { - if (priv->priority) { - icalcomponent_remove_property (priv->icalcomp, priv->priority); - icalproperty_free (priv->priority); - priv->priority = NULL; - } - - return; - } - - g_return_if_fail (*priority >= 0 && *priority <= 9); - - if (priv->priority) - icalproperty_set_priority (priv->priority, *priority); - else { - priv->priority = icalproperty_new_priority (*priority); - icalcomponent_add_property (priv->icalcomp, priv->priority); - } -} - -/** - * cal_component_get_rdate_list: - * @comp: A calendar component object. - * @period_list: Return value for the list of recurrence dates, as a list of - * #CalComponentPeriod structures. This should be freed using the - * cal_component_free_period_list() function. - * - * Queries the list of recurrence date properties in a calendar component - * object. - **/ -void -cal_component_get_rdate_list (CalComponent *comp, GSList **period_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (period_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_period_list (priv->rdate_list, icalproperty_get_rdate, period_list); -} - -/** - * cal_component_set_rdate_list: - * @comp: A calendar component object. - * @period_list: List of #CalComponentPeriod structures. - * - * Sets the list of recurrence dates in a calendar component object. - **/ -void -cal_component_set_rdate_list (CalComponent *comp, GSList *period_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (period_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_period_list (comp, icalproperty_new_rdate, &priv->rdate_list, period_list); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_has_rdates: - * @comp: A calendar component object. - * - * Queries whether a calendar component object has any recurrence dates defined - * for it. - * - * Return value: TRUE if the component has recurrence dates, FALSE otherwise. - **/ -gboolean -cal_component_has_rdates (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - return (priv->rdate_list != NULL); -} - -/** - * cal_component_get_rrule_list: - * @comp: A calendar component object. - * @recur_list: List of recurrence rules as struct #icalrecurrencetype - * structures. This should be freed using the cal_component_free_recur_list() - * function. - * - * Queries the list of recurrence rule properties of a calendar component - * object. - **/ -void -cal_component_get_rrule_list (CalComponent *comp, GSList **recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_recur_list (priv->rrule_list, icalproperty_get_rrule, recur_list); -} - -/** - * cal_component_set_rrule_list: - * @comp: A calendar component object. - * @recur_list: List of struct #icalrecurrencetype structures. - * - * Sets the list of recurrence rules in a calendar component object. - **/ -void -cal_component_set_rrule_list (CalComponent *comp, GSList *recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_recur_list (comp, icalproperty_new_rrule, &priv->rrule_list, recur_list); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_has_rrules: - * @comp: A calendar component object. - * - * Queries whether a calendar component object has any recurrence rules defined - * for it. - * - * Return value: TRUE if the component has recurrence rules, FALSE otherwise. - **/ -gboolean -cal_component_has_rrules (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - return (priv->rrule_list != NULL); -} - -/** - * cal_component_get_sequence: - * @comp: A calendar component object. - * @sequence: Return value for the sequence number. This should be freed using - * cal_component_free_sequence(). - * - * Queries the sequence number of a calendar component object. - **/ -void -cal_component_get_sequence (CalComponent *comp, int **sequence) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (sequence != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->sequence) { - *sequence = NULL; - return; - } - - *sequence = g_new (int, 1); - **sequence = icalproperty_get_sequence (priv->sequence); -} - -/** - * cal_component_set_sequence: - * @comp: A calendar component object. - * @sequence: Sequence number value. - * - * Sets the sequence number of a calendar component object. Normally this - * function should not be called, since the sequence number is incremented - * automatically at the proper times. - **/ -void -cal_component_set_sequence (CalComponent *comp, int *sequence) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - priv->need_sequence_inc = FALSE; - - if (!sequence) { - if (priv->sequence) { - icalcomponent_remove_property (priv->icalcomp, priv->sequence); - icalproperty_free (priv->sequence); - priv->sequence = NULL; - } - - return; - } - - if (priv->sequence) - icalproperty_set_sequence (priv->sequence, *sequence); - else { - priv->sequence = icalproperty_new_sequence (*sequence); - icalcomponent_add_property (priv->icalcomp, priv->sequence); - } -} - -/** - * cal_component_get_summary: - * @comp: A calendar component object. - * @summary: Return value for the summary property and its parameters. - * - * Queries the summary of a calendar component object. - **/ -void -cal_component_get_summary (CalComponent *comp, CalComponentText *summary) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (summary != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->summary.prop) - summary->value = icalproperty_get_summary (priv->summary.prop); - else - summary->value = NULL; - - if (priv->summary.altrep_param) - summary->altrep = icalparameter_get_altrep (priv->summary.altrep_param); - else - summary->altrep = NULL; -} - -/** - * cal_component_set_summary: - * @comp: A calendar component object. - * @summary: Summary property and its parameters. - * - * Sets the summary of a calendar component object. - **/ -void -cal_component_set_summary (CalComponent *comp, CalComponentText *summary) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!summary) { - if (priv->summary.prop) { - icalcomponent_remove_property (priv->icalcomp, priv->summary.prop); - icalproperty_free (priv->summary.prop); - - priv->summary.prop = NULL; - priv->summary.altrep_param = NULL; - } - - return; - } - - g_return_if_fail (summary->value != NULL); - - if (priv->summary.prop) - icalproperty_set_summary (priv->summary.prop, (char *) summary->value); - else { - priv->summary.prop = icalproperty_new_summary ((char *) summary->value); - icalcomponent_add_property (priv->icalcomp, priv->summary.prop); - } - - if (summary->altrep) { - g_assert (priv->summary.prop != NULL); - - if (priv->summary.altrep_param) - icalparameter_set_altrep (priv->summary.altrep_param, - (char *) summary->altrep); - else { - priv->summary.altrep_param = icalparameter_new_altrep ( - (char *) summary->altrep); - icalproperty_add_parameter (priv->summary.prop, - priv->summary.altrep_param); - } - } else if (priv->summary.altrep_param) { -#if 0 - /* FIXME: this fucking routine will assert(0) since it is not implemented */ - icalproperty_remove_parameter (priv->summary.prop, ICAL_ALTREP_PARAMETER); - icalparameter_free (priv->summary.altrep_param); -#endif - priv->summary.altrep_param = NULL; - } -} - -/** - * cal_component_get_transparency: - * @comp: A calendar component object. - * @transp: Return value for the time transparency. - * - * Queries the time transparency of a calendar component object. - **/ -void -cal_component_get_transparency (CalComponent *comp, CalComponentTransparency *transp) -{ - CalComponentPrivate *priv; - const char *val; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (transp != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->transparency) { - *transp = CAL_COMPONENT_TRANSP_NONE; - return; - } - - val = icalproperty_get_transp (priv->transparency); - - if (strcasecmp (val, "TRANSPARENT")) - *transp = CAL_COMPONENT_TRANSP_TRANSPARENT; - else if (strcasecmp (val, "OPAQUE")) - *transp = CAL_COMPONENT_TRANSP_OPAQUE; - else - *transp = CAL_COMPONENT_TRANSP_UNKNOWN; -} - -/** - * cal_component_set_transparency: - * @comp: A calendar component object. - * @transp: Time transparency value. - * - * Sets the time transparency of a calendar component object. - **/ -void -cal_component_set_transparency (CalComponent *comp, CalComponentTransparency transp) -{ - CalComponentPrivate *priv; - char *str; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (transp != CAL_COMPONENT_TRANSP_UNKNOWN); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - - if (transp == CAL_COMPONENT_TRANSP_NONE) { - if (priv->transparency) { - icalcomponent_remove_property (priv->icalcomp, priv->transparency); - icalproperty_free (priv->transparency); - priv->transparency = NULL; - } - - return; - } - - switch (transp) { - case CAL_COMPONENT_TRANSP_TRANSPARENT: - str = "TRANSPARENT"; - break; - - case CAL_COMPONENT_TRANSP_OPAQUE: - str = "OPAQUE"; - break; - - default: - g_assert_not_reached (); - str = NULL; - } - - if (priv->transparency) - icalproperty_set_transp (priv->transparency, str); - else { - priv->transparency = icalproperty_new_transp (str); - icalcomponent_add_property (priv->icalcomp, priv->transparency); - } -} - -/** - * cal_component_get_url: - * @comp: A calendar component object. - * @url: Return value for the URL. - * - * Queries the uniform resource locator property of a calendar component object. - **/ -void -cal_component_get_url (CalComponent *comp, const char **url) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (url != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->url) - *url = icalproperty_get_url (priv->url); - else - *url = NULL; -} - -/** - * cal_component_set_url: - * @comp: A calendar component object. - * @url: URL value. - * - * Sets the uniform resource locator property of a calendar component object. - **/ -void -cal_component_set_url (CalComponent *comp, const char *url) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!url) { - if (priv->url) { - icalcomponent_remove_property (priv->icalcomp, priv->url); - icalproperty_free (priv->url); - priv->url = NULL; - } - - return; - } - - if (priv->url) - icalproperty_set_url (priv->url, (char *) url); - else { - priv->url = icalproperty_new_url ((char *) url); - icalcomponent_add_property (priv->icalcomp, priv->url); - } -} - -/** - * cal_component_get_pilot_id: - * @comp: A calendar component object. - * @pilot_id: Return value for the pilot ID. - * - * Queries the pilot id of a calendar component object, if any. - **/ -void -cal_component_get_pilot_id (CalComponent *comp, unsigned long *pilot_id) -{ - /* pilot_id maybe should be recordid_t */ - /* FIX ME */ - *pilot_id = 0; -} - -/** - * cal_component_set_pilot_id: - * @comp: A calendar component object. - * @pilot_id: Return value for the pilot ID. - * - * Sets the pilot id of a clanedar component object. - **/ -void -cal_component_set_pilot_id (CalComponent *comp, unsigned long pilot_id) -{ - /* pilot_id maybe should be recordid_t */ - /* FIX ME */ -} - -/** - * cal_component_get_pilot_status: - * @comp: A calendar component object. - * @pilot_status: Return value for the pilot sync status. - * - * Queries the pilot status of a calendar component object, if any. - **/ -void -cal_component_get_pilot_status (CalComponent *comp, unsigned long *pilot_status) -{ - /* FIX ME */ - /* pilot_status should be iCalPilotState ? */ - *pilot_status = 0; -} - -/** - * cal_component_set_pilot_id: - * @comp: A calendar component object. - * @pilot_id: Return value for the pilot ID. - * - * Sets the pilot id of a clanedar component object. - **/ -void -cal_component_set_pilot_status (CalComponent *comp, unsigned long pilot_status) -{ - /* pilot_id maybe should be recordid_t */ - /* FIX ME */ -} - - - - - -/** - * cal_component_free_categories_list: - * @categ_list: List of category strings. - * - * Frees a list of category strings. - **/ -void -cal_component_free_categories_list (GSList *categ_list) -{ - GSList *l; - - for (l = categ_list; l; l = l->next) - g_free (l->data); - - g_slist_free (categ_list); -} - -/** - * cal_component_free_datetime: - * @dt: A date/time structure. - * - * Frees a date/time structure. - **/ -void -cal_component_free_datetime (CalComponentDateTime *dt) -{ - g_return_if_fail (dt != NULL); - - if (dt->value) - g_free (dt->value); -} - -/** - * cal_component_free_exdate_list: - * @exdate_list: List of struct #icaltimetype structures. - * - * Frees a list of struct #icaltimetype structures. - **/ -void -cal_component_free_exdate_list (GSList *exdate_list) -{ - GSList *l; - - for (l = exdate_list; l; l = l->next) { - struct icaltimetype *t; - - g_assert (l->data != NULL); - t = l->data; - - g_free (t); - } - - g_slist_free (exdate_list); -} - -/** - * cal_component_free_geo: - * @geo: An #icalgeotype structure. - * - * Frees a struct #icalgeotype structure as returned by the calendar component - * functions. - **/ -void -cal_component_free_geo (struct icalgeotype *geo) -{ - g_return_if_fail (geo != NULL); - - g_free (geo); -} - -/** - * cal_component_free_icaltimetype: - * @t: An #icaltimetype structure. - * - * Frees a struct #icaltimetype value as returned by the calendar component - * functions. - **/ -void -cal_component_free_icaltimetype (struct icaltimetype *t) -{ - g_return_if_fail (t != NULL); - - g_free (t); -} - -/** - * cal_component_free_percent: - * @percent: Percent value. - * - * Frees a percent value as returned by the cal_component_get_percent() - * function. - **/ -void -cal_component_free_percent (int *percent) -{ - g_return_if_fail (percent != NULL); - - g_free (percent); -} - -/** - * cal_component_free_priority: - * @priority: Priority value. - * - * Frees a priority value as returned by the cal_component_get_priority() - * function. - **/ -void -cal_component_free_priority (int *priority) -{ - g_return_if_fail (priority != NULL); - - g_free (priority); -} - -/** - * cal_component_free_period_list: - * @period_list: List of #CalComponentPeriod structures. - * - * Frees a list of #CalComponentPeriod structures. - **/ -void -cal_component_free_period_list (GSList *period_list) -{ - GSList *l; - - for (l = period_list; l; l = l->next) { - CalComponentPeriod *period; - - g_assert (l->data != NULL); - - period = l->data; - g_free (period); - } - - g_slist_free (period_list); -} - -/** - * cal_component_free_recur_list: - * @recur_list: List of struct #icalrecurrencetype structures. - * - * Frees a list of struct #icalrecurrencetype structures. - **/ -void -cal_component_free_recur_list (GSList *recur_list) -{ - GSList *l; - - for (l = recur_list; l; l = l->next) { - struct icalrecurrencetype *r; - - g_assert (l->data != NULL); - r = l->data; - - g_free (l); - } - - g_slist_free (recur_list); -} - -/** - * cal_component_free_sequence: - * @sequence: Sequence number value. - * - * Frees a sequence number value. - **/ -void -cal_component_free_sequence (int *sequence) -{ - g_return_if_fail (sequence != NULL); - - g_free (sequence); -} - -/** - * cal_component_free_text_list: - * @text_list: List of #CalComponentText structures. - * - * Frees a list of #CalComponentText structures. This function should only be - * used to free lists of text values as returned by the other getter functions - * of #CalComponent. - **/ -void -cal_component_free_text_list (GSList *text_list) -{ - GSList *l; - - for (l = text_list; l; l = l->next) { - CalComponentText *text; - - g_assert (l->data != NULL); - - text = l->data; - g_return_if_fail (text != NULL); - g_free (text); - } - - g_slist_free (text_list); -} - - - -/* Scans an icalproperty from a calendar component and adds its mapping to our - * own alarm structure. - */ -static void -scan_alarm_property (CalComponentAlarm *alarm, icalproperty *prop) -{ - icalproperty_kind kind; - - kind = icalproperty_isa (prop); - - switch (kind) { - case ICAL_ACTION_PROPERTY: - alarm->action = prop; - break; - - case ICAL_TRIGGER_PROPERTY: - alarm->trigger = prop; - break; - - default: - break; - } -} - -/* Creates a CalComponentAlarm from a libical alarm subcomponent */ -static CalComponentAlarm * -make_alarm (CalComponent *comp, icalcomponent *subcomp) -{ - CalComponentAlarm *alarm; - icalproperty *prop; - - alarm = g_new (CalComponentAlarm, 1); - - alarm->parent = comp; - alarm->icalcomp = subcomp; - - for (prop = icalcomponent_get_first_property (subcomp, ICAL_ANY_PROPERTY); - prop; - prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY)) - scan_alarm_property (alarm, prop); - - return alarm; -} - -/** - * cal_component_get_first_alarm: - * @comp: A calendar component object. - * - * Starts an iterator for the alarms in a calendar component object. Subsequent - * alarms can be obtained with the cal_component_get_next_alarm() function. - * - * Return value: The first alarm in the component, or NULL if the component has - * no alarms. This should be freed using the cal_component_alarm_free() - * function. - **/ -CalComponentAlarm * -cal_component_get_first_alarm (CalComponent *comp) -{ - CalComponentPrivate *priv; - icalcomponent *subcomp; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - subcomp = icalcomponent_get_first_component (priv->icalcomp, ICAL_VALARM_COMPONENT); - if (!subcomp) - return NULL; - - return make_alarm (comp, subcomp); -} - -/** - * cal_component_get_next_alarm: - * @comp: A calendar component object. - * - * Gets the next alarm on a calendar component object. This should be used as - * an iterator function after calling cal_component_get_first_alarm(). - * - * Return value: The next alarm in the component, or NULL if the component has - * no more alarms. This should be freed using the cal_component_alarm_free() - * function. - **/ -CalComponentAlarm * -cal_component_get_next_alarm (CalComponent *comp) -{ - CalComponentPrivate *priv; - icalcomponent *subcomp; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - subcomp = icalcomponent_get_next_component (priv->icalcomp, ICAL_VALARM_COMPONENT); - if (!subcomp) - return NULL; - - return make_alarm (comp, subcomp); -} - -/** - * cal_component_alarm_free: - * @alarm: A calendar alarm. - * - * Frees an alarm structure. - **/ -void -cal_component_alarm_free (CalComponentAlarm *alarm) -{ - g_return_if_fail (alarm != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (icalcomponent_get_parent (alarm->icalcomp) != NULL) - icalcomponent_free (alarm->icalcomp); - - alarm->icalcomp = NULL; - - alarm->parent = NULL; - alarm->action = NULL; - - g_free (alarm); -} - -/** - * cal_component_alarm_get_action: - * @alarm: An alarm. - * @action: Return value for the alarm's action type. - * - * Queries the action type of an alarm. - **/ -void -cal_component_alarm_get_action (CalComponentAlarm *alarm, CalComponentAlarmAction *action) -{ - const char *str; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (action != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (!alarm->action) { - *action = CAL_COMPONENT_ALARM_NONE; - return; - } - - str = icalproperty_get_action (alarm->action); - - if (strcasecmp (str, "AUDIO") == 0) - *action = CAL_COMPONENT_ALARM_AUDIO; - else if (strcasecmp (str, "DISPLAY") == 0) - *action = CAL_COMPONENT_ALARM_DISPLAY; - else if (strcasecmp (str, "EMAIL") == 0) - *action = CAL_COMPONENT_ALARM_EMAIL; - else if (strcasecmp (str, "PROCEDURE") == 0) - *action = CAL_COMPONENT_ALARM_PROCEDURE; - else - *action = CAL_COMPONENT_ALARM_UNKNOWN; -} - -/** - * cal_component_alarm_set_action: - * @alarm: An alarm. - * @action: Action type. - * - * Sets the action type for an alarm. - **/ -void -cal_component_alarm_set_action (CalComponentAlarm *alarm, CalComponentAlarmAction action) -{ - char *str; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (action != CAL_COMPONENT_ALARM_NONE); - g_return_if_fail (action != CAL_COMPONENT_ALARM_UNKNOWN); - - g_assert (alarm->icalcomp != NULL); - - switch (action) { - case CAL_COMPONENT_ALARM_AUDIO: - str = "AUDIO"; - break; - - case CAL_COMPONENT_ALARM_DISPLAY: - str = "DISPLAY"; - break; - - case CAL_COMPONENT_ALARM_EMAIL: - str = "EMAIL"; - break; - - case CAL_COMPONENT_ALARM_PROCEDURE: - str = "PROCEDURE"; - break; - - default: - g_assert_not_reached (); - str = NULL; - } - - if (alarm->action) - icalproperty_set_action (alarm->action, str); - else { - alarm->action = icalproperty_new_action (str); - icalcomponent_add_property (alarm->icalcomp, alarm->action); - } -} - -/** - * cal_component_alarm_get_trigger: - * @alarm: An alarm. - * @trigger: Return value for the trigger time. This should be freed using the - * cal_component_alarm_free_trigger() function. - * - * Queries the trigger time for an alarm. - **/ -void -cal_component_alarm_get_trigger (CalComponentAlarm *alarm, CalComponentAlarmTrigger **trigger) -{ - icalparameter *param; - union icaltriggertype t; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (trigger != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (!alarm->trigger) { - *trigger = NULL; - return; - } - - *trigger = g_new (CalComponentAlarmTrigger, 1); - - /* Get trigger type */ - - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_VALUE_PARAMETER); - - if (param) { - icalparameter_value value; - - value = icalparameter_get_value (param); - - switch (value) { - case ICAL_VALUE_DURATION: - (*trigger)->type = CAL_COMPONENT_ALARM_TRIGGER_RELATIVE; - break; - - case ICAL_VALUE_DATETIME: - (*trigger)->type = CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE; - break; - - default: - g_message ("cal_component_alarm_get_trigger(): Unknown value for trigger " - "value %d; using RELATIVE", value); - - (*trigger)->type = CAL_COMPONENT_ALARM_TRIGGER_RELATIVE; - break; - } - } else - (*trigger)->type = CAL_COMPONENT_ALARM_TRIGGER_RELATIVE; - - /* Get trigger value and the RELATED parameter */ - - t = icalproperty_get_trigger (alarm->trigger); - - switch ((*trigger)->type) { - case CAL_COMPONENT_ALARM_TRIGGER_RELATIVE: - (*trigger)->u.relative.duration = t.duration; - - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_RELATED_PARAMETER); - if (param) { - icalparameter_related rel; - - rel = icalparameter_get_related (param); - - switch (rel) { - case ICAL_RELATED_START: - (*trigger)->u.relative.related = - CAL_COMPONENT_ALARM_TRIGGER_RELATED_START; - break; - - case ICAL_RELATED_END: - (*trigger)->u.relative.related = - CAL_COMPONENT_ALARM_TRIGGER_RELATED_END; - break; - - default: - g_assert_not_reached (); - } - } else - (*trigger)->u.relative.related = CAL_COMPONENT_ALARM_TRIGGER_RELATED_START; - - break; - - case CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE: - (*trigger)->u.absolute = t.time; - break; - - default: - g_assert_not_reached (); - } -} - -/** - * cal_component_alarm_set_trigger: - * @alarm: An alarm. - * @trigger: Trigger time structure. - * - * Sets the trigger time of an alarm. - **/ -void -cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalComponentAlarmTrigger *trigger) -{ - union icaltriggertype t; - icalparameter *param; - icalparameter_value value_type; - icalparameter_related related; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (trigger != NULL); - - g_assert (alarm->icalcomp != NULL); - - /* Delete old trigger */ - - if (alarm->trigger) { - icalcomponent_remove_property (alarm->icalcomp, alarm->trigger); - icalproperty_free (alarm->trigger); - alarm->trigger = NULL; - } - - /* Set the value */ - - value_type = ICAL_DURATION_VALUE; /* Keep GCC happy */ - related = ICAL_RELATED_START; /* Ditto */ - - switch (trigger->type) { - case CAL_COMPONENT_ALARM_TRIGGER_RELATIVE: - t.duration = trigger->u.relative.duration; - value_type = ICAL_DURATION_VALUE; - - switch (trigger->u.relative.related) { - case CAL_COMPONENT_ALARM_TRIGGER_RELATED_START: - related = ICAL_RELATED_START; - break; - - case CAL_COMPONENT_ALARM_TRIGGER_RELATED_END: - related = ICAL_RELATED_END; - break; - - default: - g_assert_not_reached (); - return; - } - - break; - - case CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE: - t.time = trigger->u.absolute; - value_type = ICAL_DATETIME_VALUE; - break; - - default: - g_assert_not_reached (); - return; - } - - alarm->trigger = icalproperty_new_trigger (t); - icalcomponent_add_property (alarm->icalcomp, alarm->trigger); - - /* Value parameters */ - - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_VALUE_PARAMETER); - if (param) - icalparameter_set_value (param, value_type); - else { - param = icalparameter_new_value (value_type); - icalproperty_add_parameter (alarm->trigger, param); - } - - /* Related parameter */ - - if (trigger->type == CAL_COMPONENT_ALARM_TRIGGER_RELATIVE) { - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_RELATED_PARAMETER); - - if (param) - icalparameter_set_related (param, related); - else { - param = icalparameter_new_related (related); - icalproperty_add_parameter (alarm->trigger, param); - } - } -} - -/** - * cal_component_alarm_free_trigger: - * @trigger: A #CalComponentAlarmTrigger structure. - * - * Frees a #CalComponentAlarmTrigger structure. - **/ -void -cal_component_alarm_free_trigger (CalComponentAlarmTrigger *trigger) -{ - g_return_if_fail (trigger != NULL); - - g_free (trigger); -} diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h deleted file mode 100644 index c8e2627448..0000000000 --- a/calendar/cal-util/cal-component.h +++ /dev/null @@ -1,306 +0,0 @@ -/* Evolution calendar - iCalendar component object - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_COMPONENT_H -#define CAL_COMPONENT_H - -#include <libgnome/gnome-defs.h> -#include <time.h> -#include <gtk/gtkobject.h> -#include <ical.h> - -BEGIN_GNOME_DECLS - - - -#define CAL_COMPONENT_TYPE (cal_component_get_type ()) -#define CAL_COMPONENT(obj) (GTK_CHECK_CAST ((obj), CAL_COMPONENT_TYPE, CalComponent)) -#define CAL_COMPONENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_COMPONENT_TYPE, \ - CalComponentClass)) -#define IS_CAL_COMPONENT(obj) (GTK_CHECK_TYPE ((obj), CAL_COMPONENT_TYPE)) -#define IS_CAL_COMPONENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_COMPONENT_TYPE)) - -/* Types of calendar components to be stored by a CalComponent, as per RFC 2445. - * We don't put the alarm component type here since we store alarms as separate - * structures inside the other "real" components. - */ -typedef enum { - CAL_COMPONENT_NO_TYPE, - CAL_COMPONENT_EVENT, - CAL_COMPONENT_TODO, - CAL_COMPONENT_JOURNAL, - CAL_COMPONENT_FREEBUSY, - CAL_COMPONENT_TIMEZONE -} CalComponentVType; - -/* Field identifiers for a calendar component */ -typedef enum { - CAL_COMPONENT_FIELD_CATEGORIES, /* concatenation of the categories list */ - CAL_COMPONENT_FIELD_CLASSIFICATION, - CAL_COMPONENT_FIELD_COMPLETED, - CAL_COMPONENT_FIELD_DTEND, - CAL_COMPONENT_FIELD_DTSTART, - CAL_COMPONENT_FIELD_DUE, - CAL_COMPONENT_FIELD_GEO, - CAL_COMPONENT_FIELD_PERCENT, - CAL_COMPONENT_FIELD_PRIORITY, - CAL_COMPONENT_FIELD_SUMMARY, - CAL_COMPONENT_FIELD_TRANSPARENCY, - CAL_COMPONENT_FIELD_URL, - CAL_COMPONENT_FIELD_HAS_ALARMS, /* not a real field */ - CAL_COMPONENT_FIELD_ICON, /* not a real field */ - CAL_COMPONENT_FIELD_COMPLETE, /* not a real field */ - CAL_COMPONENT_FIELD_RECURRING, /* not a real field */ - CAL_COMPONENT_FIELD_OVERDUE, /* not a real field */ - CAL_COMPONENT_FIELD_COLOR, /* not a real field */ - CAL_COMPONENT_FIELD_NUM_FIELDS -} CalComponentField; - -/* Structures to return properties and their parameters */ - -typedef enum { - CAL_COMPONENT_CLASS_NONE, - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, - CAL_COMPONENT_CLASS_UNKNOWN -} CalComponentClassification; - -typedef struct { - /* Actual date/time value */ - struct icaltimetype *value; - - /* Timezone ID */ - const char *tzid; -} CalComponentDateTime; - -typedef enum { - CAL_COMPONENT_PERIOD_DATETIME, - CAL_COMPONENT_PERIOD_DURATION -} CalComponentPeriodType; - -typedef struct { - CalComponentPeriodType type; - - struct icaltimetype start; - - union { - struct icaltimetype end; - struct icaldurationtype duration; - } u; -} CalComponentPeriod; - -typedef struct { - /* Description string */ - const char *value; - - /* Alternate representation URI */ - const char *altrep; -} CalComponentText; - -typedef enum { - CAL_COMPONENT_TRANSP_NONE, - CAL_COMPONENT_TRANSP_TRANSPARENT, - CAL_COMPONENT_TRANSP_OPAQUE, - CAL_COMPONENT_TRANSP_UNKNOWN -} CalComponentTransparency; - -typedef struct _CalComponentAlarm CalComponentAlarm; - -typedef struct _CalComponent CalComponent; -typedef struct _CalComponentClass CalComponentClass; - -typedef struct _CalComponentPrivate CalComponentPrivate; - -struct _CalComponent { - GtkObject object; - - /* Private data */ - CalComponentPrivate *priv; -}; - -struct _CalComponentClass { - GtkObjectClass parent_class; -}; - -/* Calendar component */ - -GtkType cal_component_get_type (void); - -char *cal_component_gen_uid (void); - -CalComponent *cal_component_new (void); - -CalComponent *cal_component_clone (CalComponent *comp); - -void cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type); - -gboolean cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp); -icalcomponent *cal_component_get_icalcomponent (CalComponent *comp); - -CalComponentVType cal_component_get_vtype (CalComponent *comp); - -char *cal_component_get_as_string (CalComponent *comp); - -void cal_component_commit_sequence (CalComponent *comp); - -void cal_component_get_uid (CalComponent *comp, const char **uid); -void cal_component_set_uid (CalComponent *comp, const char *uid); - -void cal_component_get_categories_list (CalComponent *comp, GSList **categ_list); -void cal_component_set_categories_list (CalComponent *comp, GSList *categ_list); - -void cal_component_get_classification (CalComponent *comp, CalComponentClassification *classif); -void cal_component_set_classification (CalComponent *comp, CalComponentClassification classif); - -void cal_component_get_comment_list (CalComponent *comp, GSList **text_list); -void cal_component_set_comment_list (CalComponent *comp, GSList *text_list); - -void cal_component_get_completed (CalComponent *comp, struct icaltimetype **t); -void cal_component_set_completed (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_created (CalComponent *comp, struct icaltimetype **t); -void cal_component_set_created (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_description_list (CalComponent *comp, GSList **text_list); -void cal_component_set_description_list (CalComponent *comp, GSList *text_list); - -void cal_component_get_dtend (CalComponent *comp, CalComponentDateTime *dt); -void cal_component_set_dtend (CalComponent *comp, CalComponentDateTime *dt); - -void cal_component_get_dtstamp (CalComponent *comp, struct icaltimetype *t); -void cal_component_set_dtstamp (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_dtstart (CalComponent *comp, CalComponentDateTime *dt); -void cal_component_set_dtstart (CalComponent *comp, CalComponentDateTime *dt); - -void cal_component_get_due (CalComponent *comp, CalComponentDateTime *dt); -void cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt); - -void cal_component_get_exdate_list (CalComponent *comp, GSList **exdate_list); -void cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list); - -void cal_component_get_exrule_list (CalComponent *comp, GSList **recur_list); -void cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list); - -void cal_component_get_geo (CalComponent *comp, struct icalgeotype **geo); -void cal_component_set_geo (CalComponent *comp, struct icalgeotype *geo); - -void cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t); -void cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_percent (CalComponent *comp, int **percent); -void cal_component_set_percent (CalComponent *comp, int *percent); - -void cal_component_get_priority (CalComponent *comp, int **priority); -void cal_component_set_priority (CalComponent *comp, int *priority); - -void cal_component_get_rdate_list (CalComponent *comp, GSList **period_list); -void cal_component_set_rdate_list (CalComponent *comp, GSList *period_list); -gboolean cal_component_has_rdates (CalComponent *comp); - -void cal_component_get_rrule_list (CalComponent *comp, GSList **recur_list); -void cal_component_set_rrule_list (CalComponent *comp, GSList *recur_list); -gboolean cal_component_has_rrules (CalComponent *comp); - -void cal_component_get_sequence (CalComponent *comp, int **sequence); -void cal_component_set_sequence (CalComponent *comp, int *sequence); - -void cal_component_get_summary (CalComponent *comp, CalComponentText *summary); -void cal_component_set_summary (CalComponent *comp, CalComponentText *summary); - -void cal_component_get_transparency (CalComponent *comp, CalComponentTransparency *transp); -void cal_component_set_transparency (CalComponent *comp, CalComponentTransparency transp); - -void cal_component_get_url (CalComponent *comp, const char **url); -void cal_component_set_url (CalComponent *comp, const char *url); - -void cal_component_get_pilot_id (CalComponent *comp, unsigned long *pilot_id); -void cal_component_set_pilot_id (CalComponent *comp, unsigned long pilot_id); - -void cal_component_get_pilot_status (CalComponent *comp, unsigned long *pilot_status); -void cal_component_set_pilot_status (CalComponent *comp, unsigned long pilot_status); - -/* Functions to free returned values */ - -void cal_component_free_categories_list (GSList *categ_list); -void cal_component_free_datetime (CalComponentDateTime *dt); -void cal_component_free_exdate_list (GSList *exdate_list); -void cal_component_free_geo (struct icalgeotype *geo); -void cal_component_free_icaltimetype (struct icaltimetype *t); -void cal_component_free_percent (int *percent); -void cal_component_free_priority (int *priority); -void cal_component_free_period_list (GSList *period_list); -void cal_component_free_recur_list (GSList *recur_list); -void cal_component_free_sequence (int *sequence); -void cal_component_free_text_list (GSList *text_list); - -/* Alarms */ - -typedef enum { - CAL_COMPONENT_ALARM_NONE, - CAL_COMPONENT_ALARM_AUDIO, - CAL_COMPONENT_ALARM_DISPLAY, - CAL_COMPONENT_ALARM_EMAIL, - CAL_COMPONENT_ALARM_PROCEDURE, - CAL_COMPONENT_ALARM_UNKNOWN -} CalComponentAlarmAction; - -typedef enum { - CAL_COMPONENT_ALARM_TRIGGER_RELATIVE, - CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE -} CalComponentAlarmTriggerType; - -typedef enum { - CAL_COMPONENT_ALARM_TRIGGER_RELATED_START, - CAL_COMPONENT_ALARM_TRIGGER_RELATED_END -} CalComponentAlarmTriggerRelated; - -typedef struct { - CalComponentAlarmTriggerType type; - - union { - struct { - struct icaldurationtype duration; - CalComponentAlarmTriggerRelated related; - } relative; - - struct icaltimetype absolute; - } u; -} CalComponentAlarmTrigger; - -CalComponentAlarm *cal_component_get_first_alarm (CalComponent *comp); -CalComponentAlarm *cal_component_get_next_alarm (CalComponent *comp); - -void cal_component_alarm_free (CalComponentAlarm *alarm); - -void cal_component_alarm_get_action (CalComponentAlarm *alarm, CalComponentAlarmAction *action); -void cal_component_alarm_set_action (CalComponentAlarm *alarm, CalComponentAlarmAction action); - -void cal_component_alarm_get_trigger (CalComponentAlarm *alarm, CalComponentAlarmTrigger **trigger); -void cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalComponentAlarmTrigger *trigger); -void cal_component_alarm_free_trigger (CalComponentAlarmTrigger *trigger); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c deleted file mode 100644 index 164ffdbfc6..0000000000 --- a/calendar/cal-util/cal-recur.c +++ /dev/null @@ -1,3054 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Evolution calendar recurrence rule functions - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Damon Chaplin <damon@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <stdlib.h> -#include <string.h> -#include <cal-util/cal-recur.h> -#include <cal-util/timeutil.h> - - -/* - * Introduction to The Recurrence Generation Functions: - * - * Note: This is pretty complicated. See the iCalendar spec (RFC 2445) for - * the specification of the recurrence rules and lots of examples - * (sections 4.3.10 & 4.8.5). We also want to support the older - * vCalendar spec, though this should be easy since it is basically a - * subset of iCalendar. - * - * o An iCalendar event can have any number of recurrence rules specifying - * occurrences of the event, as well as dates & times of specific - * occurrences. It can also have any number of recurrence rules and - * specific dates & times specifying exceptions to the occurrences. - * So we first merge all the occurrences generated, eliminating any - * duplicates, then we generate all the exceptions and remove these to - * form the final set of occurrences. - * - * o There are 7 frequencies of occurrences: YEARLY, MONTHLY, WEEKLY, DAILY, - * HOURLY, MINUTELY & SECONDLY. The 'interval' property specifies the - * multiples of the frequency which we step by. We generate a 'set' of - * occurrences for each period defined by the frequency & interval. - * So for a YEARLY frequency with an interval of 3, we generate a set of - * occurrences for every 3rd year. We use complete years here - any - * generated occurrences that occur before the event's start (or after its - * end) are just discarded. - * - * o There are 8 frequency modifiers: BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, - * BYDAY, BYHOUR, BYMINUTE & BYSECOND. These can either add extra occurrences - * or filter out occurrences. For example 'FREQ=YEARLY;BYMONTH=1,2' produces - * 2 occurrences for each year rather than the default 1. And - * 'FREQ=DAILY;BYMONTH=1' filters out all occurrences except those in Jan. - * If the modifier works on periods which are less than the recurrence - * frequency, then extra occurrences are added, otherwise occurrences are - * filtered. So we have 2 functions for each modifier - one to expand events - * and the other to filter. We use a table of functions for each frequency - * which points to the appropriate function to use for each modifier. - * - * o Any number of frequency modifiers can be used in a recurrence rule. - * (Though the iCalendar spec says that BYWEEKNO can only be used in a YEARLY - * rule, and some modifiers aren't appropriate for some frequencies - e.g. - * BYMONTHDAY is not really useful in a WEEKLY frequency, and BYYEARDAY is - * not useful in a MONTHLY or WEEKLY frequency). - * The frequency modifiers are applied in the order given above. The first 5 - * modifier rules (BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY & BYDAY) all - * produce the days on which the occurrences take place, and so we have to - * compute some of these in parallel rather than sequentially, or we may end - * up with too many days. - * - * o Note that some expansion functions may produce days which are invalid, - * e.g. 31st September, 30th Feb. These invalid days are removed before the - * BYHOUR, BYMINUTE & BYSECOND modifier functions are applied. - * - * o After the set of occurrences for the frequency interval are generated, - * the BYSETPOS property is used to select which of the occurrences are - * finally output. If BYSETPOS is not specified then all the occurrences are - * output. - */ - - -/* This is what we use to pass to all the filter functions. */ -typedef struct _RecurData RecurData; -struct _RecurData { - CalRecurrence *recur; - - /* This is used for the WEEKLY frequency. */ - gint weekday; - - /* This is used for fast lookup in BYMONTH filtering. */ - guint8 months[12]; - - /* This is used for fast lookup in BYYEARDAY filtering. */ - guint8 yeardays[367], neg_yeardays[367]; /* Days are 1 - 366. */ - - /* This is used for fast lookup in BYMONTHDAY filtering. */ - guint8 monthdays[32], neg_monthdays[32]; /* Days are 1 to 31. */ - - /* This is used for fast lookup in BYDAY filtering. */ - guint8 weekdays[7]; - - /* This is used for fast lookup in BYHOUR filtering. */ - guint8 hours[24]; - - /* This is used for fast lookup in BYMINUTE filtering. */ - guint8 minutes[60]; - - /* This is used for fast lookup in BYSECOND filtering. */ - guint8 seconds[61]; -}; - - - -typedef gboolean (*CalObjFindStartFn) (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -typedef gboolean (*CalObjFindNextFn) (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); -typedef GArray* (*CalObjFilterFn) (RecurData *recur_data, - GArray *occs); - -typedef struct _CalRecurVTable CalRecurVTable; -struct _CalRecurVTable { - CalObjFindStartFn find_start_position; - CalObjFindNextFn find_next_position; - - CalObjFilterFn bymonth_filter; - CalObjFilterFn byweekno_filter; - CalObjFilterFn byyearday_filter; - CalObjFilterFn bymonthday_filter; - CalObjFilterFn byday_filter; - CalObjFilterFn byhour_filter; - CalObjFilterFn byminute_filter; - CalObjFilterFn bysecond_filter; -}; - - -/* This is used to specify which parts of the CalObjTime to compare in - cal_obj_time_compare(). */ -typedef enum { - CALOBJ_YEAR, - CALOBJ_MONTH, - CALOBJ_DAY, - CALOBJ_HOUR, - CALOBJ_MINUTE, - CALOBJ_SECOND -} CalObjTimeComparison; - -static void cal_object_compute_duration (CalObjTime *start, - CalObjTime *end, - gint *days, - gint *seconds); - -static gboolean generate_instances_for_year (CalComponent *comp, - time_t comp_dtstart, - GSList *rrules, - GSList *rdates, - GSList *exrules, - GSList *exdates, - CalObjTime *event_start, - CalObjTime *interval_start, - CalObjTime *interval_end, - time_t interval_start_time, - time_t interval_end_time, - gint duration_days, - gint duration_seconds, - CalRecurInstanceFn cb, - gpointer cb_data); - -static GArray* cal_obj_expand_recurrence (CalObjTime *event_start, - CalRecurrence *recur, - CalObjTime *interval_start, - CalObjTime *interval_end); - -static GArray* cal_obj_generate_set_yearly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ); -static GArray* cal_obj_generate_set_monthly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ); -static GArray* cal_obj_generate_set_default (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ); - - -static CalRecurVTable* cal_obj_get_vtable (CalRecurType recur_type); -static void cal_obj_initialize_recur_data (RecurData *recur_data, - CalRecurrence *recur, - CalObjTime *event_start); -static void cal_obj_sort_occurrences (GArray *occs); -static gint cal_obj_time_compare_func (const void *arg1, - const void *arg2); -static void cal_obj_remove_duplicates_and_invalid_dates (GArray *occs); -static void cal_obj_remove_exceptions (GArray *occs, - GArray *ex_occs); -static GArray* cal_obj_bysetpos_filter (CalRecurrence *recur, - GArray *occs); - - -static gboolean cal_obj_yearly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_yearly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_monthly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_monthly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_weekly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_weekly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_daily_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_daily_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_hourly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_hourly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_minutely_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_minutely_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_secondly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_secondly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static GArray* cal_obj_bymonth_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bymonth_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byweekno_expand (RecurData *recur_data, - GArray *occs); -#if 0 -/* This isn't used at present. */ -static GArray* cal_obj_byweekno_filter (RecurData *recur_data, - GArray *occs); -#endif -static GArray* cal_obj_byyearday_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byyearday_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bymonthday_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bymonthday_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_expand_yearly (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_expand_monthly (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_expand_weekly (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byhour_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byhour_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byminute_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byminute_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bysecond_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bysecond_filter (RecurData *recur_data, - GArray *occs); - -static void cal_obj_time_add_months (CalObjTime *cotime, - gint months); -static void cal_obj_time_add_days (CalObjTime *cotime, - gint days); -static void cal_obj_time_subtract_days (CalObjTime *cotime, - gint days); -static void cal_obj_time_add_hours (CalObjTime *cotime, - gint hours); -static void cal_obj_time_add_minutes (CalObjTime *cotime, - gint minutes); -static void cal_obj_time_add_seconds (CalObjTime *cotime, - gint seconds); -static gint cal_obj_time_compare (CalObjTime *cotime1, - CalObjTime *cotime2, - CalObjTimeComparison type); -static gint cal_obj_time_weekday (CalObjTime *cotime, - CalRecurrence *recur); -static gint cal_obj_time_day_of_year (CalObjTime *cotime); -static void cal_obj_time_find_first_week (CalObjTime *cotime, - RecurData *recur_data); -static void cal_object_time_from_time (CalObjTime *cotime, - time_t t); - - -CalRecurVTable cal_obj_yearly_vtable = { - cal_obj_yearly_find_start_position, - cal_obj_yearly_find_next_position, - - cal_obj_bymonth_expand, - cal_obj_byweekno_expand, - cal_obj_byyearday_expand, - cal_obj_bymonthday_expand, - cal_obj_byday_expand_yearly, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_monthly_vtable = { - cal_obj_monthly_find_start_position, - cal_obj_monthly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - NULL, /* BYYEARDAY is not useful in a MONTHLY frequency. */ - cal_obj_bymonthday_expand, - cal_obj_byday_expand_monthly, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_weekly_vtable = { - cal_obj_weekly_find_start_position, - cal_obj_weekly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - NULL, /* BYYEARDAY is not useful in a WEEKLY frequency. */ - NULL, /* BYMONTHDAY is not useful in a WEEKLY frequency. */ - cal_obj_byday_expand_weekly, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_daily_vtable = { - cal_obj_daily_find_start_position, - cal_obj_daily_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_hourly_vtable = { - cal_obj_hourly_find_start_position, - cal_obj_hourly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_filter, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_minutely_vtable = { - cal_obj_minutely_find_start_position, - cal_obj_minutely_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_filter, - cal_obj_byminute_filter, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_secondly_vtable = { - cal_obj_secondly_find_start_position, - cal_obj_secondly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_filter, - cal_obj_byminute_filter, - cal_obj_bysecond_filter -}; - -/* - * Calls the given callback function for each occurrence of the event between - * the given start and end times. If end is 0 it continues until the event - * ends or forever if the event has an infinite recurrence rule. - * If the callback routine return 0 the occurrence generation stops. - */ -void -cal_recur_generate_instances (CalComponent *comp, - time_t start, - time_t end, - CalRecurInstanceFn cb, - gpointer cb_data) -{ - CalComponentDateTime dtstart, dtend; - time_t dtstart_time; - GSList *rrules, *rdates, *exrules, *exdates; - CalObjTime interval_start, interval_end, event_start; - CalObjTime chunk_start, chunk_end; - gint days, seconds, year; - - g_return_if_fail (comp != NULL); - g_return_if_fail (cb != NULL); - - /* Get dtstart, dtend, recurrences, and exceptions */ - - cal_component_get_dtstart (comp, &dtstart); - cal_component_get_dtend (comp, &dtend); - - if (!dtstart.value) { - g_message ("cal_recur_generate_instances(): bogus component, does not have " - "DTSTART. Skipping..."); - goto out; - } - - dtstart_time = time_from_icaltimetype (*dtstart.value); - - cal_component_get_rrule_list (comp, &rrules); - cal_component_get_rdate_list (comp, &rdates); - cal_component_get_exrule_list (comp, &exrules); - cal_component_get_exdate_list (comp, &exdates); - - /* If there is no recurrence, just call the callback if the event - intersects the given interval. */ - - if (!(rrules || rdates || exrules || exdates)) { - time_t dtend_time; - - if (dtend.value) - dtend_time = time_from_icaltimetype (*dtend.value); - else - dtend_time = time_day_end (dtstart_time); - - if ((end && dtstart_time < end && dtend_time > start) - || (end == 0 && dtend_time > start)) { - (* cb) (comp, dtstart_time, dtend_time, cb_data); - } - - goto out; - } - - /* Convert the interval start & end to CalObjTime. */ - cal_object_time_from_time (&interval_start, start); - cal_object_time_from_time (&interval_end, end); - - cal_object_time_from_time (&event_start, dtstart_time); - - /* Calculate the duration of the event, which we use for all - occurrences. We can't just subtract start from end since that may - be affected by daylight-saving time. We also don't want to just - use the number of seconds, since leap seconds will then cause a - problem. So we want a value of days + seconds. */ - cal_object_compute_duration (&interval_start, &interval_end, - &days, &seconds); - - /* Expand the recurrence for each year between start & end, or until - the callback returns 0 if end is 0. */ - for (year = interval_start.year; year <= interval_end.year; year++) { - chunk_start = interval_start; - chunk_start.year = year; - chunk_end = interval_end; - chunk_end.year = year; - - if (year != interval_start.year) { - chunk_start.month = 0; - chunk_start.day = 0; - chunk_start.hour = 0; - chunk_start.minute = 0; - chunk_start.second = 0; - } - if (year != interval_end.year) { - chunk_end.year++; - chunk_end.month = 0; - chunk_end.day = 0; - chunk_end.hour = 0; - chunk_end.minute = 0; - chunk_end.second = 0; - } - - if (!generate_instances_for_year (comp, dtstart_time, - rrules, rdates, - exrules, exdates, - &event_start, - &interval_start, - &interval_end, - start, end, - days, seconds, - cb, cb_data)) - break; - } - - out: - cal_component_free_datetime (&dtstart); - cal_component_free_datetime (&dtend); -} - -/* Builds a list of GINT_TO_POINTER() elements out of a short array from a - * struct icalrecurrencetype. - */ -static GList * -array_to_list (short *array, int max_elements) -{ - GList *l; - int i; - - l = NULL; - - for (i = 0; i < max_elements && array[i] != SHRT_MAX; i++) - l = g_list_prepend (l, GINT_TO_POINTER ((int) (array[i]))); - - return g_list_reverse (l); -} - -/** - * cal_recur_from_icalrecurrencetype: - * @ir: A struct #icalrecurrencetype. - * - * Converts a struct #icalrecurrencetype to a #CalRecurrence. This should be - * freed using the cal_recur_free() function. - * - * Return value: #CalRecurrence structure. - **/ -CalRecurrence * -cal_recur_from_icalrecurrencetype (struct icalrecurrencetype *ir) -{ - CalRecurrence *r; - - g_return_val_if_fail (ir != NULL, NULL); - - r = g_new (CalRecurrence, 1); - - switch (ir->freq) { - case ICAL_SECONDLY_RECURRENCE: - r->type = CAL_RECUR_SECONDLY; - break; - - case ICAL_MINUTELY_RECURRENCE: - r->type = CAL_RECUR_MINUTELY; - break; - - case ICAL_HOURLY_RECURRENCE: - r->type = CAL_RECUR_HOURLY; - break; - - case ICAL_DAILY_RECURRENCE: - r->type = CAL_RECUR_DAILY; - break; - - case ICAL_WEEKLY_RECURRENCE: - r->type = CAL_RECUR_WEEKLY; - break; - - case ICAL_MONTHLY_RECURRENCE: - r->type = CAL_RECUR_MONTHLY; - break; - - case ICAL_YEARLY_RECURRENCE: - r->type = CAL_RECUR_YEARLY; - break; - - default: - g_message ("cal_recur_from_icalrecurrencetype(): Unknown recurrence frequency %d", - (int) ir->freq); - g_free (r); - return NULL; - } - - r->interval = ir->interval; - - /* FIXME: we don't deal with ir->count. Also, how does libical - * distinguish between n-occurrences and until-some-date rules? - */ - r->enddate = time_from_icaltimetype (ir->until); - - switch (ir->week_start) { - case ICAL_MONDAY_WEEKDAY: - r->week_start_day = 0; - break; - - case ICAL_TUESDAY_WEEKDAY: - r->week_start_day = 1; - break; - - case ICAL_WEDNESDAY_WEEKDAY: - r->week_start_day = 2; - break; - - case ICAL_THURSDAY_WEEKDAY: - r->week_start_day = 3; - break; - - case ICAL_FRIDAY_WEEKDAY: - r->week_start_day = 4; - break; - - case ICAL_SATURDAY_WEEKDAY: - r->week_start_day = 5; - break; - - case ICAL_SUNDAY_WEEKDAY: - r->week_start_day = 6; - break; - - default: - g_message ("cal_recur_from_icalrecurrencetype(): Unknown week day %d", - ir->week_start); - g_free (r); - return NULL; - } - - r->bymonth = array_to_list (ir->by_month, - sizeof (ir->by_month) / sizeof (ir->by_month[0])); - - r->byweekno = array_to_list (ir->by_week_no, - sizeof (ir->by_week_no) / sizeof (ir->by_week_no[0])); - - r->byyearday = array_to_list (ir->by_year_day, - sizeof (ir->by_year_day) / sizeof (ir->by_year_day[0])); - - r->bymonthday = array_to_list (ir->by_month_day, - sizeof (ir->by_month_day) / sizeof (ir->by_month_day[0])); - - r->byday = NULL; /* FIXME: libical sucks in this respect */ - - r->byhour = array_to_list (ir->by_hour, - sizeof (ir->by_hour) / sizeof (ir->by_hour[0])); - - r->byminute = array_to_list (ir->by_minute, - sizeof (ir->by_minute) / sizeof (ir->by_minute[0])); - - r->bysecond = array_to_list (ir->by_second, - sizeof (ir->by_second) / sizeof (ir->by_second[0])); - - r->bysetpos = array_to_list (ir->by_set_pos, - sizeof (ir->by_set_pos) / sizeof (ir->by_set_pos[0])); - - return r; -} - -/** - * cal_recur_free: - * @r: A #CalRecurrence structure. - * - * Frees a #CalRecurrence structure. - **/ -void -cal_recur_free (CalRecurrence *r) -{ - g_return_if_fail (r != NULL); - - g_list_free (r->bymonth); - g_list_free (r->byweekno); - g_list_free (r->byyearday); - g_list_free (r->bymonthday); - g_list_free (r->byday); - g_list_free (r->byhour); - g_list_free (r->byminute); - g_list_free (r->bysecond); - g_list_free (r->bysetpos); - - g_free (r); -} - -/* Generates one year's worth of recurrence instances. Returns TRUE if all the - * callback invocations returned TRUE, or FALSE when any one of them returns - * FALSE, i.e. meaning that the instance generation should be stopped. - */ -static gboolean -generate_instances_for_year (CalComponent *comp, - time_t comp_dtstart, - GSList *rrules, - GSList *rdates, - GSList *exrules, - GSList *exdates, - CalObjTime *event_start, - CalObjTime *interval_start, - CalObjTime *interval_end, - time_t interval_start_time, - time_t interval_end_time, - gint duration_days, - gint duration_seconds, - CalRecurInstanceFn cb, - gpointer cb_data) -{ - GArray *occs, *ex_occs, *tmp_occs; - CalObjTime cotime, *occ; - GSList *elem; - gint i, status; - time_t start_time, end_time; - struct tm start_tm, end_tm; - - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - ex_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - /* Expand each of the recurrence rules. */ - for (elem = rrules; elem; elem = elem->next) { - struct icalrecurrencetype *ir; - CalRecurrence *r; - - ir = elem->data; - r = cal_recur_from_icalrecurrencetype (ir); - - tmp_occs = cal_obj_expand_recurrence (event_start, r, - interval_start, - interval_end); - cal_recur_free (r); - - g_array_append_vals (occs, tmp_occs->data, tmp_occs->len); - g_array_free (tmp_occs, TRUE); - } - - /* Add on specific occurrence dates. */ - for (elem = rdates; elem; elem = elem->next) { - CalComponentPeriod *period; - time_t t; - - /* FIXME: this only deals with the start time */ - - period = elem->data; - t = time_from_icaltimetype (period->start); - - cal_object_time_from_time (&cotime, t); - g_array_append_val (occs, cotime); - } - - /* Expand each of the exception rules. */ - for (elem = exrules; elem; elem = elem->next) { - struct icalrecurrencetype *ir; - CalRecurrence *r; - - ir = elem->data; - r = cal_recur_from_icalrecurrencetype (ir); - - tmp_occs = cal_obj_expand_recurrence (event_start, r, - interval_start, - interval_end); - cal_recur_free (r); - - g_array_append_vals (ex_occs, tmp_occs->data, tmp_occs->len); - g_array_free (tmp_occs, TRUE); - } - - /* Add on specific exception dates. */ - for (elem = exdates; elem; elem = elem->next) { - CalComponentPeriod *period; - time_t t; - - /* FIXME: this only deals with the start time */ - - period = elem->data; - t = time_from_icaltimetype (period->start); - - cal_object_time_from_time (&cotime, t); - g_array_append_val (ex_occs, cotime); - } - - - /* Sort both arrays. */ - cal_obj_sort_occurrences (occs); - cal_obj_sort_occurrences (ex_occs); - - /* Create the final array, by removing the exceptions from the - occurrences, and removing any duplicates. */ - cal_obj_remove_exceptions (occs, ex_occs); - - - /* Call the callback for each occurrence. If it returns 0 we break - out of the loop. */ - for (i = 0; i < occs->len; i++) { - /* Convert each CalObjTime into a start & end time_t, and - check it is within the bounds of the event & interval. */ - occ = &g_array_index (occs, CalObjTime, i); - - start_tm.tm_year = occ->year - 1900; - start_tm.tm_mon = occ->month; - start_tm.tm_mday = occ->day; - start_tm.tm_hour = occ->hour; - start_tm.tm_min = occ->minute; - start_tm.tm_sec = occ->second; - start_time = mktime (&start_tm); - - if (start_time < comp_dtstart - || start_time >= interval_end_time) - continue; - - cal_obj_time_add_days (occ, duration_days); - cal_obj_time_add_seconds (occ, duration_seconds); - - end_tm.tm_year = occ->year - 1900; - end_tm.tm_mon = occ->month; - end_tm.tm_mday = occ->day; - end_tm.tm_hour = occ->hour; - end_tm.tm_min = occ->minute; - end_tm.tm_sec = occ->second; - end_time = mktime (&end_tm); - - if (end_time < interval_start_time) - continue; - - status = (*cb) (comp, start_time, end_time, cb_data); - if (!status) - return FALSE; - } - - return TRUE; -} - - -static void -cal_object_compute_duration (CalObjTime *start, - CalObjTime *end, - gint *days, - gint *seconds) -{ - GDate start_date, end_date; - gint start_seconds, end_seconds; - - g_date_clear (&start_date, 1); - g_date_clear (&end_date, 1); - g_date_set_dmy (&start_date, start->day, start->month + 1, - start->year); - g_date_set_dmy (&end_date, end->day, end->month + 1, - end->year); - - *days = g_date_julian (&end_date) - g_date_julian (&start_date); - start_seconds = start->hour * 3600 + start->minute * 60 - + start->second; - end_seconds = end->hour * 3600 + end->minute * 60 + end->second; - - *seconds = end_seconds - start_seconds; - if (*seconds < 0) { - *days = *days - 1; - *seconds += 24 * 60 * 60; - } -} - - -/* Returns an unsorted GArray of CalObjTime's resulting from expanding the - given recurrence rule within the given interval. Note that it doesn't - clip the generated occurrences to the interval, i.e. if the interval - starts part way through the year this function still returns all the - occurrences for the year. Clipping is done later. */ -static GArray* -cal_obj_expand_recurrence (CalObjTime *event_start, - CalRecurrence *recur, - CalObjTime *interval_start, - CalObjTime *interval_end) -{ - CalRecurVTable *vtable; - CalObjTime *event_end = NULL, event_end_cotime; - RecurData recur_data; - CalObjTime occ, *cotime; - GArray *all_occs, *occs; - gint len; - - vtable = cal_obj_get_vtable (recur->type); - - /* This is the resulting array of CalObjTime elements. */ - all_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - /* Calculate some useful data such as some fast lookup tables. */ - cal_obj_initialize_recur_data (&recur_data, recur, event_start); - - /* Compute the event_end, if the recur's enddate is set. */ - if (recur->enddate) { - cal_object_time_from_time (&event_end_cotime, - recur->enddate); - event_end = &event_end_cotime; - } - - /* Get the first period based on the frequency and the interval that - intersects the interval between start and end. */ - if ((*vtable->find_start_position) (event_start, event_end, - &recur_data, - interval_start, interval_end, - &occ)) - return all_occs; - - /* Loop until the event ends or we go past the end of the required - interval. */ - for (;;) { - /* Generate the set of occurrences for this period. */ - switch (recur->type) { - case CAL_RECUR_YEARLY: - occs = cal_obj_generate_set_yearly (&recur_data, - vtable, &occ); - break; - case CAL_RECUR_MONTHLY: - occs = cal_obj_generate_set_monthly (&recur_data, - vtable, &occ); - break; - default: - occs = cal_obj_generate_set_default (&recur_data, - vtable, &occ); - break; - } - - /* Sort the occurrences and remove duplicates. */ - cal_obj_sort_occurrences (occs); - cal_obj_remove_duplicates_and_invalid_dates (occs); - - /* Apply the BYSETPOS property. */ - occs = cal_obj_bysetpos_filter (recur, occs); - - /* Remove any occs after event_end. */ - len = occs->len - 1; - if (event_end) { - while (len >= 0) { - cotime = &g_array_index (occs, CalObjTime, - len); - if (cal_obj_time_compare_func (cotime, - event_end) <= 0) - break; - len--; - } - } - - /* Add the occurrences onto the main array. */ - if (len >= 0) - g_array_append_vals (all_occs, occs->data, len + 1); - - g_array_free (occs, TRUE); - - /* Skip to the next period, or exit the loop if finished. */ - if ((*vtable->find_next_position) (&occ, event_end, - &recur_data, interval_end)) - break; - } - - return all_occs; -} - - -static GArray* -cal_obj_generate_set_yearly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ) -{ - CalRecurrence *recur = recur_data->recur; - GArray *occs_arrays[4], *occs, *occs2; - gint num_occs_arrays = 0, i; - - /* This is a bit complicated, since the iCalendar spec says that - several BYxxx modifiers can be used simultaneously. So we have to - be quite careful when determining the days of the occurrences. - The BYHOUR, BYMINUTE & BYSECOND modifiers are no problem at all. - - The modifiers we have to worry about are: BYMONTH, BYWEEKNO, - BYYEARDAY, BYMONTHDAY & BYDAY. We can't do these sequentially - since each filter will mess up the results of the previous one. - But they aren't all completely independant, e.g. BYMONTHDAY and - BYDAY are related to BYMONTH, and BYDAY is related to BYWEEKNO. - - BYDAY & BYMONTHDAY can also be applied independently, which makes - it worse. So we assume that if BYMONTH or BYWEEKNO is used, then - the BYDAY modifier applies to those, else it is applied - independantly. - - We expand the occurrences in parallel into the occs_arrays[] array, - and then merge them all into one GArray before expanding BYHOUR, - BYMINUTE & BYSECOND. */ - - if (recur->bymonth) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonth_filter) (recur_data, occs); - - /* If BYMONTHDAY & BYDAY are both set we need to expand them - in parallel and add the results. */ - if (recur->bymonthday && recur->byday) { - /* Copy the occs array. */ - occs2 = g_array_new (FALSE, FALSE, - sizeof (CalObjTime)); - g_array_append_vals (occs2, occs->data, occs->len); - - occs = (*vtable->bymonthday_filter) (recur_data, occs); - /* Note that we explicitly call the monthly version - of the BYDAY expansion filter. */ - occs2 = cal_obj_byday_expand_monthly (recur_data, - occs2); - - /* Add the 2 resulting arrays together. */ - g_array_append_vals (occs, occs2->data, occs2->len); - g_array_free (occs2, TRUE); - } else { - occs = (*vtable->bymonthday_filter) (recur_data, occs); - /* Note that we explicitly call the monthly version - of the BYDAY expansion filter. */ - occs = cal_obj_byday_expand_monthly (recur_data, occs); - } - - occs_arrays[num_occs_arrays++] = occs; - } - - if (recur->byweekno) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->byweekno_filter) (recur_data, occs); - /* Note that we explicitly call the weekly version of the - BYDAY expansion filter. */ - occs = cal_obj_byday_expand_weekly (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - if (recur->byyearday) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->byyearday_filter) (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - /* If BYMONTHDAY is set, and BYMONTH is not set, we need to - expand BYMONTHDAY independantly. */ - if (recur->bymonthday && !recur->bymonth) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonthday_filter) (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - /* If BYDAY is set, and BYMONTH and BYWEEKNO are not set, we need to - expand BYDAY independantly. */ - if (recur->byday && !recur->bymonth && !recur->byweekno) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->byday_filter) (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - /* Add all the arrays together. */ - occs = occs_arrays[0]; - for (i = 1; i < num_occs_arrays; i++) { - occs2 = occs_arrays[i]; - g_array_append_vals (occs, occs2->data, occs2->len); - g_array_free (occs2, TRUE); - } - - /* Now expand BYHOUR, BYMINUTE & BYSECOND. */ - occs = (*vtable->byhour_filter) (recur_data, occs); - occs = (*vtable->byminute_filter) (recur_data, occs); - occs = (*vtable->bysecond_filter) (recur_data, occs); - - return occs; -} - - -static GArray* -cal_obj_generate_set_monthly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ) -{ - GArray *occs, *occs2; - - /* We start with just the one time in each set. */ - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonth_filter) (recur_data, occs); - - /* We need to combine the output of BYMONTHDAY & BYDAY, by doing them - in parallel rather than sequentially. If we did them sequentially - then we would lose the occurrences generated by BYMONTHDAY, and - instead have repetitions of the occurrences from BYDAY. */ - if (recur_data->recur->bymonthday && recur_data->recur->byday) { - occs2 = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs2, occs->data, occs->len); - - occs = (*vtable->bymonthday_filter) (recur_data, occs); - occs2 = (*vtable->byday_filter) (recur_data, occs2); - - g_array_append_vals (occs, occs2->data, occs2->len); - g_array_free (occs2, TRUE); - } else { - occs = (*vtable->bymonthday_filter) (recur_data, occs); - occs = (*vtable->byday_filter) (recur_data, occs); - } - - occs = (*vtable->byhour_filter) (recur_data, occs); - occs = (*vtable->byminute_filter) (recur_data, occs); - occs = (*vtable->bysecond_filter) (recur_data, occs); - - return occs; -} - - -static GArray* -cal_obj_generate_set_default (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ) -{ - GArray *occs; -#if 0 - g_print ("Generating set for %i/%i/%i %02i:%02i:%02i\n", - occ->day, occ->month, occ->year, occ->hour, occ->minute, - occ->second); -#endif - /* We start with just the one time in the set. */ - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonth_filter) (recur_data, occs); - if (vtable->byweekno_filter) - occs = (*vtable->byweekno_filter) (recur_data, occs); - if (vtable->byyearday_filter) - occs = (*vtable->byyearday_filter) (recur_data, occs); - if (vtable->bymonthday_filter) - occs = (*vtable->bymonthday_filter) (recur_data, occs); - occs = (*vtable->byday_filter) (recur_data, occs); - - occs = (*vtable->byhour_filter) (recur_data, occs); - occs = (*vtable->byminute_filter) (recur_data, occs); - occs = (*vtable->bysecond_filter) (recur_data, occs); - - return occs; -} - - - -/* Returns the function table corresponding to the recurrence frequency. */ -static CalRecurVTable* -cal_obj_get_vtable (CalRecurType recur_type) -{ - switch (recur_type) { - case CAL_RECUR_YEARLY: - return &cal_obj_yearly_vtable; - case CAL_RECUR_MONTHLY: - return &cal_obj_monthly_vtable; - case CAL_RECUR_WEEKLY: - return &cal_obj_weekly_vtable; - case CAL_RECUR_DAILY: - return &cal_obj_daily_vtable; - case CAL_RECUR_HOURLY: - return &cal_obj_hourly_vtable; - case CAL_RECUR_MINUTELY: - return &cal_obj_minutely_vtable; - case CAL_RECUR_SECONDLY: - return &cal_obj_secondly_vtable; - } - return NULL; -} - - -/* This creates a number of fast lookup tables used when filtering with the - modifier properties BYMONTH, BYYEARDAY etc. */ -static void -cal_obj_initialize_recur_data (RecurData *recur_data, - CalRecurrence *recur, - CalObjTime *event_start) -{ - GList *elem; - gint month, yearday, monthday, weekday, week_num, hour, minute, second; - - /* Clear the entire RecurData. */ - memset (recur_data, 0, sizeof (RecurData)); - - recur_data->recur = recur; - - /* Set the weekday, used for the WEEKLY frequency and the BYWEEKNO - modifier. */ - recur_data->weekday = cal_obj_time_weekday (event_start, recur); - - /* Create an array of months from bymonths for fast lookup. */ - elem = recur->bymonth; - while (elem) { - month = GPOINTER_TO_INT (elem->data); - recur_data->months[month] = 1; - elem = elem->next; - } - - /* Create an array of yeardays from byyearday for fast lookup. - We create a second array to handle the negative values. The first - element there corresponds to the last day of the year. */ - elem = recur->byyearday; - while (elem) { - yearday = GPOINTER_TO_INT (elem->data); - if (yearday >= 0) - recur_data->yeardays[yearday] = 1; - else - recur_data->neg_yeardays[-yearday] = 1; - elem = elem->next; - } - - /* Create an array of monthdays from bymonthday for fast lookup. - We create a second array to handle the negative values. The first - element there corresponds to the last day of the month. */ - elem = recur->bymonthday; - while (elem) { - monthday = GPOINTER_TO_INT (elem->data); - if (monthday >= 0) - recur_data->monthdays[monthday] = 1; - else - recur_data->neg_monthdays[-monthday] = 1; - elem = elem->next; - } - - /* Create an array of weekdays from byday for fast lookup. */ - elem = recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - /* The week number is not used when filtering. */ - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - recur_data->weekdays[weekday] = 1; - } - - /* Create an array of hours from byhour for fast lookup. */ - elem = recur->byhour; - while (elem) { - hour = GPOINTER_TO_INT (elem->data); - recur_data->hours[hour] = 1; - elem = elem->next; - } - - /* Create an array of minutes from byminutes for fast lookup. */ - elem = recur->byminute; - while (elem) { - minute = GPOINTER_TO_INT (elem->data); - recur_data->minutes[minute] = 1; - elem = elem->next; - } - - /* Create an array of seconds from byseconds for fast lookup. */ - elem = recur->bysecond; - while (elem) { - second = GPOINTER_TO_INT (elem->data); - recur_data->seconds[second] = 1; - elem = elem->next; - } -} - - -static void -cal_obj_sort_occurrences (GArray *occs) -{ - qsort (occs->data, occs->len, sizeof (CalObjTime), - cal_obj_time_compare_func); -} - - -static void -cal_obj_remove_duplicates_and_invalid_dates (GArray *occs) -{ - static const int days_in_month[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - - CalObjTime *occ, *prev_occ = NULL; - gint len, i, j = 0, year, month, days; - gboolean keep_occ; - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - keep_occ = TRUE; - - if (prev_occ && cal_obj_time_compare_func (occ, - prev_occ) == 0) - keep_occ = FALSE; - - year = occ->year; - month = occ->month; - days = days_in_month[occ->month]; - /* If it is february and a leap year, add a day. */ - if (month == 1 && (year % 4 == 0 - && (year % 100 != 0 - || year % 400 == 0))) - days++; - if (occ->day > days) - keep_occ = FALSE; - - if (keep_occ) { - if (i != j) - g_array_index (occs, CalObjTime, j) - = g_array_index (occs, CalObjTime, i); - j++; - } - - prev_occ = occ; - } - - g_array_set_size (occs, j); -} - - -/* Removes the exceptions from the ex_occs array from the occurrences in the - occs array, and removes any duplicates. Both arrays are sorted. */ -static void -cal_obj_remove_exceptions (GArray *occs, - GArray *ex_occs) -{ - CalObjTime *occ, *prev_occ = NULL, *ex_occ; - gint i, j = 0, cmp, ex_index, occs_len, ex_occs_len; - gboolean keep_occ; - - if (occs->len == 0 || ex_occs->len == 0) - return; - - ex_index = 0; - occs_len = occs->len; - ex_occs_len = ex_occs->len; - - ex_occ = &g_array_index (ex_occs, CalObjTime, ex_index); - for (i = 0; i < occs_len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - keep_occ = TRUE; - - /* If the occurrence is a duplicate of the previous one, skip - it. */ - if (prev_occ - && cal_obj_time_compare_func (occ, prev_occ) == 0) { - keep_occ = FALSE; - } else if (ex_occ) { - /* Step through the exceptions until we come to one - that matches or follows this occurrence. */ - while (ex_occ) { - cmp = cal_obj_time_compare_func (ex_occ, occ); - if (cmp > 0) - break; - - /* Move to the next exception, or set ex_occ - to NULL when we reach the end of array. */ - ex_index++; - if (ex_index < ex_occs_len) - ex_occ = &g_array_index (ex_occs, - CalObjTime, - ex_index); - else - ex_occ = NULL; - - /* If the current exception matches this - occurrence we remove it. */ - if (cmp == 0) { - keep_occ = FALSE; - break; - } - } - } - - if (keep_occ) { - if (i != j) - g_array_index (occs, CalObjTime, j) - = g_array_index (occs, CalObjTime, i); - j++; - } - - prev_occ = occ; - } - - g_array_set_size (occs, j); -} - - - -static GArray* -cal_obj_bysetpos_filter (CalRecurrence *recur, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, pos; - - /* If BYSETPOS has not been specified, or the array is empty, just - return the array. */ - elem = recur->bysetpos; - if (!elem || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - /* Iterate over the indices given in bysetpos, adding the corresponding - element from occs to new_occs. */ - len = occs->len; - while (elem) { - pos = GPOINTER_TO_INT (elem->data); - - /* Negative values count back from the end of the array. */ - if (pos < 0) - pos += len; - - if (pos >= 0 && pos < len) { - occ = &g_array_index (occs, CalObjTime, pos); - g_array_append_vals (new_occs, occ, 1); - } - elem = elem->next; - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - - -/* Finds the first year from the event_start, counting in multiples of the - recurrence interval, that intersects the given interval. It returns TRUE - if there is no intersection. */ -static gboolean -cal_obj_yearly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - *cotime = *event_start; - - /* Move on to the next interval, if the event starts before the - given interval. */ - if (cotime->year < interval_start->year) { - gint years = interval_start->year - cotime->year - + recur_data->recur->interval - 1; - years -= years % recur_data->recur->interval; - /* NOTE: The day may now be invalid, e.g. 29th Feb. */ - cotime->year += years; - } - - if ((event_end && cotime->year > event_end->year) - || (interval_end && cotime->year > interval_end->year)) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_yearly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - /* NOTE: The day may now be invalid, e.g. 29th Feb. */ - cotime->year += recur_data->recur->interval; - - if ((event_end && cotime->year > event_end->year) - || (interval_end && cotime->year > interval_end->year)) - return TRUE; - - return FALSE; -} - - - -static gboolean -cal_obj_monthly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - *cotime = *event_start; - - /* Move on to the next interval, if the event starts before the - given interval. */ - if (cal_obj_time_compare (cotime, interval_start, CALOBJ_MONTH) < 0) { - gint months = (interval_start->year - cotime->year) * 12 - + interval_start->month - cotime->month - + recur_data->recur->interval - 1; - months -= months % recur_data->recur->interval; - /* NOTE: The day may now be invalid, e.g. 31st Sep. */ - cal_obj_time_add_months (cotime, months); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MONTH) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MONTH) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_monthly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - /* NOTE: The day may now be invalid, e.g. 31st Sep. */ - cal_obj_time_add_months (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MONTH) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MONTH) > 0) - return TRUE; - - return FALSE; -} - - - -static gboolean -cal_obj_weekly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian; - gint interval_start_weekday; - CalObjTime week_start; - - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_DAY) < 0) - return TRUE; - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - *cotime = *event_start; - - /* Convert the event start and interval start to GDates, so we can - easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, interval_start->year); - - /* Calculate the start of the weeks corresponding to the event start - and interval start. */ - event_start_julian = g_date_julian (&event_start_date); - event_start_julian -= recur_data->weekday; - - interval_start_julian = g_date_julian (&interval_start_date); - interval_start_weekday = cal_obj_time_weekday (interval_start, - recur_data->recur); - interval_start_julian -= interval_start_weekday; - - /* We want to find the first full week using the recurrence interval - that intersects the given interval dates. */ - if (event_start_julian < interval_start_julian) { - gint weeks = (interval_start_julian - event_start_julian) / 7; - weeks += recur_data->recur->interval - 1; - weeks -= weeks % recur_data->recur->interval; - cal_obj_time_add_days (cotime, weeks * 7); - } - - week_start = *cotime; - cal_obj_time_subtract_days (&week_start, recur_data->weekday); - - if (event_end && cal_obj_time_compare (&week_start, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (&week_start, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_weekly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - CalObjTime week_start; - - cal_obj_time_add_days (cotime, recur_data->recur->interval * 7); - - /* Return TRUE if the start of this week is after the event finishes - or is after the end of the required interval. */ - week_start = *cotime; - cal_obj_time_subtract_days (&week_start, recur_data->weekday); - - if (event_end && cal_obj_time_compare (&week_start, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (&week_start, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_daily_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, days; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_DAY) < 0) - return TRUE; - - *cotime = *event_start; - - /* Convert the event start and interval start to GDates, so we can - easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, interval_start->year); - - event_start_julian = g_date_julian (&event_start_date); - interval_start_julian = g_date_julian (&interval_start_date); - - if (event_start_julian < interval_start_julian) { - days = interval_start_julian - event_start_julian - + recur_data->recur->interval - 1; - days -= days % recur_data->recur->interval; - cal_obj_time_add_days (cotime, days); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_daily_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_days (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_hourly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, hours; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_HOUR) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_HOUR) < 0) - return TRUE; - - *cotime = *event_start; - - if (cal_obj_time_compare (event_start, interval_start, - CALOBJ_HOUR) < 0) { - /* Convert the event start and interval start to GDates, so we - can easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, - interval_start->year); - - event_start_julian = g_date_julian (&event_start_date); - interval_start_julian = g_date_julian (&interval_start_date); - - hours = (interval_start_julian - event_start_julian) * 24; - hours += interval_start->hour - event_start->hour; - hours += recur_data->recur->interval - 1; - hours -= hours % recur_data->recur->interval; - cal_obj_time_add_hours (cotime, hours); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_HOUR) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_HOUR) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_hourly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_hours (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_HOUR) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_HOUR) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_minutely_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, minutes; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_MINUTE) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_MINUTE) < 0) - return TRUE; - - *cotime = *event_start; - - if (cal_obj_time_compare (event_start, interval_start, - CALOBJ_MINUTE) < 0) { - /* Convert the event start and interval start to GDates, so we - can easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, - interval_start->year); - - event_start_julian = g_date_julian (&event_start_date); - interval_start_julian = g_date_julian (&interval_start_date); - - minutes = (interval_start_julian - event_start_julian) - * 24 * 60; - minutes += (interval_start->hour - event_start->hour) * 24; - minutes += interval_start->minute - event_start->minute; - minutes += recur_data->recur->interval - 1; - minutes -= minutes % recur_data->recur->interval; - cal_obj_time_add_minutes (cotime, minutes); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MINUTE) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MINUTE) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_minutely_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_minutes (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MINUTE) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MINUTE) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_secondly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, seconds; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_SECOND) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_SECOND) < 0) - return TRUE; - - *cotime = *event_start; - - if (cal_obj_time_compare (event_start, interval_start, - CALOBJ_SECOND) < 0) { - /* Convert the event start and interval start to GDates, so we - can easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, - interval_start->year); - - event_start_julian = g_date_julian (&event_start_date); - interval_start_julian = g_date_julian (&interval_start_date); - - seconds = (interval_start_julian - event_start_julian) - * 24 * 60 * 60; - seconds += (interval_start->hour - event_start->hour) - * 24 * 60; - seconds += (interval_start->minute - event_start->minute) * 60; - seconds += interval_start->second - event_start->second; - seconds += recur_data->recur->interval - 1; - seconds -= seconds % recur_data->recur->interval; - cal_obj_time_add_seconds (cotime, seconds); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_SECOND) >= 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_SECOND) >= 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_secondly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_seconds (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_SECOND) >= 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_SECOND) >= 0) - return TRUE; - - return FALSE; -} - - - - - -/* If the BYMONTH rule is specified it expands each occurrence in occs, by - using each of the months in the bymonth list. */ -static GArray* -cal_obj_bymonth_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYMONTH has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonth || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->bymonth; - while (elem) { - /* NOTE: The day may now be invalid, e.g. 31st Feb. */ - occ->month = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYMONTH rule is specified it filters out all occurrences in occs - which do not match one of the months in the bymonth list. */ -static GArray* -cal_obj_bymonth_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYMONTH has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonth || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->months[occ->month]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -static GArray* -cal_obj_byweekno_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ, year_start_cotime, year_end_cotime, cotime; - GList *elem; - gint len, i, weekno; - - /* If BYWEEKNO has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byweekno || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - /* Find the day that would correspond to week 1 (note that - week 1 is the first week starting from the specified week - start day that has 4 days in the new year). */ - year_start_cotime = *occ; - cal_obj_time_find_first_week (&year_start_cotime, - recur_data); - - /* Find the day that would correspond to week 1 of the next - year, which we use for -ve week numbers. */ - year_end_cotime = *occ; - year_end_cotime.year++; - cal_obj_time_find_first_week (&year_end_cotime, - recur_data); - - /* Now iterate over the week numbers in byweekno, generating a - new occurrence for each one. */ - elem = recur_data->recur->byweekno; - while (elem) { - weekno = GPOINTER_TO_INT (elem->data); - if (weekno > 0) { - cotime = year_start_cotime; - cal_obj_time_add_days (&cotime, - (weekno - 1) * 7); - } else { - cotime = year_end_cotime; - cal_obj_time_subtract_days (&cotime, - -weekno * 7); - } - - /* Skip occurrences if they fall outside the year. */ - if (cotime.year == occ->year) - g_array_append_val (new_occs, cotime); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -#if 0 -/* This isn't used at present. */ -static GArray* -cal_obj_byweekno_filter (RecurData *recur_data, - GArray *occs) -{ - - return occs; -} -#endif - - -static GArray* -cal_obj_byyearday_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ, year_start_cotime, year_end_cotime, cotime; - GList *elem; - gint len, i, dayno; - - /* If BYYEARDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byyearday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - /* Find the day that would correspond to day 1. */ - year_start_cotime = *occ; - year_start_cotime.month = 0; - year_start_cotime.day = 1; - - /* Find the day that would correspond to day 1 of the next - year, which we use for -ve day numbers. */ - year_end_cotime = *occ; - year_end_cotime.year++; - year_end_cotime.month = 0; - year_end_cotime.day = 1; - - /* Now iterate over the day numbers in byyearday, generating a - new occurrence for each one. */ - elem = recur_data->recur->byyearday; - while (elem) { - dayno = GPOINTER_TO_INT (elem->data); - if (dayno > 0) { - cotime = year_start_cotime; - cal_obj_time_add_days (&cotime, dayno - 1); - } else { - cotime = year_end_cotime; - cal_obj_time_subtract_days (&cotime, -dayno); - } - - /* Skip occurrences if they fall outside the year. */ - if (cotime.year == occ->year) - g_array_append_val (new_occs, cotime); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* Note: occs must not contain invalid dates, e.g. 31st September. */ -static GArray* -cal_obj_byyearday_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint yearday, len, i, days_in_year; - - /* If BYYEARDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byyearday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - yearday = cal_obj_time_day_of_year (occ); - if (recur_data->yeardays[yearday]) { - g_array_append_vals (new_occs, occ, 1); - } else { - days_in_year = g_date_is_leap_year (occ->year) - ? 366 : 365; - if (recur_data->neg_yeardays[days_in_year + 1 - - yearday]) - g_array_append_vals (new_occs, occ, 1); - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -static GArray* -cal_obj_bymonthday_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ, month_start_cotime, month_end_cotime, cotime; - GList *elem; - gint len, i, dayno; - - /* If BYMONTHDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonthday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - /* Find the day that would correspond to day 1. */ - month_start_cotime = *occ; - month_start_cotime.day = 1; - - /* Find the day that would correspond to day 1 of the next - month, which we use for -ve day numbers. */ - month_end_cotime = *occ; - month_end_cotime.month++; - month_end_cotime.day = 1; - - /* Now iterate over the day numbers in bymonthday, generating a - new occurrence for each one. */ - elem = recur_data->recur->bymonthday; - while (elem) { - dayno = GPOINTER_TO_INT (elem->data); - if (dayno > 0) { - cotime = month_start_cotime; - cal_obj_time_add_days (&cotime, dayno - 1); - } else { - cotime = month_end_cotime; - cal_obj_time_subtract_days (&cotime, -dayno); - } - - /* Skip occurrences if they fall outside the month. */ - if (cotime.month == occ->month) - g_array_append_val (new_occs, cotime); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -static GArray* -cal_obj_bymonthday_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i, days_in_month; - - /* If BYMONTHDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonthday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->monthdays[occ->day]) { - g_array_append_vals (new_occs, occ, 1); - } else { - days_in_month = time_days_in_month (occ->year, - occ->month); - if (recur_data->neg_monthdays[days_in_month + 1 - - occ->day]) - g_array_append_vals (new_occs, occ, 1); - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -static GArray* -cal_obj_byday_expand_yearly (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i, weekday, week_num; - gint first_weekday, last_weekday, offset; - guint16 year; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - year = occ->year; - if (week_num == 0) { - occ->month = 0; - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ, recur_data->recur); - offset = (weekday + 7 - first_weekday) % 7; - cal_obj_time_add_days (occ, offset); - - while (occ->year == year) { - g_array_append_vals (new_occs, occ, 1); - cal_obj_time_add_days (occ, 7); - } - - } else if (week_num > 0) { - occ->month = 0; - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ, recur_data->recur); - offset = (weekday + 7 - first_weekday) % 7; - offset += (week_num - 1) * 7; - cal_obj_time_add_days (occ, offset); - if (occ->year == year) - g_array_append_vals (new_occs, occ, 1); - - } else { - occ->month = 11; - occ->day = 31; - last_weekday = cal_obj_time_weekday (occ, recur_data->recur); - offset = (last_weekday + 7 - weekday) % 7; - offset += (week_num - 1) * 7; - cal_obj_time_subtract_days (occ, offset); - if (occ->year == year) - g_array_append_vals (new_occs, occ, 1); - } - - /* Reset the year, as we may have gone past the end. */ - occ->year = year; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -static GArray* -cal_obj_byday_expand_monthly (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i, weekday, week_num; - gint first_weekday, last_weekday, offset; - guint16 year; - guint8 month; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - year = occ->year; - month = occ->month; - if (week_num == 0) { - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ, recur_data->recur); - offset = (weekday + 7 - first_weekday) % 7; - cal_obj_time_add_days (occ, offset); - - while (occ->year == year - && occ->month == month) { - g_array_append_vals (new_occs, occ, 1); - cal_obj_time_add_days (occ, 7); - } - - } else if (week_num > 0) { - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ, recur_data->recur); - offset = (weekday + 7 - first_weekday) % 7; - offset += (week_num - 1) * 7; - cal_obj_time_add_days (occ, offset); - if (occ->year == year && occ->month == month) - g_array_append_vals (new_occs, occ, 1); - - } else { - occ->day = time_days_in_month (occ->year, - occ->month); - last_weekday = cal_obj_time_weekday (occ, recur_data->recur); - offset = (last_weekday + 7 - weekday) % 7; - offset += (week_num - 1) * 7; - cal_obj_time_subtract_days (occ, offset); - if (occ->year == year && occ->month == month) - g_array_append_vals (new_occs, occ, 1); - } - - /* Reset the year & month, as we may have gone past - the end. */ - occ->year = year; - occ->month = month; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* Note: occs must not contain invalid dates, e.g. 31st September. */ -static GArray* -cal_obj_byday_expand_weekly (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i, weekday, week_num; - gint current_weekday; - gint day_of_week, new_day_of_week, days_to_add; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - current_weekday = cal_obj_time_weekday (occ, recur_data->recur); - day_of_week = (current_weekday + 7 - - recur_data->recur->week_start_day) % 7; - new_day_of_week = (weekday + 7 - - recur_data->recur->week_start_day) % 7; - days_to_add = new_day_of_week - day_of_week; - if (days_to_add > 0) - cal_obj_time_add_days (occ, days_to_add); - else if (days_to_add < 0) - cal_obj_time_subtract_days (occ, -days_to_add); - g_array_append_vals (new_occs, occ, 1); - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* Note: occs must not contain invalid dates, e.g. 31st September. */ -static GArray* -cal_obj_byday_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i, weekday; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - weekday = cal_obj_time_weekday (occ, recur_data->recur); - - /* See if the weekday on its own is set. */ - if (recur_data->weekdays[weekday]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -/* If the BYHOUR rule is specified it expands each occurrence in occs, by - using each of the hours in the byhour list. */ -static GArray* -cal_obj_byhour_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYHOUR has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byhour || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byhour; - while (elem) { - occ->hour = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYHOUR rule is specified it filters out all occurrences in occs - which do not match one of the hours in the byhour list. */ -static GArray* -cal_obj_byhour_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYHOUR has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byhour || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->hours[occ->hour]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -/* If the BYMINUTE rule is specified it expands each occurrence in occs, by - using each of the minutes in the byminute list. */ -static GArray* -cal_obj_byminute_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYMINUTE has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byminute || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byminute; - while (elem) { - occ->minute = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYMINUTE rule is specified it filters out all occurrences in occs - which do not match one of the minutes in the byminute list. */ -static GArray* -cal_obj_byminute_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYMINUTE has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byminute || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->minutes[occ->minute]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -/* If the BYSECOND rule is specified it expands each occurrence in occs, by - using each of the seconds in the bysecond list. */ -static GArray* -cal_obj_bysecond_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYSECOND has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bysecond || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->bysecond; - while (elem) { - occ->second = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYSECOND rule is specified it filters out all occurrences in occs - which do not match one of the seconds in the bysecond list. */ -static GArray* -cal_obj_bysecond_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYSECOND has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bysecond || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->seconds[occ->second]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - - - -/* Adds a positive number of months to the given CalObjTime, updating the year - appropriately so we end up with a valid month. Note that the day may be - invalid. */ -static void -cal_obj_time_add_months (CalObjTime *cotime, - gint months) -{ - guint month; - - /* We use a guint to avoid overflow on the guint8. */ - month = cotime->month + months; - cotime->year += month / 12; - cotime->month = month % 12; -} - - -/* Adds a positive number of days to the given CalObjTime, updating the month - and year appropriately so we end up with a valid day. */ -static void -cal_obj_time_add_days (CalObjTime *cotime, - gint days) -{ - guint day, days_in_month; - - /* We use a guint to avoid overflow on the guint8. */ - day = (guint) cotime->day; - day += days; - - for (;;) { - days_in_month = time_days_in_month (cotime->year, - cotime->month); - if (day <= days_in_month) - break; - - cotime->month++; - if (cotime->month >= 12) { - cotime->year++; - cotime->month = 0; - } - - day -= days_in_month; - } - - cotime->day = (guint8) day; -} - - -/* Subtracts a positive number of days from the given CalObjTime, updating the - month and year appropriately so we end up with a valid day. */ -static void -cal_obj_time_subtract_days (CalObjTime *cotime, - gint days) -{ - gint day, days_in_month; - - /* We use a gint to avoid overflow on the guint8. */ - day = (gint) cotime->day; - day -= days; - - while (day <= 0) { - if (cotime->month == 0) { - cotime->year--; - cotime->month = 11; - } else { - cotime->month--; - } - - days_in_month = time_days_in_month (cotime->year, - cotime->month); - - day += days_in_month; - } - - cotime->day = (guint8) day; -} - - -/* Adds a positive number of hours to the given CalObjTime, updating the day, - month & year appropriately so we end up with a valid time. */ -static void -cal_obj_time_add_hours (CalObjTime *cotime, - gint hours) -{ - guint hour; - - /* We use a guint to avoid overflow on the guint8. */ - hour = cotime->hour + hours; - cotime->hour = hour % 24; - if (hour >= 24) - cal_obj_time_add_days (cotime, hour / 24); -} - - -/* Adds a positive number of minutes to the given CalObjTime, updating the - rest of the CalObjTime appropriately. */ -static void -cal_obj_time_add_minutes (CalObjTime *cotime, - gint minutes) -{ - guint minute; - - /* We use a guint to avoid overflow on the guint8. */ - minute = cotime->minute + minutes; - cotime->minute = minute % 60; - if (minute >= 60) - cal_obj_time_add_hours (cotime, minute / 60); -} - - -/* Adds a positive number of seconds to the given CalObjTime, updating the - rest of the CalObjTime appropriately. */ -static void -cal_obj_time_add_seconds (CalObjTime *cotime, - gint seconds) -{ - guint second; - - /* We use a guint to avoid overflow on the guint8. */ - second = cotime->second + seconds; - cotime->second = second % 60; - if (second >= 60) - cal_obj_time_add_minutes (cotime, second / 60); -} - - -/* Compares 2 CalObjTimes. Returns -1 if the cotime1 is before cotime2, 0 if - they are the same, or 1 if cotime1 is after cotime2. The comparison type - specifies which parts of the times we are interested in, e.g. if CALOBJ_DAY - is used we only want to know if the days are different. */ -static gint -cal_obj_time_compare (CalObjTime *cotime1, - CalObjTime *cotime2, - CalObjTimeComparison type) -{ - if (cotime1->year < cotime2->year) - return -1; - if (cotime1->year > cotime2->year) - return 1; - - if (type == CALOBJ_YEAR) - return 0; - - if (cotime1->month < cotime2->month) - return -1; - if (cotime1->month > cotime2->month) - return 1; - - if (type == CALOBJ_MONTH) - return 0; - - if (cotime1->day < cotime2->day) - return -1; - if (cotime1->day > cotime2->day) - return 1; - - if (type == CALOBJ_DAY) - return 0; - - if (cotime1->hour < cotime2->hour) - return -1; - if (cotime1->hour > cotime2->hour) - return 1; - - if (type == CALOBJ_HOUR) - return 0; - - if (cotime1->minute < cotime2->minute) - return -1; - if (cotime1->minute > cotime2->minute) - return 1; - - if (type == CALOBJ_MINUTE) - return 0; - - if (cotime1->second < cotime2->second) - return -1; - if (cotime1->second > cotime2->second) - return 1; - - return 0; -} - - -/* This is the same as the above function, but without the comparison type. - It is used for qsort(). */ -static gint -cal_obj_time_compare_func (const void *arg1, - const void *arg2) -{ - CalObjTime *cotime1, *cotime2; - - cotime1 = (CalObjTime*) arg1; - cotime2 = (CalObjTime*) arg2; - - if (cotime1->year < cotime2->year) - return -1; - if (cotime1->year > cotime2->year) - return 1; - - if (cotime1->month < cotime2->month) - return -1; - if (cotime1->month > cotime2->month) - return 1; - - if (cotime1->day < cotime2->day) - return -1; - if (cotime1->day > cotime2->day) - return 1; - - if (cotime1->hour < cotime2->hour) - return -1; - if (cotime1->hour > cotime2->hour) - return 1; - - if (cotime1->minute < cotime2->minute) - return -1; - if (cotime1->minute > cotime2->minute) - return 1; - - if (cotime1->second < cotime2->second) - return -1; - if (cotime1->second > cotime2->second) - return 1; - - return 0; -} - - -/* Returns the weekday of the given CalObjTime, from 0 - 6. The week start - day is Monday by default, but can be set in the recurrence rule. */ -static gint -cal_obj_time_weekday (CalObjTime *cotime, - CalRecurrence *recur) -{ - GDate date; - gint weekday; - - g_date_clear (&date, 1); - g_date_set_dmy (&date, cotime->day, cotime->month + 1, cotime->year); - - /* This results in a value of 0 (Monday) - 6 (Sunday). */ - weekday = g_date_weekday (&date) - 1; - - /* This calculates the offset of our day from the start of the week. - We just add on a week (to avoid any possible negative values) and - then subtract the specified week start day, then convert it into a - value from 0-6. */ - weekday = (weekday + 7 - recur->week_start_day) % 7; - - return weekday; -} - - -/* Returns the day of the year of the given CalObjTime, from 1 - 366. */ -static gint -cal_obj_time_day_of_year (CalObjTime *cotime) -{ - GDate date; - - g_date_clear (&date, 1); - g_date_set_dmy (&date, cotime->day, cotime->month + 1, cotime->year); - - return g_date_day_of_year (&date); -} - - -/* Finds the first week in the given CalObjTime's year, using the same weekday - as the event start day (i.e. from the RecurData). - The first week of the year is the first week starting from the specified - week start day that has 4 days in the new year. It may be in the previous - year. */ -static void -cal_obj_time_find_first_week (CalObjTime *cotime, - RecurData *recur_data) -{ - GDate date; - gint weekday, week_start_day, offset; - - /* Find out the weekday of the 1st of the year. */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 1, 1, cotime->year); - - /* This results in a value of 0 (Monday) - 6 (Sunday). */ - weekday = g_date_weekday (&date) - 1; - - /* Calculate the first day of the year that starts a new week. */ - week_start_day = recur_data->recur->week_start_day; - offset = (week_start_day + 7 - weekday) % 7; - - /* Now see if we have to move backwards 1 week, i.e. if the week - starts on or after Jan 5th (since the previous week has 4 days in - this year and so will be the first week of the year). */ - if (offset >= 4) - offset -= 7; - - /* Now move to the required day. */ - offset += (recur_data->weekday + 7 - week_start_day) % 7; - - /* Now move the cotime to the appropriate day. */ - cotime->month = 0; - cotime->day = 1; - if (offset > 0) - cal_obj_time_add_days (cotime, offset); - else - cal_obj_time_subtract_days (cotime, offset); -} - - -static void -cal_object_time_from_time (CalObjTime *cotime, - time_t t) -{ - struct tm *tmp_tm; - time_t tmp_time_t; - - tmp_time_t = t; - tmp_tm = localtime (&tmp_time_t); - - cotime->year = tmp_tm->tm_year + 1900; - cotime->month = tmp_tm->tm_mon; - cotime->day = tmp_tm->tm_mday; - cotime->hour = tmp_tm->tm_hour; - cotime->minute = tmp_tm->tm_min; - cotime->second = tmp_tm->tm_sec; -} diff --git a/calendar/cal-util/cal-recur.h b/calendar/cal-util/cal-recur.h deleted file mode 100644 index 621985b71b..0000000000 --- a/calendar/cal-util/cal-recur.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Evolution calendar recurrence rule functions - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Damon Chaplin <damon@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_RECUR_H -#define CAL_RECUR_H - -#include <libgnome/gnome-defs.h> -#include <glib.h> -#include <cal-util/cal-component.h> - -BEGIN_GNOME_DECLS - -typedef enum { - CAL_RECUR_YEARLY, - CAL_RECUR_MONTHLY, - CAL_RECUR_WEEKLY, - CAL_RECUR_DAILY, - CAL_RECUR_HOURLY, - CAL_RECUR_MINUTELY, - CAL_RECUR_SECONDLY -} CalRecurType; - -typedef struct { - CalRecurType type; - - int interval; - - /* Specifies the end of the recurrence. No occurrences are generated - after this date. If it is 0, the event recurs forever. */ - time_t enddate; - - /* WKST property - the week start day: 0 = Monday to 6 = Sunday. */ - gint week_start_day; - - - /* NOTE: I've used GList's here, but it doesn't matter if we use - other data structures like arrays. The code should be easy to - change. So long as it is easy to see if the modifier is set. */ - - /* For BYMONTH modifier. A list of GINT_TO_POINTERs, 0-11. */ - GList *bymonth; - - /* For BYWEEKNO modifier. A list of GINT_TO_POINTERs, [+-]1-53. */ - GList *byweekno; - - /* For BYYEARDAY modifier. A list of GINT_TO_POINTERs, [+-]1-366. */ - GList *byyearday; - - /* For BYMONTHDAY modifier. A list of GINT_TO_POINTERs, [+-]1-31. */ - GList *bymonthday; - - /* For BYDAY modifier. A list of GINT_TO_POINTERs, in pairs. - The first of each pair is the weekday, 0 = Monday to 6 = Sunday. - The second of each pair is the week number [+-]0-53. */ - GList *byday; - - /* For BYHOUR modifier. A list of GINT_TO_POINTERs, 0-23. */ - GList *byhour; - - /* For BYMINUTE modifier. A list of GINT_TO_POINTERs, 0-59. */ - GList *byminute; - - /* For BYSECOND modifier. A list of GINT_TO_POINTERs, 0-60. */ - GList *bysecond; - - /* For BYSETPOS modifier. A list of GINT_TO_POINTERs, +ve or -ve. */ - GList *bysetpos; -} CalRecurrence; - -/* This is what we use to represent a date & time. */ -typedef struct _CalObjTime CalObjTime; -struct _CalObjTime { - guint16 year; - guint8 month; /* 0 - 11 */ - guint8 day; /* 1 - 31 */ - guint8 hour; /* 0 - 23 */ - guint8 minute; /* 0 - 59 */ - guint8 second; /* 0 - 59 (maybe 60 for leap second) */ -}; - -typedef gboolean (* CalRecurInstanceFn) (CalComponent *comp, - time_t instance_start, - time_t instace_end, - gpointer data); - -void cal_recur_generate_instances (CalComponent *comp, - time_t start, - time_t end, - CalRecurInstanceFn cb, - gpointer cb_data); - -CalRecurrence *cal_recur_from_icalrecurrencetype (struct icalrecurrencetype *ir); -void cal_recur_free (CalRecurrence *r); - -END_GNOME_DECLS - -#endif diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c deleted file mode 100644 index 40c4fe5bfe..0000000000 --- a/calendar/cal-util/cal-util.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Evolution calendar utilities and types - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <stdlib.h> -#include "cal-util.h" -#include "libversit/vcc.h" - - - -/** - * cal_obj_instance_list_free: - * @list: List of #CalObjInstance structures. - * - * Frees a list of #CalObjInstance structures. - **/ -void -cal_obj_instance_list_free (GList *list) -{ - CalObjInstance *i; - GList *l; - - for (l = list; l; l = l->next) { - i = l->data; - - g_assert (i != NULL); - g_assert (i->uid != NULL); - - g_free (i->uid); - g_free (i); - } - - g_list_free (list); -} - -/** - * cal_alarm_instance_list_free: - * @list: List of #CalAlarmInstance structures. - * - * Frees a list of #CalAlarmInstance structures. - **/ -void -cal_alarm_instance_list_free (GList *list) -{ - CalAlarmInstance *i; - GList *l; - - for (l = list; l; l = l->next) { - i = l->data; - - g_assert (i != NULL); - g_assert (i->uid != NULL); - - g_free (i->uid); - g_free (i); - } - - g_list_free (list); -} - -/** - * cal_obj_uid_list_free: - * @list: List of strings with unique identifiers. - * - * Frees a list of unique identifiers for calendar objects. - **/ -void -cal_obj_uid_list_free (GList *list) -{ - GList *l; - - for (l = list; l; l = l->next) { - char *uid; - - uid = l->data; - - g_assert (uid != NULL); - g_free (uid); - } - - g_list_free (list); -} diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h deleted file mode 100644 index 154f4c2ad5..0000000000 --- a/calendar/cal-util/cal-util.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Evolution calendar utilities and types - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_UTIL_H -#define CAL_UTIL_H - -#include <libgnome/gnome-defs.h> -#include <time.h> -#include <glib.h> - -BEGIN_GNOME_DECLS - - - -/* Instance of a calendar object. This can be an actual occurrence, a - * recurrence, or an alarm trigger of a `real' calendar object. - */ -typedef struct { - char *uid; /* UID of the object */ - time_t start; /* Start time of instance */ - time_t end; /* End time of instance */ -} CalObjInstance; - -void cal_obj_instance_list_free (GList *list); - -/* Instance of an alarm trigger */ -typedef struct { - char *uid; /* UID of object */ -#if 0 - enum AlarmType type; /* Type of alarm */ -#endif - time_t trigger; /* Alarm trigger time */ - time_t occur; /* Occurrence time */ -} CalAlarmInstance; - -void cal_alarm_instance_list_free (GList *list); - -/* Used for multiple UID queries */ -typedef enum { - CALOBJ_TYPE_EVENT = 1 << 0, - CALOBJ_TYPE_TODO = 1 << 1, - CALOBJ_TYPE_JOURNAL = 1 << 2, - CALOBJ_TYPE_ANY = 0x07 -} CalObjType; - -void cal_obj_uid_list_free (GList *list); - -END_GNOME_DECLS - -#endif diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c deleted file mode 100644 index 0ede42ebc6..0000000000 --- a/calendar/cal-util/calobj.c +++ /dev/null @@ -1,2008 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Calendar objects implementations. - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: - * Miguel de Icaza (miguel@gnu.org) - * Federico Mena (quartic@gimp.org) - */ -#include <config.h> -#include <string.h> -#include <glib.h> -#include <ctype.h> -#include <unistd.h> -#include <time.h> -#include "calobj.h" -#include "timeutil.h" -#include "libversit/vcc.h" -#include "icalendar-save.h" -#include "icalendar.h" - - - -/* VCalendar product ID */ -#define PRODID "-//Helix Code//NONSGML Evolution Calendar//EN" - -static gint compare_exdates (gconstpointer a, gconstpointer b); -static void ical_object_normalize_summary (iCalObject *ico); -static void list_free (GList *list); - - - -char * -ical_gen_uid (void) -{ - static char *hostname; - time_t t = time (NULL); - static int serial; - - if (!hostname){ - char buffer [128]; - - if ((gethostname (buffer, sizeof (buffer)-1) == 0) && - (buffer [0] != 0)) - hostname = g_strdup (buffer); - else - hostname = g_strdup ("localhost"); - } - - return g_strdup_printf ( - "%s-%d-%d-%d-%d@%s", - isodate_from_time_t (t), - getpid (), - getgid (), - getppid (), - serial++, - hostname); -} - -iCalObject * -ical_object_new (void) -{ - iCalObject *ico; - - ico = g_new0 (iCalObject, 1); - - ico->seq = -1; - ico->dtstamp = time (NULL); - ico->uid = ical_gen_uid (); - - ico->pilot_id = 0; - ico->pilot_status = ICAL_PILOT_SYNC_MOD; - - ico->ref_count = 1; - - return ico; -} - -iCalObject * -ical_new (char *comment, char *organizer, char *summary) -{ - iCalObject *ico; - - ico = ical_object_new (); - - ico->comment = g_strdup (comment); - ico->organizer = g_new0 (iCalPerson, 1); - ico->organizer->addr = g_strdup (organizer); - ico->summary = g_strdup (summary); - ico->class = g_strdup ("PUBLIC"); - ico->status = g_strdup ("NEEDS ACTION"); - - ico->dalarm.type = ALARM_DISPLAY; - ico->palarm.type = ALARM_PROGRAM; - ico->malarm.type = ALARM_MAIL; - ico->aalarm.type = ALARM_AUDIO; - - ical_object_normalize_summary (ico); - - return ico; -} - - -void -ical_object_ref (iCalObject *ico) -{ - ico->ref_count++; -} - - -#define free_if_defined(x) if (x){ g_free (x); x = 0; } -#define lfree_if_defined(x) if (x){ list_free (x); x = 0; } -static void -ical_object_destroy (iCalObject *ico) -{ - /* Regular strings */ - free_if_defined (ico->comment); - free_if_defined (ico->organizer); - free_if_defined (ico->summary); - free_if_defined (ico->uid); - free_if_defined (ico->status); - free_if_defined (ico->class); - free_if_defined (ico->url); - free_if_defined (ico->recur); - - /* Lists */ - lfree_if_defined (ico->exdate); - lfree_if_defined (ico->categories); - lfree_if_defined (ico->resources); - lfree_if_defined (ico->related); - lfree_if_defined (ico->attach); - - /* Alarms */ - g_free (ico->dalarm.data); - g_free (ico->palarm.data); - g_free (ico->malarm.data); - g_free (ico->aalarm.data); - - g_free (ico); -} - -void -ical_object_unref (iCalObject *ico) -{ - ico->ref_count--; - if (ico->ref_count == 0) - ical_object_destroy (ico); -} - - -static void -my_free (gpointer data, gpointer user_dat_ignored) -{ - g_free (data); -} - -static void -list_free (GList *list) -{ - g_list_foreach (list, my_free, 0); - g_list_free (list); -} - -/* This resets any recurrence rules of the iCalObject. */ -void -ical_object_reset_recurrence (iCalObject *ico) -{ - free_if_defined (ico->recur); - lfree_if_defined (ico->exdate); -} - -static GList * -set_list (char *str) -{ - GList *list = 0; - char *s; - - for (s = strtok (str, ";"); s; s = strtok (NULL, ";")) - list = g_list_prepend (list, g_strdup (s)); - - return list; -} - -static GList * -set_date_list (char *str) -{ - GList *list = 0; - char *s; - - for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){ - time_t *t = g_new (time_t, 1); - - while (*s && isspace (*s)) - s++; - *t = time_from_isodate (s); - list = g_list_prepend (list, t); - } - return list; -} - -void -ical_object_add_exdate (iCalObject *o, time_t t) -{ - time_t *pt = g_new (time_t, 1); - - *pt = t; - o->exdate = g_list_prepend (o->exdate, pt); -} - -static void -ignore_space(char **str) -{ - while (**str && isspace (**str)) - (*str)++; -} - -static void -skip_numbers (char **str) -{ - while (**str){ - ignore_space (str); - if (!isdigit (**str)) - return; - while (**str && isdigit (**str)) - (*str)++; - } -} - -static void -weekdaylist (iCalObject *o, char **str) -{ - int i; - struct { - char first_letter, second_letter; - int index; - } days [] = { - { 'S', 'U', 0 }, - { 'M', 'O', 1 }, - { 'T', 'U', 2 }, - { 'W', 'E', 3 }, - { 'T', 'H', 4 }, - { 'F', 'R', 5 }, - { 'S', 'A', 6 } - }; - - ignore_space (str); - do { - for (i = 0; i < 7; i++){ - if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){ - o->recur->weekday |= 1 << i; - *str += 2; - if (**str == ' ') - (*str)++; - } - } - } while (isalpha (**str)); - - if (o->recur->weekday == 0){ - struct tm tm = *localtime (&o->dtstart); - - o->recur->weekday = 1 << tm.tm_wday; - } -} - -static void -weekdaynum (iCalObject *o, char **str) -{ - int i; - struct { - char first_letter, second_letter; - int index; - } days [] = { - { 'S', 'U', 0 }, - { 'M', 'O', 1 }, - { 'T', 'U', 2 }, - { 'W', 'E', 3 }, - { 'T', 'H', 4 }, - { 'F', 'R', 5 }, - { 'S', 'A', 6 } - }; - - ignore_space (str); - do { - for (i = 0; i < 7; i++){ - if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){ - o->recur->weekday = i; - *str += 2; - if (**str == ' ') - (*str)++; - } - } - } while (isalpha (**str)); -} - -static void -ocurrencelist (iCalObject *o, char **str) -{ - char *p; - - ignore_space (str); - p = *str; - if (!isdigit (*p)) - return; - - if (!(*p >= '1' && *p <= '5')) - return; - - if (!(*(p+1) == '+' || *(p+1) == '-')) - return; - - o->recur->u.month_pos = (*p-'0') * (*(p+1) == '+' ? 1 : -1); - *str += 2; -} - -#if 0 - -static void -daynumber (iCalObject *o, char **str) -{ - int val = 0; - char *p = *str; - - ignore_space (str); - if (strcmp (p, "LD")){ - o->recur->u.month_day = DAY_LASTDAY; - *str += 2; - return; - } - - if (!(isdigit (*p))) - return; - - while (**str && isdigit (**str)){ - val = val * 10 + (**str - '0'); - (*str)++; - } - - if (**str == '+') - (*str)++; - - if (**str == '-') - val *= -1; - o->recur->u.month_day = val; -} - -#endif - -static void -daynumberlist (iCalObject *o, char **str) -{ - int first = 0; - int val = 0; - - ignore_space (str); - - while (**str){ - if (!isdigit (**str)) - return; - while (**str && isdigit (**str)){ - val = 10 * val + (**str - '0'); - (*str)++; - } - if (!first){ - /* - * Some broken applications set this to zero - */ - if (val == 0){ - struct tm day = *localtime (&o->dtstart); - - val = day.tm_mday; - } - o->recur->u.month_day = val; - first = 1; - val = 0; - } - } -} - -static void -load_recur_weekly (iCalObject *o, char **str) -{ - weekdaylist (o, str); -} - -static void -load_recur_monthly_pos (iCalObject *o, char **str) -{ - ocurrencelist (o, str); - weekdaynum (o, str); -} - -static void -load_recur_monthly_day (iCalObject *o, char **str) -{ - daynumberlist (o, str); -} - -static void -load_recur_yearly_month (iCalObject *o, char **str) -{ - /* Skip as we do not support multiple months and we do expect - * the dtstart to agree with the value on this field - */ - skip_numbers (str); -} - -static void -load_recur_yearly_day (iCalObject *o, char **str) -{ - /* Skip as we do not support multiple days and we do expect - * the dtstart to agree with the value on this field - * - * FIXME: we should support every-n-years - */ - skip_numbers (str); -} - -static void -duration (iCalObject *o, char **str) -{ - unsigned int duration = 0; - - ignore_space (str); - if (**str != '#') - return; - (*str)++; - while (**str && isdigit (**str)){ - duration = duration * 10 + (**str - '0'); - (*str)++; - } - o->recur->duration = duration; -} - -static void -enddate (iCalObject *o, char **str) -{ - ignore_space (str); - if (isdigit (**str)){ - o->recur->_enddate = time_from_isodate (*str); - *str += 16; - } -} - -static int -load_recurrence (iCalObject *o, char *str) -{ - enum RecurType type; - int interval = 0; - - type = -1; - switch (*str++){ - case 'D': - type = RECUR_DAILY; - break; - - case 'W': - type = RECUR_WEEKLY; - break; - - case 'M': - if (*str == 'P') - type = RECUR_MONTHLY_BY_POS; - else if (*str == 'D') - type = RECUR_MONTHLY_BY_DAY; - str++; - break; - - case 'Y': - if (*str == 'M') - type = RECUR_YEARLY_BY_MONTH; - else if (*str == 'D') - type = RECUR_YEARLY_BY_DAY; - str++; - break; - } - if (type == -1) - return 0; - - o->recur = g_new0 (Recurrence, 1); - o->recur->type = type; - ignore_space (&str); - - /* Get the interval */ - for (;*str && isdigit (*str);str++) - interval = interval * 10 + (*str-'0'); - - if (interval == 0) - interval = 1; - - o->recur->interval = interval; - - /* this is the default per the spec */ - o->recur->duration = 2; - - ignore_space (&str); - - switch (type){ - case RECUR_DAILY: - break; - case RECUR_WEEKLY: - load_recur_weekly (o, &str); - break; - case RECUR_MONTHLY_BY_POS: - load_recur_monthly_pos (o, &str); - break; - case RECUR_MONTHLY_BY_DAY: - load_recur_monthly_day (o, &str); - break; - case RECUR_YEARLY_BY_MONTH: - load_recur_yearly_month (o, &str); - break; - case RECUR_YEARLY_BY_DAY: - load_recur_yearly_day (o, &str); - break; - default: - g_warning ("Unimplemented recurrence type %d", (int) type); - break; - } - duration (o, &str); - enddate (o, &str); - - /* Compute the enddate */ - if (o->recur->_enddate == 0){ - if (o->recur->duration != 0){ - ical_object_compute_end (o); - } else - o->recur->enddate = 0; - } else { - o->recur->enddate = o->recur->_enddate; - } - return 1; -} - -#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop) -#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj)) -#define has(obj,prop) (vo = isAPropertyOf (obj, prop)) - -/* - * FIXME: This is loosing precission. Enhanec the thresholds - */ -#define HOURS(n) (n*(60*60)) - -static void -setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *vo) -{ - time_t alarm_time = time_from_isodate (iso_time); - time_t base = ico->dtstart; - int d = difftime (base, alarm_time); - VObject *a; - char *the_str; - - alarm->enabled = 1; - if (d > HOURS (2)){ - if (d > HOURS (48)){ - alarm->count = d / HOURS (24); - alarm->units = ALARM_DAYS; - } else { - alarm->count = d / (60*60); - alarm->units = ALARM_HOURS; - } - } else { - alarm->count = d / 60; - alarm->units = ALARM_MINUTES; - } - - if ((a = is_a_prop_of (vo, VCSnoozeTimeProp))){ - alarm->snooze_secs = isodiff_to_secs (str_val (a)); - free (the_str); - } - - if ((a = is_a_prop_of (vo, VCRepeatCountProp))){ - alarm->snooze_repeat = atoi (str_val (a)); - free (the_str); - } -} - -/* - * Duplicates an iCalObject. Implementation is a grand hack. - * If you need the new ICalObject to have a new uid, free the current one, - * and call ical_gen_uid() to generate a new one. - */ -iCalObject * -ical_object_duplicate (iCalObject *o) -{ - VObject *vo; - iCalObject *new; - - vo = ical_object_to_vobject (o); - switch (o->type){ - case ICAL_EVENT: - new = ical_object_create_from_vobject (vo, VCEventProp); - break; - case ICAL_TODO: - new = ical_object_create_from_vobject (vo, VCTodoProp); - break; - default: - new = NULL; - } - - cleanVObject (vo); - return new; -} - -/* FIXME: we need to load the recurrence properties */ -iCalObject * -ical_object_create_from_vobject (VObject *o, const char *object_name) -{ - time_t now = time (NULL); - iCalObject *ical; - VObject *vo, *a; - VObjectIterator i; - char *the_str; - - ical = g_new0 (iCalObject, 1); - - if (strcmp (object_name, VCEventProp) == 0) - ical->type = ICAL_EVENT; - else if (strcmp (object_name, VCTodoProp) == 0) - ical->type = ICAL_TODO; - else { - g_free (ical); - return 0; - } - - ical->ref_count = 1; - - /* uid */ - if (has (o, VCUniqueStringProp)){ - ical->uid = g_strdup (str_val (vo)); - free (the_str); - } else { - ical->uid = ical_gen_uid (); - } - - /* seq */ - if (has (o, VCSequenceProp)){ - ical->seq = atoi (str_val (vo)); - free (the_str); - } else - ical->seq = 0; - - /* dtstart */ - if (has (o, VCDTstartProp)){ - ical->dtstart = time_from_isodate (str_val (vo)); - free (the_str); - } else - ical->dtstart = 0; - - /* dtend */ - ical->dtend = 0; /* default value */ - if (ical->type == ICAL_EVENT){ - if (has (o, VCDTendProp)){ - ical->dtend = time_from_isodate (str_val (vo)); - free (the_str); - } - } else if (ical->type == ICAL_TODO){ - if (has (o, VCDueProp)){ - ical->dtend = time_from_isodate (str_val (vo)); - free (the_str); - } - } - - /* dcreated */ - if (has (o, VCDCreatedProp)){ - ical->created = time_from_isodate (str_val (vo)); - free (the_str); - } - - /* completed */ - if (has (o, VCCompletedProp)){ - ical->completed = time_from_isodate (str_val (vo)); - free (the_str); - } - - /* last_mod */ - if (has (o, VCLastModifiedProp)){ - ical->last_mod = time_from_isodate (str_val (vo)); - free (the_str); - } else - ical->last_mod = now; - - /* exdate */ - if (has (o, VCExpDateProp)){ - ical->exdate = set_date_list (str_val (vo)); - free (the_str); - } - - /* description/comment */ - if (has (o, VCDescriptionProp)){ - ical->comment = g_strdup (str_val (vo)); - free (the_str); - } - - /* summary */ - if (has (o, VCSummaryProp)){ - ical->summary = g_strdup (str_val (vo)); - free (the_str); - - /* Convert any CR/LF/CRLF sequences in the summary field to - spaces so we just have a one-line field. */ - ical_object_normalize_summary (ical); - } else - ical->summary = g_strdup (""); - - /* status */ - if (has (o, VCStatusProp)){ - ical->status = g_strdup (str_val (vo)); - free (the_str); - } else - ical->status = g_strdup ("NEEDS ACTION"); - - if (has (o, VCClassProp)){ - ical->class = g_strdup (str_val (vo)); - free (the_str); - } else - ical->class = g_strdup ("PUBLIC"); - - /* categories */ - if (has (o, VCCategoriesProp)){ - ical->categories = set_list (str_val (vo)); - free (the_str); - } - - /* resources */ - if (has (o, VCResourcesProp)){ - ical->resources = set_list (str_val (vo)); - free (the_str); - } - - /* priority */ - if (has (o, VCPriorityProp)){ - ical->priority = atoi (str_val (vo)); - free (the_str); - } - - /* tranparency */ - if (has (o, VCTranspProp)){ - ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE; - free (the_str); - } - - /* Organizer */ - if (has (o, VCOrgNameProp)){ - ical->organizer = g_new0 (iCalPerson, 1); - ical->organizer->addr = g_strdup (str_val (vo)); - free (the_str); - } - - /* related */ - if (has (o, VCRelatedToProp)){ - char *str; - char *s; - iCalRelation *rel; - str = str_val (vo); - for (s = strtok (str, ";"); s; s = strtok (NULL, ";")) { - rel = g_new0 (iCalRelation, 1); - rel->uid = g_strdup (s); - rel->reltype = g_strdup ("PARENT"); - ical->related = g_list_prepend (ical->related, rel); - } - free (the_str); - } - - /* attach */ - initPropIterator (&i, o); - while (moreIteration (&i)){ - vo = nextVObject (&i); - if (strcmp (vObjectName (vo), VCAttachProp) == 0){ - ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo))); - free (the_str); - } - } - - /* url */ - if (has (o, VCURLProp)){ - /* There seems to be a problem with the URL property. For some - reason an empty property gets saved, vObjectUStringZValue - returns NULL and fakeCString crashes. So we check for NULL. - */ - const wchar_t *zval; - - zval = vObjectUStringZValue (o); - if (zval) { - the_str = fakeCString (zval); - ical->url = g_strdup (the_str); - free (the_str); - } - } - - /* dalarm */ - ical->dalarm.type = ALARM_DISPLAY; - ical->dalarm.enabled = 0; - if (has (o, VCDAlarmProp)){ - if ((a = is_a_prop_of (vo, VCRunTimeProp))){ - setup_alarm_at (ical, &ical->dalarm, str_val (a), vo); - free (the_str); - } - } - - /* aalarm */ - ical->aalarm.type = ALARM_AUDIO; - ical->aalarm.enabled = 0; - if (has (o, VCAAlarmProp)){ - if ((a = is_a_prop_of (vo, VCRunTimeProp))){ - setup_alarm_at (ical, &ical->aalarm, str_val (a), vo); - free (the_str); - } - } - - /* palarm */ - ical->palarm.type = ALARM_PROGRAM; - ical->palarm.enabled = 0; - if (has (o, VCPAlarmProp)){ - ical->palarm.type = ALARM_PROGRAM; - if ((a = is_a_prop_of (vo, VCRunTimeProp))){ - setup_alarm_at (ical, &ical->palarm, str_val (a), vo); - free (the_str); - - if ((a = is_a_prop_of (vo, VCProcedureNameProp))){ - ical->palarm.data = g_strdup (str_val (a)); - free (the_str); - } else - ical->palarm.data = g_strdup (""); - } - } - - /* malarm */ - ical->malarm.type = ALARM_MAIL; - ical->malarm.enabled = 0; - if (has (o, VCMAlarmProp)){ - ical->malarm.type = ALARM_MAIL; - if ((a = is_a_prop_of (vo, VCRunTimeProp))){ - setup_alarm_at (ical, &ical->malarm, str_val (a), vo); - free (the_str); - - if ((a = is_a_prop_of (vo, VCEmailAddressProp))){ - ical->malarm.data = g_strdup (str_val (a)); - free (the_str); - } else - ical->malarm.data = g_strdup (""); - } - } - - /* rrule */ - if (has (o, VCRRuleProp)){ - if (!load_recurrence (ical, str_val (vo))) { - ical_object_unref (ical); - return NULL; - } - free (the_str); - } - - /* - * Pilot - */ - if (has (o, XPilotIdProp)){ - ical->pilot_id = atoi (str_val (vo)); - free (the_str); - } else - ical->pilot_id = 0; - - if (has (o, XPilotStatusProp)){ - ical->pilot_status = atoi (str_val (vo)); - free (the_str); - } else - ical->pilot_status = ICAL_PILOT_SYNC_MOD; - - return ical; -} - -static char * -to_str (int num) -{ - static char buf [40]; - - sprintf (buf, "%d", num); - return buf; -} - -/* - * stores a GList in the property. - */ -static void -store_list (VObject *o, char *prop, GList *values) -{ - GList *l; - int len; - char *result, *p; - - for (len = 0, l = values; l; l = l->next) - len += strlen (l->data) + 1; - - result = g_malloc (len); - - for (p = result, l = values; l; l = l->next) { - int len = strlen (l->data); - - strcpy (p, l->data); - - if (l->next) { - p [len] = ';'; - p += len+1; - } else - p += len; - } - - *p = 0; - - addPropValue (o, prop, result); - g_free (result); -} - -static void -store_rel_list (VObject *o, char *prop, GList *values) -{ - GList *l; - int len; - char *result, *p; - - for (len = 0, l = values; l; l = l->next) - len += strlen (((iCalRelation*)(l->data))->uid) + 1; - - result = g_malloc (len); - - for (p = result, l = values; l; l = l->next) { - int len = strlen (((iCalRelation*)(l->data))->uid); - - strcpy (p, ((iCalRelation*)(l->data))->uid); - - if (l->next) { - p [len] = ';'; - p += len+1; - } else - p += len; - } - - *p = 0; - - addPropValue (o, prop, result); - g_free (result); -} - -static void -store_date_list (VObject *o, char *prop, GList *values) -{ - GList *l; - int size, len; - char *s, *p; - - size = g_list_length (values); - s = p = g_malloc ((size * 17 + 1) * sizeof (char)); - - for (l = values; l; l = l->next){ - strcpy (s, isodate_from_time_t (*(time_t *)l->data)); - len = strlen (s); - s [len] = ','; - s += len + 1; - } - s--; - *s = 0; - addPropValue (o, prop, p); - g_free (p); -} - -static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" }; -static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" }; -static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp }; - -static VObject * -save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical) -{ - VObject *alarm_object; - struct tm tm; - time_t alarm_time; - - if (!alarm->enabled) - return NULL; - tm = *localtime (&ical->dtstart); - switch (alarm->units){ - case ALARM_MINUTES: - tm.tm_min -= alarm->count; - break; - - case ALARM_HOURS: - tm.tm_hour -= alarm->count; - break; - - case ALARM_DAYS: - tm.tm_mday -= alarm->count; - break; - } - - alarm_time = mktime (&tm); - alarm_object = addProp (o, alarm_names [alarm->type]); - addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time)); - - if (alarm->snooze_secs) - addPropValue (alarm_object, VCSnoozeTimeProp, isodiff_from_secs (alarm->snooze_secs)); - else - addPropValue (alarm_object, VCSnoozeTimeProp, ""); - - if (alarm->snooze_repeat){ - char buf [20]; - - sprintf (buf, "%d", alarm->snooze_repeat); - addPropValue (alarm_object, VCRepeatCountProp, buf); - } else - addPropValue (alarm_object, VCRepeatCountProp, ""); - return alarm_object; -} - -VObject * -ical_object_to_vobject (iCalObject *ical) -{ - VObject *o, *alarm, *s; - GList *l; - - if (ical->type == ICAL_EVENT) - o = newVObject (VCEventProp); - else - o = newVObject (VCTodoProp); - - /* uid */ - if (ical->uid) - addPropValue (o, VCUniqueStringProp, ical->uid); - - /* seq */ - addPropValue (o, VCSequenceProp, to_str (ical->seq)); - - /* dtstart */ - addPropValue (o, VCDTstartProp, isodate_from_time_t (ical->dtstart)); - - /* dtend */ - if (ical->type == ICAL_EVENT){ - addPropValue (o, VCDTendProp, isodate_from_time_t (ical->dtend)); - } else if (ical->type == ICAL_TODO){ - addPropValue (o, VCDueProp, isodate_from_time_t (ical->dtend)); - } - - /* dcreated */ - addPropValue (o, VCDCreatedProp, isodate_from_time_t (ical->created)); - - /* completed */ - if (ical->completed) - addPropValue (o, VCDTendProp, isodate_from_time_t (ical->completed)); - - /* last_mod */ - addPropValue (o, VCLastModifiedProp, isodate_from_time_t (ical->last_mod)); - - /* exdate */ - if (ical->exdate) - store_date_list (o, VCExpDateProp, ical->exdate); - - /* description/comment */ - if (ical->comment && strlen (ical->comment)){ - s = addPropValue (o, VCDescriptionProp, ical->comment); - if (strchr (ical->comment, '\n')) - addProp (s, VCQuotedPrintableProp); - } - - /* summary */ - if (ical->summary && strlen (ical->summary)) { - s = addPropValue (o, VCSummaryProp, ical->summary); - if (strchr (ical->summary, '\n')) - addProp (s, VCQuotedPrintableProp); - } - - /* status */ - addPropValue (o, VCStatusProp, ical->status); - - /* class */ - addPropValue (o, VCClassProp, ical->class); - - /* categories */ - if (ical->categories) - store_list (o, VCCategoriesProp, ical->categories); - - /* resources */ - if (ical->resources) - store_list (o, VCCategoriesProp, ical->resources); - - /* priority */ - addPropValue (o, VCPriorityProp, to_str (ical->priority)); - - /* transparency */ - addPropValue (o, VCTranspProp, to_str (ical->transp)); - - /* Owner/organizer */ - if (ical->organizer && ical->organizer->addr) - addPropValue (o, VCOrgNameProp, ical->organizer->addr); - - /* related */ - if (ical->related) - store_rel_list (o, VCRelatedToProp, ical->related); - - /* attach */ - for (l = ical->attach; l; l = l->next) - addPropValue (o, VCAttachProp, l->data); - - /* url */ - if (ical->url) - addPropValue (o, VCURLProp, ical->url); - - if (ical->recur){ - char result [256]; - char buffer [80]; - int i; - - sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval); - switch (ical->recur->type){ - case RECUR_DAILY: - break; - - case RECUR_WEEKLY: - for (i = 0; i < 7; i++){ - if (ical->recur->weekday & (1 << i)){ - sprintf (buffer, "%s ", recur_day_list [i]); - strcat (result, buffer); - } - } - break; - - case RECUR_MONTHLY_BY_POS: { - int nega = ical->recur->u.month_pos < 0; - - sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos, - nega ? "-" : "+"); - strcat (result, buffer); - /* the gui is set up for a single day, not a set here in this case */ - sprintf (buffer, "%s ", recur_day_list [ical->recur->weekday]); - strcat (result, buffer); - } - break; - - case RECUR_MONTHLY_BY_DAY: - sprintf (buffer, "%d ", ical->recur->u.month_pos); - strcat (result, buffer); - break; - - case RECUR_YEARLY_BY_MONTH: - break; - - case RECUR_YEARLY_BY_DAY: - break; - } - if (ical->recur->_enddate == 0) - sprintf (buffer, "#%d ",ical->recur->duration); - else - sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate)); - strcat (result, buffer); - addPropValue (o, VCRRuleProp, result); - } - - save_alarm (o, &ical->aalarm, ical); - save_alarm (o, &ical->dalarm, ical); - - if ((alarm = save_alarm (o, &ical->palarm, ical))) - addPropValue (alarm, VCProcedureNameProp, ical->palarm.data); - if ((alarm = save_alarm (o, &ical->malarm, ical))) - addPropValue (alarm, VCEmailAddressProp, ical->malarm.data); - - /* Pilot */ - { - char buffer [20]; - - sprintf (buffer, "%d", ical->pilot_id); - addPropValue (o, XPilotIdProp, buffer); - sprintf (buffer, "%d", ical->pilot_status); - addPropValue (o, XPilotStatusProp, buffer); - } - - return o; -} - -void -ical_foreach (GList *events, calendarfn fn, void *closure) -{ - for (; events; events = events->next){ - iCalObject *ical = events->data; - - (*fn) (ical, ical->dtstart, ical->dtend, closure); - } -} - -static int -is_date_in_list (GList *list, struct tm *date) -{ - struct tm tm; - - for (; list; list = list->next){ - time_t *timep = list->data; - - tm = *localtime (timep); - if (date->tm_mday == tm.tm_mday && - date->tm_mon == tm.tm_mon && - date->tm_year == tm.tm_year){ - return 1; - } - } - return 0; -} - -/* Generates an event instance based on the reference time */ -static gboolean -generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure) -{ - time_t offset; - struct tm tm_start, ref; - time_t start, end; - - offset = ico->dtend - ico->dtstart; - - tm_start = *localtime (&ico->dtstart); - ref = *localtime (&reference); - - tm_start.tm_mday = ref.tm_mday; - tm_start.tm_mon = ref.tm_mon; - tm_start.tm_year = ref.tm_year; - - start = mktime (&tm_start); - if (start == -1) { - g_message ("generate(): Produced invalid start date!"); - return FALSE; - } - - end = start + offset; - -#if 0 - /* FIXME: I think this is not needed, since we are offsetting by full day values, - * and the times should remain the same --- if you have a daily appointment - * at 18:00, it is always at 18:00 even during daylight savings. - * - * However, what should happen on the exact change-of-savings day with - * appointments in the early morning hours? - */ - - if (ref.tm_isdst > tm_start.tm_isdst) { - tm_start.tm_hour--; - tm_end.tm_hour--; - } else if (ref.tm_isdst < tm_start.tm_isdst) { - tm_start.tm_hour++; - tm_end.tm_hour++; - } -#endif - - if (ico->exdate && is_date_in_list (ico->exdate, &tm_start)) - return TRUE; - - return (*cb) (ico, start, end, closure); -} - -int -ical_object_get_first_weekday (int weekday_mask) -{ - int i; - - for (i = 0; i < 7; i++) - if (weekday_mask & (1 << i)) - return i; - - return -1; -} - -#define time_in_range(t, a, b) ((t >= a) && (b ? (t < b) : 1)) -#define recur_in_range(t, r) (r->enddate ? (t < r->enddate) : 1) - -/* - * Generate every possible event. Invokes the callback routine for - * every occurrence of the event in the [START, END] time interval. - * - * If END is zero, the event is generated forever. - * The callback routine is expected to return 0 when no further event - * generation is requested. - */ -void -ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure) -{ - time_t current; - int first_week_day; - - /* If there is no recurrence, just check ranges */ - - if (!ico->recur) { - if ((end && (ico->dtstart < end) && (ico->dtend > start)) - || ((end == 0) && (ico->dtend > start))) { - /* The new calendar views expect the times to not be - clipped, so they can show that it continues past - the end of the viewable area. */ -#if 0 - time_t ev_s, ev_e; - - /* Clip range */ - - ev_s = MAX (ico->dtstart, start); - ev_e = MIN (ico->dtend, end); - - (* cb) (ico, ev_s, ev_e, closure); -#else - (* cb) (ico, ico->dtstart, ico->dtend, closure); -#endif - } - return; - } - - /* The event has a recurrence rule -- check that we will generate at least one instance */ - - if (end != 0) { - if (ico->dtstart > end) - return; - - if (!IS_INFINITE (ico->recur) && (ico->recur->enddate < start)) - return; - } - - /* Generate the instances */ - - current = ico->dtstart; - - switch (ico->recur->type) { - case RECUR_DAILY: - do { - if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) - if (!generate (ico, current, cb, closure)) - return; - - /* Advance */ - - current = time_add_day (current, ico->recur->interval); - - if (current == -1) { - g_warning ("RECUR_DAILY: time_add_day() returned invalid time"); - return; - } - } while ((current < end) || (end == 0)); - - break; - - case RECUR_WEEKLY: - do { - struct tm tm; - - tm = *localtime (¤t); - - if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) { - /* Weekdays to recur on are specified as a bitmask */ - if (ico->recur->weekday & (1 << tm.tm_wday)) { - if (!generate (ico, current, cb, closure)) - return; - } - } - - /* Advance by day for scanning the week or by interval at week end */ - - if (tm.tm_wday == 6) - current = time_add_day (current, (ico->recur->interval - 1) * 7 + 1); - else - current = time_add_day (current, 1); - - if (current == -1) { - g_warning ("RECUR_WEEKLY: time_add_day() returned invalid time\n"); - return; - } - } while (current < end || (end == 0)); - - break; - - case RECUR_MONTHLY_BY_POS: - /* FIXME: We only deal with positives now */ - if (ico->recur->u.month_pos < 0) { - g_warning ("RECUR_MONTHLY_BY_POS does not support negative positions yet"); - return; - } - - if (ico->recur->u.month_pos == 0) - return; - - first_week_day = /* ical_object_get_first_weekday (ico->recur->weekday); */ - ico->recur->weekday; /* the i/f only lets you choose a single day of the week! */ - - /* This should not happen, but take it into account */ - if (first_week_day == -1) { - g_warning ("ical_object_get_first_weekday() returned -1"); - return; - } - - do { - struct tm tm; - time_t t; - int week_day_start; - - tm = *localtime (¤t); - tm.tm_mday = 1; - t = mktime (&tm); - tm = *localtime (&t); - week_day_start = tm.tm_wday; - - tm.tm_mday = (7 * (ico->recur->u.month_pos - ((week_day_start <= first_week_day ) ? 1 : 0)) - - (week_day_start - first_week_day) + 1); - if( tm.tm_mday > 31 ) - { - tm.tm_mday = 1; - tm.tm_mon += ico->recur->interval; - current = mktime (&tm); - continue; - } - - switch( tm.tm_mon ) - { - case 3: - case 5: - case 8: - case 10: - if( tm.tm_mday > 30 ) - { - tm.tm_mday = 1; - tm.tm_mon += ico->recur->interval; - current = mktime (&tm); - continue; - } - break; - case 1: - if( ((tm.tm_year+1900)%4) == 0 - && ((tm.tm_year+1900)%400) != 100 - && ((tm.tm_year+1900)%400) != 200 - && ((tm.tm_year+1900)%400) != 300 ) - { - - if( tm.tm_mday > 29 ) - { - tm.tm_mday = 1; - tm.tm_mon += ico->recur->interval; - current = mktime (&tm); - continue; - } - } - else - { - if( tm.tm_mday > 28 ) - { - tm.tm_mday = 1; - tm.tm_mon += ico->recur->interval; - current = mktime (&tm); - continue; - } - } - break; - } - - t = mktime (&tm); - - if (time_in_range (t, start, end) && recur_in_range (current, ico->recur)) - if (!generate (ico, t, cb, closure)) - return; - - /* Advance by the appropriate number of months */ - - current = mktime (&tm); - - tm.tm_mday = 1; - tm.tm_mon += ico->recur->interval; - current = mktime (&tm); - - if (current == -1) { - g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n"); - return; - } - } while ((current < end) || (end == 0)); - - break; - - case RECUR_MONTHLY_BY_DAY: - do { - struct tm tm; - time_t t; - int p; - - tm = *localtime (¤t); - - p = tm.tm_mday; - tm.tm_mday = ico->recur->u.month_day; - t = mktime (&tm); - if (time_in_range (t, start, end) && recur_in_range (current, ico->recur)) - if (!generate (ico, t, cb, closure)) - return; - - /* Advance by the appropriate number of months */ - - tm.tm_mday = p; - tm.tm_mon += ico->recur->interval; - current = mktime (&tm); - - if (current == -1) { - g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n"); - return; - } - } while (current < end || (end == 0)); - - break; - - case RECUR_YEARLY_BY_MONTH: - case RECUR_YEARLY_BY_DAY: - do { - if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) - if (!generate (ico, current, cb, closure)) - return; - - /* Advance */ - - current = time_add_year (current, ico->recur->interval); - } while (current < end || (end == 0)); - - break; - - default: - g_assert_not_reached (); - } -} - -static int -duration_callback (iCalObject *ico, time_t start, time_t end, void *closure) -{ - int *count = closure; - struct tm tm; - - tm = *localtime (&start); - - (*count)++; - if (ico->recur->duration == *count) { - ico->recur->enddate = time_day_end (end); - return 0; - } - return 1; -} - -/* Computes ico->recur->enddate from ico->recur->duration */ -void -ical_object_compute_end (iCalObject *ico) -{ - int count = 0; - - g_return_if_fail (ico->recur != NULL); - - ico->recur->_enddate = 0; - ico->recur->enddate = 0; - ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count); -} - -int -alarm_compute_offset (CalendarAlarm *a) -{ - if (!a->enabled) - return -1; - switch (a->units){ - case ALARM_MINUTES: - a->offset = a->count * 60; - break; - case ALARM_HOURS: - a->offset = a->count * 3600; - break; - case ALARM_DAYS: - a->offset = a->count * 24 * 3600; - } - return a->offset; -} - - -/** - * ical_object_find_in_string: - * @uid: Unique identifier of the sought object. - * @vcalobj: String representation of a complete calendar object. - * @ico: The resulting #iCalObject is stored here. - * - * Parses a complete vCalendar object string and tries to find the calendar - * object that matches the specified @uid. If found, it stores the resulting - * #iCalObject in the @ico parameter. - * - * Return value: A result code depending on whether the parse and search were - * successful. - **/ -CalObjFindStatus -ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico) -{ -#if 0 - icalcomponent* comp = NULL; - icalcomponent *subcomp; - iCalObject *ical; - - g_return_val_if_fail (vcalobj != NULL, CAL_OBJ_FIND_NOT_FOUND); - - comp = icalparser_parse_string (vcalobj); - - if (!comp) { - printf ("CAL_OBJ_FIND_SYNTAX_ERROR #1\n"); - return CAL_OBJ_FIND_SYNTAX_ERROR; - } - - subcomp = icalcomponent_get_first_component (comp, - ICAL_ANY_COMPONENT); - if (!subcomp) { - printf ("CAL_OBJ_FIND_SYNTAX_ERROR #2\n"); - return CAL_OBJ_FIND_SYNTAX_ERROR; - } - - while (subcomp) { - ical = ical_object_create_from_icalcomponent (subcomp); - if (ical->type != ICAL_EVENT && - ical->type != ICAL_TODO && - ical->type != ICAL_JOURNAL) { - g_warning ("Skipping unsupported iCalendar component"); - } else { - if (strcasecmp (ical->uid, uid) == 0) { - (*ico) = ical; - (*ico)->ref_count = 1; - printf ("CAL_OBJ_FIND_SUCCESS\n"); - - printf ("ical_object_find_in_string:\n"); - printf ("-----------------------------------------------------\n"); - dump_icalobject (*ico); - printf ("-----------------------------------------------------\n"); - - - return CAL_OBJ_FIND_SUCCESS; - } - } - subcomp = icalcomponent_get_next_component (comp, - ICAL_ANY_COMPONENT); - } - - printf ("CAL_OBJ_FIND_NOT_FOUND\n"); - return CAL_OBJ_FIND_NOT_FOUND; - -#else /* 1 */ - VObject *vcal; - VObjectIterator i; - CalObjFindStatus status; - - g_return_val_if_fail (uid != NULL, CAL_OBJ_FIND_SYNTAX_ERROR); - g_return_val_if_fail (vcalobj != NULL, CAL_OBJ_FIND_SYNTAX_ERROR); - g_return_val_if_fail (ico != NULL, CAL_OBJ_FIND_SYNTAX_ERROR); - - *ico = NULL; - status = CAL_OBJ_FIND_NOT_FOUND; - - vcal = Parse_MIME (vcalobj, strlen (vcalobj)); - - if (!vcal) - return CAL_OBJ_FIND_SYNTAX_ERROR; - - initPropIterator (&i, vcal); - - while (moreIteration (&i)) { - VObject *vobj; - VObject *uid_prop; - char *the_str; - - vobj = nextVObject (&i); - - uid_prop = isAPropertyOf (vobj, VCUniqueStringProp); - if (!uid_prop) - continue; - - /* str_val() sets the_str to the string representation of the - * property. - */ - str_val (uid_prop); - - if (strcmp (the_str, uid) == 0) { - const char *object_name; - - object_name = vObjectName (vobj); - *ico = ical_object_create_from_vobject (vobj, object_name); - - if (*ico) - status = CAL_OBJ_FIND_SUCCESS; - } - - free (the_str); - - if (status == CAL_OBJ_FIND_SUCCESS) - break; - } - - cleanVObject (vcal); - cleanStrTbl (); - - return status; -#endif /* 1 */ -} - - -#if 1 -/* Creates a VObject with the base information of a calendar */ -static VObject * -get_calendar_base_vobject (void) -{ - VObject *vobj; - time_t now; - struct tm tm; - - /* We call localtime for the side effect of setting tzname */ - - now = time (NULL); - tm = *localtime (&now); - - vobj = newVObject (VCCalProp); - - addPropValue (vobj, VCProdIdProp, PRODID); - -#if defined (HAVE_TM_ZONE) - addPropValue (vobj, VCTimeZoneProp, tm.tm_zone); -#elif defined (HAVE_TZNAME) - addPropValue (vobj, VCTimeZoneProp, tzname[0]); -#endif - - /* Per the vCalendar spec, this must be "1.0" */ - addPropValue (vobj, VCVersionProp, "1.0"); - - return vobj; -} -#endif /* 0 */ - -/** - * ical_object_to_string: - * @ico: A calendar object. - * - * Converts a vCalendar object to its string representation. It is wrapped - * inside a complete VCALENDAR object because other auxiliary information such - * as timezones may appear there. - * - * Return value: String representation of the object. - **/ -char * -ical_object_to_string (iCalObject *ico) -{ -#if 0 - icalcomponent *top = icalcomponent_new (ICAL_VCALENDAR_COMPONENT); - char *out_cal_string; - icalcomponent *comp; - - printf ("ical_object_to_string:\n"); - printf ("-----------------------------------------------------\n"); - dump_icalobject (ico); - printf ("-----------------------------------------------------\n"); - - comp = icalcomponent_create_from_ical_object (ico); - icalcomponent_add_component (top, comp); - out_cal_string = icalcomponent_as_ical_string (top); - return g_strdup (out_cal_string); - -#else /* 1 */ - VObject *vcalobj, *vobj; - char *buf, *gbuf; - - vcalobj = get_calendar_base_vobject (); - vobj = ical_object_to_vobject (ico); - addVObjectProp (vcalobj, vobj); - - buf = writeMemVObject (NULL, NULL, vcalobj); - - cleanVObject (vcalobj); - cleanStrTbl (); - - /* We have to g_strdup() it because libversit uses malloc()/realloc(), - * and we want clients to be able to use g_free(). Sigh. - */ - gbuf = g_strdup (buf); - free (buf); - - return gbuf; -#endif /* 1 */ -} - - -/** - * ical_object_compare_dates: - * @ico1: A calendar event. - * @ico2: A calendar event to compare with @ico1. - * - * Returns TRUE if the dates of both objects match, including any recurrence - * rules. Both calendar objects must have a type of ICAL_EVENT. - * - * Return value: TRUE if both calendar objects have the same dates. - **/ -gboolean -ical_object_compare_dates (iCalObject *ico1, - iCalObject *ico2) -{ - Recurrence *recur1, *recur2; - gint num_exdates; - GList *elem1, *elem2; - time_t *time1, *time2; - - g_return_val_if_fail (ico1 != NULL, FALSE); - g_return_val_if_fail (ico2 != NULL, FALSE); - g_return_val_if_fail (ico1->type == ICAL_EVENT, FALSE); - g_return_val_if_fail (ico2->type == ICAL_EVENT, FALSE); - - /* First check the base dates. */ - if (ico1->dtstart != ico2->dtstart - || ico1->dtend != ico2->dtend) - return FALSE; - - recur1 = ico1->recur; - recur2 = ico2->recur; - - /* If the event doesn't recur, we already know it matches. */ - if (!recur1 && !recur2) - return TRUE; - - /* Check that both recur. */ - if (!(recur1 && recur2)) - return FALSE; - - /* Now we need to see if the recurrence rules are the same. */ - if (recur1->type != recur2->type - || recur1->interval != recur2->interval - || recur1->enddate != recur2->enddate - || recur1->weekday != recur2->weekday - || recur1->duration != recur2->duration - || recur1->_enddate != recur2->_enddate - || recur1->__count != recur2->__count) - return FALSE; - - switch (recur1->type) { - case RECUR_MONTHLY_BY_POS: - if (recur1->u.month_pos != recur2->u.month_pos) - return FALSE; - break; - case RECUR_MONTHLY_BY_DAY: - if (recur1->u.month_day != recur2->u.month_day) - return FALSE; - break; - default: - break; - } - - /* Now check if the excluded dates match. */ - num_exdates = g_list_length (ico1->exdate); - if (g_list_length (ico2->exdate) != num_exdates) - return FALSE; - if (num_exdates == 0) - return TRUE; - - ico1->exdate = g_list_sort (ico1->exdate, compare_exdates); - ico2->exdate = g_list_sort (ico2->exdate, compare_exdates); - - elem1 = ico1->exdate; - elem2 = ico2->exdate; - while (elem1) { - time1 = (time_t*) elem1->data; - time2 = (time_t*) elem2->data; - - if (*time1 != *time2) - return FALSE; - - elem1 = elem1->next; - elem2 = elem2->next; - } - - return TRUE; -} - - -static gint -compare_exdates (gconstpointer a, gconstpointer b) -{ - const time_t *ca = a, *cb = b; - time_t diff = *ca - *cb; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - - -/* Converts any CR/LF sequences in the summary field to spaces so we just - have a one-line field. The iCalObjects summary field is changed. */ -static void -ical_object_normalize_summary (iCalObject *ico) -{ - gchar *src, *dest, ch; - gboolean just_output_space = FALSE; - - src = dest = ico->summary; - while ((ch = *src++)) { - if (ch == '\n' || ch == '\r') { - /* We only output 1 space for each sequence of CR & LF - characters. */ - if (!just_output_space) { - *dest++ = ' '; - just_output_space = TRUE; - } - } else { - *dest++ = ch; - just_output_space = FALSE; - } - } - *dest = '\0'; -} - - -void dump_icalobject (iCalObject *ico) -{ - if (!ico) { - printf ("<<NULL>>\n"); - return; - } - - printf ("type "); - switch (ico->type) { - case ICAL_EVENT: printf ("event"); break; - case ICAL_TODO: printf ("todo"); break; - case ICAL_JOURNAL: printf ("journal"); break; - case ICAL_FBREQUEST: printf ("fbrequest"); break; - case ICAL_FBREPLY: printf ("fbreply"); break; - case ICAL_BUSYTIME: printf ("busytime"); break; - case ICAL_TIMEZONE: printf ("timezone"); break; - } - printf ("\n"); - - printf ("attach-length %d\n", g_list_length (ico->attach)); - - printf ("attendee-length %d\n", g_list_length (ico->attendee)); - - printf ("catagories-length %d\n", g_list_length (ico->categories)); - - printf ("class '%s'\n", ico->class ? ico->class : "NULL"); - - printf ("comment '%s'\n", ico->comment ? ico->comment : "NULL"); - - printf ("completed %ld=%s", - ico->completed, ctime (&ico->completed)); - - printf ("created %ld=%s", ico->created, ctime (&ico->created)); - - printf ("contact-length %d\n", g_list_length (ico->contact)); - - printf ("desc '%s'\n", ico->desc ? ico->desc : "NULL"); - - printf ("dtstamp %ld=%s", ico->dtstamp, ctime (&ico->dtstamp)); - - printf ("dtstart %ld=%s", ico->dtstart, ctime (&ico->dtstart)); - - printf ("dtend %ld=%s", ico->dtend, ctime (&ico->dtend)); - - printf ("date_only %d\n", ico->date_only); - - printf ("exdate-length %d\n", g_list_length (ico->exdate)); - - printf ("exrule-length %d\n", g_list_length (ico->exrule)); - - printf ("iCalGeo %d %f %f\n", - ico->geo.valid, ico->geo.latitude, ico->geo.longitude); - - printf ("last_mod %ld=%s", ico->last_mod, ctime (&ico->last_mod)); - - printf ("location '%s'\n", ico->location ? ico->location : "NULL"); - - printf ("organizer %p\n", ico->organizer); - - printf ("percent %d\n", ico->percent); - - printf ("priority %d\n", ico->priority); - - printf ("rstatus '%s'\n", ico->rstatus ? ico->rstatus : "NULL"); - - printf ("related-length %d\n", g_list_length (ico->related)); - - printf ("resources-length %d\n", g_list_length (ico->resources)); - - printf ("rdate-length %d\n", g_list_length (ico->rdate)); - - printf ("rrule-length %d\n", g_list_length (ico->rrule)); - - printf ("seq %d\n", ico->seq); - - printf ("status '%s'\n", ico->status ? ico->status : "NULL"); - - printf ("summary '%s'\n", ico->summary ? ico->summary : "NULL"); - - printf ("transp "); - switch (ico->transp) { - case ICAL_OPAQUE: printf ("opaque"); break; - case ICAL_TRANSPARENT: printf ("transparent"); break; - } - printf ("\n"); - - printf ("uid '%s'\n", ico->uid ? ico->uid : "NULL"); - - printf ("url '%s'\n", ico->url ? ico->url : "NULL"); - - printf ("recurid %ld=%s", ico->recurid, ctime (&ico->recurid)); - - printf ("dalarm %d\n", ico->dalarm.enabled); - - printf ("aalarm %d\n", ico->aalarm.enabled); - - printf ("palarm %d\n", ico->palarm.enabled); - - printf ("malarm %d\n", ico->malarm.enabled); - - printf ("alarms-length %d\n", g_list_length (ico->alarms)); - - printf ("recur %p\n", ico->recur); - - printf ("new %d\n", ico->new); - - printf ("user_data %p\n", ico->user_data); - - printf ("ref_count %d\n", ico->ref_count); -} diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h deleted file mode 100644 index 3caef945e2..0000000000 --- a/calendar/cal-util/calobj.h +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Internal representation of a Calendar object. This is modeled after the - * iCalendar/vCalendar specificiation - * - * Authors: Miguel de Icaza (miguel@gnu.org) - * Federico Mena (quartic@gimp.org). - */ -#ifndef CALOBJ_H -#define CALOBJ_H - -#include <libgnome/libgnome.h> -#include "libversit/vcc.h" - -BEGIN_GNOME_DECLS - -/* Alarm types */ -enum AlarmType { - ALARM_MAIL, - ALARM_PROGRAM, - ALARM_DISPLAY, - ALARM_AUDIO -}; - -/* Whether the alarm should trigger N mins/hours/days before its due time */ -enum AlarmUnit { - ALARM_MINUTES, - ALARM_HOURS, - ALARM_DAYS -}; - -/* Field identifiers for the iCalObject structure. These are also used to - identify columns in ECalendarTable, so be careful when reordering them. */ -typedef enum { - ICAL_OBJECT_FIELD_COMMENT, - ICAL_OBJECT_FIELD_COMPLETED, - ICAL_OBJECT_FIELD_CREATED, - ICAL_OBJECT_FIELD_DESCRIPTION, - ICAL_OBJECT_FIELD_DTSTAMP, - ICAL_OBJECT_FIELD_DTSTART, - ICAL_OBJECT_FIELD_DTEND, - ICAL_OBJECT_FIELD_GEO, - ICAL_OBJECT_FIELD_LAST_MOD, - ICAL_OBJECT_FIELD_LOCATION, - ICAL_OBJECT_FIELD_ORGANIZER, - ICAL_OBJECT_FIELD_PERCENT, - ICAL_OBJECT_FIELD_PRIORITY, - ICAL_OBJECT_FIELD_SUMMARY, - ICAL_OBJECT_FIELD_URL, - ICAL_OBJECT_FIELD_HAS_ALARMS, /* not a real field */ - ICAL_OBJECT_FIELD_ICON, /* not a real field */ - ICAL_OBJECT_FIELD_COMPLETE, /* not a real field */ - ICAL_OBJECT_FIELD_RECURRING, /* not a real field */ - ICAL_OBJECT_FIELD_OVERDUE, /* not a real field */ - ICAL_OBJECT_FIELD_COLOR, /* not a real field */ - ICAL_OBJECT_FIELD_NUM_FIELDS -} iCalObjectField; - -typedef struct { - enum AlarmType type; - int enabled; - int count; - enum AlarmUnit units; - char *data; /* not used for iCalendar alarms */ - - /* the following pointers are used for iCalendar alarms */ - - char *attach; /* AUDIO, EMAIL, PROC */ - char *desc; /* DISPLAY, EMAIL, PROC */ - char *summary; /* EMAIL */ - char *attendee; /* EMAIL */ - - /* Does not get saved, internally used */ - time_t offset; - time_t trigger; - - int snooze_secs; - int snooze_repeat; - - /* Widgets */ - void *w_count; /* A GtkEntry */ - void *w_enabled; /* A GtkChecButton */ - void *w_timesel; /* A GtkMenu */ - void *w_entry; /* A GnomeEntryFile/GtkEntry for PROGRAM/MAIL */ - void *w_label; -} CalendarAlarm; - -/* Calendar object type */ -typedef enum { - ICAL_EVENT, - ICAL_TODO, - ICAL_JOURNAL, - ICAL_FBREQUEST, - ICAL_FBREPLY, - ICAL_BUSYTIME, - ICAL_TIMEZONE -} iCalType; - -/* For keys that might contain binary or text/binary */ -typedef struct { - char *data; - int len; -} iCalValue; - -typedef enum { - ICAL_PILOT_SYNC_NONE = 0, - ICAL_PILOT_SYNC_MOD = 1, - ICAL_PILOT_SYNC_DEL = 3 -} iCalPilotState; - -typedef struct { - int valid; /* true if the Geography was specified */ - double latitude; - double longitude; -} iCalGeo; - -typedef enum { - ICAL_OPAQUE, - ICAL_TRANSPARENT -} iCalTransp; - -typedef struct { - char *uid; - char *reltype; -} iCalRelation; - -typedef char NotYet; - -enum RecurType { - RECUR_DAILY, - RECUR_WEEKLY, - RECUR_MONTHLY_BY_POS, - RECUR_MONTHLY_BY_DAY, - RECUR_YEARLY_BY_MONTH, - RECUR_YEARLY_BY_DAY, -}; - -#define DAY_LASTDAY 10000 - -typedef struct { - enum RecurType type; - - int interval; - - /* Used for recur computation */ - time_t enddate; /* If the value is zero, it is an infinite event - * otherwise, it is either the _enddate value (if - * this is what got specified) or it is our computed - * ending date (computed from the duration item). - */ - - int weekday; - - union { - int month_pos; - int month_day; - } u; - - int duration; - time_t _enddate; /* As found on the vCalendar file */ - int __count; -} Recurrence; - -/* - NOTE: iCalPerson is used for various property values which specify - people (e.g. ATTENDEE, ORGANIZER, etc. Not all fields are valid - under RFC 2445 for all property values, but iCalPerson can store - them anyway. Enforcing the RFC is a job for the parser. -*/ - -typedef struct { - char *addr; - char *name; - char *role; - char *partstat; - gboolean rsvp; - char *cutype; /* calendar user type */ - GList *member; /* group memberships */ - GList *deleg_to; - GList *deleg_from; - char *sent_by; - char *directory; - GList *altrep; /* list of char* URI's */ -} iCalPerson; - -#define IS_INFINITE(r) (r->duration == 0) - -/* Flags to indicate what has changed in an object */ -typedef enum { - CHANGE_NEW = 1 << 0, /* new object */ - CHANGE_SUMMARY = 1 << 1, /* summary */ - CHANGE_DATES = 1 << 2, /* dtstart / dtend */ - CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES -} CalObjectChange; - -/* - * This describes an iCalendar object, note that we never store durations, instead we - * always compute the end time computed from the start + duration. - */ -typedef struct { - iCalType type; - - GList *attach; /* type: one or more URIs or binary data */ - GList *attendee; /* type: CAL-ADDRESS (list of iCalPerson) */ - GList *categories; /* type: one or more TEXT */ - char *class; - - char *comment; /* we collapse one or more TEXTs into one */ - time_t completed; - time_t created; - GList *contact; /* type: one or more TEXT */ - char *desc; - time_t dtstamp; - time_t dtstart; - time_t dtend; /* also duedate for todo's */ - gboolean date_only; /* set if the start/end times were - specified using dates, not times (internal use, not stored to disk) */ - GList *exdate; /* type: one or more time_t's */ - GList *exrule; /* type: one or more RECUR */ - iCalGeo geo; - time_t last_mod; - char *location; - iCalPerson *organizer; - int percent; - int priority; - char *rstatus; /* request status for freebusy */ - GList *related; /* type: one or more TEXT */ - GList *resources; /* type: one or more TEXT */ - GList *rdate; /* type: one or more recurrence date */ - GList *rrule; /* type: one or more recurrence rules */ - int seq; - char *status; - char *summary; - iCalTransp transp; - char *uid; - char *url; - time_t recurid; - - CalendarAlarm dalarm; - CalendarAlarm aalarm; - CalendarAlarm palarm; - CalendarAlarm malarm; - - GList *alarms; - - Recurrence *recur; - - int new; - void *user_data; /* Generic data pointer */ - - /* Pilot */ - iCalPilotState pilot_status; /* Status information */ - guint32 pilot_id; /* Pilot ID */ - - guint ref_count; -} iCalObject; - -/* The callback for the recurrence generator */ -typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *); - -iCalObject *ical_new (char *comment, char *organizer, char *summary); -iCalObject *ical_object_new (void); - -void ical_object_ref (iCalObject *ico); -void ical_object_unref (iCalObject *ico); - -iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name); -VObject *ical_object_to_vobject (iCalObject *ical); -iCalObject *ical_object_duplicate (iCalObject *o); -void ical_foreach (GList *events, calendarfn fn, void *closure); -void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure); -void ical_object_add_exdate (iCalObject *o, time_t t); - -/* Computes the enddate field of the recurrence based on the duration */ -void ical_object_compute_end (iCalObject *ico); - -typedef enum { - CAL_OBJ_FIND_SUCCESS, - CAL_OBJ_FIND_SYNTAX_ERROR, - CAL_OBJ_FIND_NOT_FOUND -} CalObjFindStatus; - -CalObjFindStatus ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico); - -char *ical_object_to_string (iCalObject *ico); - - -/* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple - * days on a monthly-by-pos recurrence. If no days are toggled, it returns -1. - */ -int ical_object_get_first_weekday (int weekday_mask); - -/* Returns the number of seconds configured to trigger the alarm in advance to an event */ -int alarm_compute_offset (CalendarAlarm *a); - - -/* Returns TRUE if the dates of both objects match, including any recurrence - rules. */ -gboolean ical_object_compare_dates (iCalObject *ico1, iCalObject *ico2); - -/* Generates a new uid for a calendar object. Should be g_free'd eventually. */ -char *ical_gen_uid (void); - -/* This resets any recurrence rules of the iCalObject. */ -void ical_object_reset_recurrence (iCalObject *ico); - - -void dump_icalobject (iCalObject *ico); - -END_GNOME_DECLS - -#endif - diff --git a/calendar/cal-util/icalendar-save.c b/calendar/cal-util/icalendar-save.c deleted file mode 100644 index 8f2335763f..0000000000 --- a/calendar/cal-util/icalendar-save.c +++ /dev/null @@ -1,516 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include <unistd.h> -#include <sys/stat.h> -#include "icalendar-save.h" - - -static void unparse_person (iCalPerson *person, icalproperty *person_prop); -static struct icaltimetype timet_to_icaltime (time_t tt); -static icalproperty *unparse_related (iCalRelation *rel); -static icalcomponent *unparse_alarm (CalendarAlarm *alarm); - - -icalcomponent* -icalcomponent_create_from_ical_object (iCalObject *ical) -{ - icalcomponent_kind kind; - icalcomponent *comp; - icalproperty *prop; - - switch (ical->type) { - case ICAL_EVENT: kind = ICAL_VEVENT_COMPONENT; break; - case ICAL_TODO: kind = ICAL_VTODO_COMPONENT; break; - case ICAL_JOURNAL: kind = ICAL_VJOURNAL_COMPONENT; break; - case ICAL_FBREQUEST: kind = ICAL_VFREEBUSY_COMPONENT; break; - case ICAL_TIMEZONE: kind = ICAL_VTIMEZONE_COMPONENT; break; - default: - kind = ICAL_NO_COMPONENT; break; - } - - comp = icalcomponent_new (kind); - - /*** calscale ***/ - prop = icalproperty_new_calscale ("GREGORIAN"); - icalcomponent_add_property (comp, prop); - - /*** catagories ***/ - if (ical->categories) { - /* ical->categories is a GList of (char *) */ - GList *cur; - for (cur = ical->categories; cur; cur = cur->next) { - prop = icalproperty_new_categories ((char *) cur); - icalcomponent_add_property (comp, prop); - } - } - - /*** class ***/ - if (ical->class) { - prop = icalproperty_new_class (ical->class); - icalcomponent_add_property (comp, prop); - } - - /*** comment ***/ - if (ical->comment) { - prop = icalproperty_new_comment (ical->comment); - icalcomponent_add_property (comp, prop); - } - - /*** description ***/ - if (ical->desc) { - prop = icalproperty_new_description (ical->desc); - icalcomponent_add_property (comp, prop); - } - - /*** geo ***/ - if (ical->geo.valid) { - struct icalgeotype v; - v.lat = ical->geo.latitude; - v.lon = ical->geo.longitude; - prop = icalproperty_new_geo (v); - icalcomponent_add_property (comp, prop); - } - - /*** location ***/ - if (ical->location) { - prop = icalproperty_new_location (ical->location); - icalcomponent_add_property (comp, prop); - } - - /*** percentcomplete ***/ - prop = icalproperty_new_percentcomplete (ical->percent); - icalcomponent_add_property (comp, prop); - - /*** priority ***/ - if (ical->priority) { - prop = icalproperty_new_priority (ical->priority); - icalcomponent_add_property (comp, prop); - } - - /*** resources ***/ - if (ical->resources) { - /* ical->resources is a GList of (char *) */ - GList *cur; - for (cur = ical->resources; cur; cur = cur->next) { - prop = icalproperty_new_resources ((char *) cur); - icalcomponent_add_property (comp, prop); - } - } - - /*** status ***/ - if (ical->status) { - prop = icalproperty_new_status (ical->status); - icalcomponent_add_property (comp, prop); - } - - /*** summary ***/ - if (ical->summary) { - prop = icalproperty_new_summary (ical->summary); - icalcomponent_add_property (comp, prop); - } - - /*** completed ***/ - if (ical->completed) { - struct icaltimetype ictime; - ictime = timet_to_icaltime (ical->completed); - prop = icalproperty_new_completed (ictime); - icalcomponent_add_property (comp, prop); - } - - /*** dtend ***/ /*** due ***/ - if (ical->dtend) { - /* FIXME: We should handle timezone specifiers */ - struct icaltimetype ictime; - ictime = timet_to_icaltime (ical->dtend); - if (ical->type == ICAL_TODO) - prop = icalproperty_new_due (ictime); - else - prop = icalproperty_new_dtend (ictime); - if (ical->date_only) { - icalparameter *param; - param = icalparameter_new (ICAL_VALUE_PARAMETER); - icalparameter_set_value (param, ICAL_VALUE_DATE); - icalproperty_add_parameter (prop, param); - } - icalcomponent_add_property (comp, prop); - } - - /*** dtstart ***/ - if (ical->dtstart) { - /* FIXME: We should handle timezone specifiers */ - struct icaltimetype ictime; - ictime = timet_to_icaltime (ical->dtstart); - prop = icalproperty_new_dtstart (ictime); - if (ical->date_only) { - icalparameter *param; - param = icalparameter_new (ICAL_VALUE_PARAMETER); - icalparameter_set_value (param, ICAL_VALUE_DATE); - icalproperty_add_parameter (prop, param); - } - icalcomponent_add_property (comp, prop); - } - - /*** duration ***/ - { - /* FIX ME */ - } - - /*** freebusy ***/ - { - /* FIX ME */ - } - - /*** transp ***/ - { - if (ical->transp == ICAL_TRANSP_PROPERTY) - prop = icalproperty_new_transp ("TRANSPARENT"); - else - prop = icalproperty_new_transp ("OPAQUE"); - icalcomponent_add_property (comp, prop); - } - - /* - ICAL_TZID_PROPERTY: - ICAL_TZNAME_PROPERTY: - ICAL_TZOFFSETFROM_PROPERTY: - ICAL_TZOFFSETTO_PROPERTY: - ICAL_TZURL_PROPERTY: - */ - - /*** attendee ***/ - if (ical->attendee) { - /* a list of (iCalPerson *) */ - GList *cur; - for (cur = ical->attendee; cur; cur = cur->next) { - iCalPerson *person = (iCalPerson *) cur->data; - prop = icalproperty_new_attendee (person->addr); - unparse_person (person, prop); - icalcomponent_add_property (comp, prop); - } - } - - /*** contact ***/ - if (ical->contact) { - /* a list of (iCalPerson *) */ - GList *cur; - for (cur = ical->contact; cur; cur = cur->next) { - iCalPerson *person = (iCalPerson *) cur->data; - prop = icalproperty_new_contact (person->addr); - unparse_person (person, prop); - icalcomponent_add_property (comp, prop); - } - } - - /*** organizer ***/ - if (ical->organizer) { - prop = icalproperty_new_organizer (ical->organizer->addr); - unparse_person (ical->organizer, prop); - icalcomponent_add_property (comp, prop); - } - - /*** recurrenceid ***/ - if (ical->recurid) { - struct icaltimetype ictime; - ictime = timet_to_icaltime (ical->recurid); - prop = icalproperty_new_recurrenceid (ictime); - } - - /*** relatedto ***/ - - if (ical->related) { - /* a list of (iCalPerson *) */ - GList *cur; - for (cur = ical->related; cur; cur = cur->next) { - iCalRelation *related = (iCalRelation *) cur->data; - prop = unparse_related (related); - icalcomponent_add_property (comp, prop); - } - } - - - /*** url ***/ - if (ical->url) { - prop = icalproperty_new_url (ical->url); - icalcomponent_add_property (comp, prop); - } - - /*** uid ***/ - if (ical->uid) { - prop = icalproperty_new_uid (ical->uid); - icalcomponent_add_property (comp, prop); - } - - /*** exdate ***/ - if (ical->exdate) { - struct icaltimetype v; - GList *cur; - for (cur = ical->exdate; cur; cur = cur->next) { - time_t t = (time_t) cur->data; - v = timet_to_icaltime (t); - prop = icalproperty_new_exdate (v); - icalcomponent_add_property (comp, prop); - } - } - - /*** created ***/ - if (ical->created) { - struct icaltimetype v; - v = timet_to_icaltime (ical->created); - prop = icalproperty_new_created (v); - icalcomponent_add_property (comp, prop); - } - - /*** dtstamp ***/ - if (ical->dtstamp) { - struct icaltimetype v; - v = timet_to_icaltime (ical->dtstamp); - prop = icalproperty_new_created (v); - icalcomponent_add_property (comp, prop); - } - - /*** lastmodified ***/ - if (ical->last_mod) { - struct icaltimetype v; - v = timet_to_icaltime (ical->last_mod); - prop = icalproperty_new_created (v); - icalcomponent_add_property (comp, prop); - } - - /*** sequence ***/ - if (ical->seq) { - prop = icalproperty_new_sequence (ical->seq); - icalcomponent_add_property (comp, prop); - } - - /*** requeststatus ***/ - if (ical->rstatus) { - prop = icalproperty_new_requeststatus (ical->rstatus); - icalcomponent_add_property (comp, prop); - } - - /* if there is a VALARM subcomponent, add it here */ - - if (ical->alarms) { - GList *cur; - for (cur = ical->alarms; cur; cur = cur->next) { - CalendarAlarm *alarm = (CalendarAlarm *) cur->data; - icalcomponent *subcomp = unparse_alarm (alarm); - icalcomponent_add_component (comp, subcomp); - } - } - - return comp; -} - - -/* FIX ME -- same as icaltimetype_from_timet in icaltypes.c */ -static -struct icaltimetype timet_to_icaltime (time_t tt) -{ - struct tm *t; - struct icaltimetype i; - - //t = gmtime (&tt); - t = localtime (&tt); - - /*return tt - (i->is_utc ? timezone : 0); */ - i.is_utc = 0; - - i.year = t->tm_year + 1900; - i.month = t->tm_mon + 1; - i.day = t->tm_mday; - - if (t->tm_hour == 0 && t->tm_min == 0 && t->tm_sec == 0) { - i.is_date = 1; - i.hour = 0; - i.minute = 0; - i.second = 0; - } else { - i.is_date = 0; - i.hour = t->tm_hour; - i.minute = t->tm_min; - i.second = t->tm_sec; - } - - return i; -} - - -/* fills in "person_prop" with information from "person" */ - -static -void unparse_person (iCalPerson *person, icalproperty *person_prop) -{ - icalparameter *param; - GList *cur; - - /* convert iCalPerson to an icalproperty */ - - if (person->name) { - param = icalparameter_new_cn (person->name); - icalproperty_add_parameter (person_prop, param); - } - - if (person->role) { - if (g_strcasecmp (person->role, "CHAIR") == 0) - param = icalparameter_new_role (ICAL_ROLE_CHAIR); - else if (g_strcasecmp (person->role, "REQPARTICIPANT") == 0) - param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT); - else if (g_strcasecmp (person->role, "OPTPARTICIPANT") == 0) - param = icalparameter_new_role (ICAL_ROLE_OPTPARTICIPANT); - else if (g_strcasecmp (person->role, "NONPARTICIPANT") == 0) - param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT); - else - param = icalparameter_new_role (ICAL_ROLE_XNAME); - icalproperty_add_parameter (person_prop, param); - } - - if (person->partstat) { - if (g_strcasecmp (person->partstat, "NEEDSACTION") == 0) - param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION); - else if (g_strcasecmp (person->partstat, "ACCEPTED") == 0) - param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED); - else if (g_strcasecmp (person->partstat, "DECLINED") == 0) - param = icalparameter_new_partstat (ICAL_PARTSTAT_DECLINED); - else if (g_strcasecmp (person->partstat, "TENTATIVE") == 0) - param = icalparameter_new_partstat (ICAL_PARTSTAT_TENTATIVE); - else if (g_strcasecmp (person->partstat, "DELEGATED") == 0) - param = icalparameter_new_partstat (ICAL_PARTSTAT_DELEGATED); - else if (g_strcasecmp (person->partstat, "COMPLETED") == 0) - param = icalparameter_new_partstat (ICAL_PARTSTAT_COMPLETED); - else if (g_strcasecmp (person->partstat, "INPROCESS") == 0) - param = icalparameter_new_partstat (ICAL_PARTSTAT_INPROCESS); - else /* FIX ME, NEEDSACTION instead? */ - param = icalparameter_new_partstat (ICAL_PARTSTAT_XNAME); - icalproperty_add_parameter (person_prop, param); - } - - if (person->rsvp != FALSE) { - param = icalparameter_new_rsvp (TRUE); - icalproperty_add_parameter (person_prop, param); - } - - if (person->cutype) { - if (g_strcasecmp (person->cutype, "INDIVIDUAL") == 0) - param = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL); - else if (g_strcasecmp (person->cutype, "GROUP") == 0) - param = icalparameter_new_cutype (ICAL_CUTYPE_GROUP); - else if (g_strcasecmp (person->cutype, "RESOURCE") == 0) - param = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE); - else if (g_strcasecmp (person->cutype, "ROOM") == 0) - param = icalparameter_new_cutype (ICAL_CUTYPE_ROOM); - else /* FIX ME, INDIVIDUAL instead? */ - param = icalparameter_new_cutype (ICAL_CUTYPE_UNKNOWN); - icalproperty_add_parameter (person_prop, param); - } - - /* person->member is a list of ICAL_MEMBER_PARAMETER */ - for (cur = person->member; cur; cur = cur->next) { - gchar *member = (gchar *) cur->data; - param = icalparameter_new_member (member); - icalproperty_add_parameter (person_prop, param); - } - - /* person->deleg_to is a list of ICAL_DELEGATEDTO_PARAMETER */ - for (cur = person->deleg_to; cur; cur = cur->next) { - gchar *deleg_to = (gchar *) cur->data; - param = icalparameter_new_delegatedto (deleg_to); - icalproperty_add_parameter (person_prop, param); - } - - /* ret->deleg_from is a list of ICAL_DELEGATEDFROM_PARAMETER */ - for (cur = person->deleg_from; cur; cur = cur->next) { - gchar *deleg_from = (gchar *) cur->data; - param = icalparameter_new_delegatedfrom (deleg_from); - icalproperty_add_parameter (person_prop, param); - } - - if (person->sent_by) { - param = icalparameter_new_sentby (person->sent_by); - icalproperty_add_parameter (person_prop, param); - } - - /* ret->deleg_to is a list of ICAL_DIR_PARAMETER */ - /* FIX ME ... */ -} - - -static -icalproperty *unparse_related (iCalRelation *rel) -{ - icalproperty *prop; - - prop = icalproperty_new_relatedto (rel->reltype); - - icalproperty_set_relatedto (prop, rel->uid); - - /* FIX ME RELTYPE_XNAME ? */ - - return prop; -} - - -static -icalcomponent *unparse_alarm (CalendarAlarm *alarm) -{ - icalcomponent *comp = icalcomponent_new (ICAL_VALARM_COMPONENT); - icalproperty *prop; - - prop = NULL; - switch (alarm->type){ - case ALARM_AUDIO: - prop = icalproperty_new_action ("AUDIO"); - break; - case ALARM_DISPLAY: - prop = icalproperty_new_action ("DISPLAY"); - break; - case ALARM_MAIL: - prop = icalproperty_new_action ("EMAIL"); - break; - case ALARM_PROGRAM: - prop = icalproperty_new_action ("PROCEDURE"); - break; - default: - g_warning ("Unsupported alarm type!"); - break; - } - if (prop) - icalcomponent_add_property (comp, prop); - - if (alarm->snooze_repeat) - prop = icalproperty_new_repeat (alarm->snooze_repeat); - - if (alarm->snooze_secs) { - struct icaldurationtype dur; - dur = icaldurationtype_from_timet (alarm->snooze_secs); - prop = icalproperty_new_duration (dur); - icalcomponent_add_property (comp, prop); - } - - if (alarm->attach) { - struct icalattachtype *attach; - attach = icalattachtype_new (); - icalattachtype_set_url (attach, alarm->attach); - prop = icalproperty_new_attach (*attach); - icalattachtype_free (attach); - icalcomponent_add_property (comp, prop); - } - - if (alarm->desc) { - prop = icalproperty_new_description (alarm->desc); - icalcomponent_add_property (comp, prop); - } - - if (alarm->summary) { - prop = icalproperty_new_summary (alarm->summary); - icalcomponent_add_property (comp, prop); - } - - if (alarm->attendee) { - icalproperty_new_attendee (alarm->attendee); - icalcomponent_add_property (comp, prop); - } - - return comp; -} diff --git a/calendar/cal-util/icalendar-save.h b/calendar/cal-util/icalendar-save.h deleted file mode 100644 index 1e0ab59e70..0000000000 --- a/calendar/cal-util/icalendar-save.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ICALENDAR_SAVE_H -#define ICALENDAR_SAVE_H - -#include <ical.h> -#include <cal-util/calobj.h> - - - -icalcomponent *icalcomponent_create_from_ical_object (iCalObject *ical); - - - -#endif diff --git a/calendar/cal-util/icalendar-test.c b/calendar/cal-util/icalendar-test.c deleted file mode 100644 index 921e109a2c..0000000000 --- a/calendar/cal-util/icalendar-test.c +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <sys/stat.h> -#include <stdlib.h> -#include <unistd.h> - -#include <config.h> -#include <gtk/gtksignal.h> -#include <cal-util/calobj.h> -#include "libversit/vcc.h" - -#include "icalendar-save.h" -#include "icalendar.h" - - -static icalcomponent* -icalendar_parse_file (char* fname) -{ - FILE* fp; - icalcomponent* comp = NULL; - gchar* str; - struct stat st; - int n; - - fp = fopen (fname, "r"); - if (!fp) { - g_warning ("Cannot open open calendar file."); - return NULL; - } - - stat (fname, &st); - - str = g_malloc (st.st_size + 2); - - n = fread ((gchar*) str, 1, st.st_size, fp); - if (n != st.st_size) { - g_warning ("Read error."); - } - str[n] = '\0'; - - fclose (fp); - - comp = icalparser_parse_string (str); - g_free (str); - - return comp; -} - - -static GList * -icalendar_calendar_load (GList *icals, char *fname) -{ - icalcomponent *comp; - icalcomponent *subcomp; - iCalObject *ical; - - comp = icalendar_parse_file (fname); - subcomp = icalcomponent_get_first_component (comp, - ICAL_ANY_COMPONENT); - while (subcomp) { - ical = ical_object_create_from_icalcomponent (subcomp); - if (ical->type != ICAL_EVENT && - ical->type != ICAL_TODO && - ical->type != ICAL_JOURNAL) { - g_warning ("Skipping unsupported iCalendar component"); - } else { - printf ("prepending %p\n", ical); - icals = g_list_prepend (icals, ical); - } - subcomp = icalcomponent_get_next_component (comp, - ICAL_ANY_COMPONENT); - } - - return icals; -} - - - - -static void -icalendar_calendar_save (GList *icals, char *fname) -{ - GList *cur; - icalcomponent *top = icalcomponent_new (ICAL_VCALENDAR_COMPONENT); - char *out_cal_string; - - for (cur=icals; cur; cur=cur->next) { - iCalObject *ical = (iCalObject *) cur->data; - icalcomponent *comp; - comp = icalcomponent_create_from_ical_object (ical); - icalcomponent_add_component (top, comp); - } - - out_cal_string = icalcomponent_as_ical_string (top); - - printf ("---------------------------------------------------------\n"); - printf ("%s", out_cal_string); -} - - - -int main (int argc, char *argv[]) -{ - GList *icals = NULL; - int i; - long int n0, n1; - struct icaldurationtype dt; - - - /* test icaldurationtype_from_timet */ - srandom (time (0)); - - for (i=0; i<10; i++) { - n0 = random () % ((60 * 60 * 24 * 7) * 4); - dt = icaldurationtype_from_timet (n0); - n1 = icaldurationtype_as_timet (dt); - - printf ("%ld -> (%d %d %d %d %d) -> %ld\n", - n0, - dt.weeks, dt.days, dt.hours, dt.minutes, dt.seconds, - n1); - if (n0 != n1) abort (); - } - - /*****************/ - /* test conversion of icalcomponents to and from iCalObjects */ - /*****************/ - - /* load an ical file */ - - if (argc < 2) { - printf ("give ical file as argument.\n"); - return 1; - } - - icals = icalendar_calendar_load (icals, argv[ 1 ]); - - printf ("loaded %d ical components\n", g_list_length (icals)); - - - /* save it back out */ - - icalendar_calendar_save (icals, "out.ical"); - - return 0; -} diff --git a/calendar/cal-util/icalendar.c b/calendar/cal-util/icalendar.c deleted file mode 100644 index c43d0fba77..0000000000 --- a/calendar/cal-util/icalendar.c +++ /dev/null @@ -1,673 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * icalendar server for gnomecal - * - * This module interfaces between libical and the gnomecal internal - * representation - * - * Copyright (C) 1999 The Free Software Foundation - * Authors: - * Russell Steinthal (rms39@columbia.edu) - * - */ - -#include <config.h> -#include <unistd.h> -#include <sys/stat.h> -#include "icalendar.h" - -static time_t icaltime_to_timet (struct icaltimetype* i); -static CalendarAlarm* parse_alarm (icalproperty *prop); -static iCalPerson* parse_person (icalproperty *prop, gchar *value); -static iCalRelation* parse_related (icalproperty *prop); - -/* Duplicate a string without memory leaks */ -static gchar* copy_str (gchar** store, gchar* src) -{ - if (*store) - g_free (*store); - return (*store = g_strdup (src)); -} - -static GList* -copy_to_list (GList** store, gchar* src) -{ - *store = g_list_prepend (*store, g_strdup (src)); - return *store; -} - - -iCalObject * -ical_object_create_from_icalcomponent (icalcomponent* comp) -{ - iCalObject *ical = NULL; - iCalPerson *person; - icalcomponent *subcomp; - icalproperty *prop; - icalparameter *param; - struct icaltimetype ictime; - time_t *pt; - CalendarAlarm *alarm = NULL; - icalcomponent_kind compType; - struct icalgeotype geo; - struct icalperiodtype period; - - gboolean root = FALSE; - gboolean attachment = FALSE; - - char *tmpStr; /* this is a library-owned string */ - - ical = g_new0 (iCalObject, 1); - - compType = icalcomponent_isa (comp); - - switch (compType) { - case ICAL_XROOT_COMPONENT: - root = TRUE; - break; - case ICAL_XATTACH_COMPONENT: - attachment = TRUE; - break; - case ICAL_VEVENT_COMPONENT: - ical->type = ICAL_EVENT; - break; - case ICAL_VTODO_COMPONENT: - ical->type = ICAL_TODO; - break; - case ICAL_VJOURNAL_COMPONENT: - ical->type = ICAL_JOURNAL; - break; - case ICAL_VCALENDAR_COMPONENT: - /* FIXME: what does this mean? */ - break; - case ICAL_VFREEBUSY_COMPONENT: - ical->type = ICAL_FBREQUEST; - /* NOTE: This is not conclusive- you need to analyze - properties to determine whether this is an - FBREQUEST or an FBREPLY */ - break; - case ICAL_VTIMEZONE_COMPONENT: - ical->type = ICAL_TIMEZONE; - break; - case ICAL_VALARM_COMPONENT: - case ICAL_XAUDIOALARM_COMPONENT: - case ICAL_XDISPLAYALARM_COMPONENT: - case ICAL_XEMAILALARM_COMPONENT: - case ICAL_XPROCEDUREALARM_COMPONENT: - /* this should not be reached, since this loop should - only be processing first level components */ - break; - case ICAL_XSTANDARD_COMPONENT: - /* FIXME: what does this mean? */ - break; - case ICAL_XDAYLIGHT_COMPONENT: - /* FIXME: what does this mean? */ - break; - case ICAL_X_COMPONENT: - /* FIXME: what does this mean? */ - break; - case ICAL_VSCHEDULE_COMPONENT: - /* FIXME: what does this mean? */ - break; - case ICAL_XLICINVALID_COMPONENT: - /* FIXME: what does this mean? */ - break; - case ICAL_NO_COMPONENT: - case ICAL_ANY_COMPONENT: - /* should not occur */ - break; - case ICAL_VQUERY_COMPONENT: - case ICAL_VCAR_COMPONENT: - case ICAL_VCOMMAND_COMPONENT: - /* FIXME: what does this mean? */ - break; - } - - prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY); - while (prop) { - switch (icalproperty_isa (prop)) { - case ICAL_CALSCALE_PROPERTY: - if (g_strcasecmp (icalproperty_get_calscale (prop), - "GREGORIAN")) - g_warning ("Unknown calendar format."); - break; - case ICAL_METHOD_PROPERTY: - /* FIXME: implement something here */ - break; - case ICAL_ATTACH_PROPERTY: - /* FIXME: not yet implemented */ - break; - case ICAL_CATEGORIES_PROPERTY: - copy_to_list (&ical->categories, - icalproperty_get_categories (prop)); - break; - case ICAL_CLASS_PROPERTY: - copy_str (&ical->class, icalproperty_get_class (prop)); - break; - case ICAL_COMMENT_PROPERTY: - /*tmpStr = icalproperty_get_comment (prop);*/ - tmpStr = g_strconcat (icalproperty_get_comment (prop), - ical->comment, - NULL); - if (ical->comment) - g_free (ical->comment); - ical->comment = tmpStr; - break; - case ICAL_DESCRIPTION_PROPERTY: - copy_str (&ical->desc, - icalproperty_get_description (prop)); - break; - case ICAL_GEO_PROPERTY: - geo = icalproperty_get_geo (prop); - ical->geo.latitude = geo.lat; - ical->geo.longitude = geo.lon; - ical->geo.valid = TRUE; - break; - case ICAL_LOCATION_PROPERTY: - copy_str (&ical->location, - icalproperty_get_location (prop)); - break; - case ICAL_PERCENTCOMPLETE_PROPERTY: - ical->percent = icalproperty_get_percentcomplete (prop); - break; - case ICAL_PRIORITY_PROPERTY: - ical->priority = icalproperty_get_priority (prop); - if (ical->priority < 0 || ical->priority > 9) - g_warning ("Priority out-of-range (see RFC2445)"); - break; - case ICAL_RESOURCES_PROPERTY: - copy_to_list (&ical->resources, - icalproperty_get_resources (prop)); - break; - case ICAL_STATUS_PROPERTY: - copy_str (&ical->status, - icalproperty_get_status (prop)); - break; - case ICAL_SUMMARY_PROPERTY: - copy_str (&ical->summary, - icalproperty_get_summary (prop)); - break; - case ICAL_COMPLETED_PROPERTY: - ictime = icalproperty_get_completed (prop); - ical->completed = icaltime_to_timet (&ictime); - break; - case ICAL_DTEND_PROPERTY: - ictime = icalproperty_get_dtend (prop); - ical->dtend = icaltime_to_timet (&ictime); - param = icalproperty_get_first_parameter (prop, - ICAL_VALUE_PARAMETER); - if (param) - ical->date_only = (icalparameter_get_value (param) == ICAL_VALUE_DATE); - /* FIXME: We should handle timezone specifiers */ - break; - case ICAL_DUE_PROPERTY: - ictime = icalproperty_get_due (prop); - ical->dtend = icaltime_to_timet (&ictime); - param = icalproperty_get_first_parameter (prop, - ICAL_VALUE_PARAMETER); - ical->date_only = (icalparameter_get_value (param) == - ICAL_VALUE_DATE); - /* FIXME: We should handle timezone specifiers */ - break; - case ICAL_DTSTART_PROPERTY: - ictime = icalproperty_get_dtstart (prop); - ical->dtstart = icaltime_to_timet (&ictime); - param = icalproperty_get_first_parameter (prop, - ICAL_VALUE_PARAMETER); - if (param) - ical->date_only = (icalparameter_get_value (param) == ICAL_VALUE_DATE); - /* FIXME: We should handle timezone specifiers */ - break; - case ICAL_DURATION_PROPERTY: - /* FIXME: I don't see the necessary libical function */ - break; - case ICAL_FREEBUSY_PROPERTY: - period = icalproperty_get_freebusy (prop); - ical->dtstart = icaltime_to_timet (&(period.start)); - /* FIXME: period.end is specified as being relative - to start, so this may not be correct */ - ical->dtend = icaltime_to_timet (&(period.end)); - break; - case ICAL_TRANSP_PROPERTY: - tmpStr = icalproperty_get_transp (prop); - /* do not i18n the following string constant! */ - if (!g_strcasecmp (tmpStr, "TRANSPARENT")) - ical->transp = ICAL_TRANSPARENT; - else - ical->transp = ICAL_OPAQUE; - break; - case ICAL_TZID_PROPERTY: - case ICAL_TZNAME_PROPERTY: - case ICAL_TZOFFSETFROM_PROPERTY: - case ICAL_TZOFFSETTO_PROPERTY: - case ICAL_TZURL_PROPERTY: - /* no implementation for now */ - break; - case ICAL_ATTENDEE_PROPERTY: - tmpStr = icalproperty_get_attendee (prop); - person = parse_person (prop, tmpStr); - ical->attendee = g_list_prepend (ical->attendee, - person); - break; - case ICAL_CONTACT_PROPERTY: - tmpStr = icalproperty_get_contact (prop); - person = parse_person (prop, tmpStr); - ical->contact = g_list_prepend (ical->contact, person); - break; - case ICAL_ORGANIZER_PROPERTY: - tmpStr = icalproperty_get_organizer (prop); - person = parse_person (prop, tmpStr); - if (ical->organizer) - g_free (ical->organizer); - ical->organizer = person; - break; - case ICAL_RECURRENCEID_PROPERTY: - ictime = icalproperty_get_recurrenceid (prop); - ical->recurid = icaltime_to_timet (&ictime); - /* FIXME: Range parameter not implemented */ - break; - case ICAL_RELATEDTO_PROPERTY: - ical->related = g_list_prepend (ical->related, - parse_related (prop)); - break; - case ICAL_URL_PROPERTY: - copy_str (&ical->url, - icalproperty_get_url (prop)); - break; - case ICAL_UID_PROPERTY: - copy_str (&ical->uid, - icalproperty_get_uid (prop)); - break; - case ICAL_EXDATE_PROPERTY: - /* FIXME: This does not appear to parse - multiple exdate values in one property, as - allowed by the RFC; needs a libical fix */ - ictime = icalproperty_get_exdate (prop); - pt = g_new0 (time_t, 1); - *pt = icaltime_to_timet (&ictime); - ical->exdate = g_list_prepend (ical->exdate, pt); - break; - case ICAL_EXRULE_PROPERTY: - case ICAL_RDATE_PROPERTY: - case ICAL_RRULE_PROPERTY: - /* FIXME: need recursion processing */ - break; - case ICAL_ACTION_PROPERTY: - case ICAL_REPEAT_PROPERTY: - case ICAL_TRIGGER_PROPERTY: - /* should only occur in VALARM's, handled below */ - g_assert_not_reached(); - break; - case ICAL_CREATED_PROPERTY: - ictime = icalproperty_get_created (prop); - ical->created = icaltime_to_timet (&ictime); - break; - case ICAL_DTSTAMP_PROPERTY: - ictime = icalproperty_get_dtstamp (prop); - ical->dtstamp = icaltime_to_timet (&ictime); - break; - case ICAL_LASTMODIFIED_PROPERTY: - ictime = icalproperty_get_lastmodified (prop); - ical->last_mod = icaltime_to_timet (&ictime); - break; - case ICAL_SEQUENCE_PROPERTY: - ical->seq = icalproperty_get_sequence (prop); - break; - case ICAL_REQUESTSTATUS_PROPERTY: - copy_str (&ical->rstatus, - icalproperty_get_requeststatus (prop)); - break; - case ICAL_X_PROPERTY: - g_warning ("Unsupported X-property: %s", - icalproperty_as_ical_string (prop)); - break; - case ICAL_XLICERROR_PROPERTY: - g_warning ("Unsupported property: %s", - icalproperty_get_xlicerror (prop)); - break; - case ICAL_PRODID_PROPERTY: - case ICAL_VERSION_PROPERTY: - /* nothing to do for this property */ - break; - default: - g_warning ("Unsupported property: %s", icalproperty_as_ical_string (prop)); - break; - - } - - prop = icalcomponent_get_next_property (comp, - ICAL_ANY_PROPERTY); - } - - /* now parse subcomponents --- should only be VALARM's */ - subcomp = icalcomponent_get_first_component (comp, - ICAL_ANY_COMPONENT); - while (subcomp) { - compType = icalcomponent_isa (subcomp); - switch (compType) { - case ICAL_VALARM_COMPONENT: - alarm = parse_alarm (subcomp); - if (alarm) - ical->alarms = g_list_prepend (ical->alarms, - alarm); - break; - default: - g_warning ("Only nested VALARM components are supported."); - } - - subcomp = icalcomponent_get_next_component (comp, - ICAL_ANY_COMPONENT); - } - - return ical; -} - - -static time_t icaltime_to_timet (struct icaltimetype* i) -{ - struct tm t; - time_t ret; - - t.tm_year = i->year - 1900; - t.tm_mon = i->month - 1; - t.tm_mday = i->day; - if (!i->is_date) { - t.tm_hour = i->hour; - t.tm_min = i->minute; - t.tm_sec = i->second; - } else { - t.tm_hour = 0; - t.tm_min = 0; - t.tm_sec = 0; - } - - ret = mktime(&t); - - if (i->is_utc) { -#ifdef HAVE_TIMEZONE - extern long timezone; - ret -= timezone; -#else - struct tm *tmp; - time_t tod = time(NULL); - tmp = localtime (&tod); - ret += tmp->tm_gmtoff; -#endif - } - - return ret; -} - -static iCalPerson* -parse_person (icalproperty* prop, gchar* value) -{ - icalparameter* param; - icalparameter_role role; - icalparameter_partstat partstat; - icalparameter_cutype cutype; - - iCalPerson* ret; - - ret = g_new0 (iCalPerson, 1); - - ret->addr = g_strdup (value); - - param = icalproperty_get_first_parameter (prop, - ICAL_CN_PARAMETER); - if (param) - ret->name = g_strdup (icalparameter_get_cn (param)); - else - ret->name = NULL; - - - param = icalproperty_get_first_parameter (prop, - ICAL_ROLE_PARAMETER); - if (param) { - role = icalparameter_get_role (param); - switch (role) { - case ICAL_ROLE_CHAIR: - ret->role = g_strdup ("CHAIR"); - break; - case ICAL_ROLE_REQPARTICIPANT: - ret->role = g_strdup ("REQPARTICIPANT"); - break; - case ICAL_ROLE_OPTPARTICIPANT: - ret->role = g_strdup ("OPTPARTICIPANT"); - break; - case ICAL_ROLE_NONPARTICIPANT: - ret->role = g_strdup ("NONPARTICIPANT"); - break; - case ICAL_ROLE_XNAME: - default: - ret->role = g_strdup ("UNKNOWN"); - break; - } - } else - ret->role = g_strdup ("REQPARTICIPANT"); - - param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER); - if (param) { - partstat = icalparameter_get_partstat (param); - switch (partstat) { - case ICAL_PARTSTAT_NEEDSACTION: - ret->partstat = g_strdup ("NEEDSACTION"); - break; - case ICAL_PARTSTAT_ACCEPTED: - ret->partstat = g_strdup ("ACCEPTED"); - break; - case ICAL_PARTSTAT_DECLINED: - ret->partstat = g_strdup ("DECLINED"); - break; - case ICAL_PARTSTAT_TENTATIVE: - ret->partstat = g_strdup ("TENTATIVE"); - break; - case ICAL_PARTSTAT_DELEGATED: - ret->partstat = g_strdup ("DELEGATED"); - break; - case ICAL_PARTSTAT_COMPLETED: - ret->partstat = g_strdup ("COMPLETED"); - break; - case ICAL_PARTSTAT_INPROCESS: - ret->partstat = g_strdup ("INPROCESS"); - break; - case ICAL_PARTSTAT_XNAME: - ret->partstat = g_strdup (icalparameter_get_xvalue (param)); - break; - default: - ret->partstat = g_strdup ("UNKNOWN"); - break; - } - } else - ret->partstat = g_strdup ("NEEDSACTION"); - - param = icalproperty_get_first_parameter (prop, ICAL_RSVP_PARAMETER); - if (param) - ret->rsvp = icalparameter_get_rsvp (param); - else - ret->rsvp = FALSE; - - param = icalproperty_get_first_parameter (prop, ICAL_CUTYPE_PARAMETER -); - if (param) { - cutype = icalparameter_get_cutype (param); - switch (cutype) { - case ICAL_CUTYPE_INDIVIDUAL: - ret->cutype = g_strdup ("INDIVIDUAL"); - break; - case ICAL_CUTYPE_GROUP: - ret->cutype = g_strdup ("GROUP"); - break; - case ICAL_CUTYPE_RESOURCE: - ret->cutype = g_strdup ("RESOURCE"); - break; - case ICAL_CUTYPE_ROOM: - ret->cutype = g_strdup ("ROOM"); - break; - case ICAL_CUTYPE_UNKNOWN: - case ICAL_CUTYPE_XNAME: - default: - ret->cutype = g_strdup ("UNKNOWN"); - break; - } - } else - ret->cutype = g_strdup ("INDIVIDUAL"); - - param = icalproperty_get_first_parameter (prop, ICAL_MEMBER_PARAMETER -); - while (param) { - copy_to_list (&ret->member, icalparameter_get_member (param)); - param = icalproperty_get_next_parameter (prop, - ICAL_MEMBER_PARAMETER); - } - - param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDTO_PARAMETER); - while (param) { - copy_to_list (&ret->deleg_to, - icalparameter_get_delegatedto (param)); - param = icalproperty_get_next_parameter (prop, - ICAL_DELEGATEDTO_PARAMETER); - } - - param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDFROM_PARAMETER); - while (param) { - copy_to_list (&ret->deleg_from, - icalparameter_get_delegatedfrom (param)); - param = icalproperty_get_next_parameter (prop, - ICAL_DELEGATEDFROM_PARAMETER); - } - - param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER); - if (param) - copy_str (&ret->sent_by, icalparameter_get_sentby (param)); - else - ret->sent_by = NULL; - - param = icalproperty_get_first_parameter (prop, ICAL_DIR_PARAMETER); - while (param) { - copy_to_list (&ret->deleg_to, - icalparameter_get_delegatedto (param)); - param = icalproperty_get_next_parameter (prop, - ICAL_DIR_PARAMETER); - } - - return ret; -} - -static iCalRelation* -parse_related (icalproperty* prop) -{ - iCalRelation* rel; - icalparameter* param; - icalparameter_reltype type; - - rel = g_new0 (iCalRelation, 1); - rel->uid = g_strdup (icalproperty_get_relatedto (prop)); - - param = icalproperty_get_first_parameter (prop, - ICAL_RELTYPE_PARAMETER); - if (param) { - type = icalparameter_get_reltype (param); - switch (type) { - case ICAL_RELTYPE_PARENT: - rel->reltype = g_strdup ("PARENT"); - break; - case ICAL_RELTYPE_CHILD: - rel->reltype = g_strdup ("CHILD"); - break; - case ICAL_RELTYPE_SIBLING: - rel->reltype = g_strdup ("SIBLING"); - break; - case ICAL_RELTYPE_XNAME: - rel->reltype = g_strdup (icalparameter_get_xvalue (param)); - break; - default: - rel->reltype = g_strdup ("UNKNOWN"); - break; - } - } else - rel->reltype = g_strdup ("PARENT"); - - return rel; -} - -#ifdef TEST - -int main(int argc, char* argv[]) -{ - icalcomponent* comp; - comp = icalendar_parse_file (argv[1]); - printf ("%s\n", icalcomponent_as_ical_string (comp)); - return 0; -} - -#endif - - -static CalendarAlarm* -parse_alarm (icalcomponent* comp) -{ - CalendarAlarm *alarm; - icalproperty *prop; - char *tmpStr; - struct icaldurationtype dur; - struct icalattachtype attach; - - g_return_val_if_fail (comp != NULL, NULL); - - alarm = g_new0 (CalendarAlarm, 1); - - prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY); - while (prop) { - switch (icalproperty_isa (prop)) { - case ICAL_ACTION_PROPERTY: - tmpStr = icalproperty_get_action (prop); - if (!g_strcasecmp (tmpStr, "AUDIO")) - alarm->type = ALARM_AUDIO; - else if (!g_strcasecmp (tmpStr, "DISPLAY")) - alarm->type = ALARM_DISPLAY; - else if (!g_strcasecmp (tmpStr, "EMAIL")) - alarm->type = ALARM_MAIL; - else if (!g_strcasecmp (tmpStr, "PROCEDURE")) - alarm->type = ALARM_PROGRAM; - else - g_warning ("Unsupported alarm type!"); - break; - case ICAL_TRIGGER_PROPERTY: - /* FIXME: waiting on proper libical support */ - break; - case ICAL_REPEAT_PROPERTY: - alarm->snooze_repeat = icalproperty_get_repeat (prop); - break; - case ICAL_DURATION_PROPERTY: - dur = icalproperty_get_duration (prop); - alarm->snooze_secs = icaldurationtype_as_timet (dur); - break; - case ICAL_ATTACH_PROPERTY: - attach = icalproperty_get_attach (prop); - copy_str (&alarm->attach, - icalattachtype_get_url (&attach)); - break; - case ICAL_DESCRIPTION_PROPERTY: - copy_str (&alarm->desc, - icalproperty_get_description (prop)); - break; - case ICAL_SUMMARY_PROPERTY: - copy_str (&alarm->summary, - icalproperty_get_summary (prop)); - break; - case ICAL_ATTENDEE_PROPERTY: - copy_str (&alarm->attendee, - icalproperty_get_attendee (prop)); - break; - default: - g_warning ("Unsupported alarm property: %s", - icalproperty_as_ical_string (prop)); - break; - } - - prop = icalcomponent_get_next_property (comp, - ICAL_ANY_PROPERTY); - } - - return alarm; -} diff --git a/calendar/cal-util/icalendar.h b/calendar/cal-util/icalendar.h deleted file mode 100644 index 2a22fbab71..0000000000 --- a/calendar/cal-util/icalendar.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ICALENDAR_H -#define ICALENDAR_H - -#include <ical.h> -#include <cal-util/calobj.h> - - - -iCalObject *ical_object_create_from_icalcomponent (icalcomponent* comp); - - - -#endif diff --git a/calendar/cal-util/test-recur.c b/calendar/cal-util/test-recur.c deleted file mode 100644 index 83602bb0d6..0000000000 --- a/calendar/cal-util/test-recur.c +++ /dev/null @@ -1,337 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * This tests the recurrence rule expansion functions. - */ - -#include <config.h> -#include <string.h> -#include <time.h> -#include <glib.h> -#include "cal-recur.h" - -static void set_time (CalObjTime *cotime, gint year, gint month, gint day, - gint hour, gint minute, gint second); -static void display_occs (GArray *occs); -static GList* build_list (gint first, ...); -static gchar* time_to_string (CalObjTime *cotime); -static void do_test (gchar *description, - CalObjTime *event_start, - CalObjRecurrence *recur, - CalObjTime *interval_start, - CalObjTime *interval_end); - -#define LIST_END 999 - -static void -test_yearly () -{ - CalObjTime event_start, interval_start, interval_end; - CalObjRecurrence recur; - - set_time (&event_start, 2000, 0, 1, 0, 0, 0); - - /* We set the interval to a wide range so we just test the event. */ - set_time (&interval_start, 2000, 0, 1, 0, 0, 0); - set_time (&interval_end, 2010, 0, 1, 0, 0, 0); - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_YEARLY; - recur.interval = 3; - recur.byweekno = build_list (3, 9, 24, LIST_END); - recur.byday = build_list (3, 0, 5, 0, LIST_END); - do_test ("YEARLY every 3 years in weeks 3, 9, 24 on Thu/Sat", - &event_start, &recur, &interval_start, &interval_end); - - - set_time (&interval_end, 2002, 0, 1, 0, 0, 0); - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_YEARLY; - recur.interval = 1; - recur.bymonth = build_list (0, 6, LIST_END); - recur.byday = build_list (0, 0, 6, 0, LIST_END); - do_test ("YEARLY every year in Jan/Jul on Mon/Sun", - &event_start, &recur, &interval_start, &interval_end); - - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_YEARLY; - recur.interval = 1; - recur.bymonthday = build_list (3, 7, LIST_END); - do_test ("YEARLY every year on 3rd & 7th of the month", - &event_start, &recur, &interval_start, &interval_end); - - - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_YEARLY; - recur.interval = 1; - recur.byyearday = build_list (15, 126, 360, LIST_END); - do_test ("YEARLY every year on 15th, 126th & 360th day of the year", - &event_start, &recur, &interval_start, &interval_end); - -} - - -static void -test_monthly () -{ - CalObjTime event_start, interval_start, interval_end; - CalObjRecurrence recur; - - set_time (&event_start, 2000, 0, 1, 0, 0, 0); - - /* We set the interval to a wide range so we just test the event. */ - set_time (&interval_start, 2000, 0, 1, 0, 0, 0); - set_time (&interval_end, 2002, 0, 1, 0, 0, 0); - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_MONTHLY; - recur.interval = 1; - do_test ("MONTHLY every month", - &event_start, &recur, &interval_start, &interval_end); - -} - -static void -test_weekly () -{ - CalObjTime event_start, interval_start, interval_end; - CalObjRecurrence recur; - - set_time (&event_start, 2000, 0, 1, 0, 0, 0); - - /* We set the interval to a wide range so we just test the event. */ - set_time (&interval_start, 2000, 0, 1, 0, 0, 0); - set_time (&interval_end, 2002, 0, 1, 0, 0, 0); - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_WEEKLY; - recur.interval = 1; - do_test ("WEEKLY every week", - &event_start, &recur, &interval_start, &interval_end); - -} - -static void -test_daily () -{ - CalObjTime event_start, interval_start, interval_end; - CalObjRecurrence recur; - - set_time (&event_start, 2000, 0, 1, 0, 0, 0); - - /* We set the interval to a wide range so we just test the event. */ - set_time (&interval_start, 2000, 0, 1, 0, 0, 0); - set_time (&interval_end, 2000, 6, 1, 0, 0, 0); - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_DAILY; - recur.interval = 1; - do_test ("DAILY every day", - &event_start, &recur, &interval_start, &interval_end); - -} - -static void -test_hourly () -{ - CalObjTime event_start, interval_start, interval_end; - CalObjRecurrence recur; - - set_time (&event_start, 2000, 0, 1, 2, 15, 0); - - /* We set the interval to a wide range so we just test the event. */ - set_time (&interval_start, 2000, 0, 1, 0, 0, 0); - set_time (&interval_end, 2002, 0, 1, 0, 0, 0); - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_HOURLY; - recur.interval = 3; - recur.bymonth = build_list (3, 11, LIST_END); - recur.byday = build_list (2, 0, 4, 0, LIST_END); - do_test ("HOURLY every 3 hours in Apr/Dec on Wed & Fri", - &event_start, &recur, &interval_start, &interval_end); -} - -static void -test_minutely () -{ - CalObjTime event_start, interval_start, interval_end; - CalObjRecurrence recur; - - set_time (&event_start, 2000, 0, 1, 0, 0, 0); - - /* We set the interval to a wide range so we just test the event. */ - set_time (&interval_start, 2000, 0, 1, 0, 0, 0); - set_time (&interval_end, 2000, 0, 2, 0, 0, 0); - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_MINUTELY; - recur.interval = 45; - do_test ("MINUTELY every 45 minutes", - &event_start, &recur, &interval_start, &interval_end); -} - -static void -test_secondly () -{ - CalObjTime event_start, interval_start, interval_end; - CalObjRecurrence recur; - - set_time (&event_start, 2000, 0, 1, 0, 0, 0); - - /* We set the interval to a wide range so we just test the event. */ - set_time (&interval_start, 2000, 0, 1, 0, 0, 0); - set_time (&interval_end, 2000, 0, 2, 0, 0, 0); - - memset (&recur, 0, sizeof (recur)); - recur.type = CAL_RECUR_SECONDLY; - recur.interval = 15; - recur.byhour = build_list (2, 4, 6, LIST_END); - recur.byminute = build_list (0, 30, LIST_END); - do_test ("SECONDLY every 15 seconds at 2:00,2:30,4:00,4:30,6:00,6:30", - &event_start, &recur, &interval_start, &interval_end); -} - -int -main (int argc, char *argv[]) -{ - - test_yearly (); - test_monthly (); - test_weekly (); - test_daily (); - test_hourly (); - test_minutely (); - test_secondly (); - - return 0; -} - - -static void -set_time (CalObjTime *cotime, gint year, gint month, gint day, - gint hour, gint minute, gint second) -{ - cotime->year = year; - cotime->month = month; - cotime->day = day; - cotime->hour = hour; - cotime->minute = minute; - cotime->second = second; -} - - -static GList* -build_list (gint first, ...) -{ - va_list args; - GList *list; - gint num; - - va_start (args, first); - - list = g_list_prepend (NULL, GINT_TO_POINTER (first)); - - num = va_arg (args, gint); - while (num != LIST_END) { - list = g_list_prepend (list, GINT_TO_POINTER (num)); - num = va_arg (args, gint); - } - - list = g_list_reverse (list); - - va_end (args); - - return list; -} - - -static void -do_test (gchar *description, - CalObjTime *event_start, - CalObjRecurrence *recur, - CalObjTime *interval_start, - CalObjTime *interval_end) -{ - GArray *occs; - - g_print ("========================================================\n"); - g_print ("%s\n", description); - g_print ("(From %s", time_to_string (interval_start)); - g_print (" To %s)\n\n", time_to_string (interval_end)); - - occs = cal_obj_expand_recurrence (event_start, recur, - interval_start, interval_end); - display_occs (occs); - g_array_free (occs, TRUE); -} - - -static gchar* -time_to_string (CalObjTime *cotime) -{ - static gchar buffer[64]; - gint month; - gchar *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "XXX" }; - - month = cotime->month; - if (month < 0 || month > 12) - month = 12; - - sprintf (buffer, "%s %2i %02i:%02i:%02i %4i", - months[month], cotime->day, - cotime->hour, cotime->minute, cotime->second, - cotime->year); - - return buffer; -} - -static void -display_occs (GArray *occs) -{ - CalObjTime *occ; - gint len, i; - struct tm t; - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - t.tm_sec = occ->second; - t.tm_min = occ->minute; - t.tm_hour = occ->hour; - t.tm_mday = occ->day; - t.tm_mon = occ->month; - t.tm_year = occ->year - 1900; - t.tm_isdst = -1; - - mktime (&t); - - g_print ("%s", asctime (&t)); - } -} diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c deleted file mode 100644 index bbce9b82d6..0000000000 --- a/calendar/cal-util/timeutil.c +++ /dev/null @@ -1,590 +0,0 @@ -/* Miscellaneous time-related utilities - * - * Copyright (C) 1998 The Free Software Foundation - * - * Authors: Federico Mena <federico@nuclecu.unam.mx> - * Miguel de Icaza <miguel@nuclecu.unam.mx> - */ - -#include <libgnome/libgnome.h> -#include <string.h> -#include "timeutil.h" - - - -/** - * time_from_icaltimetype: - * @itt: A struct icaltimetype value. - * - * Converts a struct icaltimetype value into a time_t value. Does not deal with - * timezones. - * - * Return value: A time_t value. - **/ -time_t -time_from_icaltimetype (struct icaltimetype itt) -{ - struct tm tm; - - /* FIXME: this does not handle timezones */ - - memset (&tm, 0, sizeof (tm)); - - tm.tm_year = itt.year - 1900; - tm.tm_mon = itt.month - 1; - tm.tm_mday = itt.day; - - if (!itt.is_date) { - tm.tm_hour = itt.hour; - tm.tm_min = itt.minute; - tm.tm_sec = itt.second; - } - - return mktime (&tm); -} - -#define digit_at(x,y) (x [y] - '0') - -time_t -time_from_isodate (char *str) -{ - struct tm my_tm; - time_t t; - - if (strlen (str) < 14) - return -1; - - my_tm.tm_year = (digit_at (str, 0) * 1000 + digit_at (str, 1) * 100 + - digit_at (str, 2) * 10 + digit_at (str, 3)) - 1900; - - my_tm.tm_mon = digit_at (str, 4) * 10 + digit_at (str, 5) - 1; - my_tm.tm_mday = digit_at (str, 6) * 10 + digit_at (str, 7); - my_tm.tm_hour = digit_at (str, 9) * 10 + digit_at (str, 10); - my_tm.tm_min = digit_at (str, 11) * 10 + digit_at (str, 12); - my_tm.tm_sec = digit_at (str, 13) * 10 + digit_at (str, 14); - my_tm.tm_isdst = -1; - - t = mktime (&my_tm); - - if (str [15] == 'Z') -#if defined(HAVE_TM_GMTOFF) - t -= my_tm.tm_gmtoff -#elsif defined(HAVE_TIMEZONE) - t -= timezone -#endif - ; - - return t; -} - -void -print_time_t (time_t t) -{ - struct tm *tm = localtime (&t); - - printf ("TIEMPO: %d/%d/%d %d:%d:%d\n", - tm->tm_mon+1, tm->tm_mday, tm->tm_year, - tm->tm_hour, tm->tm_min, tm->tm_sec); -} - -int -get_time_t_hour (time_t t) -{ - struct tm *tm; - - tm = localtime (&t); - return tm->tm_hour; -} - -char * -isodate_from_time_t (time_t t) -{ - struct tm *tm; - static char isotime [40]; - - tm = localtime (&t); - strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%S", tm); - return isotime; -} - -time_t -time_from_start_duration (time_t start, char *duration) -{ - printf ("Not yet implemented\n"); - return 0; -} - -char * -format_simple_hour (int hour, int use_am_pm) -{ - static char buf[256]; - - /* I don't know whether this is the best way to internationalize it. - * Does any language use different conventions? - Federico - */ - - if (use_am_pm) - g_snprintf (buf, sizeof(buf), "%d%s", - (hour == 0) ? 12 : (hour > 12) ? (hour - 12) : hour, - (hour < 12) ? _("am") : _("pm")); - else - g_snprintf (buf, sizeof(buf), "%02d%s", hour, _("h")); - - return buf; - -} - -time_t -time_add_minutes (time_t time, int minutes) -{ - struct tm *tm = localtime (&time); - time_t new_time; - - tm->tm_min += minutes; - if ((new_time = mktime (tm)) == -1){ - g_message ("time_add_minutes(): mktime() could not handle " - "adding %d minutes with\n", minutes); - print_time_t (time); - return time; - } - return new_time; -} - -/* Adds a day onto the time, using local time. - Note that if clocks go forward due to daylight savings time, there are - some non-existent local times, so the hour may be changed to make it a - valid time. This also means that it may not be wise to keep calling - time_add_day() to step through a certain period - if the hour gets changed - to make it valid time, any further calls to time_add_day() will also return - this hour, which may not be what you want. */ -time_t -time_add_day (time_t time, int days) -{ - struct tm *tm = localtime (&time); - time_t new_time; -#if 0 - int dst_flag = tm->tm_isdst; -#endif - - tm->tm_mday += days; - - if ((new_time = mktime (tm)) == -1){ - g_message ("time_add_day(): mktime() could not handling adding %d days with\n", - days); - print_time_t (time); - return time; - } - -#if 0 - /* I don't know what this is for. See also time_day_begin() and - time_day_end(). - Damon. */ - if (dst_flag > tm->tm_isdst){ - tm->tm_hour++; - new_time += 3600; - } else if (dst_flag < tm->tm_isdst){ - tm->tm_hour--; - new_time -= 3600; - } -#endif - - return new_time; -} - -time_t -time_add_week (time_t time, int weeks) -{ - return time_add_day (time, weeks * 7); -} - -time_t -time_add_month (time_t time, int months) -{ - struct tm *tm = localtime (&time); - time_t new_time; - int mday; - - mday = tm->tm_mday; - - tm->tm_mon += months; - tm->tm_isdst = -1; - if ((new_time = mktime (tm)) == -1){ - g_message ("time_add_month(): mktime() could not handling adding %d months with\n", - months); - print_time_t (time); - return time; - } - tm = localtime (&new_time); - if (tm->tm_mday < mday){ - tm->tm_mon--; - tm->tm_mday = time_days_in_month (tm->tm_year+1900, tm->tm_mon); - return new_time = mktime (tm); - } - else - return new_time; -} - -time_t -time_add_year (time_t time, int years) -{ - struct tm *tm = localtime (&time); - time_t new_time; - - tm->tm_year += years; - if ((new_time = mktime (tm)) == -1){ - g_message ("time_add_year(): mktime() could not handling adding %d years with\n", - years); - print_time_t (time); - return time; - } - return new_time; -} - -time_t -time_day_hour (time_t t, int hour) -{ - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = hour; - tm.tm_min = 0; - tm.tm_sec = 0; - - return mktime (&tm); -} - -/* Number of days in a month, for normal and leap years */ -static const int days_in_month[2][12] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -/* Returns whether the specified year is a leap year */ -static int -is_leap_year (int year) -{ - if (year <= 1752) - return !(year % 4); - else - return (!(year % 4) && (year % 100)) || !(year % 400); -} - -int -time_days_in_month (int year, int month) -{ - g_return_val_if_fail (year >= 1900, 0); - g_return_val_if_fail ((month >= 0) && (month < 12), 0); - - return days_in_month [is_leap_year (year)][month]; -} - -time_t -time_from_day (int year, int month, int day) -{ - struct tm tm; - - memset (&tm, 0, sizeof (tm)); - tm.tm_year = year - 1900; - tm.tm_mon = month; - tm.tm_mday = day; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -time_t -time_year_begin (time_t t) -{ - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_mon = 0; - tm.tm_mday = 1; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -time_t -time_year_end (time_t t) -{ - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_mon = 0; - tm.tm_mday = 1; - tm.tm_year++; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -time_t -time_month_begin (time_t t) -{ - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_mday = 1; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -time_t -time_month_end (time_t t) -{ - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_mday = 1; - tm.tm_mon++; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -time_t -time_week_begin (time_t t) -{ - struct tm tm; - - /* FIXME: make it take week_starts_on_monday into account */ - - tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_mday -= tm.tm_wday; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -time_t -time_week_end (time_t t) -{ - struct tm tm; - - /* FIXME: make it take week_starts_on_monday into account */ - - tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_mday += 7 - tm.tm_wday; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -/* Returns the start of the day, according to the local time. */ -time_t -time_day_begin (time_t t) -{ -#if 1 - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_isdst = -1; - - return mktime (&tm); - -#else - /* This is the original code which sometimes produces a time of 1:00. - I don't understand why it looked at the tm_isdst flags at all. - - Damon. */ - - struct tm tm; - time_t temp = t - 43200; - int dstflag, dstflag2; - - tm = *localtime(&temp); /* one day */ - dstflag = tm.tm_isdst; - - tm = *localtime (&t); - dstflag2 = tm.tm_isdst; - - if (dstflag < dstflag2) - tm.tm_hour = 1; - else - tm.tm_hour = 0; - - tm.tm_min = 0; - tm.tm_sec = 0; - - temp = mktime(&tm); - if (dstflag > dstflag2){ - temp += 3600; - } - - return temp; -#endif -} - -/* Returns the end of the day, according to the local time. */ -time_t -time_day_end (time_t t) -{ -#if 1 - struct tm tm; - - tm = *localtime (&t); - tm.tm_mday++; - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_isdst = -1; - - return mktime (&tm); - -#else - /* This is the original code which has more problems than - time_day_begin(). - Damon. */ - - struct tm tm; - time_t temp; - int dstflag, dstflag2; - - t += 10800; - temp = t - 86400; - - tm = *localtime(&temp); /* one day */ - dstflag = tm.tm_isdst; - - tm = *localtime (&t); - dstflag2 = tm.tm_isdst; - - if (dstflag < dstflag2) - tm.tm_hour = 23; - else { - tm.tm_mday++; - tm.tm_hour = 0; - } - tm.tm_min = 0; - tm.tm_sec = 0; - - temp = mktime(&tm); - if(dstflag > dstflag2) { - } - return temp; -#endif -} - -static char * -pcat (char *dest, int num, char key) -{ - int c; - - c = sprintf (dest, "%d%c", num, key); - return dest + c; -} - -/* Converts secs into the ISO difftime representation */ -char * -isodiff_from_secs (int secs) -{ - static char buffer [60], *p; - int years, months, weeks, days, hours, minutes; - - years = months = weeks = days = hours = minutes = 0; - - years = secs / (365 * 86400); - secs %= (365 * 86400); - months = secs / (30 * 86400); - secs %= (30 * 86400); - weeks = secs / (7 * 86400); - secs %= (7 * 86400); - days = secs / 86400; - secs %= 86400; - hours = secs / 3600; - secs %= 3600; - minutes = secs / 60; - secs %= 60; - - strcpy (buffer, "P"); - p = buffer + 1; - if (years) - p = pcat (p, years, 'Y'); - if (months) - p = pcat (p, months, 'M'); - if (weeks) - p = pcat (p, weeks, 'W'); - if (days) - p = pcat (p, days, 'D'); - if (hours || minutes || secs){ - *p++ = 'T'; - if (hours) - p = pcat (p, hours, 'H'); - if (minutes) - p = pcat (p, minutes, 'M'); - if (secs) - p = pcat (p, secs, 'S'); - } - - return buffer; -} - -int -isodiff_to_secs (char *str) -{ - int value, time; - int years, months, weeks, days, hours, minutes, seconds; - - value = years = months = weeks = days = hours = minutes = time = seconds = 0; - if (*str != 'P') - return 0; - - str++; - while (*str){ - switch (*str){ - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - value = value * 10 + (*str - '0'); - break; - case 'Y': - years = value; value = 0; - break; - case 'M': - if (time) - minutes = value; - else - months = value; - value = 0; - break; - case 'W': - weeks = value; value = 0; - break; - case 'D': - days = value; value = 0; - break; - case 'T': - value = 0; time = 1; - break; - case 'H': - hours = value; value = 0; - break; - case 'S': - seconds = value; value = 0; - break; - } - str++; - } - return seconds + (minutes * 60) + (hours * 3600) + - (days * 86400) + (weeks * 7 * 86400) + - (months * 30 * 86400) + (years * 365 * 86400); -} diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h deleted file mode 100644 index 37b70ee6cf..0000000000 --- a/calendar/cal-util/timeutil.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Miscellaneous time-related utilities - * - * Copyright (C) 1998 The Free Software Foundation - * - * Authors: Federico Mena <federico@nuclecu.unam.mx> - * Miguel de Icaza <miguel@nuclecu.unam.mx> - */ - -#ifndef TIMEUTIL_H -#define TIMEUTIL_H - - -#include <time.h> -#include <icaltypes.h> - - -time_t time_from_icaltimetype (struct icaltimetype itt); -time_t time_from_isodate (char *str); -time_t time_from_start_duration (time_t start, char *duration); -char *isodate_from_time_t (time_t t); -int get_time_t_hour (time_t t); -int isodiff_to_secs (char *str); -char *isodiff_from_secs (int secs); - -time_t time_add_minutes (time_t time, int minutes); -time_t time_add_day (time_t time, int days); -time_t time_add_week (time_t time, int weeks); -time_t time_add_month (time_t time, int months); -time_t time_add_year (time_t time, int years); - - -/* Returns pointer to a statically-allocated buffer with a string of the form - * 3am, 4am, 12pm, 08h, 17h, etc. - * The string is internationalized, hopefully correctly. - */ -char *format_simple_hour (int hour, int use_am_pm); - -/* Returns the number of days in the specified month. Years are full years (starting from year 1). - * Months are in [0, 11]. - */ -int time_days_in_month (int year, int month); - -/* Converts the specified date to a time_t at the start of the specified day. Years are full years - * (starting from year 1). Months are in [0, 11]. Days are 1-based. - */ -time_t time_from_day (int year, int month, int day); - -time_t time_day_hour (time_t t, int hour); - -/* For the functions below, time ranges are considered to contain the start time, but not the end - * time. - */ - -/* These two functions take a time value and return the beginning or end of the corresponding year, - * respectively. - */ -time_t time_year_begin (time_t t); -time_t time_year_end (time_t t); - -/* These two functions take a time value and return the beginning or end of the corresponding month, - * respectively. - */ -time_t time_month_begin (time_t t); -time_t time_month_end (time_t t); - -/* These functions take a time value and return the beginning or end of the corresponding week, - * respectively. This takes into account the global week_starts_on_monday flag. - */ -time_t time_week_begin (time_t t); -time_t time_week_end (time_t t); - -/* These two functions take a time value and return the beginning or end of the corresponding day, - * respectively. - */ -time_t time_day_begin (time_t t); -time_t time_day_end (time_t t); - -time_t parse_date (char *str); -void print_time_t (time_t t); - - -#endif diff --git a/calendar/conduits/.cvsignore b/calendar/conduits/.cvsignore deleted file mode 100644 index b840c21800..0000000000 --- a/calendar/conduits/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile
\ No newline at end of file diff --git a/calendar/conduits/Makefile.am b/calendar/conduits/Makefile.am deleted file mode 100644 index 906ea61971..0000000000 --- a/calendar/conduits/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = calendar todo diff --git a/calendar/conduits/calendar/.cvsignore b/calendar/conduits/calendar/.cvsignore deleted file mode 100644 index 0029a85a37..0000000000 --- a/calendar/conduits/calendar/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile.in -Makefile -.deps -calendar.conduit -*.lo -.libs -libcalendar_conduit.la -calendar-conduit-control-applet diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am deleted file mode 100644 index 1aa9abecd6..0000000000 --- a/calendar/conduits/calendar/Makefile.am +++ /dev/null @@ -1,81 +0,0 @@ -# -# -# - -INCLUDES = \ - -I$(top_srcdir)/calendar \ - $(GNOME_PILOT_CFLAGS) - -file_conduitsdir=$(libdir)/gnome-pilot/conduits - -bin_PROGRAMS = calendar-conduit-control-applet - -calendar_conduit_control_applet_SOURCES = calendar-conduit-control-applet.c - -calendar_conduit_control_applet_LDADD = \ - $(CAPPLET_LIBS) \ - $(GNOME_LIBDIR) \ - -lgpilotdcm \ - -lgpilotd \ - -lgpilotdconduit \ - $(GNOME_CAPPLET_LIBS) \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(GNOME_XML_LIB) \ - $(GNOMEUI_LIBS) \ - $(PISOCK_LIBDIR) $(PISOCK_LIBS) \ - $(INTLLIBS) - - -# $(top_builddir)/libgpilotdCM/libgpilotdcm.la \ -# $(top_builddir)/gpilotd/libgpilotd.la \ -# $(top_builddir)/gpilotd/libgpilotdconduit.la \ - - -# calendar_conduit -calendar_conduitsdir=$(libdir)/gnome-pilot/conduits -calendar_conduits_LTLIBRARIES = libcalendar_conduit.la - -libcalendar_conduit_la_SOURCES = \ - calendar-conduit.c - -# calendar-conduit.c: my_gnomecal_idl - -calendar.conduit: calendar.conduit.in Makefile - sed -e 's^\@prefix\@^$(prefix)^g' < $(srcdir)/calendar.conduit.in > calendar.conduit.tmp \ - && mv calendar.conduit.tmp calendar.conduit - -# -# conduit -# - -libcalendar_conduit_la_LDFLAGS = \ - -rpath $(libdir) - -libcalendar_conduit_la_LIBADD = \ - $(top_builddir)/calendar/cal-client/libcal-client-static.la \ - $(top_builddir)/calendar/cal-util/libcal-util-static.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical-static.la \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(PISOCK_LIBDIR) $(PISOCK_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOME_LIBS) - -ccenterdir = $(datadir)/control-center -ccenterPalmPilotdir = $(ccenterdir)/Peripherals -ccenterConduitsdir = $(ccenterPalmPilotdir)/Conduits -ccenterConduits_DATA = calendar-conduit-control-applet.desktop - -panelConduitsdir = $(datadir)/gnome/apps/Settings/Peripherals/Conduits -panelConduits_DATA = $(ccenterConduits_DATA) - -Conduitdir = $(datadir)/gnome-pilot/conduits/ -Conduit_DATA = calendar.conduit - -EXTRA_DIST = \ - calendar.conduit.in \ - $(ccenterConduits_DATA) - -install-data-local: - $(mkinstalldirs) $(ccenterConduitsdir) - $(mkinstalldirs) $(Conduitdir) diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.c b/calendar/conduits/calendar/calendar-conduit-control-applet.c deleted file mode 100644 index 291d429bab..0000000000 --- a/calendar/conduits/calendar/calendar-conduit-control-applet.c +++ /dev/null @@ -1,387 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Control applet ("capplet") for the gnome-pilot calendar conduit, */ -/* based on */ -/* gpilotd control applet ('capplet') for use with the GNOME control center */ - -#include <pwd.h> -#include <sys/types.h> -#include <signal.h> -#include <gnome.h> - -#include <config.h> -#include <capplet-widget.h> - -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> -#include <gpilotd/gnome-pilot-client.h> - -#include "calendar-conduit.h" - - -/* tell changes callbacks to ignore changes or not */ -static gboolean ignore_changes=FALSE; - -/* capplet widget */ -static GtkWidget *capplet=NULL; - -/* host/device/pilot configuration windows */ -GtkWidget *cfgOptionsWindow=NULL; -GtkWidget *cfgStateWindow=NULL; -GtkWidget *dialogWindow=NULL; - -gboolean activated,org_activation_state; -GnomePilotConduitManagement *conduit; -GnomePilotConduitConfig *conduit_config; -GCalConduitCfg *origState = NULL; -GCalConduitCfg *curState = NULL; - -static void doTrySettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg); -static void doRevertSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg); -static void doSaveSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg); - -//static void readStateCfg (GtkWidget *w, GCalConduitCfg *c); -static void setStateCfg (GtkWidget *w, GCalConduitCfg *c); - -gint pilotId; -/* CORBA_Environment ev; */ -static GnomePilotClient *gpc; - - - -/* This array must be in the same order as enumerations - in GnomePilotConduitSyncType as they are used as index. - Custom type implies Disabled state. -*/ -static gchar* sync_options[] ={ N_("Disabled"), - N_("Synchronize"), - N_("Copy From Pilot"), - N_("Copy To Pilot"), - N_("Merge From Pilot"), - N_("Merge To Pilot")}; -#define SYNC_OPTIONS_COUNT 6 - - - - -/* Saves the configuration data. */ -static void -gcalconduit_save_configuration(GCalConduitCfg *c) -{ - gchar prefix[256]; - - g_snprintf(prefix,255,"/gnome-pilot.d/calendar-conduit/Pilot_%u/",c->pilotId); - - gnome_config_push_prefix(prefix); - gnome_config_set_bool ("open_secret", c->open_secret); - gnome_config_pop_prefix(); - - gnome_config_sync(); - gnome_config_drop_all(); -} - -/* Creates a duplicate of the configuration data */ -static GCalConduitCfg* -gcalconduit_dupe_configuration(GCalConduitCfg *c) { - GCalConduitCfg *retval; - g_return_val_if_fail(c!=NULL,NULL); - retval = g_new0(GCalConduitCfg,1); - retval->sync_type = c->sync_type; - retval->open_secret = c->open_secret; - retval->pilotId = c->pilotId; - return retval; -} - - -static void -doTrySettings(GtkWidget *widget, GCalConduitCfg *c) -{ - /* - readStateCfg (cfgStateWindow, curState); - if (activated) - gnome_pilot_conduit_config_enable (conduit_config, GnomePilotConduitSyncTypeCustom); - else - gnome_pilot_conduit_config_disable (conduit_config); - */ - - if (c->sync_type!=GnomePilotConduitSyncTypeCustom) - gnome_pilot_conduit_config_enable_with_first_sync (conduit_config, - c->sync_type, - c->sync_type, - TRUE); - else - gnome_pilot_conduit_config_disable (conduit_config); - - gcalconduit_save_configuration (c); -} - - -static void -doSaveSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg) -{ - doTrySettings(widget, GCalConduitCfg); - gcalconduit_save_configuration(GCalConduitCfg); -} - - -static void -doCancelSettings(GtkWidget *widget, GCalConduitCfg *c) -{ - doSaveSettings (widget, c); -} - - -static void -doRevertSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg) -{ - activated = org_activation_state; - setStateCfg (cfgStateWindow, curState); -} - -static void -about_cb (GtkWidget *widget, gpointer data) -{ - GtkWidget *about; - const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL}; - - about = gnome_about_new (_("Gpilotd calendar conduit"), VERSION, - _("(C) 1998 the Free Software Foundation"), - authors, - _("Configuration utility for the calendar conduit.\n"), - _("gnome-unknown.xpm")); - gtk_widget_show (about); - - return; -} - - -/* called by the sync_type GtkOptionMenu */ -static void -sync_action_selection(GtkMenuShell *widget, gpointer unused) -{ - if (!ignore_changes) { - capplet_widget_state_changed(CAPPLET_WIDGET (capplet), TRUE); - } -} - - -/* called by the sync_type GtkOptionMenu */ -static void -activate_sync_type(GtkMenuItem *widget, gpointer data) -{ - curState->sync_type = GPOINTER_TO_INT(data); - if(!ignore_changes) - capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); -} - - -static GtkWidget -*createStateCfgWindow(void) -{ - GtkWidget *vbox, *table; - GtkWidget *label; - GtkWidget *optionMenu,*menuItem; - GtkMenu *menu; - gint i; - - vbox = gtk_vbox_new(FALSE, GNOME_PAD); - - table = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD); - - label = gtk_label_new(_("Synchronize Action")); - gtk_box_pack_start(GTK_BOX(table), label, FALSE, FALSE, GNOME_PAD); - - optionMenu=gtk_option_menu_new(); - gtk_object_set_data(GTK_OBJECT(vbox), "conduit_state", optionMenu); - menu = GTK_MENU(gtk_menu_new()); - - for (i=0; i<SYNC_OPTIONS_COUNT;i++) { - sync_options[i]=_(sync_options[i]); - menuItem = gtk_menu_item_new_with_label(sync_options[i]); - gtk_widget_show(menuItem); - gtk_signal_connect(GTK_OBJECT(menuItem),"activate", - GTK_SIGNAL_FUNC(activate_sync_type), - GINT_TO_POINTER(i)); - gtk_menu_append(menu,menuItem); - } - - gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu)); - gtk_signal_connect(GTK_OBJECT(menu), "selection-done", - GTK_SIGNAL_FUNC(sync_action_selection), - NULL); - - gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0); - - return vbox; -} - - -static void -setStateCfg (GtkWidget *w, GCalConduitCfg *c) -{ - GtkOptionMenu *optionMenu; - GtkMenu *menu; - - optionMenu = gtk_object_get_data (GTK_OBJECT(w), "conduit_state"); - g_assert (optionMenu != NULL); - menu = GTK_MENU (gtk_option_menu_get_menu (optionMenu)); - - ignore_changes = TRUE; - /* Here were are relying on the items in menu being the same - order as in GnomePilotConduitSyncType. */ - gtk_option_menu_set_history (optionMenu, (int) c->sync_type); - ignore_changes = FALSE; -} - - -#if 0 -static void -readStateCfg (GtkWidget *w, GCalConduitCfg *c) -{ - /* - GtkWidget *button; - button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off"); - g_assert(button!=NULL); - activated = GTK_TOGGLE_BUTTON(button)->active; - */ -} -#endif /* 0 */ - - -static void -pilot_capplet_setup(void) -{ - GtkWidget *frame, *table; - - capplet = capplet_widget_new(); - - table = gtk_table_new(1, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD); - gtk_container_add(GTK_CONTAINER(capplet), table); - - frame = gtk_frame_new(_("Conduit state")); - gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL); - gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1); - cfgStateWindow = createStateCfgWindow(); - gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow); - - gtk_signal_connect(GTK_OBJECT(capplet), "try", - GTK_SIGNAL_FUNC(doTrySettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "revert", - GTK_SIGNAL_FUNC(doRevertSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "ok", - GTK_SIGNAL_FUNC(doSaveSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "cancel", - GTK_SIGNAL_FUNC(doCancelSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "help", - GTK_SIGNAL_FUNC(about_cb), NULL); - - - setStateCfg (cfgStateWindow, curState); - - gtk_widget_show_all (capplet); -} - - -static void -run_error_dialog(gchar *mesg,...) -{ - char tmp[80]; - va_list ap; - - va_start(ap,mesg); - vsnprintf(tmp,79,mesg,ap); - dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL); - gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow)); - va_end(ap); -} - - -static gint -get_pilot_id_from_gpilotd() -{ - GList *pilots=NULL; - gint pilot; - int i,err; - - i=0; - /* we don't worry about leaking here, so pilots isn't freed */ - switch(err = gnome_pilot_client_get_pilots(gpc,&pilots)) { - case GPILOTD_OK: { - if(pilots) { - for(i=0;i<g_list_length(pilots);i++) { - g_message("pilot %d = \"%s\"",i,(gchar*)g_list_nth(pilots,i)->data); - } - if(i==0) { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } else { - gnome_pilot_client_get_pilot_id_by_name(gpc, - pilots->data, /* this is the first pilot */ - &pilot); - if(i>1) { - g_message("too many pilots..."); - /* need a choose here */ - } - return pilot; - } - } else { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } - break; - } - case GPILOTD_ERR_NOT_CONNECTED: - run_error_dialog(_("Not connected to the gnome-pilot daemon")); - return -1; - break; - default: - g_warning("gnome_pilot_client_get_pilot_ids(...) = %d",err); - run_error_dialog(_("An error occured when trying to fetch\npilot list from the gnome-pilot daemon")); - return -1; - break; - } -} - - -int -main (int argc, char *argv[]) -{ - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - - /* we're a capplet */ - gnome_capplet_init ("calendar conduit control applet", NULL, argc, argv, - NULL, 0, NULL); - - - gpc = gnome_pilot_client_new(); - gnome_pilot_client_connect_to_daemon(gpc); - pilotId = get_pilot_id_from_gpilotd(); - if(!pilotId) return -1; - - /* put all code to set things up in here */ - gcalconduit_load_configuration (&origState, pilotId); - - conduit = gnome_pilot_conduit_management_new ("Calendar", GNOME_PILOT_CONDUIT_MGMT_ID); - if (conduit == NULL) return -1; - conduit_config = gnome_pilot_conduit_config_new (conduit, pilotId); - org_activation_state = gnome_pilot_conduit_config_is_enabled (conduit_config, - &origState->sync_type); - activated = org_activation_state; - - //gpilotd_conduit_mgmt_get_sync_type (conduit, pilotId, &origState->sync_type); - - curState = gcalconduit_dupe_configuration(origState); - - pilot_capplet_setup (); - - - /* done setting up, now run main loop */ - capplet_gtk_main(); - - gnome_pilot_conduit_management_destroy(conduit); - - return 0; -} diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop b/calendar/conduits/calendar/calendar-conduit-control-applet.desktop deleted file mode 100644 index 15fd0dc77b..0000000000 --- a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop +++ /dev/null @@ -1,13 +0,0 @@ -[Desktop Entry] -Name=Calendar conduit -Name[da]=Gnome kalender -Name[no]=GNOME kalender -Name[tr]=Takvim parçasý -Comment=Configure the GnomeCal conduit -Comment[da]=Konfigurér GnomeCal-komponent -Comment[no]=Konfigurér GnomeCal-komponent -Comment[tr]=GnomeCal takvim parçasý ayarlarý -Exec=calendar-conduit-control-applet --cap-id=1 -Terminal=0 -Type=Application -Icon=gnome-calendar-conduit.png diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c deleted file mode 100644 index 8094fee315..0000000000 --- a/calendar/conduits/calendar/calendar-conduit.c +++ /dev/null @@ -1,1727 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include <sys/stat.h> -#include <utime.h> -#include <unistd.h> -#include <pwd.h> -#include <signal.h> -#include <errno.h> - -#include <cal-client/cal-client.h> -// #include <cal-util/calobj.h> -#include <cal-util/timeutil.h> -#include <pi-source.h> -#include <pi-socket.h> -#include <pi-file.h> -#include <pi-dlp.h> -#include <libgnorba/gnorba.h> -#include <libgnorba/gnome-factory.h> -#include <pi-version.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-standard-abs.h> -#include <calendar-conduit.h> - -#include <bonobo.h> - -GnomePilotConduit * conduit_get_gpilot_conduit (guint32); -void conduit_destroy_gpilot_conduit (GnomePilotConduit*); -void local_record_from_icalobject (GCalLocalRecord *local, CalComponent *obj); - -#define CONDUIT_VERSION "0.8.11" -#ifdef G_LOG_DOMAIN -#undef G_LOG_DOMAIN -#endif -#define G_LOG_DOMAIN "gcalconduit" - -#define DEBUG_CALCONDUIT -#undef DEBUG_CALCONDUIT - -#ifdef DEBUG_CALCONDUIT -#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e)) -#define LOG(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e) -#else -#define show_exception(e) -#define LOG(e...) -#endif - -#define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e) -#define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e) - -#define catch_ret_val(_env,ret) \ - if (_env._major != CORBA_NO_EXCEPTION) { \ - g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \ - g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \ - CORBA_exception_free(&(_env)); \ - return ret; \ - } - - - - -/* debug spew DELETE ME */ -static char *print_ical (CalComponent *obj) -{ - static char buff[ 4096 ]; - CalComponentText summary; - GSList *comments; - CalComponentText *first_comment = NULL; - - if (obj == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - cal_component_get_summary (obj, &summary); - cal_component_get_comment_list (obj, &comments); - if (comments) - first_comment = (CalComponentText *) comments->data; - - - sprintf (buff, "['%s' '%s']", - summary.value, /* description */ - first_comment ? first_comment->value : "" /* note */); - return buff; -} - - -/* debug spew DELETE ME */ -static char *print_local (GCalLocalRecord *local) -{ - static char buff[ 4096 ]; - - if (local == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - if (local->a && local->a->description) { - sprintf (buff, "['%s' '%s']", - local->a->description, - local->a->note); - return buff; - } - - return print_ical (local->ical); -} - - -/* debug spew DELETE ME */ -static char *print_remote (PilotRecord *remote) -{ - static char buff[ 4096 ]; - struct Appointment a; - - if (remote == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - memset (&a, 0, sizeof (struct Appointment)); - unpack_Appointment (&a, remote->record, remote->length); - - sprintf (buff, "['%s' '%s']", - a.description, - a.note); - - return buff; -} - - - -/* Destroys any data allocated by gcalconduit_load_configuration - and deallocates the given configuration. */ -static void -gcalconduit_destroy_configuration(GCalConduitCfg **c) -{ - g_return_if_fail(c!=NULL); - g_return_if_fail(*c!=NULL); - g_free(*c); - *c = NULL; -} - - -/* Given a GCalConduitContxt*, allocates the structure */ -static void -gcalconduit_new_context(GCalConduitContext **ctxt, - GCalConduitCfg *c) -{ - *ctxt = g_new0(GCalConduitContext,1); - g_assert(ctxt!=NULL); - (*ctxt)->cfg = c; - CORBA_exception_init (&((*ctxt)->ev)); -} - - -/* Destroys any data allocated by gcalconduit_new_context - and deallocates its data. */ -static void -gcalconduit_destroy_context(GCalConduitContext **ctxt) -{ - g_return_if_fail(ctxt!=NULL); - g_return_if_fail(*ctxt!=NULL); -/* - if ((*ctxt)->cfg!=NULL) - gcalconduit_destroy_configuration(&((*ctxt)->cfg)); -*/ - g_free(*ctxt); - *ctxt = NULL; -} - - -static void -gnome_calendar_load_cb (GtkWidget *cal_client, - CalClientLoadStatus status, - GCalConduitContext *ctxt) -{ - CalClient *client = CAL_CLIENT (cal_client); - - printf (" calendar-conduit entering " - "gnome_calendar_load_cb, tried=%d\n", - ctxt->calendar_load_tried); - - if (status == CAL_CLIENT_LOAD_SUCCESS) { - ctxt->calendar_load_success = TRUE; - printf (" success\n"); - gtk_main_quit (); /* end the sub event loop */ - } else { - if (ctxt->calendar_load_tried) { - printf (" load and create of calendar failed\n"); - gtk_main_quit (); /* end the sub event loop */ - return; - } - - cal_client_create_calendar (client, ctxt->calendar_file); - ctxt->calendar_load_tried = 1; - } -} - - - - - -static int -start_calendar_server (GnomePilotConduitStandardAbs *conduit, - GCalConduitContext *ctxt) -{ - - g_return_val_if_fail(conduit!=NULL,-2); - g_return_val_if_fail(ctxt!=NULL,-2); - - ctxt->client = cal_client_new (); - - /* FIX ME */ - ctxt->calendar_file = g_concat_dir_and_file (g_get_home_dir (), - "evolution/local/Calendar/calendar.vcf"); - - gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded", - gnome_calendar_load_cb, ctxt); - - printf (" calling cal_client_load_calendar\n"); - cal_client_load_calendar (ctxt->client, ctxt->calendar_file); - - /* run a sub event loop to turn cal-client's async load - notification into a synchronous call */ - gtk_main (); - - if (ctxt->calendar_load_success) - return 0; - - return -1; -} - - -#if 0 -/* Just a stub to link with */ -void calendar_notify (time_t time, CalendarAlarm *which, void *data); -void calendar_notify (time_t time, CalendarAlarm *which, void *data) { } -#endif /* 0 */ - - -static GSList * -get_calendar_objects(GnomePilotConduitStandardAbs *conduit, - gboolean *status, - GCalConduitContext *ctxt) -{ - GList *uids; - GSList *result = NULL; - - g_return_val_if_fail (conduit != NULL, NULL); - g_return_val_if_fail (ctxt != NULL, NULL); - - /* uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_ANY); */ - uids = cal_client_get_uids (ctxt->client, - CALOBJ_TYPE_EVENT | - /*CALOBJ_TYPE_TODO |*/ - CALOBJ_TYPE_JOURNAL); - - if (status != NULL) - (*status) = TRUE; - - if (! uids) - INFO ("No entries found"); - else { - GList *c; - for (c=uids; c; c=c->next) - result = g_slist_prepend (result, (gchar *) c->data); - /* FIX ME free uids */ - } - - return result; -} - - -static void -local_record_from_ical_uid (GCalLocalRecord *local, - char *uid, - GCalConduitContext *ctxt) -{ - CalComponent *obj; - CalClientGetStatus status; - - g_assert (local != NULL); - - status = cal_client_get_object (ctxt->client, uid, &obj); - - if (status == CAL_CLIENT_GET_SUCCESS) - local_record_from_icalobject (local, obj); - else - INFO ("Object did not exist"); -} - - -/* - * converts a CalComponent to a GCalLocalRecord - */ - -void -local_record_from_icalobject (GCalLocalRecord *local, - CalComponent *obj) -{ - unsigned long int pilot_status; - - g_return_if_fail(local!=NULL); - g_return_if_fail(obj!=NULL); - - local->ical = obj; - cal_component_get_pilot_id (obj, &local->local.ID); - cal_component_get_pilot_status (obj, &pilot_status); - -/* - LOG ("local->Id = %ld [%s], status = %d", - local->local.ID,obj->summary,local->ical->pilot_status); -*/ - switch (pilot_status) { - case ICAL_PILOT_SYNC_NONE: - local->local.attr = GnomePilotRecordNothing; - break; - case ICAL_PILOT_SYNC_MOD: - local->local.attr = GnomePilotRecordModified; - break; - case ICAL_PILOT_SYNC_DEL: - local->local.attr = GnomePilotRecordDeleted; - break; - } - - /* Records without a pilot_id are new */ - if (local->local.ID == 0) - local->local.attr = GnomePilotRecordNew; - - /* - local->local.secret = 0; - if(obj->class!=NULL) - if(strcmp(obj->class,"PRIVATE")==0) - local->local.secret = 1; - */ - - local->local.archived = 0; -} - - -/* - * Given a PilotRecord, find the matching record in - * the calendar repository. If no match, return NULL - */ -static GCalLocalRecord * -find_record_in_repository(GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - char *uid = NULL; - GCalLocalRecord *loc; - CalClientGetStatus status; - CalComponent *obj; - - g_return_val_if_fail(conduit!=NULL,NULL); - g_return_val_if_fail(remote!=NULL,NULL); - - printf ("find_record_in_repository: remote=%s... ", - print_remote (remote)); - - status = cal_client_get_uid_by_pilot_id (ctxt->client, remote->ID, &uid); - - if (status == CAL_CLIENT_GET_SUCCESS) { - status = cal_client_get_object (ctxt->client, uid, &obj); - if (status == CAL_CLIENT_GET_SUCCESS) { - printf ("found %s\n", print_ical (obj)); - loc = g_new0(GCalLocalRecord,1); - /* memory allocated in new_from_string is freed in free_match */ - local_record_from_icalobject (loc, obj); - return loc; - } - } - - printf ("not found\n"); - return NULL; -} - - -/* - * updates an given CalComponent in the repository - */ -static void -update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit, - CalComponent *obj, - GCalConduitContext *ctxt) -{ - gboolean success; - - g_return_if_fail(conduit!=NULL); - g_return_if_fail(obj!=NULL); - - printf (" update_calendar_entry_in_repository " - "saving %s to desktop\n", - print_ical (obj)); - - success = cal_client_update_object (ctxt->client, obj); - - if (! success) { - WARN (_("Error while communicating with calendar server")); - } -} - - -static CalComponent * -ical_from_remote_record(GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - CalComponent *in_obj) -{ - CalComponent *obj; - // int i; - struct Appointment a; - struct icaltimetype now = icaltimetype_from_timet (time (NULL), FALSE); - - CalComponentText summary = {NULL, NULL}; - CalComponentText comment = {NULL, NULL}; - GSList *comment_list; - - g_return_val_if_fail(remote!=NULL,NULL); - memset(&a,0,sizeof(struct Appointment)); - unpack_Appointment(&a,remote->record,remote->length); - - printf (" ical_from_remote_record: " - "merging remote %s into local %s\n", - print_remote (remote), print_ical (in_obj)); - - - if (in_obj == NULL) { - obj = cal_component_new (); - } else { - obj = in_obj; - } - - summary.value = a.description; - cal_component_set_summary (obj, &summary); - - comment.value = a.note; - comment_list = g_slist_append (NULL, &comment); - cal_component_set_comment_list (obj, comment_list); - g_slist_free (comment_list); - - cal_component_set_new_vtype (obj, CAL_COMPONENT_EVENT); - - //obj->created = now; - cal_component_set_created (obj, &now); - //obj->last_mod = now; - cal_component_set_last_modified (obj, &now); - //obj->priority = 0; - //obj->transp = 0; - cal_component_set_transparency (obj, - /*CalComponentTransparency transp*/ - CAL_COMPONENT_TRANSP_NONE); - //obj->related = NULL; - - // obj->pilot_id = remote->ID; - // cal_component_set_pilot_status (obj, ICAL_PILOT_SYNC_NONE); - - /* - * Begin and end - */ - - if (a.event) - { - /* turn day-long events into a full day's appointment - FIXME: get settings from gnomecal */ - a.begin.tm_sec = 0; - a.begin.tm_min = 0; - a.begin.tm_hour = 0; - - a.end.tm_sec = 0; - a.end.tm_min =59; - a.end.tm_hour = 23; - } - - //obj->dtstart = mktime (&a.begin); - { - /* do i need to malloc these? FIX ME */ - struct icaltimetype dtstart_ictt; - CalComponentDateTime dtstart; - - dtstart_ictt = icaltimetype_from_timet (mktime (& a.begin), FALSE); - dtstart.value = &dtstart_ictt; - dtstart.tzid = NULL; - cal_component_set_dtstart (obj, &dtstart); - } - - //obj->dtend = mktime (&a.end); - { - /* do i need to malloc these? FIX ME */ - struct icaltimetype dtend_ictt; - CalComponentDateTime dtend; - - dtend_ictt = icaltimetype_from_timet (mktime (& a.end), FALSE); - dtend.value = &dtend_ictt; - dtend.tzid = NULL; - cal_component_set_dtend (obj, &dtend); - } - - - /* Special case: daily repetitions are converted to a multi-day event */ - /* This sucketh, a pilot event scheduled for dailyRepeat, freq 1, end on - whatever is cleary converted wrong - if (a.repeatType == repeatDaily){ - time_t newt = time_add_day (obj->dtend, a.repeatFrequency); - - obj->dtend = newt; - } - */ - -#warning "finish alarms here" -#if 0 - /* - * Alarm - */ - if (a.alarm){ - obj->aalarm.type = ALARM_AUDIO; - obj->aalarm.enabled = 1; - obj->aalarm.count = a.advance; - - switch (a.advanceUnits){ - case advMinutes: - obj->aalarm.units = ALARM_MINUTES; - break; - - case advHours: - obj->aalarm.units = ALARM_HOURS; - break; - - case advDays: - obj->aalarm.units = ALARM_DAYS; - break; - default: - } - } -#endif /* 0 */ - -#warning "finish recurrence here" -#if 0 - /* - * Recurrence - */ - if (a.repeatFrequency) { - obj->recur = g_new0 (Recurrence, 1); - - switch (a.repeatType){ - case repeatDaily: - /* - * In the Pilot daily repetitions are actually - * multi-day events - */ - obj->recur->type = RECUR_DAILY; - break; - - case repeatMonthlyByDate: - obj->recur->type = RECUR_MONTHLY_BY_DAY; - obj->recur->u.month_day = a.repeatFrequency; - break; - - case repeatWeekly: - { - int wd; - - obj->recur->type = RECUR_WEEKLY; - for (wd = 0; wd < 7; wd++) - if (a.repeatDays [wd]) - obj->recur->weekday |= 1 << wd; - - if (obj->recur->weekday == 0){ - struct tm tm = *localtime (&obj->dtstart); - - obj->recur->weekday = 1 << tm.tm_wday; - } - break; - } - - case repeatMonthlyByDay: - obj->recur->type = RECUR_MONTHLY_BY_POS; - obj->recur->u.month_pos = a.repeatFrequency; - obj->recur->weekday = (a.repeatDay / 7); - break; - - case repeatYearly: - obj->recur->type = RECUR_YEARLY_BY_DAY; - break; - - default: - g_assert_not_reached(); - } - - if (a.repeatForever) - obj->recur->duration = 0; - else - obj->recur->_enddate = mktime (&a.repeatEnd); - - obj->recur->interval = a.repeatFrequency; - } - - /* - * Load exception dates - */ - obj->exdate = NULL; - for (i = 0; i < a.exceptions; i++){ - time_t *t = g_new (time_t, 1); - - *t = mktime (&(a.exception [i])); - obj->exdate = g_list_prepend (obj->exdate, t); - } -#endif /* 0 */ - - // g_free (obj->class); - - if (remote->attr & dlpRecAttrSecret) - cal_component_set_classification (obj, CAL_COMPONENT_CLASS_PRIVATE); - else - cal_component_set_classification (obj, CAL_COMPONENT_CLASS_PUBLIC); - - free_Appointment(&a); - - return obj; -} - - -/* Code blatantly stolen from - * calendar-pilot-sync.c: - * - * (C) 1999 International GNOME Support - * - * Author: - * Miguel de Icaza (miguel@gnome-support.com) - * - */ -static gint -update_record (GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - CalComponent *obj; - struct Appointment a; - CalClientGetStatus status; - char *uid; - - CalComponentText summary = {NULL, NULL}; - CalComponentText comment = {NULL, NULL}; - GSList *comment_list; - - g_return_val_if_fail(remote!=NULL,-1); - - memset(&a,0,sizeof(struct Appointment)); - unpack_Appointment(&a,remote->record,remote->length); - - printf (" cal_client_get_uid_by_pilot_id... "); - - status = cal_client_get_uid_by_pilot_id (ctxt->client, - remote->ID, &uid); - if (status == CAL_CLIENT_GET_SUCCESS) { - printf (" succeeded with '%s'\n", uid); - printf (" cal_client_get_object... "); - status = cal_client_get_object (ctxt->client, uid, &obj); - } - - if (status != CAL_CLIENT_GET_SUCCESS) { - struct icaltimetype now = icaltimetype_from_timet (time (NULL), FALSE); - - printf ("failed, making a new one.\n"); - - obj = cal_component_new (); - - summary.value = a.description; - cal_component_set_summary (obj, &summary); - - comment.value = a.note; - comment_list = g_slist_append (NULL, &comment); - cal_component_set_comment_list (obj, comment_list); - g_slist_free (comment_list); - - // obj->type = ICAL_TODO; - cal_component_set_new_vtype (obj, CAL_COMPONENT_TODO); - // obj->new = TRUE; - // obj->created = now; - cal_component_set_created (obj, &now); - // obj->last_mod = now; - cal_component_set_last_modified (obj, &now); - // obj->priority = 0; - // obj->transp = 0; - cal_component_set_transparency (obj, - /*CalComponentTransparency transp*/ - CAL_COMPONENT_TRANSP_NONE); - // obj->related = NULL; - //obj->pilot_id = remote->ID; - //obj->pilot_status = ICAL_PILOT_SYNC_NONE; - cal_component_set_pilot_id (obj, remote->ID); - cal_component_set_pilot_status (obj, ICAL_PILOT_SYNC_NONE); - } else { - CalComponent *new_obj; - - printf ("succeeded %s\n", print_ical (obj)); - - new_obj = ical_from_remote_record (conduit, remote, obj); - obj = new_obj; - } - - /* update record on server */ - { - const char *uid; - unsigned long pilot_id; - - cal_component_get_uid (obj, &uid); - cal_component_get_pilot_id (obj, &pilot_id); - - update_calendar_entry_in_repository (conduit, obj, ctxt); - cal_client_update_pilot_id (ctxt->client, (char *) uid, pilot_id, - ICAL_PILOT_SYNC_NONE); - } - - /* - * Shutdown - */ - //ical_object_unref (obj); - free_Appointment(&a); - - return 0; -} - -static void -check_for_slow_setting (GnomePilotConduit *c, GCalConduitContext *ctxt) -{ - GList *uids; - unsigned long int entry_number; - - /* get all but TODOs, those are handled by the todo conduit */ - /* uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_ANY); */ - uids = cal_client_get_uids (ctxt->client, - CALOBJ_TYPE_EVENT | - /*CALOBJ_TYPE_TODO |*/ - CALOBJ_TYPE_JOURNAL); - - entry_number = g_list_length (uids); - - /* If the local base is empty, do a slow sync */ - if (entry_number == 0) { - GnomePilotConduitStandard *conduit; - printf (" doing slow sync\n"); - conduit = GNOME_PILOT_CONDUIT_STANDARD (c); - gnome_pilot_conduit_standard_set_slow (conduit); - } else { - printf (" doing fast sync\n"); - } -} - -static gint -pre_sync (GnomePilotConduit *c, - GnomePilotDBInfo *dbi, - GCalConduitContext *ctxt) -{ - int l; - unsigned char *buf; - GnomePilotConduitStandardAbs *conduit; - - - /* - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - */ - - - conduit = GNOME_PILOT_CONDUIT_STANDARD_ABS(c); - - - printf ("---------------------------------------------------------\n"); - printf ("pre_sync: Calendar Conduit v.%s\n", CONDUIT_VERSION); - g_message ("Calendar Conduit v.%s", CONDUIT_VERSION); - - ctxt->client = NULL; - - if (start_calendar_server (GNOME_PILOT_CONDUIT_STANDARD_ABS(c), ctxt) != 0) { - WARN(_("Could not start gnomecal server")); - gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c), - _("Could not start gnomecal server")); - return -1; - } - - -#if 0 - /* Set the counters for the progress bar crap */ - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev)); - - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev)); - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev)); - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev)); - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); -#endif /* 0 */ - - gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi); - - /* load_records(c); */ - - buf = (unsigned char*)g_malloc(0xffff); - if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff)) < 0) { - WARN(_("Could not read pilot's DateBook application block")); - WARN("dlp_ReadAppBlock(...) = %d",l); - gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c), - _("Could not read pilot's DateBook application block")); - return -1; - } - unpack_AppointmentAppInfo(&(ctxt->ai),buf,l); - g_free(buf); - - check_for_slow_setting(c,ctxt); - - return 0; -} - -/** - * Find (if possible) the local record which matches - * the given PilotRecord. - * if successfull, return non-zero and set *local to - * a non-null value (the located local record), - * otherwise return 0 and set *local = NULL; - */ - -static gint -match_record (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - printf ("match_record: looking for local copy of %s\n", - print_remote (remote)); - - g_return_val_if_fail(local!=NULL,-1); - g_return_val_if_fail(remote!=NULL,-1); - - *local = find_record_in_repository(conduit,remote,ctxt); - - if (*local == NULL) - printf (" match_record: not found.\n"); - else - printf (" match_record: found, %s\n", print_local (*local)); - - if (*local==NULL) return -1; - return 0; -} - -/** - * Free the data allocated by a previous match_record call. - * If successfull, return non-zero and ser *local=NULL, otherwise - * return 0. - */ -static gint -free_match (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - GCalConduitContext *ctxt) -{ - printf ("free_match: %s\n", print_local (*local)); - - g_return_val_if_fail (local!=NULL, -1); - g_return_val_if_fail (*local!=NULL, -1); - - // ical_object_unref (GCAL_LOCALRECORD(*local)->ical); - g_free (*local); - - *local = NULL; - return 0; -} - -/* - Move to archive and set status to Nothing - */ -static gint -archive_local (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - GCalConduitContext *ctxt) -{ - printf ("archive_local: doing nothing with %s\n", print_local (local)); - - g_return_val_if_fail(local!=NULL,-1); - - return -1; -} - -/* - Store in archive and set status to Nothing - */ -static gint -archive_remote (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - printf ("archive_remote: doing nothing with %s\n", - print_local (local)); - - //g_return_val_if_fail(remote!=NULL,-1); - //g_return_val_if_fail(local!=NULL,-1); - - return -1; -} - -/* - Store and set status to Nothing - */ -static gint -store_remote (GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - printf ("store_remote: copying pilot record %s to desktop\n", - print_remote (remote)); - - g_return_val_if_fail(remote!=NULL,-1); - remote->attr = GnomePilotRecordNothing; - - return update_record(conduit,remote,ctxt); -} - -static gint -clear_status_archive_local (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - GCalConduitContext *ctxt) -{ - printf ("clear_status_archive_local: doing nothing\n"); - - g_return_val_if_fail(local!=NULL,-1); - - return -1; -} - -static gint -iterate (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - GCalConduitContext *ctxt) -{ - static GSList *events,*iterator; - static int hest; - - g_return_val_if_fail(local!=NULL,-1); - - if(*local==NULL) { - LOG ("beginning iteration"); - - events = get_calendar_objects(conduit,NULL,ctxt); - hest = 0; - - if(events!=NULL) { - LOG ("iterating over %d records", g_slist_length (events)); - *local = g_new0(GCalLocalRecord,1); - - local_record_from_ical_uid(*local,(gchar*)events->data,ctxt); - iterator = events; - } else { - LOG ("no events"); - (*local) = NULL; - } - } else { - hest++; - if(g_slist_next(iterator)==NULL) { - GSList *l; - - LOG ("ending"); - /** free stuff allocated for iteration */ - g_free((*local)); - - LOG ("iterated over %d records", hest); - for(l=events;l;l=l->next) - g_free(l->data); - - g_slist_free(events); - - /* ends iteration */ - (*local) = NULL; - return 0; - } else { - iterator = g_slist_next(iterator); - local_record_from_ical_uid(*local,(gchar*)(iterator->data),ctxt); - } - } - return 1; -} - - -static gint -iterate_specific (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - gint flag, - gint archived, - GCalConduitContext *ctxt) -{ - (*local) = NULL; - - /* debugging */ - { - gchar *tmp; - switch (flag) { - case GnomePilotRecordNothing: - tmp = g_strdup("RecordNothing"); break; - case GnomePilotRecordModified: - tmp = g_strdup("RecordModified"); break; - case GnomePilotRecordDeleted: - tmp = g_strdup("RecordDeleted"); break; - case GnomePilotRecordNew: - tmp = g_strdup("RecordNew"); break; - default: tmp = g_strdup_printf("0x%x",flag); break; - } - printf ("\niterate_specific: (flag = %s)... ", tmp); - g_free(tmp); - } - - - g_return_val_if_fail(local!=NULL,-1); - - /* iterate until a record meets the criteria */ - while (gnome_pilot_conduit_standard_abs_iterate (conduit, - (LocalRecord**)local)) { - if((*local)==NULL) break; - if(archived && ((*local)->local.archived==archived)) break; - if(((*local)->local.attr == flag)) break; - } - - if ((*local)) { - printf (" found %s\n", print_local (*local)); - } else { - printf (" no more found.\n"); - } - - return (*local)==NULL?0:1; -} - - -static gint -purge (GnomePilotConduitStandardAbs *conduit, - GCalConduitContext *ctxt) -{ - printf ("purge: doing nothing\n"); - - /* HEST, gem posterne her */ - - return -1; -} - - -static char *gnome_pilot_status_to_string (gint status) -{ - switch(status) { - case GnomePilotRecordPending: return "GnomePilotRecordPending"; - case GnomePilotRecordNothing: return "GnomePilotRecordNothing"; - case GnomePilotRecordDeleted: return "GnomePilotRecordDeleted"; - case GnomePilotRecordNew: return "GnomePilotRecordNew"; - case GnomePilotRecordModified: return "GnomePilotRecordModified"; - } - - return "Unknown"; -} - - -static gint -set_status (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - gint status, - GCalConduitContext *ctxt) -{ - gboolean success; - iCalPilotState new_state; - - printf ("set_status: %s status is now '%s'\n", - print_local (local), - gnome_pilot_status_to_string (status)); - - g_return_val_if_fail(local!=NULL,-1); - g_assert(local->ical!=NULL); - - local->local.attr = status; - switch(status) { - case GnomePilotRecordPending: - case GnomePilotRecordNothing: - new_state = ICAL_PILOT_SYNC_NONE; - break; - case GnomePilotRecordDeleted: - break; - case GnomePilotRecordNew: - case GnomePilotRecordModified: - new_state = ICAL_PILOT_SYNC_MOD; - break; - } - - if (status == GnomePilotRecordDeleted) { - const char *uid; - cal_component_get_uid (local->ical, &uid); - success = cal_client_remove_object (ctxt->client, uid); - } else { - const char *uid; - unsigned long pilot_id; - - cal_component_get_uid (local->ical, &uid); - cal_component_get_pilot_id (local->ical, &pilot_id); - - success = cal_client_update_object (ctxt->client, local->ical); - cal_client_update_pilot_id (ctxt->client, (char *) uid, - pilot_id, new_state); - } - - if (! success) { - WARN (_("Error while communicating with calendar server")); - } - - return 0; -} - -static gint -set_archived (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - gint archived, - GCalConduitContext *ctxt) -{ - printf ("set_archived: %s archived flag is now '%d'\n", - print_local (local), archived); - - g_return_val_if_fail(local!=NULL,-1); - g_assert(local->ical!=NULL); - - local->local.archived = archived; - update_calendar_entry_in_repository(conduit,local->ical,ctxt); - /* FIXME: This should move the entry into a speciel - calendar file, eg. Archive, or (by config option), simply - delete it */ - return 0; -} - -static gint -set_pilot_id (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - guint32 ID, - GCalConduitContext *ctxt) -{ - const char *uid; - unsigned long int pilot_status; - - printf ("set_pilot_id: %s pilot ID is now '%d'\n", - print_local (local), ID); - - g_return_val_if_fail(local!=NULL,-1); - g_assert(local->ical!=NULL); - - local->local.ID = ID; - cal_component_set_pilot_id (local->ical, ID); - - cal_component_get_uid (local->ical, &uid); - cal_component_get_pilot_status (local->ical, &pilot_status); - - cal_client_update_pilot_id (ctxt->client, - (char *) uid, - local->local.ID, - pilot_status); - - return 0; -} - -static gint -transmit (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord **remote, - GCalConduitContext *ctxt) -{ - PilotRecord *p; - //int daycount; - - CalComponentText summary; - GSList *comment_list = NULL; - CalComponentText *comment; - - printf ("transmit: encoding local %s\n", print_local (local)); - - g_return_val_if_fail(local!=NULL,-1); - g_return_val_if_fail(remote!=NULL,-1); - g_assert(local->ical!=NULL); - - p = g_new0(PilotRecord,1); - - p->ID = local->local.ID; - p->attr = local->local.attr; - p->archived = local->local.archived; - p->secret = local->local.secret; - - local->a = g_new0(struct Appointment,1); - - local->a->event = 0; /* if no start time, leave at 1 */ - //local->a->begin = *localtime(&local->ical->dtstart); - { - CalComponentDateTime dtstart; - time_t dtstart_time_t; - - cal_component_get_dtstart (local->ical, &dtstart); - dtstart_time_t = time_from_icaltimetype (*dtstart.value); - - local->a->begin = *localtime (&dtstart_time_t); - } - - //local->a->end = *localtime(&local->ical->dtend); - { - CalComponentDateTime dtend; - time_t dtend_time_t; - - cal_component_get_dtend (local->ical, &dtend); - dtend_time_t = time_from_icaltimetype (*dtend.value); - - local->a->end = *localtime (&dtend_time_t); - } - -#warning "finish alarm and recurrence here" -#if 0 - /* set the Audio Alarm parameters */ - if(local->ical->aalarm.enabled) { - local->a->alarm = 1; - local->a->advance = local->ical->aalarm.count; - switch(local->ical->aalarm.units) { - case ALARM_MINUTES: - local->a->advanceUnits = advMinutes; - break; - case ALARM_HOURS: - local->a->advanceUnits = advHours; - break; - case ALARM_DAYS: - local->a->advanceUnits = advDays; - break; - } - } else { - local->a->alarm = 0; - local->a->advance = 0; - local->a->advanceUnits = advMinutes; - } - - /* set the recurrence parameters */ - if (local->ical->recur != NULL) { - switch (local->ical->recur->type) { - case RECUR_DAILY: - local->a->repeatType = repeatDaily; - break; - case RECUR_WEEKLY: - local->a->repeatType = repeatWeekly; - break; - case RECUR_MONTHLY_BY_POS: - local->a->repeatType = repeatMonthlyByDate; - break; - case RECUR_MONTHLY_BY_DAY: - local->a->repeatType = repeatMonthlyByDay; - break; - case RECUR_YEARLY_BY_MONTH: - local->a->repeatType = repeatYearly; - break; - case RECUR_YEARLY_BY_DAY: - local->a->repeatType = repeatYearly; - break; - } - if (local->ical->recur->duration == 0) { - local->a->repeatForever = 1; - } else { - local->a->repeatForever = 0; - local->a->repeatEnd = *localtime(&local->ical->recur->_enddate); - } - local->a->repeatFrequency = local->ical->recur->interval; - - - for ( daycount=0; daycount<7; daycount++ ) { - if (local->ical->recur->weekday & (1 << daycount)) - local->a->repeatDays[daycount] = 1; - } - } else { - local->a->repeatType = repeatNone; - local->a->repeatForever = 0; - local->a->repeatEnd = local->a->end; - local->a->repeatFrequency = 0; - local->a->repeatDay = dom1stSun; - local->a->repeatDays[0] = 0; - local->a->repeatDays[1] = 0; - local->a->repeatDays[2] = 0; - local->a->repeatDays[3] = 0; - local->a->repeatDays[4] = 0; - local->a->repeatDays[5] = 0; - local->a->repeatDays[6] = 0; - local->a->repeatWeekstart = 0; - local->a->exceptions = 0; - local->a->exception = NULL; - } -#endif /* 0 */ - - /* STOP: don't replace these with g_strdup, since free_Appointment - uses free to deallocte */ - - cal_component_get_summary (local->ical, &summary); - local->a->note = - //local->ical->comment==NULL?NULL:strdup(local->ical->comment); - strdup ((char *) summary.value); - - /* local->a->description = - local->ical->summary==NULL?NULL:strdup(local->ical->summary); */ - - cal_component_get_comment_list (local->ical, &comment_list); - if (comment_list) { - comment = (CalComponentText *) comment_list->data; - if (comment && comment->value) - local->a->description = strdup (comment->value); - else - local->a->description = NULL; - } else { - local->a->note = NULL; - } - - /* Generate pilot record structure */ - p->record = g_new0(char,0xffff); - p->length = pack_Appointment(local->a,p->record,0xffff); - -#if 0 - /* This is some debug code that hexdumps the calendar entry... - You won't need this. */ - { - int x,y; - g_message("calconduit: new item from %s to %s",asctime(&(local->a->begin)),asctime(&(local->a->end))); - - g_message("local->a->note = %s",local->a->note); - g_message("local->a->description = %s",local->a->description); - g_message("sizeof(p->record) = %d, length is %d",sizeof(p->record),p->length); - for(x=0;x<p->length;x+=32) { - for(y=x;y<x+32;y++) - if(p->record[y]<33 || p->record[y]>128) - printf("%02X",p->record[y]); - else - printf(" %c",p->record[y]); - printf("\n"); - } - } -#endif - - *remote = p; - - return 0; -} - -static gint -free_transmit (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord **remote, - GCalConduitContext *ctxt) -{ - LOG ("entering free_transmit"); - - g_return_val_if_fail(local!=NULL,-1); - g_return_val_if_fail(remote!=NULL,-1); - - /* free_Appointment(local->a); */ /* FIX ME is this needed? */ - g_free((*remote)->record); - *remote = NULL; - return 0; -} - - -static gint -compare (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - /* used by the quick compare */ - PilotRecord *remoteOfLocal; - int err; - int retval; - - /* used by the tedious compare */ - //struct Appointment a; - - printf ("compare: local=%s remote=%s...\n", - print_local (local), print_remote (remote)); - - g_return_val_if_fail (local!=NULL,-1); - g_return_val_if_fail (remote!=NULL,-1); -#if 1 - err = transmit(conduit,local,&remoteOfLocal,ctxt); - if (err != 0) return err; - - retval = 0; - if (remote->length == remoteOfLocal->length) { - if (memcmp (remoteOfLocal->record, - remote->record, remote->length)!=0) { - printf (" compare failed on contents\n"); - retval = 1; - } - } else { - g_message("compare failed on length"); - retval = 1; - } - - - if (retval == 0) { - printf (" match.\n"); - } else { - /* debug spew */ - printf (" local:%s\n", print_remote (remoteOfLocal)); - printf (" remote:%s\n", print_remote (remote)); - } - - free_transmit(conduit,local,&remoteOfLocal,ctxt); - return retval; - -#else - /** FIXME: All the { LOG("yadayada"); return 1; } bloat is for debug purposes. - Once this is known to work, compact to return 1;'s */ - - /* Check record attributes */ - if (local->local.ID != remote->ID) { - LOG("failed local->local.ID == remote->ID"); - return 1; - } - if (local->local.attr != remote->attr) { - LOG("failed local->local.attr == remote->attr"); - return 1; - } - if (local->local.archived != remote->archived) { - LOG("failed local->local.archived == remote->archived"); - return 1; - } - if (local->local.secret != remote->secret) { - LOG("failed local->local.secret == remote->secret"); - return 1; - } - - unpack_Appointment(&a,remote->record,remote->length); - - /* Check records begin/end time */ - if (a.event==0) { -/* FIXME - if (a.begin != *localtime(&local->ical->dtstart)) { - LOG("a.begin == *localtime(&local->ical->dtstart)"); - return 1; - } - if (a.end != *localtime(&local->ical->dtend)) { - LOG("a.end == *localtime(&local->ical->dtend)"); - return 1; - } -*/ - } else { - LOG("failed local->a.event != 0, unsupported by gnomecal"); - return 1; - } - - /* Check records alarm settings */ - if(a.alarm == 1) { - if (local->ical->aalarm.enabled == 1) { - if (a.advance != local->ical->aalarm.count) { - LOG("failed a.advance == local->ical->aalarm.count"); - return 1; - } - switch(local->ical->aalarm.units) { - case ALARM_MINUTES: - if (a.advanceUnits != advMinutes) { - LOG("failed local->ical->aalarm.units == a.advanceUnits"); - return 1; - } - break; - case ALARM_HOURS: - if (a.advanceUnits != advHours) { - LOG("failed local->ical->aalarm.units == a.advanceUnits"); - return 1; - } - break; - case ALARM_DAYS: - if (a.advanceUnits != advDays) { - LOG("failed local->ical->aalarm.units == a.advanceUnits"); - return 1; - } - break; - } - } else { - LOG("failed a.alarm == 1 && local->ical->aalarm.enabled == 1"); - return 1; - } - } else if (local->ical->aalarm.enabled == 1) { - LOG("failed a.alarm != 1 && local->ical->aalarm.enabled != 1"); - return 1; - } - - /* Check records recurrence settings */ - /* If this code is broken, a more or less safe although not efficient - approach is (other the fixing the bug), if either has recurrence, - return 1, thus failing the comparision */ - if (local->ical->recur != NULL) { - if (a.repeatType == repeatNone) { - LOG("failed: local->ical->recur != NULL && a.repeatType != repeatNone"); - return 1; - } - switch (local->ical->recur->type) { - case RECUR_DAILY: - if (a.repeatType != repeatDaily) { - LOG("failed a.repeatType == repeatDaily"); - return 1; } - break; - case RECUR_WEEKLY: - if (a.repeatType != repeatWeekly) { - LOG("failed a.repeatType == repeatWeekly"); - return 1; } - break; - case RECUR_MONTHLY_BY_POS: - if (a.repeatType != repeatMonthlyByDate) { - LOG("failed a.repeatType == repeatMonthlyByDate"); - return 1; } - break; - case RECUR_MONTHLY_BY_DAY: - if (a.repeatType != repeatMonthlyByDay) { - LOG("failed a.repeatType == repeatMonthlyByDay"); - return 1; } - break; - case RECUR_YEARLY_BY_MONTH: - if (a.repeatType != repeatYearly) { - LOG("failed a.repeatType == repeatYearly"); - return 1; } - break; - case RECUR_YEARLY_BY_DAY: - if (a.repeatType != repeatYearly) { - LOG("failed a.repeatType == repeatYearly"); - return 1; } - break; - } - if (local->ical->recur->duration == 0) { - if(a.repeatForever != 1) { - LOG("failed local->ical->recur->duration == 0 && a.repeatForever == 1"); - return 1; - } - } else { - if(a.repeatForever != 0) { - LOG("failed local->ical->recur->duration != 0 && ! a.repeatForever == 0"); - return 1; - } -/* FIXME - if(a.repeatEnd != *localtime(&local->ical->recur->_enddate)) { - LOG("failed a.repeatEnd == *localtime(&local->ical->recur->_enddate)"); - return 1; - } -*/ - } - if (a.repeatFrequency != local->ical->recur->interval) { - LOG("failed a.repeatFrequency == local->ical->recur->interval"); - return 1; - } - for (daycount = 0; daycount<7; daycount++) { - if(local->ical->recur->weekday & (1<<daycount)) { - if (a.repeatDays[daycount]!=1) { - LOG("failed local->ical->recur->weekday & (1<<daycount) && a.repeatDays[daycount]==1"); - return 1; - } - } else { - if (a.repeatDays[daycount]!=0) { - LOG("failed local->ical->recur->weekday &! (1<<daycount) && a.repeatDays[daycount]==0"); - return 1; - } - } - } - } else if (a.repeatType != repeatNone ) { - LOG("failed: local->ical->recur == NULL && a.repeatType == repeatNone"); - return 1; - } - - /* check the note and description */ - if(a.note!=NULL) { - if(local->ical->comment==NULL) { - LOG("failed a.note != NULL && local->ical->coment != NULL"); - return 1; - } - if(strcmp(local->ical->comment,a.note)!=0) { - LOG("failed strcmp(local->ical->comment,a.note)==0"); - return 1; - } - } if(local->ical->comment!=NULL) { - LOG("failed a.note == NULL && local->ical->coment == NULL"); - return 1; - } - if(a.description!=NULL) { - if(local->ical->summary==NULL) { - LOG("failed a.description != NULL && local->ical->coment != NULL"); - return 1; - } - if(strcmp(local->ical->summary,a.description)!=0) { - LOG("failed strcmp(local->ical->summary,a.description)==0"); - return 1; - } - } if(local->ical->summary!=NULL) { - LOG("failed a.description == NULL && local->ical->coment == NULL"); - return 1; - } -#endif - return 0; -} - -static gint -compare_backup (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - printf ("compare_backup: doing nothing\n"); - - g_return_val_if_fail(local!=NULL,-1); - g_return_val_if_fail(remote!=NULL,-1); - - return -1; -} - - -static gint -delete_all (GnomePilotConduitStandardAbs *conduit, - GCalConduitContext *ctxt) -{ - GSList *events,*it; - gboolean error; - gboolean success; - - events = get_calendar_objects(conduit,&error,ctxt); - - printf ("delete_all: deleting all objects from desktop\n"); - - if (error == FALSE) return -1; - for (it=events; it; it = g_slist_next (it)) { - success = cal_client_remove_object (ctxt->client, it->data); - - if (!success) - INFO ("Object did not exist"); - - g_free (it->data); - } - - g_slist_free (events); - return -1; -} - - -static ORBit_MessageValidationResult -accept_all_cookies (CORBA_unsigned_long request_id, - CORBA_Principal *principal, - CORBA_char *operation) -{ - /* allow ALL cookies */ - return ORBIT_MESSAGE_ALLOW_ALL; -} - - -GnomePilotConduit * -conduit_get_gpilot_conduit (guint32 pilotId) -{ - GtkObject *retval; - GCalConduitCfg *cfg; - GCalConduitContext *ctxt; - - printf ("in calendar's conduit_get_gpilot_conduit\n"); - - /* we need to find wombat with oaf, so make sure oaf - is initialized here. once the desktop is converted - to oaf and gpilotd is built with oaf, this can go away */ - if (! oaf_is_initialized ()) - { - char *argv[ 1 ] = {"hi"}; - oaf_init (1, argv); - - if (bonobo_init (CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - ORBit_set_request_validation_handler (accept_all_cookies); - } - - - retval = gnome_pilot_conduit_standard_abs_new ("DatebookDB", 0x64617465); - g_assert (retval != NULL); - gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"GnomeCalConduit"); - - gcalconduit_load_configuration(&cfg,pilotId); - gtk_object_set_data(retval,"gcalconduit_cfg",cfg); - - gcalconduit_new_context(&ctxt,cfg); - gtk_object_set_data(GTK_OBJECT(retval),"gcalconduit_context",ctxt); - - gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt); - gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); - gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, ctxt); - gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, ctxt); - gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, ctxt); - gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt); - gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, ctxt); - gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, ctxt); - gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, ctxt); - gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, ctxt); - gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, ctxt); - gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt); - gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt); - gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, ctxt); - gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, ctxt); - gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, ctxt); - gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt); - gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt); - - return GNOME_PILOT_CONDUIT (retval); -} - -void -conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit) -{ - GCalConduitCfg *cc; - GCalConduitContext *ctxt; - - cc = GET_GCALCONFIG(conduit); - ctxt = GET_GCALCONTEXT(conduit); - - if (ctxt->client != NULL) { - gtk_object_unref (GTK_OBJECT (ctxt->client)); - //pi_close (ctxt->link); - //GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev)); - } - - gcalconduit_destroy_configuration (&cc); - - gcalconduit_destroy_context (&ctxt); - - gtk_object_destroy (GTK_OBJECT (conduit)); -} diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h deleted file mode 100644 index a8a1c81a50..0000000000 --- a/calendar/conduits/calendar/calendar-conduit.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* $Id$ */ - -#ifndef __CALENDAR_CONDUIT_H__ -#define __CALENDAR_CONDUIT_H__ - -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#include <gnome.h> -#include <pi-datebook.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-standard-abs.h> -#include <cal-client/cal-client.h> -#include <cal-util/calobj.h> -#include <cal-util/timeutil.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - - -/* This is the local record structure for the GnomeCal conduit. */ -typedef struct _GCalLocalRecord GCalLocalRecord; -struct _GCalLocalRecord { - /* The stuff from gnome-pilot-conduit-standard-abs.h - Must be first in the structure, or instances of this - structure cannot be used by gnome-pilot-conduit-standard-abs. - */ - LocalRecord local; - /* The corresponding iCal object, as found by GnomeCal. */ - CalComponent *ical; - /* pilot-link appointment structure, used for implementing Transmit. */ - struct Appointment *a; -}; -#define GCAL_LOCALRECORD(s) ((GCalLocalRecord*)(s)) - -/* This is the configuration of the GnomeCal conduit. */ -typedef struct _GCalConduitCfg GCalConduitCfg; -struct _GCalConduitCfg { - gboolean open_secret; - guint32 pilotId; - GnomePilotConduitSyncType sync_type; /* only used by capplet */ -}; -#define GET_GCALCONFIG(c) ((GCalConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_cfg")) - -/* This is the context for all the GnomeCal conduit methods. */ -typedef struct _GCalConduitContext GCalConduitContext; -struct _GCalConduitContext { - struct AppointmentAppInfo ai; - GCalConduitCfg *cfg; - CalClient *client; - CORBA_Environment ev; - CORBA_ORB orb; - gboolean calendar_load_tried; - gboolean calendar_load_success; - - char *calendar_file; -}; -#define GET_GCALCONTEXT(c) ((GCalConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_context")) - - -/* Given a GCalConduitCfg*, allocates the structure and - loads the configuration data for the given pilot. - this is defined in the header file because it is used by - both calendar-conduit and calendar-conduit-control-applet, - and we don't want to export any symbols we don't have to. */ -static void -gcalconduit_load_configuration(GCalConduitCfg **c, - guint32 pilotId) -{ - gchar prefix[256]; - g_snprintf(prefix,255,"/gnome-pilot.d/calendard-conduit/Pilot_%u/",pilotId); - - *c = g_new0(GCalConduitCfg,1); - g_assert(*c != NULL); - gnome_config_push_prefix(prefix); - (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE"); - (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */ - gnome_config_pop_prefix(); - - (*c)->pilotId = pilotId; -} - - -#endif __CALENDAR_CONDUIT_H__ diff --git a/calendar/conduits/calendar/calendar.conduit.in b/calendar/conduits/calendar/calendar.conduit.in deleted file mode 100644 index fb48e00584..0000000000 --- a/calendar/conduits/calendar/calendar.conduit.in +++ /dev/null @@ -1,8 +0,0 @@ -<gnome-pilot-conduit version="1.0"> -<conduit id="Calendar" type="shlib" location="@prefix@/lib/gnome-pilot/conduits/libcalendar_conduit.so"/> -<name value="Calendar"/> -<conduit-attribute name="description" value="Synchronizes with Evolution"/> -<conduit-attribute name="default-synctype" value="synchronize"/> -<conduit-attribute name="icon" value="@prefix@/share/pixmaps/gnome-calendar-conduit.png"/> -<conduit-attribute name="settings" value="TRUE"/> -</gnome-pilot-conduit> diff --git a/calendar/conduits/todo/.cvsignore b/calendar/conduits/todo/.cvsignore deleted file mode 100644 index 2820c43c3b..0000000000 --- a/calendar/conduits/todo/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile.in -Makefile -.deps -.libs -*.lo -*.la -todo-conduit-control-applet -todo.conduit diff --git a/calendar/conduits/todo/Makefile.am b/calendar/conduits/todo/Makefile.am deleted file mode 100644 index 6801c6150d..0000000000 --- a/calendar/conduits/todo/Makefile.am +++ /dev/null @@ -1,81 +0,0 @@ -# -# -# - -INCLUDES = \ - -I$(top_srcdir)/calendar \ - $(GNOME_PILOT_CFLAGS) - -file_conduitsdir=$(libdir)/gnome-pilot/conduits - -bin_PROGRAMS = todo-conduit-control-applet - -todo_conduit_control_applet_SOURCES = todo-conduit-control-applet.c - -todo_conduit_control_applet_LDADD = \ - $(CAPPLET_LIBS) \ - $(GNOME_LIBDIR) \ - -lgpilotdcm \ - -lgpilotd \ - -lgpilotdconduit \ - $(GNOME_CAPPLET_LIBS) \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(GNOME_XML_LIB) \ - $(GNOMEUI_LIBS) \ - $(PISOCK_LIBDIR) $(PISOCK_LIBS) \ - $(INTLLIBS) - - -# $(top_builddir)/libgpilotdCM/libgpilotdcm.la \ -# $(top_builddir)/gpilotd/libgpilotd.la \ -# $(top_builddir)/gpilotd/libgpilotdconduit.la \ - - -# todo_conduit -todo_conduitsdir=$(libdir)/gnome-pilot/conduits -todo_conduits_LTLIBRARIES = libtodo_conduit.la - -libtodo_conduit_la_SOURCES = \ - todo-conduit.c - -# todo-conduit.c: my_gnomecal_idl - -todo.conduit: todo.conduit.in Makefile - sed -e 's^\@prefix\@^$(prefix)^g' < $(srcdir)/todo.conduit.in > todo.conduit.tmp \ - && mv todo.conduit.tmp todo.conduit - -# -# conduit -# - -libtodo_conduit_la_LDFLAGS = \ - -rpath $(libdir) - -libtodo_conduit_la_LIBADD = \ - $(top_builddir)/calendar/cal-client/libcal-client-static.la \ - $(top_builddir)/calendar/cal-util/libcal-util-static.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical-static.la \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(PISOCK_LIBDIR) $(PISOCK_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOME_LIBS) - -ccenterdir = $(datadir)/control-center -ccenterPalmPilotdir = $(ccenterdir)/Peripherals -ccenterConduitsdir = $(ccenterPalmPilotdir)/Conduits -ccenterConduits_DATA = todo-conduit-control-applet.desktop - -panelConduitsdir = $(datadir)/gnome/apps/Settings/Peripherals/Conduits -panelConduits_DATA = $(ccenterConduits_DATA) - -Conduitdir = $(datadir)/gnome-pilot/conduits/ -Conduit_DATA = todo.conduit - -EXTRA_DIST = \ - todo.conduit.in \ - $(ccenterConduits_DATA) - -install-data-local: - $(mkinstalldirs) $(ccenterConduitsdir) - $(mkinstalldirs) $(Conduitdir) diff --git a/calendar/conduits/todo/todo-conduit-control-applet.c b/calendar/conduits/todo/todo-conduit-control-applet.c deleted file mode 100644 index 188aadc16e..0000000000 --- a/calendar/conduits/todo/todo-conduit-control-applet.c +++ /dev/null @@ -1,386 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Control applet ("capplet") for the gnome-pilot todo conduit, */ -/* based on */ -/* gpilotd control applet ('capplet') for use with the GNOME control center */ - -#include <pwd.h> -#include <sys/types.h> -#include <signal.h> -#include <gnome.h> - -#include <config.h> -#include <capplet-widget.h> - -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> -#include <gpilotd/gnome-pilot-client.h> - -#include "todo-conduit.h" - - -/* tell changes callbacks to ignore changes or not */ -static gboolean ignore_changes=FALSE; - -/* capplet widget */ -static GtkWidget *capplet=NULL; - -/* host/device/pilot configuration windows */ -GtkWidget *cfgOptionsWindow=NULL; -GtkWidget *cfgStateWindow=NULL; -GtkWidget *dialogWindow=NULL; - -gboolean activated,org_activation_state; -GnomePilotConduitManagement *conduit; -GnomePilotConduitConfig *conduit_config; -GCalConduitCfg *origState = NULL; -GCalConduitCfg *curState = NULL; - -static void doTrySettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg); -static void doRevertSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg); -static void doSaveSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg); - -//static void readStateCfg (GtkWidget *w, GCalConduitCfg *c); -static void setStateCfg (GtkWidget *w, GCalConduitCfg *c); - -gint pilotId; -CORBA_Environment ev; -static GnomePilotClient *gpc; - - - -/* This array must be in the same order as enumerations - in GnomePilotConduitSyncType as they are used as index. - Custom type implies Disabled state. -*/ -static gchar* sync_options[] ={ N_("Disabled"), - N_("Synchronize"), - N_("Copy From Pilot"), - N_("Copy To Pilot"), - N_("Merge From Pilot"), - N_("Merge To Pilot")}; -#define SYNC_OPTIONS_COUNT 6 - - - - -/* Saves the configuration data. */ -static void -gcalconduit_save_configuration(GCalConduitCfg *c) -{ - gchar prefix[256]; - - g_snprintf(prefix,255,"/gnome-pilot.d/todo-conduit/Pilot_%u/",c->pilotId); - - gnome_config_push_prefix(prefix); - gnome_config_set_bool ("open_secret", c->open_secret); - gnome_config_pop_prefix(); - - gnome_config_sync(); - gnome_config_drop_all(); -} - -/* Creates a duplicate of the configuration data */ -static GCalConduitCfg* -gcalconduit_dupe_configuration(GCalConduitCfg *c) { - GCalConduitCfg *retval; - g_return_val_if_fail(c!=NULL,NULL); - retval = g_new0(GCalConduitCfg,1); - retval->sync_type = c->sync_type; - retval->open_secret = c->open_secret; - retval->pilotId = c->pilotId; - return retval; -} - - -static void -doTrySettings(GtkWidget *widget, GCalConduitCfg *c) -{ - /* - readStateCfg (cfgStateWindow, curState); - if (activated) - gnome_pilot_conduit_config_enable (conduit_config, GnomePilotConduitSyncTypeCustom); - else - gnome_pilot_conduit_config_disable (conduit_config); - */ - - if (c->sync_type!=GnomePilotConduitSyncTypeCustom) - gnome_pilot_conduit_config_enable_with_first_sync (conduit_config, - c->sync_type, - c->sync_type, - TRUE); - else - gnome_pilot_conduit_config_disable (conduit_config); - - gcalconduit_save_configuration (c); -} - - -static void -doSaveSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg) -{ - doTrySettings(widget, GCalConduitCfg); - gcalconduit_save_configuration(GCalConduitCfg); -} - - -static void -doCancelSettings(GtkWidget *widget, GCalConduitCfg *c) -{ - doSaveSettings (widget, c); -} - - -static void -doRevertSettings(GtkWidget *widget, GCalConduitCfg *GCalConduitCfg) -{ - activated = org_activation_state; - setStateCfg (cfgStateWindow, curState); -} - -static void -about_cb (GtkWidget *widget, gpointer data) -{ - GtkWidget *about; - const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL}; - - about = gnome_about_new (_("Gpilotd todo conduit"), VERSION, - _("(C) 1998 the Free Software Foundation"), - authors, - _("Configuration utility for the todo conduit.\n"), - _("gnome-unknown.xpm")); - gtk_widget_show (about); - - return; -} - - -/* called by the sync_type GtkOptionMenu */ -static void -sync_action_selection(GtkMenuShell *widget, gpointer unused) -{ - if (!ignore_changes) { - capplet_widget_state_changed(CAPPLET_WIDGET (capplet), TRUE); - } -} - - -/* called by the sync_type GtkOptionMenu */ -static void -activate_sync_type(GtkMenuItem *widget, gpointer data) -{ - curState->sync_type = GPOINTER_TO_INT(data); - if(!ignore_changes) - capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); -} - - -static GtkWidget -*createStateCfgWindow(void) -{ - GtkWidget *vbox, *table; - GtkWidget *label; - GtkWidget *optionMenu,*menuItem; - GtkMenu *menu; - gint i; - - vbox = gtk_vbox_new(FALSE, GNOME_PAD); - - table = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD); - - label = gtk_label_new(_("Synchronize Action")); - gtk_box_pack_start(GTK_BOX(table), label, FALSE, FALSE, GNOME_PAD); - - optionMenu=gtk_option_menu_new(); - gtk_object_set_data(GTK_OBJECT(vbox), "conduit_state", optionMenu); - menu = GTK_MENU(gtk_menu_new()); - - for (i=0; i<SYNC_OPTIONS_COUNT;i++) { - sync_options[i]=_(sync_options[i]); - menuItem = gtk_menu_item_new_with_label(sync_options[i]); - gtk_widget_show(menuItem); - gtk_signal_connect(GTK_OBJECT(menuItem),"activate", - GTK_SIGNAL_FUNC(activate_sync_type), - GINT_TO_POINTER(i)); - gtk_menu_append(menu,menuItem); - } - - gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu)); - gtk_signal_connect(GTK_OBJECT(menu), "selection-done", - GTK_SIGNAL_FUNC(sync_action_selection), - NULL); - - gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0); - - return vbox; -} - - -static void -setStateCfg (GtkWidget *w, GCalConduitCfg *c) -{ - GtkOptionMenu *optionMenu; - GtkMenu *menu; - - optionMenu = gtk_object_get_data (GTK_OBJECT(w), "conduit_state"); - g_assert (optionMenu != NULL); - menu = GTK_MENU (gtk_option_menu_get_menu (optionMenu)); - - ignore_changes = TRUE; - /* Here were are relying on the items in menu being the same - order as in GnomePilotConduitSyncType. */ - gtk_option_menu_set_history (optionMenu, (int) c->sync_type); - ignore_changes = FALSE; -} - - -#if 0 -static void -readStateCfg (GtkWidget *w, GCalConduitCfg *c) -{ - /* - GtkWidget *button; - button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off"); - g_assert(button!=NULL); - activated = GTK_TOGGLE_BUTTON(button)->active; - */ -} -#endif /* 0 */ - - -static void -pilot_capplet_setup(void) -{ - GtkWidget *frame, *table; - - capplet = capplet_widget_new(); - - table = gtk_table_new(1, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD); - gtk_container_add(GTK_CONTAINER(capplet), table); - - frame = gtk_frame_new(_("Conduit state")); - gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL); - gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1); - cfgStateWindow = createStateCfgWindow(); - gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow); - - gtk_signal_connect(GTK_OBJECT(capplet), "try", - GTK_SIGNAL_FUNC(doTrySettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "revert", - GTK_SIGNAL_FUNC(doRevertSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "ok", - GTK_SIGNAL_FUNC(doSaveSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "cancel", - GTK_SIGNAL_FUNC(doCancelSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "help", - GTK_SIGNAL_FUNC(about_cb), NULL); - - - setStateCfg (cfgStateWindow, curState); - - gtk_widget_show_all (capplet); -} - - -static void -run_error_dialog(gchar *mesg,...) -{ - char tmp[80]; - va_list ap; - - va_start(ap,mesg); - vsnprintf(tmp,79,mesg,ap); - dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL); - gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow)); - va_end(ap); -} - - -static gint -get_pilot_id_from_gpilotd() -{ - GList *pilots=NULL; - gint pilot; - int i,err; - - i=0; - /* we don't worry about leaking here, so pilots isn't freed */ - switch(err = gnome_pilot_client_get_pilots(gpc,&pilots)) { - case GPILOTD_OK: { - if(pilots) { - for(i=0;i<g_list_length(pilots);i++) { - g_message("pilot %d = \"%s\"",i,(gchar*)g_list_nth(pilots,i)->data); - } - if(i==0) { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } else { - gnome_pilot_client_get_pilot_id_by_name(gpc, - pilots->data, /* this is the first pilot */ - &pilot); - if(i>1) { - g_message("too many pilots..."); - /* need a choose here */ - } - return pilot; - } - } else { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } - break; - } - case GPILOTD_ERR_NOT_CONNECTED: - run_error_dialog(_("Not connected to the gnome-pilot daemon")); - return -1; - break; - default: - g_warning("gnome_pilot_client_get_pilot_ids(...) = %d",err); - run_error_dialog(_("An error occured when trying to fetch\npilot list from the gnome-pilot daemon")); - return -1; - break; - } -} - - -int -main (int argc, char *argv[]) -{ - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - - /* we're a capplet */ - gnome_capplet_init ("todo conduit control applet", NULL, argc, argv, - NULL, 0, NULL); - - gpc = gnome_pilot_client_new(); - gnome_pilot_client_connect_to_daemon(gpc); - pilotId = get_pilot_id_from_gpilotd(); - if(!pilotId) return -1; - - /* put all code to set things up in here */ - gcalconduit_load_configuration (&origState, pilotId); - - conduit = gnome_pilot_conduit_management_new ("todo_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); - if (conduit == NULL) return -1; - conduit_config = gnome_pilot_conduit_config_new (conduit, pilotId); - org_activation_state = gnome_pilot_conduit_config_is_enabled (conduit_config, - &origState->sync_type); - activated = org_activation_state; - - //gpilotd_conduit_mgmt_get_sync_type (conduit, pilotId, &origState->sync_type); - - curState = gcalconduit_dupe_configuration(origState); - - pilot_capplet_setup (); - - - /* done setting up, now run main loop */ - capplet_gtk_main(); - - gnome_pilot_conduit_management_destroy(conduit); - - return 0; -} diff --git a/calendar/conduits/todo/todo-conduit-control-applet.desktop b/calendar/conduits/todo/todo-conduit-control-applet.desktop deleted file mode 100644 index 28bbeebde3..0000000000 --- a/calendar/conduits/todo/todo-conduit-control-applet.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Name=Todo conduit -Name[da]=Udstående -Name[no]=Oppgaver -Name[tr]=Yapýlacaklar parçasý -Comment=Configure the todo conduit -Comment[da]=Konfigurér Udstående -Comment[no]=Konfigurér oppgavelisten -Comment[tr]=Yapýlacaklar parçasý ayarlarý -Exec=todo-conduit-control-applet --cap-id=1 -Terminal=0 -Type=Application diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c deleted file mode 100644 index 2a3c643a3d..0000000000 --- a/calendar/conduits/todo/todo-conduit.c +++ /dev/null @@ -1,1355 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include <sys/stat.h> -#include <utime.h> -#include <unistd.h> -#include <pwd.h> -#include <signal.h> -#include <errno.h> - -#include <cal-client/cal-client.h> -// #include <cal-util/calobj.h> -#include <cal-util/timeutil.h> -#include <pi-source.h> -#include <pi-socket.h> -#include <pi-file.h> -#include <pi-dlp.h> -#include <libgnorba/gnorba.h> -#include <libgnorba/gnome-factory.h> -#include <pi-version.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-standard-abs.h> -#include <todo-conduit.h> -#include <libical/src/libical/icaltypes.h> - -#include <bonobo.h> - -//#include "GnomeCal.h" - -GnomePilotConduit * conduit_get_gpilot_conduit (guint32); -void conduit_destroy_gpilot_conduit (GnomePilotConduit*); -void local_record_from_icalobject (GCalLocalRecord *local, CalComponent *obj); - -#define CONDUIT_VERSION "0.8.11" -#ifdef G_LOG_DOMAIN -#undef G_LOG_DOMAIN -#endif -#define G_LOG_DOMAIN "todoconduit" - -#define DEBUG_CALCONDUIT 1 -/* #undef DEBUG_CALCONDUIT */ - -#ifdef DEBUG_CALCONDUIT -#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e)) -#define LOG(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e) -#else -#define show_exception(e) -#define LOG(e...) -#endif - -#define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e) -#define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e) - -#define catch_ret_val(_env,ret) \ - if (_env._major != CORBA_NO_EXCEPTION) { \ - g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \ - g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \ - CORBA_exception_free(&(_env)); \ - return ret; \ - } - - - -/* debug spew DELETE ME */ -static char *print_ical (CalComponent *obj - /*iCalObject *obj*/) -{ - static char buff[ 4096 ]; - - int indefinite; - CalComponentDateTime dtend; - int priority; - struct icaltimetype *complete; - CalComponentText summary; - GSList *comments; - CalComponentText *first_comment = NULL; - - if (obj == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - indefinite = 0; /* FIX ME how do i get this */ - cal_component_get_dtend (obj, &dtend); - priority = 1; /* FIX ME how do i get this */ - cal_component_get_completed (obj, &complete); - - cal_component_get_summary (obj, &summary); - cal_component_get_comment_list (obj, &comments); - if (comments) - first_comment = (CalComponentText *) comments->data; - - sprintf (buff, "[%d %d-%d-%d %d %d-%d-%d '%s' '%s']", - indefinite, - dtend.value->year, dtend.value->month, dtend.value->day, - priority, - complete->year, complete->month, complete->day, - summary.value, /* description */ - first_comment ? first_comment->value : "" /* note */ - ); - return buff; -} - - -/* debug spew DELETE ME */ -static char *print_local (GCalLocalRecord *local) -{ - static char buff[ 4096 ]; - - if (local == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - if (local->todo && local->todo->description) { - sprintf (buff, "[%d %ld %d %d '%s' '%s']", - local->todo->indefinite, - mktime (& local->todo->due), - local->todo->priority, - local->todo->complete, - local->todo->description, - local->todo->note); - return buff; - } - - return print_ical (local->ical); -} - - -/* debug spew DELETE ME */ -static char *print_remote (PilotRecord *remote) -{ - static char buff[ 4096 ]; - struct ToDo todo; - - if (remote == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - memset (&todo, 0, sizeof (struct ToDo)); - unpack_ToDo (&todo, remote->record, remote->length); - - sprintf (buff, "[%d %ld %d %d '%s' '%s']", - todo.indefinite, - mktime (& todo.due), - todo.priority, - todo.complete, - todo.description, - todo.note); - - return buff; -} - - - - -/* Destroys any data allocated by gcalconduit_load_configuration - and deallocates the given configuration. */ -static void -gcalconduit_destroy_configuration(GCalConduitCfg **c) -{ - g_return_if_fail(c!=NULL); - g_return_if_fail(*c!=NULL); - g_free(*c); - *c = NULL; -} - - -/* Given a GCalConduitContxt*, allocates the structure */ -static void -gcalconduit_new_context(GCalConduitContext **ctxt, - GCalConduitCfg *c) -{ - *ctxt = g_new0(GCalConduitContext,1); - g_assert(ctxt!=NULL); - (*ctxt)->cfg = c; - CORBA_exception_init (&((*ctxt)->ev)); -} - - -/* Destroys any data allocated by gcalconduit_new_context - and deallocates its data. */ -static void -gcalconduit_destroy_context(GCalConduitContext **ctxt) -{ - g_return_if_fail(ctxt!=NULL); - g_return_if_fail(*ctxt!=NULL); -/* - if ((*ctxt)->cfg!=NULL) - gcalconduit_destroy_configuration(&((*ctxt)->cfg)); -*/ - g_free(*ctxt); - *ctxt = NULL; -} - - -static void -gnome_calendar_load_cb (GtkWidget *cal_client, - CalClientLoadStatus status, - GCalConduitContext *ctxt) -{ - CalClient *client = CAL_CLIENT (cal_client); - - LOG (" todo-conduit entering gnome_calendar_load_cb, tried=%d\n", - ctxt->calendar_load_tried); - - if (status == CAL_CLIENT_LOAD_SUCCESS) { - ctxt->calendar_load_success = TRUE; - LOG (" success\n"); - gtk_main_quit (); /* end the sub event loop */ - } else { - if (ctxt->calendar_load_tried) { - LOG (" load and create of calendar failed\n"); - gtk_main_quit (); /* end the sub event loop */ - return; - } - - cal_client_create_calendar (client, ctxt->calendar_file); - ctxt->calendar_load_tried = 1; - } -} - - - - - -static int -start_calendar_server (GnomePilotConduitStandardAbs *conduit, - GCalConduitContext *ctxt) -{ - - g_return_val_if_fail(conduit!=NULL,-2); - g_return_val_if_fail(ctxt!=NULL,-2); - - ctxt->client = cal_client_new (); - - /* FIX ME */ - ctxt->calendar_file = g_concat_dir_and_file (g_get_home_dir (), - "evolution/local/Calendar/calendar.vcf"); - - gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded", - gnome_calendar_load_cb, ctxt); - - LOG (" calling cal_client_load_calendar\n"); - cal_client_load_calendar (ctxt->client, ctxt->calendar_file); - - /* run a sub event loop to turn cal-client's async load - notification into a synchronous call */ - gtk_main (); - - if (ctxt->calendar_load_success) - return 0; - - return -1; -} - - -#if 0 -/* Just a stub to link with */ -void calendar_notify (time_t time, CalendarAlarm *which, void *data); -void calendar_notify (time_t time, CalendarAlarm *which, void *data) { } -#endif /* 0 */ - - -static GSList * -get_calendar_objects(GnomePilotConduitStandardAbs *conduit, - gboolean *status, - GCalConduitContext *ctxt) -{ - GList *uids; - GSList *result = NULL; - - g_return_val_if_fail (conduit != NULL, NULL); - g_return_val_if_fail (ctxt != NULL, NULL); - - uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_TODO); - - // LOG ("got %d todo entries from cal server\n", g_list_length (uids)); - - if (status != NULL) - (*status) = TRUE; - - if (! uids) - INFO ("No entries found"); - else { - GList *c; - for (c=uids; c; c=c->next) - result = g_slist_prepend (result, (gchar *) c->data); - /* FIX ME free uids */ - } - - return result; -} - - -static void -local_record_from_ical_uid (GCalLocalRecord *local, - char *uid, - GCalConduitContext *ctxt) -{ - //iCalObject *obj; - CalComponent *obj; - CalClientGetStatus status; - - g_assert(local!=NULL); - - status = cal_client_get_object (ctxt->client, uid, &obj); - - if (status == CAL_CLIENT_GET_SUCCESS) - local_record_from_icalobject (local, obj); - else - INFO ("Object did not exist"); -} - - - -static char *gnome_pilot_status_to_string (gint status) -{ - switch(status) { - case GnomePilotRecordPending: return "GnomePilotRecordPending"; - case GnomePilotRecordNothing: return "GnomePilotRecordNothing"; - case GnomePilotRecordDeleted: return "GnomePilotRecordDeleted"; - case GnomePilotRecordNew: return "GnomePilotRecordNew"; - case GnomePilotRecordModified: return "GnomePilotRecordModified"; - } - - return "Unknown"; -} - - - -/* - * converts a iCalObject to a GCalLocalRecord - */ - -void -local_record_from_icalobject(GCalLocalRecord *local, - CalComponent *obj) -{ - //iCalPilotState pilot_status; - unsigned long int pilot_status; - - g_return_if_fail(local!=NULL); - g_return_if_fail(obj!=NULL); - - local->ical = obj; - local->todo = NULL; /* ??? */ - cal_component_get_pilot_id (obj, &local->local.ID); - cal_component_get_pilot_status (obj, &pilot_status); - - switch (pilot_status) { - case ICAL_PILOT_SYNC_NONE: - local->local.attr = GnomePilotRecordNothing; - break; - case ICAL_PILOT_SYNC_MOD: - local->local.attr = GnomePilotRecordModified; - break; - case ICAL_PILOT_SYNC_DEL: - local->local.attr = GnomePilotRecordDeleted; - break; - default: - g_warning ("unhandled pilot status: %ld\n", pilot_status); - } - - /* Records without a pilot_id are new */ - if(local->local.ID == 0) - local->local.attr = GnomePilotRecordNew; - - /* - local->local.secret = 0; - if (obj->class!=NULL) - if (strcmp(obj->class,"PRIVATE")==0) - local->local.secret = 1; - */ - - local->local.archived = 0; -} - - -/* - * Given a PilotRecord, find the matching record in - * the calendar repository. If no match, return NULL - */ -static GCalLocalRecord * -find_record_in_repository(GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - char *uid = NULL; - GCalLocalRecord *loc; - CalClientGetStatus status; - //iCalObject *obj; - CalComponent *obj; - - g_return_val_if_fail(conduit!=NULL,NULL); - g_return_val_if_fail(remote!=NULL,NULL); - - LOG ("find_record_in_repository: remote=%s... ", - print_remote (remote)); - - // LOG ("requesting %ld", remote->ID); - - status = cal_client_get_uid_by_pilot_id (ctxt->client, remote->ID, &uid); - - if (status == CAL_CLIENT_GET_SUCCESS) { - status = cal_client_get_object (ctxt->client, uid, &obj); - if (status == CAL_CLIENT_GET_SUCCESS) { - LOG ("found %s\n", print_ical (obj)); - loc = g_new0(GCalLocalRecord,1); - /* memory allocated in new_from_string is freed in free_match */ - local_record_from_icalobject (loc, obj); - return loc; - } - } - - // INFO ("Object did not exist"); - LOG ("not found\n"); - return NULL; -} - - -/* - * updates an given iCalObject in the repository - */ -static void -update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit, - CalComponent *obj, - GCalConduitContext *ctxt) -{ - gboolean success; - - g_return_if_fail (conduit!=NULL); - g_return_if_fail (obj!=NULL); - - LOG (" update_calendar_entry_in_repository " - "saving %s to desktop\n", - print_ical (obj)); - - success = cal_client_update_object (ctxt->client, obj); - - if (! success) { - WARN (_("Error while communicating with calendar server")); - } -} - - -static CalComponent * -ical_from_remote_record (GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - CalComponent *in_obj) -{ - CalComponent *obj; - struct ToDo todo; - struct icaltimetype now = icaltimetype_from_timet (time (NULL), FALSE); - - CalComponentText summary = {NULL, NULL}; - CalComponentText comment = {NULL, NULL}; - GSList *comment_list; - - g_return_val_if_fail(remote!=NULL,NULL); - memset (&todo, 0, sizeof (struct ToDo)); - unpack_ToDo (&todo, remote->record, remote->length); - - LOG (" ical_from_remote_record: " - "merging remote %s into local %s\n", - print_remote (remote), print_ical (in_obj)); - - if (in_obj == NULL) { - obj = cal_component_new (); - } else { - obj = in_obj; - } - - summary.value = todo.description; - cal_component_set_summary (obj, &summary); - - comment.value = todo.note; - comment_list = g_slist_append (NULL, &comment); - cal_component_set_comment_list (obj, comment_list); - g_slist_free (comment_list); - - cal_component_set_new_vtype (obj, CAL_COMPONENT_TODO); - // obj->new = TRUE; - // obj->created = now; - cal_component_set_created (obj, &now); - // obj->last_mod = now; - cal_component_set_last_modified (obj, &now); - /* obj->priority = 0; */ - // obj->transp = 0; - cal_component_set_transparency (obj, - /*CalComponentTransparency transp*/ - CAL_COMPONENT_TRANSP_NONE); - /* obj->related = NULL; */ - - // cal_component_set_pilot_status (obj, ICAL_PILOT_SYNC_NONE); - - /* - * Begin and end - */ - - // obj->dtend = mktime (& todo.due); - { - /* do i need to malloc these? FIX ME */ - struct icaltimetype dtend_ictt; - CalComponentDateTime dtend; - - dtend_ictt = icaltimetype_from_timet (mktime (& todo.due), FALSE); - dtend.value = &dtend_ictt; - dtend.tzid = NULL; - cal_component_set_dtend (obj, &dtend); - } - - - /* - if (todo.complete) { - obj->completed = now-5; - obj->percent = 100; - } - */ - { - cal_component_set_completed (obj, &now); - } - - /* - LOG ("[%s] from pilot, complete=%d/%ld\n", - todo.description, - todo.complete, - obj->completed); - */ - - - //obj->priority = todo.priority; FIX ME - - /* g_free (obj->class); */ - - /* - if (remote->attr & dlpRecAttrSecret) - obj->class = g_strdup ("PRIVATE"); - else - obj->class = g_strdup ("PUBLIC"); - */ - - if (remote->attr & dlpRecAttrSecret) - cal_component_set_classification (obj, CAL_COMPONENT_CLASS_PRIVATE); - else - cal_component_set_classification (obj, CAL_COMPONENT_CLASS_PUBLIC); - - free_ToDo(&todo); - - return obj; -} - - -/* Code blatantly stolen from - * calendar-pilot-sync.c: - * - * (C) 1999 International GNOME Support - * - * Author: - * Miguel de Icaza (miguel@gnome-support.com) - * - * store a copy of a pilot record in the desktop database - * - */ -static gint -update_record (GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - //iCalObject *obj; - CalComponent *obj; - struct ToDo todo; - CalClientGetStatus status; - char *uid; - - CalComponentText summary = {NULL, NULL}; - CalComponentText comment = {NULL, NULL}; - GSList *comment_list; - - g_return_val_if_fail(remote!=NULL,-1); - - memset (&todo, 0, sizeof (struct ToDo)); - unpack_ToDo (&todo, remote->record, remote->length); - - LOG (" cal_client_get_uid_by_pilot_id... "); - - status = cal_client_get_uid_by_pilot_id (ctxt->client, - remote->ID, &uid); - if (status == CAL_CLIENT_GET_SUCCESS) { - LOG (" succeeded with '%s'\n", uid); - LOG (" cal_client_get_object... "); - status = cal_client_get_object (ctxt->client, uid, &obj); - } - - if (status != CAL_CLIENT_GET_SUCCESS) { - struct icaltimetype now = icaltimetype_from_timet (time (NULL), FALSE); - - LOG ("failed, making a new one.\n"); - - obj = cal_component_new (); - - summary.value = todo.description; - cal_component_set_summary (obj, &summary); - - comment.value = todo.note; - comment_list = g_slist_append (NULL, &comment); - cal_component_set_comment_list (obj, comment_list); - g_slist_free (comment_list); - - // obj->type = ICAL_TODO; - cal_component_set_new_vtype (obj, CAL_COMPONENT_TODO); - // obj->new = TRUE; - // obj->created = now; - cal_component_set_created (obj, &now); - // obj->last_mod = now; - cal_component_set_last_modified (obj, &now); - // obj->priority = 0; - // obj->transp = 0; - cal_component_set_transparency (obj, - /*CalComponentTransparency transp*/ - CAL_COMPONENT_TRANSP_NONE); - // obj->related = NULL; - //obj->pilot_id = remote->ID; - //obj->pilot_status = ICAL_PILOT_SYNC_NONE; - cal_component_set_pilot_id (obj, remote->ID); - cal_component_set_pilot_status (obj, ICAL_PILOT_SYNC_NONE); - } else { - CalComponent *new_obj; - - LOG ("succeeded %s\n", print_ical (obj)); - - new_obj = ical_from_remote_record (conduit, remote, obj); - obj = new_obj; - } - - /* update record on server */ - { - const char *uid; - unsigned long pilot_id; - - cal_component_get_uid (obj, &uid); - cal_component_get_pilot_id (obj, &pilot_id); - - update_calendar_entry_in_repository (conduit, obj, ctxt); - cal_client_update_pilot_id (ctxt->client, (char *) uid, pilot_id, - ICAL_PILOT_SYNC_NONE); - } - - /* - * Shutdown - */ - //ical_object_unref (obj); - free_ToDo(&todo); - - return 0; -} - -static void -check_for_slow_setting (GnomePilotConduit *c, GCalConduitContext *ctxt) -{ - GList *uids; - unsigned long int entry_number; - - uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_TODO); - - entry_number = g_list_length (uids); - - /* If the local base is empty, do a slow sync */ - if (entry_number == 0) { - GnomePilotConduitStandard *conduit; - LOG (" doing slow sync\n"); - conduit = GNOME_PILOT_CONDUIT_STANDARD (c); - gnome_pilot_conduit_standard_set_slow (conduit); - } else { - LOG (" doing fast sync\n"); - } -} - -static gint -pre_sync (GnomePilotConduit *c, - GnomePilotDBInfo *dbi, - GCalConduitContext *ctxt) -{ - int l; - unsigned char *buf; - GnomePilotConduitStandardAbs *conduit; - /* gint num_records; */ - //GList *uids; - - /* - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - */ - - - conduit = GNOME_PILOT_CONDUIT_STANDARD_ABS(c); - - LOG ("---------------------------------------------------------\n"); - LOG ("pre_sync: ToDo Conduit v.%s", CONDUIT_VERSION); - g_message ("ToDo Conduit v.%s", CONDUIT_VERSION); - - ctxt->client = NULL; - - if (start_calendar_server (GNOME_PILOT_CONDUIT_STANDARD_ABS(c), ctxt) != 0) { - WARN(_("Could not start gnomecal server")); - gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c), - _("Could not start gnomecal server")); - return -1; - } - - -#if 0 - /* Set the counters for the progress bar crap */ - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev)); - - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev)); - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev)); - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); - num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev)); - catch_ret_val (ctxt->ev, -1); - gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), num_records); -#endif /* 0 */ - - gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi); - - /* load_records(c); */ - - buf = (unsigned char*)g_malloc(0xffff); - if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff)) < 0) { - WARN(_("Could not read pilot's ToDo application block")); - WARN("dlp_ReadAppBlock(...) = %d",l); - gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c), - _("Could not read pilot's ToDo application block")); - return -1; - } - unpack_ToDoAppInfo(&(ctxt->ai),buf,l); - g_free(buf); - - check_for_slow_setting(c,ctxt); - - return 0; -} - -/** - * Find (if possible) the local record which matches - * the given PilotRecord. - * if successfull, return non-zero and set *local to - * a non-null value (the located local record), - * otherwise return 0 and set *local = NULL; - */ - -static gint -match_record (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - LOG ("match_record: looking for local copy of %s\n", - print_remote (remote)); - - g_return_val_if_fail (local != NULL, -1); - g_return_val_if_fail (remote != NULL, -1); - - *local = find_record_in_repository(conduit,remote,ctxt); - - if (*local == NULL) - LOG (" match_record: not found.\n"); - else - LOG (" match_record: found, %s\n", print_local (*local)); - - if (*local==NULL) return -1; - return 0; -} - -/** - * Free the data allocated by a previous match_record call. - * If successfull, return non-zero and ser *local=NULL, otherwise - * return 0. - */ -static gint -free_match (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - GCalConduitContext *ctxt) -{ - LOG ("free_match: %s\n", print_local (*local)); - - g_return_val_if_fail (local!=NULL, -1); - g_return_val_if_fail (*local!=NULL, -1); - - // ical_object_unref (GCAL_LOCALRECORD(*local)->ical); - g_free (*local); - - *local = NULL; - return 0; -} - -/* - Move to archive and set status to Nothing - */ -static gint -archive_local (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - GCalConduitContext *ctxt) -{ - LOG ("archive_local: doing nothing with %s\n", print_local (local)); - - g_return_val_if_fail(local!=NULL,-1); - - return -1; -} - -/* - Store in archive and set status to Nothing - */ -static gint -archive_remote (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - LOG ("archive_remote: doing nothing with %s\n", - print_local (local)); - - //g_return_val_if_fail(remote!=NULL,-1); - //g_return_val_if_fail(local!=NULL,-1); - - return -1; -} - -/* - Store and set status to Nothing - */ -static gint -store_remote (GnomePilotConduitStandardAbs *conduit, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - LOG ("store_remote: copying pilot record %s to desktop\n", - print_remote (remote)); - - g_return_val_if_fail(remote!=NULL,-1); - remote->attr = GnomePilotRecordNothing; - - return update_record(conduit,remote,ctxt); -} - -static gint -clear_status_archive_local (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - GCalConduitContext *ctxt) -{ - LOG ("clear_status_archive_local: doing nothing\n"); - - g_return_val_if_fail(local!=NULL,-1); - - return -1; -} - -static gint -iterate (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - GCalConduitContext *ctxt) -{ - static GSList *events,*iterator; - static int hest; - - g_return_val_if_fail(local!=NULL,-1); - - if(*local==NULL) { - // LOG ("beginning iteration"); - - events = get_calendar_objects(conduit,NULL,ctxt); - hest = 0; - - if(events!=NULL) { - // LOG ("iterating over %d records", g_slist_length (events)); - *local = g_new0(GCalLocalRecord,1); - - local_record_from_ical_uid(*local,(gchar*)events->data,ctxt); - iterator = events; - } else { - // LOG ("no events"); - (*local) = NULL; - } - } else { - /* LOG ("continuing iteration\n"); */ - hest++; - if(g_slist_next(iterator)==NULL) { - GSList *l; - - // LOG ("ending"); - /** free stuff allocated for iteration */ - g_free((*local)); - - // LOG ("iterated over %d records", hest); - for(l=events;l;l=l->next) - g_free(l->data); - - g_slist_free(events); - - /* ends iteration */ - (*local) = NULL; - return 0; - } else { - iterator = g_slist_next(iterator); - local_record_from_ical_uid(*local,(gchar*)(iterator->data),ctxt); - } - } - return 1; -} - - -static gint -iterate_specific (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord **local, - gint flag, - gint archived, - GCalConduitContext *ctxt) -{ - (*local) = NULL; /* ??? */ - - /* debugging */ - { - gchar *tmp; - switch (flag) { - case GnomePilotRecordNothing: - tmp = g_strdup("RecordNothing"); break; - case GnomePilotRecordModified: - tmp = g_strdup("RecordModified"); break; - case GnomePilotRecordDeleted: - tmp = g_strdup("RecordDeleted"); break; - case GnomePilotRecordNew: - tmp = g_strdup("RecordNew"); break; - default: tmp = g_strdup_printf("0x%x",flag); break; - } - LOG ("\niterate_specific: (flag = %s)... ", tmp); - g_free(tmp); - } - - g_return_val_if_fail(local!=NULL,-1); - - /* iterate until a record meets the criteria */ - while (gnome_pilot_conduit_standard_abs_iterate (conduit, - (LocalRecord**)local)) { - if((*local)==NULL) break; - if(archived && ((*local)->local.archived==archived)) break; - if(((*local)->local.attr == flag)) break; - } - - if ((*local)) { - LOG (" found %s\n", print_local (*local)); - } else { - LOG (" no more found.\n"); - } - - return (*local)==NULL?0:1; -} - -static gint -purge (GnomePilotConduitStandardAbs *conduit, - GCalConduitContext *ctxt) -{ - LOG ("purge: doing nothing\n"); - - /* HEST, gem posterne her */ - - return -1; -} - - -static gint -set_status (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - gint status, - GCalConduitContext *ctxt) -{ - gboolean success; - iCalPilotState new_state; - - LOG ("set_status: %s status is now '%s'\n", - print_local (local), - gnome_pilot_status_to_string (status)); - - g_return_val_if_fail(local!=NULL,-1); - g_assert(local->ical!=NULL); - - local->local.attr = status; - switch(status) { - case GnomePilotRecordPending: - case GnomePilotRecordNothing: - new_state = ICAL_PILOT_SYNC_NONE; - break; - case GnomePilotRecordDeleted: - break; - case GnomePilotRecordNew: - case GnomePilotRecordModified: - new_state = ICAL_PILOT_SYNC_MOD; - break; - } - - if (status == GnomePilotRecordDeleted) { - const char *uid; - cal_component_get_uid (local->ical, &uid); - success = cal_client_remove_object (ctxt->client, uid); - } else { - const char *uid; - unsigned long pilot_id; - - cal_component_get_uid (local->ical, &uid); - cal_component_get_pilot_id (local->ical, &pilot_id); - - success = cal_client_update_object (ctxt->client, local->ical); - cal_client_update_pilot_id (ctxt->client, (char *) uid, - pilot_id, new_state); - } - - if (! success) { - WARN (_("Error while communicating with calendar server")); - } - - return 0; -} - -static gint -set_archived (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - gint archived, - GCalConduitContext *ctxt) -{ - LOG ("set_archived: %s archived flag is now '%d'\n", - print_local (local), archived); - - g_return_val_if_fail(local!=NULL,-1); - g_assert(local->ical!=NULL); - - local->local.archived = archived; - update_calendar_entry_in_repository(conduit,local->ical,ctxt); - /* FIXME: This should move the entry into a speciel - calendar file, eg. Archive, or (by config option), simply - delete it */ - return 0; -} - -static gint -set_pilot_id (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - guint32 ID, - GCalConduitContext *ctxt) -{ - const char *uid; - unsigned long int pilot_status; - - LOG ("set_pilot_id: %s pilot ID is now '%d'\n", - print_local (local), ID); - - g_return_val_if_fail(local!=NULL,-1); - g_assert(local->ical!=NULL); - - local->local.ID = ID; - cal_component_set_pilot_id (local->ical, ID); - - cal_component_get_uid (local->ical, &uid); - cal_component_get_pilot_status (local->ical, &pilot_status); - - cal_client_update_pilot_id (ctxt->client, - (char *) uid, - local->local.ID, - pilot_status); - - return 0; -} - -static gint -transmit (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord **remote, - GCalConduitContext *ctxt) -{ - PilotRecord *p; - /* priority; FIX ME */ - struct icaltimetype *completed; - CalComponentText summary; - GSList *comment_list = NULL; - CalComponentText *comment; - - LOG ("transmit: encoding local %s\n", print_local (local)); - - g_return_val_if_fail(local!=NULL,-1); - g_return_val_if_fail(remote!=NULL,-1); - g_assert(local->ical!=NULL); - - p = g_new0(PilotRecord,1); - - p->ID = local->local.ID; - p->attr = local->local.attr; - p->archived = local->local.archived; - p->secret = local->local.secret; - - local->todo = g_new0(struct ToDo,1); - - { - CalComponentDateTime dtend; - time_t dtend_time_t; - - cal_component_get_dtend (local->ical, &dtend); - dtend_time_t = time_from_icaltimetype (*dtend.value); - - local->todo->due = *localtime (&dtend_time_t); - local->todo->indefinite = (dtend.value->year == 0); - } - - //local->todo->priority = local->ical->priority; - local->todo->priority = 1; /* FIX ME */ - - cal_component_get_completed (local->ical, &completed); - if (completed->year > 0) - local->todo->complete = 1; /* FIX ME */ - - /* STOP: don't replace these with g_strdup, since free_ToDo - uses free to deallocte */ - - cal_component_get_summary (local->ical, &summary); - local->todo->description = - //local->ical->summary == NULL ? NULL : strdup (summary.value); - strdup ((char *) summary.value); - - - cal_component_get_comment_list (local->ical, &comment_list); - if (comment_list) { - comment = (CalComponentText *) comment_list->data; - if (comment && comment->value) - local->todo->note = strdup (comment->value); - else - local->todo->note = NULL; - } else { - local->todo->note = NULL; - } - - /* - LOG ("transmitting todo to pilot [%s] complete=%d/%ld\n", - local->ical->summary==NULL?"NULL":local->ical->summary, - local->todo->complete, local->ical->completed); - */ - - /* Generate pilot record structure */ - p->record = g_new0(char,0xffff); - p->length = pack_ToDo(local->todo,p->record,0xffff); - - *remote = p; - - return 0; -} - -static gint -free_transmit (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord **remote, - GCalConduitContext *ctxt) -{ - LOG ("free_transmit: freeing %s\n", - print_local (local)); - - g_return_val_if_fail(local!=NULL,-1); - g_return_val_if_fail(remote!=NULL,-1); - - /* free_ToDo(local->todo); */ /* FIX ME is this needed? */ - g_free((*remote)->record); - *remote = NULL; - return 0; -} - - -static gint -compare (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - /* used by the quick compare */ - PilotRecord *remoteOfLocal; - int err; - int retval; - - LOG ("compare: local=%s remote=%s...\n", - print_local (local), print_remote (remote)); - - g_return_val_if_fail (local!=NULL,-1); - g_return_val_if_fail (remote!=NULL,-1); - - err = transmit(conduit,local,&remoteOfLocal,ctxt); - if (err != 0) return err; - - retval = 0; - if (remote->length == remoteOfLocal->length) { - if (memcmp (remoteOfLocal->record, - remote->record, remote->length)!=0) { - LOG (" compare failed on contents\n"); - retval = 1; - } - } else { - LOG(" compare failed on length\n"); - retval = 1; - } - - - if (retval == 0) { - LOG (" match.\n"); - } else { - /* debug spew */ - LOG (" local:%s\n", print_remote (remoteOfLocal)); - LOG (" remote:%s\n", print_remote (remote)); - } - - free_transmit(conduit,local,&remoteOfLocal,ctxt); - return retval; -} - - -static gint -compare_backup (GnomePilotConduitStandardAbs *conduit, - GCalLocalRecord *local, - PilotRecord *remote, - GCalConduitContext *ctxt) -{ - LOG ("compare_backup: doing nothing\n"); - - g_return_val_if_fail(local!=NULL,-1); - g_return_val_if_fail(remote!=NULL,-1); - - return -1; -} - - -static gint -delete_all (GnomePilotConduitStandardAbs *conduit, - GCalConduitContext *ctxt) -{ - GSList *events,*it; - gboolean error; - gboolean success; - - events = get_calendar_objects(conduit,&error,ctxt); - - LOG ("delete_all: deleting all objects from desktop\n"); - - if (error == FALSE) return -1; - for (it=events; it; it = g_slist_next (it)) { - success = cal_client_remove_object (ctxt->client, it->data); - - if (!success) - INFO ("Object did not exist"); - - g_free (it->data); - } - - g_slist_free (events); - return -1; -} - - -static ORBit_MessageValidationResult -accept_all_cookies (CORBA_unsigned_long request_id, - CORBA_Principal *principal, - CORBA_char *operation) -{ - /* allow ALL cookies */ - return ORBIT_MESSAGE_ALLOW_ALL; -} - - -GnomePilotConduit * -conduit_get_gpilot_conduit (guint32 pilotId) -{ - GtkObject *retval; - GCalConduitCfg *cfg; - GCalConduitContext *ctxt; - - LOG ("in todo's conduit_get_gpilot_conduit\n"); - - /* we need to find wombat with oaf, so make sure oaf - is initialized here. once the desktop is converted - to oaf and gpilotd is built with oaf, this can go away */ - if (! oaf_is_initialized ()) - { - char *argv[ 1 ] = {"hi"}; - oaf_init (1, argv); - - if (bonobo_init (CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - ORBit_set_request_validation_handler (accept_all_cookies); - } - - retval = gnome_pilot_conduit_standard_abs_new ("ToDoDB", 0x746F646F); - g_assert (retval != NULL); - gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"ToDoConduit"); - - gcalconduit_load_configuration(&cfg,pilotId); - gtk_object_set_data(retval,"todoconduit_cfg",cfg); - - gcalconduit_new_context(&ctxt,cfg); - gtk_object_set_data(GTK_OBJECT(retval),"todoconduit_context",ctxt); - - gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt); - gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); - gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, ctxt); - gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, ctxt); - gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, ctxt); - gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt); - gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, ctxt); - gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, ctxt); - gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, ctxt); - gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, ctxt); - gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, ctxt); - gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt); - gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt); - gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, ctxt); - gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, ctxt); - gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, ctxt); - gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt); - gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt); - - return GNOME_PILOT_CONDUIT (retval); -} - -void -conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit) -{ - GCalConduitCfg *cc; - GCalConduitContext *ctxt; - - cc = GET_GCALCONFIG(conduit); - ctxt = GET_GCALCONTEXT(conduit); - - if (ctxt->client != NULL) { - gtk_object_unref (GTK_OBJECT (ctxt->client)); - //pi_close (ctxt->link); - //GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev)); - } - - gcalconduit_destroy_configuration (&cc); - - gcalconduit_destroy_context (&ctxt); - - gtk_object_destroy (GTK_OBJECT (conduit)); -} diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h deleted file mode 100644 index f01b52173d..0000000000 --- a/calendar/conduits/todo/todo-conduit.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#ifndef __TODO_CONDUIT_H__ -#define __TODO_CONDUIT_H__ - -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#include <gnome.h> -#include <pi-todo.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-standard-abs.h> -#include <cal-client/cal-client.h> -#include <cal-util/calobj.h> -#include <cal-util/timeutil.h> - -/* -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif -*/ - -#include <liboaf/liboaf.h> -#include <libgnorba/gnorba.h> - -/* This is the local record structure for the GnomeCal conduit. */ -typedef struct _GCalLocalRecord GCalLocalRecord; -struct _GCalLocalRecord { - /* The stuff from gnome-pilot-conduit-standard-abs.h - Must be first in the structure, or instances of this - structure cannot be used by gnome-pilot-conduit-standard-abs. - */ - LocalRecord local; - /* The corresponding iCal object, as found by GnomeCal. */ - //iCalObject *ical; - CalComponent *ical; - - /* pilot-link todo structure, used for implementing Transmit. */ - struct ToDo *todo; -}; -#define GCAL_LOCALRECORD(s) ((GCalLocalRecord*)(s)) - -/* This is the configuration of the GnomeCal conduit. */ -typedef struct _GCalConduitCfg GCalConduitCfg; -struct _GCalConduitCfg { - gboolean open_secret; - guint32 pilotId; - GnomePilotConduitSyncType sync_type; /* only used by capplet */ -}; -#define GET_GCALCONFIG(c) ((GCalConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"todoconduit_cfg")) - -/* This is the context for all the GnomeCal conduit methods. */ -typedef struct _GCalConduitContext GCalConduitContext; -struct _GCalConduitContext { - struct ToDoAppInfo ai; - GCalConduitCfg *cfg; - CalClient *client; - CORBA_Environment ev; - CORBA_ORB orb; - gboolean calendar_load_tried; - gboolean calendar_load_success; - - char *calendar_file; -}; -#define GET_GCALCONTEXT(c) ((GCalConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"todoconduit_context")) - - -/* Given a GCalConduitCfg*, allocates the structure and - loads the configuration data for the given pilot. - this is defined in the header file because it is used by - both todo-conduit and todo-conduit-control-applet, - and we don't want to export any symbols we don't have to. */ -static void -gcalconduit_load_configuration(GCalConduitCfg **c, - guint32 pilotId) -{ - gchar prefix[256]; - g_snprintf(prefix,255,"/gnome-pilot.d/todo-conduit/Pilot_%u/",pilotId); - - *c = g_new0(GCalConduitCfg,1); - g_assert(*c != NULL); - gnome_config_push_prefix(prefix); - (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE"); - (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */ - gnome_config_pop_prefix(); - - (*c)->pilotId = pilotId; -} - - -#endif __TODO_CONDUIT_H__ diff --git a/calendar/conduits/todo/todo.conduit.in b/calendar/conduits/todo/todo.conduit.in deleted file mode 100644 index b940c2b498..0000000000 --- a/calendar/conduits/todo/todo.conduit.in +++ /dev/null @@ -1,8 +0,0 @@ -<gnome-pilot-conduit version="1.0"> -<conduit id="todo_conduit" type="shlib" location="@prefix@/lib/gnome-pilot/conduits/libtodo_conduit.so"/> -<name value="todo"/> -<conduit-attribute name="description" value="Synchronizes with Evolution"/> -<conduit-attribute name="default-synctype" value="synchronize"/> -<conduit-attribute name="icon" value="@prefix@/share/pixmaps/gnome-calendar-conduit.png"/> -<conduit-attribute name="settings" value="TRUE"/> -</gnome-pilot-conduit> diff --git a/calendar/gui/.cvsignore b/calendar/gui/.cvsignore deleted file mode 100644 index c55e5d266f..0000000000 --- a/calendar/gui/.cvsignore +++ /dev/null @@ -1,21 +0,0 @@ -Makefile.in -Makefile -.deps -_libs -.libs -.pure -gncal -evolution-calendar -evolution-calendar.pure -test-calendar-widget -getdate.c -GnomeCal-skels.c -GnomeCal-common.c -GnomeCal.h -calendar-pilot-sync -evolution-calendar-stubs.c -evolution-calendar-skels.c -evolution-calendar-common.c -evolution-calendar.h -GnomeCal-stubs.c -*.lo diff --git a/calendar/gui/GNOME_Evolution_Calendar.oaf.in b/calendar/gui/GNOME_Evolution_Calendar.oaf.in deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar.oaf.in +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar.oafinfo b/calendar/gui/GNOME_Evolution_Calendar.oafinfo deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar.oafinfo +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_Control.oaf.in b/calendar/gui/GNOME_Evolution_Calendar_Control.oaf.in deleted file mode 100644 index fb0f138caf..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_Control.oaf.in +++ /dev/null @@ -1,28 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the sample Calendar control"/> -</oaf_server> - -<oaf_server iid="OAFIID:control:calendar:dd34ddae-25c6-486b-a8a8-3e8f0286b54c" - type="factory" - location="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/calendar-control:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="A sample Bonobo control which displays an calendar."/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_Control.oafinfo b/calendar/gui/GNOME_Evolution_Calendar_Control.oafinfo deleted file mode 100644 index fb0f138caf..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_Control.oafinfo +++ /dev/null @@ -1,28 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the sample Calendar control"/> -</oaf_server> - -<oaf_server iid="OAFIID:control:calendar:dd34ddae-25c6-486b-a8a8-3e8f0286b54c" - type="factory" - location="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/calendar-control:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="A sample Bonobo control which displays an calendar."/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am deleted file mode 100644 index 4927f7c6b6..0000000000 --- a/calendar/gui/Makefile.am +++ /dev/null @@ -1,143 +0,0 @@ -SUBDIRS = dialogs - -help_base = $(datadir)/gnome/help/cal - -bin_PROGRAMS = evolution-calendar - -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" - -INCLUDES = \ - -DG_LOG_DOMAIN=\"calendar-gui\" \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/shell \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_srcdir)/libical/src/libical \ - -I$(top_srcdir)/widgets \ - -I$(includedir) \ - $(BONOBO_VFS_GNOME_CFLAGS) \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" - -LINK_FLAGS = \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(INTLLIBS) \ - dialogs/libcal-dialogs.a \ - $(top_builddir)/calendar/cal-client/libcal-client.la \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/widgets/e-paned/libepaned.a \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical.a - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - event-editor-dialog.glade - -glade_messages = event-editor-dialog.glade.h - -evolution_calendar_SOURCES = \ - alarm.c \ - alarm.h \ - calendar-commands.c \ - calendar-commands.h \ - calendar-model.c \ - calendar-model.h \ - control-factory.c \ - control-factory.h \ - component-factory.c \ - component-factory.h \ - e-calendar-table.h \ - e-calendar-table.c \ - e-day-view-main-item.c \ - e-day-view-main-item.h \ - e-day-view-time-item.c \ - e-day-view-time-item.h \ - e-day-view-top-item.c \ - e-day-view-top-item.h \ - e-day-view.c \ - e-day-view.h \ - e-week-view-event-item.c \ - e-week-view-event-item.h \ - e-week-view-main-item.c \ - e-week-view-main-item.h \ - e-week-view-titles-item.c \ - e-week-view-titles-item.h \ - e-week-view.c \ - e-week-view.h \ - event-editor.c \ - event-editor.h \ - getdate.y \ - gncal-todo.c \ - gncal-todo.h \ - gnome-cal.c \ - gnome-cal.h \ - gnome-month-item.c \ - gnome-month-item.h \ - goto.c \ - main.c \ - mark.c \ - mark.h \ - popup-menu.c \ - popup-menu.h \ - print.c \ - print.h \ - prop.c - -evolution_calendar_LDADD = \ - $(top_builddir)/shell/libeshell.a \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_HTML_GNOME_LIBS) \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la \ - $(LINK_FLAGS) - -evolution_calendar_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -if USING_OAF -oafdir = $(datadir)/oaf -oaf_DATA = calendar-control.oafinfo evolution-calendar.oafinfo -else -gnorbadir = $(sysconfdir)/CORBA/servers -gnorba_DATA = calendar-control.gnorba evolution-calendar.gnorba -endif - -OAF_GNORBA_EXTRAS = calendar-control.oafinfo evolution-calendar.oafinfo calendar-control.gnorba evolution-calendar.gnorba -EXTRA_DIST = \ - $(OAF_GNORBA_EXTRAS) \ - $(glade_DATA) \ - bell.xpm \ - dayview.xpm \ - jump.xpm \ - monthview.xpm \ - recur.xpm \ - task-assigned-to.xpm \ - task-assigned.xpm \ - task-recurring.xpm \ - task.xpm \ - weekview.xpm \ - workweekview.xpm \ - yearview.xpm \ - calendar-control.gnorba \ - calendar-control.oafinfo - - -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(help_base)/C - $(mkinstalldirs) $(Conduitsdir) - -if ENABLE_PURIFY -PLINK = $(LIBTOOL) --mode=link $(PURIFY) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ - -all-local: evolution-calendar.pure - -evolution-calendar.pure: evolution-calendar - @rm -f evolution-calendar.pure - $(PLINK) $(evolution_calendar_LDFLAGS) $(evolution_calendar_OBJECTS) $(evolution_calendar_LDADD) $(LIBS) - -endif diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c deleted file mode 100644 index 7d8357599c..0000000000 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include "alarm-notify-dialog.h" - - - -/* The useful contents of the alarm notify dialog */ -typedef struct { - GladeXML *xml; - - GtkWidget *dialog; - GtkWidget *close; - GtkWidget *snooze; - GtkWidget *edit; - GtkWidget *heading; - GtkWidget *summary; - GtkWidget *snooze_time; - - AlarmNotifyFunc func; - gpointer func_data; -} AlarmNotify; - - - -/* Callback used when the notify dialog is destroyed */ -static void -dialog_destroy_cb (GtkObject *object, gpointer data) -{ - AlarmNotify *an; - - an = data; - gtk_object_unref (GTK_OBJECT (an->xml)); - g_free (an); -} - -/* Delete_event handler for the alarm notify dialog */ -static gint -delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (widget); - return TRUE; -} - -/* Callback for the close button */ -static void -close_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the snooze button */ -static void -snooze_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - int snooze_time; - - an = data; - g_assert (an->func != NULL); - - snooze_time = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time)); - (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_time, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the edit button */ -static void -edit_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/** - * alarm_notify_dialog: - * @trigger: Trigger time for the alarm. - * @occur: Occurrence time for the event. - * @comp: Calendar component object which corresponds to the alarm. - * @func: Function to be called when a dialog action is invoked. - * @func_data: Closure data for @func. - * - * Runs the alarm notification dialog. The specified @func will be used to - * notify the client about result of the actions in the dialog. - * - * Return value: TRUE on success, FALSE if the dialog could not be created. - **/ -gboolean -alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, - AlarmNotifyFunc func, gpointer func_data) -{ - AlarmNotify *an; - char buf[256]; - struct tm tm_trigger; - struct tm tm_occur; - CalComponentText summary; - - g_return_val_if_fail (trigger != -1, FALSE); - g_return_val_if_fail (occur != -1, FALSE); - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - g_return_val_if_fail (func != NULL, FALSE); - - an = g_new0 (AlarmNotify, 1); - - an->func = func; - an->func_data = func_data; - - an->xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-notify.glade", NULL); - if (!an->xml) { - g_message ("alarm_notify_dialog(): Could not load the Glade XML file!"); - g_free (an); - return FALSE; - } - - an->dialog = glade_xml_get_widget (an->xml, "alarm-notify"); - an->close = glade_xml_get_widget (an->xml, "close"); - an->snooze = glade_xml_get_widget (an->xml, "snooze"); - an->edit = glade_xml_get_widget (an->xml, "edit"); - an->heading = glade_xml_get_widget (an->xml, "heading"); - an->summary = glade_xml_get_widget (an->xml, "summary"); - an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time"); - - if (!(an->dialog && an->close && an->snooze && an->edit && an->heading && an->summary - && an->snooze_time)) { - g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!"); - gtk_object_unref (GTK_OBJECT (an->xml)); - g_free (an); - return FALSE; - } - - gtk_object_set_data (GTK_OBJECT (an->dialog), "alarm-notify", an); - gtk_signal_connect (GTK_OBJECT (an->dialog), "destroy", - GTK_SIGNAL_FUNC (dialog_destroy_cb), an); - - /* Title */ - - /* FIXME: use am_pm_flag or 24-hour time */ - - tm_trigger = *localtime (&trigger); - strftime (buf, sizeof (buf), _("Alarm on %A %b %d %Y %H:%M"), &tm_trigger); - gtk_window_set_title (GTK_WINDOW (an->dialog), buf); - - /* Heading */ - - tm_occur = *localtime (&occur); - strftime (buf, sizeof (buf), - _("Notification about your appointment on %A %b %d %Y %H:%M"), - &tm_occur); - gtk_label_set_text (GTK_LABEL (an->heading), buf); - - /* Summary */ - - cal_component_get_summary (comp, &summary); - - if (summary.value) - gtk_label_set_text (GTK_LABEL (an->summary), summary.value); - else - gtk_label_set_text (GTK_LABEL (an->summary), _("No summary available.")); - - /* Connect actions */ - - gtk_signal_connect (GTK_OBJECT (an->dialog), "delete_event", - GTK_SIGNAL_FUNC (delete_event_cb), - an); - - gtk_signal_connect (GTK_OBJECT (an->close), "clicked", - GTK_SIGNAL_FUNC (close_clicked_cb), - an); - - gtk_signal_connect (GTK_OBJECT (an->snooze), "clicked", - GTK_SIGNAL_FUNC (snooze_clicked_cb), - an); - - gtk_signal_connect (GTK_OBJECT (an->edit), "clicked", - GTK_SIGNAL_FUNC (edit_clicked_cb), - an); - - /* Run! */ - - gtk_widget_show (an->dialog); - return TRUE; -} diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.h b/calendar/gui/alarm-notify/alarm-notify-dialog.h deleted file mode 100644 index 1e56f1c586..0000000000 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_NOTIFY_DIALOG_H -#define ALARM_NOTIFY_DIALOG_H - -#include <time.h> -#include <glib.h> -#include <cal-util/cal-component.h> - - - -typedef enum { - ALARM_NOTIFY_CLOSE, - ALARM_NOTIFY_SNOOZE, - ALARM_NOTIFY_EDIT -} AlarmNotifyResult; - -typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data); - -gboolean alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, - AlarmNotifyFunc func, gpointer func_data); - - - -#endif diff --git a/calendar/gui/alarm-notify/alarm-notify.glade b/calendar/gui/alarm-notify/alarm-notify.glade deleted file mode 100644 index 32d7e03f8b..0000000000 --- a/calendar/gui/alarm-notify/alarm-notify.glade +++ /dev/null @@ -1,230 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>Evolution Calendar</name> - <program_name>evolution-calendar</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>alarm-notify.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GtkWindow</class> - <name>alarm-notify</name> - <cxx_use_heap>True</cxx_use_heap> - <title></title> - <type>GTK_WINDOW_DIALOG</type> - <position>GTK_WIN_POS_CENTER</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> - <auto_shrink>False</auto_shrink> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox5</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>heading</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>summary</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>close</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Close</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>snooze</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Snooze</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>edit</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Edit appointment</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <cxx_use_heap>True</cxx_use_heap> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label4</name> - <cxx_use_heap>True</cxx_use_heap> - <label>Snooze time (minutes)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>snooze-time</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>5</value> - <lower>1</lower> - <upper>1440</upper> - <step>1</step> - <page>5</page> - <page_size>5</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c deleted file mode 100644 index c89b65ff5e..0000000000 --- a/calendar/gui/alarm-notify/alarm.c +++ /dev/null @@ -1,304 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <time.h> -#include <gnome.h> -#include <fcntl.h> -#include <signal.h> -#include <sys/time.h> -#include "alarm.h" - - - -/* The pipes used to notify about an alarm */ -static int alarm_pipes [2]; - -/* The list of pending alarms */ -static GList *alarms; - -/* A queued alarm structure */ -typedef struct { - time_t trigger; - AlarmFunction alarm_fn; - gpointer data; - AlarmDestroyNotify destroy_notify_fn; -} AlarmRecord; - - - -/* SIGALRM handler. Notifies the callback about the alarm. */ -static void -alarm_signal (int arg) -{ - char c = 0; - - write (alarm_pipes [1], &c, 1); -} - -/* Sets up an itimer and returns a success code */ -static gboolean -setup_itimer (time_t diff) -{ - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = diff; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - - return (v == 0) ? TRUE : FALSE; -} - -/* Removes the head alarm, returns it, and schedules the next alarm in the - * queue. - */ -static AlarmRecord * -pop_alarm (void) -{ - AlarmRecord *ar; - GList *l; - - if (!alarms) - return NULL; - - ar = alarms->data; - - l = alarms; - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - - if (alarms) { - time_t now; - AlarmRecord *new_ar; - - now = time (NULL); - new_ar = alarms->data; - - if (!setup_itimer (new_ar->trigger - now)) { - g_message ("pop_alarm(): Could not reset the timer! " - "Weird things will happen."); - - /* FIXME: should we free the alarm list? What - * about further alarm removal requests that - * will fail? - */ - } - } else { - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - if (v != 0) - g_message ("pop_alarm(): Could not clear the timer! " - "Weird things may happen."); - } - - return ar; -} - -/* Input handler for our own alarm notification pipe */ -static void -alarm_ready (gpointer data, gint fd, GdkInputCondition cond) -{ - AlarmRecord *ar; - char c; - - if (read (alarm_pipes [0], &c, 1) != 1) { - g_message ("alarm_ready(): Uh? Could not read from notification pipe."); - return; - } - - g_assert (alarms != NULL); - ar = pop_alarm (); - - g_message ("alarm_ready(): Notifying about alarm on %s", ctime (&ar->trigger)); - - (* ar->alarm_fn) (ar, ar->trigger, ar->data); - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -static int -compare_alarm_by_time (gconstpointer a, gconstpointer b) -{ - const AlarmRecord *ara = a; - const AlarmRecord *arb = b; - time_t diff; - - diff = ara->trigger - arb->trigger; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - -/* Adds an alarm to the queue and sets up the timer */ -static gboolean -queue_alarm (time_t now, AlarmRecord *ar) -{ - time_t diff; - AlarmRecord *old_head; - - if (alarms) - old_head = alarms->data; - else - old_head = NULL; - - alarms = g_list_insert_sorted (alarms, ar, compare_alarm_by_time); - - if (old_head == alarms->data) - return TRUE; - - /* Set the timer for removal upon activation */ - - diff = ar->trigger - now; - if (!setup_itimer (diff)) { - GList *l; - - g_message ("queue_alarm(): Could not set up timer! Not queueing alarm."); - - l = g_list_find (alarms, ar); - g_assert (l != NULL); - - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - return FALSE; - } - - return TRUE; -} - -/** - * alarm_add: - * @trigger: Time at which alarm will trigger. - * @alarm_fn: Callback for trigger. - * @data: Closure data for callback. - * - * Adds an alarm to trigger at the specified time. The @alarm_fn will be called - * with the provided data and the alarm will be removed from the trigger list. - * - * Return value: An identifier for this alarm; it can be used to remove the - * alarm later with alarm_remove(). If the trigger time occurs in the past, then - * the alarm will not be queued and the function will return NULL. - **/ -gpointer -alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn) -{ - time_t now; - AlarmRecord *ar; - - now = time (NULL); - if (trigger < now) - return NULL; - - ar = g_new (AlarmRecord, 1); - ar->trigger = trigger; - ar->alarm_fn = alarm_fn; - ar->data = data; - ar->destroy_notify_fn = destroy_notify_fn; - - g_message ("alarm_add(): Adding alarm for %s", ctime (&trigger)); - - if (!queue_alarm (now, ar)) { - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); - ar = NULL; - } - - return ar; -} - -/** - * alarm_remove: - * @alarm: A queued alarm identifier. - * - * Removes an alarm from the alarm queue. - **/ -void -alarm_remove (gpointer alarm) -{ - AlarmRecord *ar; - AlarmRecord *old_head; - GList *l; - - ar = alarm; - - l = g_list_find (alarms, ar); - if (!l) { - g_message ("alarm_remove(): Requested removal of nonexistent alarm!"); - return; - } - - old_head = alarms->data; - - if (old_head == ar) - pop_alarm (); - else { - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - } - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -/** - * alarm_init: - * @void: - * - * Initializes the alarm notification system. This must be called near the - * beginning of the program. - **/ -void -alarm_init (void) -{ - struct sigaction sa; - int flags; - - pipe (alarm_pipes); - - /* set non blocking mode */ - flags = 0; - fcntl (alarm_pipes [0], F_GETFL, &flags); - fcntl (alarm_pipes [0], F_SETFL, flags | O_NONBLOCK); - gdk_input_add (alarm_pipes [0], GDK_INPUT_READ, alarm_ready, NULL); - - /* Setup the signal handler */ - sa.sa_handler = alarm_signal; - sigemptyset (&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sigaction (SIGALRM, &sa, NULL); -} diff --git a/calendar/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h deleted file mode 100644 index 2394d28024..0000000000 --- a/calendar/gui/alarm-notify/alarm.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_H -#define ALARM_H - -#include <time.h> - - - -typedef void (* AlarmFunction) (gpointer alarm_id, time_t trigger, gpointer data); -typedef void (* AlarmDestroyNotify) (gpointer data); - -void alarm_init (void); -gpointer alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn); -void alarm_remove (gpointer alarm); - - - -#endif diff --git a/calendar/gui/alarm.c b/calendar/gui/alarm.c deleted file mode 100644 index c89b65ff5e..0000000000 --- a/calendar/gui/alarm.c +++ /dev/null @@ -1,304 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <time.h> -#include <gnome.h> -#include <fcntl.h> -#include <signal.h> -#include <sys/time.h> -#include "alarm.h" - - - -/* The pipes used to notify about an alarm */ -static int alarm_pipes [2]; - -/* The list of pending alarms */ -static GList *alarms; - -/* A queued alarm structure */ -typedef struct { - time_t trigger; - AlarmFunction alarm_fn; - gpointer data; - AlarmDestroyNotify destroy_notify_fn; -} AlarmRecord; - - - -/* SIGALRM handler. Notifies the callback about the alarm. */ -static void -alarm_signal (int arg) -{ - char c = 0; - - write (alarm_pipes [1], &c, 1); -} - -/* Sets up an itimer and returns a success code */ -static gboolean -setup_itimer (time_t diff) -{ - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = diff; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - - return (v == 0) ? TRUE : FALSE; -} - -/* Removes the head alarm, returns it, and schedules the next alarm in the - * queue. - */ -static AlarmRecord * -pop_alarm (void) -{ - AlarmRecord *ar; - GList *l; - - if (!alarms) - return NULL; - - ar = alarms->data; - - l = alarms; - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - - if (alarms) { - time_t now; - AlarmRecord *new_ar; - - now = time (NULL); - new_ar = alarms->data; - - if (!setup_itimer (new_ar->trigger - now)) { - g_message ("pop_alarm(): Could not reset the timer! " - "Weird things will happen."); - - /* FIXME: should we free the alarm list? What - * about further alarm removal requests that - * will fail? - */ - } - } else { - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - if (v != 0) - g_message ("pop_alarm(): Could not clear the timer! " - "Weird things may happen."); - } - - return ar; -} - -/* Input handler for our own alarm notification pipe */ -static void -alarm_ready (gpointer data, gint fd, GdkInputCondition cond) -{ - AlarmRecord *ar; - char c; - - if (read (alarm_pipes [0], &c, 1) != 1) { - g_message ("alarm_ready(): Uh? Could not read from notification pipe."); - return; - } - - g_assert (alarms != NULL); - ar = pop_alarm (); - - g_message ("alarm_ready(): Notifying about alarm on %s", ctime (&ar->trigger)); - - (* ar->alarm_fn) (ar, ar->trigger, ar->data); - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -static int -compare_alarm_by_time (gconstpointer a, gconstpointer b) -{ - const AlarmRecord *ara = a; - const AlarmRecord *arb = b; - time_t diff; - - diff = ara->trigger - arb->trigger; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - -/* Adds an alarm to the queue and sets up the timer */ -static gboolean -queue_alarm (time_t now, AlarmRecord *ar) -{ - time_t diff; - AlarmRecord *old_head; - - if (alarms) - old_head = alarms->data; - else - old_head = NULL; - - alarms = g_list_insert_sorted (alarms, ar, compare_alarm_by_time); - - if (old_head == alarms->data) - return TRUE; - - /* Set the timer for removal upon activation */ - - diff = ar->trigger - now; - if (!setup_itimer (diff)) { - GList *l; - - g_message ("queue_alarm(): Could not set up timer! Not queueing alarm."); - - l = g_list_find (alarms, ar); - g_assert (l != NULL); - - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - return FALSE; - } - - return TRUE; -} - -/** - * alarm_add: - * @trigger: Time at which alarm will trigger. - * @alarm_fn: Callback for trigger. - * @data: Closure data for callback. - * - * Adds an alarm to trigger at the specified time. The @alarm_fn will be called - * with the provided data and the alarm will be removed from the trigger list. - * - * Return value: An identifier for this alarm; it can be used to remove the - * alarm later with alarm_remove(). If the trigger time occurs in the past, then - * the alarm will not be queued and the function will return NULL. - **/ -gpointer -alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn) -{ - time_t now; - AlarmRecord *ar; - - now = time (NULL); - if (trigger < now) - return NULL; - - ar = g_new (AlarmRecord, 1); - ar->trigger = trigger; - ar->alarm_fn = alarm_fn; - ar->data = data; - ar->destroy_notify_fn = destroy_notify_fn; - - g_message ("alarm_add(): Adding alarm for %s", ctime (&trigger)); - - if (!queue_alarm (now, ar)) { - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); - ar = NULL; - } - - return ar; -} - -/** - * alarm_remove: - * @alarm: A queued alarm identifier. - * - * Removes an alarm from the alarm queue. - **/ -void -alarm_remove (gpointer alarm) -{ - AlarmRecord *ar; - AlarmRecord *old_head; - GList *l; - - ar = alarm; - - l = g_list_find (alarms, ar); - if (!l) { - g_message ("alarm_remove(): Requested removal of nonexistent alarm!"); - return; - } - - old_head = alarms->data; - - if (old_head == ar) - pop_alarm (); - else { - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - } - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -/** - * alarm_init: - * @void: - * - * Initializes the alarm notification system. This must be called near the - * beginning of the program. - **/ -void -alarm_init (void) -{ - struct sigaction sa; - int flags; - - pipe (alarm_pipes); - - /* set non blocking mode */ - flags = 0; - fcntl (alarm_pipes [0], F_GETFL, &flags); - fcntl (alarm_pipes [0], F_SETFL, flags | O_NONBLOCK); - gdk_input_add (alarm_pipes [0], GDK_INPUT_READ, alarm_ready, NULL); - - /* Setup the signal handler */ - sa.sa_handler = alarm_signal; - sigemptyset (&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sigaction (SIGALRM, &sa, NULL); -} diff --git a/calendar/gui/alarm.h b/calendar/gui/alarm.h deleted file mode 100644 index 2394d28024..0000000000 --- a/calendar/gui/alarm.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_H -#define ALARM_H - -#include <time.h> - - - -typedef void (* AlarmFunction) (gpointer alarm_id, time_t trigger, gpointer data); -typedef void (* AlarmDestroyNotify) (gpointer data); - -void alarm_init (void); -gpointer alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn); -void alarm_remove (gpointer alarm); - - - -#endif diff --git a/calendar/gui/bell.xpm b/calendar/gui/bell.xpm deleted file mode 100644 index b1ab537a17..0000000000 --- a/calendar/gui/bell.xpm +++ /dev/null @@ -1,83 +0,0 @@ -/* XPM */ -static char * bell_xpm[] = { -"16 16 64 1", -" c None", -". c #000000", -"+ c #E3BB43", -"@ c #E6C049", -"# c #EED275", -"$ c #F4E193", -"% c #F4DF8C", -"& c #EAC95C", -"* c #EFD57A", -"= c #FAEFBB", -"- c #FDF6D3", -"; c #FDF5C6", -"> c #F4E18F", -", c #E4BD43", -"' c #F6E295", -") c #FEF9D8", -"! c #FFFFFF", -"~ c #FFFADA", -"{ c #FCEEAA", -"] c #EBCA5A", -"^ c #E9C550", -"/ c #FAEA9C", -"( c #FEF7CB", -"_ c #FFF8CC", -": c #FDF1A8", -"< c #EED060", -"[ c #D39D12", -"} c #F2D55D", -"| c #FCEC91", -"1 c #FFF4AE", -"2 c #FFF5B6", -"3 c #FEEF97", -"4 c #F3D65E", -"5 c #D5A216", -"6 c #FAE05C", -"7 c #FFED7C", -"8 c #FFEF8C", -"9 c #FFF092", -"0 c #FDEB7A", -"a c #F4D750", -"b c #D8A717", -"c c #EAC01D", -"d c #F6D83E", -"e c #FAE255", -"f c #FAE362", -"g c #F9E161", -"h c #F6DE5B", -"i c #F1D145", -"j c #E6BE28", -"k c #D09B09", -"l c #B67E00", -"m c #CE9100", -"n c #D69F04", -"o c #E0B011", -"p c #E6BA1D", -"q c #E3B721", -"r c #E0B21E", -"s c #DCAB16", -"t c #D7A20D", -"u c #CC9303", -"v c #BE8400", -"w c #AC7500", -"x c #A06B00", -"y c #FFDD00", -" ", -" .. ", -" .+@. ", -" .#$%&. ", -" .*=-;>,. ", -" .')!~{]. ", -" .^/(~_:<[. ", -" .}|121345. ", -" .678980ab. ", -" .cdefghijkl. ", -" .mnopqrstuvwx. ", -" .............. ", -" .8y. ", -" .. ", -" ", -" "}; diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c deleted file mode 100644 index 2dd63f832c..0000000000 --- a/calendar/gui/calendar-commands.c +++ /dev/null @@ -1,855 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Main file for the GNOME Calendar program - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: - * Miguel de Icaza (miguel@kernel.org) - * Federico Mena (federico@helixcode.com) - */ - -#include <config.h> -#include <pwd.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <string.h> -#include <ctype.h> -#include <errno.h> -#include <gnome.h> -#include <libgnorba/gnorba.h> -#include <bonobo.h> -#include <cal-util/timeutil.h> -#include "gnome-cal.h" -#include "calendar-commands.h" -#include "print.h" - -#include "dayview.xpm" -#include "workweekview.xpm" -#include "weekview.xpm" -#include "monthview.xpm" - -#if 0 -#include "yearview.xpm" -#endif - -/* The username, used to set the `owner' field of the event */ -char *user_name; - -/* The full user name from the Gecos field */ -char *full_name; - -/* a gnome-config string prefix that can be used to access the calendar config info */ -char *calendar_settings; - -/* Day begin, day end parameters */ -int day_begin, day_end; - -/* Whether weeks starts on Sunday or Monday */ -int week_starts_on_monday; - -/* If AM/PM indicators should be used. This may not be supported by the new - views. */ -int am_pm_flag = 0; - -/* The array of color properties -- keep in sync with the enumeration defined in main.h. The color - * values specified here are the defaults for the program. - */ -struct color_prop color_props[] = { - { 0x3e72, 0x35ec, 0x8ba2, N_("Outline:"), "/calendar/Colors/outline" }, - { 0xffff, 0xffff, 0xffff, N_("Headings:"), "/calendar/Colors/headings" }, - { 0xf26c, 0xecec, 0xbbe7, N_("Empty days:"), "/calendar/Colors/empty_bg" }, - { 0xfc1e, 0xf87f, 0x5f80, N_("Appointments:"), "/calendar/Colors/mark_bg" }, - { 0xd364, 0xc6b7, 0x7969, N_("Highlighted day:"), "/calendar/Colors/prelight_bg" }, - { 0x01f0, 0x01f0, 0x01f0, N_("Day numbers:"), "/calendar/Colors/day_fg" }, - { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" }, - { 0xbbbb, 0xbbbb, 0x0000, N_("To-Do item that is not yet due:"), "/calendar/Colors/todo_not_yet" }, - { 0xdddd, 0xbbbb, 0x0000, N_("To-Do item that is due today:"), "/calendar/Colors/todo_today" }, - { 0xbbbb, 0xdddd, 0x0000, N_("To-Do item that is overdue:"), "/calendar/Colors/todo_overdue" } -}; - -/* Number of active calendars */ -int active_calendars = 0; - -/* A list of all of the calendars started */ -GList *all_calendars = NULL; - -/* If set, beep on display alarms */ -gboolean beep_on_display = 0; - -/* If true, timeout the beeper on audio alarms */ - -gboolean enable_aalarm_timeout = 0; -guint audio_alarm_timeout = 0; -const guint MAX_AALARM_TIMEOUT = 3600; -const guint MAX_SNOOZE_SECS = 3600; -gboolean enable_snooze = 0; -guint snooze_secs = 60; - -#if 0 -CalendarAlarm alarm_defaults[4] = { - { ALARM_MAIL, 0, 15, ALARM_MINUTES }, - { ALARM_PROGRAM, 0, 15, ALARM_MINUTES }, - { ALARM_DISPLAY, 0, 15, ALARM_MINUTES }, - { ALARM_AUDIO, 0, 15, ALARM_MINUTES } -}; -#endif - -static void -init_username (void) -{ - user_name = g_strdup(g_get_user_name()); - full_name = g_strdup(g_get_real_name()); -} - -static int -range_check_hour (int hour) -{ - if (hour < 0) - hour = 0; - else if (hour >= 24) - hour = 23; - - return hour; -} - -#if 0 -static void -init_default_alarms (void) -{ - int i; - gboolean def; - - alarm_defaults [ALARM_DISPLAY].type = ALARM_DISPLAY; - alarm_defaults [ALARM_AUDIO].type = ALARM_AUDIO; - alarm_defaults [ALARM_PROGRAM].type = ALARM_PROGRAM; - alarm_defaults [ALARM_MAIL].type = ALARM_MAIL; - - for (i = 0; i < 4; i++) { - switch (alarm_defaults [i].type) { - case ALARM_DISPLAY: - gnome_config_push_prefix ("/calendar/alarms/def_disp_"); - break; - case ALARM_AUDIO: - gnome_config_push_prefix ("/calendar/alarms/def_audio_"); - break; - case ALARM_PROGRAM: - gnome_config_push_prefix ("/calendar/alarms/def_prog_"); - break; - case ALARM_MAIL: - gnome_config_push_prefix ("/calendar/alarms/def_mail_"); - break; - } - - alarm_defaults[i].enabled = gnome_config_get_int ("enabled=0"); - if (alarm_defaults[i].type != ALARM_MAIL) { - alarm_defaults[i].count = gnome_config_get_int ("count=15"); - alarm_defaults[i].units = gnome_config_get_int ("units=0"); - } else { - alarm_defaults[i].count = gnome_config_get_int ("count=1"); - alarm_defaults[i].count = gnome_config_get_int ("count=2"); - } - - alarm_defaults[i].data = gnome_config_get_string_with_default ("data=", - &def); - if (def) - alarm_defaults[i].data = NULL; - - gnome_config_pop_prefix (); - } -} -#endif - -static void -about_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GtkWidget *about; - const gchar *authors[] = { - "Miguel de Icaza (miguel@kernel.org)", - "Federico Mena (federico@gimp.org)", - "Arturo Espinosa (arturo@nuclecu.unam.mx)", - "Russell Steinthal (rms39@columbia.edu)", - NULL - }; - - about = gnome_about_new (_("Gnome Calendar"), VERSION, - "(C) 1998 the Free Software Foundation", - authors, - _("The GNOME personal calendar and schedule manager."), - NULL); - gtk_window_set_modal (GTK_WINDOW (about), TRUE); - gnome_dialog_set_close (GNOME_DIALOG (about), TRUE); - gtk_widget_show (about); -} - -/* Callback for the new appointment command */ -static void -new_appointment_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (user_data); - gnome_calendar_new_appointment (gcal); -} - -/* Prints the calendar at its current view and time range */ -static void -print (GnomeCalendar *gcal, gboolean preview) -{ - time_t start; - const char *view; - PrintView print_view; - - gnome_calendar_get_current_time_range (gcal, &start, NULL); - view = gnome_calendar_get_current_view_name (gcal); - - if (strcmp (view, "dayview") == 0) - print_view = PRINT_VIEW_DAY; - else if (strcmp (view, "workweekview") == 0 || strcmp (view, "weekview") == 0) - print_view = PRINT_VIEW_WEEK; - else if (strcmp (view, "monthview") == 0) - print_view = PRINT_VIEW_MONTH; - else { - g_assert_not_reached (); - print_view = PRINT_VIEW_DAY; - } - - print_calendar (gcal, preview, start, print_view); -} - -/* Toolbar/Print callback */ -static void -tb_print_cb (GtkWidget *widget, gpointer data) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - print (gcal, FALSE); -} - -/* File/Print callback */ -static void -file_print_cb (BonoboUIHandler *uih, void *data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - print (gcal, FALSE); -} - -void -time_format_changed (void) -{ - GList *l; - - for (l = all_calendars; l; l = l->next) - gnome_calendar_time_format_changed (GNOME_CALENDAR (l->data)); -} - -void -colors_changed (void) -{ - GList *l; - - for (l = all_calendars; l; l = l->next) - gnome_calendar_colors_changed (GNOME_CALENDAR (l->data)); -} - -void -todo_properties_changed(void) -{ - GList *l; - - for (l = all_calendars; l; l = l->next) - gnome_calendar_todo_properties_changed (GNOME_CALENDAR (l->data)); -} - -/* Sets a clock cursor for the specified calendar window */ -static void -set_clock_cursor (GnomeCalendar *gcal) -{ - GdkCursor *cursor; - - cursor = gdk_cursor_new (GDK_WATCH); - gdk_window_set_cursor (GTK_WIDGET (gcal)->window, cursor); - gdk_cursor_destroy (cursor); - gdk_flush (); -} - -/* Resets the normal cursor for the specified calendar window */ -static void -set_normal_cursor (GnomeCalendar *gcal) -{ - gdk_window_set_cursor (GTK_WIDGET (gcal)->window, NULL); - gdk_flush (); -} - -static void -previous_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - set_clock_cursor (gcal); - gnome_calendar_previous (gcal); - set_normal_cursor (gcal); -} - -static void -next_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - set_clock_cursor (gcal); - gnome_calendar_next (gcal); - set_normal_cursor (gcal); -} - -static void -today_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - set_clock_cursor (gcal); - gnome_calendar_goto_today (gcal); - set_normal_cursor (gcal); -} - -static void -goto_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - goto_dialog (gcal); -} - -static void -show_day_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "dayview"); - gtk_widget_grab_focus (gcal->day_view); -} - -static void -show_work_week_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "workweekview"); - gtk_widget_grab_focus (gcal->work_week_view); -} - -static void -show_week_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "weekview"); - gtk_widget_grab_focus (gcal->week_view); -} - -static void -show_month_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "monthview"); - gtk_widget_grab_focus (gcal->month_view); -} - -#if 0 -static void -show_year_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "yearview"); - gtk_widget_grab_focus (gcal->year_view); -} -#endif - -static void -new_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - new_calendar (full_name, NULL, NULL, FALSE); -} - -static void -close_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - all_calendars = g_list_remove (all_calendars, gcal); - - gtk_widget_destroy (GTK_WIDGET (gcal)); - active_calendars--; - - if (active_calendars == 0) - gtk_main_quit (); -} - - -void -quit_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - while (all_calendars){ - GnomeCalendar *cal = GNOME_CALENDAR (all_calendars->data); - - close_cmd (uih, cal, path); - } -} - - -static void -open_ok (GtkWidget *widget, GtkFileSelection *fs) -{ - GtkWidget *error_dialog; - int ret; - if(!g_file_exists (gtk_file_selection_get_filename (fs))) { - error_dialog = gnome_message_box_new ( - _("File not found"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, - NULL); - - gnome_dialog_set_parent (GNOME_DIALOG (error_dialog), GTK_WINDOW (fs)); - ret = gnome_dialog_run (GNOME_DIALOG (error_dialog)); - } else { - /* FIXME: find out who owns this calendar and use that name */ -#warning "FIXME: find out who owns this calendar and use that name" - /* - new_calendar ("Somebody", gtk_file_selection_get_filename (fs), NULL, NULL, FALSE); - */ - gtk_widget_destroy (GTK_WIDGET (fs)); - } -} - -static void -open_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GtkFileSelection *fs; - - fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open calendar"))); - - gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", - (GtkSignalFunc) open_ok, - fs); - gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", - (GtkSignalFunc) gtk_widget_destroy, - GTK_OBJECT (fs)); - - gtk_widget_show (GTK_WIDGET (fs)); - gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me */ -} - -static void -save_ok (GtkWidget *widget, GtkFileSelection *fs) -{ - GnomeCalendar *gcal; - gchar *fname; - - gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs))); - gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal"); - - fname = g_strdup (gtk_file_selection_get_filename (fs)); - g_free(fname); - gtk_main_quit (); -} - -static gint -close_save (GtkWidget *w) -{ - gtk_main_quit (); - return TRUE; -} - -static void -save_as_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GtkFileSelection *fs; - - fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar"))); - gtk_object_set_user_data (GTK_OBJECT (fs), user_data); - - gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", - (GtkSignalFunc) save_ok, - fs); - gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", - (GtkSignalFunc) close_save, - GTK_OBJECT (fs)); - gtk_signal_connect_object (GTK_OBJECT (fs), "delete_event", - GTK_SIGNAL_FUNC (close_save), - GTK_OBJECT (fs)); - gtk_widget_show (GTK_WIDGET (fs)); - gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */ - gtk_main (); - gtk_widget_destroy (GTK_WIDGET (fs)); -} - -static void -properties_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - properties (GTK_WIDGET (gcal)); -} - - -static GnomeUIInfo gnome_toolbar_view_buttons [] = { - GNOMEUIINFO_RADIOITEM (N_("Day"), N_("Show 1 day"), - show_day_view_clicked, - dayview_xpm), - GNOMEUIINFO_RADIOITEM (N_("5 Days"), N_("Show the working week"), - show_work_week_view_clicked, - workweekview_xpm), - GNOMEUIINFO_RADIOITEM (N_("Week"), N_("Show 1 week"), - show_week_view_clicked, - weekview_xpm), - GNOMEUIINFO_RADIOITEM (N_("Month"), N_("Show 1 month"), - show_month_view_clicked, - monthview_xpm), -#if 0 - GNOMEUIINFO_RADIOITEM (N_("Year"), N_("Show 1 year"), - show_year_view_clicked, - yearview_xpm), -#endif - GNOMEUIINFO_END -}; - - -static GnomeUIInfo calendar_toolbar [] = { - GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new appointment"), - new_appointment_cb, GNOME_STOCK_PIXMAP_NEW), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print this calendar"), tb_print_cb, GNOME_STOCK_PIXMAP_PRINT), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Go back in time"), previous_clicked, GNOME_STOCK_PIXMAP_BACK), - GNOMEUIINFO_ITEM_STOCK (N_("Today"), N_("Go to present time"), today_clicked, GNOME_STOCK_PIXMAP_HOME), - GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Go forward in time"), next_clicked, GNOME_STOCK_PIXMAP_FORWARD), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Go to"), N_("Go to a specific date"), goto_clicked, GNOME_STOCK_PIXMAP_JUMP_TO), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_RADIOLIST (gnome_toolbar_view_buttons), - - GNOMEUIINFO_END -}; - - - -/* Performs signal connection as appropriate for interpreters or native bindings */ -static void -do_ui_signal_connect (GnomeUIInfo *uiinfo, gchar *signal_name, - GnomeUIBuilderData *uibdata) -{ - if (uibdata->is_interp) - gtk_signal_connect_full (GTK_OBJECT (uiinfo->widget), - signal_name, NULL, uibdata->relay_func, - uibdata->data ? - uibdata->data : uiinfo->user_data, - uibdata->destroy_func, FALSE, FALSE); - - else if (uiinfo->moreinfo) - gtk_signal_connect (GTK_OBJECT (uiinfo->widget), - signal_name, uiinfo->moreinfo, uibdata->data ? - uibdata->data : uiinfo->user_data); -} - - -void -calendar_control_activate (BonoboControl *control, - GnomeCalendar *cal) -{ - Bonobo_UIHandler remote_uih; - GtkWidget *toolbar, *toolbar_frame; - BonoboControl *toolbar_control; - GnomeUIBuilderData uibdata; - BonoboUIHandler *uih; - gchar *page_name; - gint button, i; - int behavior; - - uih = bonobo_control_get_ui_handler (control); - g_assert (uih != NULL); - - uibdata.connect_func = do_ui_signal_connect; - uibdata.data = cal; - uibdata.is_interp = FALSE; - uibdata.relay_func = NULL; - uibdata.destroy_func = NULL; - - g_print ("In calendar_control_activate\n"); - - remote_uih = bonobo_control_get_remote_ui_handler (control); - bonobo_ui_handler_set_container (uih, remote_uih); - bonobo_object_release_unref (remote_uih, NULL); - - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, - GTK_TOOLBAR_BOTH); - gnome_app_fill_toolbar_custom (GTK_TOOLBAR (toolbar), - calendar_toolbar, &uibdata, - /*app->accel_group*/ NULL); - - /*gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));*/ - - for (i = 0; i < GNOME_CALENDAR_NUM_VIEWS; i++) - cal->view_toolbar_buttons[i] = gnome_toolbar_view_buttons[i].widget; - - /* Note that these indices should correspond with the button indices - in gnome_toolbar_view_buttons. */ - page_name = gnome_calendar_get_current_view_name (cal); - if (!strcmp (page_name, "dayview")) { - button = 0; - } else if (!strcmp (page_name, "workweekview")) { - button = 1; - } else if (!strcmp (page_name, "weekview")) { - button = 2; - } else if (!strcmp (page_name, "monthview")) { - button = 3; -#if 0 - } else if (!strcmp (page_name, "yearview")) { - button = 4; -#endif - } else { - g_warning ("Unknown calendar view: %s", page_name); - button = 0; - } - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cal->view_toolbar_buttons[button]), TRUE); - - gtk_widget_show_all (toolbar); - - toolbar_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (toolbar_frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (toolbar_frame), toolbar); - gtk_widget_show (toolbar_frame); - - gtk_widget_show_all (toolbar_frame); - - behavior = GNOME_DOCK_ITEM_BEH_EXCLUSIVE | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL; - - if (!gnome_preferences_get_toolbar_detachable ()) - behavior |= GNOME_DOCK_ITEM_BEH_LOCKED; - - toolbar_control = bonobo_control_new (toolbar_frame); - - bonobo_ui_handler_dock_add (uih, "/Toolbar", - bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)), - behavior, - GNOME_DOCK_TOP, - 1, 1, 0); - - /* file menu */ - bonobo_ui_handler_menu_new_item (uih, "/File/New/Calendar", N_("New Ca_lendar"), - N_("Create a new calendar"), - -1, BONOBO_UI_HANDLER_PIXMAP_NONE, - NULL, 0, 0, new_calendar_cmd, cal); - bonobo_ui_handler_menu_new_item (uih, "/File/Open/Calendar", N_("Open Ca_lendar"), - N_("Open a calendar"), -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, open_calendar_cmd, cal); - bonobo_ui_handler_menu_new_item (uih, "/File/Save Calendar As", - N_("Save Calendar As"), - N_("Save Calendar As"), - -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, save_as_calendar_cmd, cal); - bonobo_ui_handler_menu_new_item (uih, "/File/Print", N_("Print..."), - N_("Print this calendar"), -1, - BONOBO_UI_HANDLER_PIXMAP_STOCK, - GNOME_STOCK_PIXMAP_PRINT, - 'p', GDK_CONTROL_MASK, - file_print_cb, cal); - - /* edit menu */ - bonobo_ui_handler_menu_new_item (uih, "/Edit/New Appointment", - N_("_New appointment..."), N_("Create a new appointment"), - -1, BONOBO_UI_HANDLER_PIXMAP_STOCK, - GNOME_STOCK_MENU_NEW, 0, 0, - new_appointment_cb, cal); - - //bonobo_ui_handler_menu_new_separator (uih, "/Edit", -1); - - bonobo_ui_handler_menu_new_item (uih, "/Edit/Preferences", - N_("Preferences"), N_("Preferences"), - -1, BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, properties_cmd, cal); - /* help menu */ - - bonobo_ui_handler_menu_new_item (uih, - "/Help/About Calendar", - N_("About Calendar"), - N_("About Calendar"), - -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, about_calendar_cmd, cal); - -} - - -void -calendar_control_deactivate (BonoboControl *control) -{ - BonoboUIHandler *uih = bonobo_control_get_ui_handler (control); - g_assert (uih); - - g_print ("In calendar_control_deactivate\n"); - - bonobo_ui_handler_dock_remove (uih, "/Toolbar"); - bonobo_ui_handler_unset_container (uih); -} - - - - -static gint -calendar_close_event (GtkWidget *widget, GdkEvent *event, GnomeCalendar *gcal) -{ - close_cmd (NULL, gcal, NULL); - return TRUE; -} - - -GnomeCalendar * -new_calendar (char *full_name, char *geometry, char *page, gboolean hidden) -{ - GtkWidget *toplevel; - char title[128]; - int xpos, ypos, width, height; - - - /* i18n: This "%s%s" indicates possession. Languages where the order is - * the inverse should translate it to "%2$s%1$s". - */ - g_snprintf(title, 128, _("%s%s"), full_name, _("'s calendar")); - - toplevel = gnome_calendar_new (title); - - if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){ - if (xpos != -1) - gtk_widget_set_uposition (toplevel, xpos, ypos); - } - - if (page) - gnome_calendar_set_view (GNOME_CALENDAR (toplevel), page); - - gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event", - GTK_SIGNAL_FUNC(calendar_close_event), toplevel); - - active_calendars++; - all_calendars = g_list_prepend (all_calendars, toplevel); - - if (hidden){ - GnomeWinState state; - - /* Realize the toplevel window to prevent a segfault */ - gtk_widget_realize (toplevel); - state = gnome_win_hints_get_state (toplevel); - - state |= WIN_STATE_MINIMIZED; - gnome_win_hints_set_state (toplevel, state); - } - - gtk_widget_show (toplevel); - - return GNOME_CALENDAR (toplevel); -} - - -void calendar_set_uri (GnomeCalendar *gcal, char *calendar_file) -{ - gboolean success; - - g_return_if_fail (gcal); - g_return_if_fail (calendar_file); - - printf ("calendar_set_uri: calendar_file is '%s'\n", calendar_file); - - success = gnome_calendar_open (gcal, - calendar_file, - CALENDAR_OPEN_OR_CREATE); - - printf (" load or create returned %d\n", success); -} - - - - - -/* - * Initializes the calendar internal variables, loads defaults - */ -void -init_calendar (void) -{ - int i; - char *cspec, *color; - char *str; - - init_username (); - /*user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");*/ - - gnome_config_push_prefix (calendar_settings); - - /* Read calendar settings */ - - day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8")); - day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17")); - am_pm_flag = gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0"); - week_starts_on_monday = gnome_config_get_bool ("/calendar/Calendar/Week starts on Monday=0"); - - if (day_end < day_begin){ - day_begin = 8; - day_end = 17; - } - - /* Read color settings */ - - for (i = 0; i < COLOR_PROP_LAST; i++) { - cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b); - str = g_strconcat (color_props[i].key, "=", cspec, NULL); - - color = gnome_config_get_string (str); - parse_color_spec (color, &color_props[i].r, &color_props[i].g, &color_props[i].b); - - g_free (str); - g_free (color); - } - - /* read todolist settings */ - - todo_show_time_remaining = gnome_config_get_bool("/calendar/Todo/show_time_remain"); - todo_show_due_date = gnome_config_get_bool("/calendar/Todo/show_due_date"); - - todo_item_dstatus_highlight_overdue = gnome_config_get_bool("/calendar/Todo/highlight_overdue"); - - todo_item_dstatus_highlight_due_today = gnome_config_get_bool("/calendar/Todo/highlight_due_today"); - - todo_item_dstatus_highlight_not_due_yet = gnome_config_get_bool("/calendar/Todo/highlight_not_due_yet"); - - todo_current_sort_column = gnome_config_get_int("/calendar/Todo/sort_column"); - - todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type"); - - todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority"); - - /* read alarm settings */ - beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE"); - enable_aalarm_timeout = gnome_config_get_bool ("/calendar/alarms/enable_audio_timeout=FALSE"); - audio_alarm_timeout = gnome_config_get_int ("/calendar/alarms/audio_alarm_timeout=60"); - if (audio_alarm_timeout < 1) - audio_alarm_timeout = 1; - if (audio_alarm_timeout > MAX_AALARM_TIMEOUT) - audio_alarm_timeout = MAX_AALARM_TIMEOUT; - enable_snooze = gnome_config_get_bool ("/calendar/alarms/enable_snooze=FALSE"); - snooze_secs = gnome_config_get_int ("/calendar/alarms/snooze_secs=300"); - if (snooze_secs < 1) - snooze_secs = 1; - if (snooze_secs > MAX_SNOOZE_SECS) - snooze_secs = MAX_SNOOZE_SECS; - -#if 0 - init_default_alarms (); -#endif - - /* Done */ - - gnome_config_pop_prefix (); -} diff --git a/calendar/gui/calendar-commands.h b/calendar/gui/calendar-commands.h deleted file mode 100644 index f48ba333bc..0000000000 --- a/calendar/gui/calendar-commands.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef CALENDAR_COMMANDS_H -#define CALENDAR_COMMANDS_H - -#include <bonobo/bonobo-control.h> -#include "gnome-cal.h" - -/* This enum and the following array define the color preferences */ - -typedef enum { - COLOR_PROP_OUTLINE_COLOR, /* Color of calendar outline */ - COLOR_PROP_HEADING_COLOR, /* Color for headings */ - COLOR_PROP_EMPTY_DAY_BG, /* Background color for empty days */ - COLOR_PROP_MARK_DAY_BG, /* Background color for days with appointments */ - COLOR_PROP_PRELIGHT_DAY_BG, /* Background color for prelighted day */ - COLOR_PROP_DAY_FG, /* Color for day numbers */ - COLOR_PROP_CURRENT_DAY_FG, /* Color for current day's number */ - COLOR_PROP_TODO_NOT_DUE_YET, /* Color for Todo items not yet due */ - COLOR_PROP_TODO_DUE_TODAY, /* Color for Todo items due today */ - COLOR_PROP_TODO_OVERDUE, /* Color for Todo items that are overdue */ - COLOR_PROP_LAST /* Number of color properties */ -} ColorProp; - -struct color_prop { - int r; /* Values are in [0, 65535] */ - int g; - int b; - char *label; /* Label for properties dialog */ - char *key; /* Key for gnome_config */ -}; - -extern struct color_prop color_props[]; - - -#define COOKIE_USER_HOME_DIR ((char *) -1) - - -/* Calendar preferences */ - -extern int day_begin, day_end; -extern char *user_name; -extern int am_pm_flag; -extern int week_starts_on_monday; - -/* todo preferences */ -extern int todo_show_due_date; - -extern int todo_item_dstatus_highlight_overdue; -extern int todo_item_dstatus_highlight_due_today; -extern int todo_item_dstatus_highlight_not_due_yet; - -extern int todo_show_time_remaining; -extern int todo_show_priority; -extern char *todo_overdue_font_text; -extern gboolean todo_style_changed; -extern gint todo_current_sort_column; -extern gint todo_current_sort_type; - -/* alarm stuff */ -#if 0 -extern CalendarAlarm alarm_defaults[4]; -#endif -extern gboolean beep_on_display; -extern gboolean enable_aalarm_timeout; -extern guint audio_alarm_timeout; -extern const guint MAX_AALARM_TIMEOUT; -extern gboolean enable_snooze; -extern guint snooze_secs; -extern const guint MAX_SNOOZE_SECS; - -/* Creates and runs the preferences dialog box */ -void properties (GtkWidget *toplevel); - -/* Asks for all the time-related displays to be updated when the user changes the time format - * preferences. - */ -void time_format_changed (void); - -/* Asks for all the month items' colors to be reset */ -void colors_changed (void); - -/* Asks for all todo lists to reflect the accurate properties */ -void todo_properties_changed(void); - -/* Creates and runs the Go-to date dialog */ -void goto_dialog (GnomeCalendar *gcal); - -/* Returns a pointer to a statically-allocated string with a representation of the specified color. - * Values must be in [0, 65535]. - */ -char *build_color_spec (int r, int g, int b); - -/* Parses a color specification of the form "#%04x%04x%04x" and returns the color components. */ -void parse_color_spec (char *spec, int *r, int *g, int *b); - -/* Calls build_color_spec() for the color in the specified property number */ -char *color_spec_from_prop (ColorProp propnum); - -GnomeCalendar *new_calendar (char *full_name, - char *geometry, - char *page, - gboolean hidden); - -void calendar_set_uri (GnomeCalendar *gcal, char *calendar_file); - - -/*----------------------------------------------------------------------*/ -/* FIXME -- where should this stuff go? */ -/*----------------------------------------------------------------------*/ - -void init_calendar (void); - -void calendar_control_activate (BonoboControl *control, - GnomeCalendar *cal); -void calendar_control_deactivate (BonoboControl *control); - -void quit_cmd (BonoboUIHandler *uih, void *user_data, const char *path); - -/*extern char *user_calendar_file;*/ -extern char *user_name; -extern char *full_name; -extern int debug_alarms; -extern int active_calendars; -extern GList *all_calendars; - -#endif /* CALENDAR_COMMANDS_H */ diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c deleted file mode 100644 index 8644b8928c..0000000000 --- a/calendar/gui/calendar-component.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#include <config.h> -#include <bonobo.h> -#include "evolution-shell-component.h" -#include "component-factory.h" -#include "control-factory.h" - - - -#ifdef USING_OAF -#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" -#else -#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:evolution-calendar" -#endif - -static BonoboGenericFactory *factory = NULL; - -static const EvolutionShellComponentFolderType folder_types[] = { - { "calendar", "evolution-calendar.png" }, - { NULL, NULL } -}; - - -/* EvolutionShellComponent methods and signals. */ - -static EvolutionShellComponentResult -create_view (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - BonoboControl **control_return, - void *closure) -{ - BonoboControl *control; - - if (g_strcasecmp (type, "calendar") != 0) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; - - control = control_factory_new_control (); - bonobo_control_set_property (control, "folder_uri", physical_uri, NULL); - - *control_return = control; - - return EVOLUTION_SHELL_COMPONENT_OK; -} - -static gint owner_count = 0; - -static void -owner_set_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - const char *evolution_homedir) -{ - owner_count ++; -} - -static void -owner_unset_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - EvolutionShellClient shell_client, - void *data) -{ - owner_count --; - if (owner_count <= 0) - gtk_main_quit(); -} - - -/* The factory function. */ - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - void *closure) -{ - EvolutionShellComponent *shell_component; - - shell_component = evolution_shell_component_new (folder_types, create_view, NULL, NULL, NULL, NULL); - - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", - GTK_SIGNAL_FUNC (owner_set_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", - GTK_SIGNAL_FUNC (owner_unset_cb), NULL); - - return BONOBO_OBJECT (shell_component); -} - - -void -component_factory_init (void) -{ - if (factory != NULL) - return; - - factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); - - if (factory == NULL) - g_error ("Cannot initialize Evolution's calendar component."); -} diff --git a/calendar/gui/calendar-component.h b/calendar/gui/calendar-component.h deleted file mode 100644 index f83a849452..0000000000 --- a/calendar/gui/calendar-component.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.h - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef _COMPONENT_FACTORY_H_ -#define _COMPONENT_FACTORY_H_ - -void component_factory_init (void); - -#endif /* _COMPONENT_FACTORY_H_ */ diff --git a/calendar/gui/calendar-control.gnorba b/calendar/gui/calendar-control.gnorba deleted file mode 100644 index ed504d8f5b..0000000000 --- a/calendar/gui/calendar-control.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[control-factory:calendar] -type=exe -repo_id=IDL:Bonobo/GenericFactory:1.0 -description=Factory for the sample Calendar control -location_info=evolution-calendar - -[control:calendar] -type=factory -repo_id=IDL:BonoboControl/calendar-control:1.0 IDL:Bonobo/Control:1.0 -description=A sample Bonobo control which displays an calendar. -location_info=control-factory:calendar diff --git a/calendar/gui/calendar-control.oafinfo b/calendar/gui/calendar-control.oafinfo deleted file mode 100644 index fb0f138caf..0000000000 --- a/calendar/gui/calendar-control.oafinfo +++ /dev/null @@ -1,28 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the sample Calendar control"/> -</oaf_server> - -<oaf_server iid="OAFIID:control:calendar:dd34ddae-25c6-486b-a8a8-3e8f0286b54c" - type="factory" - location="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/calendar-control:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="A sample Bonobo control which displays an calendar."/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c deleted file mode 100644 index a39044f7e6..0000000000 --- a/calendar/gui/calendar-model.c +++ /dev/null @@ -1,1782 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* Evolution calendar - Data model for ETable - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -/* We need this for strptime. */ -#define _XOPEN_SOURCE - -#include <config.h> -#include <ctype.h> -#include <math.h> -#undef _XOPEN_SOURCE -#include <sys/time.h> -#define _XOPEN_SOURCE -#include <time.h> -#include <gnome.h> -#include <cal-util/timeutil.h> -#include "calendar-model.h" -#include "calendar-commands.h" - - - -/* Private part of the ECalendarModel structure */ -typedef struct { - /* Calendar client we are using */ - CalClient *client; - - /* Types of objects we are dealing with */ - CalObjType type; - - /* Array of pointers to calendar objects */ - GArray *objects; - - /* UID -> array index hash */ - GHashTable *uid_index_hash; - - /* HACK: so that ETable can do its stupid append_row() thing */ - guint appending_row : 1; -} CalendarModelPrivate; - - - -static void calendar_model_class_init (CalendarModelClass *class); -static void calendar_model_init (CalendarModel *model); -static void calendar_model_destroy (GtkObject *object); - -static int calendar_model_column_count (ETableModel *etm); -static int calendar_model_row_count (ETableModel *etm); -static void *calendar_model_value_at (ETableModel *etm, int col, int row); -static void calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *value); -static gboolean calendar_model_is_cell_editable (ETableModel *etm, int col, int row); -static void calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row); -static void *calendar_model_duplicate_value (ETableModel *etm, int col, const void *value); -static void calendar_model_free_value (ETableModel *etm, int col, void *value); -static void *calendar_model_initialize_value (ETableModel *etm, int col); -static gboolean calendar_model_value_is_empty (ETableModel *etm, int col, const void *value); -#if 0 -static char * calendar_model_value_to_string (ETableModel *etm, int col, const void *value); -#endif -static void load_objects (CalendarModel *model); -static int remove_object (CalendarModel *model, const char *uid); - -static ETableModelClass *parent_class; - - - -/** - * calendar_model_get_type: - * @void: - * - * Registers the #CalendarModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalendarModel class. - **/ -GtkType -calendar_model_get_type (void) -{ - static GtkType calendar_model_type = 0; - - if (!calendar_model_type) { - static GtkTypeInfo calendar_model_info = { - "CalendarModel", - sizeof (CalendarModel), - sizeof (CalendarModelClass), - (GtkClassInitFunc) calendar_model_class_init, - (GtkObjectInitFunc) calendar_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - calendar_model_type = gtk_type_unique (E_TABLE_MODEL_TYPE, &calendar_model_info); - } - - return calendar_model_type; -} - -/* Class initialization function for the calendar table model */ -static void -calendar_model_class_init (CalendarModelClass *class) -{ - GtkObjectClass *object_class; - ETableModelClass *etm_class; - - object_class = (GtkObjectClass *) class; - etm_class = (ETableModelClass *) class; - - parent_class = gtk_type_class (E_TABLE_MODEL_TYPE); - - object_class->destroy = calendar_model_destroy; - - etm_class->column_count = calendar_model_column_count; - etm_class->row_count = calendar_model_row_count; - etm_class->value_at = calendar_model_value_at; - etm_class->set_value_at = calendar_model_set_value_at; - etm_class->is_cell_editable = calendar_model_is_cell_editable; - etm_class->append_row = calendar_model_append_row; - etm_class->duplicate_value = calendar_model_duplicate_value; - etm_class->free_value = calendar_model_free_value; - etm_class->initialize_value = calendar_model_initialize_value; - etm_class->value_is_empty = calendar_model_value_is_empty; -#if 0 - etm_class->value_to_string = calendar_model_value_to_string; -#endif -} - -/* Object initialization function for the calendar table model */ -static void -calendar_model_init (CalendarModel *model) -{ - CalendarModelPrivate *priv; - - priv = g_new0 (CalendarModelPrivate, 1); - model->priv = priv; - - priv->objects = g_array_new (FALSE, TRUE, sizeof (CalComponent *)); - priv->uid_index_hash = g_hash_table_new (g_str_hash, g_str_equal); -} - -/* Called from g_hash_table_foreach_remove(), frees a stored UID->index - * mapping. - */ -static gboolean -free_uid_index (gpointer key, gpointer value, gpointer data) -{ - int *idx; - - idx = value; - g_free (idx); - - return TRUE; -} - -/* Frees the objects stored in the calendar model */ -static void -free_objects (CalendarModel *model) -{ - CalendarModelPrivate *priv; - int i; - - priv = model->priv; - - g_hash_table_foreach_remove (priv->uid_index_hash, free_uid_index, NULL); - - for (i = 0; i < priv->objects->len; i++) { - CalComponent *comp; - - comp = g_array_index (priv->objects, CalComponent *, i); - g_assert (comp != NULL); - gtk_object_unref (GTK_OBJECT (comp)); - } - - g_array_set_size (priv->objects, 0); -} - -/* Destroy handler for the calendar table model */ -static void -calendar_model_destroy (GtkObject *object) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (object)); - - model = CALENDAR_MODEL (object); - priv = model->priv; - - /* Free the calendar client interface object */ - - if (priv->client) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), model); - gtk_object_unref (GTK_OBJECT (priv->client)); - priv->client = NULL; - } - - /* Free the uid->index hash data and the array of UIDs */ - - free_objects (model); - - g_hash_table_destroy (priv->uid_index_hash); - priv->uid_index_hash = NULL; - - g_array_free (priv->objects, TRUE); - priv->objects = NULL; - - /* Free the private structure */ - - g_free (priv); - model->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* ETableModel methods */ - -/* column_count handler for the calendar table model */ -static int -calendar_model_column_count (ETableModel *etm) -{ - return CAL_COMPONENT_FIELD_NUM_FIELDS; -} - -/* row_count handler for the calendar table model */ -static int -calendar_model_row_count (ETableModel *etm) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - return priv->objects->len; -} - -/* Creates a nice string representation of a time value */ -static char* -get_time_t (time_t *t, gboolean skip_midnight) -{ - static char buffer[32]; - struct tm *tmp_tm; - - if (*t <= 0) { - buffer[0] = '\0'; - } else { - tmp_tm = localtime (t); - - if (skip_midnight && tmp_tm->tm_hour == 0 - && tmp_tm->tm_min == 0 && tmp_tm->tm_sec == 0) - strftime (buffer, 32, "%a %x", tmp_tm); - else - strftime (buffer, 32, "%a %x %T", tmp_tm); - } - - return buffer; -} - -/* Builds a string based on the list of CATEGORIES properties of a calendar - * component. - */ -static char * -get_categories (CalComponent *comp) -{ - GSList *categories; - GString *str; - char *s; - GSList *l; - - cal_component_get_categories_list (comp, &categories); - - str = g_string_new (NULL); - - for (l = categories; l; l = l->next) { - const char *category; - - category = l->data; - g_string_append (str, category); - - if (l->next != NULL) - g_string_append (str, ", "); - } - - s = str->str; - - g_string_free (str, FALSE); - cal_component_free_categories_list (categories); - - return s; -} - -/* Returns a string based on the CLASSIFICATION property of a calendar component */ -static char * -get_classification (CalComponent *comp) -{ - CalComponentClassification classif; - - cal_component_get_classification (comp, &classif); - - switch (classif) { - case CAL_COMPONENT_CLASS_NONE: - return ""; - - case CAL_COMPONENT_CLASS_PUBLIC: - return _("Public"); - - case CAL_COMPONENT_CLASS_PRIVATE: - return _("Private"); - - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - return _("Confidential"); - - case CAL_COMPONENT_CLASS_UNKNOWN: - return _("Unknown"); - - default: - g_assert_not_reached (); - return NULL; - } -} - -/* Builds a string for the COMPLETED property of a calendar component */ -static char * -get_completed (CalComponent *comp) -{ - struct icaltimetype *completed; - time_t t; - - cal_component_get_completed (comp, &completed); - - if (!completed) - t = 0; - else { - t = time_from_icaltimetype (*completed); - cal_component_free_icaltimetype (completed); - } - - return get_time_t (&t, FALSE); -} - -/* Builds a string for and frees a date/time value */ -static char * -get_and_free_datetime (CalComponentDateTime dt) -{ - time_t t; - - if (!dt.value) - t = 0; - else - t = time_from_icaltimetype (*dt.value); - - cal_component_free_datetime (&dt); - - return get_time_t (&t, FALSE); -} - -/* Builds a string for the DTEND property of a calendar component */ -static char * -get_dtend (CalComponent *comp) -{ - CalComponentDateTime dt; - - cal_component_get_dtend (comp, &dt); - return get_and_free_datetime (dt); -} - -/* Builds a string for the DTSTART property of a calendar component */ -static char * -get_dtstart (CalComponent *comp) -{ - CalComponentDateTime dt; - - cal_component_get_dtstart (comp, &dt); - return get_and_free_datetime (dt); -} - -/* Builds a string for the DUE property of a calendar component */ -static char * -get_due (CalComponent *comp) -{ - CalComponentDateTime dt; - - cal_component_get_due (comp, &dt); - return get_and_free_datetime (dt); -} - -/* Builds a string for the GEO property of a calendar component */ -static char* -get_geo (CalComponent *comp) -{ - struct icalgeotype *geo; - static gchar buf[32]; - - cal_component_get_geo (comp, &geo); - - if (!geo) - buf[0] = '\0'; - else { - g_snprintf (buf, sizeof (buf), "%g %s, %g %s", - fabs (geo->lat), - geo->lat >= 0.0 ? _("N") : _("S"), - fabs (geo->lon), - geo->lon >= 0.0 ? _("E") : _("W")); - cal_component_free_geo (geo); - } - - return buf; -} - -/* Builds a string for the PERCENT property of a calendar component */ -static char * -get_percent (CalComponent *comp) -{ - int *percent; - static char buf[32]; - - cal_component_get_percent (comp, &percent); - - if (!percent) - buf[0] = '\0'; - else { - g_snprintf (buf, sizeof (buf), "%d%%", *percent); - cal_component_free_percent (percent); - } - - return buf; -} - -/* Builds a string for the PRIORITY property of a calendar component */ -static char * -get_priority (CalComponent *comp) -{ - int *priority; - static char buf[32]; - - cal_component_get_priority (comp, &priority); - - if (!priority) - buf[0] = '\0'; - else { - g_snprintf (buf, sizeof (buf), "%d", *priority); - cal_component_free_priority (priority); - } - - return buf; -} - -/* Builds a string for the SUMMARY property of a calendar component */ -static char * -get_summary (CalComponent *comp) -{ - CalComponentText summary; - - cal_component_get_summary (comp, &summary); - - if (summary.value) - return (char *) summary.value; - else - return ""; -} - -/* Builds a string for the TRANSPARENCY property of a calendar component */ -static char * -get_transparency (CalComponent *comp) -{ - CalComponentTransparency transp; - - cal_component_get_transparency (comp, &transp); - - switch (transp) { - case CAL_COMPONENT_TRANSP_NONE: - return ""; - - case CAL_COMPONENT_TRANSP_TRANSPARENT: - return _("Transparent"); - - case CAL_COMPONENT_TRANSP_OPAQUE: - return _("Opaque"); - - case CAL_COMPONENT_TRANSP_UNKNOWN: - return _("Unknown"); - - default: - g_assert_not_reached (); - return NULL; - } -} - -/* Builds a string for the URL property of a calendar component */ -static char * -get_url (CalComponent *comp) -{ - const char *url; - - cal_component_get_url (comp, &url); - - if (url) - return (char *) url; - else - return ""; -} - -/* Returns whether the component has any alarms defined for it */ -static gboolean -get_has_alarms (CalComponent *comp) -{ - CalComponentAlarm *alarm; - gboolean retval; - - alarm = cal_component_get_first_alarm (comp); - retval = (alarm != NULL); - - cal_component_alarm_free (alarm); - return retval; -} - -/* Returns whether the component has any recurrences defined for it */ -static gboolean -get_has_recurrences (CalComponent *comp) -{ - return cal_component_has_rdates (comp) || cal_component_has_rrules (comp); -} - -/* Returns whether the completion date has been set on a component */ -static gboolean -get_is_complete (CalComponent *comp) -{ - struct icaltimetype *t; - gboolean retval; - - cal_component_get_completed (comp, &t); - retval = (t != NULL); - - cal_component_free_icaltimetype (t); - return retval; -} - -/* Returns whether a calendar component is overdue. - * - * FIXME: This will only get called when the component is scrolled into the - * ETable. There should be some sort of dynamic update thingy for if a component - * becomes overdue while it is being viewed. - */ -static gboolean -get_is_overdue (CalComponent *comp) -{ - CalComponentDateTime dt; - gboolean retval; - - cal_component_get_due (comp, &dt); - - /* First, do we have a due date? */ - - if (!dt.value) - retval = FALSE; - else { - struct icaltimetype *completed; - time_t t; - - /* Second, is it already completed? */ - - cal_component_get_completed (comp, &completed); - - if (completed) { - retval = FALSE; - - cal_component_free_icaltimetype (completed); - goto out; - } - - /* Third, are we overdue as of right now? - * - * FIXME: should we check the PERCENT as well? If it is at 100% - * but the COMPLETED property is not set, is the component - * really overdue? - **/ - - t = time_from_icaltimetype (*dt.value); - - if (t < time (NULL)) - retval = TRUE; - else - retval = FALSE; - } - - out: - - cal_component_free_datetime (&dt); - - return retval; -} - -/* value_at handler for the calendar table model */ -static void * -calendar_model_value_at (ETableModel *etm, int col, int row) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - CalComponent *comp; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL); - g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - return get_categories (comp); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return get_classification (comp); - - case CAL_COMPONENT_FIELD_COMPLETED: - return get_completed (comp); - - case CAL_COMPONENT_FIELD_DTEND: - return get_dtend (comp); - - case CAL_COMPONENT_FIELD_DTSTART: - return get_dtstart (comp); - - case CAL_COMPONENT_FIELD_DUE: - return get_due (comp); - - case CAL_COMPONENT_FIELD_GEO: - return get_geo (comp); - - case CAL_COMPONENT_FIELD_PERCENT: - return get_percent (comp); - - case CAL_COMPONENT_FIELD_PRIORITY: - return get_priority (comp); - - case CAL_COMPONENT_FIELD_SUMMARY: - return get_summary (comp); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return get_transparency (comp); - - case CAL_COMPONENT_FIELD_URL: - return get_url (comp); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - return GINT_TO_POINTER (get_has_alarms (comp)); - - case CAL_COMPONENT_FIELD_ICON: - /* FIXME: Also support 'Assigned to me' & 'Assigned to someone - else'. */ - if (get_has_recurrences (comp)) - return GINT_TO_POINTER (1); - else - return GINT_TO_POINTER (0); - - case CAL_COMPONENT_FIELD_COMPLETE: - return GINT_TO_POINTER (get_is_complete (comp)); - - case CAL_COMPONENT_FIELD_RECURRING: - return GINT_TO_POINTER (get_has_recurrences (comp)); - - case CAL_COMPONENT_FIELD_OVERDUE: - return GINT_TO_POINTER (get_is_overdue (comp)); - - case CAL_COMPONENT_FIELD_COLOR: - if (get_is_overdue (comp)) - return "red"; - else - return NULL; - - default: - g_message ("calendar_model_value_at(): Requested invalid column %d", col); - return NULL; - } -} - -/* Returns whether a string is NULL, empty, or full of whitespace */ -static gboolean -string_is_empty (const char *value) -{ - const char *p; - gboolean empty = TRUE; - - if (value) { - p = value; - while (*p) { - if (!isspace (*p)) { - empty = FALSE; - break; - } - p++; - } - } - return empty; -} - - -/* FIXME: We need to set the "transient_for" property for the dialog, but - the model doesn't know anything about the windows. */ -static void -show_date_warning (void) -{ - GtkWidget *dialog; - char buffer[32], message[256]; - time_t t; - struct tm *tmp_tm; - - t = time (NULL); - tmp_tm = localtime (&t); - strftime (buffer, 32, "%a %x %T", tmp_tm); - - g_snprintf (message, 256, - _("The date must be entered in the format: \n\n%s"), - buffer); - - dialog = gnome_message_box_new (message, - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Builds a list of categories from a comma-delimited string */ -static GSList * -categories_from_string (const char *value) -{ - GSList *list; - const char *categ_start; - const char *categ_end; - const char *p; - - if (!value) - return NULL; - - list = NULL; - - categ_start = categ_end = NULL; - - for (p = value; *p; p++) { - if (categ_start) { - if (*p == ',') { - char *c; - - c = g_strndup (categ_start, categ_end - categ_start + 1); - list = g_slist_prepend (list, c); - - categ_start = categ_end = NULL; - } else if (!isspace (*p)) - categ_end = p; - } else if (!isspace (*p) && *p != ',') - categ_start = categ_end = p; - } - - if (categ_start) { - char *c; - - c = g_strndup (categ_start, categ_end - categ_start + 1); - list = g_slist_prepend (list, c); - } - - return g_slist_reverse (list); -} - -/* Sets the list of categories from a comma-delimited string */ -static void -set_categories (CalComponent *comp, const char *value) -{ - GSList *list; - GSList *l; - - list = categories_from_string (value); - - cal_component_set_categories_list (comp, list); - - for (l = list; l; l = l->next) { - char *s; - - s = l->data; - g_free (s); - } - - g_slist_free (list); -} - -/* Parses a time value entered by the user; returns -1 if it could not be - * parsed. Returns 0 for an empty time. - */ -static time_t -parse_time (const char *value) -{ - struct tm tmp_tm; - struct tm *today_tm; - time_t t; - const char *p; - - if (string_is_empty (value)) - return 0; - - /* Skip any weekday name. */ - p = strptime (value, "%a", &tmp_tm); - if (!p) - p = value; - - /* Try to match the full date & time, or without the seconds, - or just the date, or just the time with/without seconds. - The info pages say we should clear the tm before calling - strptime. It also means that if we don't match a time we - get 00:00:00 which is good. */ - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%x %T", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%x %H:%M", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%x", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%T", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%H:%M", &tmp_tm)) - return -1; /* Could not parse it */ - } - - /* We only got a time, so we use the - current day. */ - t = time (NULL); - today_tm = localtime (&t); - tmp_tm.tm_mday = today_tm->tm_mday; - tmp_tm.tm_mon = today_tm->tm_mon; - tmp_tm.tm_year = today_tm->tm_year; - } - } - } - - tmp_tm.tm_isdst = -1; - return mktime (&tmp_tm); -} - -/* Sets the completion time of a component */ -static void -set_completed (CalComponent *comp, const char *value) -{ - time_t t; - struct icaltimetype itt; - - t = parse_time (value); - if (t == -1) { - show_date_warning (); - return; - } else if (t == 0) { - cal_component_set_completed (comp, NULL); - return; - } else { - itt = icaltimetype_from_timet (t, FALSE); - cal_component_set_completed (comp, &itt); - } -} - -/* Sets a CalComponentDateTime value */ -static void -set_datetime (CalComponent *comp, const char *value, - void (* set_func) (CalComponent *comp, CalComponentDateTime *dt)) -{ - time_t t; - - t = parse_time (value); - if (t == -1) { - show_date_warning (); - return; - } else if (t == 0) { - (* set_func) (comp, NULL); - return; - } else { - CalComponentDateTime dt; - struct icaltimetype itt; - - itt = icaltimetype_from_timet (t, FALSE); - dt.value = &itt; - dt.tzid = NULL; - - (* set_func) (comp, &dt); - } -} - -/* FIXME: We need to set the "transient_for" property for the dialog, but the - * model doesn't know anything about the windows. - */ -static void -show_geo_warning (void) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("The geographical position must be entered " - "in the format: \n\n45.436845,125.862501"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Sets the geographical position value of a component */ -static void -set_geo (CalComponent *comp, const char *value) -{ - double latitude, longitude; - int matched; - struct icalgeotype geo; - - if (string_is_empty (value)) { - cal_component_set_geo (comp, NULL); - return; - } - - matched = sscanf (value, "%lg , %lg", &latitude, &longitude); - - if (matched != 2) { - show_geo_warning (); - return; - } - - geo.lat = latitude; - geo.lon = longitude; - cal_component_set_geo (comp, &geo); -} - -/* FIXME: We need to set the "transient_for" property for the dialog, but the - * model doesn't know anything about the windows. - */ -static void -show_percent_warning (void) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("The percent value must be between 0 and 100, inclusive"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Sets the percent value of a calendar component */ -static void -set_percent (CalComponent *comp, const char *value) -{ - int matched, percent; - - if (string_is_empty (value)) { - cal_component_set_percent (comp, NULL); - return; - } - - matched = sscanf (value, "%i", &percent); - - if (matched != 1 || percent < 0 || percent > 100) { - show_percent_warning (); - return; - } - - cal_component_set_percent (comp, &percent); -} - -/* FIXME: We need to set the "transient_for" property for the dialog, but the - * model doesn't know anything about the windows. */ -static void -show_priority_warning (void) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("The priority must be between 1 and 9, inclusive"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Sets the priority of a calendar component */ -static void -set_priority (CalComponent *comp, const char *value) -{ - int matched, priority; - - if (string_is_empty (value)) { - cal_component_set_priority (comp, NULL); - return; - } - - matched = sscanf (value, "%i", &priority); - - if (matched != 1 || priority < 1 || priority > 9) { - show_priority_warning (); - return; - } - - cal_component_set_priority (comp, &priority); -} - -/* Sets the summary of a calendar component */ -static void -set_summary (CalComponent *comp, const char *value) -{ - CalComponentText text; - - if (string_is_empty (value)) { - cal_component_set_summary (comp, NULL); - return; - } - - text.value = value; - text.altrep = NULL; /* FIXME: should we preserve the old ALTREP? */ - - cal_component_set_summary (comp, &text); -} - -/* Sets the URI of a calendar component */ -static void -set_url (CalComponent *comp, const char *value) -{ - if (string_is_empty (value)) { - cal_component_set_url (comp, NULL); - return; - } - - cal_component_set_url (comp, value); -} - -/* set_value_at handler for the calendar table model */ -static void -calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *value) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - CalComponent *comp; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - g_return_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS); - g_return_if_fail (row >= 0 && row < priv->objects->len); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - set_categories (comp, value); - break; - - /* FIXME: CLASSIFICATION requires an option menu cell renderer */ - - case CAL_COMPONENT_FIELD_COMPLETED: - set_completed (comp, value); - break; - - case CAL_COMPONENT_FIELD_DTEND: - /* FIXME: Need to reset dtstart if dtend happens before it */ - set_datetime (comp, value, cal_component_set_dtend); - break; - - case CAL_COMPONENT_FIELD_DTSTART: - /* FIXME: Need to reset dtend if dtstart happens after it */ - set_datetime (comp, value, cal_component_set_dtstart); - break; - - case CAL_COMPONENT_FIELD_DUE: - set_datetime (comp, value, cal_component_set_due); - break; - - case CAL_COMPONENT_FIELD_GEO: - set_geo (comp, value); - break; - - case CAL_COMPONENT_FIELD_PERCENT: - set_percent (comp, value); - break; - - case CAL_COMPONENT_FIELD_PRIORITY: - set_priority (comp, value); - break; - - case CAL_COMPONENT_FIELD_SUMMARY: - set_summary (comp, value); - break; - - /* FIXME: TRANSPARENCY requires an option menu cell renderer */ - - case CAL_COMPONENT_FIELD_URL: - set_url (comp, value); - break; - - default: - g_message ("calendar_model_set_value_at(): Requested invalid column %d", col); - break; - } - - /* FIXME: this is an ugly HACK. ETable needs a better API for the - * "click here to add an element" thingy. - */ - if (priv->appending_row) - return; - - if (!cal_client_update_object (priv->client, comp)) - g_message ("calendar_model_set_value_at(): Could not update the object!"); -} - -/* is_cell_editable handler for the calendar table model */ -static gboolean -calendar_model_is_cell_editable (ETableModel *etm, int col, int row) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, FALSE); - - /* FIXME: We can't check this as 'click-to-add' passes row 0. */ - /*g_return_val_if_fail (row >= 0 && row < priv->objects->len, FALSE);*/ - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - case CAL_COMPONENT_FIELD_SUMMARY: - case CAL_COMPONENT_FIELD_URL: - return TRUE; - - default: - return FALSE; - } -} - -/* append_row handler for the calendar model */ -static void -calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - CalComponent *comp; - int *new_idx, col; - const char *uid; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - /* This is a HACK */ - priv->appending_row = TRUE; - - /* FIXME: This should support other types of components, but for now it - * is only used for the task list. - */ - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - - cal_component_get_uid (comp, &uid); - - g_array_append_val (priv->objects, comp); - new_idx = g_new (int, 1); - *new_idx = priv->objects->len - 1; - g_hash_table_insert (priv->uid_index_hash, (char *) uid, new_idx); - - /* Notify the views about the new row. I think we have to do that here, - or the views may become confused when they start getting - "row_changed" or "cell_changed" signals for this new row. */ - e_table_model_row_inserted (etm, *new_idx); - - for (col = 0; col < CAL_COMPONENT_FIELD_NUM_FIELDS; col++) { - const void *val; - - if (!e_table_model_is_cell_editable (etm, col, *new_idx)) - continue; - - val = e_table_model_value_at(source, col, row); - e_table_model_set_value_at (etm, col, *new_idx, val); - } - - /* This is the end of the HACK */ - priv->appending_row = FALSE; - - if (!cal_client_update_object (priv->client, comp)) { - /* FIXME: Show error dialog. */ - g_message ("calendar_model_append_row(): Could not add new object!"); - remove_object (model, uid); - e_table_model_row_deleted (etm, *new_idx); - } -} - -/* Duplicates a string value */ -static char * -dup_string (const char *value) -{ - return g_strdup (value); -} - -/* duplicate_value handler for the calendar table model */ -static void * -calendar_model_duplicate_value (ETableModel *etm, int col, const void *value) -{ - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL); - - /* They are almost all dup_string()s for now, but we'll have real fields - * later. - */ - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - return dup_string (value); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return (void *) value; - - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - return dup_string (value); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return (void *) value; - - case CAL_COMPONENT_FIELD_URL: - return dup_string (value); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return (void *) value; - - default: - g_message ("calendar_model_duplicate_value(): Requested invalid column %d", col); - return NULL; - } -} - -/* free_value handler for the calendar table model */ -static void -calendar_model_free_value (ETableModel *etm, int col, void *value) -{ - g_return_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - g_free (value); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return; - - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - g_free (value); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return; - - case CAL_COMPONENT_FIELD_URL: - g_free (value); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return; - - default: - g_message ("calendar_model_free_value(): Requested invalid column %d", col); - return; - } -} - -/* Initializes a string value */ -static char * -init_string (void) -{ - return g_strdup (""); -} - -/* initialize_value handler for the calendar table model */ -static void * -calendar_model_initialize_value (ETableModel *etm, int col) -{ - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - return init_string (); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return NULL; - - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - return init_string (); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return NULL; - - case CAL_COMPONENT_FIELD_URL: - return init_string (); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return NULL; - - default: - g_message ("calendar_model_initialize_value(): Requested invalid column %d", col); - return NULL; - } -} - -/* value_is_empty handler for the calendar model. This should return TRUE - unless a significant value has been set. The 'click-to-add' feature - checks all fields to see if any are not empty and if so it adds a new - row, so we only want to return FALSE if we have a useful object. */ -static gboolean -calendar_model_value_is_empty (ETableModel *etm, int col, const void *value) -{ - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, TRUE); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - case CAL_COMPONENT_FIELD_CLASSIFICATION: /* actually goes here, not by itself */ - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - case CAL_COMPONENT_FIELD_TRANSPARENCY: - case CAL_COMPONENT_FIELD_URL: - return string_is_empty (value); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return TRUE; - - default: - g_message ("calendar_model_value_is_empty(): Requested invalid column %d", col); - return TRUE; - } -} - - - -/** - * calendar_model_new: - * - * Creates a new calendar model. It must be told about the calendar client - * interface object it will monitor with calendar_model_set_cal_client(). - * - * Return value: A newly-created calendar model. - **/ -CalendarModel * -calendar_model_new (void) -{ - return CALENDAR_MODEL (gtk_type_new (TYPE_CALENDAR_MODEL)); -} - - -/* Callback used when a calendar is loaded into the server */ -static void -cal_loaded_cb (CalClient *client, - CalClientLoadStatus status, - CalendarModel *model) -{ - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - e_table_model_pre_change (E_TABLE_MODEL (model)); - load_objects (model); - e_table_model_changed (E_TABLE_MODEL (model)); -} - - -/* Removes an object from the model and updates all the indices that follow. - * Returns the index of the object that was removed, or -1 if no object with - * such UID was found. - */ -static int -remove_object (CalendarModel *model, const char *uid) -{ - CalendarModelPrivate *priv; - int *idx; - CalComponent *orig_comp; - int i; - int n; - - priv = model->priv; - - /* Find the index of the object to be removed */ - - idx = g_hash_table_lookup (priv->uid_index_hash, uid); - if (!idx) - return -1; - - orig_comp = g_array_index (priv->objects, CalComponent *, *idx); - g_assert (orig_comp != NULL); - - /* Decrease the indices of all the objects that follow in the array */ - - for (i = *idx + 1; i < priv->objects->len; i++) { - CalComponent *comp; - int *comp_idx; - const char *comp_uid; - - comp = g_array_index (priv->objects, CalComponent *, i); - g_assert (comp != NULL); - - cal_component_get_uid (comp, &comp_uid); - - comp_idx = g_hash_table_lookup (priv->uid_index_hash, comp_uid); - g_assert (comp_idx != NULL); - - (*comp_idx)--; - g_assert (*comp_idx >= 0); - } - - /* Remove this object from the array and hash */ - - g_hash_table_remove (priv->uid_index_hash, uid); - g_array_remove_index (priv->objects, *idx); - - gtk_object_unref (GTK_OBJECT (orig_comp)); - - n = *idx; - g_free (idx); - - return n; -} - -/* Callback used when an object is updated in the server */ -static void -obj_updated_cb (CalClient *client, const char *uid, gpointer data) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - int orig_idx; - CalComponent *new_comp; - const char *new_comp_uid; - int *new_idx; - CalClientGetStatus status; - gboolean added; - - model = CALENDAR_MODEL (data); - priv = model->priv; - - orig_idx = remove_object (model, uid); - - status = cal_client_get_object (priv->client, uid, &new_comp); - - added = FALSE; - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - cal_component_get_uid (new_comp, &new_comp_uid); - - if (orig_idx == -1) { - /* The object not in the model originally, so we just append it */ - - g_array_append_val (priv->objects, new_comp); - - new_idx = g_new (int, 1); - *new_idx = priv->objects->len - 1; - - g_hash_table_insert (priv->uid_index_hash, (char *) new_comp_uid, new_idx); - } else { - int i; - - /* Insert the new version of the object in its old position */ - - g_array_insert_val (priv->objects, orig_idx, new_comp); - - new_idx = g_new (int, 1); - *new_idx = orig_idx; - g_hash_table_insert (priv->uid_index_hash, (char *) new_comp_uid, new_idx); - - /* Increase the indices of all subsequent objects */ - - for (i = orig_idx + 1; i < priv->objects->len; i++) { - CalComponent *comp; - int *comp_idx; - const char *comp_uid; - - comp = g_array_index (priv->objects, CalComponent *, i); - g_assert (comp != NULL); - - cal_component_get_uid (comp, &comp_uid); - - comp_idx = g_hash_table_lookup (priv->uid_index_hash, comp_uid); - g_assert (comp_idx != NULL); - - (*comp_idx)++; - } - } - - e_table_model_row_changed (E_TABLE_MODEL (model), *new_idx); - break; - - case CAL_CLIENT_GET_NOT_FOUND: - /* Nothing; the object may have been removed from the server. We just - * notify that the old object was deleted. - */ - if (orig_idx != -1) - e_table_model_row_deleted (E_TABLE_MODEL (model), orig_idx); - - break; - - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid); - - /* Same notification as above */ - if (orig_idx != -1) - e_table_model_row_deleted (E_TABLE_MODEL (model), orig_idx); - - break; - - default: - g_assert_not_reached (); - } -} - -/* Callback used when an object is removed in the server */ -static void -obj_removed_cb (CalClient *client, const char *uid, gpointer data) -{ - CalendarModel *model; - int idx; - - model = CALENDAR_MODEL (data); - - idx = remove_object (model, uid); - - if (idx != -1) - e_table_model_row_deleted (E_TABLE_MODEL (model), idx); -} - -/* Loads the required objects from the calendar client */ -static void -load_objects (CalendarModel *model) -{ - CalendarModelPrivate *priv; - GList *uids; - GList *l; - - priv = model->priv; - - uids = cal_client_get_uids (priv->client, priv->type); - - for (l = uids; l; l = l->next) { - char *uid; - CalComponent *comp; - const char *comp_uid; - CalClientGetStatus status; - int *idx; - - uid = l->data; - status = cal_client_get_object (priv->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - break; - - case CAL_CLIENT_GET_NOT_FOUND: - /* Nothing; the object may have been removed from the server */ - continue; - - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_message ("load_objects(): Syntax error when getting object `%s'", uid); - continue; - - default: - g_assert_not_reached (); - } - - idx = g_new (int, 1); - - g_array_append_val (priv->objects, comp); - *idx = priv->objects->len - 1; - - cal_component_get_uid (comp, &comp_uid); - g_hash_table_insert (priv->uid_index_hash, (char *) comp_uid, idx); - } - - cal_obj_uid_list_free (uids); -} - -/** - * calendar_model_get_cal_client: - * @model: A calendar model. - * - * Queries the calendar client interface object that a calendar model is using. - * - * Return value: A calendar client interface object. - **/ -CalClient * -calendar_model_get_cal_client (CalendarModel *model) -{ - CalendarModelPrivate *priv; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL); - - priv = model->priv; - - return priv->client; -} - - -/** - * calendar_model_set_cal_client: - * @model: A calendar model. - * @client: A calendar client interface object. - * @type: Type of objects to present. - * - * Sets the calendar client interface object that a calendar model will monitor. - * It also sets the types of objects this model will present to an #ETable. - **/ -void -calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjType type) -{ - CalendarModelPrivate *priv; - - g_return_if_fail (model != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - if (client) - g_return_if_fail (IS_CAL_CLIENT (client)); - - priv = model->priv; - - if (priv->client == client && priv->type == type) - return; - - e_table_model_pre_change (E_TABLE_MODEL(model)); - - if (client) - gtk_object_ref (GTK_OBJECT (client)); - - if (priv->client) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), model); - gtk_object_unref (GTK_OBJECT (priv->client)); - } - - free_objects (model); - - priv->client = client; - priv->type = type; - - if (priv->client) { - gtk_signal_connect (GTK_OBJECT (priv->client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), model); - gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated", - GTK_SIGNAL_FUNC (obj_updated_cb), model); - gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed", - GTK_SIGNAL_FUNC (obj_removed_cb), model); - - load_objects (model); - } - - e_table_model_changed (E_TABLE_MODEL (model)); -} - - -void -calendar_model_delete_task (CalendarModel *model, - gint row) -{ - CalendarModelPrivate *priv; - CalComponent *comp; - const char *uid; - - g_return_if_fail (model != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - priv = model->priv; - - g_return_if_fail (row >= 0 && row < priv->objects->len); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - cal_component_get_uid (comp, &uid); - - if (!cal_client_remove_object (priv->client, uid)) - g_message ("calendar_model_delete_task(): Could not remove the object!"); -} - - -void -calendar_model_mark_task_complete (CalendarModel *model, - gint row) -{ - CalendarModelPrivate *priv; - CalComponent *comp; - int percent; - struct icaltimetype itt; - - g_return_if_fail (model != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - priv = model->priv; - - g_return_if_fail (row >= 0 && row < priv->objects->len); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - percent = 100; - cal_component_set_percent (comp, &percent); - - itt = icaltimetype_from_timet (time (NULL), FALSE); - cal_component_set_completed (comp, &itt); - - if (!cal_client_update_object (priv->client, comp)) - g_message ("calendar_model_mark_task_complete(): Could not update the object!"); -} - - -/* Frees the objects stored in the calendar model */ -CalComponent * -calendar_model_get_cal_object (CalendarModel *model, - gint row) -{ - CalendarModelPrivate *priv; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL); - - priv = model->priv; - - g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL); - - return g_array_index (priv->objects, CalComponent *, row); -} diff --git a/calendar/gui/calendar-model.h b/calendar/gui/calendar-model.h deleted file mode 100644 index d1481a4ece..0000000000 --- a/calendar/gui/calendar-model.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Evolution calendar - Data model for ETable - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CALENDAR_MODEL_H -#define CALENDAR_MODEL_H - -#include <libgnome/gnome-defs.h> -#include <e-table/e-table-model.h> -#include <cal-client/cal-client.h> - -BEGIN_GNOME_DECLS - - - -#define TYPE_CALENDAR_MODEL (calendar_model_get_type ()) -#define CALENDAR_MODEL(obj) (GTK_CHECK_CAST ((obj), TYPE_CALENDAR_MODEL, CalendarModel)) -#define CALENDAR_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_CALENDAR_MODEL, \ - CalendarModelClass)) -#define IS_CALENDAR_MODEL(obj) (GTK_CHECK_TYPE ((obj), TYPE_CALENDAR_MODEL)) -#define IS_CALENDAR_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_CALENDAR_MODEL)) - -typedef struct _CalendarModel CalendarModel; -typedef struct _CalendarModelClass CalendarModelClass; - -struct _CalendarModel { - ETableModel model; - - /* Private data */ - gpointer priv; -}; - -struct _CalendarModelClass { - ETableModelClass parent_class; -}; - -GtkType calendar_model_get_type (void); - -CalendarModel* calendar_model_new (void); - -CalClient* calendar_model_get_cal_client (CalendarModel *model); -void calendar_model_set_cal_client (CalendarModel *model, - CalClient *client, - CalObjType type); - -void calendar_model_mark_task_complete (CalendarModel *model, - gint row); -void calendar_model_delete_task (CalendarModel *model, - gint row); - -CalComponent* calendar_model_get_cal_object (CalendarModel *model, - gint row); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c deleted file mode 100644 index 8644b8928c..0000000000 --- a/calendar/gui/component-factory.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#include <config.h> -#include <bonobo.h> -#include "evolution-shell-component.h" -#include "component-factory.h" -#include "control-factory.h" - - - -#ifdef USING_OAF -#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" -#else -#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:evolution-calendar" -#endif - -static BonoboGenericFactory *factory = NULL; - -static const EvolutionShellComponentFolderType folder_types[] = { - { "calendar", "evolution-calendar.png" }, - { NULL, NULL } -}; - - -/* EvolutionShellComponent methods and signals. */ - -static EvolutionShellComponentResult -create_view (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - BonoboControl **control_return, - void *closure) -{ - BonoboControl *control; - - if (g_strcasecmp (type, "calendar") != 0) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; - - control = control_factory_new_control (); - bonobo_control_set_property (control, "folder_uri", physical_uri, NULL); - - *control_return = control; - - return EVOLUTION_SHELL_COMPONENT_OK; -} - -static gint owner_count = 0; - -static void -owner_set_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - const char *evolution_homedir) -{ - owner_count ++; -} - -static void -owner_unset_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - EvolutionShellClient shell_client, - void *data) -{ - owner_count --; - if (owner_count <= 0) - gtk_main_quit(); -} - - -/* The factory function. */ - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - void *closure) -{ - EvolutionShellComponent *shell_component; - - shell_component = evolution_shell_component_new (folder_types, create_view, NULL, NULL, NULL, NULL); - - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", - GTK_SIGNAL_FUNC (owner_set_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", - GTK_SIGNAL_FUNC (owner_unset_cb), NULL); - - return BONOBO_OBJECT (shell_component); -} - - -void -component_factory_init (void) -{ - if (factory != NULL) - return; - - factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); - - if (factory == NULL) - g_error ("Cannot initialize Evolution's calendar component."); -} diff --git a/calendar/gui/component-factory.h b/calendar/gui/component-factory.h deleted file mode 100644 index f83a849452..0000000000 --- a/calendar/gui/component-factory.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.h - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef _COMPONENT_FACTORY_H_ -#define _COMPONENT_FACTORY_H_ - -void component_factory_init (void); - -#endif /* _COMPONENT_FACTORY_H_ */ diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c deleted file mode 100644 index d7626d21f3..0000000000 --- a/calendar/gui/control-factory.c +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* control-factory.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <bonobo.h> -#include <bonobo/bonobo-control.h> -#include <glade/glade.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - -#include <cal-util/timeutil.h> -#include <gui/alarm.h> -#include <gui/gnome-cal.h> -#include <gui/calendar-commands.h> - -#include "control-factory.h" - -#define PROPERTY_CALENDAR_URI "folder_uri" - -#define PROPERTY_CALENDAR_URI_IDX 1 - -#ifdef USING_OAF -#define CONTROL_FACTORY_ID "OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" -#else -#define CONTROL_FACTORY_ID "control-factory:calendar" -#endif - - -CORBA_Environment ev; -CORBA_ORB orb; - - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - if (activate) - calendar_control_activate (control, user_data); - else - calendar_control_deactivate (control); -} - - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - /*GnomeCalendar *gcal = user_data;*/ - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - /* - if (fb && fb->uri) - BONOBO_ARG_SET_STRING (arg, fb->uri); - else - BONOBO_ARG_SET_STRING (arg, ""); - */ - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - } -} - - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - GnomeCalendar *gcal = user_data; - char *filename; - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - printf ("set_prop: '%s'\n", BONOBO_ARG_GET_STRING (arg)); - filename = g_strdup_printf ("%s/calendar.vcf", - BONOBO_ARG_GET_STRING (arg)); - calendar_set_uri (gcal, filename); - g_free (filename); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - break; - } -} - - -static void -calendar_properties_init (GnomeCalendar *gcal) -{ - gcal->properties = bonobo_property_bag_new (get_prop, set_prop, gcal); - - bonobo_property_bag_add (gcal->properties, - PROPERTY_CALENDAR_URI, - PROPERTY_CALENDAR_URI_IDX, - BONOBO_ARG_STRING, - NULL, - _("The URI that the calendar will display"), - 0); - - bonobo_control_set_property_bag (gcal->control, gcal->properties); -} - - -static BonoboControl * -create_control (void) -{ - BonoboControl *control; - GnomeCalendar *cal; - - cal = new_calendar (full_name, NULL, NULL, 0); - gtk_widget_show (GTK_WIDGET (cal)); - - control = bonobo_control_new (GTK_WIDGET (cal)); - cal->control = control; - - calendar_properties_init (cal); - - gtk_signal_connect (GTK_OBJECT (control), "activate", - control_activate_cb, cal); - - return control; -} - - -static BonoboObject * -control_factory (BonoboGenericFactory *Factory, void *closure) -{ - return BONOBO_OBJECT (create_control ()); -} - - -void -control_factory_init (void) -{ - static BonoboGenericFactory *factory = NULL; - - if (factory != NULL) - return; - - puts ("XXXXXX - initializing calendar factory!!!"); - - factory = bonobo_generic_factory_new (CONTROL_FACTORY_ID, control_factory, NULL); - - if (factory == NULL) - g_error ("I could not register a Calendar control factory."); -} - - -BonoboControl * -control_factory_new_control (void) -{ - return create_control (); -} diff --git a/calendar/gui/control-factory.h b/calendar/gui/control-factory.h deleted file mode 100644 index bacd2d3d90..0000000000 --- a/calendar/gui/control-factory.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* control-factory.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Federico Mena Quintero - */ - -#ifndef _CONTROL_FACTORY_H_ -#define _CONTROL_FACTORY_H_ - -void control_factory_init (void); -BonoboControl *control_factory_new_control (void); - -#endif /* _CONTROL_FACTORY_H_ */ diff --git a/calendar/gui/dayview.xpm b/calendar/gui/dayview.xpm deleted file mode 100644 index bc8e74e4d6..0000000000 --- a/calendar/gui/dayview.xpm +++ /dev/null @@ -1,42 +0,0 @@ -/* XPM */ -static char * dayview_xpm[] = { -"24 24 15 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #AAAFE2", -"$ c #C7CAEB", -"% c #A3A6C7", -"& c #0010A8", -"* c #555FC5", -"= c #1725AC", -"- c #4550B5", -"; c #E3E4F5", -"> c #8B90C3", -", c #3945BB", -"' c #BABBCC", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++@++@#$@++@++@++. ", -" .++@++@++%&*@++@++@++. ", -" .@@@@@@@%=&-@@@@@@@@@. ", -" .++@++@++@&*@++@++@++. ", -" .++@++@++@&*@++@++@++. ", -" .@@@@@@@@@&-@@@@@@@@@. ", -" .++@++@++@&*@++@++@++. ", -" .++@++@+;>&,>++@++@++. ", -" .@@@@@@@'>>>>@@@@@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/gui/dialogs/.cvsignore b/calendar/gui/dialogs/.cvsignore deleted file mode 100644 index e995588475..0000000000 --- a/calendar/gui/dialogs/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -.deps -Makefile -Makefile.in diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am deleted file mode 100644 index 227cb5aa07..0000000000 --- a/calendar/gui/dialogs/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -gladedir = $(datadir)/evolution/glade - -INCLUDES = \ - -DG_LOG_DOMAIN=\"calendar-gui\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_srcdir)/libical/src/libical \ - -I$(includedir) \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - $(BONOBO_VFS_GNOME_CFLAGS) \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" - -noinst_LIBRARIES = libcal-dialogs.a - -libcal_dialogs_a_SOURCES = \ - alarm-notify-dialog.c \ - alarm-notify-dialog.h \ - task-editor.c \ - task-editor.h - -glade_DATA = \ - alarm-notify.glade \ - task-editor-dialog.glade - -glade_messages = \ - alarm-notify.glade.h \ - task-editor-dialog.glade.h - -EXTRA_DIST = \ - $(glade_DATA) \ - $(glade_messages) diff --git a/calendar/gui/dialogs/alarm-notify-dialog.c b/calendar/gui/dialogs/alarm-notify-dialog.c deleted file mode 100644 index 7d8357599c..0000000000 --- a/calendar/gui/dialogs/alarm-notify-dialog.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include "alarm-notify-dialog.h" - - - -/* The useful contents of the alarm notify dialog */ -typedef struct { - GladeXML *xml; - - GtkWidget *dialog; - GtkWidget *close; - GtkWidget *snooze; - GtkWidget *edit; - GtkWidget *heading; - GtkWidget *summary; - GtkWidget *snooze_time; - - AlarmNotifyFunc func; - gpointer func_data; -} AlarmNotify; - - - -/* Callback used when the notify dialog is destroyed */ -static void -dialog_destroy_cb (GtkObject *object, gpointer data) -{ - AlarmNotify *an; - - an = data; - gtk_object_unref (GTK_OBJECT (an->xml)); - g_free (an); -} - -/* Delete_event handler for the alarm notify dialog */ -static gint -delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (widget); - return TRUE; -} - -/* Callback for the close button */ -static void -close_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the snooze button */ -static void -snooze_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - int snooze_time; - - an = data; - g_assert (an->func != NULL); - - snooze_time = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time)); - (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_time, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the edit button */ -static void -edit_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/** - * alarm_notify_dialog: - * @trigger: Trigger time for the alarm. - * @occur: Occurrence time for the event. - * @comp: Calendar component object which corresponds to the alarm. - * @func: Function to be called when a dialog action is invoked. - * @func_data: Closure data for @func. - * - * Runs the alarm notification dialog. The specified @func will be used to - * notify the client about result of the actions in the dialog. - * - * Return value: TRUE on success, FALSE if the dialog could not be created. - **/ -gboolean -alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, - AlarmNotifyFunc func, gpointer func_data) -{ - AlarmNotify *an; - char buf[256]; - struct tm tm_trigger; - struct tm tm_occur; - CalComponentText summary; - - g_return_val_if_fail (trigger != -1, FALSE); - g_return_val_if_fail (occur != -1, FALSE); - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - g_return_val_if_fail (func != NULL, FALSE); - - an = g_new0 (AlarmNotify, 1); - - an->func = func; - an->func_data = func_data; - - an->xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-notify.glade", NULL); - if (!an->xml) { - g_message ("alarm_notify_dialog(): Could not load the Glade XML file!"); - g_free (an); - return FALSE; - } - - an->dialog = glade_xml_get_widget (an->xml, "alarm-notify"); - an->close = glade_xml_get_widget (an->xml, "close"); - an->snooze = glade_xml_get_widget (an->xml, "snooze"); - an->edit = glade_xml_get_widget (an->xml, "edit"); - an->heading = glade_xml_get_widget (an->xml, "heading"); - an->summary = glade_xml_get_widget (an->xml, "summary"); - an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time"); - - if (!(an->dialog && an->close && an->snooze && an->edit && an->heading && an->summary - && an->snooze_time)) { - g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!"); - gtk_object_unref (GTK_OBJECT (an->xml)); - g_free (an); - return FALSE; - } - - gtk_object_set_data (GTK_OBJECT (an->dialog), "alarm-notify", an); - gtk_signal_connect (GTK_OBJECT (an->dialog), "destroy", - GTK_SIGNAL_FUNC (dialog_destroy_cb), an); - - /* Title */ - - /* FIXME: use am_pm_flag or 24-hour time */ - - tm_trigger = *localtime (&trigger); - strftime (buf, sizeof (buf), _("Alarm on %A %b %d %Y %H:%M"), &tm_trigger); - gtk_window_set_title (GTK_WINDOW (an->dialog), buf); - - /* Heading */ - - tm_occur = *localtime (&occur); - strftime (buf, sizeof (buf), - _("Notification about your appointment on %A %b %d %Y %H:%M"), - &tm_occur); - gtk_label_set_text (GTK_LABEL (an->heading), buf); - - /* Summary */ - - cal_component_get_summary (comp, &summary); - - if (summary.value) - gtk_label_set_text (GTK_LABEL (an->summary), summary.value); - else - gtk_label_set_text (GTK_LABEL (an->summary), _("No summary available.")); - - /* Connect actions */ - - gtk_signal_connect (GTK_OBJECT (an->dialog), "delete_event", - GTK_SIGNAL_FUNC (delete_event_cb), - an); - - gtk_signal_connect (GTK_OBJECT (an->close), "clicked", - GTK_SIGNAL_FUNC (close_clicked_cb), - an); - - gtk_signal_connect (GTK_OBJECT (an->snooze), "clicked", - GTK_SIGNAL_FUNC (snooze_clicked_cb), - an); - - gtk_signal_connect (GTK_OBJECT (an->edit), "clicked", - GTK_SIGNAL_FUNC (edit_clicked_cb), - an); - - /* Run! */ - - gtk_widget_show (an->dialog); - return TRUE; -} diff --git a/calendar/gui/dialogs/alarm-notify-dialog.h b/calendar/gui/dialogs/alarm-notify-dialog.h deleted file mode 100644 index 1e56f1c586..0000000000 --- a/calendar/gui/dialogs/alarm-notify-dialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_NOTIFY_DIALOG_H -#define ALARM_NOTIFY_DIALOG_H - -#include <time.h> -#include <glib.h> -#include <cal-util/cal-component.h> - - - -typedef enum { - ALARM_NOTIFY_CLOSE, - ALARM_NOTIFY_SNOOZE, - ALARM_NOTIFY_EDIT -} AlarmNotifyResult; - -typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data); - -gboolean alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, - AlarmNotifyFunc func, gpointer func_data); - - - -#endif diff --git a/calendar/gui/dialogs/alarm-notify.glade b/calendar/gui/dialogs/alarm-notify.glade deleted file mode 100644 index 32d7e03f8b..0000000000 --- a/calendar/gui/dialogs/alarm-notify.glade +++ /dev/null @@ -1,230 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>Evolution Calendar</name> - <program_name>evolution-calendar</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>alarm-notify.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GtkWindow</class> - <name>alarm-notify</name> - <cxx_use_heap>True</cxx_use_heap> - <title></title> - <type>GTK_WINDOW_DIALOG</type> - <position>GTK_WIN_POS_CENTER</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> - <auto_shrink>False</auto_shrink> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox5</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>heading</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>summary</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>close</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Close</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>snooze</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Snooze</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>edit</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Edit appointment</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <cxx_use_heap>True</cxx_use_heap> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label4</name> - <cxx_use_heap>True</cxx_use_heap> - <label>Snooze time (minutes)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>snooze-time</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>5</value> - <lower>1</lower> - <upper>1440</upper> - <step>1</step> - <page>5</page> - <page_size>5</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/dialogs/alarm-notify.glade.h b/calendar/gui/dialogs/alarm-notify.glade.h deleted file mode 100644 index c7b8918e06..0000000000 --- a/calendar/gui/dialogs/alarm-notify.glade.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("Close"); -gchar *s = N_("Snooze"); -gchar *s = N_("Edit appointment"); -gchar *s = N_("Snooze time (minutes)"); diff --git a/calendar/gui/dialogs/task-editor-dialog.glade b/calendar/gui/dialogs/task-editor-dialog.glade deleted file mode 100644 index 56f7f83422..0000000000 --- a/calendar/gui/dialogs/task-editor-dialog.glade +++ /dev/null @@ -1,822 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>task-editor-dialog</name> - <program_name>task-editor-dialog</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>task-editor-dialog.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>task-editor-dialog</name> - <visible>False</visible> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock1</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkNotebook</class> - <child_name>GnomeDock:contents</child_name> - <name>notebook1</name> - <border_width>2</border_width> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - - <widget> - <class>GtkVBox</class> - <name>vbox1</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>S_ubject:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>entry1</default_focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry1</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label10</name> - <label>Owner:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label11</name> - <label></label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table1</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit1</name> - <show_time>True</show_time> - <use_24_format>False</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit2</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label6</name> - <label>Sta_rt Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label5</name> - <label>_Due Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator2</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label7</name> - <label>_Status:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo1</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>Not Started -In Progress -Completed -Cancelled -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry1</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>Not Started</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label8</name> - <label>_Priority:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry2</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo2</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>High -Normal -Low -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry2</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>False</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>High</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label9</name> - <label>% Comp_lete:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>spinbutton1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>spinbutton1</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>10</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow1</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkText</class> - <name>text1</name> - <height>150</height> - <can_focus>True</can_focus> - <editable>True</editable> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox2</name> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_focus>True</can_focus> - <label>_Contacts...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry2</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button4</name> - <can_focus>True</can_focus> - <label>Ca_tegories...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry3</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>checkbutton1</name> - <can_focus>True</can_focus> - <label>Private</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label1</name> - <label>Task</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit3</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label12</name> - <label>Date Completed:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label13</name> - <label>Location:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label14</name> - <label>URL:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry4</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry5</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label15</name> - <label>Resources:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry6</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label2</name> - <label>Details</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/dialogs/task-editor-dialog.glade.h b/calendar/gui/dialogs/task-editor-dialog.glade.h deleted file mode 100644 index 9ee959817f..0000000000 --- a/calendar/gui/dialogs/task-editor-dialog.glade.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("S_ubject:"); -gchar *s = N_("Owner:"); -gchar *s = N_("Sta_rt Date:"); -gchar *s = N_("_Due Date:"); -gchar *s = N_("_Status:"); -gchar *s = N_("Not Started\n" - "In Progress\n" - "Completed\n" - "Cancelled\n" - ""); -gchar *s = N_("Not Started"); -gchar *s = N_("_Priority:"); -gchar *s = N_("High\n" - "Normal\n" - "Low\n" - ""); -gchar *s = N_("High"); -gchar *s = N_("% Comp_lete:"); -gchar *s = N_("_Contacts..."); -gchar *s = N_("Ca_tegories..."); -gchar *s = N_("Private"); -gchar *s = N_("Task"); -gchar *s = N_("Date Completed:"); -gchar *s = N_("Location:"); -gchar *s = N_("URL:"); -gchar *s = N_("Resources:"); -gchar *s = N_("Details"); diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c deleted file mode 100644 index dd40c1b9df..0000000000 --- a/calendar/gui/dialogs/task-editor.c +++ /dev/null @@ -1,481 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * TaskEditor - a GtkObject which handles a libglade-loaded dialog to edit - * tasks. - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <e-util/e-util.h> -#include <cal-client/cal-client.h> -#include "task-editor.h" - - -typedef struct { - /* Glade XML data */ - GladeXML *xml; - - /* UI handler */ - BonoboUIHandler *uih; - - /* Calendar component we are editing; this is an internal copy and is - * not one of the read-only objects from the parent calendar. - */ - CalComponent *comp; - - /* Widgets from the Glade file */ - - GtkWidget *app; -} TaskEditorPrivate; - - -static void task_editor_class_init (TaskEditorClass *class); -static void task_editor_init (TaskEditor *tedit); -TaskEditor * task_editor_construct (TaskEditor *tedit); -static gboolean get_widgets (TaskEditor *tedit); -static void init_widgets (TaskEditor *tedit); -static void create_menu (TaskEditor *tedit); -static void create_toolbar (TaskEditor *tedit); -static void task_editor_destroy (GtkObject *object); - -static GtkObjectClass *parent_class; - -E_MAKE_TYPE(task_editor, "TaskEditor", TaskEditor, - task_editor_class_init, task_editor_init, GTK_TYPE_OBJECT) - - -static void -task_editor_class_init (TaskEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - - object_class->destroy = task_editor_destroy; -} - - -static void -task_editor_init (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = g_new0 (TaskEditorPrivate, 1); - tedit->priv = priv; -} - - -/** - * task_editor_new: - * @Returns: a new #TaskEditor. - * - * Creates a new #TaskEditor. - **/ -TaskEditor * -task_editor_new (void) -{ - TaskEditor *tedit; - - tedit = TASK_EDITOR (gtk_type_new (task_editor_get_type ())); - - return task_editor_construct (tedit); -} - - -/** - * task_editor_construct: - * @tedit: A #TaskEditor. - * - * Constructs a task editor by loading its Glade XML file. - * - * Return value: The same object as @tedit, or NULL if the widgets could not be - * created. In the latter case, the task editor will automatically be - * destroyed. - **/ -TaskEditor * -task_editor_construct (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - g_return_val_if_fail (tedit != NULL, NULL); - g_return_val_if_fail (IS_TASK_EDITOR (tedit), NULL); - - priv = tedit->priv; - - /* Load the content widgets */ - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/task-editor-dialog.glade", NULL); - if (!priv->xml) { - g_message ("task_editor_construct(): Could not load the Glade XML file!"); - goto error; - } - - if (!get_widgets (tedit)) { - g_message ("task_editor_construct(): Could not find all widgets in the XML file!"); - goto error; - } - - init_widgets (tedit); - - /* Construct the app */ - - priv->uih = bonobo_ui_handler_new (); - if (!priv->uih) { - g_message ("task_editor_construct(): Could not create the UI handler"); - goto error; - } - - bonobo_ui_handler_set_app (priv->uih, GNOME_APP (priv->app)); - - create_menu (tedit); - create_toolbar (tedit); - - /* Hook to destruction of the dialog */ - -#if 0 - gtk_signal_connect (GTK_OBJECT (priv->app), "delete_event", - GTK_SIGNAL_FUNC (app_delete_event_cb), tedit); -#endif - - /* Show the dialog */ - - gtk_widget_show (priv->app); - - return tedit; - - error: - - gtk_object_unref (GTK_OBJECT (tedit)); - return NULL; -} - - -/* Gets the widgets from the XML file and returns if they are all available. - * For the widgets whose values can be simply set with e-dialog-utils, it does - * that as well. - */ -static gboolean -get_widgets (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - priv->app = GW ("task-editor-dialog"); - - return TRUE; -} - - -/* Hooks the widget signals */ -static void -init_widgets (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - -} - - -/* Menu bar */ - -static GnomeUIInfo file_new_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mail Message"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Appointment"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Meeting Re_quest"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Journal Entry"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Note"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_page_setup_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Memo Style"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Define Print _Styles..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_menu[] = { - GNOMEUIINFO_MENU_NEW_SUBTREE (file_new_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_SAVE_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_SAVE_AS_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL), - GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLOSE_ITEM (NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_object_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: what goes here?", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_menu[] = { - GNOMEUIINFO_MENU_UNDO_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_REDO_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CUT_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_COPY_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_PASTE_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Paste _Special..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLEAR_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_SELECT_ALL_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Mark as U_nread"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_FIND_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_FIND_AGAIN_ITEM (NULL, NULL), - GNOMEUIINFO_SUBTREE (N_("_Object"), edit_object_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_previous_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: In_complete Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Fi_rst Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_next_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: In_complete Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Last Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_toolbars_menu[] = { - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: _Standard"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: __Formatting"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Customize..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_menu[] = { - GNOMEUIINFO_SUBTREE (N_("Pre_vious"), view_previous_menu), - GNOMEUIINFO_SUBTREE (N_("Ne_xt"), view_next_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Toolbars"), view_toolbars_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo insert_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _File..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: It_em..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Object..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo format_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Font..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Paragraph..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_forms_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Desi_gn This Form"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: D_esign a Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Publish _Form..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Pu_blish Form As..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Script _Debugger"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Spelling..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Chec_k Names"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Address _Book..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Forms"), tools_forms_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo actions_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _New Task"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end Status Report"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mark Complete"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Rec_urrence..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_kip Occurrence"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Assig_n Task"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Reply"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Reply to A_ll"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: For_ward"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo help_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: fix Bonobo so it supports help items!", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo main_menu[] = { - GNOMEUIINFO_MENU_FILE_TREE (file_menu), - GNOMEUIINFO_MENU_EDIT_TREE (edit_menu), - GNOMEUIINFO_MENU_VIEW_TREE (view_menu), - GNOMEUIINFO_SUBTREE (N_("_Insert"), insert_menu), - GNOMEUIINFO_SUBTREE (N_("F_ormat"), format_menu), - GNOMEUIINFO_SUBTREE (N_("_Tools"), tools_menu), - GNOMEUIINFO_SUBTREE (N_("Actio_ns"), actions_menu), - GNOMEUIINFO_MENU_HELP_TREE (help_menu), - GNOMEUIINFO_END -}; - - -/* Creates the menu bar for the event editor */ -static void -create_menu (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - BonoboUIHandlerMenuItem *list; - - priv = tedit->priv; - - bonobo_ui_handler_create_menubar (priv->uih); - - list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (main_menu, - tedit); - bonobo_ui_handler_menu_add_list (priv->uih, "/", list); -} - - -/* Toolbar */ - -static GnomeUIInfo toolbar[] = { - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Save and Close"), - N_("Save the task and close the dialog box"), - NULL, - GNOME_STOCK_PIXMAP_SAVE), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print..."), - N_("Print this item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."), - N_("Insert a file as an attachment"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Recurrence..."), - N_("Configure recurrence rules"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Assign Task..."), - N_("Assign the task to someone"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Delete"), - N_("Delete this item"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Previous"), - N_("Go to the previous item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Next"), - N_("Go to the next item"), NULL), - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Help"), - N_("See online help"), NULL, GNOME_STOCK_PIXMAP_HELP), - GNOMEUIINFO_END -}; - - -/* Creates the toolbar for the event editor */ -static void -create_toolbar (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - BonoboUIHandlerToolbarItem *list; - GnomeDockItem *dock_item; - GtkWidget *toolbar_child; - - priv = tedit->priv; - - bonobo_ui_handler_create_toolbar (priv->uih, "Toolbar"); - - /* Fetch the toolbar. What a pain in the ass. */ - - dock_item = gnome_app_get_dock_item_by_name (GNOME_APP (priv->app), GNOME_APP_TOOLBAR_NAME); - g_assert (dock_item != NULL); - - toolbar_child = gnome_dock_item_get_child (dock_item); - g_assert (toolbar_child != NULL && GTK_IS_TOOLBAR (toolbar_child)); - - /* Turn off labels as GtkToolbar sucks */ - gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_child), GTK_TOOLBAR_ICONS); - - list = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (toolbar, - tedit); - bonobo_ui_handler_toolbar_add_list (priv->uih, "/Toolbar", list); -} - - -static void -task_editor_destroy (GtkObject *object) -{ - TaskEditor *tedit; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_TASK_EDITOR (object)); - - tedit = TASK_EDITOR (object); - - -} - - diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h deleted file mode 100644 index 159b969ab9..0000000000 --- a/calendar/gui/dialogs/task-editor.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _TASK_EDITOR_H_ -#define _TASK_EDITOR_H_ - -#include <gtk/gtkobject.h> -#include <libgnome/gnome-defs.h> -#include <bonobo.h> - -BEGIN_GNOME_DECLS - - -#define TASK_EDITOR(obj) GTK_CHECK_CAST (obj, task_editor_get_type (), TaskEditor) -#define TASK_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, task_editor_get_type (), TaskEditorClass) -#define IS_TASK_EDITOR(obj) GTK_CHECK_TYPE (obj, task_editor_get_type ()) - - -typedef struct _TaskEditor TaskEditor; -typedef struct _TaskEditorClass TaskEditorClass; - -struct _TaskEditor -{ - GtkObject object; - - /* Private data */ - gpointer priv; -}; - -struct _TaskEditorClass -{ - GtkObjectClass parent_class; -}; - - -GtkType task_editor_get_type (void); -TaskEditor* task_editor_new (void); - - - -END_GNOME_DECLS - -#endif /* _TASK_EDITOR_H_ */ diff --git a/calendar/gui/dialogs/task-page.glade b/calendar/gui/dialogs/task-page.glade deleted file mode 100644 index 56f7f83422..0000000000 --- a/calendar/gui/dialogs/task-page.glade +++ /dev/null @@ -1,822 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>task-editor-dialog</name> - <program_name>task-editor-dialog</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>task-editor-dialog.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>task-editor-dialog</name> - <visible>False</visible> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock1</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkNotebook</class> - <child_name>GnomeDock:contents</child_name> - <name>notebook1</name> - <border_width>2</border_width> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - - <widget> - <class>GtkVBox</class> - <name>vbox1</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>S_ubject:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>entry1</default_focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry1</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label10</name> - <label>Owner:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label11</name> - <label></label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table1</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit1</name> - <show_time>True</show_time> - <use_24_format>False</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit2</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label6</name> - <label>Sta_rt Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label5</name> - <label>_Due Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator2</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label7</name> - <label>_Status:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo1</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>Not Started -In Progress -Completed -Cancelled -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry1</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>Not Started</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label8</name> - <label>_Priority:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry2</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo2</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>High -Normal -Low -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry2</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>False</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>High</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label9</name> - <label>% Comp_lete:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>spinbutton1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>spinbutton1</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>10</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow1</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkText</class> - <name>text1</name> - <height>150</height> - <can_focus>True</can_focus> - <editable>True</editable> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox2</name> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_focus>True</can_focus> - <label>_Contacts...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry2</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button4</name> - <can_focus>True</can_focus> - <label>Ca_tegories...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry3</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>checkbutton1</name> - <can_focus>True</can_focus> - <label>Private</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label1</name> - <label>Task</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit3</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label12</name> - <label>Date Completed:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label13</name> - <label>Location:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label14</name> - <label>URL:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry4</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry5</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label15</name> - <label>Resources:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry6</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label2</name> - <label>Details</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c deleted file mode 100644 index 1a9e00de12..0000000000 --- a/calendar/gui/e-calendar-table.c +++ /dev/null @@ -1,482 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * ECalendarTable - displays the iCalendar objects in a table (an ETable). - * Used for calendar events and tasks. - */ - -#include <config.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-popup-menu.h> -#include <e-table/e-table-scrolled.h> -#include <e-table/e-cell-checkbox.h> -#include <e-table/e-cell-toggle.h> -#include <e-table/e-cell-text.h> -#include "e-calendar-table.h" -#include "calendar-model.h" -#include "gncal-todo.h" - -/* Pixmaps. */ -#include "task.xpm" -#include "task-recurring.xpm" -#include "task-assigned.xpm" -#include "task-assigned-to.xpm" - -#include <e-table/check-filled.xpm> - - -static void e_calendar_table_class_init (ECalendarTableClass *class); -static void e_calendar_table_init (ECalendarTable *cal_table); -static void e_calendar_table_destroy (GtkObject *object); - -static void e_calendar_table_on_double_click (ETable *table, - gint row, - ECalendarTable *cal_table); -static gint e_calendar_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEventButton *event, - ECalendarTable *cal_table); -static void e_calendar_table_on_open_task (GtkWidget *menuitem, - gpointer data); -static void e_calendar_table_on_mark_task_complete (GtkWidget *menuitem, - gpointer data); -static void e_calendar_table_on_delete_task (GtkWidget *menuitem, - gpointer data); -static gint e_calendar_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - ECalendarTable *cal_table); - -static void e_calendar_table_open_task (ECalendarTable *cal_table, - gint row); - -/* The icons to represent the task. */ -#define E_CALENDAR_MODEL_NUM_ICONS 4 -static char** icon_xpm_data[E_CALENDAR_MODEL_NUM_ICONS] = { - task_xpm, task_recurring_xpm, task_assigned_xpm, task_assigned_to_xpm -}; -static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { 0 }; - -static GtkTableClass *parent_class; - - -GtkType -e_calendar_table_get_type (void) -{ - static GtkType e_calendar_table_type = 0; - - if (!e_calendar_table_type){ - GtkTypeInfo e_calendar_table_info = { - "ECalendarTable", - sizeof (ECalendarTable), - sizeof (ECalendarTableClass), - (GtkClassInitFunc) e_calendar_table_class_init, - (GtkObjectInitFunc) e_calendar_table_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = gtk_type_class (GTK_TYPE_TABLE); - e_calendar_table_type = gtk_type_unique (GTK_TYPE_TABLE, - &e_calendar_table_info); - } - - return e_calendar_table_type; -} - - -static void -e_calendar_table_class_init (ECalendarTableClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - object_class->destroy = e_calendar_table_destroy; - -#if 0 - widget_class->realize = e_calendar_table_realize; - widget_class->unrealize = e_calendar_table_unrealize; - widget_class->style_set = e_calendar_table_style_set; - widget_class->size_allocate = e_calendar_table_size_allocate; - widget_class->focus_in_event = e_calendar_table_focus_in; - widget_class->focus_out_event = e_calendar_table_focus_out; - widget_class->key_press_event = e_calendar_table_key_press; -#endif -} - - -#define E_CALENDAR_TABLE_SPEC \ - "<ETableSpecification click-to-add=\"1\">" \ - "<columns-shown>" \ - "<column> 16 </column>" \ - "<column> 17 </column>" \ - "<column> 13 </column>" \ - "</columns-shown>" \ - "<grouping> </grouping>" \ - "</ETableSpecification>" - -#define e_cell_time_new e_cell_text_new -#define e_cell_time_compare g_str_compare -#define e_cell_geo_pos_new e_cell_text_new -#define e_cell_geo_pos_compare g_str_compare - -static void -e_calendar_table_init (ECalendarTable *cal_table) -{ - GtkWidget *table; - ETableModel *model; - ETableHeader *header; - ECell *cell; - ETableCol *column; - gint i; - GdkPixbuf *pixbuf; - GdkColormap *colormap; - gboolean success[E_CALENDAR_TABLE_COLOR_LAST]; - gint nfailed; - - /* Allocate the colors we need. */ - colormap = gtk_widget_get_colormap (GTK_WIDGET (cal_table)); - - cal_table->colors[E_CALENDAR_TABLE_COLOR_OVERDUE].red = 65535; - cal_table->colors[E_CALENDAR_TABLE_COLOR_OVERDUE].green = 0; - cal_table->colors[E_CALENDAR_TABLE_COLOR_OVERDUE].blue = 0; - - nfailed = gdk_colormap_alloc_colors (colormap, cal_table->colors, - E_CALENDAR_TABLE_COLOR_LAST, - FALSE, TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); - - - cal_table->model = calendar_model_new (); - model = E_TABLE_MODEL (cal_table->model); - - header = e_table_header_new (); - gtk_object_ref (GTK_OBJECT (header)); - gtk_object_sink (GTK_OBJECT (header)); - - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_COMMENT, _("Comment"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_COMMENT); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_COMPLETED, _("Completed"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_COMPLETED); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_CREATED, _("Created"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_CREATED); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DESCRIPTION, _("Description"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DESCRIPTION); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DTSTAMP, _("Timestamp"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DTSTAMP); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DTSTART, _("Start Date"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DTSTART); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DTEND, _("End Date"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DTEND); - - cell = e_cell_geo_pos_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_GEO, _("Geographical Position"), - 1.0, 10, cell, e_cell_geo_pos_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_GEO); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_LAST_MOD, _("Last Modification Date"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_LAST_MOD); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_LOCATION, _("Location"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_LOCATION); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_ORGANIZER, _("Organizer"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_ORGANIZER); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_PERCENT, _("% Complete"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_PERCENT); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_PRIORITY, _("Priority"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_PRIORITY); - - /* FIXME: This should really be 'Subject' in the big view. */ - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - gtk_object_set (GTK_OBJECT (cell), - "strikeout_column", ICAL_OBJECT_FIELD_COMPLETE, - "bold_column", ICAL_OBJECT_FIELD_OVERDUE, - "color_column", ICAL_OBJECT_FIELD_COLOR, - NULL); - column = e_table_col_new (ICAL_OBJECT_FIELD_SUMMARY, _("TaskPad"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_SUMMARY); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_URL, _("URL"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_URL); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_HAS_ALARMS, _("Reminder"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_HAS_ALARMS); - - /* Create pixmaps. */ - if (!icon_pixbufs[0]) { - for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) { - icon_pixbufs[i] = gdk_pixbuf_new_from_xpm_data ( - (const char **) icon_xpm_data[i]); - } - } - - cell = e_cell_toggle_new (0, 4, icon_pixbufs); - column = e_table_col_new_with_pixbuf (ICAL_OBJECT_FIELD_ICON, - icon_pixbufs[0], 0.0, 16, cell, - g_int_compare, FALSE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_ICON); - - cell = e_cell_checkbox_new (); - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) check_filled_xpm); - column = e_table_col_new_with_pixbuf (ICAL_OBJECT_FIELD_COMPLETE, - pixbuf, 0.0, 16, cell, - g_int_compare, FALSE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_COMPLETE); - - - table = e_table_scrolled_new (header, model, E_CALENDAR_TABLE_SPEC); - gtk_object_set (GTK_OBJECT (table), - "click_to_add_message", "Click here to add a new Task", - NULL); - gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (table); - - gtk_signal_connect (GTK_OBJECT (table), "double_click", - GTK_SIGNAL_FUNC (e_calendar_table_on_double_click), - cal_table); - gtk_signal_connect (GTK_OBJECT (table), "right_click", - GTK_SIGNAL_FUNC (e_calendar_table_on_right_click), - cal_table); - gtk_signal_connect (GTK_OBJECT (table), "key_press", - GTK_SIGNAL_FUNC (e_calendar_table_on_key_press), - cal_table); -} - - -/** - * e_calendar_table_new: - * @Returns: a new #ECalendarTable. - * - * Creates a new #ECalendarTable. - **/ -GtkWidget * -e_calendar_table_new (void) -{ - GtkWidget *cal_table; - - cal_table = GTK_WIDGET (gtk_type_new (e_calendar_table_get_type ())); - - return cal_table; -} - - -static void -e_calendar_table_destroy (GtkObject *object) -{ - ECalendarTable *cal_table; - - cal_table = E_CALENDAR_TABLE (object); - - - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -void -e_calendar_table_set_cal_client (ECalendarTable *cal_table, - CalClient *client) -{ - g_print ("In e_calendar_table_set_cal_client\n"); - - calendar_model_set_cal_client (cal_table->model, client, - CALOBJ_TYPE_TODO); -} - - -static void -e_calendar_table_on_double_click (ETable *table, - gint row, - ECalendarTable *cal_table) -{ - g_print ("In e_calendar_table_on_double_click row:%i\n", row); - - e_calendar_table_open_task (cal_table, row); -} - - -static GnomeUIInfo e_calendar_table_popup_uiinfo[] = { - { GNOME_APP_UI_ITEM, N_("Open..."), - N_("Open the task"), e_calendar_table_on_open_task, - NULL, NULL, 0, 0, 0, 0 }, - { GNOME_APP_UI_ITEM, N_("Mark Complete"), - N_("Mark the task complete"), e_calendar_table_on_mark_task_complete, - NULL, NULL, 0, 0, 0, 0 }, - { GNOME_APP_UI_ITEM, N_("Delete"), - N_("Delete the task"), e_calendar_table_on_delete_task, - NULL, NULL, 0, 0, 0, 0 }, - - GNOMEUIINFO_END -}; - - -typedef struct _ECalendarMenuData ECalendarMenuData; -struct _ECalendarMenuData { - ECalendarTable *cal_table; - gint row; -}; - -static gint -e_calendar_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEventButton *event, - ECalendarTable *cal_table) -{ - ECalendarMenuData menu_data; - GtkWidget *popup_menu; - - menu_data.cal_table = cal_table; - menu_data.row = row; - - popup_menu = gnome_popup_menu_new (e_calendar_table_popup_uiinfo); - gnome_popup_menu_do_popup_modal (popup_menu, NULL, NULL, event, - &menu_data); - - gtk_widget_destroy (popup_menu); - - return TRUE; -} - - -static void -e_calendar_table_on_open_task (GtkWidget *menuitem, - gpointer data) -{ - ECalendarMenuData *menu_data = (ECalendarMenuData*) data; - - e_calendar_table_open_task (menu_data->cal_table, - menu_data->row); -} - - -static void -e_calendar_table_on_mark_task_complete (GtkWidget *menuitem, - gpointer data) -{ - ECalendarMenuData *menu_data = (ECalendarMenuData*) data; - - calendar_model_mark_task_complete (menu_data->cal_table->model, - menu_data->row); -} - - -static void -e_calendar_table_on_delete_task (GtkWidget *menuitem, - gpointer data) -{ - ECalendarMenuData *menu_data = (ECalendarMenuData*) data; - - calendar_model_delete_task (menu_data->cal_table->model, - menu_data->row); -} - - - -static gint -e_calendar_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - ECalendarTable *cal_table) -{ - g_print ("In e_calendar_table_on_key_press\n"); - - if (event->keyval == GDK_Delete) { - g_print (" delete key!!!\n"); - - calendar_model_delete_task (cal_table->model, row); - } - - return FALSE; -} - - -static void -e_calendar_table_open_task (ECalendarTable *cal_table, - gint row) -{ - iCalObject *ico; - -#if 0 - task_editor_new (); - /* FIXME: Set iCalObject to edit. */ -#endif - - ico = calendar_model_get_cal_object (cal_table->model, row); - - gncal_todo_edit (calendar_model_get_cal_client (cal_table->model), - ico); -} - - diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h deleted file mode 100644 index eed021e846..0000000000 --- a/calendar/gui/e-calendar-table.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_CALENDAR_TABLE_H_ -#define _E_CALENDAR_TABLE_H_ - -#include <gtk/gtktable.h> -#include "calendar-model.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * ECalendarTable - displays the iCalendar objects in a table (an ETable). - * Used for calendar events and tasks. - */ - -/* These index our colors array. */ -typedef enum -{ - E_CALENDAR_TABLE_COLOR_OVERDUE, - - E_CALENDAR_TABLE_COLOR_LAST -} ECalendarTableColors; - - -#define E_CALENDAR_TABLE(obj) GTK_CHECK_CAST (obj, e_calendar_table_get_type (), ECalendarTable) -#define E_CALENDAR_TABLE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_calendar_table_get_type (), ECalendarTableClass) -#define E_IS_CALENDAR_TABLE(obj) GTK_CHECK_TYPE (obj, e_calendar_table_get_type ()) - - -typedef struct _ECalendarTable ECalendarTable; -typedef struct _ECalendarTableClass ECalendarTableClass; - -struct _ECalendarTable -{ - GtkTable table; - - CalendarModel *model; - - /* Colors for drawing. */ - GdkColor colors[E_CALENDAR_TABLE_COLOR_LAST]; -}; - -struct _ECalendarTableClass -{ - GtkTableClass parent_class; -}; - - -GtkType e_calendar_table_get_type (void); -GtkWidget* e_calendar_table_new (void); - - -void e_calendar_table_set_cal_client (ECalendarTable *cal_table, - CalClient *client); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CALENDAR_TABLE_H_ */ diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c deleted file mode 100644 index 8353c0497e..0000000000 --- a/calendar/gui/e-day-view-main-item.c +++ /dev/null @@ -1,651 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EDayViewMainItem - canvas item which displays most of the appointment - * data in the main Day/Work Week display. - */ - -#include <config.h> -#include "e-day-view-main-item.h" - -static void e_day_view_main_item_class_init (EDayViewMainItemClass *class); -static void e_day_view_main_item_init (EDayViewMainItem *dvtitem); - -static void e_day_view_main_item_set_arg (GtkObject *o, GtkArg *arg, - guint arg_id); -static void e_day_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, int flags); -static void e_day_view_main_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, int y, - int width, int height); -static double e_day_view_main_item_point (GnomeCanvasItem *item, - double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item); -static gint e_day_view_main_item_event (GnomeCanvasItem *item, - GdkEvent *event); - -static void e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day); -static void e_day_view_main_item_draw_day_events (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day); -static void e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day, gint event_num); - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_DAY_VIEW -}; - - -GtkType -e_day_view_main_item_get_type (void) -{ - static GtkType e_day_view_main_item_type = 0; - - if (!e_day_view_main_item_type) { - GtkTypeInfo e_day_view_main_item_info = { - "EDayViewMainItem", - sizeof (EDayViewMainItem), - sizeof (EDayViewMainItemClass), - (GtkClassInitFunc) e_day_view_main_item_class_init, - (GtkObjectInitFunc) e_day_view_main_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_day_view_main_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_day_view_main_item_info); - } - - return e_day_view_main_item_type; -} - - -static void -e_day_view_main_item_class_init (EDayViewMainItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EDayViewMainItem::day_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_DAY_VIEW); - - object_class->set_arg = e_day_view_main_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_day_view_main_item_update; - item_class->draw = e_day_view_main_item_draw; - item_class->point = e_day_view_main_item_point; - item_class->event = e_day_view_main_item_event; -} - - -static void -e_day_view_main_item_init (EDayViewMainItem *dvtitem) -{ - dvtitem->day_view = NULL; -} - - -static void -e_day_view_main_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EDayViewMainItem *dvmitem; - - item = GNOME_CANVAS_ITEM (o); - dvmitem = E_DAY_VIEW_MAIN_ITEM (o); - - switch (arg_id){ - case ARG_DAY_VIEW: - dvmitem->day_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_day_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable, - int x, int y, int width, int height) -{ - EDayViewMainItem *dvmitem; - EDayView *day_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc, *gc; - GdkFont *font; - gint row, row_y, grid_x1, grid_x2; - gint day, grid_y1, grid_y2; - gint work_day_start_row, work_day_end_row; - gint work_day_start_y, work_day_end_y; - gint work_day_x, work_day_w; - gint start_row, end_row, rect_x, rect_y, rect_width, rect_height; - -#if 0 - g_print ("In e_day_view_main_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - dvmitem = E_DAY_VIEW_MAIN_ITEM (canvas_item); - day_view = dvmitem->day_view; - g_return_if_fail (day_view != NULL); - - style = GTK_WIDGET (day_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - - /* Paint the background colors. */ - gc = day_view->main_gc; - work_day_start_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); - work_day_start_y = work_day_start_row * day_view->row_height - y; - work_day_end_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_end_hour, day_view->work_day_end_minute); - work_day_end_y = work_day_end_row * day_view->row_height - y; - - work_day_x = day_view->day_offsets[0] - x; - work_day_w = width - work_day_x; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]); - gdk_draw_rectangle (drawable, gc, TRUE, - work_day_x, 0 - y, - work_day_w, work_day_start_y - (0 - y)); - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING]); - gdk_draw_rectangle (drawable, gc, TRUE, - work_day_x, work_day_start_y, - work_day_w, work_day_end_y - work_day_start_y); - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]); - gdk_draw_rectangle (drawable, gc, TRUE, - work_day_x, work_day_end_y, - work_day_w, height - work_day_end_y); - - /* Paint the selection background. */ - if (GTK_WIDGET_HAS_FOCUS (day_view) - && day_view->selection_start_day != -1 - && !day_view->selection_in_top_canvas) { - for (day = day_view->selection_start_day; - day <= day_view->selection_end_day; - day++) { - if (day == day_view->selection_start_day - && day_view->selection_start_row != -1) - start_row = day_view->selection_start_row; - else - start_row = 0; - if (day == day_view->selection_end_day - && day_view->selection_end_row != -1) - end_row = day_view->selection_end_row; - else - end_row = day_view->rows - 1; - - rect_x = day_view->day_offsets[day] - x; - rect_width = day_view->day_widths[day]; - rect_y = start_row * day_view->row_height - y; - rect_height = (end_row - start_row + 1) * day_view->row_height; - - gc = style->bg_gc[GTK_STATE_SELECTED]; - gdk_draw_rectangle (drawable, gc, TRUE, - rect_x, rect_y, - rect_width, rect_height); - } - } - - /* Drawing the horizontal grid lines. */ - grid_x1 = day_view->day_offsets[0] - x; - grid_x2 = day_view->day_offsets[day_view->days_shown] - x; - - for (row = 0, row_y = 0 - y; - row < day_view->rows && row_y < height; - row++, row_y += day_view->row_height) { - if (row_y >= 0 && row_y < height) - gdk_draw_line (drawable, dark_gc, - grid_x1, row_y, grid_x2, row_y); - } - - /* Draw the vertical bars down the left of each column. */ - grid_y1 = 0; - grid_y2 = height; - for (day = 0; day < day_view->days_shown; day++) { - grid_x1 = day_view->day_offsets[day] - x; - - /* Skip if it isn't visible. */ - if (grid_x1 >= width || grid_x1 + E_DAY_VIEW_BAR_WIDTH <= 0) - continue; - - gdk_draw_line (drawable, fg_gc, - grid_x1, grid_y1, - grid_x1, grid_y2); - gdk_draw_line (drawable, fg_gc, - grid_x1 + E_DAY_VIEW_BAR_WIDTH - 1, grid_y1, - grid_x1 + E_DAY_VIEW_BAR_WIDTH - 1, grid_y2); - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - grid_x1 + 1, grid_y1, - E_DAY_VIEW_BAR_WIDTH - 2, grid_y2 - grid_y1); - - /* Fill in the bars when the user is busy. */ - e_day_view_main_item_draw_events_in_vbars (dvmitem, drawable, - x, y, - width, height, - day); - } - - /* Fill in the vertical bars corresponding to the busy times from the - long events. */ - e_day_view_main_item_draw_long_events_in_vbars (dvmitem, drawable, - x, y, width, height); - - /* Draw the event borders and backgrounds, and the vertical bars - down the left edges. */ - for (day = 0; day < day_view->days_shown; day++) { - e_day_view_main_item_draw_day_events (dvmitem, drawable, - x, y, width, height, - day); - } -} - - -static void -e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day) -{ - EDayView *day_view; - EDayViewEvent *event; - GdkGC *gc; - gint grid_x, event_num, bar_y, bar_h; - - day_view = dvmitem->day_view; - - gc = day_view->main_gc; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); - - grid_x = day_view->day_offsets[day] + 1 - x; - - /* Draw the busy times corresponding to the events in the day. */ - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* We can skip the events in the first column since they will - draw over this anyway. */ - if (event->num_columns > 0 && event->start_row_or_col == 0) - continue; - - bar_y = event->start_minute * day_view->row_height / day_view->mins_per_row; - bar_h = event->end_minute * day_view->row_height / day_view->mins_per_row - bar_y; - bar_y -= y; - - /* Skip it if it isn't visible. */ - if (bar_y >= height || bar_y + bar_h <= 0) - continue; - - gdk_draw_rectangle (drawable, gc, TRUE, - grid_x, bar_y, - E_DAY_VIEW_BAR_WIDTH - 2, bar_h); - } -} - - -static void -e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height) -{ - EDayView *day_view; - EDayViewEvent *event; - gint event_num, start_day, end_day, day, bar_y1, bar_y2, grid_x; - GdkGC *gc; - - day_view = dvmitem->day_view; - - gc = day_view->main_gc; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - continue; - - for (day = start_day; day <= end_day; day++) { - grid_x = day_view->day_offsets[day] + 1 - x; - - /* Skip if it isn't visible. */ - if (grid_x >= width - || grid_x + E_DAY_VIEW_BAR_WIDTH <= 0) - continue; - - if (event->start <= day_view->day_starts[day]) { - bar_y1 = 0; - } else { - bar_y1 = event->start_minute * day_view->row_height / day_view->mins_per_row - y; - } - - if (event->end >= day_view->day_starts[day + 1]) { - bar_y2 = height; - } else { - bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y; - } - - if (bar_y1 < height && bar_y2 > 0 && bar_y2 > bar_y1) { - gdk_draw_rectangle (drawable, gc, TRUE, - grid_x, bar_y1, - E_DAY_VIEW_BAR_WIDTH - 2, - bar_y2 - bar_y1); - } - } - - - } -} - - -static void -e_day_view_main_item_draw_day_events (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, int width, int height, - gint day) -{ - EDayView *day_view; - gint event_num; - - day_view = dvmitem->day_view; - - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - e_day_view_main_item_draw_day_event (dvmitem, drawable, - x, y, width, height, - day, event_num); - } -} - - -static void -e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, int width, int height, - gint day, gint event_num) -{ - EDayView *day_view; - EDayViewEvent *event; - gint item_x, item_y, item_w, item_h, bar_y1, bar_y2; - GtkStyle *style; - GdkGC *gc; - CalComponent *comp; - gint num_icons, icon_x, icon_y, icon_x_inc, icon_y_inc; - gint max_icon_w, max_icon_h; - gboolean draw_reminder_icon, draw_recurrence_icon; - - day_view = dvmitem->day_view; - - /* If the event is currently being dragged, don't draw it. It will - be drawn in the special drag items. */ - if (day_view->drag_event_day == day - && day_view->drag_event_num == event_num) - return; - - style = GTK_WIDGET (day_view)->style; - - gc = day_view->main_gc; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); - - /* Get the position of the event. If it is not shown skip it.*/ - if (!e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) - return; - - item_x -= x; - item_y -= y; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Fill in the white background. Note that for events in the first - column of the day, we might not want to paint over the vertical bar, - since that is used for multiple events. But then you can't see - where the event in the first column finishes. */ -#if 0 - if (event->start_row_or_col == 0) - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - item_x + E_DAY_VIEW_BAR_WIDTH, item_y + 1, - MAX (item_w - E_DAY_VIEW_BAR_WIDTH - 1, 0), - item_h - 2); - else -#endif - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - item_x + 1, item_y + 1, - MAX (item_w - 2, 0), item_h - 2); - - /* Draw the right edge of the vertical bar. */ - gdk_draw_line (drawable, style->black_gc, - item_x + E_DAY_VIEW_BAR_WIDTH - 1, - item_y + 1, - item_x + E_DAY_VIEW_BAR_WIDTH - 1, - item_y + item_h - 2); - - /* Draw the vertical colored bar showing when the appointment - begins & ends. */ - bar_y1 = event->start_minute * day_view->row_height / day_view->mins_per_row - y; - bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y; - - /* When an item is being resized, we fill the bar up to the new row. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == day - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) - bar_y1 = item_y + 1; - else if (day_view->resize_drag_pos == E_DAY_VIEW_POS_BOTTOM_EDGE) - bar_y2 = item_y + item_h - 1; - } - - gdk_draw_rectangle (drawable, gc, TRUE, - item_x + 1, bar_y1, - E_DAY_VIEW_BAR_WIDTH - 2, bar_y2 - bar_y1); - - /* Draw the box around the entire event. Do this after drawing - the colored bar so we don't have to worry about being 1 - pixel out. */ - gdk_draw_rectangle (drawable, style->black_gc, FALSE, - item_x, item_y, MAX (item_w - 1, 0), item_h - 1); - -#if 0 - /* Draw the horizontal bars above and beneath the event if it - is currently being edited. */ - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) { - gdk_draw_rectangle (drawable, gc, TRUE, - item_x, - item_y - E_DAY_VIEW_BAR_HEIGHT, - item_w, - E_DAY_VIEW_BAR_HEIGHT); - gdk_draw_rectangle (drawable, gc, TRUE, - item_x, item_y + item_h, - item_w, E_DAY_VIEW_BAR_HEIGHT); - } -#endif - - /* Draw the reminder & recurrence icons, if needed. */ - num_icons = 0; - draw_reminder_icon = FALSE; - draw_recurrence_icon = FALSE; - icon_x = item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_ICON_X_PAD; - icon_y = item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT - + E_DAY_VIEW_ICON_Y_PAD; - comp = event->comp; - -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) { - draw_reminder_icon = TRUE; - num_icons++; - } -#endif - - if (cal_component_has_rrules (comp) - || cal_component_has_rdates (comp)) { - draw_recurrence_icon = TRUE; - num_icons++; - } - - if (num_icons != 0) { - if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD) - * num_icons) { - icon_x_inc = 0; - icon_y_inc = E_DAY_VIEW_ICON_HEIGHT - + E_DAY_VIEW_ICON_Y_PAD; - } else { - icon_x_inc = E_DAY_VIEW_ICON_WIDTH - + E_DAY_VIEW_ICON_X_PAD; - icon_y_inc = 0; - } - - if (draw_reminder_icon) { - max_icon_w = item_x + item_w - icon_x - - E_DAY_VIEW_EVENT_BORDER_WIDTH; - max_icon_h = item_y + item_h - icon_y - - E_DAY_VIEW_EVENT_BORDER_HEIGHT; - - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->reminder_mask); - gdk_draw_pixmap (drawable, gc, - day_view->reminder_icon, - 0, 0, icon_x, icon_y, - MIN (E_DAY_VIEW_ICON_WIDTH, - max_icon_w), - MIN (E_DAY_VIEW_ICON_HEIGHT, - max_icon_h)); - icon_x += icon_x_inc; - icon_y += icon_y_inc; - } - - if (draw_recurrence_icon) { - max_icon_w = item_x + item_w - icon_x - - E_DAY_VIEW_EVENT_BORDER_WIDTH; - max_icon_h = item_y + item_h - icon_y - - E_DAY_VIEW_EVENT_BORDER_HEIGHT; - - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->recurrence_mask); - gdk_draw_pixmap (drawable, gc, - day_view->recurrence_icon, - 0, 0, icon_x, icon_y, - MIN (E_DAY_VIEW_ICON_WIDTH, - max_icon_w), - MIN (E_DAY_VIEW_ICON_HEIGHT, - max_icon_h)); - } - gdk_gc_set_clip_mask (gc, NULL); - } -} - - -/* This is supposed to return the nearest item to the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_day_view_main_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_day_view_main_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EDayViewMainItem *dvtitem; - - dvtitem = E_DAY_VIEW_MAIN_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - - case GDK_BUTTON_RELEASE: - - case GDK_MOTION_NOTIFY: - - default: - break; - } - - return FALSE; -} - - diff --git a/calendar/gui/e-day-view-main-item.h b/calendar/gui/e-day-view-main-item.h deleted file mode 100644 index d8305e594d..0000000000 --- a/calendar/gui/e-day-view-main-item.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_DAY_VIEW_MAIN_ITEM_H_ -#define _E_DAY_VIEW_MAIN_ITEM_H_ - -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayViewMainItem - canvas item which displays most of the appointment - * data in the main Day/Work Week display. - */ - -#define E_DAY_VIEW_MAIN_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_day_view_main_item_get_type (), EDayViewMainItem)) -#define E_DAY_VIEW_MAIN_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_day_view_main_item_get_type ())) -#define E_IS_DAY_VIEW_MAIN_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_day_view_main_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EDayView widget. */ - EDayView *day_view; -} EDayViewMainItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EDayViewMainItemClass; - - -GtkType e_day_view_main_item_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_MAIN_ITEM_H_ */ diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c deleted file mode 100644 index c2dcf55727..0000000000 --- a/calendar/gui/e-day-view-time-item.c +++ /dev/null @@ -1,531 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EDayViewTimeItem - canvas item which displays the times down the left of - * the EDayView. - */ - -#include <config.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkradiomenuitem.h> -#include "e-day-view-time-item.h" -#include "../../e-util/e-gui-utils.h" - - -/* The spacing between items in the time column. GRID_X_PAD is the space down - either side of the column, i.e. outside the main horizontal grid lines. - HOUR_L_PAD & HOUR_R_PAD are the spaces on the left & right side of the - big hour number (this is inside the horizontal grid lines). - MIN_X_PAD is the spacing either side of the minute number. The smaller - horizontal grid lines match with this. - 60_MIN_X_PAD is the space either side of the HH:MM display used when - we are displaying 60 mins per row (inside the main grid lines). */ -#define E_DVTMI_TIME_GRID_X_PAD 4 -#define E_DVTMI_HOUR_L_PAD 4 -#define E_DVTMI_HOUR_R_PAD 2 -#define E_DVTMI_MIN_X_PAD 2 -#define E_DVTMI_60_MIN_X_PAD 4 - - -static void e_day_view_time_item_class_init (EDayViewTimeItemClass *class); -static void e_day_view_time_item_init (EDayViewTimeItem *dvtmitem); -static void e_day_view_time_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); - -static void e_day_view_time_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, int flags); -static void e_day_view_time_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, int y, - int width, int height); -static double e_day_view_time_item_point (GnomeCanvasItem *item, - double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item); -static gint e_day_view_time_item_event (GnomeCanvasItem *item, - GdkEvent *event); -static void e_day_view_time_item_show_popup_menu (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static void e_day_view_time_item_on_set_divisions (GtkWidget *item, - EDayViewTimeItem *dvtmitem); -static void e_day_view_time_item_on_button_press (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static void e_day_view_time_item_on_button_release (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static void e_day_view_time_item_on_motion_notify (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static gint e_day_view_time_item_convert_position_to_row (EDayViewTimeItem *dvtmitem, - gint y); - - -static GnomeCanvasItemClass *parent_class; - - -/* The arguments we take */ -enum { - ARG_0, - ARG_DAY_VIEW -}; - - -GtkType -e_day_view_time_item_get_type (void) -{ - static GtkType e_day_view_time_item_type = 0; - - if (!e_day_view_time_item_type) { - GtkTypeInfo e_day_view_time_item_info = { - "EDayViewTimeItem", - sizeof (EDayViewTimeItem), - sizeof (EDayViewTimeItemClass), - (GtkClassInitFunc) e_day_view_time_item_class_init, - (GtkObjectInitFunc) e_day_view_time_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_day_view_time_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_day_view_time_item_info); - } - - return e_day_view_time_item_type; -} - - -static void -e_day_view_time_item_class_init (EDayViewTimeItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EDayViewTimeItem::day_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_DAY_VIEW); - - object_class->set_arg = e_day_view_time_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_day_view_time_item_update; - item_class->draw = e_day_view_time_item_draw; - item_class->point = e_day_view_time_item_point; - item_class->event = e_day_view_time_item_event; -} - - -static void -e_day_view_time_item_init (EDayViewTimeItem *dvtmitem) -{ - dvtmitem->dragging_selection = FALSE; -} - - -static void -e_day_view_time_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EDayViewTimeItem *dvtmitem; - - item = GNOME_CANVAS_ITEM (o); - dvtmitem = E_DAY_VIEW_TIME_ITEM (o); - - switch (arg_id){ - case ARG_DAY_VIEW: - dvtmitem->day_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_day_view_time_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* Returns the minimum width needed for the column, by adding up all the - maximum widths of the strings. The string widths are all calculated in - the style_set handlers of EDayView and EDayViewTimeCanvas. */ -gint -e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem) -{ - EDayView *day_view; - - day_view = dvtmitem->day_view; - g_return_val_if_fail (day_view != NULL, 0); - - /* Calculate the width of each time column. */ - if (day_view->mins_per_row == 60) { - dvtmitem->column_width = day_view->max_small_hour_width - + day_view->colon_width - + day_view->max_minute_width - + E_DVTMI_60_MIN_X_PAD * 2 - + E_DVTMI_TIME_GRID_X_PAD * 2; - } else { - dvtmitem->column_width = day_view->max_large_hour_width - + day_view->max_minute_width - + E_DVTMI_MIN_X_PAD * 2 - + E_DVTMI_HOUR_L_PAD - + E_DVTMI_HOUR_R_PAD - + E_DVTMI_TIME_GRID_X_PAD * 2; - } - - return dvtmitem->column_width; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EDayView *day_view; - EDayViewTimeItem *dvtmitem; - gint time_hour_x1, time_hour_x2, time_min_x1; - gint hour, minute, hour_y, min_y, hour_r, min_r, start_y; - gint row, row_y, min_width, hour_width; - GtkStyle *style; - GdkFont *small_font, *large_font; - GdkGC *fg_gc, *dark_gc; - gchar buffer[16]; - - dvtmitem = E_DAY_VIEW_TIME_ITEM (canvas_item); - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - style = GTK_WIDGET (day_view)->style; - small_font = style->font; - large_font = day_view->large_font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - - /* Step through each row, drawing the horizontal grid lines for each - day column and the times. */ - time_hour_x1 = E_DVTMI_TIME_GRID_X_PAD - x; - time_hour_x2 = dvtmitem->column_width - E_DVTMI_TIME_GRID_X_PAD - x; - if (day_view->mins_per_row == 60) { - min_r = time_hour_x2 - E_DVTMI_60_MIN_X_PAD; - } else { - time_min_x1 = time_hour_x2 - E_DVTMI_MIN_X_PAD * 2 - - day_view->max_minute_width; - hour_r = time_min_x1 - E_DVTMI_HOUR_R_PAD; - min_r = time_hour_x2 - E_DVTMI_MIN_X_PAD; - } - - hour = day_view->first_hour_shown; - hour_y = large_font->ascent + 2; /* FIXME */ - minute = day_view->first_minute_shown; - min_y = small_font->ascent + 2; /* FIXME */ - start_y = 0 - MAX (day_view->row_height, hour_y + large_font->descent); - for (row = 0, row_y = 0 - y; - row < day_view->rows && row_y < height; - row++, row_y += day_view->row_height) { - if (row_y > start_y) { - /* Draw the times down the left if needed. */ - if (min_r <= 0) - continue; - - if (day_view->mins_per_row == 60) { - gdk_draw_line (drawable, dark_gc, - time_hour_x1, row_y, - time_hour_x2, row_y); - sprintf (buffer, "%02i:%02i", hour, minute); - min_width = day_view->small_hour_widths[hour] + day_view->minute_widths[minute / 5] + day_view->colon_width; - gdk_draw_string (drawable, small_font, fg_gc, - min_r - min_width, - row_y + min_y, buffer); - } else { - if (minute == 0) { - gdk_draw_line (drawable, dark_gc, - time_hour_x1, row_y, - time_hour_x2, row_y); - sprintf (buffer, "%02i", hour); - hour_width = day_view->large_hour_widths[hour]; - gdk_draw_string (drawable, large_font, - fg_gc, - hour_r - hour_width, - row_y + hour_y, - buffer); - } else { - gdk_draw_line (drawable, dark_gc, - time_min_x1, row_y, - time_hour_x2, row_y); - } - - if (day_view->mins_per_row != 30 - || minute != 30) { - sprintf (buffer, "%02i", minute); - min_width = day_view->minute_widths[minute / 5]; - gdk_draw_string (drawable, small_font, - fg_gc, - min_r - min_width, - row_y + min_y, - buffer); - } - } - } - - minute += day_view->mins_per_row; - if (minute >= 60) { - hour++; - minute -= 60; - } - } -} - - -static double -e_day_view_time_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_day_view_time_item_event (GnomeCanvasItem *item, - GdkEvent *event) -{ - EDayViewTimeItem *dvtmitem; - - dvtmitem = E_DAY_VIEW_TIME_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - e_day_view_time_item_on_button_press (dvtmitem, event); - } else if (event->button.button == 3) { - e_day_view_time_item_show_popup_menu (dvtmitem, event); - return TRUE; - } - break; - case GDK_BUTTON_RELEASE: - if (event->button.button == 1) - e_day_view_time_item_on_button_release (dvtmitem, - event); - break; - - case GDK_MOTION_NOTIFY: - e_day_view_time_item_on_motion_notify (dvtmitem, event); - break; - - default: - break; - } - - return FALSE; -} - - -static void -e_day_view_time_item_show_popup_menu (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - static gint divisions[] = { 60, 30, 15, 10, 5 }; - EDayView *day_view; - gint num_divisions = sizeof (divisions) / sizeof (divisions[0]); - GtkWidget *menu, *item; - gchar buffer[256]; - GSList *group = NULL; - gint current_divisions, i; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - current_divisions = e_day_view_get_mins_per_row (day_view); - - menu = gtk_menu_new (); - - /* Make sure the menu is destroyed when it disappears. */ - e_auto_kill_popup_menu_on_hide (GTK_MENU (menu)); - - for (i = 0; i < num_divisions; i++) { - sprintf (buffer, _("%02i minute divisions"), divisions[i]); - item = gtk_radio_menu_item_new_with_label (group, buffer); - group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (item)); - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - - if (current_divisions == divisions[i]) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - - gtk_object_set_data (GTK_OBJECT (item), "divisions", - GINT_TO_POINTER (divisions[i])); - - gtk_signal_connect (GTK_OBJECT (item), "toggled", - e_day_view_time_item_on_set_divisions, - dvtmitem); - } - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, - event->button.button, event->button.time); -} - - -static void -e_day_view_time_item_on_set_divisions (GtkWidget *item, - EDayViewTimeItem *dvtmitem) -{ - EDayView *day_view; - gint divisions; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - if (!GTK_CHECK_MENU_ITEM (item)->active) - return; - - divisions = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), - "divisions")); - e_day_view_set_mins_per_row (day_view, divisions); -} - - -static void -e_day_view_time_item_on_button_press (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - EDayView *day_view; - GnomeCanvas *canvas; - gint row; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - canvas = GNOME_CANVAS_ITEM (dvtmitem)->canvas; - - row = e_day_view_time_item_convert_position_to_row (dvtmitem, - event->button.y); - - if (row == -1) - return; - - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (canvas)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->button.time) == 0) { - e_day_view_start_selection (day_view, -1, row); - dvtmitem->dragging_selection = TRUE; - } -} - - -static void -e_day_view_time_item_on_button_release (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - EDayView *day_view; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - if (dvtmitem->dragging_selection) { - gdk_pointer_ungrab (event->button.time); - e_day_view_finish_selection (day_view); - e_day_view_stop_auto_scroll (day_view); - } - - dvtmitem->dragging_selection = FALSE; -} - - -static void -e_day_view_time_item_on_motion_notify (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - EDayView *day_view; - GnomeCanvas *canvas; - gdouble window_y; - gint y, row; - - if (!dvtmitem->dragging_selection) - return; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - canvas = GNOME_CANVAS_ITEM (dvtmitem)->canvas; - - y = event->motion.y; - row = e_day_view_time_item_convert_position_to_row (dvtmitem, y); - - if (row != -1) { - gnome_canvas_world_to_window (canvas, 0, event->motion.y, - NULL, &window_y); - e_day_view_update_selection (day_view, -1, row); - e_day_view_check_auto_scroll (day_view, -1, (gint) window_y); - } -} - - -/* Returns the row corresponding to the y position, or -1. */ -static gint -e_day_view_time_item_convert_position_to_row (EDayViewTimeItem *dvtmitem, - gint y) -{ - EDayView *day_view; - gint row; - - day_view = dvtmitem->day_view; - g_return_val_if_fail (day_view != NULL, -1); - - if (y < 0) - return -1; - - row = y / day_view->row_height; - if (row >= day_view->rows) - return -1; - - return row; -} diff --git a/calendar/gui/e-day-view-time-item.h b/calendar/gui/e-day-view-time-item.h deleted file mode 100644 index 8b20fe999e..0000000000 --- a/calendar/gui/e-day-view-time-item.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_DAY_VIEW_TIME_ITEM_H_ -#define _E_DAY_VIEW_TIME_ITEM_H_ - -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayViewTimeItem - canvas item which displays the times down the left of - * the EDayView. - */ - -#define E_DAY_VIEW_TIME_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_day_view_time_item_get_type (), EDayViewTimeItem)) -#define E_DAY_VIEW_TIME_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_day_view_time_item_get_type ())) -#define E_IS_DAY_VIEW_TIME_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_day_view_time_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EDayView widget. */ - EDayView *day_view; - - /* The width of the time column. */ - gint column_width; - - /* TRUE if we are currently dragging the selection times. */ - gboolean dragging_selection; -} EDayViewTimeItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EDayViewTimeItemClass; - - -GtkType e_day_view_time_item_get_type (void); - - -gint e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_TIME_ITEM_H_ */ diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c deleted file mode 100644 index 88e30885ca..0000000000 --- a/calendar/gui/e-day-view-top-item.c +++ /dev/null @@ -1,586 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EDayViewTopItem - displays the top part of the Day/Work Week calendar view. - */ - -#include <config.h> -#include "e-day-view-top-item.h" - -static void e_day_view_top_item_class_init (EDayViewTopItemClass *class); -static void e_day_view_top_item_init (EDayViewTopItem *dvtitem); - -static void e_day_view_top_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_day_view_top_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_day_view_top_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, - gint event_num, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h); -static double e_day_view_top_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); -static gint e_day_view_top_item_event (GnomeCanvasItem *item, - GdkEvent *event); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_DAY_VIEW -}; - - -GtkType -e_day_view_top_item_get_type (void) -{ - static GtkType e_day_view_top_item_type = 0; - - if (!e_day_view_top_item_type) { - GtkTypeInfo e_day_view_top_item_info = { - "EDayViewTopItem", - sizeof (EDayViewTopItem), - sizeof (EDayViewTopItemClass), - (GtkClassInitFunc) e_day_view_top_item_class_init, - (GtkObjectInitFunc) e_day_view_top_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_day_view_top_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_day_view_top_item_info); - } - - return e_day_view_top_item_type; -} - - -static void -e_day_view_top_item_class_init (EDayViewTopItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EDayViewTopItem::day_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_DAY_VIEW); - - object_class->set_arg = e_day_view_top_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_day_view_top_item_update; - item_class->draw = e_day_view_top_item_draw; - item_class->point = e_day_view_top_item_point; - item_class->event = e_day_view_top_item_event; -} - - -static void -e_day_view_top_item_init (EDayViewTopItem *dvtitem) -{ - dvtitem->day_view = NULL; -} - - -static void -e_day_view_top_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EDayViewTopItem *dvtitem; - - item = GNOME_CANVAS_ITEM (o); - dvtitem = E_DAY_VIEW_TOP_ITEM (o); - - switch (arg_id){ - case ARG_DAY_VIEW: - dvtitem->day_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_day_view_top_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_day_view_top_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EDayViewTopItem *dvtitem; - EDayView *day_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc; - gchar buffer[128]; - GdkRectangle clip_rect; - GdkFont *font; - gint canvas_width, canvas_height, left_edge, day, date_width, date_x; - gint item_height, event_num; - struct tm *day_start; - -#if 0 - g_print ("In e_day_view_top_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - dvtitem = E_DAY_VIEW_TOP_ITEM (canvas_item); - day_view = dvtitem->day_view; - g_return_if_fail (day_view != NULL); - - style = GTK_WIDGET (day_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - canvas_width = GTK_WIDGET (canvas_item->canvas)->allocation.width; - canvas_height = GTK_WIDGET (canvas_item->canvas)->allocation.height; - left_edge = 0; - item_height = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP; - - /* Clear the entire background. */ - gdk_draw_rectangle (drawable, dark_gc, TRUE, - left_edge - x, 0, - canvas_width - left_edge, height); - - /* Draw the shadow around the dates. */ - gdk_draw_line (drawable, light_gc, - left_edge + 1 - x, 1 - y, - canvas_width - 2 - x, 1 - y); - gdk_draw_line (drawable, light_gc, - left_edge + 1 - x, 2 - y, - left_edge + 1 - x, item_height - 1 - y); - - /* Draw the background for the dates. */ - gdk_draw_rectangle (drawable, bg_gc, TRUE, - left_edge + 2 - x, 2 - y, - canvas_width - left_edge - 3, - item_height - 3); - - /* Draw the selection background. */ - if (GTK_WIDGET_HAS_FOCUS (day_view) - && day_view->selection_start_day != -1) { - gint start_col, end_col, rect_x, rect_y, rect_w, rect_h; - - start_col = day_view->selection_start_day; - end_col = day_view->selection_end_day; - - if (end_col > start_col - || day_view->selection_start_row == -1 - || day_view->selection_end_row == -1) { - rect_x = day_view->day_offsets[start_col]; - rect_y = item_height; - rect_w = day_view->day_offsets[end_col + 1] - rect_x; - rect_h = canvas_height - 1 - rect_y; - - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - rect_x - x, rect_y - y, - rect_w, rect_h); - } - } - - /* Draw the date. Set a clipping rectangle so we don't draw over the - next day. */ - for (day = 0; day < day_view->days_shown; day++) { - day_start = localtime (&day_view->day_starts[day]); - - if (day_view->date_format == E_DAY_VIEW_DATE_FULL) - strftime (buffer, 128, "%d %B", day_start); - else if (day_view->date_format == E_DAY_VIEW_DATE_ABBREVIATED) - strftime (buffer, 128, "%d %b", day_start); - else - strftime (buffer, 128, "%d", day_start); - - clip_rect.x = day_view->day_offsets[day] - x; - clip_rect.y = 2 - y; - clip_rect.width = day_view->day_widths[day]; - clip_rect.height = item_height - 2; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - date_width = gdk_string_width (font, buffer); - date_x = day_view->day_offsets[day] + (day_view->day_widths[day] - date_width) / 2; - gdk_draw_string (drawable, font, fg_gc, - date_x - x, 3 + font->ascent - y, buffer); - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - /* Draw the lines down the left and right of the date cols. */ - if (day != 0) { - gdk_draw_line (drawable, light_gc, - day_view->day_offsets[day] - x, - 4 - y, - day_view->day_offsets[day] - x, - item_height - 4 - y); - - gdk_draw_line (drawable, dark_gc, - day_view->day_offsets[day] - 1 - x, - 4 - y, - day_view->day_offsets[day] - 1 - x, - item_height - 4 - y); - } - - /* Draw the lines between each column. */ - if (day != 0) { - gdk_draw_line (drawable, style->black_gc, - day_view->day_offsets[day] - x, - item_height - y, - day_view->day_offsets[day] - x, - canvas_height - y); - } - } - - /* Draw the long events. */ - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - e_day_view_top_item_draw_long_event (dvtitem, event_num, - drawable, - x, y, width, height); - } -} - - -/* This draws one event in the top canvas. */ -static void -e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, - gint event_num, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EDayView *day_view; - EDayViewEvent *event; - GtkStyle *style; - GdkGC *gc, *fg_gc, *bg_gc; - GdkFont *font; - gint start_day, end_day; - gint item_x, item_y, item_w, item_h; - gint text_x, icon_x, icon_y, icon_x_inc; - CalComponent *comp; - gchar buffer[16]; - gint hour, minute, offset, time_width, time_x, min_end_time_x; - gboolean draw_start_triangle, draw_end_triangle; - GdkRectangle clip_rect; - - day_view = dvtitem->day_view; - - /* If the event is currently being dragged, don't draw it. It will - be drawn in the special drag items. */ - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->drag_event_num == event_num) - return; - - if (!e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) - return; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - style = GTK_WIDGET (day_view)->style; - font = style->font; - gc = day_view->main_gc; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - comp = event->comp; - - /* Draw the lines across the top & bottom of the entire event. */ - gdk_draw_line (drawable, fg_gc, - item_x - x, item_y - y, - item_x + item_w - 1 - x, item_y - y); - gdk_draw_line (drawable, fg_gc, - item_x - x, item_y + item_h - 1 - y, - item_x + item_w - 1 - x, item_y + item_h - 1 - y); - - /* Fill it in. */ - gdk_draw_rectangle (drawable, bg_gc, TRUE, - item_x - x, item_y + 1 - y, - item_w, item_h - 2); - - /* When resizing we don't draw the triangles.*/ - draw_start_triangle = TRUE; - draw_end_triangle = TRUE; - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) - draw_start_triangle = FALSE; - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_RIGHT_EDGE) - draw_end_triangle = FALSE; - } - - /* If the event starts before the first day shown, draw a triangle, - else just draw a vertical line down the left. */ - if (draw_start_triangle - && event->start < day_view->day_starts[start_day]) { - e_day_view_top_item_draw_triangle (dvtitem, drawable, - item_x - x, item_y - y, - -E_DAY_VIEW_BAR_WIDTH, - item_h); - } else { - gdk_draw_line (drawable, fg_gc, - item_x - x, item_y - y, - item_x - x, item_y + item_h - 1 - y); - } - - /* Similar for the event end. */ - if (draw_end_triangle - && event->end > day_view->day_starts[end_day + 1]) { - e_day_view_top_item_draw_triangle (dvtitem, drawable, - item_x + item_w - 1 - x, - item_y - y, - E_DAY_VIEW_BAR_WIDTH, - item_h); - } else { - gdk_draw_line (drawable, fg_gc, - item_x + item_w - 1 - x, - item_y - y, - item_x + item_w - 1 - x, - item_y + item_h - 1 - y); - } - - /* If we are editing the event we don't show the icons or the start - & end times. */ - if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->editing_event_num == event_num) - return; - - /* Determine the position of the label, so we know where to place the - icons. Note that since the top canvas never scrolls we don't need - to take the scroll offset into account. It will always be 0. */ - text_x = event->canvas_item->x1; - - /* Draw the icons. */ - icon_x_inc = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD; - icon_x = text_x - icon_x_inc - x; - icon_y = item_y + 1 + E_DAY_VIEW_ICON_Y_PAD - y; - - if (cal_component_has_rrules (comp) - || cal_component_has_rdates (comp)) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->recurrence_mask); - gdk_draw_pixmap (drawable, gc, - day_view->recurrence_icon, - 0, 0, icon_x, icon_y, - E_DAY_VIEW_ICON_WIDTH, - E_DAY_VIEW_ICON_HEIGHT); - icon_x -= icon_x_inc; - } - -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->reminder_mask); - gdk_draw_pixmap (drawable, gc, - day_view->reminder_icon, - 0, 0, icon_x, icon_y, - E_DAY_VIEW_ICON_WIDTH, - E_DAY_VIEW_ICON_HEIGHT); - icon_x -= icon_x_inc; - } - gdk_gc_set_clip_mask (gc, NULL); -#endif - - /* Draw the start & end times, if necessary. - Note that GtkLabel adds 1 to the ascent so we must do that to be - level with it. */ - min_end_time_x = item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x; - - if (event->start > day_view->day_starts[start_day]) { - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown + event->start_minute; - hour = offset / 60; - minute = offset % 60; - sprintf (buffer, "%02i:%02i", hour, minute); - - clip_rect.x = item_x - x; - clip_rect.y = item_y - y; - clip_rect.width = item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH; - clip_rect.height = item_h; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - gdk_draw_string (drawable, font, fg_gc, - item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x, - item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD + font->ascent + 1 - y, - buffer); - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - min_end_time_x += day_view->small_hour_widths[hour] + 2 - + day_view->max_minute_width + day_view->colon_width; - } - - if (event->end < day_view->day_starts[end_day + 1]) { - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown - + event->end_minute; - hour = offset / 60; - minute = offset % 60; - time_width = day_view->small_hour_widths[hour] - + day_view->max_minute_width + day_view->colon_width; - time_x = item_x + item_w - E_DAY_VIEW_LONG_EVENT_X_PAD - time_width - E_DAY_VIEW_LONG_EVENT_TIME_X_PAD - x; - - if (time_x >= min_end_time_x) { - sprintf (buffer, "%02i:%02i", hour, minute); - gdk_draw_string (drawable, font, fg_gc, - time_x, - item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD - + font->ascent + 1 - y, - buffer); - } - } -} - - -/* This draws a little triangle to indicate that an event extends past - the days visible on screen. */ -static void -e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h) -{ - EDayView *day_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc; - GdkPoint points[3]; - gint c1, c2; - - day_view = dvtitem->day_view; - - style = GTK_WIDGET (day_view)->style; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - - points[0].x = x; - points[0].y = y; - points[1].x = x + w; - points[1].y = y + (h / 2) - 1; - points[2].x = x; - points[2].y = y + h - 1; - - /* If the height is odd we can use the same central point for both - lines. If it is even we use different end-points. */ - c1 = c2 = y + (h / 2); - if (h % 2 == 0) - c1--; - - gdk_draw_polygon (drawable, bg_gc, TRUE, points, 3); - gdk_draw_line (drawable, fg_gc, x, y, x + w, c1); - gdk_draw_line (drawable, fg_gc, x, y + h - 1, x + w, c2); -} - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_day_view_top_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_day_view_top_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EDayViewTopItem *dvtitem; - - dvtitem = E_DAY_VIEW_TOP_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - - case GDK_BUTTON_RELEASE: - - case GDK_MOTION_NOTIFY: - - default: - break; - } - - return FALSE; -} - - diff --git a/calendar/gui/e-day-view-top-item.h b/calendar/gui/e-day-view-top-item.h deleted file mode 100644 index 435ef12b58..0000000000 --- a/calendar/gui/e-day-view-top-item.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_DAY_VIEW_TOP_ITEM_H_ -#define _E_DAY_VIEW_TOP_ITEM_H_ - -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayViewTopItem - displays the top part of the Day/Work Week calendar view. - */ - -#define E_DAY_VIEW_TOP_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_day_view_top_item_get_type (), EDayViewTopItem)) -#define E_DAY_VIEW_TOP_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_day_view_top_item_get_type ())) -#define E_IS_DAY_VIEW_TOP_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_day_view_top_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EDayView widget. */ - EDayView *day_view; -} EDayViewTopItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EDayViewTopItemClass; - - -GtkType e_day_view_top_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_TOP_ITEM_H_ */ diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c deleted file mode 100644 index c14da5f58f..0000000000 --- a/calendar/gui/e-day-view.c +++ /dev/null @@ -1,5716 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EDayView - displays the Day & Work-Week views of the calendar. - */ - -#include <config.h> -#include <math.h> -#include <time.h> -#include <gnome.h> -#include <gdk/gdkx.h> -#include <cal-util/timeutil.h> -#include "e-day-view.h" -#include "e-day-view-time-item.h" -#include "e-day-view-top-item.h" -#include "e-day-view-main-item.h" -#include "calendar-commands.h" -#include "popup-menu.h" -#include "../e-util/e-canvas.h" -#include "../widgets/e-text/e-text.h" -#include "e-util/e-canvas-utils.h" - -/* Images */ -#include "bell.xpm" -#include "recur.xpm" - -/* The minimum amount of space wanted on each side of the date string. */ -#define E_DAY_VIEW_DATE_X_PAD 4 - -#define E_DAY_VIEW_LARGE_FONT \ - "-adobe-utopia-regular-r-normal-*-*-240-*-*-p-*-iso8859-*" -#define E_DAY_VIEW_LARGE_FONT_FALLBACK \ - "-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-iso8859-*" - -/* The offset from the top/bottom of the canvas before auto-scrolling starts.*/ -#define E_DAY_VIEW_AUTO_SCROLL_OFFSET 16 - -/* The time between each auto-scroll, in milliseconds. */ -#define E_DAY_VIEW_AUTO_SCROLL_TIMEOUT 50 - -/* The number of timeouts we skip before we start scrolling. */ -#define E_DAY_VIEW_AUTO_SCROLL_DELAY 5 - -/* The number of pixels the mouse has to be moved with the button down before - we start a drag. */ -#define E_DAY_VIEW_DRAG_START_OFFSET 4 - -/* Drag and Drop stuff. */ -enum { - TARGET_CALENDAR_EVENT -}; -static GtkTargetEntry target_table[] = { - { "application/x-e-calendar-event", 0, TARGET_CALENDAR_EVENT } -}; -static guint n_targets = sizeof(target_table) / sizeof(target_table[0]); - -static void e_day_view_class_init (EDayViewClass *class); -static void e_day_view_init (EDayView *day_view); -static void e_day_view_destroy (GtkObject *object); -static void e_day_view_realize (GtkWidget *widget); -static void e_day_view_unrealize (GtkWidget *widget); -static void e_day_view_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void e_day_view_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean e_day_view_update_scroll_regions (EDayView *day_view); -static gint e_day_view_focus_in (GtkWidget *widget, - GdkEventFocus *event); -static gint e_day_view_focus_out (GtkWidget *widget, - GdkEventFocus *event); -static gint e_day_view_key_press (GtkWidget *widget, - GdkEventKey *event); -static void e_day_view_cursor_key_up_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_down_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_left_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_right_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_up (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_down (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_left (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_right (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_ensure_rows_visible (EDayView *day_view, - gint start_row, - gint end_row); - -static gboolean e_day_view_check_if_new_event_fits (EDayView *day_view); - -static void e_day_view_on_canvas_realized (GtkWidget *widget, - EDayView *day_view); - -static gboolean e_day_view_on_top_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); -static gboolean e_day_view_on_top_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); -static gboolean e_day_view_on_top_canvas_motion (GtkWidget *widget, - GdkEventMotion *event, - EDayView *day_view); - -static gboolean e_day_view_on_main_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); -static gboolean e_day_view_on_main_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); - -static gboolean e_day_view_on_time_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); - -static void e_day_view_update_calendar_selection_time (EDayView *day_view); -static gboolean e_day_view_on_main_canvas_motion (GtkWidget *widget, - GdkEventMotion *event, - EDayView *day_view); -static gboolean e_day_view_convert_event_coords (EDayView *day_view, - GdkEvent *event, - GdkWindow *window, - gint *x_return, - gint *y_return); -static void e_day_view_update_long_event_resize (EDayView *day_view, - gint day); -static void e_day_view_update_resize (EDayView *day_view, - gint row); -static void e_day_view_finish_long_event_resize (EDayView *day_view); -static void e_day_view_finish_resize (EDayView *day_view); -static void e_day_view_abort_resize (EDayView *day_view, - guint32 time); - - -static gboolean e_day_view_on_long_event_button_press (EDayView *day_view, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y); -static gboolean e_day_view_on_event_button_press (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y); -static void e_day_view_on_long_event_click (EDayView *day_view, - gint event_num, - GdkEventButton *bevent, - EDayViewPosition pos, - gint event_x, - gint event_y); -static void e_day_view_on_event_click (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y); -static void e_day_view_on_event_double_click (EDayView *day_view, - gint day, - gint event_num); -static void e_day_view_on_event_right_click (EDayView *day_view, - GdkEventButton *bevent, - gint day, - gint event_num); - -static void e_day_view_recalc_day_starts (EDayView *day_view, - time_t start_time); -static void e_day_view_recalc_num_rows (EDayView *day_view); - -static EDayViewPosition e_day_view_convert_position_in_top_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *event_num_return); -static EDayViewPosition e_day_view_convert_position_in_main_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *row_return, - gint *event_num_return); -static gboolean e_day_view_find_event_from_item (EDayView *day_view, - GnomeCanvasItem *item, - gint *day_return, - gint *event_num_return); -static gboolean e_day_view_find_event_from_uid (EDayView *day_view, - const gchar *uid, - gint *day_return, - gint *event_num_return); - -typedef gboolean (* EDayViewForeachEventCallback) (EDayView *day_view, - gint day, - gint event_num, - gpointer data); - -static void e_day_view_foreach_event_with_uid (EDayView *day_view, - const gchar *uid, - EDayViewForeachEventCallback callback, - gpointer data); - -static void e_day_view_reload_events (EDayView *day_view); -static void e_day_view_free_events (EDayView *day_view); -static void e_day_view_free_event_array (EDayView *day_view, - GArray *array); -static int e_day_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data); -static void e_day_view_update_event_label (EDayView *day_view, - gint day, - gint event_num); -static void e_day_view_update_long_event_label (EDayView *day_view, - gint event_num); - -static void e_day_view_layout_long_events (EDayView *day_view); -static void e_day_view_layout_long_event (EDayView *day_view, - EDayViewEvent *event, - guint8 *grid); -static void e_day_view_reshape_long_events (EDayView *day_view); -static void e_day_view_reshape_long_event (EDayView *day_view, - gint event_num); -static void e_day_view_layout_day_events (EDayView *day_view, - gint day); -static void e_day_view_layout_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid, - guint16 *group_starts); -static void e_day_view_expand_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid); -static void e_day_view_recalc_cols_per_row (EDayView *day_view, - gint day, - guint16 *group_starts); -static void e_day_view_reshape_day_events (EDayView *day_view, - gint day); -static void e_day_view_reshape_day_event (EDayView *day_view, - gint day, - gint event_num); -static void e_day_view_reshape_main_canvas_resize_bars (EDayView *day_view); -static void e_day_view_reshape_resize_long_event_rect_item (EDayView *day_view); -static void e_day_view_reshape_resize_rect_item (EDayView *day_view); - -static void e_day_view_ensure_events_sorted (EDayView *day_view); -static gint e_day_view_event_sort_func (const void *arg1, - const void *arg2); - -static void e_day_view_start_editing_event (EDayView *day_view, - gint day, - gint event_num, - gchar *initial_text); -static void e_day_view_stop_editing_event (EDayView *day_view); -static gboolean e_day_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EDayView *day_view); -static void e_day_view_on_editing_started (EDayView *day_view, - GnomeCanvasItem *item); -static void e_day_view_on_editing_stopped (EDayView *day_view, - GnomeCanvasItem *item); - -static time_t e_day_view_convert_grid_position_to_time (EDayView *day_view, - gint col, - gint row); -static gboolean e_day_view_convert_time_to_grid_position (EDayView *day_view, - time_t time, - gint *col, - gint *row); - -static void e_day_view_start_auto_scroll (EDayView *day_view, - gboolean scroll_up); -static gboolean e_day_view_auto_scroll_handler (gpointer data); - -static void e_day_view_on_new_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_edit_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_delete_occurrence (GtkWidget *widget, - gpointer data); -static void e_day_view_on_delete_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_unrecur_appointment (GtkWidget *widget, - gpointer data); -static EDayViewEvent* e_day_view_get_popup_menu_event (EDayView *day_view); - -static gint e_day_view_on_top_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view); -static void e_day_view_update_top_canvas_drag (EDayView *day_view, - gint day); -static void e_day_view_reshape_top_canvas_drag_item (EDayView *day_view); -static gint e_day_view_on_main_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view); -static void e_day_view_reshape_main_canvas_drag_item (EDayView *day_view); -static void e_day_view_update_main_canvas_drag (EDayView *day_view, - gint row, - gint day); -static void e_day_view_on_top_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view); -static void e_day_view_on_main_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view); -static void e_day_view_on_drag_begin (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view); -static void e_day_view_on_drag_end (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view); -static void e_day_view_on_drag_data_get (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EDayView *day_view); -static void e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view); -static void e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view); -static gboolean e_day_view_update_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data); -static gboolean e_day_view_remove_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data); -static void e_day_view_normalize_selection (EDayView *day_view); - - -static GtkTableClass *parent_class; - - -GtkType -e_day_view_get_type (void) -{ - static GtkType e_day_view_type = 0; - - if (!e_day_view_type){ - GtkTypeInfo e_day_view_info = { - "EDayView", - sizeof (EDayView), - sizeof (EDayViewClass), - (GtkClassInitFunc) e_day_view_class_init, - (GtkObjectInitFunc) e_day_view_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = gtk_type_class (GTK_TYPE_TABLE); - e_day_view_type = gtk_type_unique (GTK_TYPE_TABLE, - &e_day_view_info); - } - - return e_day_view_type; -} - - -static void -e_day_view_class_init (EDayViewClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - object_class->destroy = e_day_view_destroy; - - widget_class->realize = e_day_view_realize; - widget_class->unrealize = e_day_view_unrealize; - widget_class->style_set = e_day_view_style_set; - widget_class->size_allocate = e_day_view_size_allocate; - widget_class->focus_in_event = e_day_view_focus_in; - widget_class->focus_out_event = e_day_view_focus_out; - widget_class->key_press_event = e_day_view_key_press; -} - - -static void -e_day_view_init (EDayView *day_view) -{ - GdkColormap *colormap; - gboolean success[E_DAY_VIEW_COLOR_LAST]; - gint day, nfailed; - GnomeCanvasGroup *canvas_group; - - GTK_WIDGET_SET_FLAGS (day_view, GTK_CAN_FOCUS); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view)); - - day_view->calendar = NULL; - - day_view->long_events = g_array_new (FALSE, FALSE, - sizeof (EDayViewEvent)); - day_view->long_events_sorted = TRUE; - day_view->long_events_need_layout = FALSE; - day_view->long_events_need_reshape = FALSE; - - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) { - day_view->events[day] = g_array_new (FALSE, FALSE, - sizeof (EDayViewEvent)); - day_view->events_sorted[day] = TRUE; - day_view->need_layout[day] = FALSE; - day_view->need_reshape[day] = FALSE; - } - - /* These indicate that the times haven't been set. */ - day_view->lower = 0; - day_view->upper = 0; - - /* FIXME: Initialize day_starts. */ - day_view->days_shown = 1; - - day_view->mins_per_row = 30; - day_view->date_format = E_DAY_VIEW_DATE_FULL; - day_view->rows_in_top_display = 0; - - /* Note that these don't work yet. It would need a few fixes to the - way event->start_minute and event->end_minute are used, and there - may be problems with events that go outside the visible times. */ - day_view->first_hour_shown = 0; - day_view->first_minute_shown = 0; - day_view->last_hour_shown = 24; - day_view->last_minute_shown = 0; - - day_view->main_gc = NULL; - e_day_view_recalc_num_rows (day_view); - - day_view->work_day_start_hour = 9; - day_view->work_day_start_minute = 0; - day_view->work_day_end_hour = 17; - day_view->work_day_end_minute = 0; - day_view->scroll_to_work_day = TRUE; - - day_view->editing_event_day = -1; - day_view->editing_event_num = -1; - day_view->editing_new_event = FALSE; - - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - - day_view->selection_start_row = -1; - day_view->selection_start_day = -1; - day_view->selection_end_row = -1; - day_view->selection_end_day = -1; - day_view->selection_is_being_dragged = FALSE; - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END; - day_view->selection_in_top_canvas = FALSE; - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - - day_view->pressed_event_day = -1; - - day_view->drag_event_day = -1; - day_view->drag_last_day = -1; - - day_view->auto_scroll_timeout_id = 0; - - /* Create the large font. */ - day_view->large_font = gdk_font_load (E_DAY_VIEW_LARGE_FONT); - if (!day_view->large_font) - day_view->large_font = gdk_font_load (E_DAY_VIEW_LARGE_FONT_FALLBACK); - if (!day_view->large_font) - g_warning ("Couldn't load font"); - - - /* Allocate the colors. */ -#if 1 - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].red = 247 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].green = 247 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].blue = 244 * 257; - - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].red = 216 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].green = 216 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].blue = 214 * 257; -#else - - /* FG: MistyRose1, LightPink3 | RosyBrown | MistyRose3. */ - - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].red = 255 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].green = 228 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].blue = 225 * 257; - - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].red = 238 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].green = 162 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].blue = 173 * 257; -#endif - - day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].red = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].green = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].blue = 65535; - - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].red = 65535; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].green = 65535; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].blue = 65535; - - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].red = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].green = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].blue = 0; - - nfailed = gdk_colormap_alloc_colors (colormap, day_view->colors, - E_DAY_VIEW_COLOR_LAST, FALSE, - TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); - - - - /* - * Top Canvas - */ - day_view->top_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (day_view), day_view->top_canvas, - 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (day_view->top_canvas); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), "button_press_event", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_button_press), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), "button_release_event", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_button_release), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), "motion_notify_event", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), - "drag_motion", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_drag_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), - "drag_leave", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_drag_leave), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_begin", - GTK_SIGNAL_FUNC (e_day_view_on_drag_begin), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_end", - GTK_SIGNAL_FUNC (e_day_view_on_drag_end), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_data_get", - GTK_SIGNAL_FUNC (e_day_view_on_drag_data_get), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_data_received", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_drag_data_received), - day_view); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->top_canvas)->root); - - day_view->top_canvas_item = - gnome_canvas_item_new (canvas_group, - e_day_view_top_item_get_type (), - "EDayViewTopItem::day_view", day_view, - NULL); - - day_view->resize_long_event_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type(), - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - - day_view->drag_long_event_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->drag_long_event_rect_item); - - day_view->drag_long_event_item = - gnome_canvas_item_new (canvas_group, - e_text_get_type (), - "anchor", GTK_ANCHOR_NW, - "line_wrap", TRUE, - "clip", TRUE, - "max_lines", 1, - "editable", TRUE, - NULL); - gnome_canvas_item_hide (day_view->drag_long_event_item); - - /* - * Main Canvas - */ - day_view->main_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (day_view), day_view->main_canvas, - 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (day_view->main_canvas); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), "realize", - GTK_SIGNAL_FUNC (e_day_view_on_canvas_realized), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "button_press_event", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_button_press), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "button_release_event", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_button_release), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "motion_notify_event", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "drag_motion", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_drag_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "drag_leave", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_drag_leave), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_begin", - GTK_SIGNAL_FUNC (e_day_view_on_drag_begin), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_end", - GTK_SIGNAL_FUNC (e_day_view_on_drag_end), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_data_get", - GTK_SIGNAL_FUNC (e_day_view_on_drag_data_get), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_data_received", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_drag_data_received), - day_view); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->main_canvas)->root); - - day_view->main_canvas_item = - gnome_canvas_item_new (canvas_group, - e_day_view_main_item_get_type (), - "EDayViewMainItem::day_view", day_view, - NULL); - - day_view->resize_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type(), - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->resize_rect_item); - - day_view->resize_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type(), - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->resize_bar_item); - - day_view->main_canvas_top_resize_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - - day_view->main_canvas_bottom_resize_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - - - day_view->drag_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->drag_rect_item); - - day_view->drag_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->drag_bar_item); - - day_view->drag_item = - gnome_canvas_item_new (canvas_group, - e_text_get_type (), - "anchor", GTK_ANCHOR_NW, - "line_wrap", TRUE, - "clip", TRUE, - "editable", TRUE, - NULL); - gnome_canvas_item_hide (day_view->drag_item); - - - /* - * Times Canvas - */ - day_view->time_canvas = e_canvas_new (); - gtk_layout_set_vadjustment (GTK_LAYOUT (day_view->time_canvas), - GTK_LAYOUT (day_view->main_canvas)->vadjustment); - gtk_table_attach (GTK_TABLE (day_view), day_view->time_canvas, - 0, 1, 1, 2, - GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (day_view->time_canvas); - gtk_signal_connect_after (GTK_OBJECT (day_view->time_canvas), - "button_press_event", - GTK_SIGNAL_FUNC (e_day_view_on_time_canvas_button_press), - day_view); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->time_canvas)->root); - - day_view->time_canvas_item = - gnome_canvas_item_new (canvas_group, - e_day_view_time_item_get_type (), - "EDayViewTimeItem::day_view", day_view, - NULL); - - - /* - * Scrollbar. - */ - day_view->vscrollbar = gtk_vscrollbar_new (GTK_LAYOUT (day_view->main_canvas)->vadjustment); - gtk_table_attach (GTK_TABLE (day_view), day_view->vscrollbar, - 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (day_view->vscrollbar); - - - /* Create the pixmaps. */ - day_view->reminder_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &day_view->reminder_mask, NULL, bell_xpm); - day_view->recurrence_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &day_view->recurrence_mask, NULL, recur_xpm); - - - /* Create the cursors. */ - day_view->normal_cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW); - day_view->move_cursor = gdk_cursor_new (GDK_FLEUR); - day_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); - day_view->resize_height_cursor = gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW); - day_view->last_cursor_set_in_top_canvas = NULL; - day_view->last_cursor_set_in_main_canvas = NULL; - - /* Set up the drop sites. */ - gtk_drag_dest_set (day_view->top_canvas, - GTK_DEST_DEFAULT_ALL, - target_table, n_targets, - GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_drag_dest_set (day_view->main_canvas, - GTK_DEST_DEFAULT_ALL, - target_table, n_targets, - GDK_ACTION_COPY | GDK_ACTION_MOVE); -} - - -/* Turn off the background of the canvas windows. This reduces flicker - considerably when scrolling. (Why isn't it in GnomeCanvas?). */ -static void -e_day_view_on_canvas_realized (GtkWidget *widget, - EDayView *day_view) -{ - gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window, - NULL, FALSE); -} - - -/** - * e_day_view_new: - * @Returns: a new #EDayView. - * - * Creates a new #EDayView. - **/ -GtkWidget * -e_day_view_new (void) -{ - GtkWidget *day_view; - - day_view = GTK_WIDGET (gtk_type_new (e_day_view_get_type ())); - - return day_view; -} - - -static void -e_day_view_destroy (GtkObject *object) -{ - EDayView *day_view; - gint day; - - day_view = E_DAY_VIEW (object); - - e_day_view_stop_auto_scroll (day_view); - - if (day_view->large_font) - gdk_font_unref (day_view->large_font); - - gdk_cursor_destroy (day_view->normal_cursor); - gdk_cursor_destroy (day_view->move_cursor); - gdk_cursor_destroy (day_view->resize_width_cursor); - gdk_cursor_destroy (day_view->resize_height_cursor); - - e_day_view_free_events (day_view); - g_array_free (day_view->long_events, TRUE); - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - g_array_free (day_view->events[day], TRUE); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -static void -e_day_view_realize (GtkWidget *widget) -{ - EDayView *day_view; - - if (GTK_WIDGET_CLASS (parent_class)->realize) - (*GTK_WIDGET_CLASS (parent_class)->realize)(widget); - - day_view = E_DAY_VIEW (widget); - day_view->main_gc = gdk_gc_new (widget->window); -} - - -static void -e_day_view_unrealize (GtkWidget *widget) -{ - EDayView *day_view; - - day_view = E_DAY_VIEW (widget); - - gdk_gc_unref (day_view->main_gc); - day_view->main_gc = NULL; - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget); -} - - -static void -e_day_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - EDayView *day_view; - GdkFont *font; - gint top_rows, top_canvas_height; - gint month, max_month_width, max_abbr_month_width, number_width; - gint hour, max_large_hour_width, month_width; - gint minute, max_minute_width, i; - GDate date; - gchar buffer[128]; - gint times_width; - - if (GTK_WIDGET_CLASS (parent_class)->style_set) - (*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style); - - day_view = E_DAY_VIEW (widget); - font = widget->style->font; - - /* Recalculate the height of each row based on the font size. */ - day_view->row_height = font->ascent + font->descent + E_DAY_VIEW_EVENT_BORDER_HEIGHT * 2 + E_DAY_VIEW_EVENT_Y_PAD * 2 + 2 /* FIXME */; - day_view->row_height = MAX (day_view->row_height, E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD + 2); - GTK_LAYOUT (day_view->main_canvas)->vadjustment->step_increment = day_view->row_height; - - day_view->top_row_height = font->ascent + font->descent + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT * 2 + E_DAY_VIEW_LONG_EVENT_Y_PAD * 2 + E_DAY_VIEW_TOP_CANVAS_Y_GAP; - day_view->top_row_height = MAX (day_view->top_row_height, E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD + 2 + E_DAY_VIEW_TOP_CANVAS_Y_GAP); - - /* Set the height of the top canvas based on the row height and the - number of rows needed (min 1 + 1 for the dates + 1 space for DnD).*/ - top_rows = MAX (1, day_view->rows_in_top_display); - top_canvas_height = (top_rows + 2) * day_view->top_row_height; - gtk_widget_set_usize (day_view->top_canvas, -1, top_canvas_height); - - /* Find the biggest full month name. */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 20, 1, 2000); - max_month_width = 0; - max_abbr_month_width = 0; - for (month = 1; month <= 12; month++) { - g_date_set_month (&date, month); - - g_date_strftime (buffer, 128, "%B", &date); - month_width = gdk_string_width (font, buffer); - max_month_width = MAX (max_month_width, month_width); - - g_date_strftime (buffer, 128, "%b", &date); - month_width = gdk_string_width (font, buffer); - max_abbr_month_width = MAX (max_abbr_month_width, month_width); - } - number_width = gdk_string_width (font, "31 "); - day_view->long_format_width = number_width + max_month_width - + E_DAY_VIEW_DATE_X_PAD; - day_view->abbreviated_format_width = number_width - + max_abbr_month_width + E_DAY_VIEW_DATE_X_PAD; - - /* Calculate the widths of all the time strings necessary. */ - day_view->max_small_hour_width = 0; - max_large_hour_width = 0; - for (hour = 0; hour < 24; hour++) { - sprintf (buffer, "%02i", hour); - day_view->small_hour_widths[hour] = gdk_string_width (font, buffer); - day_view->large_hour_widths[hour] = gdk_string_width (day_view->large_font, buffer); - day_view->max_small_hour_width = MAX (day_view->max_small_hour_width, day_view->small_hour_widths[hour]); - max_large_hour_width = MAX (max_large_hour_width, day_view->large_hour_widths[hour]); - } - day_view->max_large_hour_width = max_large_hour_width; - - max_minute_width = 0; - for (minute = 0, i = 0; minute < 60; minute += 5, i++) { - sprintf (buffer, "%02i", minute); - day_view->minute_widths[i] = gdk_string_width (font, buffer); - max_minute_width = MAX (max_minute_width, day_view->minute_widths[i]); - } - day_view->max_minute_width = max_minute_width; - day_view->colon_width = gdk_string_width (font, ":"); - - /* Calculate the width of the time column. */ - times_width = e_day_view_time_item_get_column_width (E_DAY_VIEW_TIME_ITEM (day_view->time_canvas_item)); - gtk_widget_set_usize (day_view->time_canvas, times_width, -1); -} - - -/* This recalculates the sizes of each column. */ -static void -e_day_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - EDayView *day_view; - gfloat width, offset; - gint col, day, scroll_y; - gboolean need_reshape; - gdouble old_x2, old_y2, new_x2, new_y2; - -#if 0 - g_print ("In e_day_view_size_allocate\n"); -#endif - day_view = E_DAY_VIEW (widget); - - (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); - - /* Calculate the column sizes, using floating point so that pixels - get divided evenly. Note that we use one more element than the - number of columns, to make it easy to get the column widths. */ - width = day_view->main_canvas->allocation.width; - width /= day_view->days_shown; - offset = 0; - for (col = 0; col <= day_view->days_shown; col++) { - day_view->day_offsets[col] = floor (offset + 0.5); - offset += width; - } - - /* Calculate the days widths based on the offsets. */ - for (col = 0; col < day_view->days_shown; col++) { - day_view->day_widths[col] = day_view->day_offsets[col + 1] - day_view->day_offsets[col]; - } - - /* Determine which date format to use, based on the column widths. */ - if (day_view->day_widths[0] > day_view->long_format_width) - day_view->date_format = E_DAY_VIEW_DATE_FULL; - else if (day_view->day_widths[0] > day_view->abbreviated_format_width) - day_view->date_format = E_DAY_VIEW_DATE_ABBREVIATED; - else - day_view->date_format = E_DAY_VIEW_DATE_SHORT; - - /* Set the scroll region of the top canvas to its allocated size. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (day_view->top_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = day_view->top_canvas->allocation.width - 1; - new_y2 = day_view->top_canvas->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (day_view->top_canvas), - 0, 0, new_x2, new_y2); - - need_reshape = e_day_view_update_scroll_regions (day_view); - - /* Scroll to the start of the working day, if this is the initial - allocation. */ - if (day_view->scroll_to_work_day) { - scroll_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); - gnome_canvas_scroll_to (GNOME_CANVAS (day_view->main_canvas), - 0, scroll_y); - day_view->scroll_to_work_day = FALSE; - } - - /* Flag that we need to reshape the events. Note that changes in height - don't matter, since the rows are always the same height. */ - if (need_reshape) { - day_view->long_events_need_reshape = TRUE; - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - day_view->need_reshape[day] = TRUE; - - e_day_view_check_layout (day_view); - } -} - - -static gint -e_day_view_focus_in (GtkWidget *widget, GdkEventFocus *event) -{ - EDayView *day_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - day_view = E_DAY_VIEW (widget); - - GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - return FALSE; -} - - -static gint -e_day_view_focus_out (GtkWidget *widget, GdkEventFocus *event) -{ - EDayView *day_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - day_view = E_DAY_VIEW (widget); - - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - return FALSE; -} - - -void -e_day_view_set_calendar (EDayView *day_view, - GnomeCalendar *calendar) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - day_view->calendar = calendar; - - /* FIXME: free current events? */ -} - - -/* This reloads all calendar events. */ -void -e_day_view_update_all_events (EDayView *day_view) -{ - e_day_view_reload_events (day_view); -} - - -/* This is called when one event has been added or updated. */ -void -e_day_view_update_event (EDayView *day_view, - const gchar *uid) -{ - EDayViewEvent *event; - CalComponent *comp; - CalClientGetStatus status; - gint day, event_num; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - -#if 0 - /* FIXME: Just for testing. */ - chdir ("/home/damon/tmp"); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); - - g_print ("In e_day_view_update_event day_view:%p uid:%s\n", - day_view, uid); -#endif - - /* If our calendar or time hasn't been set yet, just return. */ - if (!day_view->calendar - || (day_view->lower == 0 && day_view->upper == 0)) - return; - - /* Get the event from the server. */ - status = cal_client_get_object (day_view->calendar->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Do nothing. */ - break; - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_warning ("syntax error uid=%s\n", uid); - return; - case CAL_CLIENT_GET_NOT_FOUND: - g_warning ("obj not found uid=%s\n", uid); - return; - } - - /* We only care about events. */ - if (comp && cal_component_get_vtype (comp) == CAL_COMPONENT_EVENT) { - gtk_object_unref (GTK_OBJECT (comp)); - return; - } - - /* If the event already exists and the dates didn't change, we can - update the event fairly easily without changing the events arrays - or computing a new layout. */ - if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) { - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); -#warning "FIX ME" - /* Do this the long way every time for now */ -#if 0 - if (ical_object_compare_dates (event->ico, ico)) { - g_print ("updated object's dates unchanged\n"); - e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, ico); - ical_object_unref (ico); - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - return; - } -#endif - /* The dates have changed, so we need to remove the - old occurrrences before adding the new ones. */ - g_print ("dates changed - removing occurrences\n"); - e_day_view_foreach_event_with_uid (day_view, uid, - e_day_view_remove_event_cb, - NULL); - } - - /* Add the occurrences of the event. */ - cal_recur_generate_instances (comp, day_view->lower, - day_view->upper, - e_day_view_add_event, - day_view); - gtk_object_unref (GTK_OBJECT (comp)); - - e_day_view_check_layout (day_view); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static gboolean -e_day_view_update_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data) -{ - EDayViewEvent *event; - CalComponent *comp; - - comp = data; -#if 0 - g_print ("In e_day_view_update_event_cb day:%i event_num:%i\n", - day, event_num); -#endif - if (day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - } - - gtk_object_unref (GTK_OBJECT (event->comp)); - event->comp = comp; - gtk_object_ref (GTK_OBJECT (comp)); - - /* If we are editing an event which we have just created, we will get - an update_event callback from the server. But we need to ignore it - or we will lose the text the user has already typed in. */ - if (day_view->editing_new_event - && day_view->editing_event_day == day - && day_view->editing_event_num == event_num) { - return TRUE; - } - - if (day == E_DAY_VIEW_LONG_EVENT) { - e_day_view_update_long_event_label (day_view, event_num); - e_day_view_reshape_long_event (day_view, event_num); - } else { - e_day_view_update_event_label (day_view, day, event_num); - e_day_view_reshape_day_event (day_view, day, event_num); - } - return TRUE; -} - - -/* This calls a given function for each event instance that matches the given - uid. Note that it is safe for the callback to remove the event (since we - step backwards through the arrays). */ -static void -e_day_view_foreach_event_with_uid (EDayView *day_view, - const gchar *uid, - EDayViewForeachEventCallback callback, - gpointer data) -{ - EDayViewEvent *event; - gint day, event_num; - const char *u; - - for (day = 0; day < day_view->days_shown; day++) { - for (event_num = day_view->events[day]->len - 1; - event_num >= 0; - event_num--) { - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (uid && !strcmp (uid, u)) { - if (!(*callback) (day_view, day, event_num, - data)) - return; - } - } - } - - for (event_num = day_view->long_events->len - 1; - event_num >= 0; - event_num--) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - if (!(*callback) (day_view, E_DAY_VIEW_LONG_EVENT, - event_num, data)) - return; - } - } -} - - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void -e_day_view_remove_event (EDayView *day_view, - const gchar *uid) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - -#if 1 - g_print ("In e_day_view_remove_event day_view:%p uid:%s\n", - day_view, uid); -#endif - - e_day_view_foreach_event_with_uid (day_view, uid, - e_day_view_remove_event_cb, NULL); - - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static gboolean -e_day_view_remove_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data) -{ - EDayViewEvent *event; - -#if 1 - g_print ("In e_day_view_remove_event_cb day:%i event_num:%i\n", - day, event_num); -#endif - - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - /* If we were editing this event, set editing_event_num to -1 so - on_editing_stopped doesn't try to update the event. */ - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) - day_view->editing_event_day = -1; - - if (event->canvas_item) - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - gtk_object_unref (GTK_OBJECT (event->comp)); - - if (day == E_DAY_VIEW_LONG_EVENT) { - g_array_remove_index (day_view->long_events, event_num); - day_view->long_events_need_layout = TRUE; - } else { - g_array_remove_index (day_view->events[day], event_num); - day_view->need_layout[day] = TRUE; - } - return TRUE; -} - - -/* This updates the text shown for an event. If the event start or end do not - lie on a row boundary, the time is displayed before the summary. */ -static void -e_day_view_update_event_label (EDayView *day_view, - gint day, - gint event_num) -{ - EDayViewEvent *event; - gchar *text; - gboolean free_text = FALSE, editing_event = FALSE; - gint offset, start_minute, end_minute; - CalComponentText summary; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* If the event isn't visible just return. */ - if (!event->canvas_item) - return; - - cal_component_get_summary (event->comp, &summary); - text = summary.value ? summary.value : ""; - - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) - editing_event = TRUE; - - if (!editing_event - && (event->start_minute % day_view->mins_per_row != 0 - || event->end_minute % day_view->mins_per_row != 0)) { - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - start_minute = offset + event->start_minute; - end_minute = offset + event->end_minute; - text = g_strdup_printf ("%02i:%02i-%02i:%02i %s", - start_minute / 60, - start_minute % 60, - end_minute / 60, - end_minute % 60, - text); - free_text = TRUE; - } - - gnome_canvas_item_set (event->canvas_item, - "text", text, - NULL); - - if (free_text) - g_free (text); -} - - -static void -e_day_view_update_long_event_label (EDayView *day_view, - gint event_num) -{ - EDayViewEvent *event; - CalComponentText summary; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* If the event isn't visible just return. */ - if (!event->canvas_item) - return; - - cal_component_get_summary (event->comp, &summary); - gnome_canvas_item_set (event->canvas_item, - "text", summary.value ? summary.value : "", - NULL); -} - - -/* Finds the day and index of the event with the given canvas item. - If is is a long event, -1 is returned as the day. - Returns TRUE if the event was found. */ -static gboolean -e_day_view_find_event_from_item (EDayView *day_view, - GnomeCanvasItem *item, - gint *day_return, - gint *event_num_return) -{ - EDayViewEvent *event; - gint day, event_num; - - for (day = 0; day < day_view->days_shown; day++) { - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - if (event->canvas_item == item) { - *day_return = day; - *event_num_return = event_num; - return TRUE; - } - } - } - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - if (event->canvas_item == item) { - *day_return = E_DAY_VIEW_LONG_EVENT; - *event_num_return = event_num; - return TRUE; - } - } - - return FALSE; -} - - -/* Finds the day and index of the event with the given uid. - If is is a long event, E_DAY_VIEW_LONG_EVENT is returned as the day. - Returns TRUE if an event with the uid was found. - Note that for recurring events there may be several EDayViewEvents, one - for each instance, all with the same iCalObject and uid. So only use this - function if you know the event doesn't recur or you are just checking to - see if any events with the uid exist. */ -static gboolean -e_day_view_find_event_from_uid (EDayView *day_view, - const gchar *uid, - gint *day_return, - gint *event_num_return) -{ - EDayViewEvent *event; - gint day, event_num; - const char *u; - - for (day = 0; day < day_view->days_shown; day++) { - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - *day_return = day; - *event_num_return = event_num; - return TRUE; - } - } - } - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - *day_return = E_DAY_VIEW_LONG_EVENT; - *event_num_return = event_num; - return TRUE; - } - } - - return FALSE; -} - - -/* This sets the selected time range. The EDayView will show the day or week - corresponding to the start time. If the start_time & end_time are not equal - and are both visible in the view, then the selection is set to those times, - otherwise it is set to 1 hour from the start of the working day. */ -void -e_day_view_set_selected_time_range (EDayView *day_view, - time_t start_time, - time_t end_time) -{ - GDate date; - time_t lower; - gint start_row, start_col, end_row, end_col; - gboolean need_redraw = FALSE, start_in_grid, end_in_grid; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - /* Calculate the first day that should be shown, based on start_time - and the days_shown setting. If we are showing 1 day it is just the - start of the day given by start_time, otherwise it is the previous - Monday. */ - if (day_view->days_shown == 1) - lower = time_day_begin (start_time); - else { - g_date_clear (&date, 1); - g_date_set_time (&date, start_time); - g_date_subtract_days (&date, g_date_weekday (&date) - 1); - lower = time_from_day (g_date_year (&date), - g_date_month (&date) - 1, - g_date_day (&date)); - } - - /* See if we need to change the days shown. */ - if (lower != day_view->lower) { - e_day_view_recalc_day_starts (day_view, lower); - e_day_view_reload_events (day_view); - need_redraw = TRUE; - } - - /* Set the selection. */ - start_in_grid = e_day_view_convert_time_to_grid_position (day_view, - start_time, - &start_col, - &start_row); - end_in_grid = e_day_view_convert_time_to_grid_position (day_view, - end_time - 60, - &end_col, - &end_row); - - /* If either of the times isn't in the grid, or the selection covers - an entire day, we set the selection to 1 row from the start of the - working day, in the day corresponding to the start time. */ - if (!start_in_grid || !end_in_grid - || (start_row == 0 && end_row == day_view->rows - 1)) { - end_col = start_col; - - start_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); - start_row = CLAMP (start_row, 0, day_view->rows - 1); - end_row = start_row; - } - - if (start_row != day_view->selection_start_row - || start_col != day_view->selection_start_day) { - need_redraw = TRUE; - day_view->selection_in_top_canvas = FALSE; - day_view->selection_start_row = start_row; - day_view->selection_start_day = start_col; - } - - if (end_row != day_view->selection_end_row - || end_col != day_view->selection_end_day) { - need_redraw = TRUE; - day_view->selection_in_top_canvas = FALSE; - day_view->selection_end_row = end_row; - day_view->selection_end_day = end_col; - } - - if (need_redraw) { - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -/* Returns the selected time range. */ -void -e_day_view_get_selected_time_range (EDayView *day_view, - time_t *start_time, - time_t *end_time) -{ - gint start_col, start_row, end_col, end_row; - time_t start, end; - - start_col = day_view->selection_start_day; - start_row = day_view->selection_start_row; - end_col = day_view->selection_end_day; - end_row = day_view->selection_end_row; - - if (start_col == -1) { - start_col = 0; - start_row = 0; - end_col = 0; - end_row = 0; - } - - /* Check if the selection is only in the top canvas, in which case - we can simply use the day_starts array. */ - if (day_view->selection_in_top_canvas) { - start = day_view->day_starts[start_col]; - end = day_view->day_starts[end_col + 1]; - } else { - /* Convert the start col + row into a time. */ - start = e_day_view_convert_grid_position_to_time (day_view, start_col, start_row); - end = e_day_view_convert_grid_position_to_time (day_view, end_col, end_row + 1); - } - - if (start_time) - *start_time = start; - - if (end_time) - *end_time = end; -} - - -static void -e_day_view_recalc_day_starts (EDayView *day_view, - time_t start_time) -{ - gint day; - - day_view->day_starts[0] = start_time; - for (day = 1; day <= day_view->days_shown; day++) { - day_view->day_starts[day] = time_add_day (day_view->day_starts[day - 1], 1); - } - - day_view->lower = start_time; - day_view->upper = day_view->day_starts[day_view->days_shown]; -} - - -gint -e_day_view_get_days_shown (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->days_shown; -} - - -void -e_day_view_set_days_shown (EDayView *day_view, - gint days_shown) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - g_return_if_fail (days_shown >= 1); - g_return_if_fail (days_shown <= E_DAY_VIEW_MAX_DAYS); - - if (day_view->days_shown != days_shown) { - day_view->days_shown = days_shown; - - /* FIXME: Update everything. */ - } -} - - -gint -e_day_view_get_mins_per_row (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->mins_per_row; -} - - -void -e_day_view_set_mins_per_row (EDayView *day_view, - gint mins_per_row) -{ - gint day; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - if (mins_per_row != 5 && mins_per_row != 10 && mins_per_row != 15 - && mins_per_row != 30 && mins_per_row != 60) { - g_warning ("Invalid minutes per row setting"); - return; - } - - if (day_view->mins_per_row == mins_per_row) - return; - - day_view->mins_per_row = mins_per_row; - e_day_view_recalc_num_rows (day_view); - - /* If we aren't visible, we'll sort it out later. */ - if (!GTK_WIDGET_VISIBLE (day_view)) - return; - - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - day_view->need_layout[day] = TRUE; - - /* We must layout the events before updating the scroll region, since - that will result in a redraw which would crash otherwise. */ - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->time_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - e_day_view_update_scroll_regions (day_view); -} - - -static gboolean -e_day_view_update_scroll_regions (EDayView *day_view) -{ - gdouble old_x2, old_y2, new_x2, new_y2; - gboolean need_reshape = FALSE; - - /* Set the scroll region of the time canvas to its allocated width, - but with the height the same as the main canvas. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (day_view->time_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = day_view->time_canvas->allocation.width - 1; - new_y2 = MAX (day_view->rows * day_view->row_height, - day_view->main_canvas->allocation.height) - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (day_view->time_canvas), - 0, 0, new_x2, new_y2); - - /* Set the scroll region of the main canvas to its allocated width, - but with the height depending on the number of rows needed. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (day_view->main_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = day_view->main_canvas->allocation.width - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) { - need_reshape = TRUE; - gnome_canvas_set_scroll_region (GNOME_CANVAS (day_view->main_canvas), - 0, 0, new_x2, new_y2); - } - - return need_reshape; -} - - -/* This recalculates the number of rows to display, based on the time range - shown and the minutes per row. */ -static void -e_day_view_recalc_num_rows (EDayView *day_view) -{ - gint hours, minutes, total_minutes; - - hours = day_view->last_hour_shown - day_view->first_hour_shown; - /* This could be negative but it works out OK. */ - minutes = day_view->last_minute_shown - day_view->first_minute_shown; - total_minutes = hours * 60 + minutes; - day_view->rows = total_minutes / day_view->mins_per_row; -} - - -/* Converts an hour and minute to a row in the canvas. Note that if we aren't - showing all 24 hours of the day, the returned row may be negative or - greater than day_view->rows. */ -gint -e_day_view_convert_time_to_row (EDayView *day_view, - gint hour, - gint minute) -{ - gint total_minutes, start_minute, offset; - - total_minutes = hour * 60 + minute; - start_minute = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - offset = total_minutes - start_minute; - if (offset < 0) - return -1; - else - return offset / day_view->mins_per_row; -} - - -/* Converts an hour and minute to a y coordinate in the canvas. */ -gint -e_day_view_convert_time_to_position (EDayView *day_view, - gint hour, - gint minute) -{ - gint total_minutes, start_minute, offset; - - total_minutes = hour * 60 + minute; - start_minute = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - offset = total_minutes - start_minute; - - return offset * day_view->row_height / day_view->mins_per_row; -} - - -static gboolean -e_day_view_on_top_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - gint event_x, event_y, scroll_x, scroll_y, day, event_num; - EDayViewPosition pos; - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - /* The top canvas doesn't scroll, but just in case. */ - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - event_x += scroll_x; - event_y += scroll_y; - - pos = e_day_view_convert_position_in_top_canvas (day_view, - event_x, event_y, - &day, &event_num); - - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return FALSE; - - if (pos != E_DAY_VIEW_POS_NONE) - return e_day_view_on_long_event_button_press (day_view, - event_num, - event, pos, - event_x, - event_y); - - e_day_view_stop_editing_event (day_view); - - if (event->button == 1) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->time) == 0) { - e_day_view_start_selection (day_view, day, -1); - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, -1, -1); - } - - return TRUE; -} - - -static gboolean -e_day_view_convert_event_coords (EDayView *day_view, - GdkEvent *event, - GdkWindow *window, - gint *x_return, - gint *y_return) -{ - gint event_x, event_y, win_x, win_y; - GdkWindow *event_window;; - - /* Get the event window, x & y from the appropriate event struct. */ - switch (event->type) { - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - event_x = event->button.x; - event_y = event->button.y; - event_window = event->button.window; - break; - case GDK_MOTION_NOTIFY: - event_x = event->motion.x; - event_y = event->motion.y; - event_window = event->motion.window; - break; - default: - /* Shouldn't get here. */ - g_assert_not_reached (); - return FALSE; - } - - while (event_window && event_window != window - && event_window != GDK_ROOT_PARENT()) { - gdk_window_get_position (event_window, &win_x, &win_y); - event_x += win_x; - event_y += win_y; - event_window = gdk_window_get_parent (event_window); - } - - *x_return = event_x; - *y_return = event_y; - - if (event_window != window) - g_warning ("Couldn't find event window\n"); - - return (event_window == window) ? TRUE : FALSE; -} - - -static gboolean -e_day_view_on_main_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - gint event_x, event_y, scroll_x, scroll_y, row, day, event_num; - EDayViewPosition pos; - - /* Handle scroll wheel events */ - if (event->button == 4 || event->button == 5) { - GtkAdjustment *adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - gfloat new_value; - - new_value = adj->value + ((event->button == 4) ? - -adj->page_increment / 2: - adj->page_increment / 2); - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, new_value); - - return TRUE; - } - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - event_x += scroll_x; - event_y += scroll_y; - - /* Find out where the mouse is. */ - pos = e_day_view_convert_position_in_main_canvas (day_view, - event_x, event_y, - &day, &row, - &event_num); - - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return FALSE; - - if (pos != E_DAY_VIEW_POS_NONE) - return e_day_view_on_event_button_press (day_view, day, - event_num, event, pos, - event_x, event_y); - - e_day_view_stop_editing_event (day_view); - - /* Start the selection drag. */ - if (event->button == 1) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->time) == 0) { - e_day_view_start_selection (day_view, day, row); - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, -1, -1); - } - - return TRUE; -} - - -static gboolean -e_day_view_on_time_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - /* Handle scroll wheel events */ - if (event->button == 4 || event->button == 5) { - GtkAdjustment *adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - gfloat new_value; - - new_value = adj->value + ((event->button == 4) ? - -adj->page_increment / 2: - adj->page_increment / 2); - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, new_value); - - return TRUE; - } - - return FALSE; -} - - -static gboolean -e_day_view_on_long_event_button_press (EDayView *day_view, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - if (event->button == 1) { - if (event->type == GDK_BUTTON_PRESS) { - e_day_view_on_long_event_click (day_view, event_num, - event, pos, - event_x, event_y); - return TRUE; - } else if (event->type == GDK_2BUTTON_PRESS) { - e_day_view_on_event_double_click (day_view, -1, - event_num); - return TRUE; - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, - E_DAY_VIEW_LONG_EVENT, - event_num); - return TRUE; - } - return FALSE; -} - - -static gboolean -e_day_view_on_event_button_press (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - if (event->button == 1) { - if (event->type == GDK_BUTTON_PRESS) { - e_day_view_on_event_click (day_view, day, event_num, - event, pos, - event_x, event_y); - return TRUE; - } else if (event->type == GDK_2BUTTON_PRESS) { - e_day_view_on_event_double_click (day_view, day, - event_num); - return TRUE; - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, - day, event_num); - return TRUE; - } - return FALSE; -} - - -static void -e_day_view_on_long_event_click (EDayView *day_view, - gint event_num, - GdkEventButton *bevent, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - EDayViewEvent *event; - gint start_day, end_day, day; - gint item_x, item_y, item_w, item_h; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* Ignore clicks on the EText while editing. */ - if (pos == E_DAY_VIEW_POS_EVENT - && E_TEXT (event->canvas_item)->editing) - return; - - if (!(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp)) - && (pos == E_DAY_VIEW_POS_LEFT_EDGE - || pos == E_DAY_VIEW_POS_RIGHT_EDGE)) { - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - return; - - /* Grab the keyboard focus, so the event being edited is saved - and we can use the Escape key to abort the resize. */ - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (day_view->top_canvas)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, bevent->time) == 0) { - - day_view->resize_event_day = E_DAY_VIEW_LONG_EVENT; - day_view->resize_event_num = event_num; - day_view->resize_drag_pos = pos; - day_view->resize_start_row = start_day; - day_view->resize_end_row = end_day; - - /* Create the edit rect if necessary. */ - e_day_view_reshape_resize_long_event_rect_item (day_view); - - /* Make sure the text item is on top. */ - gnome_canvas_item_raise_to_top (day_view->resize_long_event_rect_item); - - /* Raise the event's item, above the rect as well. */ - gnome_canvas_item_raise_to_top (event->canvas_item); - } - } else if (e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) { - /* Remember the item clicked and the mouse position, - so we can start a drag if the mouse moves. */ - day_view->pressed_event_day = E_DAY_VIEW_LONG_EVENT; - day_view->pressed_event_num = event_num; - - day_view->drag_event_x = event_x; - day_view->drag_event_y = event_y; - - e_day_view_convert_position_in_top_canvas (day_view, - event_x, event_y, - &day, NULL); - day_view->drag_event_offset = day - start_day; - } -} - - -static void -e_day_view_on_event_click (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *bevent, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - EDayViewEvent *event; - gint tmp_day, row, start_row; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Ignore clicks on the EText while editing. */ - if (pos == E_DAY_VIEW_POS_EVENT - && E_TEXT (event->canvas_item)->editing) - return; - - if (!(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp)) - && (pos == E_DAY_VIEW_POS_TOP_EDGE - || pos == E_DAY_VIEW_POS_BOTTOM_EDGE)) { - /* Grab the keyboard focus, so the event being edited is saved - and we can use the Escape key to abort the resize. */ - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (day_view->main_canvas)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, bevent->time) == 0) { - - day_view->resize_event_day = day; - day_view->resize_event_num = event_num; - day_view->resize_drag_pos = pos; - day_view->resize_start_row = event->start_minute / day_view->mins_per_row; - day_view->resize_end_row = (event->end_minute - 1) / day_view->mins_per_row; - - day_view->resize_bars_event_day = day; - day_view->resize_bars_event_num = event_num; - - /* Create the edit rect if necessary. */ - e_day_view_reshape_resize_rect_item (day_view); - - e_day_view_reshape_main_canvas_resize_bars (day_view); - - /* Make sure the text item is on top. */ - gnome_canvas_item_raise_to_top (day_view->resize_rect_item); - gnome_canvas_item_raise_to_top (day_view->resize_bar_item); - - /* Raise the event's item, above the rect as well. */ - gnome_canvas_item_raise_to_top (event->canvas_item); - } - - } else { - /* Remember the item clicked and the mouse position, - so we can start a drag if the mouse moves. */ - day_view->pressed_event_day = day; - day_view->pressed_event_num = event_num; - - day_view->drag_event_x = event_x; - day_view->drag_event_y = event_y; - - e_day_view_convert_position_in_main_canvas (day_view, - event_x, event_y, - &tmp_day, &row, - NULL); - start_row = event->start_minute / day_view->mins_per_row; - day_view->drag_event_offset = row - start_row; - } -} - - -static void -e_day_view_reshape_resize_long_event_rect_item (EDayView *day_view) -{ - gint day, event_num, start_day, end_day; - gint item_x, item_y, item_w, item_h; - gdouble x1, y1, x2, y2; - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - - /* If we're not resizing an event, or the event is not shown, - hide the resize bars. */ - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE - || !e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) { - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - return; - } - - x1 = item_x; - y1 = item_y; - x2 = item_x + item_w - 1; - y2 = item_y + item_h - 1; - - gnome_canvas_item_set (day_view->resize_long_event_rect_item, - "x1", x1, - "y1", y1, - "x2", x2, - "y2", y2, - NULL); - gnome_canvas_item_show (day_view->resize_long_event_rect_item); -} - - -static void -e_day_view_reshape_resize_rect_item (EDayView *day_view) -{ - gint day, event_num; - gint item_x, item_y, item_w, item_h; - gdouble x1, y1, x2, y2; - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - - /* If we're not resizing an event, or the event is not shown, - hide the resize bars. */ - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE - || !e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) { - gnome_canvas_item_hide (day_view->resize_rect_item); - return; - } - - x1 = item_x; - y1 = item_y; - x2 = item_x + item_w - 1; - y2 = item_y + item_h - 1; - - gnome_canvas_item_set (day_view->resize_rect_item, - "x1", x1 + E_DAY_VIEW_BAR_WIDTH - 1, - "y1", y1, - "x2", x2, - "y2", y2, - NULL); - gnome_canvas_item_show (day_view->resize_rect_item); - - gnome_canvas_item_set (day_view->resize_bar_item, - "x1", x1, - "y1", y1, - "x2", x1 + E_DAY_VIEW_BAR_WIDTH - 1, - "y2", y2, - NULL); - gnome_canvas_item_show (day_view->resize_bar_item); -} - - -static void -e_day_view_on_event_double_click (EDayView *day_view, - gint day, - gint event_num) -{ -#if 0 - g_print ("In e_day_view_on_event_double_click\n"); -#endif - -} - - -static void -e_day_view_on_event_right_click (EDayView *day_view, - GdkEventButton *bevent, - gint day, - gint event_num) -{ - EDayViewEvent *event; - int have_selection, not_being_edited, items, i; - struct menu_item *context_menu; - - static struct menu_item main_items[] = { - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_day_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this appointment"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item recur_child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_day_view_on_edit_appointment, NULL, TRUE }, - { N_("Make this appointment movable"), (GtkSignalFunc) e_day_view_on_unrecur_appointment, NULL, TRUE }, - { N_("Delete this occurrence"), (GtkSignalFunc) e_day_view_on_delete_occurrence, NULL, TRUE }, - { N_("Delete all occurrences"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; - - have_selection = GTK_WIDGET_HAS_FOCUS (day_view) - && day_view->selection_start_day != -1; - - if (event_num == -1) { - items = 1; - context_menu = &main_items[0]; - context_menu[0].sensitive = have_selection; - } else { - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - /* This used to be set only if the event wasn't being edited - in the event editor, but we can't check that at present. - We could possibly set up another method of checking it. */ - not_being_edited = TRUE; - - if (cal_component_has_rrules (event->comp) - || cal_component_has_rdates (event->comp)) { - items = 6; - context_menu = &recur_child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[2].sensitive = not_being_edited; - context_menu[3].sensitive = not_being_edited; - context_menu[5].sensitive = have_selection; - } else { - items = 4; - context_menu = &child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[3].sensitive = have_selection; - } - } - - for (i = 0; i < items; i++) - context_menu[i].data = day_view; - - day_view->popup_event_day = day; - day_view->popup_event_num = event_num; - popup_menu (context_menu, items, bevent); -} - - -static void -e_day_view_on_new_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - CalComponent *comp; - CalComponentDateTime date; - time_t dtstart, dtend; - - day_view = E_DAY_VIEW (data); - - comp = cal_component_new (); - e_day_view_get_selected_time_range (day_view, &dtstart, &dtend); - - date.value = g_new (struct icaltimetype, 1); - *date.value = icaltimetype_from_timet (dtstart, FALSE); - cal_component_set_dtstart (comp, &date); - *date.value = icaltimetype_from_timet (dtend, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - gnome_calendar_edit_object (day_view->calendar, comp); - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_day_view_on_edit_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - gnome_calendar_edit_object (day_view->calendar, event->comp); -} - - -static void -e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - CalComponent *comp; - CalComponentDateTime *date=NULL; - GSList *list; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - /* We must duplicate the CalComponent, or we won't know it has changed - when we get the "update_event" callback. */ - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - list = g_slist_append (list, date); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - const char *uid; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - if (day_view->editing_event_day >= 0) - e_day_view_stop_editing_event (day_view); - - cal_component_get_uid (event->comp, &uid); - if (!cal_client_remove_object (day_view->calendar->client, uid)) - g_message ("e_day_view_on_delete_appointment(): Could not remove the object!"); -} - - -static void -e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - CalComponent *comp, *new_comp; - CalComponentDateTime *date; - GSList *list; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - /* For the recurring object, we add a exception to get rid of the - instance. */ - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - list = g_slist_append (list, date); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - /* For the unrecurred instance we duplicate the original object, - create a new uid for it, get rid of the recurrence rules, and set - the start & end times to the instances times. */ - new_comp = cal_component_clone (event->comp); - cal_component_set_uid (new_comp, cal_component_gen_uid ()); - cal_component_set_exdate_list (new_comp, NULL); - cal_component_set_exrule_list (new_comp, NULL); - - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - - *date->value = icaltimetype_from_timet (event->start, FALSE); - cal_component_set_dtstart (new_comp, date); - *date->value = icaltimetype_from_timet (event->end, FALSE); - cal_component_set_dtend (new_comp, date); - - cal_component_free_datetime (date); - - /* Now update both CalComponents. Note that we do this last since at - * present the updates happen synchronously so our event may disappear. - */ - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - if (!cal_client_update_object (day_view->calendar->client, new_comp)) - g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (new_comp)); -} - - -static EDayViewEvent* -e_day_view_get_popup_menu_event (EDayView *day_view) -{ - if (day_view->popup_event_num == -1) - return NULL; - - if (day_view->popup_event_day == E_DAY_VIEW_LONG_EVENT) - return &g_array_index (day_view->long_events, - EDayViewEvent, - day_view->popup_event_num); - else - return &g_array_index (day_view->events[day_view->popup_event_day], - EDayViewEvent, - day_view->popup_event_num); -} - - -static gboolean -e_day_view_on_top_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - if (day_view->selection_is_being_dragged) { - gdk_pointer_ungrab (event->time); - e_day_view_finish_selection (day_view); - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - e_day_view_finish_long_event_resize (day_view); - gdk_pointer_ungrab (event->time); - } else if (day_view->pressed_event_day != -1) { - e_day_view_start_editing_event (day_view, - day_view->pressed_event_day, - day_view->pressed_event_num, - NULL); - } - - day_view->pressed_event_day = -1; - - return FALSE; -} - - -static gboolean -e_day_view_on_main_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - if (day_view->selection_is_being_dragged) { - gdk_pointer_ungrab (event->time); - e_day_view_finish_selection (day_view); - e_day_view_stop_auto_scroll (day_view); - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - e_day_view_finish_resize (day_view); - gdk_pointer_ungrab (event->time); - e_day_view_stop_auto_scroll (day_view); - } else if (day_view->pressed_event_day != -1) { - e_day_view_start_editing_event (day_view, - day_view->pressed_event_day, - day_view->pressed_event_num, - NULL); - } - - day_view->pressed_event_day = -1; - - return FALSE; -} - - -static void -e_day_view_update_calendar_selection_time (EDayView *day_view) -{ - time_t start, end; - - e_day_view_get_selected_time_range (day_view, &start, &end); - gnome_calendar_set_selected_time_range (day_view->calendar, - start, end); -} - - -static gboolean -e_day_view_on_top_canvas_motion (GtkWidget *widget, - GdkEventMotion *mevent, - EDayView *day_view) -{ - EDayViewEvent *event = NULL; - EDayViewPosition pos; - gint event_x, event_y, scroll_x, scroll_y, canvas_x, canvas_y; - gint day, event_num; - GdkCursor *cursor; - -#if 0 - g_print ("In e_day_view_on_top_canvas_motion\n"); -#endif - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) mevent, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - /* The top canvas doesn't scroll, but just in case. */ - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - canvas_x = event_x + scroll_x; - canvas_y = event_y + scroll_y; - - pos = e_day_view_convert_position_in_top_canvas (day_view, - canvas_x, canvas_y, - &day, &event_num); - if (event_num != -1) - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (day_view->selection_is_being_dragged) { - e_day_view_update_selection (day_view, day, -1); - return TRUE; - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - e_day_view_update_long_event_resize (day_view, day); - return TRUE; - } - } else if (day_view->pressed_event_day == E_DAY_VIEW_LONG_EVENT) { - GtkTargetList *target_list; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->pressed_event_num); - - if (!(cal_component_has_rdates (event->comp) - && cal_component_has_rrules (event->comp)) - && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET - || abs (canvas_y - day_view->drag_event_y) > E_DAY_VIEW_DRAG_START_OFFSET)) { - day_view->drag_event_day = day_view->pressed_event_day; - day_view->drag_event_num = day_view->pressed_event_num; - day_view->pressed_event_day = -1; - - /* Hide the horizontal bars. */ - if (day_view->resize_bars_event_day != -1) { - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } - - target_list = gtk_target_list_new (target_table, - n_targets); - gtk_drag_begin (widget, target_list, - GDK_ACTION_COPY | GDK_ACTION_MOVE, - 1, (GdkEvent*)mevent); - gtk_target_list_unref (target_list); - } - } else { - cursor = day_view->normal_cursor; - - /* Recurring events can't be resized. */ - if (event && - !(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp))) { - switch (pos) { - case E_DAY_VIEW_POS_LEFT_EDGE: - case E_DAY_VIEW_POS_RIGHT_EDGE: - cursor = day_view->resize_width_cursor; - break; - default: - break; - } - } - - /* Only set the cursor if it is different to last one set. */ - if (day_view->last_cursor_set_in_top_canvas != cursor) { - day_view->last_cursor_set_in_top_canvas = cursor; - gdk_window_set_cursor (widget->window, cursor); - } - - } - - return FALSE; -} - - -static gboolean -e_day_view_on_main_canvas_motion (GtkWidget *widget, - GdkEventMotion *mevent, - EDayView *day_view) -{ - EDayViewEvent *event = NULL; - EDayViewPosition pos; - gint event_x, event_y, scroll_x, scroll_y, canvas_x, canvas_y; - gint row, day, event_num; - GdkCursor *cursor; - -#if 0 - g_print ("In e_day_view_on_main_canvas_motion\n"); -#endif - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) mevent, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - canvas_x = event_x + scroll_x; - canvas_y = event_y + scroll_y; - - pos = e_day_view_convert_position_in_main_canvas (day_view, - canvas_x, canvas_y, - &day, &row, - &event_num); - if (event_num != -1) - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - if (day_view->selection_is_being_dragged) { - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - e_day_view_update_selection (day_view, day, row); - e_day_view_check_auto_scroll (day_view, - event_x, event_y); - return TRUE; - } - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - e_day_view_update_resize (day_view, row); - e_day_view_check_auto_scroll (day_view, - event_x, event_y); - return TRUE; - } - } else if (day_view->pressed_event_day != -1 - && day_view->pressed_event_day != E_DAY_VIEW_LONG_EVENT) { - GtkTargetList *target_list; - - event = &g_array_index (day_view->events[day_view->pressed_event_day], EDayViewEvent, day_view->pressed_event_num); - - if (!(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp)) - && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET - || abs (canvas_y - day_view->drag_event_y) > E_DAY_VIEW_DRAG_START_OFFSET)) { - day_view->drag_event_day = day_view->pressed_event_day; - day_view->drag_event_num = day_view->pressed_event_num; - day_view->pressed_event_day = -1; - - /* Hide the horizontal bars. */ - if (day_view->resize_bars_event_day != -1) { - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } - - target_list = gtk_target_list_new (target_table, - n_targets); - gtk_drag_begin (widget, target_list, - GDK_ACTION_COPY | GDK_ACTION_MOVE, - 1, (GdkEvent*)mevent); - gtk_target_list_unref (target_list); - } - } else { - cursor = day_view->normal_cursor; - - /* Recurring events can't be resized. */ - if (event && - !(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp))) { - switch (pos) { - case E_DAY_VIEW_POS_LEFT_EDGE: - cursor = day_view->move_cursor; - break; - case E_DAY_VIEW_POS_TOP_EDGE: - case E_DAY_VIEW_POS_BOTTOM_EDGE: - cursor = day_view->resize_height_cursor; - break; - default: - break; - } - } - - /* Only set the cursor if it is different to last one set. */ - if (day_view->last_cursor_set_in_main_canvas != cursor) { - day_view->last_cursor_set_in_main_canvas = cursor; - gdk_window_set_cursor (widget->window, cursor); - } - } - - return FALSE; -} - - -/* This sets the selection to a single cell. If day is -1 then the current - start day is reused. If row is -1 then the selection is in the top canvas. -*/ -void -e_day_view_start_selection (EDayView *day_view, - gint day, - gint row) -{ - if (day == -1) { - day = day_view->selection_start_day; - if (day == -1) - day = 0; - } - - day_view->selection_start_day = day; - day_view->selection_end_day = day; - - day_view->selection_start_row = row; - day_view->selection_end_row = row; - - day_view->selection_is_being_dragged = TRUE; - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END; - day_view->selection_in_top_canvas = (row == -1) ? TRUE : FALSE; - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -/* Updates the selection during a drag. If day is -1 the selection day is - unchanged. */ -void -e_day_view_update_selection (EDayView *day_view, - gint day, - gint row) -{ - gboolean need_redraw = FALSE; - -#if 0 - g_print ("Updating selection %i,%i\n", day, row); -#endif - - day_view->selection_in_top_canvas = (row == -1) ? TRUE : FALSE; - - if (day == -1) - day = (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - ? day_view->selection_start_day - : day_view->selection_end_day; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) { - if (row != day_view->selection_start_row - || day != day_view->selection_start_day) { - need_redraw = TRUE; - day_view->selection_start_row = row; - day_view->selection_start_day = day; - } - } else { - if (row != day_view->selection_end_row - || day != day_view->selection_end_day) { - need_redraw = TRUE; - day_view->selection_end_row = row; - day_view->selection_end_day = day; - } - } - - e_day_view_normalize_selection (day_view); - - /* FIXME: Optimise? */ - if (need_redraw) { - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -static void -e_day_view_normalize_selection (EDayView *day_view) -{ - gint tmp_row, tmp_day; - - /* Switch the drag position if necessary. */ - if (day_view->selection_start_day > day_view->selection_end_day - || (day_view->selection_start_day == day_view->selection_end_day - && day_view->selection_start_row > day_view->selection_end_row)) { - tmp_row = day_view->selection_start_row; - tmp_day = day_view->selection_start_day; - day_view->selection_start_day = day_view->selection_end_day; - day_view->selection_start_row = day_view->selection_end_row; - day_view->selection_end_day = tmp_day; - day_view->selection_end_row = tmp_row; - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END; - else - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_START; - } -} - - -void -e_day_view_finish_selection (EDayView *day_view) -{ - day_view->selection_is_being_dragged = FALSE; - e_day_view_update_calendar_selection_time (day_view); -} - - -static void -e_day_view_update_long_event_resize (EDayView *day_view, - gint day) -{ - EDayViewEvent *event; - gint event_num; - gboolean need_reshape = FALSE; - -#if 0 - g_print ("Updating resize Day:%i\n", day); -#endif - - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) { - day = MIN (day, day_view->resize_end_row); - if (day != day_view->resize_start_row) { - need_reshape = TRUE; - day_view->resize_start_row = day; - - } - } else { - day = MAX (day, day_view->resize_start_row); - if (day != day_view->resize_end_row) { - need_reshape = TRUE; - day_view->resize_end_row = day; - } - } - - /* FIXME: Optimise? */ - if (need_reshape) { - e_day_view_reshape_long_event (day_view, event_num); - e_day_view_reshape_resize_long_event_rect_item (day_view); - gtk_widget_queue_draw (day_view->top_canvas); - } -} - - -static void -e_day_view_update_resize (EDayView *day_view, - gint row) -{ - EDayViewEvent *event; - gint day, event_num; - gboolean need_reshape = FALSE; - -#if 0 - g_print ("Updating resize Row:%i\n", row); -#endif - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) { - row = MIN (row, day_view->resize_end_row); - if (row != day_view->resize_start_row) { - need_reshape = TRUE; - day_view->resize_start_row = row; - - } - } else { - row = MAX (row, day_view->resize_start_row); - if (row != day_view->resize_end_row) { - need_reshape = TRUE; - day_view->resize_end_row = row; - } - } - - /* FIXME: Optimise? */ - if (need_reshape) { - e_day_view_reshape_day_event (day_view, day, event_num); - e_day_view_reshape_resize_rect_item (day_view); - e_day_view_reshape_main_canvas_resize_bars (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -/* This converts the resize start or end row back to a time and updates the - event. */ -static void -e_day_view_finish_long_event_resize (EDayView *day_view) -{ - EDayViewEvent *event; - gint event_num; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* We use a temporary shallow copy of the ico since we don't want to - change the original ico here. Otherwise we would not detect that - the event's time had changed in the "update_event" callback. */ - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) { - dt = day_view->day_starts[day_view->resize_start_row]; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - } else { - dt = day_view->day_starts[day_view->resize_end_row + 1]; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - } - g_free (date.value); - - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_finish_long_event_resize(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -/* This converts the resize start or end row back to a time and updates the - event. */ -static void -e_day_view_finish_resize (EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* We use a temporary shallow copy of the ico since we don't want to - change the original ico here. Otherwise we would not detect that - the event's time had changed in the "update_event" callback. */ - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) { - dt = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_start_row); - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - } else { - dt = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_end_row + 1); - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - } - g_free (date.value); - - gnome_canvas_item_hide (day_view->resize_rect_item); - gnome_canvas_item_hide (day_view->resize_bar_item); - - /* Hide the horizontal bars. */ - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_finish_resize(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_day_view_abort_resize (EDayView *day_view, - guint32 time) -{ - gint day, event_num; - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE) - return; - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - gdk_pointer_ungrab (time); - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - - if (day == E_DAY_VIEW_LONG_EVENT) { - e_day_view_reshape_long_event (day_view, event_num); - gtk_widget_queue_draw (day_view->top_canvas); - - day_view->last_cursor_set_in_top_canvas = day_view->normal_cursor; - gdk_window_set_cursor (day_view->top_canvas->window, - day_view->normal_cursor); - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - } else { - e_day_view_reshape_day_event (day_view, day, event_num); - e_day_view_reshape_main_canvas_resize_bars (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - - day_view->last_cursor_set_in_main_canvas = day_view->normal_cursor; - gdk_window_set_cursor (day_view->main_canvas->window, - day_view->normal_cursor); - gnome_canvas_item_hide (day_view->resize_rect_item); - gnome_canvas_item_hide (day_view->resize_bar_item); - } -} - - -static void -e_day_view_reload_events (EDayView *day_view) -{ - e_day_view_free_events (day_view); - - /* Reset all our indices. */ - day_view->editing_event_day = -1; - day_view->popup_event_day = -1; - day_view->resize_bars_event_day = -1; - day_view->resize_event_day = -1; - day_view->pressed_event_day = -1; - day_view->drag_event_day = -1; - - /* If both lower & upper are 0, then the time range hasn't been set, - so we don't try to load any events. */ - if (day_view->calendar - && (day_view->lower != 0 || day_view->upper != 0)) { - cal_client_generate_instances (day_view->calendar->client, - CALOBJ_TYPE_EVENT, - day_view->lower, - day_view->upper, - e_day_view_add_event, - day_view); - } - - /* We need to do this to make sure the top canvas is resized. */ - day_view->long_events_need_layout = TRUE; - - e_day_view_check_layout (day_view); - e_day_view_reshape_main_canvas_resize_bars (day_view); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_free_events (EDayView *day_view) -{ - gint day; - - e_day_view_free_event_array (day_view, day_view->long_events); - - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - e_day_view_free_event_array (day_view, day_view->events[day]); -} - - -static void -e_day_view_free_event_array (EDayView *day_view, - GArray *array) -{ - EDayViewEvent *event; - gint event_num; - - for (event_num = 0; event_num < array->len; event_num++) { - event = &g_array_index (array, EDayViewEvent, event_num); - if (event->canvas_item) - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - gtk_object_unref (GTK_OBJECT (event->comp)); - } - - g_array_set_size (array, 0); -} - - -/* This adds one event to the view, adding it to the appropriate array. */ -static gboolean -e_day_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data) - -{ - EDayView *day_view; - EDayViewEvent event; - gint day, offset; - struct tm start_tm, end_tm; - - day_view = E_DAY_VIEW (data); - - /* Check that the event times are valid. */ - g_return_val_if_fail (start <= end, TRUE); - g_return_val_if_fail (start < day_view->upper, TRUE); - g_return_val_if_fail (end > day_view->lower, TRUE); - - start_tm = *(localtime (&start)); - end_tm = *(localtime (&end)); - - event.comp = comp; - gtk_object_ref (GTK_OBJECT (comp)); - event.start = start; - event.end = end; - event.canvas_item = NULL; - - /* Calculate the start & end minute, relative to the top of the - display. */ - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - event.start_minute = start_tm.tm_hour * 60 + start_tm.tm_min - offset; - event.end_minute = end_tm.tm_hour * 60 + end_tm.tm_min - offset; - - event.start_row_or_col = -1; - event.num_columns = -1; - - /* Find out which array to add the event to. */ - for (day = 0; day < day_view->days_shown; day++) { - if (start >= day_view->day_starts[day] - && end <= day_view->day_starts[day + 1]) { - - /* Special case for when the appointment ends at - midnight, i.e. the start of the next day. */ - if (end == day_view->day_starts[day + 1]) { - - /* If the event last the entire day, then we - skip it here so it gets added to the top - canvas. */ - if (start == day_view->day_starts[day]) - break; - - event.end_minute = 24 * 60; - } - - g_array_append_val (day_view->events[day], event); - day_view->events_sorted[day] = FALSE; - day_view->need_layout[day] = TRUE; - return TRUE; - } - } - - /* The event wasn't within one day so it must be a long event, - i.e. shown in the top canvas. */ - g_array_append_val (day_view->long_events, event); - day_view->long_events_sorted = FALSE; - day_view->long_events_need_layout = TRUE; - return TRUE; -} - - -/* This lays out the short (less than 1 day) events in the columns. - Any long events are simply skipped. */ -void -e_day_view_check_layout (EDayView *day_view) -{ - gint day; - - /* Don't bother if we aren't visible. */ - if (!GTK_WIDGET_VISIBLE (day_view)) - return; - - /* Make sure the events are sorted (by start and size). */ - e_day_view_ensure_events_sorted (day_view); - - for (day = 0; day < day_view->days_shown; day++) { - if (day_view->need_layout[day]) - e_day_view_layout_day_events (day_view, day); - - if (day_view->need_layout[day] - || day_view->need_reshape[day]) { - e_day_view_reshape_day_events (day_view, day); - - if (day_view->resize_bars_event_day == day) - e_day_view_reshape_main_canvas_resize_bars (day_view); - } - - day_view->need_layout[day] = FALSE; - day_view->need_reshape[day] = FALSE; - } - - if (day_view->long_events_need_layout) - e_day_view_layout_long_events (day_view); - - if (day_view->long_events_need_layout - || day_view->long_events_need_reshape) - e_day_view_reshape_long_events (day_view); - - day_view->long_events_need_layout = FALSE; - day_view->long_events_need_reshape = FALSE; -} - - -static void -e_day_view_layout_long_events (EDayView *day_view) -{ - EDayViewEvent *event; - gint event_num, old_rows_in_top_display, top_canvas_height, top_rows; - guint8 *grid; - - /* This is a temporary 2-d grid which is used to place events. - Each element is 0 if the position is empty, or 1 if occupied. - We allocate the maximum size possible here, assuming that each - event will need its own row. */ - grid = g_new0 (guint8, - day_view->long_events->len * E_DAY_VIEW_MAX_DAYS); - - /* Reset the number of rows in the top display to 0. It will be - updated as events are layed out below. */ - old_rows_in_top_display = day_view->rows_in_top_display; - day_view->rows_in_top_display = 0; - - /* Iterate over the events, finding which days they cover, and putting - them in the first free row available. */ - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - e_day_view_layout_long_event (day_view, event, grid); - } - - /* Free the grid. */ - g_free (grid); - - /* Set the height of the top canvas based on the row height and the - number of rows needed (min 1 + 1 for the dates + 1 space for DnD).*/ - if (day_view->rows_in_top_display != old_rows_in_top_display) { - top_rows = MAX (1, day_view->rows_in_top_display); - top_canvas_height = (top_rows + 2) * day_view->top_row_height; - gtk_widget_set_usize (day_view->top_canvas, -1, - top_canvas_height); - } -} - - -static void -e_day_view_layout_long_event (EDayView *day_view, - EDayViewEvent *event, - guint8 *grid) -{ - gint start_day, end_day, free_row, day, row; - - event->num_columns = 0; - - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - return; - - /* Try each row until we find a free one. */ - row = 0; - do { - free_row = row; - for (day = start_day; day <= end_day; day++) { - if (grid[row * E_DAY_VIEW_MAX_DAYS + day]) { - free_row = -1; - break; - } - } - row++; - } while (free_row == -1); - - event->start_row_or_col = free_row; - event->num_columns = 1; - - /* Mark the cells as full. */ - for (day = start_day; day <= end_day; day++) { - grid[free_row * E_DAY_VIEW_MAX_DAYS + day] = 1; - } - - /* Update the number of rows in the top canvas if necessary. */ - day_view->rows_in_top_display = MAX (day_view->rows_in_top_display, - free_row + 1); -} - - -static void -e_day_view_reshape_long_events (EDayView *day_view) -{ - EDayViewEvent *event; - gint event_num; - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (event->num_columns == 0) { - if (event->canvas_item) { - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - event->canvas_item = NULL; - } - } else { - e_day_view_reshape_long_event (day_view, event_num); - } - } -} - - -static void -e_day_view_reshape_long_event (EDayView *day_view, - gint event_num) -{ - EDayViewEvent *event; - GdkFont *font; - gint start_day, end_day, item_x, item_y, item_w, item_h; - gint text_x, text_w, num_icons, icons_width, width, time_width; - CalComponent *comp; - gint min_text_x, max_text_w, text_width, line_len; - gchar *text, *end_of_line; - gboolean show_icons = TRUE, use_max_width = FALSE; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (!e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) { - if (event->canvas_item) { - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - event->canvas_item = NULL; - } - return; - } - - /* Take off the border and padding. */ - item_x += E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD; - item_w -= (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD) * 2; - item_y += E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD; - item_h -= (E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD) * 2; - - /* We don't show the icons while resizing, since we'd have to - draw them on top of the resize rect. Nor when editing. */ - num_icons = 0; - comp = event->comp; - font = GTK_WIDGET (day_view)->style->font; - - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->resize_event_num == event_num) - show_icons = FALSE; - - if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->editing_event_num == event_num) { - show_icons = FALSE; - use_max_width = TRUE; - } - -#if 0 - if (show_icons) { - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) - num_icons++; - if (ico->recur) - num_icons++; - } -#endif - - if (!event->canvas_item) { - event->canvas_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->top_canvas)->root), - e_text_get_type (), - "font_gdk", GTK_WIDGET (day_view)->style->font, - "anchor", GTK_ANCHOR_NW, - "clip", TRUE, - "max_lines", 1, - "editable", TRUE, - "use_ellipsis", TRUE, - NULL); - gtk_signal_connect (GTK_OBJECT (event->canvas_item), "event", - GTK_SIGNAL_FUNC (e_day_view_on_text_item_event), - day_view); - e_day_view_update_long_event_label (day_view, event_num); - } - - /* Calculate its position. We first calculate the ideal position which - is centered with the icons. We then make sure we haven't gone off - the left edge of the available space. Finally we make sure we don't - go off the right edge. */ - icons_width = (E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD) - * num_icons; - time_width = day_view->max_small_hour_width + day_view->colon_width - + day_view->max_minute_width; - - if (use_max_width) { - text_x = item_x; - text_w = item_w; - } else { - /* Get the requested size of the label. */ - gtk_object_get (GTK_OBJECT (event->canvas_item), - "text", &text, - NULL); - text_width = 0; - if (text) { - end_of_line = strchr (text, '\n'); - if (end_of_line) - line_len = end_of_line - text; - else - line_len = strlen (text); - text_width = gdk_text_width (font, text, line_len); - g_free (text); - } - - width = text_width + icons_width; - text_x = item_x + (item_w - width) / 2; - - min_text_x = item_x; - if (event->start > day_view->day_starts[start_day]) - min_text_x += time_width + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD; - - text_x = MAX (text_x, min_text_x); - - max_text_w = item_x + item_w - text_x; - if (event->end < day_view->day_starts[end_day + 1]) - max_text_w -= time_width + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD; - - text_w = MIN (width, max_text_w); - - /* Now take out the space for the icons. */ - text_x += icons_width; - text_w -= icons_width; - } - - text_w = MAX (text_w, 0); - gnome_canvas_item_set (event->canvas_item, - "clip_width", (gdouble) text_w, - "clip_height", (gdouble) item_h, - NULL); - e_canvas_item_move_absolute(event->canvas_item, - text_x, item_y); -} - - -/* Find the start and end days for the event. */ -gboolean -e_day_view_find_long_event_days (EDayView *day_view, - EDayViewEvent *event, - gint *start_day_return, - gint *end_day_return) -{ - gint day, start_day, end_day; - - start_day = -1; - end_day = -1; - - for (day = 0; day < day_view->days_shown; day++) { - if (start_day == -1 - && event->start < day_view->day_starts[day + 1]) - start_day = day; - if (event->end > day_view->day_starts[day]) - end_day = day; - } - - /* Sanity check. */ - if (start_day < 0 || start_day >= day_view->days_shown - || end_day < 0 || end_day >= day_view->days_shown - || end_day < start_day) { - g_warning ("Invalid date range for event"); - return FALSE; - } - - *start_day_return = start_day; - *end_day_return = end_day; - - return TRUE; -} - - -static void -e_day_view_layout_day_events (EDayView *day_view, - gint day) -{ - EDayViewEvent *event; - gint row, event_num; - guint8 *grid; - - /* This is a temporary array which keeps track of rows which are - connected. When an appointment spans multiple rows then the number - of columns in each of these rows must be the same (i.e. the maximum - of all of them). Each element in the array corresponds to one row - and contains the index of the first row in the group of connected - rows. */ - guint16 group_starts[12 * 24]; - - /* Reset the cols_per_row array, and initialize the connected rows. */ - for (row = 0; row < day_view->rows; row++) { - day_view->cols_per_row[day][row] = 0; - group_starts[row] = row; - } - - /* This is a temporary 2-d grid which is used to place events. - Each element is 0 if the position is empty, or 1 if occupied. */ - grid = g_new0 (guint8, day_view->rows * E_DAY_VIEW_MAX_COLUMNS); - - - /* Iterate over the events, finding which rows they cover, and putting - them in the first free column available. Increment the number of - events in each of the rows it covers, and make sure they are all - in one group. */ - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - e_day_view_layout_day_event (day_view, day, event, - grid, group_starts); - } - - /* Recalculate the number of columns needed in each row. */ - e_day_view_recalc_cols_per_row (day_view, day, group_starts); - - /* Iterate over the events again, trying to expand events horizontally - if there is enough space. */ - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - e_day_view_expand_day_event (day_view, day, event, grid); - } - - /* Free the grid. */ - g_free (grid); -} - - -/* Finds the first free position to place the event in. - Increments the number of events in each of the rows it covers, and makes - sure they are all in one group. */ -static void -e_day_view_layout_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid, - guint16 *group_starts) -{ - gint start_row, end_row, free_col, col, row, group_start; - - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - - event->num_columns = 0; - - /* If the event can't currently be seen, just return. */ - if (start_row >= day_view->rows || end_row < 0) - return; - - /* Make sure we don't go outside the visible times. */ - start_row = CLAMP (start_row, 0, day_view->rows - 1); - end_row = CLAMP (end_row, 0, day_view->rows - 1); - - /* Try each column until we find a free one. */ - for (col = 0; col < E_DAY_VIEW_MAX_COLUMNS; col++) { - free_col = col; - for (row = start_row; row <= end_row; row++) { - if (grid[row * E_DAY_VIEW_MAX_COLUMNS + col]) { - free_col = -1; - break; - } - } - - if (free_col != -1) - break; - } - - /* If we can't find space for the event, just return. */ - if (free_col == -1) - return; - - /* The event is assigned 1 col initially, but may be expanded later. */ - event->start_row_or_col = free_col; - event->num_columns = 1; - - /* Determine the start index of the group. */ - group_start = group_starts[start_row]; - - /* Increment number of events in each of the rows the event covers. - We use the cols_per_row array for this. It will be sorted out after - all the events have been layed out. Also make sure all the rows that - the event covers are in one group. */ - for (row = start_row; row <= end_row; row++) { - grid[row * E_DAY_VIEW_MAX_COLUMNS + free_col] = 1; - day_view->cols_per_row[day][row]++; - group_starts[row] = group_start; - } - - /* If any following rows should be in the same group, add them. */ - for (row = end_row + 1; row < day_view->rows; row++) { - if (group_starts[row] > end_row) - break; - group_starts[row] = group_start; - } -} - - -/* For each group of rows, find the max number of events in all the - rows, and set the number of cols in each of the rows to that. */ -static void -e_day_view_recalc_cols_per_row (EDayView *day_view, - gint day, - guint16 *group_starts) -{ - gint start_row = 0, row, next_start_row, max_events; - - while (start_row < day_view->rows) { - - max_events = 0; - for (row = start_row; row < day_view->rows && group_starts[row] == start_row; row++) - max_events = MAX (max_events, day_view->cols_per_row[day][row]); - - next_start_row = row; - - for (row = start_row; row < next_start_row; row++) - day_view->cols_per_row[day][row] = max_events; - - start_row = next_start_row; - } -} - - -/* Expands the event horizontally to fill any free space. */ -static void -e_day_view_expand_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid) -{ - gint start_row, end_row, col, row; - gboolean clashed; - - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - - /* Try each column until we find a free one. */ - clashed = FALSE; - for (col = event->start_row_or_col + 1; col < day_view->cols_per_row[day][start_row]; col++) { - for (row = start_row; row <= end_row; row++) { - if (grid[row * E_DAY_VIEW_MAX_COLUMNS + col]) { - clashed = TRUE; - break; - } - } - - if (clashed) - break; - - event->num_columns++; - } -} - - -/* This creates or updates the sizes of the canvas items for one day of the - main canvas. */ -static void -e_day_view_reshape_day_events (EDayView *day_view, - gint day) -{ - gint event_num; - - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - e_day_view_reshape_day_event (day_view, day, event_num); - } -} - - -static void -e_day_view_reshape_day_event (EDayView *day_view, - gint day, - gint event_num) -{ - EDayViewEvent *event; - gint item_x, item_y, item_w, item_h; - gint num_icons, icons_offset; - CalComponent *comp; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - comp = event->comp; - - if (!e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) { - if (event->canvas_item) { - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - event->canvas_item = NULL; - } - } else { - /* Skip the border and padding. */ - item_x += E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_EVENT_X_PAD; - item_w -= E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_EVENT_X_PAD * 2; - item_y += E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD; - item_h -= (E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD) * 2; - - /* We don't show the icons while resizing, since we'd have to - draw them on top of the resize rect. */ - num_icons = 0; - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE - || day_view->resize_event_day != day - || day_view->resize_event_num != event_num) { -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) - num_icons++; -#endif - if (cal_component_has_rrules (comp) - || cal_component_has_rdates (comp)) - num_icons++; - } - - if (num_icons > 0) { - if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD) * num_icons) - icons_offset = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD * 2; - else - icons_offset = (E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD) * num_icons + E_DAY_VIEW_ICON_X_PAD; - item_x += icons_offset; - item_w -= icons_offset; - } - - if (!event->canvas_item) { - event->canvas_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->main_canvas)->root), - e_text_get_type (), - "font_gdk", GTK_WIDGET (day_view)->style->font, - "anchor", GTK_ANCHOR_NW, - "line_wrap", TRUE, - "editable", TRUE, - "clip", TRUE, - "use_ellipsis", TRUE, - NULL); - gtk_signal_connect (GTK_OBJECT (event->canvas_item), - "event", - GTK_SIGNAL_FUNC (e_day_view_on_text_item_event), - day_view); - e_day_view_update_event_label (day_view, day, - event_num); - } - - item_w = MAX (item_w, 0); - gnome_canvas_item_set (event->canvas_item, - "clip_width", (gdouble) item_w, - "clip_height", (gdouble) item_h, - NULL); - e_canvas_item_move_absolute(event->canvas_item, - item_x, item_y); - } -} - - -/* This creates or resizes the horizontal bars used to resize events in the - main canvas. */ -static void -e_day_view_reshape_main_canvas_resize_bars (EDayView *day_view) -{ - gint day, event_num; - gint item_x, item_y, item_w, item_h; - gdouble x, y, w, h; - - day = day_view->resize_bars_event_day; - event_num = day_view->resize_bars_event_num; - - /* If we're not editing an event, or the event is not shown, - hide the resize bars. */ - if (day != -1 && day == day_view->drag_event_day - && event_num == day_view->drag_event_num) { - gtk_object_get (GTK_OBJECT (day_view->drag_rect_item), - "x1", &x, - "y1", &y, - "x2", &w, - "y2", &h, - NULL); - w -= x; - x++; - h -= y; - } else if (day != -1 - && e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) { - x = item_x + E_DAY_VIEW_BAR_WIDTH; - y = item_y; - w = item_w - E_DAY_VIEW_BAR_WIDTH; - h = item_h; - } else { - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - return; - } - - gnome_canvas_item_set (day_view->main_canvas_top_resize_bar_item, - "x1", x - E_DAY_VIEW_BAR_WIDTH, - "y1", y - E_DAY_VIEW_BAR_HEIGHT, - "x2", x + w - 1, - "y2", y - 1, - NULL); - gnome_canvas_item_show (day_view->main_canvas_top_resize_bar_item); - - gnome_canvas_item_set (day_view->main_canvas_bottom_resize_bar_item, - "x1", x - E_DAY_VIEW_BAR_WIDTH, - "y1", y + h, - "x2", x + w - 1, - "y2", y + h + E_DAY_VIEW_BAR_HEIGHT - 1, - NULL); - gnome_canvas_item_show (day_view->main_canvas_bottom_resize_bar_item); -} - - -static void -e_day_view_ensure_events_sorted (EDayView *day_view) -{ - gint day; - - /* Sort the long events. */ - if (!day_view->long_events_sorted) { - qsort (day_view->long_events->data, - day_view->long_events->len, - sizeof (EDayViewEvent), - e_day_view_event_sort_func); - day_view->long_events_sorted = TRUE; - } - - /* Sort the events for each day. */ - for (day = 0; day < day_view->days_shown; day++) { - if (!day_view->events_sorted[day]) { - qsort (day_view->events[day]->data, - day_view->events[day]->len, - sizeof (EDayViewEvent), - e_day_view_event_sort_func); - day_view->events_sorted[day] = TRUE; - } - } -} - - -static gint -e_day_view_event_sort_func (const void *arg1, - const void *arg2) -{ - EDayViewEvent *event1, *event2; - - event1 = (EDayViewEvent*) arg1; - event2 = (EDayViewEvent*) arg2; - - if (event1->start < event2->start) - return -1; - if (event1->start > event2->start) - return 1; - - if (event1->end > event2->end) - return -1; - if (event1->end < event2->end) - return 1; - - return 0; -} - - -static gint -e_day_view_key_press (GtkWidget *widget, GdkEventKey *event) -{ - EDayView *day_view; - CalComponent *comp; - gint day, event_num; - gchar *initial_text; - guint keyval; - gboolean stop_emission; - time_t dtstart, dtend; - const char *uid; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - day_view = E_DAY_VIEW (widget); - keyval = event->keyval; - - /* The Escape key aborts a resize operation. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - if (keyval == GDK_Escape) { - e_day_view_abort_resize (day_view, event->time); - } - return FALSE; - } - - /* Handle the cursor keys for moving & extending the selection. */ - stop_emission = TRUE; - if (event->state & GDK_SHIFT_MASK) { - switch (keyval) { - case GDK_Up: - e_day_view_cursor_key_up_shifted (day_view, event); - break; - case GDK_Down: - e_day_view_cursor_key_down_shifted (day_view, event); - break; - case GDK_Left: - e_day_view_cursor_key_left_shifted (day_view, event); - break; - case GDK_Right: - e_day_view_cursor_key_right_shifted (day_view, event); - break; - default: - stop_emission = FALSE; - break; - } - } else { - switch (keyval) { - case GDK_Up: - e_day_view_cursor_key_up (day_view, event); - break; - case GDK_Down: - e_day_view_cursor_key_down (day_view, event); - break; - case GDK_Left: - e_day_view_cursor_key_left (day_view, event); - break; - case GDK_Right: - e_day_view_cursor_key_right (day_view, event); - break; - default: - stop_emission = FALSE; - break; - } - } - if (stop_emission) - return TRUE; - - if (day_view->selection_start_day == -1) - return FALSE; - - /* Check if there is room for a new event to be typed in. If there - isn't we don't want to add an event as we will then add a new - event for every key press. */ - if (!e_day_view_check_if_new_event_fits (day_view)) { - return FALSE; - } - - /* We only want to start an edit with a return key or a simple - character. */ - if (keyval == GDK_Return) { - initial_text = NULL; - } else if ((keyval < 0x20) - || (keyval > 0xFF) - || (event->length == 0) - || (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) { - return FALSE; - } else { - initial_text = event->string; - } - - /* Add a new event covering the selected range. - Note that user_name is a global variable. */ - comp = cal_component_new (); - - e_day_view_get_selected_time_range (day_view, &dtstart, &dtend); - - /* We add the event locally and start editing it. When we get the - "update_event" callback from the server, we basically ignore it. - If we were to wait for the "update_event" callback it wouldn't be - as responsive and we may lose a few keystrokes. */ - e_day_view_add_event (comp, dtstart, dtend, day_view); - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - cal_component_get_uid (comp, &uid); - if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) { - e_day_view_start_editing_event (day_view, day, event_num, - initial_text); - day_view->editing_new_event = TRUE; - } else { - g_warning ("Couldn't find event to start editing.\n"); - } - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_key_press(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return TRUE; -} - - -static void -e_day_view_cursor_key_up_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *row; - - if (day_view->selection_in_top_canvas) - return; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - row = &day_view->selection_start_row; - else - row = &day_view->selection_end_row; - - if (*row == 0) - return; - - *row = *row - 1; - - e_day_view_ensure_rows_visible (day_view, *row, *row); - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_down_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *row; - - if (day_view->selection_in_top_canvas) - return; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - row = &day_view->selection_start_row; - else - row = &day_view->selection_end_row; - - if (*row >= day_view->rows - 1) - return; - - *row = *row + 1; - - e_day_view_ensure_rows_visible (day_view, *row, *row); - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_left_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *day; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - day = &day_view->selection_start_day; - else - day = &day_view->selection_end_day; - - if (*day == 0) - return; - - *day = *day - 1; - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_right_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *day; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - day = &day_view->selection_start_day; - else - day = &day_view->selection_end_day; - - if (*day >= day_view->days_shown - 1) - return; - - *day = *day + 1; - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_up (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_start_day == -1) { - day_view->selection_start_day = 0; - day_view->selection_start_row = 0; - } - day_view->selection_end_day = day_view->selection_start_day; - - if (day_view->selection_in_top_canvas) { - return; - } else if (day_view->selection_start_row == 0) { - day_view->selection_in_top_canvas = TRUE; - day_view->selection_start_row = -1; - } else { - day_view->selection_start_row--; - } - day_view->selection_end_row = day_view->selection_start_row; - - if (!day_view->selection_in_top_canvas) - e_day_view_ensure_rows_visible (day_view, - day_view->selection_start_row, - day_view->selection_end_row); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_down (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_start_day == -1) { - day_view->selection_start_day = 0; - day_view->selection_start_row = 0; - } - day_view->selection_end_day = day_view->selection_start_day; - - if (day_view->selection_in_top_canvas) { - day_view->selection_in_top_canvas = FALSE; - day_view->selection_start_row = 0; - } else if (day_view->selection_start_row >= day_view->rows - 1) { - return; - } else { - day_view->selection_start_row++; - } - day_view->selection_end_row = day_view->selection_start_row; - - if (!day_view->selection_in_top_canvas) - e_day_view_ensure_rows_visible (day_view, - day_view->selection_start_row, - day_view->selection_end_row); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_left (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_start_day == 0) { - gnome_calendar_previous (day_view->calendar); - } else { - day_view->selection_start_day--; - day_view->selection_end_day--; - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -static void -e_day_view_cursor_key_right (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_end_day == day_view->days_shown - 1) { - gnome_calendar_next (day_view->calendar); - } else { - day_view->selection_start_day++; - day_view->selection_end_day++; - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -static gboolean -e_day_view_check_if_new_event_fits (EDayView *day_view) -{ - gint day, start_row, end_row, row; - - day = day_view->selection_start_day; - start_row = day_view->selection_start_row; - end_row = day_view->selection_end_row; - - /* Long events always fit, since we keep adding rows to the top - canvas. */ - if (day != day_view->selection_end_day) - return FALSE; - if (start_row == 0 && end_row == day_view->rows) - return FALSE; - - /* If any of the rows already have E_DAY_VIEW_MAX_COLUMNS columns, - return FALSE. */ - for (row = start_row; row <= end_row; row++) { - if (day_view->cols_per_row[day][row] >= E_DAY_VIEW_MAX_COLUMNS) - return FALSE; - } - - return TRUE; -} - - -static void -e_day_view_ensure_rows_visible (EDayView *day_view, - gint start_row, - gint end_row) -{ - GtkAdjustment *adj; - gfloat value, min_value, max_value; - - adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - - value = adj->value; - - min_value = (end_row + 1) * day_view->row_height - adj->page_size; - if (value < min_value) - value = min_value; - - max_value = start_row * day_view->row_height; - if (value > max_value) - value = max_value; - - if (value != adj->value) { - adj->value = value; - gtk_adjustment_value_changed (adj); - } -} - - -static void -e_day_view_start_editing_event (EDayView *day_view, - gint day, - gint event_num, - gchar *initial_text) -{ - EDayViewEvent *event; - ETextEventProcessor *event_processor = NULL; - ETextEventProcessorCommand command; - - /* If we are already editing the event, just return. */ - if (day == day_view->editing_event_day - && event_num == day_view->editing_event_num) - return; - - if (day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - } - - /* If the event is not shown, don't try to edit it. */ - if (!event->canvas_item) - return; - - /* We must grab the focus before setting the initial text, since - grabbing the focus will result in a call to - e_day_view_on_editing_started(), which will reset the text to get - rid of the start and end times. */ - e_canvas_item_grab_focus (event->canvas_item); - - if (initial_text) { - gnome_canvas_item_set (event->canvas_item, - "text", initial_text, - NULL); - } - - /* Try to move the cursor to the end of the text. */ - gtk_object_get (GTK_OBJECT (event->canvas_item), - "event_processor", &event_processor, - NULL); - if (event_processor) { - command.action = E_TEP_MOVE; - command.position = E_TEP_END_OF_BUFFER; - gtk_signal_emit_by_name (GTK_OBJECT (event_processor), - "command", &command); - } -} - - -/* This stops the current edit. If accept is TRUE the event summary is update, - else the edit is cancelled. */ -static void -e_day_view_stop_editing_event (EDayView *day_view) -{ - GtkWidget *toplevel; - - /* Check we are editing an event. */ - if (day_view->editing_event_day == -1) - return; - - /* Set focus to the toplevel so the item loses focus. */ - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (day_view)); - if (toplevel && GTK_IS_WINDOW (toplevel)) - gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); -} - - -static gboolean -e_day_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EDayView *day_view) -{ - switch (event->type) { - case GDK_KEY_PRESS: - if (event && event->key.keyval == GDK_Return) { - /* We set the keyboard focus to the EDayView, so the - EText item loses it and stops the edit. */ - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - /* Stop the signal last or we will also stop any - other events getting to the EText item. */ - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - return TRUE; - } - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - /* Only let the EText handle the event while editing. */ - if (!E_TEXT (item)->editing) - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - break; - case GDK_FOCUS_CHANGE: - if (event->focus_change.in) - e_day_view_on_editing_started (day_view, item); - else - e_day_view_on_editing_stopped (day_view, item); - - return FALSE; - default: - break; - } - - return FALSE; -} - - -static void -e_day_view_on_editing_started (EDayView *day_view, - GnomeCanvasItem *item) -{ - gint day, event_num; - - if (!e_day_view_find_event_from_item (day_view, item, - &day, &event_num)) - return; - -#if 0 - g_print ("In e_day_view_on_editing_started Day:%i Event:%i\n", - day, event_num); -#endif - - /* FIXME: This is a temporary workaround for a bug which seems to stop - us getting focus_out signals. It is not a complete fix since if we - don't get focus_out signals we don't save the appointment text so - this may be lost. */ - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) - return; - - day_view->editing_event_day = day; - day_view->editing_event_num = event_num; - - if (day == E_DAY_VIEW_LONG_EVENT) { - e_day_view_reshape_long_event (day_view, event_num); - } else { - day_view->resize_bars_event_day = day; - day_view->resize_bars_event_num = event_num; - e_day_view_update_event_label (day_view, day, event_num); - e_day_view_reshape_main_canvas_resize_bars (day_view); - } -} - - -static void -e_day_view_on_editing_stopped (EDayView *day_view, - GnomeCanvasItem *item) -{ - gint day, event_num; - gboolean editing_long_event = FALSE; - EDayViewEvent *event; - gchar *text = NULL; - CalComponentText summary; - const char *uid; - - /* Note: the item we are passed here isn't reliable, so we just stop - the edit of whatever item was being edited. We also receive this - event twice for some reason. */ - day = day_view->editing_event_day; - event_num = day_view->editing_event_num; - - /* If no item is being edited, just return. */ - if (day == -1) - return; - -#if 0 - g_print ("In e_day_view_on_editing_stopped Day:%i Event:%i\n", - day, event_num); -#endif - - if (day == E_DAY_VIEW_LONG_EVENT) { - editing_long_event = TRUE; - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Hide the horizontal bars. */ - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } - - /* Reset the edit fields. */ - day_view->editing_event_day = -1; - day_view->editing_event_num = -1; - day_view->editing_new_event = FALSE; - - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - - /* Check that the event is still valid. */ - cal_component_get_uid (event->comp, &uid); - if (!uid) - return; - - gtk_object_get (GTK_OBJECT (event->canvas_item), - "text", &text, - NULL); - - /* Only update the summary if necessary. */ - cal_component_get_summary (event->comp, &summary); - if (text && summary.value && !strcmp (text, summary.value)) { - g_free (text); - - if (day == E_DAY_VIEW_LONG_EVENT) - e_day_view_reshape_long_event (day_view, event_num); - return; - } - - cal_component_set_summary (event->comp, &summary); - g_free (text); - - if (!cal_client_update_object (day_view->calendar->client, event->comp)) - g_message ("e_day_view_on_editing_stopped(): Could not update the object!"); -} - - -/* FIXME: It is possible that we may produce an invalid time due to daylight - saving times (i.e. when clocks go forward there is a range of time which - is not valid). I don't know the best way to handle daylight saving time. */ -static time_t -e_day_view_convert_grid_position_to_time (EDayView *day_view, - gint col, - gint row) -{ - struct tm *tmp_tm; - time_t val; - gint minutes; - - /* Calulate the number of minutes since the start of the day. */ - minutes = day_view->first_hour_shown * 60 - + day_view->first_minute_shown - + row * day_view->mins_per_row; - - /* A special case for midnight, where we can use the start of the - next day. */ - if (minutes == 60 * 24) - return day_view->day_starts[col + 1]; - - /* We convert the start of the day to a struct tm, then set the - hour and minute, then convert it back to a time_t. */ - tmp_tm = localtime (&day_view->day_starts[col]); - - tmp_tm->tm_hour = minutes / 60; - tmp_tm->tm_min = minutes % 60; - tmp_tm->tm_isdst = -1; - - val = mktime (tmp_tm); - return val; -} - - -static gboolean -e_day_view_convert_time_to_grid_position (EDayView *day_view, - time_t time, - gint *col, - gint *row) -{ - struct tm *tmp_tm; - gint day, minutes; - - *col = *row = 0; - - if (time < day_view->lower || time >= day_view->upper) - return FALSE; - - /* We can find the column easily using the day_starts array. */ - for (day = 1; day <= day_view->days_shown; day++) { - if (time < day_view->day_starts[day]) { - *col = day - 1; - break; - } - } - - /* To find the row we need to convert the time to a struct tm, - calculate the offset in minutes from the top of the display and - divide it by the mins per row setting. */ - tmp_tm = localtime (&time); - minutes = tmp_tm->tm_hour * 60 + tmp_tm->tm_min; - minutes -= day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - - *row = minutes / day_view->mins_per_row; - - if (*row < 0 || *row >= day_view->rows) - return FALSE; - - return TRUE; -} - - -/* This starts or stops auto-scrolling when dragging a selection or resizing - an event. */ -void -e_day_view_check_auto_scroll (EDayView *day_view, - gint event_x, - gint event_y) -{ - day_view->last_mouse_x = event_x; - day_view->last_mouse_y = event_y; - - if (event_y < E_DAY_VIEW_AUTO_SCROLL_OFFSET) - e_day_view_start_auto_scroll (day_view, TRUE); - else if (event_y >= day_view->main_canvas->allocation.height - - E_DAY_VIEW_AUTO_SCROLL_OFFSET) - e_day_view_start_auto_scroll (day_view, FALSE); - else - e_day_view_stop_auto_scroll (day_view); -} - - -static void -e_day_view_start_auto_scroll (EDayView *day_view, - gboolean scroll_up) -{ - if (day_view->auto_scroll_timeout_id == 0) { - day_view->auto_scroll_timeout_id = g_timeout_add (E_DAY_VIEW_AUTO_SCROLL_TIMEOUT, e_day_view_auto_scroll_handler, day_view); - day_view->auto_scroll_delay = E_DAY_VIEW_AUTO_SCROLL_DELAY; - } - day_view->auto_scroll_up = scroll_up; -} - - -void -e_day_view_stop_auto_scroll (EDayView *day_view) -{ - if (day_view->auto_scroll_timeout_id != 0) { - gtk_timeout_remove (day_view->auto_scroll_timeout_id); - day_view->auto_scroll_timeout_id = 0; - } -} - - -static gboolean -e_day_view_auto_scroll_handler (gpointer data) -{ - EDayView *day_view; - EDayViewPosition pos; - gint scroll_x, scroll_y, new_scroll_y, canvas_x, canvas_y, row, day; - GtkAdjustment *adj; - - g_return_val_if_fail (E_IS_DAY_VIEW (data), FALSE); - - day_view = E_DAY_VIEW (data); - - GDK_THREADS_ENTER (); - - if (day_view->auto_scroll_delay > 0) { - day_view->auto_scroll_delay--; - GDK_THREADS_LEAVE (); - return TRUE; - } - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (day_view->main_canvas), - &scroll_x, &scroll_y); - - adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - - if (day_view->auto_scroll_up) - new_scroll_y = MAX (scroll_y - adj->step_increment, 0); - else - new_scroll_y = MIN (scroll_y + adj->step_increment, - adj->upper - adj->page_size); - - if (new_scroll_y != scroll_y) { - /* NOTE: This reduces flicker, but only works if we don't use - canvas items which have X windows. */ - gtk_layout_freeze (GTK_LAYOUT (day_view->main_canvas)); - - gnome_canvas_scroll_to (GNOME_CANVAS (day_view->main_canvas), - scroll_x, new_scroll_y); - - gtk_layout_thaw (GTK_LAYOUT (day_view->main_canvas)); - } - - canvas_x = day_view->last_mouse_x + scroll_x; - canvas_y = day_view->last_mouse_y + new_scroll_y; - - /* The last_mouse_x position is set to -1 when we are selecting using - the time column. In this case we set canvas_x to 0 and we ignore - the resulting day. */ - if (day_view->last_mouse_x == -1) - canvas_x = 0; - - /* Update the selection/resize/drag if necessary. */ - pos = e_day_view_convert_position_in_main_canvas (day_view, - canvas_x, canvas_y, - &day, &row, NULL); - - if (day_view->last_mouse_x == -1) - day = -1; - - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - if (day_view->selection_is_being_dragged) { - e_day_view_update_selection (day_view, day, row); - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - e_day_view_update_resize (day_view, row); - } else if (day_view->drag_item->object.flags - & GNOME_CANVAS_ITEM_VISIBLE) { - e_day_view_update_main_canvas_drag (day_view, row, - day); - } - } - - GDK_THREADS_LEAVE (); - return TRUE; -} - - -gboolean -e_day_view_get_event_position (EDayView *day_view, - gint day, - gint event_num, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h) -{ - EDayViewEvent *event; - gint start_row, end_row, cols_in_row, start_col, num_columns; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* If the event is flagged as not displayed, return FALSE. */ - if (event->num_columns == 0) - return FALSE; - - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - cols_in_row = day_view->cols_per_row[day][start_row]; - start_col = event->start_row_or_col; - num_columns = event->num_columns; - - if (cols_in_row == 0) - return FALSE; - - /* If the event is being resize, use the resize position. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == day - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) - start_row = day_view->resize_start_row; - else if (day_view->resize_drag_pos == E_DAY_VIEW_POS_BOTTOM_EDGE) - end_row = day_view->resize_end_row; - } - - *item_x = day_view->day_offsets[day] + day_view->day_widths[day] * start_col / cols_in_row; - *item_w = day_view->day_widths[day] * num_columns / cols_in_row - E_DAY_VIEW_GAP_WIDTH; - *item_w = MAX (*item_w, 0); - *item_y = start_row * day_view->row_height; - *item_h = (end_row - start_row + 1) * day_view->row_height; - - return TRUE; -} - - -gboolean -e_day_view_get_long_event_position (EDayView *day_view, - gint event_num, - gint *start_day, - gint *end_day, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h) -{ - EDayViewEvent *event; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* If the event is flagged as not displayed, return FALSE. */ - if (event->num_columns == 0) - return FALSE; - - if (!e_day_view_find_long_event_days (day_view, event, - start_day, end_day)) - return FALSE; - - /* If the event is being resize, use the resize position. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) - *start_day = day_view->resize_start_row; - else if (day_view->resize_drag_pos == E_DAY_VIEW_POS_RIGHT_EDGE) - *end_day = day_view->resize_end_row; - } - - *item_x = day_view->day_offsets[*start_day] + E_DAY_VIEW_BAR_WIDTH; - *item_w = day_view->day_offsets[*end_day + 1] - *item_x - - E_DAY_VIEW_GAP_WIDTH; - *item_w = MAX (*item_w, 0); - *item_y = (event->start_row_or_col + 1) * day_view->top_row_height; - *item_h = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP; - return TRUE; -} - - -/* Converts a position within the entire top canvas to a day & event and - a place within the event if appropriate. If event_num_return is NULL, it - simply returns the grid position without trying to find the event. */ -static EDayViewPosition -e_day_view_convert_position_in_top_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *event_num_return) -{ - EDayViewEvent *event; - gint day, row, col; - gint event_num, start_day, end_day, item_x, item_y, item_w, item_h; - - *day_return = -1; - if (event_num_return) - *event_num_return = -1; - - if (x < 0 || y < 0) - return E_DAY_VIEW_POS_OUTSIDE; - - row = y / day_view->top_row_height - 1; - - day = -1; - for (col = 1; col <= day_view->days_shown; col++) { - if (x < day_view->day_offsets[col]) { - day = col - 1; - break; - } - } - if (day == -1) - return E_DAY_VIEW_POS_OUTSIDE; - - *day_return = day; - - /* If only the grid position is wanted, return. */ - if (event_num_return == NULL) - return E_DAY_VIEW_POS_NONE; - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (event->start_row_or_col != row) - continue; - - if (!e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) - continue; - - if (x < item_x) - continue; - - if (x >= item_x + item_w) - continue; - - *event_num_return = event_num; - - if (x < item_x + E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH - + E_DAY_VIEW_LONG_EVENT_X_PAD) - return E_DAY_VIEW_POS_LEFT_EDGE; - - if (x >= item_x + item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH - - E_DAY_VIEW_LONG_EVENT_X_PAD) - return E_DAY_VIEW_POS_RIGHT_EDGE; - - return E_DAY_VIEW_POS_EVENT; - } - - return E_DAY_VIEW_POS_NONE; -} - - -/* Converts a position within the entire main canvas to a day, row, event and - a place within the event if appropriate. If event_num_return is NULL, it - simply returns the grid position without trying to find the event. */ -static EDayViewPosition -e_day_view_convert_position_in_main_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *row_return, - gint *event_num_return) -{ - gint day, row, col, event_num; - gint item_x, item_y, item_w, item_h; - - *day_return = -1; - *row_return = -1; - if (event_num_return) - *event_num_return = -1; - - /* Check the position is inside the canvas, and determine the day - and row. */ - if (x < 0 || y < 0) - return E_DAY_VIEW_POS_OUTSIDE; - - row = y / day_view->row_height; - if (row >= day_view->rows) - return E_DAY_VIEW_POS_OUTSIDE; - - day = -1; - for (col = 1; col <= day_view->days_shown; col++) { - if (x < day_view->day_offsets[col]) { - day = col - 1; - break; - } - } - if (day == -1) - return E_DAY_VIEW_POS_OUTSIDE; - - *day_return = day; - *row_return = row; - - /* If only the grid position is wanted, return. */ - if (event_num_return == NULL) - return E_DAY_VIEW_POS_NONE; - - /* Check the selected item first, since the horizontal resizing bars - may be above other events. */ - if (day_view->resize_bars_event_day == day) { - if (e_day_view_get_event_position (day_view, day, - day_view->resize_bars_event_num, - &item_x, &item_y, - &item_w, &item_h)) { - if (x >= item_x && x < item_x + item_w) { - *event_num_return = day_view->resize_bars_event_num; - if (y >= item_y - E_DAY_VIEW_BAR_HEIGHT - && y < item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT) - return E_DAY_VIEW_POS_TOP_EDGE; - if (y >= item_y + item_h - E_DAY_VIEW_EVENT_BORDER_HEIGHT - && y < item_y + item_h + E_DAY_VIEW_BAR_HEIGHT) - return E_DAY_VIEW_POS_BOTTOM_EDGE; - } - } - } - - /* Try to find the event at the found position. */ - *event_num_return = -1; - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - if (!e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) - continue; - - if (x < item_x || x >= item_x + item_w - || y < item_y || y >= item_y + item_h) - continue; - - *event_num_return = event_num; - - if (x < item_x + E_DAY_VIEW_BAR_WIDTH) - return E_DAY_VIEW_POS_LEFT_EDGE; - - if (y < item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT - + E_DAY_VIEW_EVENT_Y_PAD) - return E_DAY_VIEW_POS_TOP_EDGE; - - if (y >= item_y + item_h - E_DAY_VIEW_EVENT_BORDER_HEIGHT - - E_DAY_VIEW_EVENT_Y_PAD) - return E_DAY_VIEW_POS_BOTTOM_EDGE; - - return E_DAY_VIEW_POS_EVENT; - } - - return E_DAY_VIEW_POS_NONE; -} - - -static gint -e_day_view_on_top_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view) -{ - gint scroll_x, scroll_y; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - day_view->drag_event_x = x + scroll_x; - day_view->drag_event_y = y + scroll_y; - - e_day_view_reshape_top_canvas_drag_item (day_view); - - return TRUE; -} - - -static void -e_day_view_reshape_top_canvas_drag_item (EDayView *day_view) -{ - EDayViewPosition pos; - gint x, y, day; - - /* Calculate the day & start row of the event being dragged, using - the current mouse position. */ - x = day_view->drag_event_x; - y = day_view->drag_event_y; - pos = e_day_view_convert_position_in_top_canvas (day_view, x, y, - &day, NULL); - /* This shouldn't really happen in a drag. */ - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) - day -= day_view->drag_event_offset; - day = MAX (day, 0); - - e_day_view_update_top_canvas_drag (day_view, day); -} - - -static void -e_day_view_update_top_canvas_drag (EDayView *day_view, - gint day) -{ - EDayViewEvent *event = NULL; - gint row, num_days, start_day, end_day; - gdouble item_x, item_y, item_w, item_h; - GdkFont *font; - gchar *text; - - - /* Calculate the event's position. If the event is in the same - position we started in, we use the same columns. */ - row = day_view->rows_in_top_display + 1; - num_days = 1; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - row = event->start_row_or_col + 1; - - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - return; - - num_days = end_day - start_day + 1; - - /* Make sure we don't go off the screen. */ - day = MIN (day, day_view->days_shown - num_days); - - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - } - - /* If the position hasn't changed, just return. */ - if (day_view->drag_last_day == day - && (day_view->drag_long_event_item->object.flags - & GNOME_CANVAS_ITEM_VISIBLE)) - return; - - day_view->drag_last_day = day; - - - item_x = day_view->day_offsets[day] + E_DAY_VIEW_BAR_WIDTH; - item_w = day_view->day_offsets[day + num_days] - item_x - - E_DAY_VIEW_GAP_WIDTH; - item_y = row * day_view->top_row_height; - item_h = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP; - - - /* Set the positions of the event & associated items. */ - gnome_canvas_item_set (day_view->drag_long_event_rect_item, - "x1", item_x, - "y1", item_y, - "x2", item_x + item_w - 1, - "y2", item_y + item_h - 1, - NULL); - - font = GTK_WIDGET (day_view)->style->font; - gnome_canvas_item_set (day_view->drag_long_event_item, - "font_gdk", font, - "clip_width", item_w - (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD) * 2, - "clip_height", item_h - (E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD) * 2, - NULL); - e_canvas_item_move_absolute(day_view->drag_long_event_item, - item_x + E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD, - item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD); - - if (!(day_view->drag_long_event_rect_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - gnome_canvas_item_raise_to_top (day_view->drag_long_event_rect_item); - gnome_canvas_item_show (day_view->drag_long_event_rect_item); - } - - /* Set the text, if necessary. We don't want to set the text every - time it moves, so we check if it is currently invisible and only - set the text then. */ - if (!(day_view->drag_long_event_item->object.flags - & GNOME_CANVAS_ITEM_VISIBLE)) { - CalComponentText summary; - - cal_component_get_summary (event->comp, &summary); - if (event) { - cal_component_get_summary (event->comp, &summary); - text = g_strdup (summary.value); - } else { - text = NULL; - } - - gnome_canvas_item_set (day_view->drag_long_event_item, - "text", text ? text : "", - NULL); - gnome_canvas_item_raise_to_top (day_view->drag_long_event_item); - gnome_canvas_item_show (day_view->drag_long_event_item); - - g_free (text); - } -} - - -static gint -e_day_view_on_main_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view) -{ - gint scroll_x, scroll_y; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - day_view->drag_event_x = x + scroll_x; - day_view->drag_event_y = y + scroll_y; - - e_day_view_reshape_main_canvas_drag_item (day_view); - e_day_view_reshape_main_canvas_resize_bars (day_view); - - e_day_view_check_auto_scroll (day_view, x, y); - - return TRUE; -} - - -static void -e_day_view_reshape_main_canvas_drag_item (EDayView *day_view) -{ - EDayViewPosition pos; - gint x, y, day, row; - - /* Calculate the day & start row of the event being dragged, using - the current mouse position. */ - x = day_view->drag_event_x; - y = day_view->drag_event_y; - pos = e_day_view_convert_position_in_main_canvas (day_view, x, y, - &day, &row, NULL); - /* This shouldn't really happen in a drag. */ - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return; - - if (day_view->drag_event_day != -1 - && day_view->drag_event_day != E_DAY_VIEW_LONG_EVENT) - row -= day_view->drag_event_offset; - row = MAX (row, 0); - - e_day_view_update_main_canvas_drag (day_view, row, day); -} - - -static void -e_day_view_update_main_canvas_drag (EDayView *day_view, - gint row, - gint day) -{ - EDayViewEvent *event = NULL; - gint cols_in_row, start_col, num_columns, num_rows, start_row, end_row; - gdouble item_x, item_y, item_w, item_h; - GdkFont *font; - gchar *text; - - /* If the position hasn't changed, just return. */ - if (day_view->drag_last_day == day - && day_view->drag_last_row == row - && (day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) - return; - - day_view->drag_last_day = day; - day_view->drag_last_row = row; - - /* Calculate the event's position. If the event is in the same - position we started in, we use the same columns. */ - cols_in_row = 1; - start_col = 0; - num_columns = 1; - num_rows = 1; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - num_rows = end_row - start_row + 1; - } - - if (day_view->drag_event_day == day && start_row == row) { - cols_in_row = day_view->cols_per_row[day][row]; - start_col = event->start_row_or_col; - num_columns = event->num_columns; - } - - item_x = day_view->day_offsets[day] - + day_view->day_widths[day] * start_col / cols_in_row; - item_w = day_view->day_widths[day] * num_columns / cols_in_row - - E_DAY_VIEW_GAP_WIDTH; - item_y = row * day_view->row_height; - item_h = num_rows * day_view->row_height; - - /* Set the positions of the event & associated items. */ - gnome_canvas_item_set (day_view->drag_rect_item, - "x1", item_x + E_DAY_VIEW_BAR_WIDTH - 1, - "y1", item_y, - "x2", item_x + item_w - 1, - "y2", item_y + item_h - 1, - NULL); - - gnome_canvas_item_set (day_view->drag_bar_item, - "x1", item_x, - "y1", item_y, - "x2", item_x + E_DAY_VIEW_BAR_WIDTH - 1, - "y2", item_y + item_h - 1, - NULL); - - font = GTK_WIDGET (day_view)->style->font; - gnome_canvas_item_set (day_view->drag_item, - "font_gdk", font, - "clip_width", item_w - E_DAY_VIEW_BAR_WIDTH - E_DAY_VIEW_EVENT_X_PAD * 2, - "clip_height", item_h - (E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD) * 2, - NULL); - e_canvas_item_move_absolute(event->canvas_item, - item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_EVENT_X_PAD, - item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD); - - if (!(day_view->drag_bar_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - gnome_canvas_item_raise_to_top (day_view->drag_bar_item); - gnome_canvas_item_show (day_view->drag_bar_item); - } - - if (!(day_view->drag_rect_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - gnome_canvas_item_raise_to_top (day_view->drag_rect_item); - gnome_canvas_item_show (day_view->drag_rect_item); - } - - /* Set the text, if necessary. We don't want to set the text every - time it moves, so we check if it is currently invisible and only - set the text then. */ - if (!(day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - CalComponentText summary; - - if (event) { - cal_component_get_summary (event->comp, &summary); - text = g_strdup (summary.value); - } else { - text = NULL; - } - - gnome_canvas_item_set (day_view->drag_item, - "text", text ? text : "", - NULL); - gnome_canvas_item_raise_to_top (day_view->drag_item); - gnome_canvas_item_show (day_view->drag_item); - - g_free (text); - } -} - - -static void -e_day_view_on_top_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view) -{ - day_view->drag_last_day = -1; - - gnome_canvas_item_hide (day_view->drag_long_event_rect_item); - gnome_canvas_item_hide (day_view->drag_long_event_item); -} - - -static void -e_day_view_on_main_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view) -{ - day_view->drag_last_day = -1; - - e_day_view_stop_auto_scroll (day_view); - - gnome_canvas_item_hide (day_view->drag_rect_item); - gnome_canvas_item_hide (day_view->drag_bar_item); - gnome_canvas_item_hide (day_view->drag_item); - - /* Hide the resize bars if they are being used in the drag. */ - if (day_view->drag_event_day == day_view->resize_bars_event_day - && day_view->drag_event_num == day_view->resize_bars_event_num) { - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } -} - - -static void -e_day_view_on_drag_begin (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - - day = day_view->drag_event_day; - event_num = day_view->drag_event_num; - - /* These should both be set. */ - g_return_if_fail (day != -1); - g_return_if_fail (event_num != -1); - - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - else - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Hide the text item, since it will be shown in the special drag - items. */ - gnome_canvas_item_hide (event->canvas_item); -} - - -static void -e_day_view_on_drag_end (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - - day = day_view->drag_event_day; - event_num = day_view->drag_event_num; - - /* If the calendar has already been updated in drag_data_received() - we just return. */ - if (day == -1 || event_num == -1) - return; - - if (day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - gtk_widget_queue_draw (day_view->top_canvas); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - gtk_widget_queue_draw (day_view->main_canvas); - } - - /* Show the text item again. */ - gnome_canvas_item_show (event->canvas_item); - - day_view->drag_event_day = -1; - day_view->drag_event_num = -1; -} - - -static void -e_day_view_on_drag_data_get (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - const char *event_uid; - - day = day_view->drag_event_day; - event_num = day_view->drag_event_num; - - /* These should both be set. */ - g_return_if_fail (day != -1); - g_return_if_fail (event_num != -1); - - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - - cal_component_get_uid (event->comp, &event_uid); - - g_return_if_fail (event_uid != NULL); - - if (info == TARGET_CALENDAR_EVENT) { - gtk_selection_data_set (selection_data, selection_data->target, - 8, event_uid, strlen (event_uid)); - } -} - - -static void -e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view) -{ - EDayViewEvent *event=NULL; - EDayViewPosition pos; - gint day, start_day, end_day, num_days; - gint start_offset, end_offset; - gchar *event_uid; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - if ((data->length >= 0) && (data->format == 8)) { - pos = e_day_view_convert_position_in_top_canvas (day_view, - x, y, &day, - NULL); - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - const char *uid; - num_days = 1; - start_offset = 0; - end_offset = -1; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - day -= day_view->drag_event_offset; - day = MAX (day, 0); - - e_day_view_find_long_event_days (day_view, - event, - &start_day, - &end_day); - num_days = end_day - start_day + 1; - /* Make sure we don't go off the screen. */ - day = MIN (day, day_view->days_shown - num_days); - - start_offset = event->start_minute; - end_offset = event->end_minute; - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - } - - event_uid = data->data; - - cal_component_get_uid (event->comp, &uid); - - if (!event_uid || !uid || strcmp (event_uid, uid)) - g_warning ("Unexpected event UID"); - - /* We use a temporary shallow of the comp since we - don't want to change the original comp here. - Otherwise we would not detect that the event's time - had changed in the "update_event" callback. */ - - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - dt = day_view->day_starts[day] + start_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - if (end_offset == -1 || end_offset == 0) - dt = day_view->day_starts[day + num_days]; - else - dt = day_view->day_starts[day + num_days - 1] + end_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - gtk_drag_finish (context, TRUE, TRUE, time); - - /* Reset this since it will be invalid. */ - day_view->drag_event_day = -1; - - /* Show the text item again, just in case it hasn't - moved. If we don't do this it may not appear. */ - if (event->canvas_item) - gnome_canvas_item_show (event->canvas_item); - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_top_canvas_drag_data_received(): Could " - "not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return; - } - } - - gtk_drag_finish (context, FALSE, FALSE, time); -} - - -static void -e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view) -{ - EDayViewEvent *event = NULL; - EDayViewPosition pos; - gint day, row, start_row, end_row, num_rows, scroll_x, scroll_y; - gint start_offset, end_offset; - gchar *event_uid; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - x += scroll_x; - y += scroll_y; - - if ((data->length >= 0) && (data->format == 8)) { - pos = e_day_view_convert_position_in_main_canvas (day_view, - x, y, &day, - &row, NULL); - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - const char *uid; - num_rows = 1; - start_offset = 0; - end_offset = 0; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - row -= day_view->drag_event_offset; - - /* Calculate time offset from start row. */ - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - num_rows = end_row - start_row + 1; - - start_offset = event->start_minute % day_view->mins_per_row; - end_offset = event->end_minute % day_view->mins_per_row; - if (end_offset != 0) - end_offset = day_view->mins_per_row - end_offset; - } - - event_uid = data->data; - - cal_component_get_uid (event->comp, &uid); - if (!event_uid || !uid || strcmp (event_uid, uid)) - g_warning ("Unexpected event UID"); - - /* We use a temporary shallow copy of comp since we - don't want to change the original comp here. - Otherwise we would not detect that the event's time - had changed in the "update_event" callback. */ - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - dt = e_day_view_convert_grid_position_to_time (day_view, day, row) + start_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - dt = e_day_view_convert_grid_position_to_time (day_view, day, row + num_rows) - end_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - gtk_drag_finish (context, TRUE, TRUE, time); - - /* Reset this since it will be invalid. */ - day_view->drag_event_day = -1; - - /* Show the text item again, just in case it hasn't - moved. If we don't do this it may not appear. */ - if (event->canvas_item) - gnome_canvas_item_show (event->canvas_item); - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_main_canvas_drag_data_received(): " - "Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return; - } - } - - gtk_drag_finish (context, FALSE, FALSE, time); -} - - - - - diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h deleted file mode 100644 index 955ef0541c..0000000000 --- a/calendar/gui/e-day-view.h +++ /dev/null @@ -1,504 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_DAY_VIEW_H_ -#define _E_DAY_VIEW_H_ - -#include <time.h> -#include <gtk/gtktable.h> -#include <libgnomeui/gnome-canvas.h> - -#include "gnome-cal.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayView - displays the Day & Work-Week views of the calendar. - */ - -/* The maximum number of days shown. We use 7 since we only show 1 week max. */ -#define E_DAY_VIEW_MAX_DAYS 7 - -/* This is used as a special code to signify a long event instead of the day - of a normal event. */ -#define E_DAY_VIEW_LONG_EVENT E_DAY_VIEW_MAX_DAYS - -/* The maximum number of columns of appointments within a day. */ -#define E_DAY_VIEW_MAX_COLUMNS 6 - -/* The width of the gap between appointments. This should be at least - E_DAY_VIEW_BAR_WIDTH, since in the top canvas we use this space to draw - the triangle to represent continuing events. */ -#define E_DAY_VIEW_GAP_WIDTH 8 - -/* The width of the bars down the left of each column and appointment. - This includes the borders on each side of it. */ -#define E_DAY_VIEW_BAR_WIDTH 8 - -/* The height of the horizontal bar above & beneath the selected event. - This includes the borders on the top and bottom. */ -#define E_DAY_VIEW_BAR_HEIGHT 6 - -/* The size of the reminder & recurrence icons, and padding around them. */ -#define E_DAY_VIEW_ICON_WIDTH 16 -#define E_DAY_VIEW_ICON_HEIGHT 16 -#define E_DAY_VIEW_ICON_X_PAD 0 -#define E_DAY_VIEW_ICON_Y_PAD 0 - -/* The size of the border around the event. */ -#define E_DAY_VIEW_EVENT_BORDER_WIDTH 1 -#define E_DAY_VIEW_EVENT_BORDER_HEIGHT 1 - -/* The padding on each side of the event text. */ -#define E_DAY_VIEW_EVENT_X_PAD 2 -#define E_DAY_VIEW_EVENT_Y_PAD 1 - -/* The padding on each side of the event text for events in the top canvas. */ -#define E_DAY_VIEW_LONG_EVENT_X_PAD 2 -#define E_DAY_VIEW_LONG_EVENT_Y_PAD 2 - -/* The size of the border around the long events in the top canvas. */ -#define E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH 1 -#define E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT 1 - -/* The space between the time and the icon/text in the top canvas. */ -#define E_DAY_VIEW_LONG_EVENT_TIME_X_PAD 2 - -/* The gap between rows in the top canvas. */ -#define E_DAY_VIEW_TOP_CANVAS_Y_GAP 2 - - -/* These are used to specify the type of an appointment. They match those - used in EMeetingTimeSelector. */ -typedef enum -{ - E_DAY_VIEW_BUSY_TENTATIVE = 0, - E_DAY_VIEW_BUSY_OUT_OF_OFFICE = 1, - E_DAY_VIEW_BUSY_BUSY = 2, - - E_DAY_VIEW_BUSY_LAST = 3 -} EDayViewBusyType; - -/* This is used to specify the format used when displaying the dates. - The full format is like 'September 12'. The abbreviated format is like - 'Sep 12'. The short format is like '12'. The actual format used is - determined in style_set(), once we know the font being used. */ -typedef enum -{ - E_DAY_VIEW_DATE_FULL, - E_DAY_VIEW_DATE_ABBREVIATED, - E_DAY_VIEW_DATE_SHORT -} EDayViewDateFormat; - -/* These index our colors array. */ -typedef enum -{ - E_DAY_VIEW_COLOR_BG_WORKING, - E_DAY_VIEW_COLOR_BG_NOT_WORKING, - E_DAY_VIEW_COLOR_EVENT_VBAR, - - E_DAY_VIEW_COLOR_EVENT_BACKGROUND, - E_DAY_VIEW_COLOR_EVENT_BORDER, - - E_DAY_VIEW_COLOR_LAST -} EDayViewColors; - -/* These specify which part of the selection we are dragging, if any. */ -typedef enum -{ - E_DAY_VIEW_DRAG_START, - E_DAY_VIEW_DRAG_END -} EDayViewDragPosition; - -/* Specifies the position of the mouse. */ -typedef enum -{ - E_DAY_VIEW_POS_OUTSIDE, - E_DAY_VIEW_POS_NONE, - E_DAY_VIEW_POS_EVENT, - E_DAY_VIEW_POS_LEFT_EDGE, - E_DAY_VIEW_POS_RIGHT_EDGE, - E_DAY_VIEW_POS_TOP_EDGE, - E_DAY_VIEW_POS_BOTTOM_EDGE -} EDayViewPosition; - -typedef struct _EDayViewEvent EDayViewEvent; -struct _EDayViewEvent { - CalComponent *comp; - time_t start; - time_t end; - guint8 start_row_or_col;/* The start column for normal events, or the - start row for long events. */ - guint8 num_columns; /* 0 indicates not displayed. For long events - this is just 1 if the event is shown. */ - guint16 start_minute; /* Offsets from the start of the display. */ - guint16 end_minute; - GnomeCanvasItem *canvas_item; -}; - - -#define E_DAY_VIEW(obj) GTK_CHECK_CAST (obj, e_day_view_get_type (), EDayView) -#define E_DAY_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_day_view_get_type (), EDayViewClass) -#define E_IS_DAY_VIEW(obj) GTK_CHECK_TYPE (obj, e_day_view_get_type ()) - - -typedef struct _EDayView EDayView; -typedef struct _EDayViewClass EDayViewClass; - -struct _EDayView -{ - GtkTable table; - - /* The top canvas where the dates and long appointments are shown. */ - GtkWidget *top_canvas; - GnomeCanvasItem *top_canvas_item; - - /* The main canvas where the rest of the appointments are shown. */ - GtkWidget *main_canvas; - GnomeCanvasItem *main_canvas_item; - - /* The canvas displaying the times of the day. */ - GtkWidget *time_canvas; - GnomeCanvasItem *time_canvas_item; - - GtkWidget *vscrollbar; - - /* The calendar we are associated with. */ - GnomeCalendar *calendar; - - /* The start and end of the day shown. */ - time_t lower; - time_t upper; - - /* The number of days we are showing. Usually 1 or 5. Maybe 6 or 7. */ - gint days_shown; - - /* The start of each day & an extra element to hold the last time. */ - time_t day_starts[E_DAY_VIEW_MAX_DAYS + 1]; - - - /* An array of EDayViewEvent elements for the top view and each day. */ - GArray *long_events; - GArray *events[E_DAY_VIEW_MAX_DAYS]; - - /* These are set to FALSE whenever an event in the corresponding array - is changed. Any function that needs the events sorted calls - e_day_view_ensure_events_sorted(). */ - gboolean long_events_sorted; - gboolean events_sorted[E_DAY_VIEW_MAX_DAYS]; - - /* This is TRUE if we need to relayout the events before drawing. */ - gboolean long_events_need_layout; - gboolean need_layout[E_DAY_VIEW_MAX_DAYS]; - - /* This is TRUE if we need to reshape the canvas items, but a full - layout is not necessary. */ - gboolean long_events_need_reshape; - gboolean need_reshape[E_DAY_VIEW_MAX_DAYS]; - - /* The number of minutes per row. 5, 10, 15, 30 or 60. */ - gint mins_per_row; - - /* The number of rows needed, depending on the times shown and the - minutes per row. */ - gint rows; - - /* The height of each row. */ - gint row_height; - - /* The number of rows in the top display. */ - gint rows_in_top_display; - - /* The height of each row in the top canvas. */ - gint top_row_height; - - /* The first and last times shown in the display. The last time isn't - included in the range. Default is 0:00-24:00 */ - gint first_hour_shown; - gint first_minute_shown; - gint last_hour_shown; - gint last_minute_shown; - - /* The start and end of the work day, rounded to the nearest row. */ - gint work_day_start_hour; - gint work_day_start_minute; - gint work_day_end_hour; - gint work_day_end_minute; - - /* This is set to TRUE when the widget is created, so it scrolls to - the start of the working day when first shown. */ - gboolean scroll_to_work_day; - - /* This is the width & offset of each of the day columns in the - display. */ - gint day_widths[E_DAY_VIEW_MAX_DAYS]; - gint day_offsets[E_DAY_VIEW_MAX_DAYS + 1]; - - /* An array holding the number of columns in each row, in each day. */ - guint8 cols_per_row[E_DAY_VIEW_MAX_DAYS][12 * 24]; - - /* Sizes of the various time strings. */ - gint large_hour_widths[24]; - gint small_hour_widths[24]; - gint minute_widths[12]; /* intervals of 5 minutes. */ - gint max_small_hour_width; - gint max_large_hour_width; - gint max_minute_width; - gint colon_width; - - /* This specifies how we are displaying the dates at the top. */ - EDayViewDateFormat date_format; - - /* These are the maximum widths of the different types of dates. */ - gint long_format_width; - gint abbreviated_format_width; - - /* The large font use to display the hours. I don't think we need a - fontset since we only display numbers. */ - GdkFont *large_font; - - /* The GC used for painting in different colors. */ - GdkGC *main_gc; - - /* The icons. */ - GdkPixmap *reminder_icon; - GdkBitmap *reminder_mask; - GdkPixmap *recurrence_icon; - GdkBitmap *recurrence_mask; - - /* Colors for drawing. */ - GdkColor colors[E_DAY_VIEW_COLOR_LAST]; - - /* The normal & resizing cursors. */ - GdkCursor *normal_cursor; - GdkCursor *move_cursor; - GdkCursor *resize_width_cursor; - GdkCursor *resize_height_cursor; - - /* This remembers the last cursor set on the window. */ - GdkCursor *last_cursor_set_in_top_canvas; - GdkCursor *last_cursor_set_in_main_canvas; - - /* - * Editing, Selection & Dragging data - */ - - /* The horizontal bars to resize events in the main canvas. */ - GnomeCanvasItem *main_canvas_top_resize_bar_item; - GnomeCanvasItem *main_canvas_bottom_resize_bar_item; - - /* The event currently being edited. The day is -1 if no event is - being edited, or E_DAY_VIEW_LONG_EVENT if a long event is edited. */ - gint editing_event_day; - gint editing_event_num; - - /* This is TRUE if we are editing an event which we have just created. - We ignore the "update_event" callback which we will get from the - server when the event is added. */ - gboolean editing_new_event; - - /* This is a GnomeCanvasRect which is placed around an item while it - is being resized, so we can raise it above all other EText items. */ - GnomeCanvasItem *resize_long_event_rect_item; - GnomeCanvasItem *resize_rect_item; - GnomeCanvasItem *resize_bar_item; - - /* The event for which a popup menu is being displayed, as above. */ - gint popup_event_day; - gint popup_event_num; - - /* The currently selected region. If selection_start_day is -1 there is - no current selection. If start_row or end_row is -1 then the - selection is in the top canvas. */ - gint selection_start_day; - gint selection_end_day; - gint selection_start_row; - gint selection_end_row; - - /* This is TRUE if the selection is currently being dragged using the - mouse. */ - gboolean selection_is_being_dragged; - - /* This specifies which end of the selection is being dragged. */ - EDayViewDragPosition selection_drag_pos; - - /* This is TRUE if the selection is in the top canvas only (i.e. if the - last motion event was in the top canvas). */ - gboolean selection_in_top_canvas; - - /* The last mouse position, relative to the main canvas window. - Used when auto-scrolling to update the selection. */ - gint last_mouse_x; - gint last_mouse_y; - - /* Auto-scroll info for when selecting an area or dragging an item. */ - gint auto_scroll_timeout_id; - gint auto_scroll_delay; - gboolean auto_scroll_up; - - /* These are used for the resize bars. */ - gint resize_bars_event_day; - gint resize_bars_event_num; - - /* These are used when resizing events. */ - gint resize_event_day; - gint resize_event_num; - EDayViewPosition resize_drag_pos; - gint resize_start_row; - gint resize_end_row; - - /* This is the event the mouse button was pressed on. If the button - is released we start editing it, but if the mouse is dragged we set - this to -1. */ - gint pressed_event_day; - gint pressed_event_num; - - /* These are used when dragging events. If drag_event_day is not -1 we - know that we are dragging one of the EDayView events around. */ - gint drag_event_day; - gint drag_event_num; - - /* The last mouse position when dragging, in the entire canvas. */ - gint drag_event_x; - gint drag_event_y; - - /* The offset of the mouse from the top of the event, in rows. - In the top canvas this is the offset from the left, in days. */ - gint drag_event_offset; - - /* The last day & row dragged to, so we know when we need to update - the dragged event's position. */ - gint drag_last_day; - gint drag_last_row; - - /* This is a GnomeCanvasRect which is placed around an item while it - is being resized, so we can raise it above all other EText items. */ - GnomeCanvasItem *drag_long_event_rect_item; - GnomeCanvasItem *drag_long_event_item; - GnomeCanvasItem *drag_rect_item; - GnomeCanvasItem *drag_bar_item; - GnomeCanvasItem *drag_item; -}; - -struct _EDayViewClass -{ - GtkTableClass parent_class; -}; - - -GtkType e_day_view_get_type (void); -GtkWidget* e_day_view_new (void); - -void e_day_view_set_calendar (EDayView *day_view, - GnomeCalendar *calendar); - -/* This sets the selected time range. The EDayView will show the day or week - corresponding to the start time. If the start_time & end_time are not equal - and are both visible in the view, then the selection is set to those times, - otherwise it is set to 1 hour from the start of the working day. */ -void e_day_view_set_selected_time_range (EDayView *day_view, - time_t start_time, - time_t end_time); - -/* Returns the selected time range. */ -void e_day_view_get_selected_time_range (EDayView *day_view, - time_t *start_time, - time_t *end_time); - -/* This reloads all calendar events. */ -void e_day_view_update_all_events (EDayView *day_view); - -/* This is called when one event has been added or updated. */ -void e_day_view_update_event (EDayView *day_view, - const gchar *uid); - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void e_day_view_remove_event (EDayView *day_view, - const gchar *uid); - -/* The number of days shown in the EDayView, from 1 to 7. This is normally - either 1 or 5 (for the Work-Week view). */ -gint e_day_view_get_days_shown (EDayView *day_view); -void e_day_view_set_days_shown (EDayView *day_view, - gint days_shown); - -/* This specifies how many minutes are represented by one row in the display. - It can be 60, 30, 15, 10 or 5. The default is 30. */ -gint e_day_view_get_mins_per_row (EDayView *day_view); -void e_day_view_set_mins_per_row (EDayView *day_view, - gint mins_per_row); - - - -/* - * Internal functions called by the associated canvas items. - */ -void e_day_view_check_layout (EDayView *day_view); -gint e_day_view_convert_time_to_row (EDayView *day_view, - gint hour, - gint minute); -gint e_day_view_convert_time_to_position (EDayView *day_view, - gint hour, - gint minute); -gboolean e_day_view_get_event_position (EDayView *day_view, - gint day, - gint event_num, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h); -gboolean e_day_view_get_long_event_position (EDayView *day_view, - gint event_num, - gint *start_day, - gint *end_day, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h); -gboolean e_day_view_find_long_event_days (EDayView *day_view, - EDayViewEvent *event, - gint *start_day, - gint *end_day); - -void e_day_view_start_selection (EDayView *day_view, - gint day, - gint row); -void e_day_view_update_selection (EDayView *day_view, - gint day, - gint row); -void e_day_view_finish_selection (EDayView *day_view); - -void e_day_view_check_auto_scroll (EDayView *day_view, - gint event_x, - gint event_y); -void e_day_view_stop_auto_scroll (EDayView *day_view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_H_ */ diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c deleted file mode 100644 index f8812f6c33..0000000000 --- a/calendar/gui/e-week-view-event-item.c +++ /dev/null @@ -1,753 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EWeekViewEventItem - displays the background, times and icons for an event - * in the week/month views. A separate EText canvas item is used to display & - * edit the text. - */ - -#include <config.h> -#include "../widgets/e-text/e-text.h" -#include "e-week-view-event-item.h" - -static void e_week_view_event_item_class_init (EWeekViewEventItemClass *class); -static void e_week_view_event_item_init (EWeekViewEventItem *wveitem); - -static void e_week_view_event_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_week_view_event_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_week_view_event_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint icon_x, - gint icon_y, - gint x2, - gboolean right_align); -static void e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h); -static double e_week_view_event_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); -static gint e_week_view_event_item_event (GnomeCanvasItem *item, - GdkEvent *event); -static gboolean e_week_view_event_item_button_press (EWeekViewEventItem *wveitem, - GdkEvent *event); -static gboolean e_week_view_event_item_button_release (EWeekViewEventItem *wveitem, - GdkEvent *event); -static EWeekViewPosition e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, - gdouble x, - gdouble y); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_EVENT_NUM, - ARG_SPAN_NUM -}; - - -GtkType -e_week_view_event_item_get_type (void) -{ - static GtkType e_week_view_event_item_type = 0; - - if (!e_week_view_event_item_type) { - GtkTypeInfo e_week_view_event_item_info = { - "EWeekViewEventItem", - sizeof (EWeekViewEventItem), - sizeof (EWeekViewEventItemClass), - (GtkClassInitFunc) e_week_view_event_item_class_init, - (GtkObjectInitFunc) e_week_view_event_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_week_view_event_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_week_view_event_item_info); - } - - return e_week_view_event_item_type; -} - - -static void -e_week_view_event_item_class_init (EWeekViewEventItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EWeekViewEventItem::event_num", - GTK_TYPE_INT, GTK_ARG_WRITABLE, - ARG_EVENT_NUM); - gtk_object_add_arg_type ("EWeekViewEventItem::span_num", - GTK_TYPE_INT, GTK_ARG_WRITABLE, - ARG_SPAN_NUM); - - object_class->set_arg = e_week_view_event_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_week_view_event_item_update; - item_class->draw = e_week_view_event_item_draw; - item_class->point = e_week_view_event_item_point; - item_class->event = e_week_view_event_item_event; -} - - -static void -e_week_view_event_item_init (EWeekViewEventItem *wveitem) -{ - wveitem->event_num = -1; - wveitem->span_num = -1; -} - - -static void -e_week_view_event_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EWeekViewEventItem *wveitem; - gboolean needs_update = FALSE; - - item = GNOME_CANVAS_ITEM (o); - wveitem = E_WEEK_VIEW_EVENT_ITEM (o); - - switch (arg_id){ - case ARG_EVENT_NUM: - wveitem->event_num = GTK_VALUE_INT (*arg); - needs_update = TRUE; - break; - case ARG_SPAN_NUM: - wveitem->span_num = GTK_VALUE_INT (*arg); - needs_update = TRUE; - break; - } - - if (needs_update) - gnome_canvas_item_request_update (item); -} - - -static void -e_week_view_event_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - EWeekViewEventItem *wveitem; - EWeekView *week_view; - gint span_x, span_y, span_w; - -#if 0 - g_print ("In e_week_view_event_item_update\n"); -#endif - - wveitem = E_WEEK_VIEW_EVENT_ITEM (item); - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; - - if (wveitem->event_num != -1 && wveitem->span_num != -1) { - if (e_week_view_get_span_position (week_view, - wveitem->event_num, - wveitem->span_num, - &span_x, &span_y, - &span_w)) { -#if 0 - g_print (" Event:%i Span:%i %i,%i W:%i\n", - wveitem->event_num, wveitem->span_num, - span_x, span_y, span_w); -#endif - item->x1 = span_x; - item->y1 = span_y; - item->x2 = span_x + span_w - 1; - item->y2 = span_y + week_view->row_height - 1; - } - } -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EWeekViewEventItem *wveitem; - EWeekView *week_view; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - GtkStyle *style; - GdkGC *fg_gc, *gc; - GdkFont *font; - gint x1, y1, x2, y2, time_x, time_y, time_y_small_min; - gint icon_x, icon_y, time_width, min_end_time_x; - gint rect_x, rect_w, rect_x2; - gboolean one_day_event, editing_span = FALSE; - gint start_minute, end_minute; - gchar buffer[128]; - gboolean draw_start_triangle = FALSE, draw_end_triangle = FALSE; - GdkRectangle clip_rect; - -#if 0 - g_print ("In e_week_view_event_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - - wveitem = E_WEEK_VIEW_EVENT_ITEM (canvas_item); - week_view = E_WEEK_VIEW (GTK_WIDGET (canvas_item->canvas)->parent); - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (wveitem->event_num == -1 || wveitem->span_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - wveitem->event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + wveitem->span_num); - - style = GTK_WIDGET (week_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - gc = week_view->main_gc; - - x1 = canvas_item->x1 - x; - y1 = canvas_item->y1 - y; - x2 = canvas_item->x2 - x; - y2 = canvas_item->y2 - y; - - if (x1 == x2 || y1 == y2) - return; - - icon_y = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD; - start_minute = event->start_minute; - end_minute = event->end_minute; - time_y = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT - + E_WEEK_VIEW_EVENT_TEXT_Y_PAD + font->ascent; - if (week_view->small_font) - time_y_small_min = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT - + E_WEEK_VIEW_EVENT_TEXT_Y_PAD - + week_view->small_font->ascent; - if (week_view->use_small_font && week_view->small_font) - time_width = week_view->digit_width * 2 - + week_view->small_digit_width * 2; - else - time_width = week_view->digit_width * 4 - + week_view->colon_width; - - one_day_event = e_week_view_is_one_day_event (week_view, - wveitem->event_num); - if (one_day_event) { - time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD; - - /* Convert the time into a string. We use different parts of - the string for the different time formats. Notice that the - string is always 11 characters long. */ - sprintf (buffer, "%02i:%02i %02i:%02i", - start_minute / 60, start_minute % 60, - end_minute / 60, end_minute % 60); - - /* Draw the start and end times, as required. */ - switch (week_view->time_format) { - case E_WEEK_VIEW_TIME_BOTH_SMALL_MIN: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 2); - gdk_draw_text (drawable, week_view->small_font, fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, buffer + 3, 2); - gdk_draw_text (drawable, font, fg_gc, - time_x + week_view->digit_width * 4 - 2, - time_y, buffer + 6, 2); - gdk_draw_text (drawable, week_view->small_font, fg_gc, - time_x + week_view->digit_width * 6 - 2, - time_y_small_min, buffer + 9, 2); - - icon_x = x1 + time_width * 2 + week_view->space_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_START_SMALL_MIN: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 2); - gdk_draw_text (drawable, week_view->small_font, fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, buffer + 3, 2); - - icon_x = x1 + time_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_BOTH: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 11); - icon_x = x1 + time_width * 2 + week_view->space_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_START: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 5); - icon_x = x1 + time_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_NONE: - icon_x = x1 + E_WEEK_VIEW_EVENT_L_PAD; - break; - } - - /* Draw the icons. */ - e_week_view_event_item_draw_icons (wveitem, drawable, - icon_x, icon_y, - x2, FALSE); - - } else { - rect_x = x1 + E_WEEK_VIEW_EVENT_L_PAD; - rect_w = x2 - x1 - E_WEEK_VIEW_EVENT_L_PAD - - E_WEEK_VIEW_EVENT_R_PAD + 1; - - /* Draw the triangles at the start & end, if needed. */ - if (event->start < week_view->day_starts[span->start_day]) { - draw_start_triangle = TRUE; - rect_x += 2; - rect_w -= 2; - } - - if (event->end > week_view->day_starts[span->start_day - + span->num_days]) { - draw_end_triangle = TRUE; - rect_w -= 2; - } - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]); - gdk_draw_rectangle (drawable, gc, TRUE, - rect_x, y1 + 1, rect_w, y2 - y1 - 1); - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]); - rect_x2 = rect_x + rect_w - 1; - gdk_draw_line (drawable, gc, rect_x, y1, rect_x2, y1); - gdk_draw_line (drawable, gc, rect_x, y2, rect_x2, y2); - - if (draw_start_triangle) { - e_week_view_event_item_draw_triangle (wveitem, drawable, x1 + E_WEEK_VIEW_EVENT_L_PAD + 2, y1, -3, y2 - y1 + 1); - } else { - gdk_draw_line (drawable, gc, rect_x, y1, rect_x, y2); - } - - if (draw_end_triangle) { - e_week_view_event_item_draw_triangle (wveitem, drawable, x2 - E_WEEK_VIEW_EVENT_R_PAD - 2, y1, 3, y2 - y1 + 1); - } else { - gdk_draw_line (drawable, gc, rect_x2, y1, rect_x2, y2); - } - - if (span->text_item && E_TEXT (span->text_item)->editing) - editing_span = TRUE; - - /* Draw the start & end times, if necessary. */ - min_end_time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - if (!editing_span - && event->start > week_view->day_starts[span->start_day]) { - sprintf (buffer, "%02i:%02i", - start_minute / 60, start_minute % 60); - time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - - clip_rect.x = x1; - clip_rect.y = y1; - clip_rect.width = x2 - x1 - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH + 1; - clip_rect.height = y2 - y1 + 1; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - if (week_view->use_small_font - && week_view->small_font) { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 2); - gdk_draw_text (drawable, week_view->small_font, - fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, - buffer + 3, 2); - } else { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 5); - } - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - min_end_time_x += time_width + 2; - } - - if (!editing_span - && event->end < week_view->day_starts[span->start_day - + span->num_days]) { - sprintf (buffer, "%02i:%02i", - end_minute / 60, end_minute % 60); - time_x = x2 - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD - 1 - - time_width; - - if (time_x >= min_end_time_x) { - if (week_view->use_small_font - && week_view->small_font) { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, - buffer, 2); - gdk_draw_text (drawable, - week_view->small_font, - fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, - buffer + 3, 2); - } else { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, - buffer, 5); - } - } - } - - /* Draw the icons. */ - if (span->text_item) { - icon_x = span->text_item->x1 - x; - e_week_view_event_item_draw_icons (wveitem, drawable, - icon_x, icon_y, - x2, TRUE); - } - } -} - - -static void -e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint icon_x, - gint icon_y, - gint x2, - gboolean right_align) -{ - EWeekView *week_view; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - CalComponent *comp; - GdkGC *gc; - gint num_icons = 0, icon_x_inc; - gboolean draw_reminder_icon = FALSE, draw_recurrence_icon = FALSE; - - week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent); - - event = &g_array_index (week_view->events, EWeekViewEvent, - wveitem->event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + wveitem->span_num); - comp = event->comp; - - gc = week_view->main_gc; - -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) { - draw_reminder_icon = TRUE; - num_icons++; - } -#endif - - if (cal_component_has_rdates (comp) - || cal_component_has_rrules (comp)) { - draw_recurrence_icon = TRUE; - num_icons++; - } - - icon_x_inc = E_WEEK_VIEW_ICON_WIDTH + E_WEEK_VIEW_ICON_X_PAD; - - if (right_align) - icon_x -= icon_x_inc * num_icons; - - if (draw_reminder_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, week_view->reminder_mask); - gdk_draw_pixmap (drawable, gc, - week_view->reminder_icon, - 0, 0, icon_x, icon_y, - E_WEEK_VIEW_ICON_WIDTH, - E_WEEK_VIEW_ICON_HEIGHT); - icon_x += icon_x_inc; - } - - if (draw_recurrence_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, week_view->recurrence_mask); - gdk_draw_pixmap (drawable, gc, - week_view->recurrence_icon, - 0, 0, icon_x, icon_y, - E_WEEK_VIEW_ICON_WIDTH, - E_WEEK_VIEW_ICON_HEIGHT); - icon_x += icon_x_inc; - } - - gdk_gc_set_clip_mask (gc, NULL); -} - - -/* This draws a little triangle to indicate that an event extends past - the days visible on screen. */ -static void -e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h) -{ - EWeekView *week_view; - GdkGC *gc; - GdkPoint points[3]; - gint c1, c2; - - week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent); - - gc = week_view->main_gc; - - points[0].x = x; - points[0].y = y; - points[1].x = x + w; - points[1].y = y + (h / 2) - 1; - points[2].x = x; - points[2].y = y + h - 1; - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]); - gdk_draw_polygon (drawable, gc, TRUE, points, 3); - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]); - - /* If the height is odd we can use the same central point for both - lines. If it is even we use different end-points. */ - c1 = c2 = y + (h / 2); - if (h % 2 == 0) - c1--; - - gdk_draw_line (drawable, gc, x, y, x + w, c1); - gdk_draw_line (drawable, gc, x, y + h - 1, x + w, c2); -} - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_week_view_event_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_week_view_event_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EWeekViewEventItem *wveitem; - - wveitem = E_WEEK_VIEW_EVENT_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - return e_week_view_event_item_button_press (wveitem, event); - case GDK_BUTTON_RELEASE: - return e_week_view_event_item_button_release (wveitem, event); - case GDK_MOTION_NOTIFY: - break; - default: - break; - } - - return FALSE; -} - - -static gboolean -e_week_view_event_item_button_press (EWeekViewEventItem *wveitem, - GdkEvent *bevent) -{ - EWeekView *week_view; - EWeekViewPosition pos; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (wveitem); - - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - - event = &g_array_index (week_view->events, EWeekViewEvent, - wveitem->event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + wveitem->span_num); - -#if 0 - g_print ("In e_week_view_event_item_button_press\n"); -#endif - - pos = e_week_view_event_item_get_position (wveitem, bevent->button.x, - bevent->button.y); - if (pos == E_WEEK_VIEW_POS_NONE) - return FALSE; - - week_view->pressed_event_num = wveitem->event_num; - week_view->pressed_span_num = wveitem->span_num; - - if (bevent->button.button == 1) { - /* Ignore clicks on the event while editing. */ - if (E_TEXT (span->text_item)->editing) - return FALSE; - - /* Remember the item clicked and the mouse position, - so we can start a drag if the mouse moves. */ - week_view->drag_event_x = bevent->button.x; - week_view->drag_event_y = bevent->button.y; - - /* FIXME: Remember the day offset from the start of the event. - */ - } else if (bevent->button.button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - e_week_view_show_popup_menu (week_view, - (GdkEventButton*) bevent, - wveitem->event_num); - gtk_signal_emit_stop_by_name (GTK_OBJECT (item->canvas), - "button_press_event"); - } - - return TRUE; -} - - -static gboolean -e_week_view_event_item_button_release (EWeekViewEventItem *wveitem, - GdkEvent *event) -{ - EWeekView *week_view; - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (wveitem); - - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - -#if 0 - g_print ("In e_week_view_event_item_button_release\n"); -#endif - - if (week_view->pressed_event_num != -1 - && week_view->pressed_event_num == wveitem->event_num - && week_view->pressed_span_num == wveitem->span_num) { - e_week_view_start_editing_event (week_view, - wveitem->event_num, - wveitem->span_num, - NULL); - week_view->pressed_event_num = -1; - return TRUE; - } - - week_view->pressed_event_num = -1; - - return FALSE; -} - - -static EWeekViewPosition -e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, - gdouble x, - gdouble y) -{ - EWeekView *week_view; - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (wveitem); - - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), E_WEEK_VIEW_POS_NONE); - -#if 0 - g_print ("In e_week_view_event_item_get_position item: %g,%g %g,%g point: %g,%g\n", item->x1, item->y1, item->x2, item->y2, x, y); -#endif - - if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD - || x >= item->x2 - E_WEEK_VIEW_EVENT_R_PAD) - return E_WEEK_VIEW_POS_NONE; - - /* Support left/right edge for long events only. */ - if (!e_week_view_is_one_day_event (week_view, wveitem->event_num)) { - if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD) - return E_WEEK_VIEW_POS_LEFT_EDGE; - - if (x >= item->x2 - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD) - return E_WEEK_VIEW_POS_RIGHT_EDGE; - } - - return E_WEEK_VIEW_POS_EVENT; -} diff --git a/calendar/gui/e-week-view-event-item.h b/calendar/gui/e-week-view-event-item.h deleted file mode 100644 index cfe58699b0..0000000000 --- a/calendar/gui/e-week-view-event-item.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_WEEK_VIEW_EVENT_ITEM_H_ -#define _E_WEEK_VIEW_EVENT_ITEM_H_ - -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekViewEventItem - displays the background, times and icons for an event - * in the week/month views. A separate EText canvas item is used to display & - * edit the text. - */ - -#define E_WEEK_VIEW_EVENT_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_week_view_event_item_get_type (), EWeekViewEventItem)) -#define E_WEEK_VIEW_EVENT_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_week_view_event_item_get_type ())) -#define E_IS_WEEK_VIEW_EVENT_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_week_view_event_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The event index in the EWeekView events array. */ - gint event_num; - - /* The span index within the event. */ - gint span_num; -} EWeekViewEventItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EWeekViewEventItemClass; - - -GtkType e_week_view_event_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_EVENT_ITEM_H_ */ diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c deleted file mode 100644 index 49c2ca3d7d..0000000000 --- a/calendar/gui/e-week-view-main-item.c +++ /dev/null @@ -1,367 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EWeekViewMainItem - displays the background grid and dates for the Week and - * Month calendar views. - */ - -#include <config.h> -#include "e-week-view-main-item.h" - -static void e_week_view_main_item_class_init (EWeekViewMainItemClass *class); -static void e_week_view_main_item_init (EWeekViewMainItem *wvmitem); - -static void e_week_view_main_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_week_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_week_view_main_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem, - gint day, - GDate *date, - GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height); -static double e_week_view_main_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WEEK_VIEW -}; - - -GtkType -e_week_view_main_item_get_type (void) -{ - static GtkType e_week_view_main_item_type = 0; - - if (!e_week_view_main_item_type) { - GtkTypeInfo e_week_view_main_item_info = { - "EWeekViewMainItem", - sizeof (EWeekViewMainItem), - sizeof (EWeekViewMainItemClass), - (GtkClassInitFunc) e_week_view_main_item_class_init, - (GtkObjectInitFunc) e_week_view_main_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_week_view_main_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_week_view_main_item_info); - } - - return e_week_view_main_item_type; -} - - -static void -e_week_view_main_item_class_init (EWeekViewMainItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EWeekViewMainItem::week_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_WEEK_VIEW); - - object_class->set_arg = e_week_view_main_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_week_view_main_item_update; - item_class->draw = e_week_view_main_item_draw; - item_class->point = e_week_view_main_item_point; -} - - -static void -e_week_view_main_item_init (EWeekViewMainItem *wvmitem) -{ - wvmitem->week_view = NULL; -} - - -static void -e_week_view_main_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EWeekViewMainItem *wvmitem; - - item = GNOME_CANVAS_ITEM (o); - wvmitem = E_WEEK_VIEW_MAIN_ITEM (o); - - switch (arg_id){ - case ARG_WEEK_VIEW: - wvmitem->week_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_week_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_week_view_main_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EWeekViewMainItem *wvmitem; - EWeekView *week_view; - GDate date; - gint num_days, day, day_x, day_y, day_w, day_h; - -#if 0 - g_print ("In e_week_view_main_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - - wvmitem = E_WEEK_VIEW_MAIN_ITEM (canvas_item); - week_view = wvmitem->week_view; - g_return_if_fail (week_view != NULL); - - /* Step through each of the days. */ - date = week_view->first_day_shown; - - /* If no date has been set, we just use Dec 1999/January 2000. */ - if (!g_date_valid (&date)) - g_date_set_dmy (&date, 27, 12, 1999); - - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - for (day = 0; day < num_days; day++) { - e_week_view_get_day_position (week_view, day, - &day_x, &day_y, - &day_w, &day_h); - /* Skip any days which are outside the area. */ - if (day_x < x + width && day_x + day_w >= x - && day_y < y + height && day_y + day_h >= y) { - e_week_view_main_item_draw_day (wvmitem, day, &date, - drawable, - day_x - x, day_y - y, - day_w, day_h); - } - g_date_add_days (&date, 1); - } -} - - -static void -e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem, - gint day, - GDate *date, - GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height) -{ - EWeekView *week_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc, *gc, *date_gc; - GdkGC *selected_fg_gc, *selected_bg_gc; - GdkFont *font; - gint right_edge, bottom_edge, date_width, date_x, line_y; - gboolean show_day_name, show_month_name, selected; - gchar buffer[128], *format_string; - gint month, day_of_month, max_width; - GdkColor *bg_color; - -#if 0 - g_print ("Drawing Day:%i at %i,%i\n", day, x, y); -#endif - week_view = wvmitem->week_view; - style = GTK_WIDGET (week_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_PRELIGHT]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - selected_fg_gc = style->fg_gc[GTK_STATE_SELECTED]; - selected_bg_gc = style->bg_gc[GTK_STATE_SELECTED]; - gc = week_view->main_gc; - - month = g_date_month (date); - day_of_month = g_date_day (date); - line_y = y + E_WEEK_VIEW_DATE_T_PAD + font->ascent - + font->descent + E_WEEK_VIEW_DATE_LINE_T_PAD; - - /* Draw the background of the day. In the month view odd months are - one color and even months another, so you can easily see when each - month starts (defaults are white for odd - January, March, ... and - light gray for even). In the week view the background is always the - same color, the color used for the odd months in the month view. */ - if (week_view->display_month && (month % 2 == 0)) - bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS]; - else - bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS]; - - gdk_gc_set_foreground (gc, bg_color); - gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height); - - /* Draw the lines on the right and bottom of the cell. The canvas is - sized so that the lines on the right & bottom edges will be off the - edge of the canvas, so we don't have to worry about them. */ - right_edge = x + width - 1; - bottom_edge = y + height - 1; - - gdk_draw_line (drawable, fg_gc, - right_edge, y, right_edge, bottom_edge); - gdk_draw_line (drawable, fg_gc, - x, bottom_edge, right_edge, bottom_edge); - - /* If the day is selected, draw the blue background. */ - selected = TRUE; - if (!GTK_WIDGET_HAS_FOCUS (week_view) - || week_view->selection_start_day == -1 - || week_view->selection_start_day > day - || week_view->selection_end_day < day) - selected = FALSE; - if (selected) { - if (week_view->display_month) - gdk_draw_rectangle (drawable, selected_bg_gc, TRUE, - x + 2, y + 1, - width - 5, - E_WEEK_VIEW_DATE_T_PAD - 1 - + font->ascent + font->descent); - else - gdk_draw_rectangle (drawable, selected_bg_gc, TRUE, - x + 2, y + 1, - width - 5, line_y - y); - } - - /* Display the date in the top of the cell. - In the week view, display the long format "10 January" in all cells, - or abbreviate it to "10 Jan" or "10" if that doesn't fit. - In the month view, only use the long format for the first cell and - the 1st of each month, otherwise use "10". */ - show_day_name = FALSE; - show_month_name = FALSE; - if (!week_view->display_month) { - show_day_name = TRUE; - show_month_name = TRUE; - } else if (day == 0 || day_of_month == 1) { - show_month_name = TRUE; - } - - /* Now find the longest form of the date that will fit. */ - max_width = width - 4; - format_string = NULL; - if (show_day_name) { - if (week_view->max_abbr_day_width + - week_view->digit_width * 2 + week_view->space_width * 2 - + week_view->month_widths[month - 1] < max_width) - format_string = "%a %d %B"; - } - if (!format_string && show_month_name) { - if (week_view->digit_width * 2 + week_view->space_width - + week_view->month_widths[month - 1] < max_width) - format_string = "%d %B"; - else if (week_view->digit_width * 2 + week_view->space_width - + week_view->abbr_month_widths[month - 1] < max_width) - format_string = "%d %b"; - } - - g_date_strftime (buffer, 128, format_string ? format_string : "%d", - date); - date_width = gdk_string_width (font, buffer); - date_x = x + width - date_width - E_WEEK_VIEW_DATE_R_PAD; - date_x = MAX (date_x, x + 1); - - if (selected) - date_gc = selected_fg_gc; - else - date_gc = fg_gc; - gdk_draw_string (drawable, font, date_gc, - date_x, y + E_WEEK_VIEW_DATE_T_PAD + font->ascent, - buffer); - - /* Draw the line under the date. */ - if (!week_view->display_month) { - gdk_draw_line (drawable, fg_gc, - x + E_WEEK_VIEW_DATE_LINE_L_PAD, line_y, - right_edge, line_y); - } -} - - - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_week_view_main_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - diff --git a/calendar/gui/e-week-view-main-item.h b/calendar/gui/e-week-view-main-item.h deleted file mode 100644 index f75dcb0ec9..0000000000 --- a/calendar/gui/e-week-view-main-item.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_WEEK_VIEW_MAIN_ITEM_H_ -#define _E_WEEK_VIEW_MAIN_ITEM_H_ - -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekViewMainItem - displays the background grid and dates for the Week and - * Month calendar views. - */ - -#define E_WEEK_VIEW_MAIN_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_week_view_main_item_get_type (), EWeekViewMainItem)) -#define E_WEEK_VIEW_MAIN_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_week_view_main_item_get_type ())) -#define E_IS_WEEK_VIEW_MAIN_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_week_view_main_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EWeekView widget. */ - EWeekView *week_view; -} EWeekViewMainItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EWeekViewMainItemClass; - - -GtkType e_week_view_main_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_MAIN_ITEM_H_ */ diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c deleted file mode 100644 index 14f47e4bcf..0000000000 --- a/calendar/gui/e-week-view-titles-item.c +++ /dev/null @@ -1,300 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EWeekViewTitlesItem - displays the 'Monday', 'Tuesday' etc. at the top of - * the Month calendar view. - */ - -#include <config.h> -#include "e-week-view-titles-item.h" - -static void e_week_view_titles_item_class_init (EWeekViewTitlesItemClass *class); -static void e_week_view_titles_item_init (EWeekViewTitlesItem *wvtitem); - -static void e_week_view_titles_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_week_view_titles_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_week_view_titles_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static double e_week_view_titles_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WEEK_VIEW -}; - - -GtkType -e_week_view_titles_item_get_type (void) -{ - static GtkType e_week_view_titles_item_type = 0; - - if (!e_week_view_titles_item_type) { - GtkTypeInfo e_week_view_titles_item_info = { - "EWeekViewTitlesItem", - sizeof (EWeekViewTitlesItem), - sizeof (EWeekViewTitlesItemClass), - (GtkClassInitFunc) e_week_view_titles_item_class_init, - (GtkObjectInitFunc) e_week_view_titles_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_week_view_titles_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_week_view_titles_item_info); - } - - return e_week_view_titles_item_type; -} - - -static void -e_week_view_titles_item_class_init (EWeekViewTitlesItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EWeekViewTitlesItem::week_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_WEEK_VIEW); - - object_class->set_arg = e_week_view_titles_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_week_view_titles_item_update; - item_class->draw = e_week_view_titles_item_draw; - item_class->point = e_week_view_titles_item_point; -} - - -static void -e_week_view_titles_item_init (EWeekViewTitlesItem *wvtitem) -{ - wvtitem->week_view = NULL; -} - - -static void -e_week_view_titles_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EWeekViewTitlesItem *wvtitem; - - item = GNOME_CANVAS_ITEM (o); - wvtitem = E_WEEK_VIEW_TITLES_ITEM (o); - - switch (arg_id){ - case ARG_WEEK_VIEW: - wvtitem->week_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_week_view_titles_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EWeekViewTitlesItem *wvtitem; - EWeekView *week_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc; - GdkFont *font; - gint canvas_width, canvas_height, col_width, col, date_width, date_x; - gchar buffer[128], *date_format; - GDate date; - GdkRectangle clip_rect; - gboolean long_format; - -#if 0 - g_print ("In e_week_view_titles_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - - wvtitem = E_WEEK_VIEW_TITLES_ITEM (canvas_item); - week_view = wvtitem->week_view; - g_return_if_fail (week_view != NULL); - - style = GTK_WIDGET (week_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - canvas_width = GTK_WIDGET (canvas_item->canvas)->allocation.width; - canvas_height = GTK_WIDGET (canvas_item->canvas)->allocation.height; - - /* Draw the shadow around the dates. */ - gdk_draw_line (drawable, light_gc, - 1 - x, 1 - y, - canvas_width - 2 - x, 1 - y); - gdk_draw_line (drawable, light_gc, - 1 - x, 2 - y, - 1 - x, canvas_height - 1 - y); - - gdk_draw_rectangle (drawable, dark_gc, FALSE, - 0 - x, 0 - y, - canvas_width - 1, canvas_height); - - /* Determine the format to use. */ - col_width = canvas_width / week_view->columns; - if (col_width > week_view->max_day_width + 2) { - date_format = "%A"; - long_format = TRUE; - } else { - date_format = "%a"; - long_format = FALSE; - } - - /* Shift right one pixel to account for the shadow around the main - canvas. */ - x--; - - /* Draw the date. Set a clipping rectangle so we don't draw over the - next day. */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 27, 3, 2000); /* Must be a Monday. */ - for (col = 0; col < week_view->columns; col++) { - if (col == 5 && week_view->compress_weekend) { - g_date_strftime (buffer, 128, "%a/", &date); - g_date_add_days (&date, 1); - g_date_strftime (buffer + strlen (buffer), 100, - "%a", &date); - } else { - g_date_strftime (buffer, 128, date_format, &date); - } - - clip_rect.x = week_view->col_offsets[col] - x; - clip_rect.y = 2 - y; - clip_rect.width = week_view->col_widths[col]; - clip_rect.height = canvas_height - 2; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - if (col == 5 && week_view->compress_weekend) - date_width = week_view->abbr_day_widths[5] - + week_view->slash_width - + week_view->abbr_day_widths[6]; - else if (long_format) - date_width = week_view->day_widths[col]; - else - date_width = week_view->abbr_day_widths[col]; - - date_x = week_view->col_offsets[col] - + (week_view->col_widths[col] - date_width) / 2; - date_x = MAX (date_x, week_view->col_offsets[col]); - gdk_draw_string (drawable, font, fg_gc, - date_x - x, 3 + font->ascent - y, buffer); - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - /* Draw the lines down the left and right of the date cols. */ - if (col != 0) { - gdk_draw_line (drawable, light_gc, - week_view->col_offsets[col] - x, - 4 - y, - week_view->col_offsets[col] - x, - canvas_height - 4 - y); - - gdk_draw_line (drawable, dark_gc, - week_view->col_offsets[col] - 1 - x, - 4 - y, - week_view->col_offsets[col] - 1 - x, - canvas_height - 4 - y); - } - - /* Draw the lines between each column. */ - if (col != 0) { - gdk_draw_line (drawable, style->black_gc, - week_view->col_offsets[col] - x, - canvas_height - y, - week_view->col_offsets[col] - x, - canvas_height - y); - } - - g_date_add_days (&date, 1); - } -} - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_week_view_titles_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - diff --git a/calendar/gui/e-week-view-titles-item.h b/calendar/gui/e-week-view-titles-item.h deleted file mode 100644 index 7ce1ccd386..0000000000 --- a/calendar/gui/e-week-view-titles-item.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_WEEK_VIEW_TITLES_ITEM_H_ -#define _E_WEEK_VIEW_TITLES_ITEM_H_ - -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekViewTitlesItem - displays the 'Monday', 'Tuesday' etc. at the top of - * the Month calendar view. - */ - -#define E_WEEK_VIEW_TITLES_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_week_view_titles_item_get_type (), EWeekViewTitlesItem)) -#define E_WEEK_VIEW_TITLES_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_week_view_titles_item_get_type ())) -#define E_IS_WEEK_VIEW_TITLES_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_week_view_titles_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EWeekView widget. */ - EWeekView *week_view; -} EWeekViewTitlesItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EWeekViewTitlesItemClass; - - -GtkType e_week_view_titles_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_TITLES_ITEM_H_ */ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c deleted file mode 100644 index faf78db567..0000000000 --- a/calendar/gui/e-week-view.c +++ /dev/null @@ -1,2925 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * EWeekView - displays the Week & Month views of the calendar. - */ - -#include <config.h> -#include <math.h> -#include <gnome.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "calendar-commands.h" -#include "e-week-view.h" -#include "e-week-view-event-item.h" -#include "e-week-view-main-item.h" -#include "e-week-view-titles-item.h" -#include <cal-util/timeutil.h> -#include "popup-menu.h" -#include "../e-util/e-canvas.h" -#include "../widgets/e-text/e-text.h" -#include "e-util/e-canvas-utils.h" - -/* Images */ -#include "bell.xpm" -#include "recur.xpm" - -#include "jump.xpm" - -#define E_WEEK_VIEW_SMALL_FONT \ - "-adobe-utopia-regular-r-normal-*-*-100-*-*-p-*-iso8859-*" -#define E_WEEK_VIEW_SMALL_FONT_FALLBACK \ - "-adobe-helvetica-medium-r-normal-*-*-80-*-*-p-*-iso8859-*" - -/* We use a 7-bit field to store row numbers in EWeekViewEventSpan, so the - maximum number or rows we can allow is 127. It is very unlikely to be - reached anyway. */ -#define E_WEEK_VIEW_MAX_ROWS_PER_CELL 127 - -#define E_WEEK_VIEW_JUMP_BUTTON_WIDTH 16 -#define E_WEEK_VIEW_JUMP_BUTTON_HEIGHT 8 - -#define E_WEEK_VIEW_JUMP_BUTTON_X_PAD 3 -#define E_WEEK_VIEW_JUMP_BUTTON_Y_PAD 3 - -static void e_week_view_class_init (EWeekViewClass *class); -static void e_week_view_init (EWeekView *week_view); -static void e_week_view_destroy (GtkObject *object); -static void e_week_view_realize (GtkWidget *widget); -static void e_week_view_unrealize (GtkWidget *widget); -static void e_week_view_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void e_week_view_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void e_week_view_recalc_cell_sizes (EWeekView *week_view); -static gint e_week_view_focus_in (GtkWidget *widget, - GdkEventFocus *event); -static gint e_week_view_focus_out (GtkWidget *widget, - GdkEventFocus *event); -static gint e_week_view_expose_event (GtkWidget *widget, - GdkEventExpose *event); -static void e_week_view_draw (GtkWidget *widget, - GdkRectangle *area); -static void e_week_view_draw_shadow (EWeekView *week_view); - -static gboolean e_week_view_on_button_press (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view); -static gboolean e_week_view_on_button_release (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view); -static gboolean e_week_view_on_motion (GtkWidget *widget, - GdkEventMotion *event, - EWeekView *week_view); -static gint e_week_view_convert_position_to_day (EWeekView *week_view, - gint x, - gint y); -static void e_week_view_update_selection (EWeekView *week_view, - gint day); - -static void e_week_view_reload_events (EWeekView *week_view); -static void e_week_view_free_events (EWeekView *week_view); -static gboolean e_week_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data); -static void e_week_view_check_layout (EWeekView *week_view); -static void e_week_view_layout_events (EWeekView *week_view); -static void e_week_view_layout_event (EWeekView *week_view, - EWeekViewEvent *event, - guint8 *grid, - GArray *spans); -static void e_week_view_ensure_events_sorted (EWeekView *week_view); -static gint e_week_view_event_sort_func (const void *arg1, - const void *arg2); -static void e_week_view_reshape_events (EWeekView *week_view); -static void e_week_view_reshape_event_span (EWeekView *week_view, - gint event_num, - gint span_num); -static gint e_week_view_find_day (EWeekView *week_view, - time_t time_to_find, - gboolean include_midnight_in_prev_day); -static gint e_week_view_find_span_end (EWeekView *week_view, - gint day); -static void e_week_view_recalc_day_starts (EWeekView *week_view, - time_t lower); -static void e_week_view_on_adjustment_changed (GtkAdjustment *adjustment, - EWeekView *week_view); -static void e_week_view_on_editing_started (EWeekView *week_view, - GnomeCanvasItem *item); -static void e_week_view_on_editing_stopped (EWeekView *week_view, - GnomeCanvasItem *item); -static gboolean e_week_view_find_event_from_item (EWeekView *week_view, - GnomeCanvasItem *item, - gint *event_num, - gint *span_num); -static gboolean e_week_view_find_event_from_uid (EWeekView *week_view, - const gchar *uid, - gint *event_num_return); -typedef gboolean (* EWeekViewForeachEventCallback) (EWeekView *week_view, - gint event_num, - gpointer data); - -static void e_week_view_foreach_event_with_uid (EWeekView *week_view, - const gchar *uid, - EWeekViewForeachEventCallback callback, - gpointer data); -static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view); -static gboolean e_week_view_on_jump_button_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view); -static gint e_week_view_key_press (GtkWidget *widget, GdkEventKey *event); -static void e_week_view_on_new_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_edit_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_delete_occurrence (GtkWidget *widget, - gpointer data); -static void e_week_view_on_delete_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_unrecur_appointment (GtkWidget *widget, - gpointer data); - -static gboolean e_week_view_update_event_cb (EWeekView *week_view, - gint event_num, - gpointer data); -static gboolean e_week_view_remove_event_cb (EWeekView *week_view, - gint event_num, - gpointer data); - -static GtkTableClass *parent_class; - - -GtkType -e_week_view_get_type (void) -{ - static GtkType e_week_view_type = 0; - - if (!e_week_view_type){ - GtkTypeInfo e_week_view_info = { - "EWeekView", - sizeof (EWeekView), - sizeof (EWeekViewClass), - (GtkClassInitFunc) e_week_view_class_init, - (GtkObjectInitFunc) e_week_view_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = gtk_type_class (GTK_TYPE_TABLE); - e_week_view_type = gtk_type_unique (GTK_TYPE_TABLE, - &e_week_view_info); - } - - return e_week_view_type; -} - - -static void -e_week_view_class_init (EWeekViewClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - object_class->destroy = e_week_view_destroy; - - widget_class->realize = e_week_view_realize; - widget_class->unrealize = e_week_view_unrealize; - widget_class->style_set = e_week_view_style_set; - widget_class->size_allocate = e_week_view_size_allocate; - widget_class->focus_in_event = e_week_view_focus_in; - widget_class->focus_out_event = e_week_view_focus_out; - widget_class->key_press_event = e_week_view_key_press; - widget_class->expose_event = e_week_view_expose_event; - widget_class->draw = e_week_view_draw; -} - - -static void -e_week_view_init (EWeekView *week_view) -{ - GdkColormap *colormap; - gboolean success[E_WEEK_VIEW_COLOR_LAST]; - gint nfailed; - GnomeCanvasGroup *canvas_group; - GtkObject *adjustment; - GdkPixbuf *pixbuf; - gint i; - - GTK_WIDGET_SET_FLAGS (week_view, GTK_CAN_FOCUS); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view)); - - week_view->calendar = NULL; - - week_view->events = g_array_new (FALSE, FALSE, - sizeof (EWeekViewEvent)); - week_view->events_sorted = TRUE; - week_view->events_need_layout = FALSE; - week_view->events_need_reshape = FALSE; - - week_view->spans = NULL; - - week_view->display_month = FALSE; - week_view->rows = 6; - week_view->columns = 2; - week_view->compress_weekend = TRUE; - - g_date_clear (&week_view->base_date, 1); - g_date_clear (&week_view->first_day_shown, 1); - - week_view->row_height = 10; - week_view->rows_per_cell = 1; - - week_view->selection_start_day = -1; - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE; - - week_view->pressed_event_num = -1; - week_view->editing_event_num = -1; - week_view->editing_new_event = FALSE; - - /* Create the small font. */ - week_view->use_small_font = TRUE; - week_view->small_font = gdk_font_load (E_WEEK_VIEW_SMALL_FONT); - if (!week_view->small_font) - week_view->small_font = gdk_font_load (E_WEEK_VIEW_SMALL_FONT_FALLBACK); - if (!week_view->small_font) - g_warning ("Couldn't load font"); - - /* Allocate the colors. */ - week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].red = 0xeded; - week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].green = 0xeded; - week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].blue = 0xeded; - - week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].red = 65535; - week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].green = 65535; - week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].blue = 65535; - - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].red = 0xd6d6; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green = 0xd6d6; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue = 0xd6d6; - - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].red = 0; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].green = 0; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].blue = 0; - - nfailed = gdk_colormap_alloc_colors (colormap, week_view->colors, - E_WEEK_VIEW_COLOR_LAST, FALSE, - TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); - - - /* - * Titles Canvas. Note that we don't show it is only shown in the - * Month view. - */ - week_view->titles_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (week_view), week_view->titles_canvas, - 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->titles_canvas)->root); - - week_view->titles_canvas_item = - gnome_canvas_item_new (canvas_group, - e_week_view_titles_item_get_type (), - "EWeekViewTitlesItem::week_view", week_view, - NULL); - - /* - * Main Canvas - */ - week_view->main_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (week_view), week_view->main_canvas, - 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1); - gtk_widget_show (week_view->main_canvas); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root); - - week_view->main_canvas_item = - gnome_canvas_item_new (canvas_group, - e_week_view_main_item_get_type (), - "EWeekViewMainItem::week_view", week_view, - NULL); - - gtk_signal_connect_after (GTK_OBJECT (week_view->main_canvas), - "button_press_event", - GTK_SIGNAL_FUNC (e_week_view_on_button_press), - week_view); - gtk_signal_connect_after (GTK_OBJECT (week_view->main_canvas), - "button_release_event", - GTK_SIGNAL_FUNC (e_week_view_on_button_release), - week_view); - gtk_signal_connect_after (GTK_OBJECT (week_view->main_canvas), - "motion_notify_event", - GTK_SIGNAL_FUNC (e_week_view_on_motion), - week_view); - - /* Create the buttons to jump to each days. */ - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char**) jump_xpm); - - for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) { - week_view->jump_buttons[i] = gnome_canvas_item_new - (canvas_group, - gnome_canvas_pixbuf_get_type (), - "GnomeCanvasPixbuf::pixbuf", pixbuf, - NULL); - - gtk_signal_connect (GTK_OBJECT (week_view->jump_buttons[i]), - "event", - GTK_SIGNAL_FUNC (e_week_view_on_jump_button_event), - week_view); - } - - - /* - * Scrollbar. - */ - adjustment = gtk_adjustment_new (0, -52, 52, 1, 1, 1); - gtk_signal_connect (adjustment, "value_changed", - GTK_SIGNAL_FUNC (e_week_view_on_adjustment_changed), - week_view); - - week_view->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (adjustment)); - gtk_table_attach (GTK_TABLE (week_view), week_view->vscrollbar, - 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (week_view->vscrollbar); - - - /* Create the pixmaps. */ - week_view->reminder_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &week_view->reminder_mask, NULL, bell_xpm); - week_view->recurrence_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &week_view->recurrence_mask, NULL, recur_xpm); - - - /* Create the cursors. */ - week_view->normal_cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW); - week_view->move_cursor = gdk_cursor_new (GDK_FLEUR); - week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); - week_view->last_cursor_set = NULL; -} - - -/** - * e_week_view_new: - * @Returns: a new #EWeekView. - * - * Creates a new #EWeekView. - **/ -GtkWidget * -e_week_view_new (void) -{ - GtkWidget *week_view; - - week_view = GTK_WIDGET (gtk_type_new (e_week_view_get_type ())); - - return week_view; -} - - -static void -e_week_view_destroy (GtkObject *object) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (object); - - /* FIXME: free the colors. In EDayView as well. */ - /* FIXME: free the events and the spans. In EDayView as well? */ - - if (week_view->small_font) - gdk_font_unref (week_view->small_font); - - gdk_cursor_destroy (week_view->normal_cursor); - gdk_cursor_destroy (week_view->move_cursor); - gdk_cursor_destroy (week_view->resize_width_cursor); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -static void -e_week_view_realize (GtkWidget *widget) -{ - EWeekView *week_view; - - if (GTK_WIDGET_CLASS (parent_class)->realize) - (*GTK_WIDGET_CLASS (parent_class)->realize)(widget); - - week_view = E_WEEK_VIEW (widget); - week_view->main_gc = gdk_gc_new (widget->window); -} - - -static void -e_week_view_unrealize (GtkWidget *widget) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (widget); - - gdk_gc_unref (week_view->main_gc); - week_view->main_gc = NULL; - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget); -} - - -static void -e_week_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - EWeekView *week_view; - GdkFont *font; - gint day, day_width, max_day_width, max_abbr_day_width; - gint month, month_width, max_month_width, max_abbr_month_width; - GDate date; - gchar buffer[128]; - - if (GTK_WIDGET_CLASS (parent_class)->style_set) - (*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style); - - week_view = E_WEEK_VIEW (widget); - font = widget->style->font; - - /* Recalculate the height of each row based on the font size. */ - week_view->row_height = font->ascent + font->descent + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2 + E_WEEK_VIEW_EVENT_TEXT_Y_PAD * 2; - week_view->row_height = MAX (week_view->row_height, E_WEEK_VIEW_ICON_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2); - - /* Set the height of the top canvas. */ - gtk_widget_set_usize (week_view->titles_canvas, -1, - font->ascent + font->descent + 5); - - /* Save the sizes of various strings in the font, so we can quickly - decide which date formats to use. */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 27, 3, 2000); /* Must be a Monday. */ - - max_day_width = 0; - max_abbr_day_width = 0; - for (day = 0; day < 7; day++) { - g_date_strftime (buffer, 128, "%A", &date); - day_width = gdk_string_width (font, buffer); - week_view->day_widths[day] = day_width; - max_day_width = MAX (max_day_width, day_width); - - g_date_strftime (buffer, 128, "%a", &date); - day_width = gdk_string_width (font, buffer); - week_view->abbr_day_widths[day] = day_width; - max_abbr_day_width = MAX (max_abbr_day_width, day_width); - - g_date_add_days (&date, 1); - } - - max_month_width = 0; - max_abbr_month_width = 0; - for (month = 0; month < 12; month++) { - g_date_set_month (&date, month + 1); - - g_date_strftime (buffer, 128, "%B", &date); - month_width = gdk_string_width (font, buffer); - week_view->month_widths[month] = month_width; - max_month_width = MAX (max_month_width, month_width); - - g_date_strftime (buffer, 128, "%b", &date); - month_width = gdk_string_width (font, buffer); - week_view->abbr_month_widths[month] = month_width; - max_abbr_month_width = MAX (max_abbr_month_width, month_width); - } - - week_view->space_width = gdk_string_width (font, " "); - week_view->colon_width = gdk_string_width (font, ":"); - week_view->slash_width = gdk_string_width (font, "/"); - week_view->digit_width = gdk_string_width (font, "5"); - if (week_view->small_font) - week_view->small_digit_width = gdk_string_width (week_view->small_font, "5"); - week_view->max_day_width = max_day_width; - week_view->max_abbr_day_width = max_abbr_day_width; - week_view->max_month_width = max_month_width; - week_view->max_abbr_month_width = max_abbr_month_width; -} - - -/* This recalculates the sizes of each column. */ -static void -e_week_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - EWeekView *week_view; - gint width, height, time_width; - gdouble old_x2, old_y2, new_x2, new_y2; - GdkFont *font; - - week_view = E_WEEK_VIEW (widget); - font = widget->style->font; - - (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); - - e_week_view_recalc_cell_sizes (week_view); - - /* Calculate the number of rows of events in each cell, for the large - cells and the compressed weekend cells. */ - if (week_view->display_month) { - week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD - + font->ascent + font->descent - + E_WEEK_VIEW_DATE_B_PAD; - } else { - week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD - + font->ascent + font->descent - + E_WEEK_VIEW_DATE_LINE_T_PAD + 1 - + E_WEEK_VIEW_DATE_LINE_B_PAD; - } - - height = week_view->row_heights[0]; - week_view->rows_per_cell = (height * 2 - week_view->events_y_offset) - / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING); - week_view->rows_per_cell = MIN (week_view->rows_per_cell, - E_WEEK_VIEW_MAX_ROWS_PER_CELL); - - week_view->rows_per_compressed_cell = - (height - week_view->events_y_offset) - / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING); - week_view->rows_per_compressed_cell = MIN (week_view->rows_per_compressed_cell, - E_WEEK_VIEW_MAX_ROWS_PER_CELL); - - /* Determine which time format to use, based on the width of the cells. - We only allow the time to take up about half of the width. */ - width = week_view->col_widths[0]; - - week_view->time_format = E_WEEK_VIEW_TIME_NONE; - if (week_view->use_small_font && week_view->small_font) { - time_width = week_view->digit_width * 2 - + week_view->small_digit_width * 2; - if (width / 2 > time_width * 2 + week_view->space_width) - week_view->time_format = E_WEEK_VIEW_TIME_BOTH_SMALL_MIN; - else if (width / 2 > time_width) - week_view->time_format = E_WEEK_VIEW_TIME_START_SMALL_MIN; - } else { - time_width = week_view->digit_width * 4 - + week_view->colon_width; - if (width / 2 > time_width * 2 + week_view->space_width) - week_view->time_format = E_WEEK_VIEW_TIME_BOTH; - else if (width / 2 > time_width) - week_view->time_format = E_WEEK_VIEW_TIME_START; - } - - /* Set the scroll region of the top canvas to its allocated size. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (week_view->titles_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = week_view->titles_canvas->allocation.width - 1; - new_y2 = week_view->titles_canvas->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (week_view->titles_canvas), - 0, 0, new_x2, new_y2); - - - /* Set the scroll region of the main canvas to its allocated width, - but with the height depending on the number of rows needed. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (week_view->main_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = week_view->main_canvas->allocation.width - 1; - new_y2 = week_view->main_canvas->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (week_view->main_canvas), - 0, 0, new_x2, new_y2); - - /* Flag that we need to reshape the events. */ - if (old_x2 != new_x2 || old_y2 != new_y2) { - week_view->events_need_reshape = TRUE; - e_week_view_check_layout (week_view); - } -} - - -static void -e_week_view_recalc_cell_sizes (EWeekView *week_view) -{ - gfloat width, height, offset; - gint row, col; - - if (week_view->display_month) { - week_view->rows = 10; - week_view->columns = 6; - } else { - week_view->rows = 6; - week_view->columns = 2; - } - - /* Calculate the column sizes, using floating point so that pixels - get divided evenly. Note that we use one more element than the - number of columns, to make it easy to get the column widths. - We also add one to the width so that the right border of the last - column is off the edge of the displayed area. */ - width = week_view->main_canvas->allocation.width + 1; - width /= week_view->columns; - offset = 0; - for (col = 0; col <= week_view->columns; col++) { - week_view->col_offsets[col] = floor (offset + 0.5); - offset += width; - } - - /* Calculate the cell widths based on the offsets. */ - for (col = 0; col < week_view->columns; col++) { - week_view->col_widths[col] = week_view->col_offsets[col + 1] - - week_view->col_offsets[col]; - } - - /* Now do the same for the row heights. */ - height = week_view->main_canvas->allocation.height + 1; - height /= week_view->rows; - offset = 0; - for (row = 0; row <= week_view->rows; row++) { - week_view->row_offsets[row] = floor (offset + 0.5); - offset += height; - } - - /* Calculate the cell heights based on the offsets. */ - for (row = 0; row < week_view->rows; row++) { - week_view->row_heights[row] = week_view->row_offsets[row + 1] - - week_view->row_offsets[row]; - } -} - - -static gint -e_week_view_focus_in (GtkWidget *widget, GdkEventFocus *event) -{ - EWeekView *week_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - week_view = E_WEEK_VIEW (widget); - - GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (week_view->main_canvas); - - return FALSE; -} - - -static gint -e_week_view_focus_out (GtkWidget *widget, GdkEventFocus *event) -{ - EWeekView *week_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - week_view = E_WEEK_VIEW (widget); - - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (week_view->main_canvas); - - return FALSE; -} - - -/* This draws a shadow around the top display and main display. */ -static gint -e_week_view_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (widget); - - e_week_view_draw_shadow (week_view); - - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - (*GTK_WIDGET_CLASS (parent_class)->expose_event)(widget, event); - - return FALSE; -} - - -static void -e_week_view_draw (GtkWidget *widget, - GdkRectangle *area) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (widget); - - e_week_view_draw_shadow (week_view); - - if (GTK_WIDGET_CLASS (parent_class)->draw) - (*GTK_WIDGET_CLASS (parent_class)->draw)(widget, area); -} - - -static void -e_week_view_draw_shadow (EWeekView *week_view) -{ - gint x1, y1, x2, y2; - GtkStyle *style; - GdkGC *light_gc, *dark_gc; - GdkWindow *window; - - /* Draw the shadow around the graphical displays. */ - x1 = week_view->main_canvas->allocation.x - 1; - y1 = week_view->main_canvas->allocation.y - 1; - x2 = x1 + week_view->main_canvas->allocation.width + 2; - y2 = y1 + week_view->main_canvas->allocation.height + 2; - - style = GTK_WIDGET (week_view)->style; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - - window = GTK_WIDGET (week_view)->window; - gdk_draw_line (window, dark_gc, x1, y1, x1, y2); - gdk_draw_line (window, dark_gc, x1, y1, x2, y1); - gdk_draw_line (window, light_gc, x2, y1, x2, y2); - gdk_draw_line (window, light_gc, x1, y2, x2, y2); -} - - -void -e_week_view_set_calendar (EWeekView *week_view, - GnomeCalendar *calendar) -{ - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - week_view->calendar = calendar; - - /* FIXME: free current events? */ -} - - -/* This sets the selected time range. The EWeekView will show the corresponding - month and the days between start_time and end_time will be selected. - To select a single day, use the same value for start_time & end_time. */ -void -e_week_view_set_selected_time_range (EWeekView *week_view, - time_t start_time, - time_t end_time) -{ - GDate date, base_date, end_date; - gint day_offset, num_days; - gboolean update_adjustment_value = FALSE; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - g_date_clear (&date, 1); - g_date_set_time (&date, start_time); - - if (week_view->display_month) { - /* Find the number of days since the start of the month. */ - day_offset = g_date_day (&date) - 1; - - /* Find the 1st Monday at or before the start of the month. */ - base_date = date; - g_date_set_day (&base_date, 1); - day_offset += g_date_weekday (&base_date) - 1; - } else { - /* Find the 1st Monday at or before the given day. */ - day_offset = g_date_weekday (&date) - 1; - } - - /* Calculate the base date, i.e. the first day shown when the - scrollbar adjustment value is 0. */ - base_date = date; - g_date_subtract_days (&base_date, day_offset); - - /* See if we need to update the base date. */ - if (!g_date_valid (&week_view->base_date) - || g_date_compare (&week_view->base_date, &base_date)) { - week_view->base_date = base_date; - update_adjustment_value = TRUE; - } - - /* See if we need to update the first day shown. */ - if (!g_date_valid (&week_view->first_day_shown) - || g_date_compare (&week_view->first_day_shown, &base_date)) { - week_view->first_day_shown = base_date; - start_time = time_add_day (start_time, -day_offset); - start_time = time_day_begin (start_time); - e_week_view_recalc_day_starts (week_view, start_time); - e_week_view_reload_events (week_view); - } - - /* Set the selection to the given days. */ - week_view->selection_start_day = g_date_julian (&date) - - g_date_julian (&base_date); - if (end_time == start_time - || end_time <= time_add_day (start_time, 1)) - week_view->selection_end_day = week_view->selection_start_day; - else { - g_date_clear (&end_date, 1); - g_date_set_time (&end_date, end_time - 60); - week_view->selection_end_day = g_date_julian (&end_date) - - g_date_julian (&base_date); - } - - /* Make sure the selection is valid. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - num_days--; - week_view->selection_start_day = CLAMP (week_view->selection_start_day, - 0, num_days); - week_view->selection_end_day = CLAMP (week_view->selection_end_day, - week_view->selection_start_day, - num_days); - - /* Reset the adjustment value to 0 if the base address has changed. - Note that we do this after updating first_day_shown so that our - signal handler will not try to reload the events. */ - if (update_adjustment_value) - gtk_adjustment_set_value (GTK_RANGE (week_view->vscrollbar)->adjustment, 0); - - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -/* Returns the selected time range. */ -void -e_week_view_get_selected_time_range (EWeekView *week_view, - time_t *start_time, - time_t *end_time) -{ - gint start_day, end_day; - - start_day = week_view->selection_start_day; - end_day = week_view->selection_end_day; - - if (start_day == -1) { - start_day = 0; - end_day = 0; - } - - if (start_time) - *start_time = week_view->day_starts[start_day]; - - if (end_time) - *end_time = week_view->day_starts[end_day + 1]; -} - - -/* Recalculates the time_t corresponding to the start of each day. */ -static void -e_week_view_recalc_day_starts (EWeekView *week_view, - time_t lower) -{ - gint num_days, day; - time_t tmp_time; - - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - - tmp_time = lower; - week_view->day_starts[0] = tmp_time; - for (day = 1; day <= num_days; day++) { - /* FIXME: There is a bug in time_add_day(). */ -#if 0 - g_print ("Day:%i - %s\n", day, ctime (&tmp_time)); -#endif - tmp_time = time_add_day (tmp_time, 1); - week_view->day_starts[day] = tmp_time; - } -} - - -gboolean -e_week_view_get_display_month (EWeekView *week_view) -{ - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - - return week_view->display_month; -} - - -void -e_week_view_set_display_month (EWeekView *week_view, - gboolean display_month) -{ - GtkAdjustment *adjustment; - gint page_increment, page_size; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (week_view->display_month == display_month) - return; - - week_view->display_month = display_month; - - if (display_month) { - gtk_widget_show (week_view->titles_canvas); - page_increment = 4; - page_size = 5; - } else { - gtk_widget_hide (week_view->titles_canvas); - page_increment = page_size = 1; - } - - adjustment = GTK_RANGE (week_view->vscrollbar)->adjustment; - adjustment->page_increment = page_increment; - adjustment->page_size = page_size; - gtk_adjustment_changed (adjustment); - - /* FIXME: Need to change start date and adjustment value? */ - - e_week_view_recalc_day_starts (week_view, week_view->day_starts[0]); - e_week_view_recalc_cell_sizes (week_view); - e_week_view_reload_events (week_view); -} - - -gboolean -e_week_view_get_compress_weekend (EWeekView *week_view) -{ - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - - return week_view->compress_weekend; -} - - -void -e_week_view_set_compress_weekend (EWeekView *week_view, - gboolean compress) -{ - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (week_view->compress_weekend == compress) - return; - - week_view->compress_weekend = compress; - - /* The option only affects the month view. */ - if (!week_view->display_month) - return; - - /* FIXME: Need to update layout. */ -} - - -/* This reloads all calendar events. */ -void -e_week_view_update_all_events (EWeekView *week_view) -{ - e_week_view_reload_events (week_view); -} - - -/* This is called when one event has been added or updated. */ -void -e_week_view_update_event (EWeekView *week_view, - const gchar *uid) -{ - EWeekViewEvent *event; - gint event_num, num_days; - CalComponent *comp; - CalClientGetStatus status; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - -#if 0 - g_print ("In e_week_view_update_event\n"); -#endif - - /* If we don't have a calendar or valid date set yet, just return. */ - if (!week_view->calendar - || !g_date_valid (&week_view->first_day_shown)) - return; - - /* Get the event from the server. */ - status = cal_client_get_object (week_view->calendar->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Do nothing. */ - break; - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_warning ("syntax error uid=%s\n", uid); - return; - case CAL_CLIENT_GET_NOT_FOUND: - g_warning ("obj not found uid=%s\n", uid); - return; - } - - /* We only care about events. */ - if (comp && cal_component_get_vtype (comp) != CAL_COMPONENT_EVENT) { - gtk_object_unref (GTK_OBJECT (comp)); - return; - } - - /* If the event already exists and the dates didn't change, we can - update the event fairly easily without changing the events arrays - or computing a new layout. */ - if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { -#warning "FIX ME" - /* Do this the long way every time for now */ -#if 0 - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - if (ical_object_compare_dates (event->ico, ico)) { - e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp); - gtk_object_unref (GTK_OBJECT (comp)); - gtk_widget_queue_draw (week_view->main_canvas); - return; - } -#endif - /* The dates have changed, so we need to remove the - old occurrrences before adding the new ones. */ - e_week_view_foreach_event_with_uid (week_view, uid, - e_week_view_remove_event_cb, - NULL); - } - - /* Add the occurrences of the event. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - - cal_recur_generate_instances (comp, - week_view->day_starts[0], - week_view->day_starts[num_days], - e_week_view_add_event, - week_view); - - gtk_object_unref (GTK_OBJECT (comp)); - - e_week_view_check_layout (week_view); - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -static gboolean -e_week_view_update_event_cb (EWeekView *week_view, - gint event_num, - gpointer data) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint span_num; - gchar *text; - CalComponent *comp; - - comp = data; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - event->comp = comp; - gtk_object_ref (GTK_OBJECT (comp)); - - /* If we are editing an event which we have just created, we will get - an update_event callback from the server. But we need to ignore it - or we will lose the text the user has already typed in. */ - if (week_view->editing_new_event - && week_view->editing_event_num == event_num) { - return TRUE; - } - - for (span_num = 0; span_num < event->num_spans; span_num++) { - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (span->text_item) { - CalComponentText t; - - cal_component_get_summary (event->comp, &t); - text = g_strdup (t.value); - gnome_canvas_item_set (span->text_item, - "text", text ? text : "", - NULL); - g_free (text); - - e_week_view_reshape_event_span (week_view, event_num, - span_num); - } - } - - return TRUE; -} - - -/* This calls a given function for each event instance that matches the given - uid. Note that it is safe for the callback to remove the event (since we - step backwards through the arrays). */ -static void -e_week_view_foreach_event_with_uid (EWeekView *week_view, - const gchar *uid, - EWeekViewForeachEventCallback callback, - gpointer data) -{ - EWeekViewEvent *event; - gint event_num; - - for (event_num = week_view->events->len - 1; - event_num >= 0; - event_num--) { - const char *u; - - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - if (!(*callback) (week_view, event_num, data)) - return; - } - } -} - - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void -e_week_view_remove_event (EWeekView *week_view, - const gchar *uid) -{ - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - e_week_view_foreach_event_with_uid (week_view, uid, - e_week_view_remove_event_cb, NULL); - - e_week_view_check_layout (week_view); - gtk_widget_queue_draw (week_view->main_canvas); -} - - -static gboolean -e_week_view_remove_event_cb (EWeekView *week_view, - gint event_num, - gpointer data) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint span_num; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - - /* If we were editing this event, set editing_event_num to -1 so - on_editing_stopped doesn't try to update the event. */ - if (week_view->editing_event_num == event_num) - week_view->editing_event_num = -1; - - /* We leave the span elements in the array, but set the canvas item - pointers to NULL. */ - for (span_num = 0; span_num < event->num_spans; span_num++) { - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (span->text_item) { - gtk_object_destroy (GTK_OBJECT (span->text_item)); - span->text_item = NULL; - } - if (span->background_item) { - gtk_object_destroy (GTK_OBJECT (span->background_item)); - span->background_item = NULL; - } - } - - gtk_object_unref (GTK_OBJECT (event->comp)); - - g_array_remove_index (week_view->events, event_num); - week_view->events_need_layout = TRUE; - - return TRUE; -} - - -void -e_week_view_get_day_position (EWeekView *week_view, - gint day, - gint *day_x, - gint *day_y, - gint *day_w, - gint *day_h) -{ - gint week, day_of_week, row; - - *day_x = *day_y = *day_w = *day_h = 0; - g_return_if_fail (day >= 0); - - if (week_view->display_month) { - g_return_if_fail (day < E_WEEK_VIEW_MAX_WEEKS * 7); - - week = day / 7; - day_of_week = day % 7; - if (week_view->compress_weekend && day_of_week >= 5) { - /* In the compressed view Saturday is above Sunday and - both have just one row as opposed to 2 for all the - other days. */ - if (day_of_week == 5) { - *day_y = week_view->row_offsets[week * 2]; - *day_h = week_view->row_heights[week * 2]; - } else { - *day_y = week_view->row_offsets[week * 2 + 1]; - *day_h = week_view->row_heights[week * 2 + 1]; - } - /* Both Saturday and Sunday are in the 6th column. */ - *day_x = week_view->col_offsets[5]; - *day_w = week_view->col_widths[5]; - } else { - *day_y = week_view->row_offsets[week * 2]; - *day_h = week_view->row_heights[week * 2] - + week_view->row_heights[week * 2 + 1]; - *day_x = week_view->col_offsets[day_of_week]; - *day_w = week_view->col_widths[day_of_week]; - } - } else { - g_return_if_fail (day < 7); - - /* The week view has Mon, Tue & Wed down the left column and - Thu, Fri & Sat/Sun down the right. */ - if (day < 3) { - *day_x = week_view->col_offsets[0]; - *day_w = week_view->col_widths[0]; - } else { - *day_x = week_view->col_offsets[1]; - *day_w = week_view->col_widths[1]; - } - - if (day < 5) { - row = (day % 3) * 2; - *day_y = week_view->row_offsets[row]; - *day_h = week_view->row_heights[row] - + week_view->row_heights[row + 1]; - } else { - /* Saturday & Sunday. */ - *day_y = week_view->row_offsets[day - 1]; - *day_h = week_view->row_heights[day - 1]; - } - } -} - - -/* Returns the bounding box for a span of an event. Usually this can easily - be determined by the start & end days and row of the span, which are set in - e_week_view_layout_event(). Though we need a special case for the weekends - when they are compressed, since the span may not fit. */ -gboolean -e_week_view_get_span_position (EWeekView *week_view, - gint event_num, - gint span_num, - gint *span_x, - gint *span_y, - gint *span_w) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint end_day_of_week, num_days; - gint start_x, start_y, start_w, start_h; - gint end_x, end_y, end_w, end_h; - - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - g_return_val_if_fail (event_num < week_view->events->len, FALSE); - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - - g_return_val_if_fail (span_num < event->num_spans, FALSE); - - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (span->row >= week_view->rows_per_cell) - return FALSE; - - end_day_of_week = (span->start_day + span->num_days - 1) % 7; - num_days = span->num_days; - /* Check if the row will not be visible in compressed cells. */ - if (span->row >= week_view->rows_per_compressed_cell) { - if (week_view->display_month) { - if (week_view->compress_weekend) { - /* If it ends on a Saturday and is 1 day long - we skip it, else we shorten it. If it ends - on a Sunday it must be 1 day long and we - skip it. */ - if (end_day_of_week == 5) { /* Sat */ - if (num_days == 1) { - return FALSE; - } else { - num_days--; - } - } else if (end_day_of_week == 6) { /* Sun */ - return FALSE; - } - } - } else { - /* All spans are 1 day long in the week view, so we - just skip it. */ - if (end_day_of_week > 4) - return FALSE; - } - } - - e_week_view_get_day_position (week_view, span->start_day, - &start_x, &start_y, &start_w, &start_h); - *span_y = start_y + week_view->events_y_offset - + span->row * (week_view->row_height - + E_WEEK_VIEW_EVENT_Y_SPACING); - if (num_days == 1) { - *span_x = start_x; - *span_w = start_w; - } else { - e_week_view_get_day_position (week_view, - span->start_day + num_days - 1, - &end_x, &end_y, &end_w, &end_h); - *span_x = start_x; - *span_w = end_x - start_x + end_w; - } - - return TRUE; -} - - - -static gboolean -e_week_view_on_button_press (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view) -{ - gint x, y, day; - -#if 0 - g_print ("In e_week_view_on_button_press\n"); -#endif - - /* Handle scroll wheel events */ - if (event->button == 4 || event->button == 5) { - GtkAdjustment *adj = GTK_RANGE (week_view->vscrollbar)->adjustment; - gfloat new_value; - - new_value = adj->value + ((event->button == 4) ? - -adj->page_increment: - adj->page_increment); - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, new_value); - - return TRUE; - } - - /* If an event is pressed just return. */ - if (week_view->pressed_event_num != -1) - return FALSE; - - /* Convert the mouse position to a week & day. */ - x = event->x; - y = event->y; - day = e_week_view_convert_position_to_day (week_view, x, y); - if (day == -1) - return FALSE; - - /* Start the selection drag. */ - if (event->button == 1) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->time) == 0) { - week_view->selection_start_day = day; - week_view->selection_end_day = day; - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_END; - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (week_view->main_canvas); - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - e_week_view_show_popup_menu (week_view, event, -1); - } - - return FALSE; -} - - -static gboolean -e_week_view_on_button_release (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view) -{ - time_t start, end; - -#if 0 - g_print ("In e_week_view_on_button_release\n"); -#endif - - if (week_view->selection_drag_pos != E_WEEK_VIEW_DRAG_NONE) { - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE; - gdk_pointer_ungrab (event->time); - start = week_view->day_starts[week_view->selection_start_day]; - end = week_view->day_starts[week_view->selection_end_day + 1]; - gnome_calendar_set_selected_time_range (week_view->calendar, - start, end); - } - - return FALSE; -} - - -static gboolean -e_week_view_on_motion (GtkWidget *widget, - GdkEventMotion *mevent, - EWeekView *week_view) -{ - gint x, y, day; - -#if 0 - g_print ("In e_week_view_on_motion\n"); -#endif - - /* Convert the mouse position to a week & day. */ - x = mevent->x; - y = mevent->y; - day = e_week_view_convert_position_to_day (week_view, x, y); - if (day == -1) - return FALSE; - - if (week_view->selection_drag_pos != E_WEEK_VIEW_DRAG_NONE) { - e_week_view_update_selection (week_view, day); - return TRUE; - } - - return FALSE; -} - - -/* Converts a position in the canvas window to a day offset from the first - day displayed. Returns -1 if the position is outside the grid. */ -static gint -e_week_view_convert_position_to_day (EWeekView *week_view, - gint x, - gint y) -{ - gint col, row, grid_x = -1, grid_y = -1, week, day; - - /* First we convert it to a grid position. */ - for (col = 0; col <= week_view->columns; col++) { - if (x < week_view->col_offsets[col]) { - grid_x = col - 1; - break; - } - } - - for (row = 0; row <= week_view->rows; row++) { - if (y < week_view->row_offsets[row]) { - grid_y = row - 1; - break; - } - } - - /* If the mouse is outside the grid return FALSE. */ - if (grid_x == -1 || grid_y == -1) - return -1; - - /* Now convert the grid position to a week and day. */ - if (week_view->display_month) { - week = grid_y / 2; - if (week_view->compress_weekend && grid_x == 5 - && grid_y % 2 == 1) - day = 6; - else - day = grid_x; - } else { - week = 0; - if (grid_x == 0) - day = grid_y / 2; - else if (grid_y == 5) - day = 6; - else - day = grid_y / 2 + 3; - } - - return week * 7 + day; -} - - -static void -e_week_view_update_selection (EWeekView *week_view, - gint day) -{ - gint tmp_day; - gboolean need_redraw = FALSE; - -#if 0 - g_print ("Updating selection %i,%i\n", week, day); -#endif - - if (week_view->selection_drag_pos == E_WEEK_VIEW_DRAG_START) { - if (day != week_view->selection_start_day) { - need_redraw = TRUE; - week_view->selection_start_day = day; - } - } else { - if (day != week_view->selection_end_day) { - need_redraw = TRUE; - week_view->selection_end_day = day; - } - } - - /* Switch the drag position if necessary. */ - if (week_view->selection_start_day > week_view->selection_end_day) { - tmp_day = week_view->selection_start_day; - week_view->selection_start_day = week_view->selection_end_day; - week_view->selection_end_day = tmp_day; - if (week_view->selection_drag_pos == E_WEEK_VIEW_DRAG_START) - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_END; - else - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_START; - } - - /* FIXME: Optimise? */ - if (need_redraw) { - gtk_widget_queue_draw (week_view->main_canvas); - } -} - - -static void -e_week_view_reload_events (EWeekView *week_view) -{ - gint num_days; - - e_week_view_free_events (week_view); - - if (week_view->calendar - && g_date_valid (&week_view->first_day_shown)) { - num_days = week_view->display_month - ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - - cal_client_generate_instances (week_view->calendar->client, - CALOBJ_TYPE_EVENT, - week_view->day_starts[0], - week_view->day_starts[num_days], - e_week_view_add_event, - week_view); - } - - e_week_view_check_layout (week_view); - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -static void -e_week_view_free_events (EWeekView *week_view) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint event_num, span_num; - - for (event_num = 0; event_num < week_view->events->len; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - gtk_object_unref (GTK_OBJECT (event->comp)); - } - - g_array_set_size (week_view->events, 0); - - /* Destroy all the old canvas items. */ - if (week_view->spans) { - for (span_num = 0; span_num < week_view->spans->len; - span_num++) { - span = &g_array_index (week_view->spans, - EWeekViewEventSpan, span_num); - if (span->background_item) - gtk_object_destroy (GTK_OBJECT (span->background_item)); - if (span->text_item) - gtk_object_destroy (GTK_OBJECT (span->text_item)); - } - g_array_free (week_view->spans, TRUE); - week_view->spans = NULL; - } -} - - -/* This adds one event to the view, adding it to the appropriate array. */ -static gboolean -e_week_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data) - -{ - EWeekView *week_view; - EWeekViewEvent event; - gint num_days; - struct tm start_tm, end_tm; - - week_view = E_WEEK_VIEW (data); - - /* Check that the event times are valid. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - -#if 0 - g_print ("View start:%li end:%li Event start:%li end:%li\n", - week_view->day_starts[0], week_view->day_starts[num_days], - start, end); -#endif - - g_return_val_if_fail (start <= end, TRUE); - g_return_val_if_fail (start < week_view->day_starts[num_days], TRUE); - g_return_val_if_fail (end > week_view->day_starts[0], TRUE); - - start_tm = *(localtime (&start)); - end_tm = *(localtime (&end)); - - event.comp = comp; - gtk_object_ref (GTK_OBJECT (event.comp)); - event.start = start; - event.end = end; - event.spans_index = 0; - event.num_spans = 0; - - event.start_minute = start_tm.tm_hour * 60 + start_tm.tm_min; - event.end_minute = end_tm.tm_hour * 60 + end_tm.tm_min; - if (event.end_minute == 0 && start != end) - event.end_minute = 24 * 60; - - g_array_append_val (week_view->events, event); - week_view->events_sorted = FALSE; - week_view->events_need_layout = TRUE; - - return TRUE; -} - - -/* This lays out the events, or reshapes them, as necessary. */ -static void -e_week_view_check_layout (EWeekView *week_view) -{ - /* Don't bother if we aren't visible. */ - if (!GTK_WIDGET_VISIBLE (week_view)) - return; - - /* Make sure the events are sorted (by start and size). */ - e_week_view_ensure_events_sorted (week_view); - - if (week_view->events_need_layout) - e_week_view_layout_events (week_view); - - if (week_view->events_need_layout || week_view->events_need_reshape) - e_week_view_reshape_events (week_view); - - week_view->events_need_layout = FALSE; - week_view->events_need_reshape = FALSE; -} - - -static void -e_week_view_layout_events (EWeekView *week_view) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint num_days, day, event_num, span_num; - guint8 *grid; - GArray *spans, *old_spans; - - /* This is a temporary 2-d grid which is used to place events. - Each element is 0 if the position is empty, or 1 if occupied. - We allocate the maximum size possible here, assuming that each - event will need its own row. */ - grid = g_new0 (guint8, E_WEEK_VIEW_MAX_ROWS_PER_CELL * 7 - * E_WEEK_VIEW_MAX_WEEKS); - - /* We create a new array of spans, which will replace the old one. */ - spans = g_array_new (FALSE, FALSE, sizeof (EWeekViewEventSpan)); - - /* Clear the number of rows used per day. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - for (day = 0; day <= num_days; day++) { - week_view->rows_per_day[day] = 0; - } - - /* Iterate over the events, finding which weeks they cover, and putting - them in the first free row available. */ - for (event_num = 0; event_num < week_view->events->len; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - e_week_view_layout_event (week_view, event, grid, spans); - } - - /* Free the grid. */ - g_free (grid); - - /* Replace the spans array. */ - old_spans = week_view->spans; - week_view->spans = spans; - - /* Destroy the old spans array, destroying any unused canvas items. */ - if (old_spans) { - for (span_num = 0; span_num < old_spans->len; span_num++) { - span = &g_array_index (old_spans, EWeekViewEventSpan, - span_num); - if (span->background_item) - gtk_object_destroy (GTK_OBJECT (span->background_item)); - if (span->text_item) - gtk_object_destroy (GTK_OBJECT (span->text_item)); - } - g_array_free (old_spans, TRUE); - } -} - - -static void -e_week_view_layout_event (EWeekView *week_view, - EWeekViewEvent *event, - guint8 *grid, - GArray *spans) -{ - gint start_day, end_day, span_start_day, span_end_day, rows_per_cell; - gint free_row, row, day, span_num, spans_index, num_spans, max_day; - EWeekViewEventSpan span, *old_span; - - start_day = e_week_view_find_day (week_view, event->start, FALSE); - end_day = e_week_view_find_day (week_view, event->end, TRUE); - max_day = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 - 1 - : 7 - 1; - start_day = CLAMP (start_day, 0, max_day); - end_day = CLAMP (end_day, 0, max_day); - -#if 0 - g_print ("In e_week_view_layout_event Start:%i End: %i\n", - start_day, end_day); -#endif - - /* Iterate through each of the spans of the event, where each span - is a sequence of 1 or more days displayed next to each other. */ - span_start_day = start_day; - rows_per_cell = E_WEEK_VIEW_MAX_ROWS_PER_CELL; - span_num = 0; - spans_index = spans->len; - num_spans = 0; - while (span_start_day <= end_day) { - span_end_day = e_week_view_find_span_end (week_view, - span_start_day); - span_end_day = MIN (span_end_day, end_day); -#if 0 - g_print (" Span start:%i end:%i\n", span_start_day, - span_end_day); -#endif - /* Try each row until we find a free one or we fall off the - bottom of the available rows. */ - row = 0; - free_row = -1; - while (free_row == -1 && row < rows_per_cell) { - free_row = row; - for (day = span_start_day; day <= span_end_day; - day++) { - if (grid[day * rows_per_cell + row]) { - free_row = -1; - break; - } - } - row++; - }; - - if (free_row != -1) { - /* Mark the cells as full. */ - for (day = span_start_day; day <= span_end_day; - day++) { - grid[day * rows_per_cell + free_row] = 1; - week_view->rows_per_day[day] = MAX (week_view->rows_per_day[day], free_row + 1); - } -#if 0 - g_print (" Span start:%i end:%i row:%i\n", - span_start_day, span_end_day, free_row); -#endif - /* Add the span to the array, and try to reuse any - canvas items from the old spans. */ - span.start_day = span_start_day; - span.num_days = span_end_day - span_start_day + 1; - span.row = free_row; - span.background_item = NULL; - span.text_item = NULL; - if (event->num_spans > span_num) { - old_span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num); - span.background_item = old_span->background_item; - span.text_item = old_span->text_item; - old_span->background_item = NULL; - old_span->text_item = NULL; - } - - g_array_append_val (spans, span); - num_spans++; - } - - span_start_day = span_end_day + 1; - span_num++; - } - - /* Set the event's spans. */ - event->spans_index = spans_index; - event->num_spans = num_spans; -} - - -static void -e_week_view_ensure_events_sorted (EWeekView *week_view) -{ - if (!week_view->events_sorted) { - qsort (week_view->events->data, - week_view->events->len, - sizeof (EWeekViewEvent), - e_week_view_event_sort_func); - week_view->events_sorted = TRUE; - } -} - - -static gint -e_week_view_event_sort_func (const void *arg1, - const void *arg2) -{ - EWeekViewEvent *event1, *event2; - - event1 = (EWeekViewEvent*) arg1; - event2 = (EWeekViewEvent*) arg2; - - if (event1->start < event2->start) - return -1; - if (event1->start > event2->start) - return 1; - - if (event1->end > event2->end) - return -1; - if (event1->end < event2->end) - return 1; - - return 0; -} - - -static void -e_week_view_reshape_events (EWeekView *week_view) -{ - EWeekViewEvent *event; - gint event_num, span_num; - gint num_days, day, day_x, day_y, day_w, day_h, max_rows; - gboolean is_weekend; - - for (event_num = 0; event_num < week_view->events->len; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - for (span_num = 0; span_num < event->num_spans; span_num++) { - e_week_view_reshape_event_span (week_view, event_num, - span_num); - } - } - - /* Reshape the jump buttons and show/hide them as appropriate. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - for (day = 0; day < num_days; day++) { - - is_weekend = (day % 7 >= 5) ? TRUE : FALSE; - if (!is_weekend || (week_view->display_month - && !week_view->compress_weekend)) - max_rows = week_view->rows_per_cell; - else - max_rows = week_view->rows_per_compressed_cell; - - /* Determine whether the jump button should be shown. */ - if (week_view->rows_per_day[day] <= max_rows) { - gnome_canvas_item_hide (week_view->jump_buttons[day]); - } else { - e_week_view_get_day_position (week_view, day, - &day_x, &day_y, - &day_w, &day_h); - - gnome_canvas_item_set (week_view->jump_buttons[day], - "GnomeCanvasPixbuf::x", (gdouble) (day_x + day_w - E_WEEK_VIEW_JUMP_BUTTON_X_PAD - E_WEEK_VIEW_JUMP_BUTTON_WIDTH), - "GnomeCanvasPixbuf::y", (gdouble) (day_y + day_h - E_WEEK_VIEW_JUMP_BUTTON_Y_PAD - E_WEEK_VIEW_JUMP_BUTTON_HEIGHT), - NULL); - - gnome_canvas_item_show (week_view->jump_buttons[day]); - gnome_canvas_item_raise_to_top (week_view->jump_buttons[day]); - } - } - - for (day = num_days; day < E_WEEK_VIEW_MAX_WEEKS * 7; day++) { - gnome_canvas_item_hide (week_view->jump_buttons[day]); - } -} - - -static void -e_week_view_reshape_event_span (EWeekView *week_view, - gint event_num, - gint span_num) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - GdkFont *font; - gint span_x, span_y, span_w, num_icons, icons_width, time_width; - gint min_text_x, max_text_w, width; - gboolean show_icons = TRUE, use_max_width = FALSE; - gboolean one_day_event; - CalComponent *comp; - gdouble text_x, text_y, text_w, text_h; - gchar *text, *end_of_line; - gint line_len, text_width; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - comp = event->comp; - font = GTK_WIDGET (week_view)->style->font; - - one_day_event = e_week_view_is_one_day_event (week_view, event_num); - - /* If the span will not be visible destroy the canvas items and - return. */ - if (!e_week_view_get_span_position (week_view, event_num, span_num, - &span_x, &span_y, &span_w)) { - if (span->background_item) - gtk_object_destroy (GTK_OBJECT (span->background_item)); - if (span->text_item) - gtk_object_destroy (GTK_OBJECT (span->text_item)); - span->background_item = NULL; - span->text_item = NULL; - return; - } - - if (!one_day_event && week_view->editing_event_num == event_num - && week_view->editing_span_num == span_num) { - show_icons = FALSE; - use_max_width = TRUE; - } - - num_icons = 0; -#if 0 - if (show_icons) { - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) - num_icons++; - if (ico->recur) - num_icons++; - } -#endif - - /* Create the background canvas item if necessary. */ - if (!span->background_item) { - span->background_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root), - e_week_view_event_item_get_type (), - NULL); - } - - gnome_canvas_item_set (span->background_item, - "event_num", event_num, - "span_num", span_num, - NULL); - - /* Create the text item if necessary. */ - if (!span->text_item) { - CalComponentText text; - - cal_component_get_summary (comp, &text); - span->text_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root), - e_text_get_type (), - "font_gdk", GTK_WIDGET (week_view)->style->font, - "anchor", GTK_ANCHOR_NW, - "clip", TRUE, -#if 0 - "max_lines", 1, -#endif - "editable", TRUE, - "text", text.value ? text.value : "", - "use_ellipsis", TRUE, - NULL); - gtk_signal_connect (GTK_OBJECT (span->text_item), "event", - GTK_SIGNAL_FUNC (e_week_view_on_text_item_event), - week_view); - } - - /* Calculate the position of the text item. - For events < 1 day it starts after the times & icons and ends at the - right edge of the span. - For events > 1 day we need to determine whether times are shown at - the start and end of the span, then try to center the text item with - the icons in the middle, but making sure we don't go over the times. - */ - - - /* Calculate the space necessary to display a time, e.g. "13:00". */ - if (week_view->use_small_font && week_view->small_font) - time_width = week_view->digit_width * 2 - + week_view->small_digit_width * 2; - else - time_width = week_view->digit_width * 4 - + week_view->colon_width; - - /* Calculate the space needed for the icons. */ - icons_width = (E_WEEK_VIEW_ICON_WIDTH + E_WEEK_VIEW_ICON_X_PAD) - * num_icons; - - /* The y position and height are the same for both event types. */ - text_y = span_y + E_WEEK_VIEW_EVENT_BORDER_HEIGHT - + E_WEEK_VIEW_EVENT_TEXT_Y_PAD; - text_h = font->ascent + font->descent; - - if (one_day_event) { - text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD + icons_width; - - switch (week_view->time_format) { - case E_WEEK_VIEW_TIME_BOTH_SMALL_MIN: - case E_WEEK_VIEW_TIME_BOTH: - text_x += time_width * 2 + week_view->space_width - + E_WEEK_VIEW_EVENT_TIME_R_PAD; - break; - case E_WEEK_VIEW_TIME_START_SMALL_MIN: - case E_WEEK_VIEW_TIME_START: - text_x += time_width + E_WEEK_VIEW_EVENT_TIME_R_PAD; - break; - case E_WEEK_VIEW_TIME_NONE: - break; - } - text_w = span_x + span_w - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_R_PAD - text_x; - - } else { - if (use_max_width) { - text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - text_w = span_x + span_w - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD - text_x; - } else { - /* Get the requested size of the label. */ - gtk_object_get (GTK_OBJECT (span->text_item), - "text", &text, - NULL); - text_width = 0; - if (text) { - end_of_line = strchr (text, '\n'); - if (end_of_line) - line_len = end_of_line - text; - else - line_len = strlen (text); - text_width = gdk_text_width (font, text, line_len); - g_free (text); - } - - /* Add on the width of the icons and find the default - position. */ - width = text_width + icons_width; - text_x = span_x + (span_w - width) / 2; - - /* Now calculate the left-most valid position, and make - sure we don't go to the left of that. */ - min_text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - if (event->start > week_view->day_starts[span->start_day]) - min_text_x += time_width - + E_WEEK_VIEW_EVENT_TIME_R_PAD; - - text_x = MAX (text_x, min_text_x); - - /* Now calculate the largest valid width, using the - calculated x position, and make sure we don't - exceed that. */ - max_text_w = span_x + span_w - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD - text_x; - if (event->end < week_view->day_starts[span->start_day - + span->num_days]) - max_text_w -= time_width - + E_WEEK_VIEW_EVENT_TIME_R_PAD; - - text_w = MIN (width, max_text_w); - - /* Now take out the space for the icons. */ - text_x += icons_width; - text_w -= icons_width; - } - } - - text_w = MAX (text_w, 0); - gnome_canvas_item_set (span->text_item, - "clip_width", (gdouble) text_w, - "clip_height", (gdouble) text_h, - NULL); - e_canvas_item_move_absolute(span->text_item, - text_x, text_y); -} - - -/* Finds the day containing the given time. - If include_midnight_in_prev_day is TRUE then if the time exactly - matches the start of a day the previous day is returned. This is useful - when calculating the end day of an event. */ -static gint -e_week_view_find_day (EWeekView *week_view, - time_t time_to_find, - gboolean include_midnight_in_prev_day) -{ - gint num_days, day; - time_t *day_starts; - - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - day_starts = week_view->day_starts; - - if (time_to_find < day_starts[0]) - return -1; - if (time_to_find > day_starts[num_days]) - return num_days; - - for (day = 1; day <= num_days; day++) { - if (time_to_find <= day_starts[day]) { - if (time_to_find == day_starts[day] - && !include_midnight_in_prev_day) - return day; - return day - 1; - } - } - - g_assert_not_reached (); - return num_days; -} - - -/* This returns the last day in the same span as the given day. A span is all - the days which are displayed next to each other from left to right. - In the week view all spans are only 1 day, since Tuesday is below Monday - rather than beside it etc. In the month view, if the weekends are not - compressed then each week is a span, otherwise Monday to Saturday of each - week is a span, and the Sundays are separate spans. */ -static gint -e_week_view_find_span_end (EWeekView *week_view, - gint day) -{ - gint week, day_of_week, end_day; - - if (week_view->display_month) { - week = day / 7; - day_of_week = day % 7; - if (week_view->compress_weekend && day_of_week <= 5) - end_day = 5; - else - end_day = 6; - return week * 7 + end_day; - } else { - return day; - } -} - - -static void -e_week_view_on_adjustment_changed (GtkAdjustment *adjustment, - EWeekView *week_view) -{ - GDate date; - gint week_offset; - struct tm tm; - time_t lower, start, end; - guint32 old_first_day_julian, new_first_day_julian; - - /* If we don't have a valid date set yet, just return. */ - if (!g_date_valid (&week_view->first_day_shown)) - return; - - /* Determine the first date shown. */ - date = week_view->base_date; - week_offset = floor (adjustment->value + 0.5); - g_date_add_days (&date, week_offset * 7); - - /* Convert the old & new first days shown to julian values. */ - old_first_day_julian = g_date_julian (&week_view->first_day_shown); - new_first_day_julian = g_date_julian (&date); - - /* If we are already showing the date, just return. */ - if (old_first_day_julian == new_first_day_julian) - return; - - /* Set the new first day shown. */ - week_view->first_day_shown = date; - - /* Convert it to a time_t. */ - g_date_to_struct_tm (&date, &tm); - lower = mktime (&tm); - lower = time_day_begin (lower); - - e_week_view_recalc_day_starts (week_view, lower); - e_week_view_reload_events (week_view); - - /* Update the selection, if needed. */ - if (week_view->selection_start_day != -1) { - start = week_view->day_starts[week_view->selection_start_day]; - end = week_view->day_starts[week_view->selection_end_day + 1]; - gnome_calendar_set_selected_time_range (week_view->calendar, - start, end); - } - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -void -e_week_view_start_editing_event (EWeekView *week_view, - gint event_num, - gint span_num, - gchar *initial_text) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - ETextEventProcessor *event_processor = NULL; - ETextEventProcessorCommand command; - - /* If we are already editing the event, just return. */ - if (event_num == week_view->editing_event_num - && span_num == week_view->editing_span_num) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - /* If the event is not shown, don't try to edit it. */ - if (!span->text_item) - return; - - if (initial_text) { - gnome_canvas_item_set (span->text_item, - "text", initial_text, - NULL); - } - - e_canvas_item_grab_focus (span->text_item); - - /* Try to move the cursor to the end of the text. */ - gtk_object_get (GTK_OBJECT (span->text_item), - "event_processor", &event_processor, - NULL); - if (event_processor) { - command.action = E_TEP_MOVE; - command.position = E_TEP_END_OF_BUFFER; - gtk_signal_emit_by_name (GTK_OBJECT (event_processor), - "command", &command); - } -} - - -/* This stops the current edit. If accept is TRUE the event summary is update, - else the edit is cancelled. */ -void -e_week_view_stop_editing_event (EWeekView *week_view) -{ - GtkWidget *toplevel; - - /* Check we are editing an event. */ - if (week_view->editing_event_num == -1) - return; - - /* Set focus to the toplevel so the item loses focus. */ - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (week_view)); - if (toplevel && GTK_IS_WINDOW (toplevel)) - gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); -} - - -static gboolean -e_week_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view) -{ - gint event_num, span_num; - -#if 0 - g_print ("In e_week_view_on_text_item_event\n"); -#endif - - switch (event->type) { - case GDK_KEY_PRESS: - if (event && event->key.keyval == GDK_Return) { - /* We set the keyboard focus to the EDayView, so the - EText item loses it and stops the edit. */ - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - - /* Stop the signal last or we will also stop any - other events getting to the EText item. */ - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - return TRUE; - } - break; - case GDK_BUTTON_PRESS: - if (!e_week_view_find_event_from_item (week_view, item, - &event_num, &span_num)) - return FALSE; - - if (event->button.button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - e_week_view_show_popup_menu (week_view, - (GdkEventButton*) event, - event_num); - gtk_signal_emit_stop_by_name (GTK_OBJECT (item->canvas), - "button_press_event"); - return TRUE; - } - - week_view->pressed_event_num = event_num; - week_view->pressed_span_num = span_num; - - /* Only let the EText handle the event while editing. */ - if (!E_TEXT (item)->editing) { - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - - if (event) { - week_view->drag_event_x = event->button.x; - week_view->drag_event_y = event->button.y; - } else - g_warning ("No GdkEvent"); - - /* FIXME: Remember the day offset from the start of - the event. */ - - return TRUE; - } - break; - case GDK_BUTTON_RELEASE: - if (!E_TEXT (item)->editing) { - /* This shouldn't ever happen. */ - if (!e_week_view_find_event_from_item (week_view, - item, - &event_num, - &span_num)) - return FALSE; - - if (week_view->pressed_event_num != -1 - && week_view->pressed_event_num == event_num - && week_view->pressed_span_num == span_num) { - e_week_view_start_editing_event (week_view, - event_num, - span_num, - NULL); - week_view->pressed_event_num = -1; - } - - /* Stop the signal last or we will also stop any - other events getting to the EText item. */ - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - return TRUE; - } - week_view->pressed_event_num = -1; - break; - case GDK_FOCUS_CHANGE: - if (event->focus_change.in) { - e_week_view_on_editing_started (week_view, item); - } else { - e_week_view_on_editing_stopped (week_view, item); - } - - return FALSE; - default: - break; - } - - return FALSE; -} - - -static void -e_week_view_on_editing_started (EWeekView *week_view, - GnomeCanvasItem *item) -{ - gint event_num, span_num; - - if (!e_week_view_find_event_from_item (week_view, item, - &event_num, &span_num)) - return; - -#if 0 - g_print ("In e_week_view_on_editing_started event_num:%i span_num:%i\n", event_num, span_num); -#endif - - week_view->editing_event_num = event_num; - week_view->editing_span_num = span_num; - - /* We need to reshape long events so the whole width is used while - editing. */ - if (!e_week_view_is_one_day_event (week_view, event_num)) { - e_week_view_reshape_event_span (week_view, event_num, - span_num); - } -} - - -static void -e_week_view_on_editing_stopped (EWeekView *week_view, - GnomeCanvasItem *item) -{ - gint event_num, span_num; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gchar *text = NULL; - CalComponentText summary; - const char *uid; - - /* Note: the item we are passed here isn't reliable, so we just stop - the edit of whatever item was being edited. We also receive this - event twice for some reason. */ - event_num = week_view->editing_event_num; - span_num = week_view->editing_span_num; - - /* If no item is being edited, just return. */ - if (event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - /* Reset the edit fields. */ - week_view->editing_event_num = -1; - week_view->editing_new_event = FALSE; - - /* Check that the event is still valid. */ - cal_component_get_uid (event->comp, &uid); - if (!uid) - return; - - gtk_object_get (GTK_OBJECT (span->text_item), - "text", &text, - NULL); - - /* Only update the summary if necessary. */ - cal_component_get_summary (event->comp, &summary); - if (text && summary.value && !strcmp (text, summary.value)) { - g_free (text); - if (!e_week_view_is_one_day_event (week_view, event_num)) - e_week_view_reshape_event_span (week_view, event_num, - span_num); - return; - } - - summary.value = text; - cal_component_set_summary (event->comp, &summary); - g_free (text); - - if (!cal_client_update_object (week_view->calendar->client, event->comp)) - g_message ("e_week_view_on_editing_stopped(): Could not update the object!"); -} - - -static gboolean -e_week_view_find_event_from_item (EWeekView *week_view, - GnomeCanvasItem *item, - gint *event_num_return, - gint *span_num_return) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint event_num, span_num, num_events; - - num_events = week_view->events->len; - for (event_num = 0; event_num < num_events; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - for (span_num = 0; span_num < event->num_spans; span_num++) { - span = &g_array_index (week_view->spans, - EWeekViewEventSpan, - event->spans_index + span_num); - if (span->text_item == item) { - *event_num_return = event_num; - *span_num_return = span_num; - return TRUE; - } - } - } - - return FALSE; -} - - -/* Finds the index of the event with the given uid. - Returns TRUE if an event with the uid was found. - Note that for recurring events there may be several EWeekViewEvents, one - for each instance, all with the same iCalObject and uid. So only use this - function if you know the event doesn't recur or you are just checking to - see if any events with the uid exist. */ -static gboolean -e_week_view_find_event_from_uid (EWeekView *week_view, - const gchar *uid, - gint *event_num_return) -{ - EWeekViewEvent *event; - gint event_num, num_events; - - num_events = week_view->events->len; - for (event_num = 0; event_num < num_events; event_num++) { - const char *u; - - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - *event_num_return = event_num; - return TRUE; - } - } - - return FALSE; -} - - -gboolean -e_week_view_is_one_day_event (EWeekView *week_view, - gint event_num) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - if (event->num_spans != 1) - return FALSE; - - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index); - - if (event->start == week_view->day_starts[span->start_day] - && event->end == week_view->day_starts[span->start_day + 1]) - return FALSE; - - if (span->num_days == 1 - && event->start >= week_view->day_starts[span->start_day] - && event->end <= week_view->day_starts[span->start_day + 1]) - return TRUE; - - return FALSE; -} - - -static gint -e_week_view_key_press (GtkWidget *widget, GdkEventKey *event) -{ - EWeekView *week_view; - CalComponent *comp; - gint event_num; - gchar *initial_text; - CalComponentDateTime date; - time_t dtstart, dtend; - const char *uid; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - week_view = E_WEEK_VIEW (widget); - - /* The Escape key aborts a resize operation. */ -#if 0 - if (week_view->resize_drag_pos != E_WEEK_VIEW_POS_NONE) { - if (event->keyval == GDK_Escape) { - e_week_view_abort_resize (week_view, event->time); - } - return FALSE; - } -#endif - - if (week_view->selection_start_day == -1) - return FALSE; - - /* We only want to start an edit with a return key or a simple - character. */ - if (event->keyval == GDK_Return) { - initial_text = NULL; - } else if ((event->keyval < 0x20) - || (event->keyval > 0xFF) - || (event->length == 0) - || (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) { - return FALSE; - } else { - initial_text = event->string; - } - - /* Add a new event covering the selected range. */ - comp = cal_component_new (); - dtstart = week_view->day_starts[week_view->selection_start_day]; - dtend = week_view->day_starts[week_view->selection_end_day + 1]; - - date.value = g_new0 (struct icaltimetype, 1); - *date.value = icaltimetype_from_timet (dtstart, FALSE); - cal_component_set_dtstart (comp, &date); - *date.value = icaltimetype_from_timet (dtend, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - /* We add the event locally and start editing it. When we get the - "update_event" callback from the server, we basically ignore it. - If we were to wait for the "update_event" callback it wouldn't be - as responsive and we may lose a few keystrokes. */ - e_week_view_add_event (comp, dtstart, dtend, week_view); - e_week_view_check_layout (week_view); - gtk_widget_queue_draw (week_view->main_canvas); - - cal_component_get_uid (comp, &uid); - if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { - e_week_view_start_editing_event (week_view, event_num, 0, - initial_text); - week_view->editing_new_event = TRUE; - } else { - g_warning ("Couldn't find event to start editing.\n"); - } - - if (!cal_client_update_object (week_view->calendar->client, comp)) - g_message ("e_week_view_key_press(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return TRUE; -} - - -void -e_week_view_show_popup_menu (EWeekView *week_view, - GdkEventButton *bevent, - gint event_num) -{ - EWeekViewEvent *event; - int have_selection, not_being_edited, num_items, i; - struct menu_item *context_menu; - - static struct menu_item items[] = { - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_week_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this appointment"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item recur_child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_week_view_on_edit_appointment, NULL, TRUE }, - { N_("Make this appointment movable"), (GtkSignalFunc) e_week_view_on_unrecur_appointment, NULL, TRUE }, - { N_("Delete this occurrence"), (GtkSignalFunc) e_week_view_on_delete_occurrence, NULL, TRUE }, - { N_("Delete all occurrences"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; - - have_selection = GTK_WIDGET_HAS_FOCUS (week_view) - && week_view->selection_start_day != -1; - - if (event_num == -1) { - num_items = 1; - context_menu = &items[0]; - context_menu[0].sensitive = have_selection; - } else { - event = &g_array_index (week_view->events, - EWeekViewEvent, event_num); - - /* This used to be set only if the event wasn't being edited - in the event editor, but we can't check that at present. - We could possibly set up another method of checking it. */ - not_being_edited = TRUE; - - if (cal_component_has_rrules (event->comp) - || cal_component_has_rdates (event->comp)) { - num_items = 6; - context_menu = &recur_child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[2].sensitive = not_being_edited; - context_menu[3].sensitive = not_being_edited; - context_menu[5].sensitive = have_selection; - } else { - num_items = 4; - context_menu = &child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[3].sensitive = have_selection; - } - } - - for (i = 0; i < num_items; i++) - context_menu[i].data = week_view; - - week_view->popup_event_num = event_num; - popup_menu (context_menu, num_items, bevent); -} - - -static void -e_week_view_on_new_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - CalComponent *comp; - CalComponentDateTime date; - week_view = E_WEEK_VIEW (data); - - comp = cal_component_new (); - - date.value = g_new0 (struct icaltimetype, 1); - - *date.value = - icaltimetype_from_timet (week_view->day_starts[week_view->selection_start_day], - FALSE); - cal_component_set_dtstart (comp, &date); - - *date.value = - icaltimetype_from_timet (week_view->day_starts[week_view->selection_end_day + 1], - FALSE); - cal_component_set_dtend (comp, &date); - - g_free (date.value); - - gnome_calendar_edit_object (week_view->calendar, comp); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_week_view_on_edit_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - gnome_calendar_edit_object (week_view->calendar, event->comp); -} - - -static void -e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - CalComponent *comp; - CalComponentDateTime *date=NULL; - GSList *list; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - /* We must duplicate the CalComponent, or we won't know it has changed - when we get the "update_event" callback. */ - - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - list = g_slist_append (list, date); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - if (!cal_client_update_object (week_view->calendar->client, comp)) - g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_week_view_on_delete_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - const char *uid; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - cal_component_get_uid (event->comp, &uid); - if (!cal_client_remove_object (week_view->calendar->client, uid)) - g_message ("e_week_view_on_delete_appointment(): Could not remove the object!"); -} - - -static void -e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - CalComponent *comp, *new_comp; - CalComponentDateTime *date; - GSList *list; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - /* For the recurring object, we add a exception to get rid of the - instance. */ - - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - list = g_slist_append (list, date); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - /* For the unrecurred instance we duplicate the original object, - create a new uid for it, get rid of the recurrence rules, and set - the start & end times to the instances times. */ - new_comp = cal_component_clone (event->comp); - cal_component_set_uid (new_comp, cal_component_gen_uid ()); - cal_component_set_exdate_list (new_comp, NULL); - cal_component_set_exrule_list (new_comp, NULL); - - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - - *date->value = icaltimetype_from_timet (event->start, TRUE); - cal_component_set_dtstart (new_comp, date); - *date->value = icaltimetype_from_timet (event->end, TRUE); - cal_component_set_dtend (new_comp, date); - - cal_component_free_datetime (date); - - /* Now update both CalComponents. Note that we do this last since at - present the updates happen synchronously so our event may disappear. - */ - if (!cal_client_update_object (week_view->calendar->client, comp)) - g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - if (!cal_client_update_object (week_view->calendar->client, new_comp)) - g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (new_comp)); -} - - -static gboolean -e_week_view_on_jump_button_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view) -{ - gint day; - - if (event->type == GDK_BUTTON_PRESS) { - for (day = 0; day < E_WEEK_VIEW_MAX_WEEKS * 7; day++) { - if (item == week_view->jump_buttons[day]) { - gnome_calendar_dayjump (week_view->calendar, - week_view->day_starts[day]); - /* A quick hack to make the 'Day' toolbar - button active. */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (week_view->calendar->view_toolbar_buttons[0]), TRUE); - return TRUE; - } - } - - } - - return FALSE; -} diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h deleted file mode 100644 index dc2b01e4ff..0000000000 --- a/calendar/gui/e-week-view.h +++ /dev/null @@ -1,380 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef _E_WEEK_VIEW_H_ -#define _E_WEEK_VIEW_H_ - -#include <gtk/gtktable.h> -#include <libgnomeui/gnome-canvas.h> - -#include "gnome-cal.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekView - displays the Week & Month views of the calendar. - */ - -/* The maximum number of weeks we show. 5 is usually enough for 1 month. */ -#define E_WEEK_VIEW_MAX_WEEKS 5 - -/* The size of the reminder & recurrence icons, and padding around them. */ -#define E_WEEK_VIEW_ICON_WIDTH 16 -#define E_WEEK_VIEW_ICON_HEIGHT 16 -#define E_WEEK_VIEW_ICON_X_PAD 0 -#define E_WEEK_VIEW_ICON_Y_PAD 0 - -/* The space on the left & right of the event. (The triangle to indicate the - event continues is displayed in this space). */ -#define E_WEEK_VIEW_EVENT_L_PAD 2 -#define E_WEEK_VIEW_EVENT_R_PAD 3 - -/* The vertical spacing between rows of events. */ -#define E_WEEK_VIEW_EVENT_Y_SPACING 1 - -/* The size of the border around the event. */ -#define E_WEEK_VIEW_EVENT_BORDER_WIDTH 1 -#define E_WEEK_VIEW_EVENT_BORDER_HEIGHT 1 - -/* The padding on each side of the event text. */ -#define E_WEEK_VIEW_EVENT_TEXT_X_PAD 4 -#define E_WEEK_VIEW_EVENT_TEXT_Y_PAD 1 - -/* The space on the right of the time string, if it is shown. */ -#define E_WEEK_VIEW_EVENT_TIME_R_PAD 2 - -/* The padding above and on the right of the date string at the top of each - cell. */ -#define E_WEEK_VIEW_DATE_T_PAD 2 -#define E_WEEK_VIEW_DATE_R_PAD 4 - -/* The padding above and below the line under the date string, in the Week - view, and also the space on the left of it. */ -#define E_WEEK_VIEW_DATE_LINE_T_PAD 1 -#define E_WEEK_VIEW_DATE_LINE_B_PAD 1 -#define E_WEEK_VIEW_DATE_LINE_L_PAD 10 - -/* The padding below the date string in the Month view. */ -#define E_WEEK_VIEW_DATE_B_PAD 1 - -/* These index our colors array. */ -typedef enum -{ - E_WEEK_VIEW_COLOR_EVEN_MONTHS, - E_WEEK_VIEW_COLOR_ODD_MONTHS, - E_WEEK_VIEW_COLOR_EVENT_BACKGROUND, - E_WEEK_VIEW_COLOR_EVENT_BORDER, - - E_WEEK_VIEW_COLOR_LAST -} EWeekViewColors; - -/* These specify which part of the selection we are dragging, if any. */ -typedef enum -{ - E_WEEK_VIEW_DRAG_NONE, - E_WEEK_VIEW_DRAG_START, - E_WEEK_VIEW_DRAG_END -} EWeekViewDragPosition; - -/* These specify which times are shown for the 1-day events. We use the small - font for the minutes if it can be loaded and the option is on. */ -typedef enum -{ - E_WEEK_VIEW_TIME_NONE, - E_WEEK_VIEW_TIME_START, - E_WEEK_VIEW_TIME_BOTH, - E_WEEK_VIEW_TIME_START_SMALL_MIN, - E_WEEK_VIEW_TIME_BOTH_SMALL_MIN -} EWeekViewTimeFormat; - -/* Specifies the position of the mouse. */ -typedef enum -{ - E_WEEK_VIEW_POS_OUTSIDE, - E_WEEK_VIEW_POS_NONE, - E_WEEK_VIEW_POS_EVENT, - E_WEEK_VIEW_POS_LEFT_EDGE, - E_WEEK_VIEW_POS_RIGHT_EDGE -} EWeekViewPosition; - - -typedef struct _EWeekViewEventSpan EWeekViewEventSpan; -struct _EWeekViewEventSpan { - guint start_day : 6; - guint num_days : 3; - guint row : 7; - GnomeCanvasItem *background_item; - GnomeCanvasItem *text_item; -}; - -typedef struct _EWeekViewEvent EWeekViewEvent; -struct _EWeekViewEvent { - CalComponent *comp; - time_t start; - time_t end; - guint16 start_minute; /* Minutes from the start of the day. */ - guint16 end_minute; - gint spans_index; - guint num_spans; -}; - - -#define E_WEEK_VIEW(obj) GTK_CHECK_CAST (obj, e_week_view_get_type (), EWeekView) -#define E_WEEK_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_week_view_get_type (), EWeekViewClass) -#define E_IS_WEEK_VIEW(obj) GTK_CHECK_TYPE (obj, e_week_view_get_type ()) - - -typedef struct _EWeekView EWeekView; -typedef struct _EWeekViewClass EWeekViewClass; - -struct _EWeekView -{ - GtkTable table; - - /* The top canvas where the dates are shown. */ - GtkWidget *titles_canvas; - GnomeCanvasItem *titles_canvas_item; - - /* The main canvas where the appointments are shown. */ - GtkWidget *main_canvas; - GnomeCanvasItem *main_canvas_item; - - GnomeCanvasItem *jump_buttons[E_WEEK_VIEW_MAX_WEEKS * 7]; - - GtkWidget *vscrollbar; - - /* The calendar we are associated with. */ - GnomeCalendar *calendar; - - /* The array of EWeekViewEvent elements. */ - GArray *events; - gboolean events_sorted; - gboolean events_need_layout; - gboolean events_need_reshape; - - /* An array of EWeekViewEventSpan elements. Each event has its own - space within this array, and uses the spans_index and num_spans - fields of the EWeekViewEvent struct to access it. */ - GArray *spans; - - /* The start of each day displayed. */ - time_t day_starts[E_WEEK_VIEW_MAX_WEEKS * 7 + 1]; - - /* The base date, where the adjustment value is 0. */ - GDate base_date; - - /* The first day shown in the view. */ - GDate first_day_shown; - - /* If we are displaying 1 week or 1 month. */ - gboolean display_month; - - /* If Sat & Sun are compressed. Only applicable in month view, since - they are always compressed into 1 cell in the week view. */ - gboolean compress_weekend; - - /* The vertical offset of the events from the top of the cells. */ - gint events_y_offset; - - /* The height of the events, not including spacing between them. */ - gint row_height; - - /* The number of rows of events in each cell. */ - gint rows_per_cell; - gint rows_per_compressed_cell; - - /* The number of rows we have used for each day (i.e. each cell) */ - gint rows_per_day[E_WEEK_VIEW_MAX_WEEKS * 7]; - - /* If the small font is used for displaying the minutes. */ - gboolean use_small_font; - - /* Small font to display the minutes. */ - GdkFont *small_font; - - /* The widths of various pieces of text, used to determine which of - several date formats to display, set in e_week_view_style_set(). */ - gint space_width; /* One space character ' '. */ - gint colon_width; /* Size of ':' in the font. */ - gint slash_width; /* Size of '/' in the font. */ - gint digit_width; /* Size of a '0' digit. */ - gint small_digit_width; /* Size of a small_font '0' digit. */ - gint day_widths[7]; /* Monday first. */ - gint max_day_width; - gint abbr_day_widths[7]; - gint max_abbr_day_width; - gint month_widths[12]; - gint max_month_width; - gint abbr_month_widths[12]; - gint max_abbr_month_width; - - /* The size of the main grid of days and of the cells. Note that the - offsets arrays have one more element than the widths/heights arrays - since they also contain the right/bottom edge. */ - gint rows; - gint columns; - gint col_widths[7]; - gint col_offsets[8]; - gint row_heights[10]; - gint row_offsets[11]; - - /* This specifies which times we are showing for the events, depending - on how much room is available. */ - EWeekViewTimeFormat time_format; - - /* The GC used for painting in different colors. */ - GdkGC *main_gc; - - /* The icons. */ - GdkPixmap *reminder_icon; - GdkBitmap *reminder_mask; - GdkPixmap *recurrence_icon; - GdkBitmap *recurrence_mask; - - /* Colors for drawing. */ - GdkColor colors[E_WEEK_VIEW_COLOR_LAST]; - - /* The normal & resizing cursors. */ - GdkCursor *normal_cursor; - GdkCursor *move_cursor; - GdkCursor *resize_width_cursor; - - /* This remembers the last cursor set on the window. */ - GdkCursor *last_cursor_set; - - /* The currently selected region, in days from the first day shown. - If selection_start_day is -1 there is no current selection. */ - gint selection_start_day; - gint selection_end_day; - - /* This specifies which end of the selection is being dragged, or is - E_WEEK_VIEW_DRAG_NONE if the selection isn't being dragged. */ - EWeekViewDragPosition selection_drag_pos; - - /* This is the event the mouse button was pressed on. If the button - is released we start editing it, but if the mouse is dragged we set - this to -1. */ - gint pressed_event_num; - gint pressed_span_num; - - /* The event span currently being edited. The num is -1 if no event is - being edited. */ - gint editing_event_num; - gint editing_span_num; - - /* This is TRUE if we are editing an event which we have just created. - We ignore the "update_event" callback which we will get from the - server when the event is added. */ - gboolean editing_new_event; - - /* The event that the context menu is for. */ - gint popup_event_num; - - /* The last mouse position when dragging, in the entire canvas. */ - gint drag_event_x; - gint drag_event_y; -}; - -struct _EWeekViewClass -{ - GtkTableClass parent_class; -}; - - -GtkType e_week_view_get_type (void); -GtkWidget* e_week_view_new (void); - -void e_week_view_set_calendar (EWeekView *week_view, - GnomeCalendar *calendar); - -/* This sets the selected time range. The EWeekView will show the corresponding - month and the days between start_time and end_time will be selected. - To select a single day, use the same value for start_time & end_time. */ -void e_week_view_set_selected_time_range (EWeekView *week_view, - time_t start_time, - time_t end_time); - -/* Returns the selected time range. */ -void e_week_view_get_selected_time_range (EWeekView *week_view, - time_t *start_time, - time_t *end_time); - -/* Whether to display 1 week or 1 month (5 weeks). It defaults to 1 week. */ -gboolean e_week_view_get_display_month (EWeekView *week_view); -void e_week_view_set_display_month (EWeekView *week_view, - gboolean display_month); - -/* Whether the weekend (Sat/Sun) should be compressed into 1 cell in the Month - view. In the Week view they are always compressed. */ -gboolean e_week_view_get_compress_weekend (EWeekView *week_view); -void e_week_view_set_compress_weekend (EWeekView *week_view, - gboolean compress); - -/* This reloads all calendar events. */ -void e_week_view_update_all_events (EWeekView *week_view); - -/* This is called when one event has been added or updated. */ -void e_week_view_update_event (EWeekView *week_view, - const gchar *uid); - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void e_week_view_remove_event (EWeekView *week_view, - const gchar *uid); - - -/* - * Internal functions called by the associated canvas items. - */ -void e_week_view_get_day_position (EWeekView *week_view, - gint day, - gint *day_x, - gint *day_y, - gint *day_w, - gint *day_h); -gboolean e_week_view_get_span_position (EWeekView *week_view, - gint event_num, - gint span_num, - gint *span_x, - gint *span_y, - gint *span_w); -gboolean e_week_view_is_one_day_event (EWeekView *week_view, - gint event_num); -void e_week_view_start_editing_event (EWeekView *week_view, - gint event_num, - gint span_num, - gchar *initial_text); -void e_week_view_stop_editing_event (EWeekView *week_view); - -void e_week_view_show_popup_menu (EWeekView *week_view, - GdkEventButton *event, - gint event_num); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_H_ */ diff --git a/calendar/gui/event-editor-dialog.glade b/calendar/gui/event-editor-dialog.glade deleted file mode 100644 index d166bca079..0000000000 --- a/calendar/gui/event-editor-dialog.glade +++ /dev/null @@ -1,2024 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>event-editor-dialog</name> - <program_name>event-editor-dialog</program_name> - <directory></directory> - <source_directory>.</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_main_file>False</output_main_file> - <output_support_files>False</output_support_files> - <output_build_files>False</output_build_files> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>event-editor-dialog.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>event-editor-dialog</name> - <visible>False</visible> - <title>event-editor-dialog</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock2</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkNotebook</class> - <child_name>GnomeDock:contents</child_name> - <name>dialog-contents</name> - <border_width>2</border_width> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>6</spacing> - - <widget> - <class>GtkTable</class> - <name>table5</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <name>general-owner</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>general-summary</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label41</name> - <label>_Summary:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>7.45058e-09</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>general-summary</focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label13</name> - <label>_Owner:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>7.45058e-09</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>general-owner</focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame4</name> - <label>Time</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <border_width>4</border_width> - <rows>2</rows> - <columns>3</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GtkLabel</class> - <name>label15</name> - <label>Start time:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label16</name> - <label>End time:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>start-time</name> - <creation_function>make_date_edit_with_time</creation_function> - <string1></string1> - <string2></string2> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Tue, 16 May 2000 19:11:05 GMT</last_modification_time> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>end-time</name> - <creation_function>make_date_edit_with_time</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Tue, 16 May 2000 19:11:10 GMT</last_modification_time> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>all-day-event</name> - <can_focus>True</can_focus> - <label>A_ll day event</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow3</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkText</class> - <name>description</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame5</name> - <label>Classification</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHBox</class> - <name>hbox6</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkRadioButton</class> - <name>classification-radio</name> - <can_focus>True</can_focus> - <label>Pu_blic</label> - <active>True</active> - <draw_indicator>True</draw_indicator> - <group>classification_radio_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name></name> - <can_focus>True</can_focus> - <label>Pri_vate</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>classification_radio_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name></name> - <can_focus>True</can_focus> - <label>_Confidential</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>classification_radio_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label11</name> - <label>General</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>5</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-display-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>True</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-audio-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-program-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-mail-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-display-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-audio-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-program-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-mail-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>alarm-mail-mail-to</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>4</left_attach> - <right_attach>5</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GnomeFileEntry</class> - <name>alarm-program-run-program</name> - <max_saved>10</max_saved> - <directory>False</directory> - <modal>False</modal> - <child> - <left_attach>4</left_attach> - <right_attach>5</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GnomeEntry:entry</child_name> - <name>alarm-program-run-program-entry</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-display</name> - <can_focus>True</can_focus> - <label>_Display</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-audio</name> - <can_focus>True</can_focus> - <label>_Audio</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-program</name> - <can_focus>True</can_focus> - <label>_Program</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-mail</name> - <can_focus>True</can_focus> - <label>_Mail</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label18</name> - <label>Mail _to:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>7.45058e-09</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>alarm-mail-mail-to</focus_target> - <child> - <left_attach>3</left_attach> - <right_attach>4</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label17</name> - <label>_Run program:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>alarm-program-run-program-entry</focus_target> - <child> - <left_attach>3</left_attach> - <right_attach>4</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label42</name> - <label>Reminder</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox3</name> - <border_width>6</border_width> - <homogeneous>False</homogeneous> - <spacing>6</spacing> - - <widget> - <class>GtkFrame</class> - <name>frame8</name> - <label>Recurrence rule</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHBox</class> - <name>hbox7</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkVBox</class> - <name>vbox4</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-none</name> - <can_focus>True</can_focus> - <label>None</label> - <active>True</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-daily</name> - <can_focus>True</can_focus> - <label>Daily</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-weekly</name> - <can_focus>True</can_focus> - <label>Weekly</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-monthly</name> - <can_focus>True</can_focus> - <label>Monthly</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-yearly</name> - <can_focus>True</can_focus> - <label>Yearly</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkVSeparator</class> - <name>vseparator1</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkNotebook</class> - <name>recurrence-rule-notebook</name> - <show_tabs>False</show_tabs> - <show_border>False</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table6</name> - <rows>3</rows> - <columns>3</columns> - <homogeneous>False</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>0</column_spacing> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label23</name> - <label>label23</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkAlignment</class> - <name>alignment1</name> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xscale>1</xscale> - <yscale>1</yscale> - - <widget> - <class>GtkVBox</class> - <name>vbox7</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox13</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label31</name> - <label>Every </label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-daily-days</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label32</name> - <label>day(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label24</name> - <label>label24</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox8</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox14</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label33</name> - <label>Every </label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-weekly-weeks</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label34</name> - <label>week(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox15</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-mon</name> - <can_focus>True</can_focus> - <label>Mon</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-tue</name> - <can_focus>True</can_focus> - <label>Tue</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-wed</name> - <can_focus>True</can_focus> - <label>Wed</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-thu</name> - <can_focus>True</can_focus> - <label>Thu</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-fri</name> - <can_focus>True</can_focus> - <label>Fri</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-sat</name> - <can_focus>True</can_focus> - <label>Sat</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-sun</name> - <can_focus>True</can_focus> - <label>Sun</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label25</name> - <label>label25</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table8</name> - <rows>2</rows> - <columns>4</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>2</column_spacing> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-monthly-on-day</name> - <can_focus>True</can_focus> - <label>Recur on the</label> - <active>True</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_monthly_group</group> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-monthly-weekday</name> - <can_focus>True</can_focus> - <label>Recur on the</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_monthly_group</group> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label35</name> - <label>th day of the month</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>recurrence-rule-monthly-week</name> - <can_focus>True</can_focus> - <items>1st -2nd -3rd -4th -5th -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>recurrence-rule-monthly-weekpos</name> - <can_focus>True</can_focus> - <items>Monday -Tuesday -Wednesday -Thursday -Friday -Saturday -Sunday -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox19</name> - <border_width>3</border_width> - <homogeneous>False</homogeneous> - <spacing>3</spacing> - <child> - <left_attach>3</left_attach> - <right_attach>4</right_attach> - <top_attach>0</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label36</name> - <label>Every</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-monthly-every-n-months</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>1</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label37</name> - <label>month(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-monthly-day-nth</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label26</name> - <label>label26</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox11</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox20</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label38</name> - <label>Every </label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-yearly-every-n-years</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label39</name> - <label>year(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label27</name> - <label>label27</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox8</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkFrame</class> - <name>frame9</name> - <label>Ending date</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox5</name> - <border_width>4</border_width> - <homogeneous>True</homogeneous> - <spacing>2</spacing> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-ending-date-repeat-forever</name> - <can_focus>True</can_focus> - <label>Repeat forever</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_ending_date</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox12</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-ending-date-end-on</name> - <can_focus>True</can_focus> - <label>End on </label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_ending_date</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>recurrence-ending-date-end-on-date</name> - <width>100</width> - <creation_function>make_date_edit</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Sat, 13 May 2000 18:02:55 GMT</last_modification_time> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox10</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-ending-date-end-after</name> - <can_focus>True</can_focus> - <label>End after</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_ending_date</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-ending-date-end-after-count</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>2</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label28</name> - <label>occurrence(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame10</name> - <label>Exceptions</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox12</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>Custom</class> - <name>recurrence-exceptions-date</name> - <creation_function>make_date_edit</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Tue, 16 May 2000 01:42:29 GMT</last_modification_time> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox21</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox13</name> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>recurrence-exceptions-add</name> - <can_focus>True</can_focus> - <label>Add</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>recurrence-exceptions-change</name> - <can_focus>True</can_focus> - <label>Change</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>recurrence-exceptions-delete</name> - <can_focus>True</can_focus> - <label>Delete</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow2</name> - <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkCList</class> - <name>recurrence-exceptions-list</name> - <can_focus>True</can_focus> - <columns>1</columns> - <column_widths>80</column_widths> - <selection_mode>GTK_SELECTION_SINGLE</selection_mode> - <show_titles>False</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label40</name> - <label></label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label12</name> - <label>Recurrence</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - - <widget> - <class>GnomeAppBar</class> - <child_name>GnomeApp:appbar</child_name> - <name>appbar2</name> - <has_progress>True</has_progress> - <has_status>True</has_status> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/event-editor-dialog.glade.h b/calendar/gui/event-editor-dialog.glade.h deleted file mode 100644 index d921f3746a..0000000000 --- a/calendar/gui/event-editor-dialog.glade.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("event-editor-dialog"); -gchar *s = N_("_Summary:"); -gchar *s = N_("_Owner:"); -gchar *s = N_("Time"); -gchar *s = N_("Start time:"); -gchar *s = N_("End time:"); -gchar *s = N_("A_ll day event"); -gchar *s = N_("Classification"); -gchar *s = N_("Pu_blic"); -gchar *s = N_("Pri_vate"); -gchar *s = N_("_Confidential"); -gchar *s = N_("General"); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("_Display"); -gchar *s = N_("_Audio"); -gchar *s = N_("_Program"); -gchar *s = N_("_Mail"); -gchar *s = N_("Mail _to:"); -gchar *s = N_("_Run program:"); -gchar *s = N_("Reminder"); -gchar *s = N_("Recurrence rule"); -gchar *s = N_("None"); -gchar *s = N_("Daily"); -gchar *s = N_("Weekly"); -gchar *s = N_("Monthly"); -gchar *s = N_("Yearly"); -gchar *s = N_("label23"); -gchar *s = N_("Every "); -gchar *s = N_("day(s)"); -gchar *s = N_("label24"); -gchar *s = N_("Every "); -gchar *s = N_("week(s)"); -gchar *s = N_("Mon"); -gchar *s = N_("Tue"); -gchar *s = N_("Wed"); -gchar *s = N_("Thu"); -gchar *s = N_("Fri"); -gchar *s = N_("Sat"); -gchar *s = N_("Sun"); -gchar *s = N_("label25"); -gchar *s = N_("Recur on the"); -gchar *s = N_("Recur on the"); -gchar *s = N_("th day of the month"); -gchar *s = N_("1st\n" - "2nd\n" - "3rd\n" - "4th\n" - "5th\n" - ""); -gchar *s = N_("Monday\n" - "Tuesday\n" - "Wednesday\n" - "Thursday\n" - "Friday\n" - "Saturday\n" - "Sunday\n" - ""); -gchar *s = N_("Every"); -gchar *s = N_("month(s)"); -gchar *s = N_("label26"); -gchar *s = N_("Every "); -gchar *s = N_("year(s)"); -gchar *s = N_("label27"); -gchar *s = N_("Ending date"); -gchar *s = N_("Repeat forever"); -gchar *s = N_("End on "); -gchar *s = N_("End after"); -gchar *s = N_("occurrence(s)"); -gchar *s = N_("Exceptions"); -gchar *s = N_("Add"); -gchar *s = N_("Change"); -gchar *s = N_("Delete"); -gchar *s = N_("Recurrence"); diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c deleted file mode 100644 index ff4a6e7e29..0000000000 --- a/calendar/gui/event-editor.c +++ /dev/null @@ -1,1985 +0,0 @@ -/* Evolution calendar - Event editor dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * Seth Alves <alves@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <e-util/e-dialog-widgets.h> -#include <cal-util/timeutil.h> -#include "event-editor.h" - - - - -typedef struct { - /* Glade XML data */ - GladeXML *xml; - - /* UI handler */ - BonoboUIHandler *uih; - - /* Calendar object we are editing; this is an internal copy and is not - * one of the read-only objects from the parent calendar. - */ - CalComponent *comp; - - /* Widgets from the Glade file */ - - GtkWidget *app; - - GtkWidget *general_owner; - GtkWidget *general_summary; - - GtkWidget *start_time; - GtkWidget *end_time; - GtkWidget *all_day_event; - - GtkWidget *description; - - GtkWidget *alarm_display; - GtkWidget *alarm_program; - GtkWidget *alarm_audio; - GtkWidget *alarm_mail; - GtkWidget *alarm_display_amount; - GtkWidget *alarm_display_unit; - GtkWidget *alarm_audio_amount; - GtkWidget *alarm_audio_unit; - GtkWidget *alarm_program_amount; - GtkWidget *alarm_program_unit; - GtkWidget *alarm_program_run_program; - GtkWidget *alarm_program_run_program_entry; - GtkWidget *alarm_mail_amount; - GtkWidget *alarm_mail_unit; - GtkWidget *alarm_mail_mail_to; - - GtkWidget *classification_radio; - - GtkWidget *recurrence_rule_notebook; - GtkWidget *recurrence_rule_none; - GtkWidget *recurrence_rule_daily; - GtkWidget *recurrence_rule_weekly; - GtkWidget *recurrence_rule_monthly; - GtkWidget *recurrence_rule_yearly; - - GtkWidget *recurrence_rule_daily_days; - - GtkWidget *recurrence_rule_weekly_weeks; - GtkWidget *recurrence_rule_weekly_sun; - GtkWidget *recurrence_rule_weekly_mon; - GtkWidget *recurrence_rule_weekly_tue; - GtkWidget *recurrence_rule_weekly_wed; - GtkWidget *recurrence_rule_weekly_thu; - GtkWidget *recurrence_rule_weekly_fri; - GtkWidget *recurrence_rule_weekly_sat; - - GtkWidget *recurrence_rule_monthly_on_day; - GtkWidget *recurrence_rule_monthly_weekday; - GtkWidget *recurrence_rule_monthly_day_nth; - GtkWidget *recurrence_rule_monthly_week; - GtkWidget *recurrence_rule_monthly_weekpos; - GtkWidget *recurrence_rule_monthly_every_n_months; - GtkWidget *recurrence_rule_yearly_every_n_years; - - GtkWidget *recurrence_ending_date_repeat_forever; - GtkWidget *recurrence_ending_date_end_on; - GtkWidget *recurrence_ending_date_end_on_date; - GtkWidget *recurrence_ending_date_end_after; - GtkWidget *recurrence_ending_date_end_after_count; - - GtkWidget *recurrence_exceptions_date; - GtkWidget *recurrence_exceptions_list; - GtkWidget *recurrence_exception_add; - GtkWidget *recurrence_exception_delete; - GtkWidget *recurrence_exception_change; - - GtkWidget *exception_list; - GtkWidget *exception_date; -} EventEditorPrivate; - - - -/* Signal IDs */ -enum { - SAVE_ICAL_OBJECT, - ICAL_OBJECT_RELEASED, - EDITOR_CLOSED, - LAST_SIGNAL -}; - -static void event_editor_class_init (EventEditorClass *class); -static void event_editor_init (EventEditor *ee); -static void event_editor_destroy (GtkObject *object); - -static GtkObjectClass *parent_class; - -extern int day_begin, day_end; -extern char *user_name; -extern int am_pm_flag; -extern int week_starts_on_monday; - - -static void append_exception (EventEditor *ee, time_t t); -static void check_all_day (EventEditor *ee); -static void set_all_day (GtkWidget *toggle, EventEditor *ee); -static void alarm_toggle (GtkWidget *toggle, EventEditor *ee); -static void check_dates (GnomeDateEdit *gde, EventEditor *ee); -static void check_times (GnomeDateEdit *gde, EventEditor *ee); -static void recurrence_toggled (GtkWidget *radio, EventEditor *ee); -static void recurrence_exception_added (GtkWidget *widget, EventEditor *ee); -static void recurrence_exception_deleted (GtkWidget *widget, EventEditor *ee); -static void recurrence_exception_changed (GtkWidget *widget, EventEditor *ee); - -static guint event_editor_signals[LAST_SIGNAL]; - - - -/** - * event_editor_get_type: - * @void: - * - * Registers the #EventEditor class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #EventEditor class. - **/ -GtkType -event_editor_get_type (void) -{ - static GtkType event_editor_type = 0; - - if (!event_editor_type) { - static const GtkTypeInfo event_editor_info = { - "EventEditor", - sizeof (EventEditor), - sizeof (EventEditorClass), - (GtkClassInitFunc) event_editor_class_init, - (GtkObjectInitFunc) event_editor_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - event_editor_type = gtk_type_unique (GTK_TYPE_OBJECT, &event_editor_info); - } - - return event_editor_type; -} - -/* Class initialization function for the event editor */ -static void -event_editor_class_init (EventEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - event_editor_signals[SAVE_ICAL_OBJECT] = - gtk_signal_new ("save_ical_object", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EventEditorClass, save_ical_object), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - event_editor_signals[ICAL_OBJECT_RELEASED] = - gtk_signal_new ("ical_object_released", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EventEditorClass, ical_object_released), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - event_editor_signals[EDITOR_CLOSED] = - gtk_signal_new ("editor_closed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EventEditorClass, editor_closed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, event_editor_signals, LAST_SIGNAL); - - object_class->destroy = event_editor_destroy; -} - -/* Object initialization function for the event editor */ -static void -event_editor_init (EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = g_new0 (EventEditorPrivate, 1); - ee->priv = priv; -} - -/* Destroy handler for the event editor */ -static void -event_editor_destroy (GtkObject *object) -{ - EventEditor *ee; - EventEditorPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_EVENT_EDITOR (object)); - - ee = EVENT_EDITOR (object); - priv = ee->priv; - - if (priv->uih) { - bonobo_object_unref (BONOBO_OBJECT (priv->uih)); - priv->uih = NULL; - } - - if (priv->app) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->app), ee); - gtk_widget_destroy (priv->app); - priv->app = NULL; - } - - if (priv->comp) { - /* We do not emit the "ical_object_released" signal here. If - * the user cloased the dialog box, then it has already been - * released. If the application just destroyed the event - * editor, then it had better clean up after itself. - */ - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - if (priv->xml) { - gtk_object_unref (GTK_OBJECT (priv->xml)); - priv->xml = NULL; - } - - g_free (priv); - ee->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Creates an appropriate title for the event editor dialog */ -static char * -make_title_from_comp (CalComponent *comp) -{ - const char *summary; - CalComponentVType type; - CalComponentText text; - - if (!comp) - return g_strdup (_("Edit Appointment")); - - cal_component_get_summary (comp, &text); - if (text.value) - summary = text.value; - else - summary = _("No summary"); - - - type = cal_component_get_vtype (comp); - switch (type) { - case CAL_COMPONENT_EVENT: - return g_strdup_printf (_("Appointment - %s"), summary); - - case CAL_COMPONENT_TODO: - return g_strdup_printf (_("Task - %s"), summary); - - case CAL_COMPONENT_JOURNAL: - return g_strdup_printf (_("Journal entry - %s"), summary); - - default: - g_message ("make_title_from_comp(): Cannot handle object of type %d", type); - return NULL; - } -} - -/* Gets the widgets from the XML file and returns if they are all available. - * For the widgets whose values can be simply set with e-dialog-utils, it does - * that as well. - */ -static gboolean -get_widgets (EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = ee->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - priv->app = GW ("event-editor-dialog"); - - priv->general_owner = GW ("general-owner"); - priv->general_summary = GW ("general-summary"); - - priv->start_time = GW ("start-time"); - priv->end_time = GW ("end-time"); - priv->all_day_event = GW ("all-day-event"); - - priv->description = GW ("description"); - - priv->alarm_display = GW ("alarm-display"); - priv->alarm_program = GW ("alarm-program"); - priv->alarm_audio = GW ("alarm-audio"); - priv->alarm_mail = GW ("alarm-mail"); - priv->alarm_display_amount = GW ("alarm-display-amount"); - priv->alarm_display_unit = GW ("alarm-display-unit"); - priv->alarm_audio_amount = GW ("alarm-audio-amount"); - priv->alarm_audio_unit = GW ("alarm-audio-unit"); - priv->alarm_program_amount = GW ("alarm-program-amount"); - priv->alarm_program_unit = GW ("alarm-program-unit"); - priv->alarm_program_run_program = GW ("alarm-program-run-program"); - priv->alarm_program_run_program_entry = GW ("alarm-program-run-program-entry"); - priv->alarm_mail_amount = GW ("alarm-mail-amount"); - priv->alarm_mail_unit = GW ("alarm-mail-unit"); - priv->alarm_mail_mail_to = GW ("alarm-mail-mail-to"); - - priv->classification_radio = GW ("classification-radio"); - - priv->recurrence_rule_notebook = GW ("recurrence-rule-notebook"); - priv->recurrence_rule_none = GW ("recurrence-rule-none"); - priv->recurrence_rule_daily = GW ("recurrence-rule-daily"); - priv->recurrence_rule_weekly = GW ("recurrence-rule-weekly"); - priv->recurrence_rule_monthly = GW ("recurrence-rule-monthly"); - priv->recurrence_rule_yearly = GW ("recurrence-rule-yearly"); - - priv->recurrence_rule_daily_days = GW ("recurrence-rule-daily-days"); - - priv->recurrence_rule_weekly_weeks = GW ("recurrence-rule-weekly-weeks"); - priv->recurrence_rule_weekly_sun = GW ("recurrence-rule-weekly-sun"); - priv->recurrence_rule_weekly_mon = GW ("recurrence-rule-weekly-mon"); - priv->recurrence_rule_weekly_tue = GW ("recurrence-rule-weekly-tue"); - priv->recurrence_rule_weekly_wed = GW ("recurrence-rule-weekly-wed"); - priv->recurrence_rule_weekly_thu = GW ("recurrence-rule-weekly-thu"); - priv->recurrence_rule_weekly_fri = GW ("recurrence-rule-weekly-fri"); - priv->recurrence_rule_weekly_sat = GW ("recurrence-rule-weekly-sat"); - - priv->recurrence_rule_monthly_on_day = GW ("recurrence-rule-monthly-on-day"); - priv->recurrence_rule_monthly_weekday = GW ("recurrence-rule-monthly-weekday"); - priv->recurrence_rule_monthly_day_nth = GW ("recurrence-rule-monthly-day-nth"); - priv->recurrence_rule_monthly_week = GW ("recurrence-rule-monthly-week"); - priv->recurrence_rule_monthly_weekpos = GW ("recurrence-rule-monthly-weekpos"); - priv->recurrence_rule_monthly_every_n_months = GW ("recurrence-rule-monthly-every-n-months"); - priv->recurrence_rule_yearly_every_n_years = GW ("recurrence-rule-yearly-every-n-years"); - - priv->recurrence_ending_date_repeat_forever = GW ("recurrence-ending-date-repeat-forever"); - priv->recurrence_ending_date_end_on = GW ("recurrence-ending-date-end-on"); - priv->recurrence_ending_date_end_on_date = GW ("recurrence-ending-date-end-on-date"); - priv->recurrence_ending_date_end_after = GW ("recurrence-ending-date-end-after"); - priv->recurrence_ending_date_end_after_count = GW ("recurrence-ending-date-end-after-count"); - - priv->recurrence_exceptions_date = GW ("recurrence-exceptions-date"); - priv->recurrence_exceptions_list = GW ("recurrence-exceptions-list"); - priv->recurrence_exception_add = GW ("recurrence-exceptions-add"); - priv->recurrence_exception_delete = GW ("recurrence-exceptions-delete"); - priv->recurrence_exception_change = GW ("recurrence-exceptions-change"); - - priv->exception_list = GW ("recurrence-exceptions-list"); - priv->exception_date = GW ("recurrence-exceptions-date"); - -#undef GW - - return (priv->general_owner - && priv->general_summary - && priv->start_time - && priv->end_time - && priv->all_day_event - && priv->description - && priv->alarm_display - && priv->alarm_program - && priv->alarm_audio - && priv->alarm_mail - && priv->alarm_display_amount - && priv->alarm_display_unit - && priv->alarm_audio_amount - && priv->alarm_audio_unit - && priv->alarm_program_amount - && priv->alarm_program_unit - && priv->alarm_program_run_program - && priv->alarm_program_run_program_entry - && priv->alarm_mail_amount - && priv->alarm_mail_unit - && priv->alarm_mail_mail_to - && priv->classification_radio - && priv->recurrence_rule_notebook - && priv->recurrence_rule_none - && priv->recurrence_rule_daily - && priv->recurrence_rule_weekly - && priv->recurrence_rule_monthly - && priv->recurrence_rule_yearly - && priv->recurrence_rule_daily_days - && priv->recurrence_rule_weekly_weeks - && priv->recurrence_rule_monthly_on_day - && priv->recurrence_rule_monthly_weekday - && priv->recurrence_rule_monthly_day_nth - && priv->recurrence_rule_monthly_week - && priv->recurrence_rule_monthly_weekpos - && priv->recurrence_rule_monthly_every_n_months - && priv->recurrence_rule_yearly_every_n_years - && priv->recurrence_ending_date_repeat_forever - && priv->recurrence_ending_date_end_on - && priv->recurrence_ending_date_end_on_date - && priv->recurrence_ending_date_end_after - && priv->recurrence_ending_date_end_after_count - && priv->recurrence_exceptions_date - && priv->recurrence_exceptions_list - && priv->recurrence_exception_add - && priv->recurrence_exception_delete - && priv->recurrence_exception_change - && priv->exception_list - && priv->exception_date); -} - -static const int classification_map[] = { - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, - -1 -}; - -#if 0 -static const int alarm_unit_map[] = { - ALARM_MINUTES, - ALARM_HOURS, - ALARM_DAYS, - -1 -}; - -static void -alarm_unit_set (GtkWidget *widget, enum AlarmUnit unit) -{ - e_dialog_option_menu_set (widget, unit, alarm_unit_map); -} - -static enum AlarmUnit -alarm_unit_get (GtkWidget *widget) -{ - return e_dialog_option_menu_get (widget, alarm_unit_map); -} -#endif - -/* Recurrence types for mapping them to radio buttons */ -static const int recur_options_map[] = { - ICAL_NO_RECURRENCE, - ICAL_DAILY_RECURRENCE, - ICAL_WEEKLY_RECURRENCE, - ICAL_MONTHLY_RECURRENCE, - ICAL_YEARLY_RECURRENCE, - -1 -}; - -static icalrecurrencetype_frequency -recur_options_get (GtkWidget *widget) -{ - return e_dialog_radio_get (widget, recur_options_map); -} - -static const int month_pos_map[] = { 0, 1, 2, 3, 4, -1 }; -static const int weekday_map[] = { 0, 1, 2, 3, 4, 5, 6, -1 }; - -/* Frees the rows and the row data in the recurrence exceptions GtkCList */ -static void -free_exception_clist_data (GtkCList *clist) -{ - int i; - - for (i = 0; i < clist->rows; i++) { - gpointer data; - - data = gtk_clist_get_row_data (clist, i); - g_free (data); - gtk_clist_set_row_data (clist, i, NULL); - } - - gtk_clist_clear (clist); -} - -/* Hooks the widget signals */ -static void -init_widgets (EventEditor *ee) -{ - EventEditorPrivate *priv; - GnomeDateEdit *gde; - GtkWidget *widget; - - priv = ee->priv; - - /* Start and end times */ - - gtk_signal_connect (GTK_OBJECT (priv->start_time), "date_changed", - GTK_SIGNAL_FUNC (check_dates), ee); - gtk_signal_connect (GTK_OBJECT (priv->start_time), "time_changed", - GTK_SIGNAL_FUNC (check_times), ee); - - gtk_signal_connect (GTK_OBJECT (priv->end_time), "date_changed", - GTK_SIGNAL_FUNC (check_dates), ee); - gtk_signal_connect (GTK_OBJECT (priv->end_time), "time_changed", - GTK_SIGNAL_FUNC (check_times), ee); - - gtk_signal_connect (GTK_OBJECT (priv->all_day_event), "toggled", - GTK_SIGNAL_FUNC (set_all_day), ee); - - /* Alarms */ - - gtk_signal_connect (GTK_OBJECT (priv->alarm_display), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - gtk_signal_connect (GTK_OBJECT (priv->alarm_program), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - gtk_signal_connect (GTK_OBJECT (priv->alarm_audio), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - gtk_signal_connect (GTK_OBJECT (priv->alarm_mail), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - - /* Recurrence types */ - - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_none), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_daily), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_weekly), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_monthly), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_yearly), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - - /* Exception buttons */ - - gtk_signal_connect (GTK_OBJECT (priv->recurrence_exception_add), "clicked", - GTK_SIGNAL_FUNC (recurrence_exception_added), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_exception_delete), "clicked", - GTK_SIGNAL_FUNC (recurrence_exception_deleted), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_exception_change), "clicked", - GTK_SIGNAL_FUNC (recurrence_exception_changed), ee); - - /* Hide the stupid 'Calendar' labels. */ - gde = GNOME_DATE_EDIT (priv->start_time); - gtk_widget_hide (gde->cal_label); - widget = gde->date_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - widget = gde->time_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - gtk_box_set_spacing (GTK_BOX (widget->parent), 2); - - gde = GNOME_DATE_EDIT (priv->end_time); - gtk_widget_hide (gde->cal_label); - widget = gde->date_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - widget = gde->time_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - gtk_box_set_spacing (GTK_BOX (widget->parent), 2); -} - -/* Fills the widgets with default values */ -static void -clear_widgets (EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t now; - - priv = ee->priv; - - now = time (NULL); - - /* Owner, summary */ - - e_dialog_editable_set (priv->general_owner, _("?")); - e_dialog_editable_set (priv->general_summary, NULL); - e_dialog_editable_set (priv->description, NULL); - - /* Start and end times */ - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - - e_dialog_dateedit_set (priv->start_time, now); - e_dialog_dateedit_set (priv->end_time, now); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - - check_all_day (ee); - - /* Alarms */ - - /* FIXMe: these should use configurable defaults */ - - e_dialog_toggle_set (priv->alarm_display, FALSE); - e_dialog_toggle_set (priv->alarm_program, FALSE); - e_dialog_toggle_set (priv->alarm_audio, FALSE); - e_dialog_toggle_set (priv->alarm_mail, FALSE); - - e_dialog_spin_set (priv->alarm_display_amount, 15); - e_dialog_spin_set (priv->alarm_audio_amount, 15); - e_dialog_spin_set (priv->alarm_program_amount, 15); - e_dialog_spin_set (priv->alarm_mail_amount, 15); - -#if 0 - alarm_unit_set (priv->alarm_display_unit, ALARM_MINUTES); - alarm_unit_set (priv->alarm_audio_unit, ALARM_MINUTES); - alarm_unit_set (priv->alarm_program_unit, ALARM_MINUTES); - alarm_unit_set (priv->alarm_mail_unit, ALARM_MINUTES); -#endif - - e_dialog_editable_set (priv->alarm_program_run_program_entry, NULL); - e_dialog_editable_set (priv->alarm_mail_mail_to, NULL); - - /* Classification */ - - e_dialog_radio_set (priv->classification_radio, - CAL_COMPONENT_CLASS_PRIVATE, classification_map); - - /* Recurrences */ - - e_dialog_radio_set (priv->recurrence_rule_none, ICAL_NO_RECURRENCE, recur_options_map); - - e_dialog_spin_set (priv->recurrence_rule_daily_days, 1); - - e_dialog_spin_set (priv->recurrence_rule_weekly_weeks, 1); - e_dialog_toggle_set (priv->recurrence_rule_weekly_sun, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_mon, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_tue, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_wed, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_thu, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_fri, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_sat, FALSE); - - e_dialog_toggle_set (priv->recurrence_rule_monthly_on_day, TRUE); - e_dialog_spin_set (priv->recurrence_rule_monthly_day_nth, 1); - e_dialog_spin_set (priv->recurrence_rule_monthly_every_n_months, 1); - e_dialog_option_menu_set (priv->recurrence_rule_monthly_week, 0, month_pos_map); - e_dialog_option_menu_set (priv->recurrence_rule_monthly_weekpos, 0, weekday_map); - e_dialog_spin_set (priv->recurrence_rule_monthly_every_n_months, 1); - - e_dialog_spin_set (priv->recurrence_rule_yearly_every_n_years, 1); - - e_dialog_toggle_set (priv->recurrence_ending_date_repeat_forever, TRUE); - e_dialog_spin_set (priv->recurrence_ending_date_end_after_count, 1); - e_dialog_dateedit_set (priv->recurrence_ending_date_end_on_date, - time_add_day (time (NULL), 1)); - - /* Exceptions list */ - - free_exception_clist_data (GTK_CLIST (priv->recurrence_exceptions_list)); -} - -/* Fills in the widgets with the proper values */ -static void -fill_widgets (EventEditor *ee) -{ - EventEditorPrivate *priv; - CalComponentText text; - CalComponentClassification cl; - CalComponentDateTime d; - GSList *list, *l; - time_t dtstart, dtend; - - priv = ee->priv; - - clear_widgets (ee); - - if (!priv->comp) - return; - - /* Owner, summary */ -#warning "FIX ME" - /* kludge until I figure out where to get the organizer */ -/* e_dialog_editable_set (priv->general_owner, */ -/* priv->ico->organizer->addr ? */ -/* priv->ico->organizer->addr : _("?")); */ - e_dialog_editable_set (priv->general_owner, _("?")); - - cal_component_get_summary (priv->comp, &text); - e_dialog_editable_set (priv->general_summary, text.value); - - cal_component_get_description_list (priv->comp, &l); - if (l) { - text = *(CalComponentText *)l->data; - e_dialog_editable_set (priv->description, text.value); - } - cal_component_free_text_list (l); - - /* Start and end times */ - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - - /* All-day events are inclusive, i.e. if the end date shown is 2nd Feb - then the event includes all of the 2nd Feb. We would normally show - 3rd Feb as the end date, since it really ends at midnight on 3rd, - so we have to subtract a day so we only show the 2nd. */ - cal_component_get_dtstart (priv->comp, &d); - dtstart = time_from_icaltimetype (*d.value); - cal_component_get_dtend (priv->comp, &d); - dtend = time_from_icaltimetype (*d.value); - if (time_day_begin (dtstart) == dtstart - && time_day_begin (dtend) == dtend) { - dtend = time_add_day (dtend, -1); - } - - e_dialog_dateedit_set (priv->start_time, dtstart); - e_dialog_dateedit_set (priv->end_time, dtend); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - - check_all_day (ee); - - /* Alarms */ -#if 0 - e_dialog_toggle_set (priv->alarm_display, priv->ico->dalarm.enabled); - e_dialog_toggle_set (priv->alarm_program, priv->ico->palarm.enabled); - e_dialog_toggle_set (priv->alarm_audio, priv->ico->aalarm.enabled); - e_dialog_toggle_set (priv->alarm_mail, priv->ico->malarm.enabled); -#endif - /* Alarm data */ -#if 0 - e_dialog_spin_set (priv->alarm_display_amount, priv->ico->dalarm.count); - e_dialog_spin_set (priv->alarm_audio_amount, priv->ico->aalarm.count); - e_dialog_spin_set (priv->alarm_program_amount, priv->ico->palarm.count); - e_dialog_spin_set (priv->alarm_mail_amount, priv->ico->malarm.count); - - alarm_unit_set (priv->alarm_display_unit, priv->ico->dalarm.units); - alarm_unit_set (priv->alarm_audio_unit, priv->ico->aalarm.units); - alarm_unit_set (priv->alarm_program_unit, priv->ico->palarm.units); - alarm_unit_set (priv->alarm_mail_unit, priv->ico->malarm.units); - - e_dialog_editable_set (priv->alarm_program_run_program_entry, priv->ico->palarm.data); - e_dialog_editable_set (priv->alarm_mail_mail_to, priv->ico->malarm.data); -#endif - /* Classification */ - cal_component_get_classification (priv->comp, &cl); - switch (cl) { - case CAL_COMPONENT_CLASS_PUBLIC: - e_dialog_radio_set (priv->classification_radio, CAL_COMPONENT_CLASS_PUBLIC, - classification_map); - case CAL_COMPONENT_CLASS_PRIVATE: - e_dialog_radio_set (priv->classification_radio, CAL_COMPONENT_CLASS_PRIVATE, - classification_map); - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - e_dialog_radio_set (priv->classification_radio, CAL_COMPONENT_CLASS_CONFIDENTIAL, - classification_map); - default: - /* What do do? We can't g_assert_not_reached() since it is a - * value from an external file. - */ - } - - /* Recurrences */ -#warning "FIX ME" - /* Need to handle recurrence dates as well as recurrence rules */ - /* Need to handle more than one rrule */ - if (cal_component_has_rrules (priv->comp)) { - struct icalrecurrencetype *r; - int i; - - cal_component_get_rrule_list (priv->comp, &list); - r = list->data; - - switch (r->freq) { - case ICAL_DAILY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_daily, ICAL_DAILY_RECURRENCE, - recur_options_map); - e_dialog_spin_set (priv->recurrence_rule_daily_days, r->interval); - break; - - case ICAL_WEEKLY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_weekly, ICAL_WEEKLY_RECURRENCE, - recur_options_map); - e_dialog_spin_set (priv->recurrence_rule_weekly_weeks, r->interval); - - e_dialog_toggle_set (priv->recurrence_rule_weekly_sun, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_mon, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_tue, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_wed, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_thu, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_fri, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_sat, FALSE); - - for (i=0; i<8 && r->by_day[i] != SHRT_MAX; i++) { - switch (r->by_day[i]) { - case ICAL_SUNDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_sun, TRUE); - break; - case ICAL_MONDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_mon, TRUE); - break; - case ICAL_TUESDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_tue, TRUE); - break; - case ICAL_WEDNESDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_wed, TRUE); - break; - case ICAL_THURSDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_thu, TRUE); - break; - case ICAL_FRIDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_fri, TRUE); - break; - case ICAL_SATURDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_sat, TRUE); - break; - default: - g_assert_not_reached (); - } - } - break; - - case ICAL_MONTHLY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_monthly, ICAL_MONTHLY_RECURRENCE, - recur_options_map); - - if (r->by_month_day[0] != SHRT_MAX) { - e_dialog_toggle_set (priv->recurrence_rule_monthly_on_day, TRUE); - e_dialog_spin_set (priv->recurrence_rule_monthly_day_nth, - r->by_month_day[0]); - } else if (r->by_day[0] != SHRT_MAX) { - e_dialog_toggle_set (priv->recurrence_rule_monthly_weekday, TRUE); - /* libical does not handle ints in by day */ -/* e_dialog_option_menu_set (priv->recurrence_rule_monthly_week, */ -/* priv->ico->recur->u.month_pos, */ -/* month_pos_map); */ -/* e_dialog_option_menu_set (priv->recurrence_rule_monthly_weekpos, */ -/* priv->ico->recur->weekday, */ -/* weekday_map); */ - } - - e_dialog_spin_set (priv->recurrence_rule_monthly_every_n_months, - r->interval); - break; - - case ICAL_YEARLY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_yearly, ICAL_YEARLY_RECURRENCE, - recur_options_map); - e_dialog_spin_set (priv->recurrence_rule_yearly_every_n_years, - r->interval); - break; - - default: - g_assert_not_reached (); - } - - if (r->until.year == 0) { - if (r->count == 0) - e_dialog_toggle_set (priv->recurrence_ending_date_repeat_forever, - TRUE); - else { - e_dialog_toggle_set (priv->recurrence_ending_date_end_after, TRUE); - e_dialog_spin_set (priv->recurrence_ending_date_end_after_count, - r->count); - } - } else { - time_t t = time_from_icaltimetype (r->until); - e_dialog_toggle_set (priv->recurrence_ending_date_end_on, TRUE); - /* Shorten by one day, as we store end-on date a day ahead */ - /* FIXME is this correct? */ - e_dialog_dateedit_set (priv->recurrence_ending_date_end_on_date, - time_add_day (t, -1)); - } - cal_component_free_recur_list (list); - } - - /* Exceptions list */ -#warning "FIX ME" - /* Need to handle exception rules as well as dates */ - cal_component_get_exdate_list (priv->comp, &list); - for (l = list; l; l = l->next) { - struct icaltimetype *t; - time_t ext; - - t = l->data; - ext = time_from_icaltimetype (*t); - append_exception (ee, ext); - } - cal_component_free_exdate_list (list); -} - - - -/* Decode the radio button group for classifications */ -static CalComponentClassification -classification_get (GtkWidget *widget) -{ - return e_dialog_radio_get (widget, classification_map); -} - -/* Get the values of the widgets in the event editor and put them in the iCalObject */ -static void -dialog_to_comp_object (EventEditor *ee) -{ - EventEditorPrivate *priv; - CalComponent *comp; - CalComponentText *text; - CalComponentDateTime date; - time_t t; - struct icalrecurrencetype *recur; - gboolean all_day_event; - int i, pos = 0; - GtkCList *exception_list; - GSList *list = NULL; - - priv = ee->priv; - comp = priv->comp; - - text = g_new0 (CalComponentText, 1); - text->value = e_dialog_editable_get (priv->general_summary); - cal_component_set_summary (comp, text); - - text->value = e_dialog_editable_get (priv->description); - g_slist_prepend (list, text); - cal_component_set_description_list (comp, list); - cal_component_free_text_list (list); - list = NULL; - - date.value = g_new (struct icaltimetype, 1); - t = e_dialog_dateedit_get (priv->start_time); - *date.value = icaltimetype_from_timet (t, FALSE); - cal_component_set_dtstart (comp, &date); - - /* If the all_day toggle is set, the end date is inclusive of the - entire day on which it points to. */ - all_day_event = e_dialog_toggle_get (priv->all_day_event); - t = e_dialog_dateedit_get (priv->end_time); - if (all_day_event) - t = time_day_end (t); - - *date.value = icaltimetype_from_timet (t, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - -#if 0 - ico->dalarm.enabled = e_dialog_toggle_get (priv->alarm_display); - ico->aalarm.enabled = e_dialog_toggle_get (priv->alarm_program); - ico->palarm.enabled = e_dialog_toggle_get (priv->alarm_audio); - ico->malarm.enabled = e_dialog_toggle_get (priv->alarm_mail); - - ico->dalarm.count = e_dialog_spin_get_int (priv->alarm_display_amount); - ico->aalarm.count = e_dialog_spin_get_int (priv->alarm_audio_amount); - ico->palarm.count = e_dialog_spin_get_int (priv->alarm_program_amount); - ico->malarm.count = e_dialog_spin_get_int (priv->alarm_mail_amount); - - ico->dalarm.units = alarm_unit_get (priv->alarm_display_unit); - ico->aalarm.units = alarm_unit_get (priv->alarm_audio_unit); - ico->palarm.units = alarm_unit_get (priv->alarm_program_unit); - ico->malarm.units = alarm_unit_get (priv->alarm_mail_unit); - - if (ico->palarm.data) - g_free (ico->palarm.data); - - if (ico->malarm.data) - g_free (ico->malarm.data); - - ico->palarm.data = e_dialog_editable_get (priv->alarm_program_run_program_entry); - ico->malarm.data = e_dialog_editable_get (priv->alarm_mail_mail_to); -#endif - - cal_component_set_classification (comp, classification_get (priv->classification_radio)); - - /* Recurrence information */ - recur = g_new (struct icalrecurrencetype, 1); - icalrecurrencetype_clear (recur); - recur->freq = recur_options_get (priv->recurrence_rule_none); - - switch (recur->freq) { - case ICAL_NO_RECURRENCE: - /* nothing */ - break; - - case ICAL_DAILY_RECURRENCE: - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_daily_days); - break; - - case ICAL_WEEKLY_RECURRENCE: - - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_weekly_weeks); - - - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sun)) - recur->by_day[pos++] = ICAL_SUNDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_mon)) - recur->by_day[pos++] = ICAL_MONDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_tue)) - recur->by_day[pos++] = ICAL_TUESDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_wed)) - recur->by_day[pos++] = ICAL_WEDNESDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_thu)) - recur->by_day[pos++] = ICAL_THURSDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_fri)) - recur->by_day[pos++] = ICAL_FRIDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sat)) - recur->by_day[pos++] = ICAL_SATURDAY_WEEKDAY; - - break; - - case ICAL_MONTHLY_RECURRENCE: - - if (e_dialog_toggle_get (priv->recurrence_rule_monthly_on_day)) { - /* by day of in the month (ex: the 5th) */ - recur->by_month_day[0] = - e_dialog_spin_get_int (priv->recurrence_rule_monthly_day_nth); - } else if (e_dialog_toggle_get (priv->recurrence_rule_monthly_weekday)) { - /* "recurrence-rule-monthly-weekday" is TRUE */ - /* by position on the calender (ex: 2nd monday) */ - /* libical does not handle this yet */ -/* ico->recur->u.month_pos = e_dialog_option_menu_get ( */ -/* priv->recurrence_rule_monthly_week, */ -/* month_pos_map); */ -/* ico->recur->weekday = e_dialog_option_menu_get ( */ -/* priv->recurrence_rule_monthly_weekpos, */ -/* weekday_map); */ - - } else - g_assert_not_reached (); - - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_monthly_every_n_months); - - break; - - case ICAL_YEARLY_RECURRENCE: - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_yearly_every_n_years); - - default: - g_assert_not_reached (); - } - - /* recurrence ending date */ - if (e_dialog_toggle_get (priv->recurrence_ending_date_end_on)) { - /* Also here, to ensure that the event is used, we add 86400 - * secs to get get next day, in accordance to the RFC - */ - t = e_dialog_dateedit_get (priv->recurrence_ending_date_end_on_date) + 86400; - recur->until = icaltimetype_from_timet (t, TRUE); - } else if (e_dialog_toggle_get (priv->recurrence_ending_date_end_after)) { - recur->count = e_dialog_spin_get_int (priv->recurrence_ending_date_end_after_count); - } - g_slist_append (list, recur); - cal_component_set_rrule_list (comp, list); - list = NULL; - - /* Get exceptions from clist into ico->exdate */ - exception_list = GTK_CLIST (priv->recurrence_exceptions_list); - for (i = 0; i < exception_list->rows; i++) { - struct icaltimetype *tt = g_new (struct icaltimetype, 1); - time_t *t; - - t = gtk_clist_get_row_data (exception_list, i); - *tt = icaltimetype_from_timet (*t, FALSE); - - list = g_slist_prepend (list, tt); - } - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); -} - -/* Emits the "save_ical_object" signal if the event editor is editing an object. */ -static void -save_ical_object (EventEditor *ee) -{ - EventEditorPrivate *priv; - char *title; - - priv = ee->priv; - - if (!priv->comp) - return; - - dialog_to_comp_object (ee); - - title = make_title_from_comp (priv->comp); - gtk_window_set_title (GTK_WINDOW (priv->app), title); - g_free (title); - - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[SAVE_ICAL_OBJECT], - priv->comp); -} - -/* Closes the dialog box and emits the appropriate signals */ -static void -close_dialog (EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = ee->priv; - - g_assert (priv->app != NULL); - - free_exception_clist_data (GTK_CLIST (priv->recurrence_exceptions_list)); - - gtk_widget_destroy (priv->app); - priv->app = NULL; - - if (priv->comp) { - const char *uid; - - cal_component_get_uid (priv->comp, &uid); - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[ICAL_OBJECT_RELEASED], uid); - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[EDITOR_CLOSED]); -} - - - -/* File/Save callback */ -static void -file_save_cb (GtkWidget *widget, gpointer data) -{ - EventEditor *ee; - - ee = EVENT_EDITOR (data); - save_ical_object (ee); -} - -/* File/Close callback */ -static void -file_close_cb (GtkWidget *widget, gpointer data) -{ - EventEditor *ee; - - /* FIXME: need to check for a dirty object */ - - ee = EVENT_EDITOR (data); - close_dialog (ee); -} - - - -/* Menu bar */ - -static GnomeUIInfo file_new_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Appointment"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Meeting Re_quest"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mail Message"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Journal Entry"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Note"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_page_setup_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Memo Style"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Define Print _Styles..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_menu[] = { - GNOMEUIINFO_MENU_NEW_SUBTREE (file_new_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_SAVE_ITEM (file_save_cb, NULL), - GNOMEUIINFO_MENU_SAVE_AS_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL), - GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLOSE_ITEM (file_close_cb, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_object_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: what goes here?", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_menu[] = { - GNOMEUIINFO_MENU_UNDO_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_REDO_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CUT_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_COPY_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_PASTE_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Paste _Special..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLEAR_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_SELECT_ALL_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Mark as U_nread"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_FIND_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_FIND_AGAIN_ITEM (NULL, NULL), - GNOMEUIINFO_SUBTREE (N_("_Object"), edit_object_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_previous_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Fi_rst Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_next_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Last Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_toolbars_menu[] = { - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: _Standard"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: __Formatting"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Customize..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_menu[] = { - GNOMEUIINFO_SUBTREE (N_("Pre_vious"), view_previous_menu), - GNOMEUIINFO_SUBTREE (N_("Ne_xt"), view_next_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ca_lendar..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Toolbars"), view_toolbars_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo insert_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _File..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: It_em..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Object..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo format_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Font..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Paragraph..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_forms_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Desi_gn This Form"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: D_esign a Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Publish _Form..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Pu_blish Form As..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Script _Debugger"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Spelling..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Chec_k Names"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Address _Book..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Forms"), tools_forms_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo actions_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _New Appointment"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Rec_urrence..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Invite _Attendees..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: C_ancel Invitation..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Forward as v_Calendar"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: For_ward"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo help_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: fix Bonobo so it supports help items!", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo main_menu[] = { - GNOMEUIINFO_MENU_FILE_TREE (file_menu), - GNOMEUIINFO_MENU_EDIT_TREE (edit_menu), - GNOMEUIINFO_MENU_VIEW_TREE (view_menu), - GNOMEUIINFO_SUBTREE (N_("_Insert"), insert_menu), - GNOMEUIINFO_SUBTREE (N_("F_ormat"), format_menu), - GNOMEUIINFO_SUBTREE (N_("_Tools"), tools_menu), - GNOMEUIINFO_SUBTREE (N_("Actio_ns"), actions_menu), - GNOMEUIINFO_MENU_HELP_TREE (help_menu), - GNOMEUIINFO_END -}; - -/* Creates the menu bar for the event editor */ -static void -create_menu (EventEditor *ee) -{ - EventEditorPrivate *priv; - BonoboUIHandlerMenuItem *list; - - priv = ee->priv; - - bonobo_ui_handler_create_menubar (priv->uih); - - list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (main_menu, ee); - bonobo_ui_handler_menu_add_list (priv->uih, "/", list); -} - - - -/* Toolbar/Save and Close callback */ -static void -tb_save_and_close_cb (GtkWidget *widget, gpointer data) -{ - EventEditor *ee; - - ee = EVENT_EDITOR (data); - save_ical_object (ee); - close_dialog (ee); -} - - - -/* Toolbar */ - -static GnomeUIInfo toolbar[] = { - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Save and Close"), - N_("Save the appointment and close the dialog box"), - tb_save_and_close_cb, - GNOME_STOCK_PIXMAP_SAVE), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print..."), - N_("Print this item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."), - N_("Insert a file as an attachment"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Recurrence..."), - N_("Configure recurrence rules"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Invite Attendees..."), - N_("Invite attendees to a meeting"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Delete"), - N_("Delete this item"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Previous"), - N_("Go to the previous item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Next"), - N_("Go to the next item"), NULL), - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Help"), - N_("See online help"), NULL, GNOME_STOCK_PIXMAP_HELP), - GNOMEUIINFO_END -}; - -/* Creates the toolbar for the event editor */ -static void -create_toolbar (EventEditor *ee) -{ - EventEditorPrivate *priv; - BonoboUIHandlerToolbarItem *list; - GnomeDockItem *dock_item; - GtkWidget *toolbar_child; - - priv = ee->priv; - - bonobo_ui_handler_create_toolbar (priv->uih, "Toolbar"); - - /* Fetch the toolbar. What a pain in the ass. */ - - dock_item = gnome_app_get_dock_item_by_name (GNOME_APP (priv->app), GNOME_APP_TOOLBAR_NAME); - g_assert (dock_item != NULL); - - toolbar_child = gnome_dock_item_get_child (dock_item); - g_assert (toolbar_child != NULL && GTK_IS_TOOLBAR (toolbar_child)); - - /* Turn off labels as GtkToolbar sucks */ - gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_child), GTK_TOOLBAR_ICONS); - - list = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (toolbar, ee); - bonobo_ui_handler_toolbar_add_list (priv->uih, "/Toolbar", list); -} - - - -/* Callback used when the dialog box is destroyed */ -static gint -app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - EventEditor *ee; - - /* FIXME: need to check for a dirty object */ - - ee = EVENT_EDITOR (data); - close_dialog (ee); - - return TRUE; -} - -/** - * event_editor_construct: - * @ee: An event editor. - * - * Constructs an event editor by loading its Glade data. - * - * Return value: The same object as @ee, or NULL if the widgets could not be - * created. In the latter case, the event editor will automatically be - * destroyed. - **/ -EventEditor * -event_editor_construct (EventEditor *ee) -{ - EventEditorPrivate *priv; - - g_return_val_if_fail (ee != NULL, NULL); - g_return_val_if_fail (IS_EVENT_EDITOR (ee), NULL); - - priv = ee->priv; - - /* Load the content widgets */ - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/event-editor-dialog.glade", NULL); - if (!priv->xml) { - g_message ("event_editor_construct(): Could not load the Glade XML file!"); - goto error; - } - - if (!get_widgets (ee)) { - g_message ("event_editor_construct(): Could not find all widgets in the XML file!"); - goto error; - } - - init_widgets (ee); - - /* Construct the app */ - - priv->uih = bonobo_ui_handler_new (); - if (!priv->uih) { - g_message ("event_editor_construct(): Could not create the UI handler"); - goto error; - } - - bonobo_ui_handler_set_app (priv->uih, GNOME_APP (priv->app)); - - create_menu (ee); - create_toolbar (ee); - - /* Hook to destruction of the dialog */ - - gtk_signal_connect (GTK_OBJECT (priv->app), "delete_event", - GTK_SIGNAL_FUNC (app_delete_event_cb), ee); - - /* Show the dialog */ - - gtk_widget_show (priv->app); - - return ee; - - error: - - gtk_object_unref (GTK_OBJECT (ee)); - return NULL; -} - -/** - * event_editor_new: - * - * Creates a new event editor dialog. - * - * Return value: A newly-created event editor dialog, or NULL if the event - * editor could not be created. - **/ -EventEditor * -event_editor_new (void) -{ - EventEditor *ee; - - ee = EVENT_EDITOR (gtk_type_new (TYPE_EVENT_EDITOR)); - return event_editor_construct (EVENT_EDITOR (ee)); -} - -/** - * event_editor_set_ical_object: - * @ee: An event editor. - * @comp: A calendar object. - * - * Sets the calendar object that an event editor dialog will manipulate. - **/ -void -event_editor_set_ical_object (EventEditor *ee, CalComponent *comp) -{ - EventEditorPrivate *priv; - char *title; - - g_return_if_fail (ee != NULL); - g_return_if_fail (IS_EVENT_EDITOR (ee)); - - priv = ee->priv; - - if (priv->comp) { - const char *uid; - - cal_component_get_uid (priv->comp, &uid); - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[ICAL_OBJECT_RELEASED], uid); - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - if (comp) - priv->comp = cal_component_clone (comp); - - title = make_title_from_comp (priv->comp); - gtk_window_set_title (GTK_WINDOW (priv->app), title); - g_free (title); - - fill_widgets (ee); -} - -/* Brings attention to a window by raising it and giving it focus */ -static void -raise_and_focus (GtkWidget *widget) -{ - g_assert (GTK_WIDGET_REALIZED (widget)); - gdk_window_show (widget->window); - gtk_widget_grab_focus (widget); -} - -/** - * event_editor_focus: - * @ee: An event editor. - * - * Makes sure an event editor is shown, on top of other windows, and focused. - **/ -void -event_editor_focus (EventEditor *ee) -{ - EventEditorPrivate *priv; - - g_return_if_fail (ee != NULL); - g_return_if_fail (IS_EVENT_EDITOR (ee)); - - priv = ee->priv; - gtk_widget_show_now (priv->app); - raise_and_focus (priv->app); -} - -static void -alarm_toggle (GtkWidget *toggle, EventEditor *ee) -{ - EventEditorPrivate *priv; - GtkWidget *alarm_amount = NULL; - GtkWidget *alarm_unit = NULL; - gboolean active; - - priv = ee->priv; - - active = GTK_TOGGLE_BUTTON (toggle)->active; - - if (toggle == priv->alarm_display) { - alarm_amount = priv->alarm_display_amount; - alarm_unit = priv->alarm_display_unit; - } else if (toggle == priv->alarm_audio) { - alarm_amount = priv->alarm_audio_amount; - alarm_unit = priv->alarm_audio_unit; - } else if (toggle == priv->alarm_program) { - alarm_amount = priv->alarm_program_amount; - alarm_unit = priv->alarm_program_unit; - gtk_widget_set_sensitive (priv->alarm_program_run_program, active); - } else if (toggle == priv->alarm_mail) { - alarm_amount = priv->alarm_mail_amount; - alarm_unit = priv->alarm_mail_unit; - gtk_widget_set_sensitive (priv->alarm_mail_mail_to, active); - } else - g_assert_not_reached (); - - gtk_widget_set_sensitive (alarm_amount, active); - gtk_widget_set_sensitive (alarm_unit, active); -} - -/* - * Checks if the day range occupies all the day, and if so, check the - * box accordingly - */ -static void -check_all_day (EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t ev_start, ev_end; - - priv = ee->priv; - - ev_start = e_dialog_dateedit_get (priv->start_time); - ev_end = e_dialog_dateedit_get (priv->end_time); - - /* all day event checkbox */ - if (time_day_begin (ev_start) == ev_start - && time_day_begin (ev_end) == ev_end) - e_dialog_toggle_set (priv->all_day_event, TRUE); - else - e_dialog_toggle_set (priv->all_day_event, FALSE); -} - -/* - * Callback: all day event box clicked - */ -static void -set_all_day (GtkWidget *toggle, EventEditor *ee) -{ - EventEditorPrivate *priv; - struct tm start_tm, end_tm; - time_t start_t, end_t; - gboolean all_day; - int flags; - - priv = ee->priv; - - /* If the all_day toggle is set, the end date is inclusive of the - entire day on which it points to. */ - all_day = GTK_TOGGLE_BUTTON (toggle)->active; - - start_t = e_dialog_dateedit_get (priv->start_time); - start_tm = *localtime (&start_t); - start_tm.tm_min = 0; - start_tm.tm_sec = 0; - - if (all_day) - start_tm.tm_hour = 0; - else - start_tm.tm_hour = day_begin; - - e_dialog_dateedit_set (priv->start_time, mktime (&start_tm)); - - end_t = e_dialog_dateedit_get (priv->end_time); - end_tm = *localtime (&end_t); - end_tm.tm_min = 0; - end_tm.tm_sec = 0; - - if (all_day) { - /* mktime() will fix this if we go past the end of the month.*/ - end_tm.tm_hour = 0; - } else { - if (end_tm.tm_year == start_tm.tm_year - && end_tm.tm_mon == start_tm.tm_mon - && end_tm.tm_mday == start_tm.tm_mday - && end_tm.tm_hour <= start_tm.tm_hour) - end_tm.tm_hour = start_tm.tm_hour + 1; - } - - flags = gnome_date_edit_get_flags (GNOME_DATE_EDIT (priv->start_time)); - if (all_day) - flags &= ~GNOME_DATE_EDIT_SHOW_TIME; - else - flags |= GNOME_DATE_EDIT_SHOW_TIME; - gnome_date_edit_set_flags (GNOME_DATE_EDIT (priv->start_time), flags); - gnome_date_edit_set_flags (GNOME_DATE_EDIT (priv->end_time), flags); - - e_dialog_dateedit_set (priv->end_time, mktime (&end_tm)); - - gtk_widget_hide (GNOME_DATE_EDIT (priv->start_time)->cal_label); - gtk_widget_hide (GNOME_DATE_EDIT (priv->end_time)->cal_label); -} - -/* - * Callback: checks that the dates are start < end - */ -static void -check_dates (GnomeDateEdit *gde, EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t start, end; - struct tm tm_start, tm_end; - - priv = ee->priv; - - start = e_dialog_dateedit_get (priv->start_time); - end = e_dialog_dateedit_get (priv->end_time); - - if (start > end) { - tm_start = *localtime (&start); - tm_end = *localtime (&end); - - if (GTK_WIDGET (gde) == priv->start_time) { - tm_end.tm_year = tm_start.tm_year; - tm_end.tm_mon = tm_start.tm_mon; - tm_end.tm_mday = tm_start.tm_mday; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - e_dialog_dateedit_set (priv->end_time, mktime (&tm_end)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - } else if (GTK_WIDGET (gde) == priv->end_time) { - tm_start.tm_year = tm_end.tm_year; - tm_start.tm_mon = tm_end.tm_mon; - tm_start.tm_mday = tm_end.tm_mday; - -#if 0 - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - e_dialog_dateedit_set (priv->start_time, mktime (&tm_start)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); -#endif - } - } -} - -/* - * Callback: checks that start_time < end_time and whether the - * selected hour range spans all of the day - */ -static void -check_times (GnomeDateEdit *gde, EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t start, end; - struct tm tm_start, tm_end; - - priv = ee->priv; -#if 0 - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gdk_flush (); -#endif - start = e_dialog_dateedit_get (priv->start_time); - end = e_dialog_dateedit_get (priv->end_time); - - if (start > end) { - tm_start = *localtime (&start); - tm_end = *localtime (&end); - - if (GTK_WIDGET (gde) == priv->start_time) { - tm_end.tm_min = tm_start.tm_min; - tm_end.tm_sec = tm_start.tm_sec; - tm_end.tm_hour = tm_start.tm_hour + 1; - - if (tm_end.tm_hour >= 24) { - tm_end.tm_hour = 24; /* mktime() will bump the day */ - tm_end.tm_min = 0; - tm_end.tm_sec = 0; - } - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - e_dialog_dateedit_set (priv->end_time, mktime (&tm_end)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - } else if (GTK_WIDGET (gde) == priv->end_time) { - tm_start.tm_min = tm_end.tm_min; - tm_start.tm_sec = tm_end.tm_sec; - tm_start.tm_hour = tm_end.tm_hour - 1; - - if (tm_start.tm_hour < 0) { - tm_start.tm_hour = 0; - tm_start.tm_min = 0; - tm_start.tm_min = 0; - } - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - e_dialog_dateedit_set (priv->start_time, mktime (&tm_start)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); - } - } - - /* Check whether the event spans the whole day */ - - check_all_day (ee); -} - -static void -recurrence_toggled (GtkWidget *radio, EventEditor *ee) -{ - EventEditorPrivate *priv; - icalrecurrencetype_frequency rf; - - priv = ee->priv; - - if (!GTK_TOGGLE_BUTTON (radio)->active) - return; - - rf = e_dialog_radio_get (radio, recur_options_map); - - gtk_notebook_set_page (GTK_NOTEBOOK (priv->recurrence_rule_notebook), (int) rf); -} - - -static char * -get_exception_string (time_t t) -{ - static char buf[256]; - - strftime (buf, sizeof (buf), _("%a %b %d %Y"), localtime (&t)); - return buf; -} - - -static void -append_exception (EventEditor *ee, time_t t) -{ - EventEditorPrivate *priv; - time_t *tt; - char *c[1]; - int i; - GtkCList *clist; - - priv = ee->priv; - - c[0] = get_exception_string (t); - - tt = g_new (time_t, 1); - *tt = t; - - clist = GTK_CLIST (priv->recurrence_exceptions_list); - - i = gtk_clist_append (clist, c); - gtk_clist_set_row_data (clist, i, tt); - gtk_clist_select_row (clist, i, 0); - -/* gtk_widget_set_sensitive (ee->recur_ex_vbox, TRUE); */ -} - - -static void -recurrence_exception_added (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t t; - - priv = ee->priv; - - t = e_dialog_dateedit_get (priv->recurrence_exceptions_date); - append_exception (ee, t); -} - - -static void -recurrence_exception_deleted (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - GtkCList *clist; - int sel; - - priv = ee->priv; - - clist = GTK_CLIST (priv->recurrence_exceptions_list); - if (!clist->selection) - return; - - sel = GPOINTER_TO_INT (clist->selection->data); - - g_free (gtk_clist_get_row_data (clist, sel)); /* free the time_t stored there */ - - gtk_clist_remove (clist, sel); - if (sel >= clist->rows) - sel--; - - gtk_clist_select_row (clist, sel, 0); -} - - -static void -recurrence_exception_changed (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - GtkCList *clist; - time_t *t; - int sel; - - priv = ee->priv; - - clist = GTK_CLIST (priv->recurrence_exceptions_list); - if (!clist->selection) - return; - - sel = GPOINTER_TO_INT (clist->selection->data); - - t = gtk_clist_get_row_data (clist, sel); - *t = e_dialog_dateedit_get (priv->recurrence_exceptions_date); - - gtk_clist_set_text (clist, sel, 0, get_exception_string (*t)); -} - - -GtkWidget * -make_date_edit (void) -{ - return date_edit_new (time (NULL), FALSE); -} - - -GtkWidget * -make_date_edit_with_time (void) -{ - return date_edit_new (time (NULL), TRUE); -} - - -GtkWidget * -date_edit_new (time_t the_time, int show_time) -{ - return gnome_date_edit_new_flags (the_time, - ((show_time ? GNOME_DATE_EDIT_SHOW_TIME : 0) - | (am_pm_flag ? 0 : GNOME_DATE_EDIT_24_HR) - | (week_starts_on_monday - ? GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY - : 0))); -} - - - -GtkWidget * -make_spin_button (int val, int low, int high) -{ - GtkAdjustment *adj; - GtkWidget *spin; - - adj = GTK_ADJUSTMENT (gtk_adjustment_new (val, low, high, 1, 10, 10)); - spin = gtk_spin_button_new (adj, 0.5, 0); - gtk_widget_set_usize (spin, 60, 0); - - return spin; -} - - -/* todo - - build some of the recur stuff by hand to take into account - the start-on-monday preference? - - get the apply button to work right - - make the properties stuff unglobal - - figure out why alarm units aren't sticking between edits - - closing the dialog window with the wm caused a crash - Gtk-WARNING **: invalid cast from `(unknown)' to `GnomeDialog' - on line 669: gnome_dialog_close (GNOME_DIALOG(dialog->dialog)); - */ diff --git a/calendar/gui/event-editor.h b/calendar/gui/event-editor.h deleted file mode 100644 index 8e95e08cfb..0000000000 --- a/calendar/gui/event-editor.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Evolution calendar - Event editor dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * Seth Alves <alves@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __EVENT_EDITOR_DIALOG_H__ -#define __EVENT_EDITOR_DIALOG_H__ - -#include <libgnome/gnome-defs.h> -#include <gtk/gtkobject.h> -#include "gnome-cal.h" - - - -#define TYPE_EVENT_EDITOR (event_editor_get_type ()) -#define EVENT_EDITOR(obj) (GTK_CHECK_CAST ((obj), TYPE_EVENT_EDITOR, EventEditor)) -#define EVENT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_EVENT_EDITOR, \ - EventEditorClass)) -#define IS_EVENT_EDITOR(obj) (GTK_CHECK_TYPE ((obj), TYPE_EVENT_EDITOR)) -#define IS_EVENT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_EVENT_EDITOR)) - -typedef struct _EventEditor EventEditor; -typedef struct _EventEditorClass EventEditorClass; - -struct _EventEditor { - GtkObject object; - - /* Private data */ - gpointer priv; -}; - -struct _EventEditorClass { - GtkObjectClass parent_class; - - /* Notification signals */ - - void (* save_ical_object) (EventEditor *ee, CalComponent *comp); - void (* ical_object_released) (EventEditor *ee, const char *uid); - void (* editor_closed) (EventEditor *ee); -}; - - -GtkType event_editor_get_type (void); -EventEditor *event_editor_construct (EventEditor *ee); - -EventEditor *event_editor_new (void); - -void event_editor_set_ical_object (EventEditor *ee, CalComponent *comp); - -void event_editor_focus (EventEditor *ee); - -#if 0 -/* Convenience function to create and show a new event editor for an - * event that goes from day_begin to day_end of the specified day. - */ -void event_editor_new_whole_day (GnomeCalendar *owner, time_t day); -#endif - -GtkWidget *make_date_edit (void); -GtkWidget *make_date_edit_with_time (void); -GtkWidget *date_edit_new (time_t the_time, int show_time); - -GtkWidget *make_spin_button (int val, int low, int high); - - - -#endif /* __EVENT_EDITOR_DIALOG_H__ */ diff --git a/calendar/gui/evolution-calendar-control.c b/calendar/gui/evolution-calendar-control.c deleted file mode 100644 index 7ebe2b5f8e..0000000000 --- a/calendar/gui/evolution-calendar-control.c +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <bonobo.h> -#include <bonobo/bonobo-control.h> -#include <glade/glade.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - -#include <cal-util/timeutil.h> -#include <gui/alarm.h> -#include <gui/gnome-cal.h> -#include <gui/calendar-commands.h> - -#define PROPERTY_CALENDAR_URI "folder_uri" - -#define PROPERTY_CALENDAR_URI_IDX 1 - -#ifdef USING_OAF -#define CONTROL_FACTORY_ID "OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" -#else -#define CONTROL_FACTORY_ID "control-factory:calendar" -#endif - -CORBA_Environment ev; -CORBA_ORB orb; - - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - if (activate) - calendar_control_activate (control, user_data); - else - calendar_control_deactivate (control); -} - - - -static void -init_bonobo (int *argc, char **argv) -{ -#ifdef USING_OAF - /* FIXME: VERSION instead of "0.0". */ - gnome_init_with_popt_table ("evolution-calendar", "0.0", - *argc, argv, oaf_popt_options, - 0, NULL); - oaf_init (*argc, argv); -#else - gnome_CORBA_init_with_popt_table ( - "evolution-calendar", "0.0", - argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); -#endif - - if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - glade_gnome_init (); -} - - - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - /*GnomeCalendar *gcal = user_data;*/ - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - /* - if (fb && fb->uri) - BONOBO_ARG_SET_STRING (arg, fb->uri); - else - BONOBO_ARG_SET_STRING (arg, ""); - */ - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - } -} - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - GnomeCalendar *gcal = user_data; - char *filename; - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - printf ("set_prop: '%s'\n", BONOBO_ARG_GET_STRING (arg)); - filename = g_strdup_printf ("%s/calendar.vcf", - BONOBO_ARG_GET_STRING (arg)); - calendar_set_uri (gcal, filename); - g_free (filename); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - break; - } -} - - -static void -calendar_properties_init (GnomeCalendar *gcal) -{ - gcal->properties = bonobo_property_bag_new (get_prop, set_prop, gcal); - - bonobo_property_bag_add (gcal->properties, - PROPERTY_CALENDAR_URI, - PROPERTY_CALENDAR_URI_IDX, - BONOBO_ARG_STRING, - NULL, - _("The URI that the calendar will display"), - 0); - - bonobo_control_set_property_bag (gcal->control, gcal->properties); -} - - - -static BonoboObject * -calendar_control_factory (BonoboGenericFactory *Factory, void *closure) -{ - BonoboControl *control; - - /* Create the control. */ - GnomeCalendar *cal = new_calendar (full_name, NULL, NULL, 0); - - gtk_widget_show (GTK_WIDGET (cal)); - - control = bonobo_control_new (GTK_WIDGET (cal)); - cal->control = control; - - calendar_properties_init (cal); - - gtk_signal_connect (GTK_OBJECT (control), "activate", - control_activate_cb, cal); - - return BONOBO_OBJECT (control); -} - - -static void -calendar_control_factory_init (void) -{ - static BonoboGenericFactory *factory = NULL; - - if (factory != NULL) - return; - - puts ("XXXXXX - initializing calendar factory!!!"); - - factory = bonobo_generic_factory_new (CONTROL_FACTORY_ID, calendar_control_factory, NULL); - - if (factory == NULL) - g_error ("I could not register a Calendar control factory."); -} - - -int -main (int argc, char **argv) -{ - init_bonobo (&argc, argv); - glade_gnome_init (); - alarm_init (); - e_cursors_init (); - - init_calendar (); - - //g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF); - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - - CORBA_exception_init (&ev); - - calendar_control_factory_init (); - component_factory_init (); - - bonobo_main (); - - return 0; -} diff --git a/calendar/gui/evolution-calendar.gnorba b/calendar/gui/evolution-calendar.gnorba deleted file mode 100644 index e2f1107926..0000000000 --- a/calendar/gui/evolution-calendar.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[evolution-shell-component-factory:evolution-calendar] -type=exe -repo_id=IDL:Bonobo/GenericFactory:1.0 -description=Factory for the Evolution calendar component. -location_info=evolution-calendar - -[evolution-shell-component:evolution-calendar] -type=factory -repo_id=IDL:Evolution/ShellComponent:1.0 -description=Evolution component for handling the calendar. -location_info=evolution-shell-component-factory:evolution-calendar diff --git a/calendar/gui/evolution-calendar.oafinfo b/calendar/gui/evolution-calendar.oafinfo deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/evolution-calendar.oafinfo +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/getdate.y b/calendar/gui/getdate.y deleted file mode 100644 index 6df71bddda..0000000000 --- a/calendar/gui/getdate.y +++ /dev/null @@ -1,1001 +0,0 @@ -%{ -/* -** Originally) written by Steven M. Bellovin <smb@research.att.com> while -** at the University of North Carolina at Chapel Hill. Later tweaked by -** a couple of people on Usenet. Completely overhauled by Rich $alz -** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990; -** send any email to Rich. -** -** This grammar has 10 shift/reduce conflicts. -** -** This code is in the public domain and has no copyright. -*/ -/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */ -/* SUPPRESS 288 on yyerrlab *//* Label unused */ - -#include <config.h> -#include <gnome.h> - -/* Since the code of getdate.y is not included in the Emacs executable - itself, there is no need to #define static in this file. Even if - the code were included in the Emacs executable, it probably - wouldn't do any harm to #undef it here; this will only cause - problems if we try to write to a static variable, which I don't - think this code needs to do. */ -#ifdef emacs -#undef static -#endif - -#include <stdio.h> -#include <ctype.h> - -/* The code at the top of get_date which figures out the offset of the - current time zone checks various CPP symbols to see if special - tricks are need, but defaults to using the gettimeofday system call. - Include <sys/time.h> if that will be used. */ - -#if defined(vms) - -#include <types.h> -#include <time.h> - -#else - -#include <sys/types.h> - -#ifdef TIME_WITH_SYS_TIME -#include <sys/time.h> -#include <time.h> -#else -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#else -#include <time.h> -#endif -#endif - -#ifdef timezone -#undef timezone /* needed for sgi */ -#endif - -#if defined(HAVE_SYS_TIMEB_H) -#include <sys/timeb.h> -#else -/* -** We use the obsolete `struct timeb' as part of our interface! -** Since the system doesn't have it, we define it here; -** our callers must do likewise. -*/ -struct timeb { - time_t time; /* Seconds since the epoch */ - unsigned short millitm; /* Field not used */ - short timezone; /* Minutes west of GMT */ - short dstflag; /* Field not used */ -}; -#endif /* defined(HAVE_SYS_TIMEB_H) */ - -#endif /* defined(vms) */ - -#if defined (STDC_HEADERS) || defined (USG) -#include <string.h> -#endif - -/* Some old versions of bison generate parsers that use bcopy. - That loses on systems that don't provide the function, so we have - to redefine it here. */ -#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy) -#define bcopy(from, to, len) memcpy ((to), (from), (len)) -#endif - -#if defined (STDC_HEADERS) -#include <stdlib.h> -#endif - -/* NOTES on rebuilding getdate.c (particularly for inclusion in CVS - releases): - - We don't want to mess with all the portability hassles of alloca. - In particular, most (all?) versions of bison will use alloca in - their parser. If bison works on your system (e.g. it should work - with gcc), then go ahead and use it, but the more general solution - is to use byacc instead of bison, which should generate a portable - parser. I played with adding "#define alloca dont_use_alloca", to - give an error if the parser generator uses alloca (and thus detect - unportable getdate.c's), but that seems to cause as many problems - as it solves. */ - -extern struct tm *gmtime(); -extern struct tm *localtime(); - -#define yyparse getdate_yyparse -#define yylex getdate_yylex -#define yyerror getdate_yyerror - -static int yylex (); -static int yyerror (); - -#define EPOCH 1970 -#define HOUR(x) ((time_t)(x) * 60) -#define SECSPERDAY (24L * 60L * 60L) - - -/* -** An entry in the lexical lookup table. -*/ -typedef struct _TABLE { - char *name; - int type; - time_t value; -} TABLE; - - -/* -** Daylight-savings mode: on, off, or not yet known. -*/ -typedef enum _DSTMODE { - DSTon, DSToff, DSTmaybe -} DSTMODE; - -/* -** Meridian: am, pm, or 24-hour style. -*/ -typedef enum _MERIDIAN { - MERam, MERpm, MER24 -} MERIDIAN; - - -/* -** Global variables. We could get rid of most of these by using a good -** union as the yacc stack. (This routine was originally written before -** yacc had the %union construct.) Maybe someday; right now we only use -** the %union very rarely. -*/ -static char *yyInput; -static DSTMODE yyDSTmode; -static time_t yyDayOrdinal; -static time_t yyDayNumber; -static int yyHaveDate; -static int yyHaveDay; -static int yyHaveRel; -static int yyHaveTime; -static int yyHaveZone; -static time_t yyTimezone; -static time_t yyDay; -static time_t yyHour; -static time_t yyMinutes; -static time_t yyMonth; -static time_t yySeconds; -static time_t yyYear; -static MERIDIAN yyMeridian; -static time_t yyRelMonth; -static time_t yyRelSeconds; - -%} - -%union { - time_t Number; - enum _MERIDIAN Meridian; -} - -%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT -%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST - -%type <Number> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT -%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tZONE -%type <Meridian> tMERIDIAN o_merid - -%% - -spec : /* NULL */ - | spec item - ; - -item : time { - yyHaveTime++; - } - | zone { - yyHaveZone++; - } - | date { - yyHaveDate++; - } - | day { - yyHaveDay++; - } - | rel { - yyHaveRel++; - } - | number - ; - -time : tUNUMBER tMERIDIAN { - yyHour = $1; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = $2; - } - | tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = 0; - yyMeridian = $4; - } - | tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($4 % 100 + ($4 / 100) * 60); - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = $6; - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($6 % 100 + ($6 / 100) * 60); - } - ; - -zone : tZONE { - yyTimezone = $1; - yyDSTmode = DSToff; - } - | tDAYZONE { - yyTimezone = $1; - yyDSTmode = DSTon; - } - | - tZONE tDST { - yyTimezone = $1; - yyDSTmode = DSTon; - } - ; - -day : tDAY { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tDAY ',' { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tUNUMBER tDAY { - yyDayOrdinal = $1; - yyDayNumber = $2; - } - ; - -date : tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - } - | tUNUMBER '/' tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - yyYear = $5; - } - | tUNUMBER tSNUMBER tSNUMBER { - /* ISO 8601 format. yyyy-mm-dd. */ - yyYear = $1; - yyMonth = -$2; - yyDay = -$3; - } - | tUNUMBER tMONTH tSNUMBER { - /* e.g. 17-JUN-1992. */ - yyDay = $1; - yyMonth = $2; - yyYear = -$3; - } - | tMONTH tUNUMBER { - yyMonth = $1; - yyDay = $2; - } - | tMONTH tUNUMBER ',' tUNUMBER { - yyMonth = $1; - yyDay = $2; - yyYear = $4; - } - | tUNUMBER tMONTH { - yyMonth = $2; - yyDay = $1; - } - | tUNUMBER tMONTH tUNUMBER { - yyMonth = $2; - yyDay = $1; - yyYear = $3; - } - ; - -rel : relunit tAGO { - yyRelSeconds = -yyRelSeconds; - yyRelMonth = -yyRelMonth; - } - | relunit - ; - -relunit : tUNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tSNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tMINUTE_UNIT { - yyRelSeconds += $1 * 60L; - } - | tSNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tUNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tSEC_UNIT { - yyRelSeconds++; - } - | tSNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tUNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tMONTH_UNIT { - yyRelMonth += $1; - } - ; - -number : tUNUMBER { - if (yyHaveTime && yyHaveDate && !yyHaveRel) - yyYear = $1; - else { - if($1>10000) { - yyHaveDate++; - yyDay= ($1)%100; - yyMonth= ($1/100)%100; - yyYear = $1/10000; - } - else { - yyHaveTime++; - if ($1 < 100) { - yyHour = $1; - yyMinutes = 0; - } - else { - yyHour = $1 / 100; - yyMinutes = $1 % 100; - } - yySeconds = 0; - yyMeridian = MER24; - } - } - } - ; - -o_merid : /* NULL */ { - $$ = MER24; - } - | tMERIDIAN { - $$ = $1; - } - ; - -%% - -/* Month and day table. */ -static TABLE const MonthDayTable[] = { - { N_("january"), tMONTH, 1 }, - { N_("february"), tMONTH, 2 }, - { N_("march"), tMONTH, 3 }, - { N_("april"), tMONTH, 4 }, - { N_("may"), tMONTH, 5 }, - { N_("june"), tMONTH, 6 }, - { N_("july"), tMONTH, 7 }, - { N_("august"), tMONTH, 8 }, - { N_("september"), tMONTH, 9 }, - { N_("sept"), tMONTH, 9 }, - { N_("october"), tMONTH, 10 }, - { N_("november"), tMONTH, 11 }, - { N_("december"), tMONTH, 12 }, - { N_("sunday"), tDAY, 0 }, - { N_("monday"), tDAY, 1 }, - { N_("tuesday"), tDAY, 2 }, - { N_("tues"), tDAY, 2 }, - { N_("wednesday"), tDAY, 3 }, - { N_("wednes"), tDAY, 3 }, - { N_("thursday"), tDAY, 4 }, - { N_("thur"), tDAY, 4 }, - { N_("thurs"), tDAY, 4 }, - { N_("friday"), tDAY, 5 }, - { N_("saturday"), tDAY, 6 }, - { NULL } -}; - -/* Time units table. */ -static TABLE const UnitsTable[] = { - { N_("year"), tMONTH_UNIT, 12 }, - { N_("month"), tMONTH_UNIT, 1 }, - { N_("fortnight"), tMINUTE_UNIT, 14 * 24 * 60 }, - { N_("week"), tMINUTE_UNIT, 7 * 24 * 60 }, - { N_("day"), tMINUTE_UNIT, 1 * 24 * 60 }, - { N_("hour"), tMINUTE_UNIT, 60 }, - { N_("minute"), tMINUTE_UNIT, 1 }, - { N_("min"), tMINUTE_UNIT, 1 }, - { N_("second"), tSEC_UNIT, 1 }, - { N_("sec"), tSEC_UNIT, 1 }, - { NULL } -}; - -/* Assorted relative-time words. */ -static TABLE const OtherTable[] = { - { N_("tomorrow"), tMINUTE_UNIT, 1 * 24 * 60 }, - { N_("yesterday"), tMINUTE_UNIT, -1 * 24 * 60 }, - { N_("today"), tMINUTE_UNIT, 0 }, - { N_("now"), tMINUTE_UNIT, 0 }, - { N_("last"), tUNUMBER, -1 }, - { N_("this"), tMINUTE_UNIT, 0 }, - { N_("next"), tUNUMBER, 2 }, - { N_("first"), tUNUMBER, 1 }, -/* { N_("second"), tUNUMBER, 2 }, */ - { N_("third"), tUNUMBER, 3 }, - { N_("fourth"), tUNUMBER, 4 }, - { N_("fifth"), tUNUMBER, 5 }, - { N_("sixth"), tUNUMBER, 6 }, - { N_("seventh"), tUNUMBER, 7 }, - { N_("eighth"), tUNUMBER, 8 }, - { N_("ninth"), tUNUMBER, 9 }, - { N_("tenth"), tUNUMBER, 10 }, - { N_("eleventh"), tUNUMBER, 11 }, - { N_("twelfth"), tUNUMBER, 12 }, - { N_("ago"), tAGO, 1 }, - { NULL } -}; - -/* The timezone table. */ -/* Some of these are commented out because a time_t can't store a float. */ -static TABLE const TimezoneTable[] = { - { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ - { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ - { "utc", tZONE, HOUR( 0) }, - { "wet", tZONE, HOUR( 0) }, /* Western European */ - { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ - { "wat", tZONE, HOUR( 1) }, /* West Africa */ - { "at", tZONE, HOUR( 2) }, /* Azores */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ - { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ -#endif -#if 0 - { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */ - { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */ - { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */ -#endif - { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ - { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ - { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ - { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ - { "cst", tZONE, HOUR( 6) }, /* Central Standard */ - { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ - { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ - { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ - { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ - { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ - { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ - { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ - { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ - { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ - { "cat", tZONE, HOUR(10) }, /* Central Alaska */ - { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ - { "nt", tZONE, HOUR(11) }, /* Nome */ - { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ - { "cet", tZONE, -HOUR(1) }, /* Central European */ - { "met", tZONE, -HOUR(1) }, /* Middle European */ - { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */ - { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ - { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */ - { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */ - { "fwt", tZONE, -HOUR(1) }, /* French Winter */ - { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */ - { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */ - { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */ -#if 0 - { "it", tZONE, -HOUR(3.5) },/* Iran */ -#endif - { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */ - { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */ -#if 0 - { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */ -#endif - { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */ -#if 0 - /* For completeness. NST is also Newfoundland Stanard, and SST is - * also Swedish Summer. */ - { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */ - { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */ -#endif /* 0 */ - { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */ - { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */ -#if 0 - { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */ -#endif - { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */ - { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */ -#if 0 - { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */ - { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */ -#endif - { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ - { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ - { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ - { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ - { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ - { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ - { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ - { NULL } -}; - -/* Military timezone table. */ -static TABLE const MilitaryTable[] = { - { "a", tZONE, HOUR( 1) }, - { "b", tZONE, HOUR( 2) }, - { "c", tZONE, HOUR( 3) }, - { "d", tZONE, HOUR( 4) }, - { "e", tZONE, HOUR( 5) }, - { "f", tZONE, HOUR( 6) }, - { "g", tZONE, HOUR( 7) }, - { "h", tZONE, HOUR( 8) }, - { "i", tZONE, HOUR( 9) }, - { "k", tZONE, HOUR( 10) }, - { "l", tZONE, HOUR( 11) }, - { "m", tZONE, HOUR( 12) }, - { "n", tZONE, HOUR(- 1) }, - { "o", tZONE, HOUR(- 2) }, - { "p", tZONE, HOUR(- 3) }, - { "q", tZONE, HOUR(- 4) }, - { "r", tZONE, HOUR(- 5) }, - { "s", tZONE, HOUR(- 6) }, - { "t", tZONE, HOUR(- 7) }, - { "u", tZONE, HOUR(- 8) }, - { "v", tZONE, HOUR(- 9) }, - { "w", tZONE, HOUR(-10) }, - { "x", tZONE, HOUR(-11) }, - { "y", tZONE, HOUR(-12) }, - { "z", tZONE, HOUR( 0) }, - { NULL } -}; - - - - -/* ARGSUSED */ -static int -yyerror(s) - char *s; -{ - return 0; -} - - -static time_t -ToSeconds(Hours, Minutes, Seconds, Meridian) - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; -{ - if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) - return -1; - switch (Meridian) { - case MER24: - if (Hours < 0 || Hours > 23) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERam: - if (Hours < 1 || Hours > 12) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERpm: - if (Hours < 1 || Hours > 12) - return -1; - return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; - default: - abort (); - } - /* NOTREACHED */ -} - - -static time_t -Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) - time_t Month; - time_t Day; - time_t Year; - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; - DSTMODE DSTmode; -{ - static int DaysInMonth[12] = { - 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - time_t tod; - time_t Julian; - int i; - - if (Year < 0) - Year = -Year; - if (Year < 100) - Year += 1900; - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) - ? 29 : 28; - if (Year < EPOCH || Year > 1999 - || Month < 1 || Month > 12 - /* Lint fluff: "conversion from long may lose accuracy" */ - || Day < 1 || Day > DaysInMonth[(int)--Month]) - return -1; - - for (Julian = Day - 1, i = 0; i < Month; i++) - Julian += DaysInMonth[i]; - for (i = EPOCH; i < Year; i++) - Julian += 365 + (i % 4 == 0); - Julian *= SECSPERDAY; - Julian += yyTimezone * 60L; - if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) - return -1; - Julian += tod; - if (DSTmode == DSTon - || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) - Julian -= 60 * 60; - return Julian; -} - - -static time_t -DSTcorrect(Start, Future) - time_t Start; - time_t Future; -{ - time_t StartDay; - time_t FutureDay; - - StartDay = (localtime(&Start)->tm_hour + 1) % 24; - FutureDay = (localtime(&Future)->tm_hour + 1) % 24; - return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; -} - - -static time_t -RelativeDate(Start, DayOrdinal, DayNumber) - time_t Start; - time_t DayOrdinal; - time_t DayNumber; -{ - struct tm *tm; - time_t now; - - now = Start; - tm = localtime(&now); - now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); - now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); - return DSTcorrect(Start, now); -} - - -static time_t -RelativeMonth(Start, RelMonth) - time_t Start; - time_t RelMonth; -{ - struct tm *tm; - time_t Month; - time_t Year; - - if (RelMonth == 0) - return 0; - tm = localtime(&Start); - Month = 12 * tm->tm_year + tm->tm_mon + RelMonth; - Year = Month / 12; - Month = Month % 12 + 1; - return DSTcorrect(Start, - Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - MER24, DSTmaybe)); -} - - -static int -LookupWord(buff) - char *buff; -{ - register char *p; - register char *q; - register const TABLE *tp; - int i; - int abbrev; - - /* Make it lowercase. */ - for (p = buff; *p; p++) - if (isupper(*p)) - *p = tolower(*p); - - if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { - yylval.Meridian = MERam; - return tMERIDIAN; - } - if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { - yylval.Meridian = MERpm; - return tMERIDIAN; - } - - /* See if we have an abbreviation for a month. */ - if (strlen(buff) == 3) - abbrev = 1; - else if (strlen(buff) == 4 && buff[3] == '.') { - abbrev = 1; - buff[3] = '\0'; - } - else - abbrev = 0; - - for (tp = MonthDayTable; tp->name; tp++) { - if (abbrev) { - if (strncmp(buff, tp->name, 3) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - else if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - if (strcmp(buff, "dst") == 0) - return tDST; - - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Strip off any plural and try the units table again. */ - i = strlen(buff) - 1; - if (buff[i] == 's') { - buff[i] = '\0'; - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - buff[i] = 's'; /* Put back for "this" in OtherTable. */ - } - - for (tp = OtherTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Military timezones. */ - if (buff[1] == '\0' && isalpha(*buff)) { - for (tp = MilitaryTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - /* Drop out any periods and try the timezone table again. */ - for (i = 0, p = q = buff; *q; q++) - if (*q != '.') - *p++ = *q; - else - i++; - *p = '\0'; - if (i) - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - return tID; -} - - -static int -yylex() -{ - register char c; - register char *p; - char buff[20]; - int Count; - int sign; - - for ( ; ; ) { - while (isspace(*yyInput)) - yyInput++; - - if (isdigit(c = *yyInput) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - if (!isdigit(*++yyInput)) - /* skip the '-' sign */ - continue; - } - else - sign = 0; - for (yylval.Number = 0; isdigit(c = *yyInput++); ) - yylval.Number = 10 * yylval.Number + c - '0'; - yyInput--; - if (sign < 0) - yylval.Number = -yylval.Number; - return sign ? tSNUMBER : tUNUMBER; - } - if (isalpha(c)) { - for (p = buff; isalpha(c = *yyInput++) || c == '.'; ) - if (p < &buff[sizeof buff - 1]) - *p++ = c; - *p = '\0'; - yyInput--; - return LookupWord(buff); - } - if (c != '(') - return *yyInput++; - Count = 0; - do { - c = *yyInput++; - if (c == '\0') - return c; - if (c == '(') - Count++; - else if (c == ')') - Count--; - } while (Count > 0); - } -} - -#define TM_YEAR_ORIGIN 1900 - -/* Yield A - B, measured in seconds. */ -static long -difftm (a, b) - struct tm *a, *b; -{ - int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); - int by = b->tm_year + (TM_YEAR_ORIGIN - 1); - int days = ( - /* difference in day of year */ - a->tm_yday - b->tm_yday - /* + intervening leap days */ - + ((ay >> 2) - (by >> 2)) - - (ay/100 - by/100) - + ((ay/100 >> 2) - (by/100 >> 2)) - /* + difference in years * 365 */ - + (long)(ay-by) * 365 - ); - return (60*(60*(24*days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) - + (a->tm_sec - b->tm_sec)); -} - -time_t -get_date(p, now) - char *p; - struct timeb *now; -{ - struct tm *tm, gmt; - struct timeb ftz; - time_t Start; - time_t tod; - time_t nowtime; - - yyInput = p; - if (now == NULL) { - now = &ftz; - (void)time (&nowtime); - - if (! (tm = gmtime (&nowtime))) - return -1; - gmt = *tm; /* Make a copy, in case localtime modifies *tm. */ - - if (! (tm = localtime (&nowtime))) - return -1; - - ftz.timezone = difftm (&gmt, tm) / 60; - if(tm->tm_isdst) - ftz.timezone += 60; - } - else - { - nowtime = now->time; - } - - tm = localtime(&nowtime); - yyYear = tm->tm_year; - yyMonth = tm->tm_mon + 1; - yyDay = tm->tm_mday; - yyTimezone = now->timezone; - yyDSTmode = DSTmaybe; - yyHour = 0; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = MER24; - yyRelSeconds = 0; - yyRelMonth = 0; - yyHaveDate = 0; - yyHaveDay = 0; - yyHaveRel = 0; - yyHaveTime = 0; - yyHaveZone = 0; - - if (yyparse() - || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) - return -1; - - if (yyHaveDate || yyHaveTime || yyHaveDay) { - Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, - yyMeridian, yyDSTmode); - if (Start < 0) - return -1; - } - else { - Start = nowtime; - if (!yyHaveRel) - Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec; - } - - Start += yyRelSeconds; - Start += RelativeMonth(Start, yyRelMonth); - - if (yyHaveDay && !yyHaveDate) { - tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber); - Start += tod; - } - - /* Have to do *something* with a legitimate -1 so it's distinguishable - * from the error return value. (Alternately could set errno on error.) */ - return Start == -1 ? 0 : Start; -} - - -#if defined(TEST) - -/* ARGSUSED */ -int -main(ac, av) - int ac; - char *av[]; -{ - char buff[128]; - time_t d; - - (void)printf("Enter date, or blank line to exit.\n\t> "); - (void)fflush(stdout); - while (gets(buff) && buff[0]) { - d = get_date(buff, (struct timeb *)NULL); - if (d == -1) - (void)printf("Bad format - couldn't convert.\n"); - else - (void)printf("%s", ctime(&d)); - (void)printf("\t> "); - (void)fflush(stdout); - } - exit(0); - /* NOTREACHED */ -} -#endif /* defined(TEST) */ diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c deleted file mode 100644 index a79d39363c..0000000000 --- a/calendar/gui/gncal-todo.c +++ /dev/null @@ -1,960 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* To-do widget for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#include <config.h> -#include <string.h> -#include <gnome.h> -#include <cal-client/cal-client.h> -#include <cal-util/timeutil.h> -#include "event-editor.h" -#include "gncal-todo.h" -#include "calendar-commands.h" -#include "popup-menu.h" - -int todo_show_due_date = 0; -int todo_show_priority = 0; -int todo_show_time_remaining = 0; - -int todo_item_dstatus_highlight_overdue = 0; -int todo_item_dstatus_highlight_due_today = 0; -int todo_item_dstatus_highlight_not_due_yet = 0; - - -char *todo_overdue_font_text; -gint todo_current_sort_column = 0; -gint todo_current_sort_type = GTK_SORT_ASCENDING; - -gboolean todo_style_changed =0; -gboolean todo_list_autoresize = 1; -gboolean todo_list_redraw_in_progess = 0; -static void gncal_todo_init (GncalTodo *todo); - - -guint -gncal_todo_get_type (void) -{ - static guint todo_type = 0; - - if (!todo_type) { - GtkTypeInfo todo_info = { - "GncalTodo", - sizeof (GncalTodo), - sizeof (GncalTodoClass), - (GtkClassInitFunc) NULL, - (GtkObjectInitFunc) gncal_todo_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - todo_type = gtk_type_unique (gtk_vbox_get_type (), &todo_info); - } - - return todo_type; -} - -static void -ok_button (GtkWidget *widget, GnomeDialog *dialog) -{ - CalComponent *comp; - CalClient *cal_client; - GnomeDateEdit *due_date; - GtkEditable *entry; - GtkSpinButton *priority; - GtkText *comment; - CalComponentText *text = g_new0 (CalComponentText, 1); - CalComponentDateTime date; - GSList *l; - gchar *t; - time_t d; - int p; - - comp = gtk_object_get_user_data (GTK_OBJECT (dialog)); - - cal_client = (CalClient*) (gtk_object_get_data (GTK_OBJECT (dialog), "cal_client")); - - /* Due date */ - due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date")); - d = gnome_date_edit_get_date (due_date); - date.value = g_new0 (struct icaltimetype, 1); - *date.value = icaltimetype_from_timet (d, 1); - cal_component_set_dtend (comp, &date); - - /* Summary */ - entry = GTK_EDITABLE (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry")); - t = gtk_editable_get_chars (entry, 0, -1); - text->value = t; - cal_component_set_summary (comp, text); - g_free (t); - - /* Priority */ - priority = GTK_SPIN_BUTTON (gtk_object_get_data(GTK_OBJECT(dialog), "priority")); - p = gtk_spin_button_get_value_as_int (priority); - cal_component_set_priority (comp, &p); - - /* Comment */ - cal_component_get_comment_list (comp, &l); - comment = GTK_TEXT(gtk_object_get_data (GTK_OBJECT(dialog), "comment")); - t = gtk_editable_get_chars (entry, 0, -1); - text->value = t; - g_slist_append (l, text); - cal_component_set_comment_list (comp, l); - cal_component_free_text_list (l); - - if (!cal_client_update_object (cal_client, comp)) - g_message ("ok_button(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -static void -cancel_button (GtkWidget *widget, GnomeDialog *dialog) -{ - CalComponent *comp; - - comp = gtk_object_get_user_data (GTK_OBJECT (dialog)); - - gtk_object_unref (GTK_OBJECT (comp)); - - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -static gint -delete_event (GtkWidget *widget, GdkEvent *event, GnomeDialog *dialog) -{ - cancel_button (NULL, dialog); - return TRUE; -} - -/* I've hacked this so we can use it separate from the rest of GncalTodo. - This whole file will go once we've got the new editor working. */ -void -gncal_todo_edit (CalClient *client, CalComponent *comp) -{ - GtkWidget *dialog; - GtkWidget *hbox; - GtkWidget *due_box; - GtkWidget *due_label; - GtkWidget *due_entry; - GtkWidget *comment_box; - GtkWidget *comment_label; - GtkWidget *comment_text; - GtkWidget *comment_internal_box; - GtkWidget *comment_sep; - GtkWidget *w; - GtkWidget *pri_box; - GtkWidget *pri_label; - GtkWidget *pri_spin; - GtkObject *pri_adj; - GtkWidget *entry; - gboolean new; - CalComponentText text; - CalComponentDateTime date; - GSList *l; - time_t d; - gint *p; - - new = (CAL_COMPONENT_NO_TYPE == cal_component_get_vtype (comp)); - if (new) - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - - dialog = gnome_dialog_new (new ? _("Create to-do item") : _("Edit to-do item"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); -#if 0 - gnome_dialog_set_parent (GNOME_DIALOG (dialog), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (todo->calendar)))); -#endif - hbox = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (hbox), 4); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), - hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - - due_box = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (due_box), 4); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0); - gtk_widget_show (due_box); - - pri_box = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (pri_box), 4); - gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (dialog)->vbox), pri_box, FALSE, FALSE, 0); - gtk_widget_show (pri_box); - - comment_box = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (comment_box), 4); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), comment_box, FALSE, FALSE, 0); - gtk_widget_show (comment_box); - - comment_internal_box = gtk_vbox_new(FALSE,2); - gtk_container_border_width (GTK_CONTAINER (comment_internal_box), 4); - - gtk_box_pack_start (GTK_BOX (comment_box), comment_internal_box, TRUE, TRUE, 0); - gtk_widget_show (comment_internal_box); - - w = gtk_label_new (_("Summary:")); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - entry = gtk_entry_new (); - cal_component_get_summary (comp, &text); - gtk_entry_set_text (GTK_ENTRY (entry), text.value); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - gtk_widget_show (entry); - - - due_label = gtk_label_new (_("Due Date:")); - gtk_box_pack_start (GTK_BOX (due_box), due_label, FALSE, FALSE, 0); - gtk_widget_show (due_label); - - due_entry = gtk_entry_new (); - cal_component_get_dtend (comp, &date); - d = time_from_icaltimetype (*date.value); - due_entry = date_edit_new (d, TRUE); - gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0); - gtk_widget_show (due_entry); - - pri_label = gtk_label_new (_("Priority:")); - gtk_box_pack_start (GTK_BOX (pri_box), pri_label, FALSE, FALSE, 0); - gtk_widget_show (pri_label); - - pri_adj = gtk_adjustment_new (5.0, 1.0, 9.0, 1.0, 3.0, 0.0); - pri_spin = gtk_spin_button_new (GTK_ADJUSTMENT(pri_adj), 0.0, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (pri_spin), TRUE); - gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (pri_spin), FALSE); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (pri_spin), FALSE); - cal_component_get_priority (comp, &p); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (pri_spin), (gfloat) *p); - gtk_box_pack_start (GTK_BOX (pri_box), pri_spin, FALSE, FALSE, 0); - gtk_widget_show (pri_spin); - - comment_sep = gtk_hseparator_new (); - gtk_box_pack_start (GTK_BOX (comment_box), comment_sep, FALSE, FALSE, 0); - gtk_widget_show(comment_sep); - - comment_label = gtk_label_new (_("Item Comments:")); - gtk_label_set_justify(GTK_LABEL(comment_label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_label, TRUE, TRUE, 0); - gtk_widget_show (comment_label); - - comment_text = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (comment_text), TRUE); - gtk_text_set_word_wrap( GTK_TEXT(comment_text), TRUE); - gtk_text_freeze(GTK_TEXT(comment_text)); -#warning "FIX ME" - /* Need to handle multiple comments */ - cal_component_get_comment_list (comp, &l); - if (l) { - CalComponentText text = *(CalComponentText*)l->data; - - gtk_text_insert(GTK_TEXT(comment_text), NULL, NULL, NULL, - text.value, strlen(text.value)); - } - cal_component_free_text_list (l); - gtk_text_thaw(GTK_TEXT(comment_text)); - gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_text, FALSE, TRUE, 0); - gtk_widget_show (comment_text); - - gtk_object_set_user_data (GTK_OBJECT (dialog), comp); - gtk_object_ref (GTK_OBJECT (comp)); - - gtk_object_set_data (GTK_OBJECT (dialog), "cal_client", client); - gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry); - gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry); - gtk_object_set_data (GTK_OBJECT (dialog), "priority", pri_spin); - gtk_object_set_data (GTK_OBJECT (dialog), "comment", comment_text); - - gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog); - gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog); - - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - (GtkSignalFunc) delete_event, - dialog); - - gnome_dialog_set_default (GNOME_DIALOG (dialog), 0); - gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE(entry)); - - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_widget_show (dialog); - gtk_widget_grab_focus (entry); -} - -static CalComponent * -get_clist_selected_comp (GtkCList *clist) -{ - gint sel; - - if (!clist->selection) - return NULL; - - sel = GPOINTER_TO_INT(clist->selection->data); - - return gtk_clist_get_row_data (clist, sel); -} - -static void -add_todo (GncalTodo *todo) -{ - CalComponent *comp; - - comp = cal_component_new (); - -#if 0 - gncal_todo_edit (todo, comp); -#endif - gtk_object_unref (GTK_OBJECT (comp)); -} - -static void -edit_todo (GncalTodo *todo) -{ - CalComponent *comp; - - comp = get_clist_selected_comp (todo->clist); - -#if 0 - gncal_todo_edit (todo, comp); -#endif -} - -static void -delete_todo (GncalTodo *todo) -{ - CalComponent *comp; - const char *uid; - - comp = get_clist_selected_comp (todo->clist); - cal_component_get_uid (comp, &uid); - - if (!cal_client_remove_object (todo->calendar->client, uid)) - g_message ("delete_todo(): Could not remove the object!"); -} - -static void -add_activated (GtkWidget *widget, GncalTodo *todo) -{ - GtkWidget *w; - - while ((w = gtk_grab_get_current ()) != NULL) - gtk_grab_remove (w); - - add_todo (todo); -} - -static void -edit_activated (GtkWidget *widget, GncalTodo *todo) -{ - GtkWidget *w; - - while ((w = gtk_grab_get_current ()) != NULL) - gtk_grab_remove (w); - - edit_todo (todo); -} - -static void -delete_activated (GtkWidget *widget, GncalTodo *todo) -{ - delete_todo (todo); -} - - -static void -clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *event, GncalTodo *todo) -{ - static struct menu_item items[] = { - { N_("Add to-do item..."), (GtkSignalFunc) add_activated, NULL, TRUE }, - { N_("Edit this item..."), (GtkSignalFunc) edit_activated, NULL, TRUE }, - { N_("Delete this item"), (GtkSignalFunc) delete_activated, NULL, TRUE } - }; - - int i; - - gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL)); - gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL)); - - if (!event) - return; - - switch (event->button) { - case 1: - if (event->type == GDK_2BUTTON_PRESS) - edit_todo (todo); - break; - - case 3: - for (i = 0; i < (sizeof (items) / sizeof (items[0])); i++) - items[i].data = todo; - - popup_menu (items, sizeof (items) / sizeof (items[0]), event); - break; - - default: - break; - } -} - -/* - * once we get a call back stating that a column - * has been resized never ever automatically resize again - */ -static void -column_resized (GtkWidget *widget, GncalTodo *todo) -{ - /* disabling autoresize of columns */ - if (todo_list_autoresize && !todo_list_redraw_in_progess){ - todo_list_autoresize = 0; - } -} - -/* - * restore the previously set settings for sorting the - * todo list - */ -static void -init_column_sorting (GtkCList *clist) -{ - - /* due date isn't shown so we can't sort by it */ - if (todo_current_sort_column == 1 && ! todo_show_due_date) - todo_current_sort_column = 0; - - clist->sort_type = todo_current_sort_type; - clist->sort_column = todo_current_sort_column; - - gtk_clist_set_sort_column (clist, todo_current_sort_column); - gtk_clist_sort (clist); -} - -static void -todo_click_column (GtkCList *clist, gint column, gpointer data) -{ - if (column == clist->sort_column) - { - if (clist->sort_type == GTK_SORT_ASCENDING) { - clist->sort_type = GTK_SORT_DESCENDING; - todo_current_sort_type = GTK_SORT_DESCENDING; - } else { - clist->sort_type = GTK_SORT_ASCENDING; - todo_current_sort_type = GTK_SORT_ASCENDING; - } - } - else { - gtk_clist_set_sort_column (clist, column); - todo_current_sort_column = column; - } - - gtk_clist_sort (clist); - - /* - * save the sorting preferences cause I hate to have the user - * click twice - */ - - gnome_config_set_int("/calendar/Todo/sort_column", todo_current_sort_column); - gnome_config_set_int("/calendar/Todo/sort_type", todo_current_sort_type); - gnome_config_sync(); -} - -static void -gncal_todo_init (GncalTodo *todo) -{ - GtkWidget *w; - GtkWidget *sw; - GtkWidget *hbox; - gchar *titles[4] = { - N_("Summary"), - N_("Due Date"), - N_("Priority"), - N_("Time Left") - }; - char *tmp[4]; - tmp[0] = _(titles[0]); - tmp[1] = _(titles[1]); - tmp[2] = _(titles[2]); - tmp[3] = _(titles[3]); - - gtk_box_set_spacing (GTK_BOX (todo), 4); - - /* Label */ - - w = gtk_label_new (_("To-do list")); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (todo), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Clist */ - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX (todo), sw, TRUE, TRUE, 0); - gtk_widget_show (sw); - - - w = gtk_clist_new_with_titles(4, tmp); - - todo->clist = GTK_CLIST (w); - gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE); - - gtk_signal_connect (GTK_OBJECT (todo->clist), "select_row", - (GtkSignalFunc) clist_row_selected, - todo); - gtk_clist_set_button_actions (todo->clist, 2, GTK_BUTTON_SELECTS); - gtk_signal_connect (GTK_OBJECT (todo->clist), "resize_column", - (GtkSignalFunc) column_resized, - todo); - gtk_signal_connect (GTK_OBJECT (todo->clist), "click_column", - (GtkSignalFunc) todo_click_column, NULL); - - gtk_container_add (GTK_CONTAINER (sw), w); - gtk_widget_show (w); - - /* Box for buttons */ - - hbox = gtk_hbox_new (TRUE, 4); - gtk_box_pack_start (GTK_BOX (todo), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - /* Add */ - - w = gtk_button_new_with_label (_("Add...")); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) add_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); - - /* Edit */ - - w = gtk_button_new_with_label (_("Edit...")); - todo->edit_button = w; - gtk_widget_set_sensitive (w, FALSE); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) edit_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); - - /* Delete */ - - w = gtk_button_new_with_label (_("Delete")); - todo->delete_button = w; - gtk_widget_set_sensitive (w, FALSE); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) delete_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); -} - -GtkWidget * -gncal_todo_new (GnomeCalendar *calendar) -{ - GncalTodo *todo; - - g_return_val_if_fail (calendar != NULL, NULL); - - todo = gtk_type_new (gncal_todo_get_type ()); - - todo->calendar = calendar; - - gncal_todo_update (todo, NULL, 0); - - return GTK_WIDGET (todo); -} - -static char * -convert_time_t_to_char (time_t t) -{ - char buf[100]; - struct tm tm; - - tm = *localtime (&t); - strftime(buf, sizeof (buf), "%m/%d/%Y", &tm); - - return g_strdup (buf); -} - - -enum todo_styles { - TODO_STYLE_OVERDUE, - TODO_STYLE_DUE_TODAY, - TODO_STYLE_NOT_DUE -}; - - -enum todo_status { - TODO_ITEM_DSTATUS_NOT_DUE_YET, - TODO_ITEM_DSTATUS_DUE_TODAY, - TODO_ITEM_DSTATUS_OVERDUE, - TODO_ITEM_DSTATUS_LAST_DUE_STATUS -}; -typedef enum todo_status todo_status; - -static GtkStyle * -make_todo_style(GncalTodo *todo, todo_status style_type) -{ - GtkStyle *style = NULL; - GdkColor style_color; - int color_prop = 0; - switch(style_type) { - case TODO_ITEM_DSTATUS_NOT_DUE_YET: - color_prop = COLOR_PROP_TODO_NOT_DUE_YET; - break; - case TODO_ITEM_DSTATUS_DUE_TODAY: - color_prop = COLOR_PROP_TODO_DUE_TODAY; - break; - case TODO_ITEM_DSTATUS_OVERDUE: - color_prop = COLOR_PROP_TODO_OVERDUE; - break; - case TODO_ITEM_DSTATUS_LAST_DUE_STATUS: - } - - style_color.red = color_props[color_prop].r; - style_color.green = color_props[color_prop].g; - style_color.blue = color_props[color_prop].b; - - style = gtk_style_copy (GTK_WIDGET (todo->clist)->style); - style->base[GTK_STATE_NORMAL] = style_color; - return style; -} - - -static -todo_status todo_item_due_status(time_t *todo_due_time) { - struct tm due_tm_time; - struct tm current_time; - struct tm *temp_tm; - time_t current_time_val = time(NULL); - temp_tm = localtime(todo_due_time); - /* make a copy so it dosen't get over written */ - memcpy(&due_tm_time, temp_tm, sizeof(struct tm)); - - - temp_tm = localtime(¤t_time_val); - memcpy(¤t_time, temp_tm, sizeof(struct tm)); - - if(due_tm_time.tm_mon == current_time.tm_mon && - due_tm_time.tm_mday == current_time.tm_mday && - due_tm_time.tm_year == current_time.tm_year) { - return TODO_ITEM_DSTATUS_DUE_TODAY; - } - - if((*todo_due_time) < current_time_val) { - return TODO_ITEM_DSTATUS_OVERDUE; - } - - return TODO_ITEM_DSTATUS_NOT_DUE_YET; -} - - -enum todo_remaining_time_form { - TODO_ITEM_REMAINING_WEEKS, - TODO_ITEM_REMAINING_DAYS, - TODO_ITEM_REMAINING_HOURS, - TODO_ITEM_REMAINING_MINUTES, - TODO_ITEM_REMAINING_SECONDS -}; -typedef enum todo_remaining_time_form todo_remaining_time_form; - - -static void -insert_in_clist (GncalTodo *todo, CalComponent *comp) -{ - int i; - CalComponentText t; - CalComponentDateTime date; - char *text[4]; - char time_remaining_buffer[100]; - time_t time_remain; - todo_remaining_time_form time_remaining_form; - int sec_in_week = 3600*7*24; - int sec_in_day = 3600*24; - int sec_in_hour = 3600; - int sec_in_minute = 60; - int weeks = 0; - int days = 0; - int hours = 0; - int minutes = 0; - int seconds = 0; - int *p; - time_t d; - - /* an array for the styles of items */ - static GtkStyle *dstatus_styles[TODO_ITEM_DSTATUS_LAST_DUE_STATUS]; - /* we want to remake the styles when the status is changed, - also we need to check for the null value in the pointer so we init them - at startup */ - if (todo_style_changed || !dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]) { - g_free(dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]); - g_free(dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]); - g_free(dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]); - - dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET] = make_todo_style(todo, TODO_ITEM_DSTATUS_NOT_DUE_YET); - dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE] = make_todo_style(todo, TODO_ITEM_DSTATUS_OVERDUE); - dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY] = make_todo_style(todo, TODO_ITEM_DSTATUS_DUE_TODAY); - - todo_style_changed = 0; - } - - cal_component_get_summary (comp, &t); - text[0] = g_strdup (t.value); - - if(todo_show_time_remaining) { - memset(time_remaining_buffer, 0, 100); - /* we need to make a string that represents the amount of time remaining - before this task is due */ - - /* for right now all I'll do is up to the hours. */ - cal_component_get_dtend (comp, &date); - time_remain = time_from_icaltimetype (*date.value) - time (NULL); - if(time_remain < 0) { - text[3] = "Overdue!"; - } - else { - - /* lets determine a decent denomination to display */ - if(time_remain / (sec_in_week)) - { - /* we have weeks available */ - time_remaining_form = TODO_ITEM_REMAINING_WEEKS; - weeks = time_remain / sec_in_week; - days = (time_remain % (sec_in_week))/sec_in_day; - } - else if(time_remain / (sec_in_day)) - { - /* we have days available */ - time_remaining_form = TODO_ITEM_REMAINING_DAYS; - days = time_remain / sec_in_day; - hours = (time_remain % sec_in_day)/sec_in_hour; - } - else if(time_remain / (sec_in_hour)) - { - /* we have hours available */ - time_remaining_form = TODO_ITEM_REMAINING_HOURS; - hours = time_remain /sec_in_hour; - minutes = (time_remain % sec_in_hour) / sec_in_minute; - } - else if(time_remain / sec_in_minute) - { - time_remaining_form = TODO_ITEM_REMAINING_MINUTES; - minutes = time_remain / sec_in_minute; - seconds = time_remain % sec_in_minute; - } - else - { - time_remaining_form = TODO_ITEM_REMAINING_SECONDS; - seconds = time_remain; - } - - switch(time_remaining_form) - { - case TODO_ITEM_REMAINING_WEEKS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", weeks, - (weeks > 1) ? _("Weeks") : _("Week"), - days, (days > 1) ? _("Days") : _("Day")); - break; - case TODO_ITEM_REMAINING_DAYS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", days, - (days > 1) ? _("Days") : _("Day"), - hours, (hours > 1) ? _("Hours") : _("Hour")); - break; - case TODO_ITEM_REMAINING_HOURS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", hours, - (hours > 1) ? _("Hours") : _("Hour"), - minutes, (minutes > 1) ? _("Minutes") : _("Minute")); - break; - case TODO_ITEM_REMAINING_MINUTES: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", minutes, - (minutes > 1) ? _("Minutes") : _("Minute"), - seconds, (seconds > 1) ? _("Seconds") : _("Second")); - break; - case TODO_ITEM_REMAINING_SECONDS: - snprintf(time_remaining_buffer, 100, "%d %s", seconds, - (seconds > 1) ? _("Seconds") : _("Second")); - break; - } - text[3] = g_strdup(time_remaining_buffer); - todo->data_ptrs = g_slist_append(todo->data_ptrs, text[3]); - } - - } - else { - text[3] = "Loose penguini!"; - } - /* - * right now column 0 will be the summary - * and column 1 will be the due date. - * WISH: this should be able to be changed on the fly - */ - - cal_component_get_dtend (comp, &date); - d = time_from_icaltimetype (*date.value); - if(todo_show_due_date) - { - text[1] = convert_time_t_to_char (d); - /* Append the data's pointer so later it can be properly freed */ - todo->data_ptrs = g_slist_append (todo->data_ptrs, text[1]); - } - else - text[1] = NULL; - - cal_component_get_priority (comp, &p); - if(p && todo_show_priority) - { - text[2] = g_strdup_printf ("%d", *p); - todo->data_ptrs = g_slist_append (todo->data_ptrs, text[2]); - } - else - text[2] = NULL; - - i = gtk_clist_append (todo->clist, text); - - gtk_clist_set_row_data_full (todo->clist, i, comp, - (GtkDestroyNotify) gtk_object_ref); - gtk_object_ref (GTK_OBJECT (comp)); - - /* - * determine if the task is overdue.. - * if so mark with the apropriate style - */ - - switch(todo_item_due_status(&d)) { - case TODO_ITEM_DSTATUS_NOT_DUE_YET: - if(todo_item_dstatus_highlight_not_due_yet) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]); - } - break; - case TODO_ITEM_DSTATUS_DUE_TODAY: - if(todo_item_dstatus_highlight_due_today) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]); - } - break; - case TODO_ITEM_DSTATUS_OVERDUE: - if(todo_item_dstatus_highlight_overdue) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]); - } - break; - case TODO_ITEM_DSTATUS_LAST_DUE_STATUS: - } - - /* keep the list in order */ - gtk_clist_sort (todo->clist); -} - - -void -gncal_todo_update (GncalTodo *todo, CalComponent *comp, int flags) -{ - GSList *current_list; - CalClientGetStatus status; - GList *l, *uids; - - g_return_if_fail (todo != NULL); - g_return_if_fail (GNCAL_IS_TODO (todo)); - - /* - * shut down the resize handler cause we are playing with the list. - * In otherwords turn off the event handler - */ - todo_list_redraw_in_progess =1; - - /* freeze the list */ - gtk_clist_freeze (todo->clist); - init_column_sorting (todo->clist); - - /* - * before here we have to free some of the memory that - * stores the due date, or else we have a memory leak. - * luckily all of the pointers are stored in todo->data_ptrs; - */ - - /* check on the columns that we should display */ - /* check for due date */ - - if(todo_show_due_date) { - gtk_clist_set_column_visibility (todo->clist, 1, 1); - } - else { - gtk_clist_set_column_visibility (todo->clist, 1, 0); - } - - if(todo_show_time_remaining) { - gtk_clist_set_column_visibility (todo->clist, 3, 1); - } - else { - gtk_clist_set_column_visibility (todo->clist, 3, 0); - } - - - if(todo_show_priority) - gtk_clist_set_column_visibility (todo->clist, 2, 1); - else - gtk_clist_set_column_visibility (todo->clist, 2, 0); - - /* free the memory locations that were used in the previous display */ - for (current_list = todo->data_ptrs; - current_list != NULL; - current_list = g_slist_next(current_list)){ - g_free(current_list->data); - } - - /* free the list and clear out the pointer */ - g_slist_free(todo->data_ptrs); - todo->data_ptrs = NULL; - - gtk_clist_clear (todo->clist); - - - uids = cal_client_get_uids (todo->calendar->client, CAL_COMPONENT_TODO); - for (l = uids; l; l = l->next){ - char *uid = l->data; - CalComponent *comp; - - status = cal_client_get_object (todo->calendar->client, uid, - &comp); - - if (status == CAL_CLIENT_GET_SUCCESS) { - insert_in_clist (todo, comp); - gtk_object_unref (GTK_OBJECT (comp)); - } -#warning "FIX ME" - /* else? */ - g_free (uid); - } - g_list_free (uids); - - /* if we are autoresizing then do it now */ - if(todo_list_autoresize && todo->clist->rows != 0) - gtk_clist_columns_autosize (todo->clist); - - gtk_clist_thaw (todo->clist); - - gtk_widget_set_sensitive (todo->edit_button, - (todo->clist->selection != NULL)); - gtk_widget_set_sensitive (todo->delete_button, - (todo->clist->selection != NULL)); - todo_list_redraw_in_progess = 0; -} - - - - - - - - - - - diff --git a/calendar/gui/gncal-todo.h b/calendar/gui/gncal-todo.h deleted file mode 100644 index 1102e32d77..0000000000 --- a/calendar/gui/gncal-todo.h +++ /dev/null @@ -1,54 +0,0 @@ -/* To-do widget for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#ifndef GNCAL_TODO_H -#define GNCAL_TODO_H - -#include <gtk/gtkclist.h> -#include <gtk/gtkvbox.h> -#include <libgnome/gnome-defs.h> -#include "gnome-cal.h" - - -BEGIN_GNOME_DECLS - - -#define GNCAL_TODO(obj) GTK_CHECK_CAST (obj, gncal_todo_get_type (), GncalTodo) -#define GNCAL_TODO_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_todo_get_type (), GncalTodoClass) -#define GNCAL_IS_TODO(obj) GTK_CHECK_TYPE (obj, gncal_todo_get_type ()) - - -typedef struct _GncalTodo GncalTodo; -typedef struct _GncalTodoClass GncalTodoClass; - -struct _GncalTodo { - GtkVBox vbox; - - GnomeCalendar *calendar; /* the calendar we are associated to */ - - GtkCList *clist; - - GtkWidget *edit_button; - GtkWidget *delete_button; - GSList *data_ptrs; -}; - -struct _GncalTodoClass { - GtkVBoxClass parent_class; -}; - - -guint gncal_todo_get_type (void); -GtkWidget *gncal_todo_new (GnomeCalendar *calendar); - -void gncal_todo_update (GncalTodo *todo, CalComponent *comp, int flags); - -void gncal_todo_edit (CalClient *client, CalComponent *comp); - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c deleted file mode 100644 index 334e66f331..0000000000 --- a/calendar/gui/gnome-cal.c +++ /dev/null @@ -1,1530 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * GnomeCalendar widget - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: Miguel de Icaza (miguel@kernel.org) - * Federico Mena-Quintero <federico@helixcode.com> - */ - -#include <config.h> -#include <unistd.h> -#include <signal.h> -#include <sys/wait.h> -#include <fcntl.h> -#include <gtk/gtkframe.h> -#include <widgets/e-paned/e-hpaned.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkmain.h> -#include <gtk/gtknotebook.h> -#include <gtk/gtkscrolledwindow.h> -#include <widgets/e-paned/e-vpaned.h> -#include <libgnomeui/gnome-messagebox.h> -#include <cal-util/timeutil.h> -#include "dialogs/alarm-notify-dialog.h" -#include "alarm.h" -#include "e-calendar-table.h" -#include "e-day-view.h" -#include "e-week-view.h" -#include "event-editor.h" -#include "gnome-cal.h" -#include "calendar-commands.h" - - - -/* An entry in the UID->alarms hash table. The UID key *is* the uid field in - * this structure, so don't free it separately. - */ -typedef struct { - char *uid; - GList *alarm_ids; -} ObjectAlarms; - - - -static void gnome_calendar_class_init (GnomeCalendarClass *class); -static void gnome_calendar_init (GnomeCalendar *gcal); -static void gnome_calendar_destroy (GtkObject *object); - -static void gnome_calendar_update_view_times (GnomeCalendar *gcal, - GtkWidget *page); -static void gnome_calendar_update_gtk_calendar (GnomeCalendar *gcal); -static void gnome_calendar_on_day_selected (GtkCalendar *calendar, - GnomeCalendar *gcal); -static void gnome_calendar_on_month_changed (GtkCalendar *calendar, - GnomeCalendar *gcal); - -static GtkVBoxClass *parent_class; - -static void setup_alarm (GnomeCalendar *cal, CalAlarmInstance *ai); - - - -guint -gnome_calendar_get_type (void) -{ - static guint gnome_calendar_type = 0; - if(!gnome_calendar_type) { - GtkTypeInfo gnome_calendar_info = { - "GnomeCalendar", - sizeof (GnomeCalendar), - sizeof (GnomeCalendarClass), - (GtkClassInitFunc) gnome_calendar_class_init, - (GtkObjectInitFunc) gnome_calendar_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - /* - gnome_calendar_type = gtk_type_unique(gnome_app_get_type(), &gnome_calendar_info); - parent_class = gtk_type_class (gnome_app_get_type()); - */ - gnome_calendar_type = gtk_type_unique (gtk_vbox_get_type (), - &gnome_calendar_info); - parent_class = gtk_type_class (gtk_vbox_get_type ()); - } - return gnome_calendar_type; -} - -/* Class initialization function for the gnome calendar */ -static void -gnome_calendar_class_init (GnomeCalendarClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - object_class->destroy = gnome_calendar_destroy; -} - -/* Object initialization function for the gnome calendar */ -static void -gnome_calendar_init (GnomeCalendar *gcal) -{ - gcal->object_editor_hash = g_hash_table_new (g_str_hash, g_str_equal); - gcal->alarms = g_hash_table_new (g_str_hash, g_str_equal); -} - -/* Used from g_hash_table_foreach(); frees an object alarms entry */ -static void -free_object_alarms (gpointer key, gpointer value, gpointer data) -{ - ObjectAlarms *oa; - - oa = value; - - g_assert (oa->uid != NULL); - g_free (oa->uid); - oa->uid = NULL; - - g_assert (oa->alarm_ids != NULL); - g_list_free (oa->alarm_ids); - oa->alarm_ids = NULL; - - g_free (oa); -} - -/* Used from g_hash_table_foreach(); frees an UID string */ -static void -free_uid (gpointer key, gpointer value, gpointer data) -{ - char *uid; - - uid = key; - g_free (uid); -} - -static void -gnome_calendar_destroy (GtkObject *object) -{ - GnomeCalendar *gcal; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (object)); - - gcal = GNOME_CALENDAR (object); - - gtk_object_unref (GTK_OBJECT (gcal->client)); - - g_hash_table_foreach (gcal->alarms, free_object_alarms, NULL); - g_hash_table_destroy (gcal->alarms); - gcal->alarms = NULL; - - g_hash_table_foreach (gcal->object_editor_hash, free_uid, NULL); - g_hash_table_destroy (gcal->object_editor_hash); - gcal->object_editor_hash = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -setup_widgets (GnomeCalendar *gcal) -{ - GtkWidget *vpane, *w; - - /* The Main Notebook. */ - gcal->main_notebook = gtk_notebook_new (); - gtk_notebook_set_show_border (GTK_NOTEBOOK (gcal->main_notebook), - FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (gcal->main_notebook), FALSE); - gtk_widget_show (gcal->main_notebook); - gtk_box_pack_start (GTK_BOX (gcal), gcal->main_notebook, - TRUE, TRUE, 0); - - /* The First Page of the Main Notebook, containing a HPaned with the - Sub-Notebook on the left and the GtkCalendar and ToDo list on the - right. */ - gcal->hpane = e_hpaned_new (); - gtk_widget_show (gcal->hpane); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->main_notebook), - gcal->hpane, gtk_label_new ("")); - - /* The Sub-Notebook, to contain the Day, Work-Week & Week views. */ - gcal->sub_notebook = gtk_notebook_new (); - gtk_notebook_set_show_border (GTK_NOTEBOOK (gcal->sub_notebook), - FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (gcal->sub_notebook), FALSE); - gtk_widget_show (gcal->sub_notebook); - e_paned_pack1 (E_PANED (gcal->hpane), gcal->sub_notebook, - TRUE, TRUE); - - /* The VPaned widget, to contain the GtkCalendar & ToDo list. */ - vpane = e_vpaned_new (); - gtk_widget_show (vpane); - e_paned_pack2 (E_PANED (gcal->hpane), vpane, FALSE, TRUE); - - /* The GtkCalendar. */ - w = gtk_calendar_new (); - gcal->gtk_calendar = GTK_CALENDAR (w); - gtk_widget_show (w); - e_paned_pack1 (E_PANED (vpane), w, FALSE, TRUE); - gcal->day_selected_id = gtk_signal_connect (GTK_OBJECT (gcal->gtk_calendar), - "day_selected", - (GtkSignalFunc) gnome_calendar_on_day_selected, - gcal); - gtk_signal_connect (GTK_OBJECT (gcal->gtk_calendar), "month_changed", - GTK_SIGNAL_FUNC (gnome_calendar_on_month_changed), - gcal); - - /* The ToDo list. */ -#if 0 - gcal->todo = gncal_todo_new (gcal); - e_paned_pack2 (E_PANED (vpane), gcal->todo, TRUE, TRUE); - gtk_widget_show (gcal->todo); -#endif - - gcal->todo = e_calendar_table_new (); - e_paned_pack2 (E_PANED (vpane), gcal->todo, TRUE, TRUE); - gtk_widget_show (gcal->todo); - e_calendar_table_set_cal_client (E_CALENDAR_TABLE (gcal->todo), - gcal->client); - - - /* The Day View. */ - gcal->day_view = e_day_view_new (); - e_day_view_set_calendar (E_DAY_VIEW (gcal->day_view), gcal); - gtk_widget_show (gcal->day_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), - gcal->day_view, gtk_label_new ("")); - - /* The Work Week View. */ - gcal->work_week_view = e_day_view_new (); - e_day_view_set_days_shown (E_DAY_VIEW (gcal->work_week_view), 5); - e_day_view_set_calendar (E_DAY_VIEW (gcal->work_week_view), gcal); - gtk_widget_show (gcal->work_week_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), - gcal->work_week_view, gtk_label_new ("")); - - /* The Week View. */ - gcal->week_view = e_week_view_new (); - e_week_view_set_calendar (E_WEEK_VIEW (gcal->week_view), gcal); - gtk_widget_show (gcal->week_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), - gcal->week_view, gtk_label_new ("")); - - /* The Month View. */ - gcal->month_view = e_week_view_new (); - e_week_view_set_calendar (E_WEEK_VIEW (gcal->month_view), gcal); - e_week_view_set_display_month (E_WEEK_VIEW (gcal->month_view), TRUE); - gtk_widget_show (gcal->month_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->main_notebook), - gcal->month_view, gtk_label_new ("")); -} - -static GtkWidget * -get_current_page (GnomeCalendar *gcal) -{ - GtkWidget *page; - - page = GTK_NOTEBOOK (gcal->main_notebook)->cur_page->child; - if (page == gcal->hpane) - return GTK_NOTEBOOK (gcal->sub_notebook)->cur_page->child; - else - return page; -} - -char * -gnome_calendar_get_current_view_name (GnomeCalendar *gcal) -{ - GtkWidget *page; - - g_return_val_if_fail (gcal != NULL, "dayview"); - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), "dayview"); - - page = get_current_page (gcal); - - if (page == gcal->day_view) - return "dayview"; - else if (page == gcal->work_week_view) - return "workweekview"; - else if (page == gcal->week_view) - return "weekview"; - else if (page == gcal->month_view) - return "monthview"; - else - return "dayview"; -} - -void -gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (new_time != -1); - - gcal->selection_start_time = time_day_begin (new_time); - gcal->selection_end_time = time_add_day (gcal->selection_start_time, - 1); - gnome_calendar_update_view_times (gcal, NULL); - gnome_calendar_update_gtk_calendar (gcal); -} - - -static void -gnome_calendar_update_view_times (GnomeCalendar *gcal, - GtkWidget *page) -{ - if (page == NULL) - page = get_current_page (gcal); - - if (page == gcal->day_view - || page == gcal->work_week_view) - e_day_view_set_selected_time_range (E_DAY_VIEW (page), - gcal->selection_start_time, - gcal->selection_end_time); - else if (page == gcal->week_view - || page == gcal->month_view) - e_week_view_set_selected_time_range (E_WEEK_VIEW (page), - gcal->selection_start_time, - gcal->selection_end_time); - else { - g_warning ("My penguin is gone!"); - g_assert_not_reached (); - } -} - -static void -gnome_calendar_direction (GnomeCalendar *gcal, int direction) -{ - GtkWidget *cp = get_current_page (gcal); - time_t start_time, end_time; - - start_time = gcal->selection_start_time; - end_time = gcal->selection_end_time; - - if (cp == gcal->day_view) { - start_time = time_add_day (start_time, direction); - end_time = time_add_day (end_time, direction); - } else if (cp == gcal->work_week_view) { - start_time = time_add_week (start_time, direction); - end_time = time_add_week (end_time, direction); - } else if (cp == gcal->week_view) { - start_time = time_add_week (start_time, direction); - end_time = time_add_week (end_time, direction); - } else if (cp == gcal->month_view) { - start_time = time_add_month (start_time, direction); - end_time = time_add_month (end_time, direction); - } else { - g_warning ("Weee! Where did the penguin go?"); - g_assert_not_reached (); - start_time = 0; - end_time = 0; - } - - gcal->selection_start_time = start_time; - gcal->selection_end_time = end_time; - - gnome_calendar_update_view_times (gcal, NULL); - gnome_calendar_update_gtk_calendar (gcal); -} - -void -gnome_calendar_next (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_direction (gcal, 1); -} - -void -gnome_calendar_previous (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_direction (gcal, -1); -} - -void -gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_set_view (gcal, "dayview"); - gnome_calendar_goto (gcal, time); -} - -void -gnome_calendar_goto_today (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_goto (gcal, time (NULL)); -} - - -/* This sets which view is currently shown. It also updates the selection time - of the view so it shows the appropriate days. */ -void -gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name) -{ - GtkWidget *page; - int main_page = 0, sub_page = -1; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (page_name != NULL); - - if (strcmp (page_name, "dayview") == 0) { - page = gcal->day_view; - sub_page = 0; - } else if (strcmp (page_name, "workweekview") == 0) { - page = gcal->work_week_view; - sub_page = 1; - } else if (strcmp (page_name, "weekview") == 0) { - page = gcal->week_view; - sub_page = 2; - } else if (strcmp (page_name, "monthview") == 0) { - page = gcal->month_view; - main_page = 1; - } else { - g_warning ("Unknown calendar view: %s", page_name); - return; - } - - gnome_calendar_update_view_times (gcal, page); - - if (sub_page != -1) - gtk_notebook_set_page (GTK_NOTEBOOK (gcal->sub_notebook), - sub_page); - gtk_notebook_set_page (GTK_NOTEBOOK (gcal->main_notebook), main_page); - - gnome_calendar_update_gtk_calendar (gcal); -} - -/* Sends a mail notification of an alarm trigger */ -static void -mail_notification (char *mail_address, char *text, time_t app_time) -{ - pid_t pid; - int p [2]; - char *command; - - pipe (p); - pid = fork (); - if (pid == 0){ - int dev_null; - - dev_null = open ("/dev/null", O_RDWR); - dup2 (p [0], 0); - dup2 (dev_null, 1); - dup2 (dev_null, 2); - execl ("/usr/lib/sendmail", "/usr/lib/sendmail", - mail_address, NULL); - _exit (127); - } - command = g_strconcat ("To: ", mail_address, "\n", - "Subject: ", _("Reminder of your appointment at "), - ctime (&app_time), "\n\n", text, "\n", NULL); - write (p [1], command, strlen (command)); - close (p [1]); - close (p [0]); - g_free (command); -} - -static int -max_open_files (void) -{ - static int files; - - if (files) - return files; - - files = sysconf (_SC_OPEN_MAX); - if (files != -1) - return files; -#ifdef OPEN_MAX - return files = OPEN_MAX; -#else - return files = 256; -#endif -} - -/* Executes a program as a notification of an alarm trigger */ -static void -program_notification (char *command, int close_standard) -{ - struct sigaction ignore, save_intr, save_quit; - int status = 0, i; - pid_t pid; - - ignore.sa_handler = SIG_IGN; - sigemptyset (&ignore.sa_mask); - ignore.sa_flags = 0; - - sigaction (SIGINT, &ignore, &save_intr); - sigaction (SIGQUIT, &ignore, &save_quit); - - if ((pid = fork ()) < 0){ - fprintf (stderr, "\n\nfork () = -1\n"); - return; - } - if (pid == 0){ - pid = fork (); - if (pid == 0){ - const int top = max_open_files (); - sigaction (SIGINT, &save_intr, NULL); - sigaction (SIGQUIT, &save_quit, NULL); - - for (i = (close_standard ? 0 : 3); i < top; i++) - close (i); - - /* FIXME: As an excercise to the reader, copy the - * code from mc to setup shell properly instead of - * /bin/sh. Yes, this comment is larger than a cut and paste. - */ - execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0); - - _exit (127); - } else { - _exit (127); - } - } - wait (&status); - sigaction (SIGINT, &save_intr, NULL); - sigaction (SIGQUIT, &save_quit, NULL); -} - -/* Queues a snooze alarm */ -static void -snooze (GnomeCalendar *gcal, CalComponent *comp, time_t occur, int snooze_mins, gboolean audio) -{ - time_t now, trigger; - struct tm tm; - CalAlarmInstance ai; - - now = time (NULL); - tm = *localtime (&now); - tm.tm_min += snooze_mins; - - trigger = mktime (&tm); - if (trigger == -1) { - g_message ("snooze(): produced invalid time_t; not queueing alarm!"); - return; - } - -#if 0 - cal_component_get_uid (comp, &ai.uid); - ai.type = audio ? ALARM_AUDIO : ALARM_DISPLAY; -#endif - ai.trigger = trigger; - ai.occur = occur; - - setup_alarm (gcal, &ai); -} - -/* Edits an appointment from the alarm notification dialog */ -static void -edit (GnomeCalendar *gcal, CalComponent *comp) -{ - gnome_calendar_edit_object (gcal, comp); -} - -struct alarm_notify_closure { - GnomeCalendar *gcal; - CalComponent *comp; - time_t occur; -}; - -/* Callback used for the result of the alarm notification dialog */ -static void -display_notification_cb (AlarmNotifyResult result, int snooze_mins, gpointer data) -{ - struct alarm_notify_closure *c; - - c = data; - - switch (result) { - case ALARM_NOTIFY_CLOSE: - break; - - case ALARM_NOTIFY_SNOOZE: - snooze (c->gcal, c->comp, c->occur, snooze_mins, FALSE); - break; - - case ALARM_NOTIFY_EDIT: - edit (c->gcal, c->comp); - break; - - default: - g_assert_not_reached (); - } - - gtk_object_unref (GTK_OBJECT (c->comp)); - g_free (c); -} - -/* Present a display notification of an alarm trigger */ -static void -display_notification (time_t trigger, time_t occur, CalComponent *comp, GnomeCalendar *gcal) -{ - gboolean result; - struct alarm_notify_closure *c; - - gtk_object_ref (GTK_OBJECT (comp)); - - c = g_new (struct alarm_notify_closure, 1); - c->gcal = gcal; - c->comp = comp; - c->occur = occur; - - result = alarm_notify_dialog (trigger, occur, comp, display_notification_cb, c); - if (!result) { - g_message ("display_notification(): could not display the alarm notification dialog"); - g_free (c); - gtk_object_unref (GTK_OBJECT (comp)); - } -} - -/* Present an audible notification of an alarm trigger */ -static void -audio_notification (time_t trigger, time_t occur, CalComponent *comp, GnomeCalendar *gcal) -{ - g_message ("AUDIO NOTIFICATION!"); - /* FIXME */ -} - -struct trigger_alarm_closure { - GnomeCalendar *gcal; - char *uid; - CalComponentAlarmAction type; - time_t occur; -}; - -/* Callback function used when an alarm is triggered */ -static void -trigger_alarm_cb (gpointer alarm_id, time_t trigger, gpointer data) -{ - struct trigger_alarm_closure *c; - CalComponent *comp; - CalClientGetStatus status; - const char *uid; - ObjectAlarms *oa; - GList *l; - - c = data; - - /* Fetch the object */ - - status = cal_client_get_object (c->gcal->client, c->uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Go on */ - break; - case CAL_CLIENT_GET_SYNTAX_ERROR: - case CAL_CLIENT_GET_NOT_FOUND: - g_message ("trigger_alarm_cb(): syntax error in fetched object"); - return; - } - - g_assert (comp != NULL); - - /* Present notification */ - - switch (c->type) { - case CAL_COMPONENT_ALARM_EMAIL: -#if 0 - g_assert (ico->malarm.enabled); - mail_notification (ico->malarm.data, ico->summary, c->occur); -#endif - break; - - case CAL_COMPONENT_ALARM_PROCEDURE: -#if 0 - g_assert (ico->palarm.enabled); - program_notification (ico->palarm.data, FALSE); -#endif - break; - - case CAL_COMPONENT_ALARM_DISPLAY: -#if 0 - g_assert (ico->dalarm.enabled); -#endif - display_notification (trigger, c->occur, comp, c->gcal); - break; - - case CAL_COMPONENT_ALARM_AUDIO: -#if 0 - g_assert (ico->aalarm.enabled); -#endif - audio_notification (trigger, c->occur, comp, c->gcal); - break; - - default: - break; - } - - /* Remove the alarm from the hash table */ - cal_component_get_uid (comp, &uid); - oa = g_hash_table_lookup (c->gcal->alarms, uid); - g_assert (oa != NULL); - - l = g_list_find (oa->alarm_ids, alarm_id); - g_assert (l != NULL); - - oa->alarm_ids = g_list_remove_link (oa->alarm_ids, l); - g_list_free_1 (l); - - if (!oa->alarm_ids) { - g_hash_table_remove (c->gcal->alarms, uid); - g_free (oa->uid); - g_free (oa); - } - - gtk_object_unref (GTK_OBJECT (comp)); -} - -/* Frees a struct trigger_alarm_closure */ -static void -free_trigger_alarm_closure (gpointer data) -{ - struct trigger_alarm_closure *c; - - c = data; - g_free (c->uid); - g_free (c); -} - -/* Queues the specified alarm */ -static void -setup_alarm (GnomeCalendar *cal, CalAlarmInstance *ai) -{ - struct trigger_alarm_closure *c; - gpointer alarm; - ObjectAlarms *oa; - - c = g_new (struct trigger_alarm_closure, 1); - c->gcal = cal; - c->uid = g_strdup (ai->uid); -#if 0 - c->type = ai->type; -#endif - c->occur = ai->occur; - - alarm = alarm_add (ai->trigger, trigger_alarm_cb, c, free_trigger_alarm_closure); - if (!alarm) { - g_message ("setup_alarm(): Could not set up alarm"); - g_free (c->uid); - g_free (c); - return; - } - - oa = g_hash_table_lookup (cal->alarms, ai->uid); - if (oa) - oa->alarm_ids = g_list_prepend (oa->alarm_ids, alarm); - else { - oa = g_new (ObjectAlarms, 1); - oa->uid = g_strdup (ai->uid); - oa->alarm_ids = g_list_prepend (NULL, alarm); - - g_hash_table_insert (cal->alarms, oa->uid, oa); - } -} - -static void load_alarms (GnomeCalendar *cal); - -/* Called nightly to refresh the day's alarms */ -static void -midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data) -{ - GnomeCalendar *cal; - - cal = GNOME_CALENDAR (data); - cal->midnight_alarm_refresh_id = NULL; - - load_alarms (cal); -} - -/* Loads and queues the alarms from the current time up to midnight. */ -static void -load_alarms (GnomeCalendar *gcal) -{ - time_t now; - time_t end_of_day; - GList *alarms, *l; - - now = time (NULL); - end_of_day = time_day_end (now); - - /* Queue alarms */ - - alarms = cal_client_get_alarms_in_range (gcal->client, now, end_of_day); - - for (l = alarms; l; l = l->next) - setup_alarm (gcal, l->data); - - cal_alarm_instance_list_free (alarms); - - /* Queue the midnight alarm refresh */ - - gcal->midnight_alarm_refresh_id = alarm_add (end_of_day, midnight_refresh_cb, gcal, NULL); - if (!gcal->midnight_alarm_refresh_id) { - g_message ("load_alarms(): Could not set up the midnight refresh alarm!"); - /* FIXME: what to do? */ - } -} - -/* This tells all components to reload all calendar objects. */ -static void -gnome_calendar_update_all (GnomeCalendar *cal) -{ - load_alarms (cal); - - e_day_view_update_all_events (E_DAY_VIEW (cal->day_view)); - e_day_view_update_all_events (E_DAY_VIEW (cal->work_week_view)); - e_week_view_update_all_events (E_WEEK_VIEW (cal->week_view)); - e_week_view_update_all_events (E_WEEK_VIEW (cal->month_view)); - -#if 0 - gncal_todo_update (GNCAL_TODO (cal->todo), NULL, TRUE); -#endif - gnome_calendar_tag_calendar (cal, cal->gtk_calendar); -} - -/* Removes any queued alarms for the specified UID */ -static void -remove_alarms_for_object (GnomeCalendar *gcal, const char *uid) -{ - ObjectAlarms *oa; - GList *l; - - oa = g_hash_table_lookup (gcal->alarms, uid); - if (!oa) - return; - - for (l = oa->alarm_ids; l; l = l->next) { - gpointer alarm_id; - - alarm_id = l->data; - alarm_remove (alarm_id); - } - - g_hash_table_remove (gcal->alarms, uid); - - g_free (oa->uid); - g_list_free (oa->alarm_ids); - g_free (oa); -} - -/* Adds today's alarms for the specified object */ -static void -add_alarms_for_object (GnomeCalendar *gcal, const char *uid) -{ - GList *alarms; - gboolean result; - time_t now, end_of_day; - GList *l; - - now = time (NULL); - end_of_day = time_day_end (now); - - result = cal_client_get_alarms_for_object (gcal->client, uid, now, end_of_day, &alarms); - if (!result) { - /* FIXME: should we warn here, or is it OK if the object - * disappeared in the meantime? - */ - return; - } - - for (l = alarms; l; l = l->next) - setup_alarm (gcal, l->data); - - cal_alarm_instance_list_free (alarms); -} - -static void -gnome_calendar_object_updated_cb (GtkWidget *cal_client, - const char *uid, - GnomeCalendar *gcal) -{ - g_message ("gnome-cal: got object changed_cb, uid='%s'", - uid?uid:"<NULL>"); - - remove_alarms_for_object (gcal, uid); - add_alarms_for_object (gcal, uid); - - /* FIXME: do we really want each view to reload the event itself? - Maybe we should keep track of events globally, maybe with ref - counts. We also need to sort out where they get freed. */ - e_day_view_update_event (E_DAY_VIEW (gcal->day_view), uid); - e_day_view_update_event (E_DAY_VIEW (gcal->work_week_view), uid); - e_week_view_update_event (E_WEEK_VIEW (gcal->week_view), uid); - e_week_view_update_event (E_WEEK_VIEW (gcal->month_view), uid); - -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, TRUE); -#endif - gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); -} - - -static void -gnome_calendar_object_removed_cb (GtkWidget *cal_client, - const char *uid, - GnomeCalendar *gcal) -{ - g_message ("gnome-cal: got object removed _cb, uid='%s'", - uid?uid:"<NULL>"); - - remove_alarms_for_object (gcal, uid); - - e_day_view_remove_event (E_DAY_VIEW (gcal->day_view), uid); - e_day_view_remove_event (E_DAY_VIEW (gcal->work_week_view), uid); - e_week_view_remove_event (E_WEEK_VIEW (gcal->week_view), uid); - e_week_view_remove_event (E_WEEK_VIEW (gcal->month_view), uid); - -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, CHANGE_ALL); -#endif - gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); -} - - -GtkWidget * -gnome_calendar_new (char *title) -{ - GtkWidget *retval; - GnomeCalendar *gcal; - - retval = gtk_type_new (gnome_calendar_get_type ()); - - gcal = GNOME_CALENDAR (retval); - - gcal->selection_start_time = time_day_begin (time (NULL)); - gcal->selection_end_time = time_add_day (gcal->selection_start_time, 1); - gcal->client = cal_client_new (); - - setup_widgets (gcal); - - gnome_calendar_set_view (gcal, "dayview"); - - gtk_signal_connect (GTK_OBJECT (gcal->client), "obj_updated", - gnome_calendar_object_updated_cb, gcal); - gtk_signal_connect (GTK_OBJECT (gcal->client), "obj_removed", - gnome_calendar_object_removed_cb, gcal); - - return retval; -} - -typedef struct -{ - GnomeCalendar *gcal; - char *uri; - GnomeCalendarOpenMode gcom; - guint signal_handle; -} load_or_create_data; - - -static void -gnome_calendar_load_cb (CalClient *cal_client, - CalClientLoadStatus status, - load_or_create_data *locd) -{ - g_return_if_fail (locd); - g_return_if_fail (GNOME_IS_CALENDAR (locd->gcal)); - - switch (status) { - case CAL_CLIENT_LOAD_SUCCESS: - gnome_calendar_update_all (locd->gcal); - g_message ("gnome_calendar_load_cb: success"); - break; - - case CAL_CLIENT_LOAD_ERROR: - g_message ("gnome_calendar_load_cb: load error"); - if (locd->gcom == CALENDAR_OPEN_OR_CREATE) { - g_message ("gnome_calendar_load_cb: trying create..."); - /* FIXME: connect to the cal_loaded signal of the - * CalClient and get theasynchronous notification - * properly! */ - /*gtk_signal_connect (GTK_OBJECT (gcal->client), - "cal_loaded", - gnome_calendar_create_cb, gcal);*/ - - gtk_signal_disconnect (GTK_OBJECT (locd->gcal->client), - locd->signal_handle); - - cal_client_create_calendar (locd->gcal->client, - locd->uri); - gnome_calendar_update_all (locd->gcal); - } - break; - - case CAL_CLIENT_LOAD_IN_USE: - /* FIXME: what to do? */ - g_message ("gnome_calendar_load_cb: in use"); - break; - - case CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED: - /* FIXME: what to do? */ - g_message ("gnome_calendar_load_cb(): method not supported"); - break; - - default: - g_message ("gnome_calendar_load_cb(): unhandled result code %d!", (int) status); - g_assert_not_reached (); - } - - g_free (locd->uri); - g_free (locd); -} - - -int -gnome_calendar_open (GnomeCalendar *gcal, - char *file, - GnomeCalendarOpenMode gcom) -{ - load_or_create_data *locd; - - g_return_val_if_fail (gcal != NULL, 0); - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0); - g_return_val_if_fail (file != NULL, 0); - - locd = g_new0 (load_or_create_data, 1); - locd->gcal = gcal; - locd->uri = g_strdup (file); - locd->gcom = gcom; - - locd->signal_handle = gtk_signal_connect (GTK_OBJECT (gcal->client), - "cal_loaded", - gnome_calendar_load_cb, - locd); - - if (cal_client_load_calendar (gcal->client, file) == FALSE){ - g_message ("Error loading calendar: %s", file); - return 0; - } - - return 1; -} - -static void -stop_beeping (GtkObject* object, gpointer data) -{ - guint timer_tag, beep_tag; - timer_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "timer_tag")); - beep_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "beep_tag")); - - if (beep_tag > 0) { - gtk_timeout_remove (beep_tag); - gtk_object_set_data (object, "beep_tag", GINT_TO_POINTER (0)); - } - if (timer_tag > 0) { - gtk_timeout_remove (timer_tag); - gtk_object_set_data (object, "timer_tag", GINT_TO_POINTER (0)); - } -} - -static gint -start_beeping (gpointer data) -{ - gdk_beep (); - - return TRUE; -} - -static gint -timeout_beep (gpointer data) -{ - stop_beeping (data, NULL); - return FALSE; -} - -#if 0 - -void -calendar_notify (time_t activation_time, CalendarAlarm *which, void *data) -{ - iCalObject *ico = data; - guint beep_tag, timer_tag; - int ret; - gchar* snooze_button = (enable_snooze ? _("Snooze") : NULL); - time_t now, diff; - - if (&ico->aalarm == which){ - time_t app = ico->aalarm.trigger + ico->aalarm.offset; - GtkWidget *w; - char *msg; - - msg = g_strconcat (_("Reminder of your appointment at "), - ctime (&app), "`", - ico->summary, "'", NULL); - - /* Idea: we need Snooze option :-) */ - w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, _("Ok"), snooze_button, NULL); - beep_tag = gtk_timeout_add (1000, start_beeping, NULL); - if (enable_aalarm_timeout) - timer_tag = gtk_timeout_add (audio_alarm_timeout*1000, - timeout_beep, w); - else - timer_tag = 0; - gtk_object_set_data (GTK_OBJECT (w), "timer_tag", - GINT_TO_POINTER (timer_tag)); - gtk_object_set_data (GTK_OBJECT (w), "beep_tag", - GINT_TO_POINTER (beep_tag)); - gtk_widget_ref (w); - gtk_window_set_modal (GTK_WINDOW (w), FALSE); - ret = gnome_dialog_run (GNOME_DIALOG (w)); - switch (ret) { - case 1: - stop_beeping (GTK_OBJECT (w), NULL); - now = time (NULL); - diff = now - which->trigger; - which->trigger = which->trigger + diff + snooze_secs; - which->offset = which->offset - diff - snooze_secs; - alarm_add (which, &calendar_notify, data); - break; - default: - stop_beeping (GTK_OBJECT (w), NULL); - break; - } - - gtk_widget_unref (w); - return; - } - - if (&ico->palarm == which){ - execute (ico->palarm.data, 0); - return; - } - - if (&ico->malarm == which){ - time_t app = ico->malarm.trigger + ico->malarm.offset; - - mail_notify (ico->malarm.data, ico->summary, app); - return; - } - - if (&ico->dalarm == which){ - time_t app = ico->dalarm.trigger + ico->dalarm.offset; - GtkWidget *w; - char *msg; - - if (beep_on_display) - gdk_beep (); - msg = g_strconcat (_("Reminder of your appointment at "), - ctime (&app), "`", - ico->summary, "'", NULL); - w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, - _("Ok"), snooze_button, NULL); - gtk_window_set_modal (GTK_WINDOW (w), FALSE); - ret = gnome_dialog_run (GNOME_DIALOG (w)); - switch (ret) { - case 1: - now = time (NULL); - diff = now - which->trigger; - which->trigger = which->trigger + diff + snooze_secs; - which->offset = which->offset - diff - snooze_secs; - alarm_add (which, &calendar_notify, data); - break; - default: - break; - } - - return; - } -} - -#endif - -/* Marks the specified range in a GtkCalendar */ -static void -mark_gtk_calendar_day (GtkCalendar *calendar, time_t start, time_t end) -{ - time_t t; - - t = time_day_begin (start); - - do { - struct tm tm; - - tm = *localtime (&t); - gtk_calendar_mark_day (calendar, tm.tm_mday); - - t = time_day_end (t); - } while (t < end); -} - -/* - * Tags the dates with appointments in a GtkCalendar based on the - * GnomeCalendar contents - */ -struct calendar_tag_closure -{ - GtkCalendar *gtk_cal; - time_t month_begin; - time_t month_end; -}; - -static gboolean -gnome_calendar_tag_calendar_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - struct calendar_tag_closure *c = data; - - start = MAX (istart, c->month_begin); - end = MIN (iend, c->month_end); - - if (start > end) - return TRUE; - - /* Clip the occurrence's start and end times to the month's limits */ - mark_gtk_calendar_day (c->gtk_cal, start, end); - - return TRUE; -} - -void -gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal) -{ - struct calendar_tag_closure c; - - g_return_if_fail (cal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (cal)); - g_return_if_fail (gtk_cal != NULL); - g_return_if_fail (GTK_IS_CALENDAR (gtk_cal)); - - /* If the GtkCalendar isn't visible, we just return. */ - if (!GTK_WIDGET_VISIBLE (cal->gtk_calendar)) - return; - - c.gtk_cal = gtk_cal; - - c.month_begin = time_from_day (gtk_cal->year, gtk_cal->month, 1); - if (c.month_begin == -1) { - g_message ("gnome_calendar_tag_calendar(): Generated invalid month begin!"); - return; - } - - c.month_end = time_month_end (c.month_begin); - if (c.month_end == -1) { - g_message ("gnome_calendar_tag_calendar(): Generated invalid month end!"); - return; - } - - gtk_calendar_freeze (gtk_cal); - gtk_calendar_clear_marks (gtk_cal); - - cal_client_generate_instances (cal->client, CALOBJ_TYPE_EVENT, - c.month_begin, c.month_end, - gnome_calendar_tag_calendar_cb, &c); - - gtk_calendar_thaw (gtk_cal); -} - -/* This is called when the day begin & end times, the AM/PM flag, or the - week_starts_on_monday flags are changed. - FIXME: Which of these options do we want the new views to support? */ -void -gnome_calendar_time_format_changed (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gtk_calendar_display_options (gcal->gtk_calendar, - (week_starts_on_monday - ? (gcal->gtk_calendar->display_flags - | GTK_CALENDAR_WEEK_START_MONDAY) - : (gcal->gtk_calendar->display_flags - & ~GTK_CALENDAR_WEEK_START_MONDAY))); -} - -/* This is called when any of the color settings are changed. - FIXME: Need to update for the new views. */ -void -gnome_calendar_colors_changed (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - todo_style_changed = 1; -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, 0); -#endif -} - -void -gnome_calendar_todo_properties_changed (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - todo_style_changed = 1; -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, 0); -#endif -} - - -void -gnome_calendar_set_selected_time_range (GnomeCalendar *gcal, - time_t start_time, - time_t end_time) -{ - gcal->selection_start_time = start_time; - gcal->selection_end_time = end_time; - - gnome_calendar_update_gtk_calendar (gcal); -} - -/* Callback used when an event editor finishes editing an object */ -static void -ical_object_released_cb (EventEditor *ee, const char *uid, gpointer data) -{ - GnomeCalendar *gcal; - gboolean result; - gpointer orig_key; - char *orig_uid; - - gcal = GNOME_CALENDAR (data); - - result = g_hash_table_lookup_extended (gcal->object_editor_hash, uid, &orig_key, NULL); - g_assert (result != FALSE); - - orig_uid = orig_key; - - g_hash_table_remove (gcal->object_editor_hash, orig_uid); - g_free (orig_uid); -} - -/* Callback used when an event editor dialog is closed */ -static void -editor_closed_cb (EventEditor *ee, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ee)); -} - -/* Callback used when an event editor requests that an object be saved */ -static void -save_ical_object_cb (EventEditor *ee, CalComponent *comp, gpointer data) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - if (!cal_client_update_object (gcal->client, comp)) - g_message ("save_ical_object_cb(): Could not update the object!"); -} - -void -gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp) -{ - EventEditor *ee; - const char *uid; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (comp != NULL); - - cal_component_get_uid (comp, &uid); - - ee = g_hash_table_lookup (gcal->object_editor_hash, uid); - if (!ee) { - ee = event_editor_new (); - if (!ee) { - g_message ("gnome_calendar_edit_object(): Could not create the event editor"); - return; - } - - /* FIXME: what to do when an event editor wants to switch - * objects? We would need to know about it as well. - */ - - g_hash_table_insert (gcal->object_editor_hash, g_strdup (uid), ee); - gtk_signal_connect (GTK_OBJECT (ee), "ical_object_released", - GTK_SIGNAL_FUNC (ical_object_released_cb), gcal); - - gtk_signal_connect (GTK_OBJECT (ee), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), gcal); - - gtk_signal_connect (GTK_OBJECT (ee), "save_ical_object", - GTK_SIGNAL_FUNC (save_ical_object_cb), gcal); - - event_editor_set_ical_object (EVENT_EDITOR (ee), comp); - } - - event_editor_focus (ee); -} - -/** - * gnome_calendar_new_appointment: - * @gcal: An Evolution calendar. - * - * Opens an event editor dialog for a new appointment. The appointment's start - * and end times are set to the currently selected time range in the calendar - * views. - **/ -void -gnome_calendar_new_appointment (GnomeCalendar *gcal) -{ - CalComponent *comp; - time_t dtstart, dtend; - CalComponentDateTime dt; - struct icaltimetype itt; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_get_current_time_range (gcal, &dtstart, &dtend); - dt.value = &itt; - dt.tzid = NULL; - - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - - itt = icaltimetype_from_timet (dtstart, 0); - cal_component_set_dtstart (comp, &dt); - - itt = icaltimetype_from_timet (dtend, 0); - cal_component_set_dtend (comp, &dt); - - gnome_calendar_edit_object (gcal, comp); - gtk_object_unref (GTK_OBJECT (comp)); - -} - -/* Returns the selected time range for the current view. Note that this may be - different from the fields in the GnomeCalendar, since the view may clip - this or choose a more appropriate time. */ -void -gnome_calendar_get_current_time_range (GnomeCalendar *gcal, - time_t *start_time, - time_t *end_time) -{ - GtkWidget *page; - - page = get_current_page (gcal); - - if (page == gcal->day_view - || page == gcal->work_week_view) - e_day_view_get_selected_time_range (E_DAY_VIEW (page), - start_time, end_time); - else if (page == gcal->week_view - || page == gcal->month_view) - e_week_view_get_selected_time_range (E_WEEK_VIEW (page), - start_time, end_time); - else { - g_message ("My penguin is gone!"); - g_assert_not_reached (); - } -} - - - -/* This updates the month shown and the day selected in the calendar, if - necessary. */ -static void -gnome_calendar_update_gtk_calendar (GnomeCalendar *gcal) -{ - GDate date; - guint current_year, current_month, current_day; - guint new_year, new_month, new_day; - gboolean set_day = FALSE; - - /* If the GtkCalendar isn't visible, we just return. */ - if (!GTK_WIDGET_VISIBLE (gcal->gtk_calendar)) - return; - - gtk_calendar_get_date (gcal->gtk_calendar, ¤t_year, - ¤t_month, ¤t_day); - - g_date_clear (&date, 1); - g_date_set_time (&date, gcal->selection_start_time); - new_year = g_date_year (&date); - new_month = g_date_month (&date) - 1; - new_day = g_date_day (&date); - - /* Block the "day_selected" signal while we update the calendar. */ - gtk_signal_handler_block (GTK_OBJECT (gcal->gtk_calendar), - gcal->day_selected_id); - - /* If the year & month don't match, update it. */ - if (new_year != current_year || new_month != current_month) { - /* FIXME: GtkCalendar bug workaround. If we select a month - which has less days than the currently selected day, it - causes a problem next time we set the day. */ - if (current_day > 28) { - gtk_calendar_select_day (gcal->gtk_calendar, 28); - set_day = TRUE; - } - gtk_calendar_select_month (gcal->gtk_calendar, new_month, - new_year); - } - - /* If the day doesn't match, update it. */ - if (new_day != current_day || set_day) - gtk_calendar_select_day (gcal->gtk_calendar, new_day); - - gtk_signal_handler_unblock (GTK_OBJECT (gcal->gtk_calendar), - gcal->day_selected_id); -} - -static void -gnome_calendar_on_day_selected (GtkCalendar *calendar, - GnomeCalendar *gcal) -{ - gint y, m, d; - struct tm tm; - - gtk_calendar_get_date (calendar, &y, &m, &d); - - tm.tm_year = y - 1900; - tm.tm_mon = m; - tm.tm_mday = d; - tm.tm_hour = 5; /* for daylight savings time fix */ - tm.tm_min = 0; - tm.tm_sec = 0; - - gnome_calendar_goto (gcal, mktime (&tm)); -} - - -static void -gnome_calendar_on_month_changed (GtkCalendar *calendar, - GnomeCalendar *gcal) -{ - gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); -} diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h deleted file mode 100644 index df087395e1..0000000000 --- a/calendar/gui/gnome-cal.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * GnomeCalendar widget - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: Miguel de Icaza (miguel@kernel.org) - * Federico Mena-Quintero <federico@helixcode.com> - */ - -#ifndef GNOME_CALENDAR_APP_H -#define GNOME_CALENDAR_APP_H - -#include <time.h> -#include <gtk/gtkcalendar.h> -#include <gtk/gtkvbox.h> -#include <libgnome/gnome-defs.h> -#include <bonobo.h> -#include <cal-client/cal-client.h> - -BEGIN_GNOME_DECLS - - - -#define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar) -#define GNOME_CALENDAR_CLASS(class) GTK_CHECK_CAST_CLASS(class, gnome_calendar_get_type(), GnomeCalendarClass) -#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type()) - -#define GNOME_CALENDAR_NUM_VIEWS 4 - -typedef struct { - GtkVBox vbox; - - CalClient *client; - - BonoboPropertyBag *properties; - BonoboControl *control; - - GHashTable *object_editor_hash; - - time_t selection_start_time; - time_t selection_end_time; - - GtkWidget *main_notebook; - GtkWidget *sub_notebook; - GtkWidget *hpane; - GtkCalendar *gtk_calendar; - GtkWidget *todo; - - GtkWidget *day_view; - GtkWidget *work_week_view; - GtkWidget *week_view; - GtkWidget *month_view; - - GtkWidget *view_toolbar_buttons[GNOME_CALENDAR_NUM_VIEWS]; - - void *event_editor; - - /* The signal handler id for our GtkCalendar "day_selected" handler. */ - guint day_selected_id; - - /* Alarm ID for the midnight refresh function */ - gpointer midnight_alarm_refresh_id; - - /* UID->alarms hash */ - GHashTable *alarms; -} GnomeCalendar; - -typedef struct { - GtkVBoxClass parent_class; -} GnomeCalendarClass; - - -typedef enum { - CALENDAR_OPEN, - CALENDAR_OPEN_OR_CREATE -} GnomeCalendarOpenMode; - -guint gnome_calendar_get_type (void); -GtkWidget *gnome_calendar_new (char *title); -int gnome_calendar_open (GnomeCalendar *gcal, - char *file, - GnomeCalendarOpenMode gcom); -/* -int gnome_calendar_create (GnomeCalendar *gcal, - char *file); -*/ -void gnome_calendar_next (GnomeCalendar *gcal); -void gnome_calendar_previous (GnomeCalendar *gcal); -void gnome_calendar_goto (GnomeCalendar *gcal, - time_t new_time); -void gnome_calendar_dayjump (GnomeCalendar *gcal, - time_t time); -/* Jumps to the current day */ -void gnome_calendar_goto_today (GnomeCalendar *gcal); -void gnome_calendar_tag_calendar (GnomeCalendar *cal, - GtkCalendar *gtk_cal); -char *gnome_calendar_get_current_view_name (GnomeCalendar *gcal); -void gnome_calendar_set_view (GnomeCalendar *gcal, - char *page_name); - -void gnome_calendar_set_selected_time_range (GnomeCalendar *gcal, - time_t start_time, - time_t end_time); - -void gnome_calendar_edit_object (GnomeCalendar *gcal, - CalComponent *comp); - -void gnome_calendar_new_appointment (GnomeCalendar *gcal); - -/* Returns the selected time range for the current view. Note that this may be - different from the fields in the GnomeCalendar, since the view may clip - this or choose a more appropriate time. */ -void gnome_calendar_get_current_time_range (GnomeCalendar *gcal, - time_t *start_time, - time_t *end_time); - - -/* Notifies the calendar that the time format has changed and it must update all its views */ -void gnome_calendar_time_format_changed (GnomeCalendar *gcal); - -/* Notifies the calendar that the todo list properties have changed and its time - * to update the views. - */ -void gnome_calendar_colors_changed (GnomeCalendar *gcal); - -/* Notifies the calendar that the todo list properties have changed and its time - * to update the views. - */ -void gnome_calendar_todo_properties_changed (GnomeCalendar *gcal); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/gnome-cal.html b/calendar/gui/gnome-cal.html deleted file mode 100644 index 5a7d0a537f..0000000000 --- a/calendar/gui/gnome-cal.html +++ /dev/null @@ -1,44 +0,0 @@ -<!-- Some simple instructions on how to use the help browser --> -<BODY> -<!-- <TITLE>GNOME Calendar Documentation</TITLE> --> -<H2> GNOME Calendar Documentation </H2> -<p> -The GNOME calendar program is the calendaring program of the GNOME -system. It uses the vCalendar standard for transfering calendar -information (and is also the on-disk format used). - -<p> - -<a name="cmdline"> -<h2>Command line options</h2> - -Several options are available on the command line, they are: -<ul> - <li><tt>--events</tt> Displays the events for the date - specified (or today, if no date is specified). - - <li><tt>--from DATE</tt> Define the beginning of the range for - the event display, or the startup day on the calenday views. - By default, the event will span the whole day specified in - DATE. - - <li><tt>--to DATE</tt> Define the range end for the event - display. If this is not specified, it will default to the end - of the day specified by the <tt>--from</tt> option. - - <li><tt>--file FILE</tt> Set the calendar to the FILE - specified on the command line. - - <li><tt>--todo</tt> Dumps the to-do values to standard output. -</ul> - -<p> - -DATE is interpreted as being in the local time- zone, unless a -specific timezone is specified. Examples of valid date specifications -include: "1 month ago", "2 hours ago", "400000 seconds ago", "last -year", "last Monday", "yesterday", "a fortnight ago", "3/31/92 -10:00:07 PST", "January 23, 1987 10:05pm", "22:00 GMT". - -</BODY> - diff --git a/calendar/gui/gnome-calendar-conduit.png b/calendar/gui/gnome-calendar-conduit.png Binary files differdeleted file mode 100644 index e867ba90b2..0000000000 --- a/calendar/gui/gnome-calendar-conduit.png +++ /dev/null diff --git a/calendar/gui/gnome-month-item.c b/calendar/gui/gnome-month-item.c deleted file mode 100644 index 58e393e4ee..0000000000 --- a/calendar/gui/gnome-month-item.c +++ /dev/null @@ -1,1246 +0,0 @@ -/* General-purpose monthly calendar canvas item for GNOME - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena <federico@nuclecu.unam.mx> - */ - -#include <config.h> -#include <math.h> -#include <time.h> -#include <gnome.h> -#include "gnome-month-item.h" - - -#define DEFAULT_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*" - - -/* Number of days in a month, for normal and leap years */ -static const int days_in_month[2][12] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -/* The weird month of September 1752, where 3 Sep through 13 Sep were eliminated due to the - * Gregorian reformation. - */ -static const int sept_1752[42] = { - 0, 0, 1, 2, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 -}; - -#define REFORMATION_DAY 639787 /* First day of the reformation, counted from 1 Jan 1 */ -#define MISSING_DAYS 11 /* They corrected out 11 days */ -#define THURSDAY 4 /* First day of reformation */ -#define SATURDAY 6 /* Offset value; 1 Jan 1 was a Saturday */ -#define SEPT_1752_START 2 /* Start day within month */ -#define SEPT_1752_END 20 /* End day within month */ - - -enum { - ARG_0, - ARG_YEAR, - ARG_MONTH, - ARG_X, - ARG_Y, - ARG_WIDTH, - ARG_HEIGHT, - ARG_ANCHOR, - ARG_HEAD_PADDING, - ARG_DAY_PADDING, - ARG_DAY_NAMES, - ARG_HEADING_HEIGHT, - ARG_HEADING_ANCHOR, - ARG_DAY_ANCHOR, - ARG_START_ON_MONDAY, - ARG_HEAD_FONT, - ARG_HEAD_FONTSET, - ARG_HEAD_FONT_GDK, - ARG_DAY_FONT, - ARG_DAY_FONTSET, - ARG_DAY_FONT_GDK, - ARG_HEAD_COLOR, - ARG_HEAD_COLOR_GDK, - ARG_OUTLINE_COLOR, - ARG_OUTLINE_COLOR_GDK, - ARG_DAY_BOX_COLOR, - ARG_DAY_BOX_COLOR_GDK, - ARG_DAY_COLOR, - ARG_DAY_COLOR_GDK -}; - - -static void gnome_month_item_class_init (GnomeMonthItemClass *class); -static void gnome_month_item_init (GnomeMonthItem *mitem); -static void gnome_month_item_destroy (GtkObject *object); -static void gnome_month_item_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gnome_month_item_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); - - - -static GnomeCanvasGroupClass *parent_class; - - -GtkType -gnome_month_item_get_type (void) -{ - static GtkType month_item_type = 0; - - if (!month_item_type) { - GtkTypeInfo month_item_info = { - "GnomeMonthItem", - sizeof (GnomeMonthItem), - sizeof (GnomeMonthItemClass), - (GtkClassInitFunc) gnome_month_item_class_init, - (GtkObjectInitFunc) gnome_month_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - month_item_type = gtk_type_unique (gnome_canvas_group_get_type (), &month_item_info); - } - - return month_item_type; -} - -static void -gnome_month_item_class_init (GnomeMonthItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("GnomeMonthItem::year", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_YEAR); - gtk_object_add_arg_type ("GnomeMonthItem::month", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_MONTH); - gtk_object_add_arg_type ("GnomeMonthItem::x", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X); - gtk_object_add_arg_type ("GnomeMonthItem::y", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y); - gtk_object_add_arg_type ("GnomeMonthItem::width", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("GnomeMonthItem::height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEIGHT); - gtk_object_add_arg_type ("GnomeMonthItem::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR); - gtk_object_add_arg_type ("GnomeMonthItem::heading_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEAD_PADDING); - gtk_object_add_arg_type ("GnomeMonthItem::day_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_DAY_PADDING); - gtk_object_add_arg_type ("GnomeMonthItem::day_names", GTK_TYPE_POINTER, GTK_ARG_WRITABLE, ARG_DAY_NAMES); - gtk_object_add_arg_type ("GnomeMonthItem::heading_height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEADING_HEIGHT); - gtk_object_add_arg_type ("GnomeMonthItem::heading_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_HEADING_ANCHOR); - gtk_object_add_arg_type ("GnomeMonthItem::day_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_DAY_ANCHOR); - gtk_object_add_arg_type ("GnomeMonthItem::start_on_monday", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_START_ON_MONDAY); - gtk_object_add_arg_type ("GnomeMonthItem::heading_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONT); - gtk_object_add_arg_type ("GnomeMonthItem::heading_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONTSET); - gtk_object_add_arg_type ("GnomeMonthItem::heading_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_HEAD_FONT_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::day_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONT); - gtk_object_add_arg_type ("GnomeMonthItem::day_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONTSET); - gtk_object_add_arg_type ("GnomeMonthItem::day_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_DAY_FONT_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::heading_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::heading_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_HEAD_COLOR_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::outline_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_OUTLINE_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::outline_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_OUTLINE_COLOR_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::day_box_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_BOX_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::day_box_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_BOX_COLOR_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::day_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::day_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_COLOR_GDK); - - object_class->destroy = gnome_month_item_destroy; - object_class->set_arg = gnome_month_item_set_arg; - object_class->get_arg = gnome_month_item_get_arg; -} - -/* Calculates the minimum heading height based on the heading font size and padding. It also - * calculates the minimum width of the month item based on the width of the headings. - */ -static void -check_heading_sizes (GnomeMonthItem *mitem) -{ - double m_height; - double m_width; - int width; - int max_width; - int i; - - /* Calculate minimum height */ - - m_height = mitem->head_font->ascent + mitem->head_font->descent + 2 * mitem->head_padding; - - if (mitem->head_height < m_height) - mitem->head_height = m_height; - - /* Go through each heading and remember the widest one */ - - max_width = 0; - - for (i = 0; i < 7; i++) { - width = gdk_string_width (mitem->head_font, mitem->day_names[i]); - if (max_width < width) - max_width = width; - } - - m_width = 7 * (max_width + 2 * mitem->head_padding); - - if (mitem->width < m_width) - mitem->width = m_width; -} - -/* Calculates the minimum width and height of the month item based on the day font size and padding. - * Assumes that the minimum heading height has already been computed. - */ -static void -check_day_sizes (GnomeMonthItem *mitem) -{ - double m_height; - double m_width; - int width; - int max_width; - char buf[100]; - int i; - - /* Calculate minimum height */ - - m_height = mitem->head_height + 6 * (mitem->day_font->ascent + mitem->day_font->descent + 2 * mitem->day_padding); - - if (mitem->height < m_height) - mitem->height = m_height; - - /* Calculate minimum width */ - - max_width = 0; - - for (i = 1; i < 32; i++) { - sprintf (buf, "%d", i); - width = gdk_string_width (mitem->day_font, buf); - if (max_width < width) - max_width = width; - } - - m_width = 7 * (max_width + 2 * mitem->day_padding); - - if (mitem->width < m_width) - mitem->width = m_width; -} - -/* Calculates the minimum size of the month item based on the font sizes and paddings. If the - * current size of the month item is smaller than the required minimum size, this function will - * change the size to the appropriate values. - */ -static void -check_sizes (GnomeMonthItem *mitem) -{ - check_heading_sizes (mitem); - check_day_sizes (mitem); -} - -/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */ -static void -reanchor (GnomeMonthItem *mitem) -{ - double x, y; - - x = mitem->x; - y = mitem->y; - - switch (mitem->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - x -= mitem->width / 2; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - x -= mitem->width; - break; - } - - switch (mitem->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - y -= mitem->height / 2; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - y -= mitem->height; - break; - } - - /* Explicitly use the canvas group class prefix since the month item class has x and y - * arguments as well. - */ - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "GnomeCanvasGroup::x", x, - "GnomeCanvasGroup::y", y, - NULL); -} - -/* Takes an anchor specification and the corners of a rectangle, and returns an anchored point with - * respect to that rectangle. - */ -static void -get_label_anchor (GtkAnchorType anchor, double x1, double y1, double x2, double y2, double *x, double *y) -{ - switch (anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - *x = x1; - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - *x = (x1 + x2) / 2.0; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - *x = x2; - break; - } - - switch (anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - *y = y1; - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - *y = (y1 + y2) / 2.0; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - *y = y2; - break; - } -} - -/* Resets the position of the day name headings in the calendar */ -static void -reshape_headings (GnomeMonthItem *mitem) -{ - double width; - int i; - double x, y; - - width = mitem->width / 7; - - for (i = 0; i < 7; i++) { - /* Group */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i], - "x", width * i, - "y", 0.0, - NULL); - - /* Box */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i], - "x1", 0.0, - "y1", 0.0, - "x2", width, - "y2", mitem->head_height, - NULL); - - /* Label */ - get_label_anchor (mitem->head_anchor, - mitem->head_padding, - mitem->head_padding, - width - mitem->head_padding, - mitem->head_height - mitem->head_padding, - &x, &y); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "x", x, - "y", y, - "anchor", mitem->head_anchor, - NULL); - } -} - -/* Resets the position of the days in the calendar */ -static void -reshape_days (GnomeMonthItem *mitem) -{ - double width, height; - double x, y; - int row, col; - int i; - - width = mitem->width / 7; - height = (mitem->height - mitem->head_height) / 6; - - i = 0; - - for (row = 0; row < 6; row++) - for (col = 0; col < 7; col++) { - /* Group */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i], - "x", width * col, - "y", mitem->head_height + height * row, - NULL); - - /* Box */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i], - "x1", 0.0, - "y1", 0.0, - "x2", width, - "y2", height, - NULL); - - /* Label */ - get_label_anchor (mitem->day_anchor, - mitem->day_padding, - mitem->day_padding, - width - mitem->day_padding, - height - mitem->day_padding, - &x, &y); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "x", x, - "y", y, - "anchor", mitem->day_anchor, - NULL); - - i++; - } -} - -/* Changes the positions and resizes the items in the calendar to match the new size of the - * calendar. - */ -static void -reshape (GnomeMonthItem *mitem) -{ - check_sizes (mitem); - reanchor (mitem); - reshape_headings (mitem); - reshape_days (mitem); -} - -/* Sets the font for all the day headings */ -static void -set_head_font (GnomeMonthItem *mitem) -{ - int i; - - for (i = 0; i < 7; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "font_gdk", mitem->head_font, - NULL); -} - -/* Sets the color for all the headings */ -static void -set_head_color (GnomeMonthItem *mitem) -{ - int i; - GdkColor outline; - GdkColor head; - - outline.pixel = mitem->outline_pixel; - head.pixel = mitem->head_pixel; - - for (i = 0; i < 7; i++) { - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i], - "fill_color_gdk", &outline, - NULL); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "fill_color_gdk", &head, - NULL); - } -} - -/* Creates the items for the day name headings */ -static void -create_headings (GnomeMonthItem *mitem) -{ - int i; - - /* Just create the items; they will be positioned and configured by a call to reshape() */ - - for (i = 0; i < 7; i++) { - /* Group */ - mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem), - gnome_canvas_group_get_type (), - NULL); - - /* Box */ - mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]), - gnome_canvas_rect_get_type (), - NULL); - - /* Label */ - mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]), - gnome_canvas_text_get_type (), - NULL); - } - - set_head_font (mitem); - set_head_color (mitem); -} - -/* Returns the number of leap years since year 1 up to (but not including) the specified year */ -static int -leap_years_up_to (int year) -{ - return (year / 4 /* trivial leapness */ - - ((year > 1700) ? (year / 100 - 17) : 0) /* minus centuries since 1700 */ - + ((year > 1600) ? ((year - 1600) / 400) : 0)); /* plus centuries since 1700 divisible by 400 */ -} - -/* Returns whether the specified year is a leap year */ -static int -is_leap_year (int year) -{ - if (year <= 1752) - return !(year % 4); - else - return (!(year % 4) && (year % 100)) || !(year % 400); -} - -/* Returns the 1-based day number within the year of the specified date */ -static int -day_in_year (int day, int month, int year) -{ - int is_leap, i; - - is_leap = is_leap_year (year); - - for (i = 0; i < month; i++) - day += days_in_month [is_leap][i]; - - return day; -} - -/* Returns the day of the week (zero-based, zero is Sunday) for the specified date. For the days - * that were removed on the Gregorian reformation, it returns Thursday. - */ -static int -day_in_week (int day, int month, int year) -{ - int n; - - n = (year - 1) * 365 + leap_years_up_to (year - 1) + day_in_year (day, month, year); - - if (n < REFORMATION_DAY) - return (n - 1 + SATURDAY) % 7; - - if (n >= (REFORMATION_DAY + MISSING_DAYS)) - return (n - 1 + SATURDAY - MISSING_DAYS) % 7; - - return THURSDAY; -} - -/* Fills the 42-element days array with the day numbers for the specified month. Slots outside the - * bounds of the month are filled with zeros. The starting and ending indexes of the days are - * returned in the start and end arguments. - */ -static void -build_month (int month, int year, int start_on_monday, int *days, int *start, int *end) -{ - int i; - int d_month, d_week; - - /* Note that months are zero-based, so September is month 8 */ - - if ((year == 1752) && (month == 8)) { - memcpy (days, sept_1752, 42 * sizeof (int)); - - if (start) - *start = SEPT_1752_START; - - if (end) - *end = SEPT_1752_END; - - return; - } - - for (i = 0; i < 42; i++) - days[i] = 0; - - d_month = days_in_month[is_leap_year (year)][month]; - d_week = day_in_week (1, month, year); - - if (start_on_monday) - d_week = (d_week + 6) % 7; - - for (i = 0; i < d_month; i++) - days[d_week + i] = i + 1; - - if (start) - *start = d_week; - - if (end) - *end = d_week + d_month - 1; -} - -/* Set the day numbers in the monthly calendar */ -static void -set_days (GnomeMonthItem *mitem) -{ - int i; - int start, end; - char buf[100]; - - build_month (mitem->month, mitem->year, mitem->start_on_monday, mitem->day_numbers, &start, &end); - - /* Clear days before start of month */ - - for (i = 0; i < start; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "text", NULL, - NULL); - - /* Set days of month */ - - for (; start <= end; start++, i++) { - sprintf (buf, "%d", mitem->day_numbers[start]); - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "text", buf, - NULL); - } - - /* Clear days after end of month */ - - for (; i < 42; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "text", NULL, - NULL); -} - -/* Sets the font for all the day numbers */ -static void -set_day_font (GnomeMonthItem *mitem) -{ - int i; - - for (i = 0; i < 42; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "font_gdk", mitem->day_font, - NULL); -} - -/* Sets the color for all the day items */ -static void -set_day_color (GnomeMonthItem *mitem) -{ - int i; - GdkColor outline; - GdkColor day_box; - GdkColor day; - - outline.pixel = mitem->outline_pixel; - day_box.pixel = mitem->day_box_pixel; - day.pixel = mitem->day_pixel; - - for (i = 0; i < 42; i++) { - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i], - "outline_color_gdk", &outline, - "fill_color_gdk", &day_box, - NULL); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "fill_color_gdk", &day, - NULL); - } -} - -/* Creates the items for the days */ -static void -create_days (GnomeMonthItem *mitem) -{ - int i; - - /* Just create the items; they will be positioned and configured by a call to reshape() */ - - for (i = 0; i < 42; i++) { - /* Group */ - mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem), - gnome_canvas_group_get_type (), - NULL); - - /* Box */ - mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]), - gnome_canvas_rect_get_type (), - NULL); - - /* Label */ - mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]), - gnome_canvas_text_get_type (), - NULL); - } - - set_day_font (mitem); - set_day_color (mitem); - set_days (mitem); -} - -/* Resets the text of the day name headings */ -static void -set_day_names (GnomeMonthItem *mitem) -{ - int i; - - for (i = 0; i < 7; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "text", mitem->day_names[mitem->start_on_monday ? ((i + 1) % 7) : i], - NULL); -} - -/* Creates all the canvas items that make up the calendar */ -static void -create_items (GnomeMonthItem *mitem) -{ - mitem->items = g_new (GnomeCanvasItem *, GNOME_MONTH_ITEM_LAST); - - create_headings (mitem); - create_days (mitem); - - /* Initialize by default to three-letter day names */ - - mitem->day_names[0] = g_strdup (_("Sun")); - mitem->day_names[1] = g_strdup (_("Mon")); - mitem->day_names[2] = g_strdup (_("Tue")); - mitem->day_names[3] = g_strdup (_("Wed")); - mitem->day_names[4] = g_strdup (_("Thu")); - mitem->day_names[5] = g_strdup (_("Fri")); - mitem->day_names[6] = g_strdup (_("Sat")); - - set_day_names (mitem); - reshape (mitem); -} - -static void -gnome_month_item_init (GnomeMonthItem *mitem) -{ - time_t t; - struct tm tm; - - /* Initialize to the current month by default */ - - t = time (NULL); - tm = *localtime (&t); - - mitem->year = tm.tm_year + 1900; - mitem->month = tm.tm_mon; - - mitem->x = 0.0; - mitem->y = 0.0; - mitem->width = 150.0; /* not unreasonable defaults, I hope */ - mitem->height = 100.0; - mitem->anchor = GTK_ANCHOR_NW; - mitem->head_padding = 0.0; - mitem->day_padding = 2.0; - mitem->head_height = 14.0; - mitem->head_anchor = GTK_ANCHOR_CENTER; - mitem->day_anchor = GTK_ANCHOR_CENTER; - - /* Load the default fonts */ - - mitem->head_font = gdk_font_load (DEFAULT_FONT); - if (!mitem->head_font) { - mitem->head_font = gdk_font_load ("fixed"); - g_assert (mitem->head_font != NULL); - } - - mitem->day_font = gdk_font_load (DEFAULT_FONT); - if (!mitem->day_font) { - mitem->day_font = gdk_font_load ("fixed"); - g_assert (mitem->day_font != NULL); - } -} - -GnomeCanvasItem * -gnome_month_item_new (GnomeCanvasGroup *parent) -{ - GnomeMonthItem *mitem; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (parent), NULL); - - mitem = GNOME_MONTH_ITEM (gnome_canvas_item_new (parent, - gnome_month_item_get_type (), - NULL)); - - gnome_month_item_construct (mitem); - - return GNOME_CANVAS_ITEM (mitem); -} - -void -gnome_month_item_construct (GnomeMonthItem *mitem) -{ - GdkColor color; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - - gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "#d6d6d6d6d6d6", &color); - mitem->head_pixel = color.pixel; - mitem->day_box_pixel = color.pixel; - - gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "black", &color); - mitem->outline_pixel = color.pixel; - mitem->day_pixel = color.pixel; - - create_items (mitem); -} - -static void -free_day_names (GnomeMonthItem *mitem) -{ - int i; - - if (mitem->day_names[0]) - for (i = 0; i < 7; i++) - g_free (mitem->day_names[i]); -} - -static void -gnome_month_item_destroy (GtkObject *object) -{ - GnomeMonthItem *mitem; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (object)); - - mitem = GNOME_MONTH_ITEM (object); - - free_day_names (mitem); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Sets the color of the specified pixel value to that of the specified argument, which must be in - * GdkColor format if format is TRUE, otherwise it must be in string format. - */ -static void -set_color_arg (GnomeMonthItem *mitem, gulong *pixel, GtkArg *arg, int gdk_format, int set_head, int set_day) -{ - GdkColor color; - - if (gdk_format) - *pixel = ((GdkColor *) GTK_VALUE_BOXED (*arg))->pixel; - else { - if (gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, GTK_VALUE_STRING (*arg), &color)) - *pixel = color.pixel; - else - *pixel = 0; - } - - if (set_head) - set_head_color (mitem); - - if (set_day) - set_day_color (mitem); -} - -static void -gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GnomeMonthItem *mitem; - char **day_names; - int i; - - mitem = GNOME_MONTH_ITEM (object); - - switch (arg_id) { - case ARG_YEAR: - mitem->year = GTK_VALUE_UINT (*arg); - set_days (mitem); - break; - - case ARG_MONTH: - mitem->month = GTK_VALUE_UINT (*arg); - set_days (mitem); - break; - - case ARG_X: - mitem->x = GTK_VALUE_DOUBLE (*arg); - reanchor (mitem); - break; - - case ARG_Y: - mitem->y = GTK_VALUE_DOUBLE (*arg); - reanchor (mitem); - break; - - case ARG_WIDTH: - mitem->width = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_HEIGHT: - mitem->height = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_ANCHOR: - mitem->anchor = GTK_VALUE_ENUM (*arg); - reanchor (mitem); - break; - - case ARG_HEAD_PADDING: - mitem->head_padding = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_DAY_PADDING: - mitem->day_padding = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_DAY_NAMES: - day_names = GTK_VALUE_POINTER (*arg); - - /* First, check that none of the names is null */ - - for (i = 0; i < 7; i++) - if (!day_names[i]) { - g_warning ("Day number %d was NULL; day names cannot be NULL!", i); - return; - } - - /* Set the new names */ - - free_day_names (mitem); - for (i = 0; i < 7; i++) - mitem->day_names[i] = g_strdup (day_names[i]); - - set_day_names (mitem); - reshape (mitem); - break; - - case ARG_HEADING_HEIGHT: - mitem->head_height = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_HEADING_ANCHOR: - mitem->head_anchor = GTK_VALUE_ENUM (*arg); - reshape (mitem); - break; - - case ARG_DAY_ANCHOR: - mitem->day_anchor = GTK_VALUE_ENUM (*arg); - reshape (mitem); - break; - - case ARG_START_ON_MONDAY: - mitem->start_on_monday = GTK_VALUE_BOOL (*arg); - set_day_names (mitem); - set_days (mitem); - break; - - case ARG_HEAD_FONT: - gdk_font_unref (mitem->head_font); - - mitem->head_font = gdk_font_load (GTK_VALUE_STRING (*arg)); - if (!mitem->head_font) { - mitem->head_font = gdk_font_load ("fixed"); - g_assert (mitem->head_font != NULL); - } - - set_head_font (mitem); - reshape (mitem); - break; - - case ARG_HEAD_FONTSET: - gdk_font_unref (mitem->head_font); - - mitem->head_font = gdk_fontset_load (GTK_VALUE_STRING (*arg)); - if (!mitem->head_font) { - mitem->head_font = - gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*"); - g_assert (mitem->head_font != NULL); - } - - set_head_font (mitem); - reshape (mitem); - break; - - case ARG_HEAD_FONT_GDK: - gdk_font_unref (mitem->head_font); - - mitem->head_font = GTK_VALUE_BOXED (*arg); - gdk_font_ref (mitem->head_font); - set_head_font (mitem); - reshape (mitem); - break; - - case ARG_DAY_FONT: - gdk_font_unref (mitem->day_font); - - mitem->day_font = gdk_font_load (GTK_VALUE_STRING (*arg)); - if (!mitem->day_font) { - mitem->day_font = gdk_font_load ("fixed"); - g_assert (mitem->day_font != NULL); - } - - set_day_font (mitem); - reshape (mitem); - break; - - case ARG_DAY_FONTSET: - gdk_font_unref (mitem->day_font); - - mitem->day_font = gdk_fontset_load (GTK_VALUE_STRING (*arg)); - if (!mitem->day_font) { - mitem->day_font = - gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*"); - g_assert (mitem->day_font != NULL); - } - - set_day_font (mitem); - reshape (mitem); - break; - - case ARG_DAY_FONT_GDK: - gdk_font_unref (mitem->day_font); - - mitem->day_font = GTK_VALUE_BOXED (*arg); - gdk_font_ref (mitem->day_font); - set_day_font (mitem); - reshape (mitem); - break; - - case ARG_HEAD_COLOR: - set_color_arg (mitem, &mitem->head_pixel, arg, FALSE, TRUE, FALSE); - break; - - case ARG_HEAD_COLOR_GDK: - set_color_arg (mitem, &mitem->head_pixel, arg, TRUE, TRUE, FALSE); - break; - - case ARG_OUTLINE_COLOR: - set_color_arg (mitem, &mitem->outline_pixel, arg, FALSE, TRUE, TRUE); - break; - - case ARG_OUTLINE_COLOR_GDK: - set_color_arg (mitem, &mitem->outline_pixel, arg, TRUE, TRUE, TRUE); - break; - - case ARG_DAY_BOX_COLOR: - set_color_arg (mitem, &mitem->day_box_pixel, arg, FALSE, FALSE, TRUE); - break; - - case ARG_DAY_BOX_COLOR_GDK: - set_color_arg (mitem, &mitem->day_box_pixel, arg, TRUE, FALSE, TRUE); - break; - - case ARG_DAY_COLOR: - set_color_arg (mitem, &mitem->day_pixel, arg, FALSE, FALSE, TRUE); - break; - - case ARG_DAY_COLOR_GDK: - set_color_arg (mitem, &mitem->day_pixel, arg, TRUE, FALSE, TRUE); - break; - - default: - break; - } -} - -/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified - * arg for returning it in the get_arg method. - */ -static void -get_color_arg (GnomeMonthItem *mitem, gulong pixel, GtkArg *arg) -{ - GdkColor *color; - - color = g_new (GdkColor, 1); - color->pixel = pixel; - gdk_color_context_query_color (GNOME_CANVAS_ITEM (mitem)->canvas->cc, color); - GTK_VALUE_BOXED (*arg) = color; -} - -static void -gnome_month_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GnomeMonthItem *mitem; - - mitem = GNOME_MONTH_ITEM (object); - - switch (arg_id) { - case ARG_YEAR: - GTK_VALUE_UINT (*arg) = mitem->year; - break; - - case ARG_MONTH: - GTK_VALUE_UINT (*arg) = mitem->month; - break; - - case ARG_X: - GTK_VALUE_DOUBLE (*arg) = mitem->x; - break; - - case ARG_Y: - GTK_VALUE_DOUBLE (*arg) = mitem->y; - break; - - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = mitem->width; - break; - - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = mitem->height; - break; - - case ARG_ANCHOR: - GTK_VALUE_ENUM (*arg) = mitem->anchor; - break; - - case ARG_HEAD_PADDING: - GTK_VALUE_DOUBLE (*arg) = mitem->head_padding; - break; - - case ARG_DAY_PADDING: - GTK_VALUE_DOUBLE (*arg) = mitem->day_padding; - break; - - case ARG_HEADING_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = mitem->head_height; - break; - - case ARG_HEADING_ANCHOR: - GTK_VALUE_ENUM (*arg) = mitem->head_anchor; - break; - - case ARG_DAY_ANCHOR: - GTK_VALUE_ENUM (*arg) = mitem->day_anchor; - break; - - case ARG_START_ON_MONDAY: - GTK_VALUE_BOOL (*arg) = mitem->start_on_monday; - break; - - case ARG_HEAD_FONT_GDK: - GTK_VALUE_BOXED (*arg) = mitem->head_font; - break; - - case ARG_DAY_FONT_GDK: - GTK_VALUE_BOXED (*arg) = mitem->day_font; - break; - - case ARG_HEAD_COLOR_GDK: - get_color_arg (mitem, mitem->head_pixel, arg); - break; - - case ARG_OUTLINE_COLOR_GDK: - get_color_arg (mitem, mitem->outline_pixel, arg); - break; - - case ARG_DAY_BOX_COLOR_GDK: - get_color_arg (mitem, mitem->day_box_pixel, arg); - break; - - case ARG_DAY_COLOR_GDK: - get_color_arg (mitem, mitem->day_pixel, arg); - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -GnomeCanvasItem * -gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num) -{ - g_return_val_if_fail (mitem != NULL, NULL); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), NULL); - - return mitem->items[child_num]; -} - -int -gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child) -{ - int i; - - g_return_val_if_fail (mitem != NULL, -1); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1); - g_return_val_if_fail (child != NULL, -1); - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (child), -1); - - for (i = 0; i < GNOME_MONTH_ITEM_LAST; i++) - if (mitem->items[i] == child) - return i; - - return -1; -} - -int -gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num) -{ - g_return_val_if_fail (mitem != NULL, 0); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), 0); - - if ((child_num >= GNOME_MONTH_ITEM_DAY_GROUP) && (child_num < GNOME_MONTH_ITEM_LAST)) { - child_num = (child_num - GNOME_MONTH_ITEM_DAY_GROUP) % 42; - return mitem->day_numbers[child_num]; - } else - return 0; -} - -int -gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num) -{ - int i; - - g_return_val_if_fail (mitem != NULL, -1); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1); - g_return_val_if_fail (day_num >= 1, -1); - - /* Find first day of month */ - - for (i = 0; mitem->day_numbers[i] == 0; i++) - ; - - /* Find the specified day */ - - for (; (mitem->day_numbers[i] != 0) && (i < 42); i++) - if (mitem->day_numbers[i] == day_num) - return i; - - /* Bail out */ - - return -1; -} diff --git a/calendar/gui/gnome-month-item.h b/calendar/gui/gnome-month-item.h deleted file mode 100644 index 0ec4fd484c..0000000000 --- a/calendar/gui/gnome-month-item.h +++ /dev/null @@ -1,165 +0,0 @@ -/* General-purpose monthly calendar canvas item for GNOME - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena <federico@nuclecu.unam.mx> - */ - -#ifndef GNOME_MONTH_ITEM_H -#define GNOME_MONTH_ITEM_H - -#include <libgnome/gnome-defs.h> -#include <gtk/gtkpacker.h> /* why the hell is GtkAnchorType here and not in gtkenums.h? */ -#include <libgnomeui/gnome-canvas.h> - - -BEGIN_GNOME_DECLS - - -/* These values are used to identify the canvas items that make up a complete GnomeMonthItem, which - * is made up of the following "pieces": - * - * Headings line: - * - 7 GnomeCanvasGroups: - * Each group contains one box (GnomeCanvasRectangle) and one label - * (GnomeCanvasText) - * - * Day slots: - * - 42 GnomeCanvasGroups: - * Each group contains one box (GnomeCanvasRectangle) and one label - * (GnomeCanvasText) - * - * The headings are organized from left to right. The day slots are organized as a table in - * row-major order. - * - * If you want to access the individual items of the GnomeMonthItem, you can use these numbers with - * the gnome_month_item_num2child() function. If you want to convert a number into the - * corresponding GnomeCanvasItem, you can use the gnome_month_item_child2num() function. - */ -typedef enum { - GNOME_MONTH_ITEM_HEAD_GROUP = 0, /* 7 groups for headings */ - GNOME_MONTH_ITEM_HEAD_BOX = 7, /* 7 boxes for headings */ - GNOME_MONTH_ITEM_HEAD_LABEL = 14, /* 7 labels for headings */ - GNOME_MONTH_ITEM_DAY_GROUP = 21, /* 42 groups for days */ - GNOME_MONTH_ITEM_DAY_BOX = 63, /* 42 boxes for days */ - GNOME_MONTH_ITEM_DAY_LABEL = 105, /* 42 labels for days */ - GNOME_MONTH_ITEM_LAST = 147 /* total number of items */ -} GnomeMonthItemChild; - -/* The MonthItem canvas item defines a simple monthly calendar. It is made out of a number of - * canvas items, which can be accessed using the functions provided. The monthly calendar is - * anchored with respect to a point. The following arguments are available: - * - * name type read/write description - * ------------------------------------------------------------------------------------------ - * year uint RW Full year (1-9999) - * month uint RW Number of month (0-11) - * x double RW X position of anchor point - * y double RW Y position of anchor point - * width double RW Width of calendar in canvas units - * height double RW Height of calendar in canvas units - * anchor GtkAnchorType RW Anchor side for calendar - * heading_padding double RW Padding inside heading boxes - * day_padding double RW Padding inside day boxes - * day_names char ** W Array of strings corresponding to the day names (sun-sat) - * heading_height double RW Height of headings bar in canvas units - * heading_anchor GtkAnchorType RW Anchor side for headings inside heading boxes - * day_anchor GtkAnchorType RW Anchor side for day numbers inside day boxes - * start_on_monday boolean RW Specifies whether the week starts on Monday or Sunday - * heading_font string W X logical font descriptor for the headings - * heading_fontset string W X logical fontset descriptor for the headings - * heading_font_gdk GdkFont * RW Pointer to GdkFont for the headings - * day_font string W X logical font descriptor for the day numbers - * day_fontset string W X logical fontset descriptor for the day numbers - * day_font_gdk GdkFont * RW Pointer to GdkFont for the day numbers - * heading_color string W X color specification for heading labels - * heading_color_gdk GdkColor * RW Pointer to an allocated GdkColor for heading labels - * outline_color string W X color specification for outline (lines and fill of heading boxes) - * outline_color_gdk GdkColor * RW Pointer to an allocated GdkColor for outline - * day_box_color string W X color specification for day boxes - * day_box_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day boxes - * day_color string W X color specification for day number labels - * day_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day number labels - */ - -#define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ()) -#define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem)) -#define GNOME_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_MONTH_ITEM, GnomeMonthItemClass)) -#define GNOME_IS_MONTH_ITEM(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_MONTH_ITEM)) -#define GNOME_IS_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_MONTH_ITEM)) - - -typedef struct _GnomeMonthItem GnomeMonthItem; -typedef struct _GnomeMonthItemClass GnomeMonthItemClass; - -struct _GnomeMonthItem { - GnomeCanvasGroup group; - - int year; /* Year to show (full, no two-digit crap) */ - int month; /* Month to show (0-11) */ - - double x, y; /* Position at anchor */ - double width, height; /* Size of calendar */ - GtkAnchorType anchor; /* Anchor side for calendar */ - - double head_padding; /* Padding to use between heading lines and text */ - double day_padding; /* Padding to use between day number lines and text */ - - char *day_names[7]; /* Names to use for the day labels, starting from Sunday */ - - double head_height; /* Height of the headings row */ - GtkAnchorType head_anchor; /* Anchor side for the heading labels */ - GtkAnchorType day_anchor; /* Anchor side for the day number labels */ - - GnomeCanvasItem **items; /* All the items that make up the calendar */ - int day_numbers[42]; /* The numbers of the days, as they are shown in the display */ - - GdkFont *head_font; /* Font for the headings */ - GdkFont *day_font; /* Font for the day numbers */ - - gulong head_pixel; /* Color for heading labels */ - gulong outline_pixel; /* Color for the outline (lines and heading boxes) */ - gulong day_box_pixel; /* Color for the day boxes */ - gulong day_pixel; /* Color for day number labels */ - - int start_on_monday : 1; /* Start the week on Monday? If false, then start from Sunday */ -}; - -struct _GnomeMonthItemClass { - GnomeCanvasGroupClass parent_class; -}; - - -/* Standard Gtk function */ -GtkType gnome_month_item_get_type (void); - -/* Creates a new month item with the specified group as parent */ -GnomeCanvasItem *gnome_month_item_new (GnomeCanvasGroup *parent); - -/* Constructor function useful for derived classes */ -void gnome_month_item_construct (GnomeMonthItem *mitem); - -/* Returns the child item defined by the child number (as specified on the GnomeMonthItemChild - * enumeration above). - */ -GnomeCanvasItem *gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num); - -/* Returns the number of the specified child item, as defined on the GnomeMonthItemChild enumeration - * above. If the specified object is not found, it returns -1. - */ -int gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child); - -/* Returns the number of the day relevant to the specified child item. Day numbers are 1-based. If - * the specified child is outside the range of displayed days, then it returns 0. - */ -int gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num); - -/* Returns the index (0-41) of the specified date within the table of days. If the day number is - * invalid for the current monthly calendar, then -1 is returned. - */ -int gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num); - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/gnomecal.gnorba b/calendar/gui/gnomecal.gnorba deleted file mode 100644 index 74df8ecf04..0000000000 --- a/calendar/gui/gnomecal.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[IDL:GNOME:Calendar:Repository:1.0] -type=factory -repo_id=IDL:Gnome/Calendar/Repository:1.0 -description=Calendar Repository -location_info=IDL:GNOME:Calendar:RepositoryLocator:1.0 - -[IDL:GNOME:Calendar:RepositoryLocator:1.0] -type=exe -repo_id=IDL:GNOME/GenericFactory:1.0 -description=Calendar Server -location_info=gnomecal diff --git a/calendar/gui/gnomecal.oafinfo b/calendar/gui/gnomecal.oafinfo deleted file mode 100644 index c4b91b9dd8..0000000000 --- a/calendar/gui/gnomecal.oafinfo +++ /dev/null @@ -1,27 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:IDL:GNOME:Calendar:Repository:1.0:56989bb6-65a1-430c-86a8-81bbe64bf7ab" - type="factory" - location="OAFIID:IDL:GNOME:Calendar:RepositoryLocator:1.0:83b25bb0-b68b-4c6b-86e7-c303e9897c21"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Gnome/Calendar/Repository:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Calendar Repository"/> -</oaf_server> - -<oaf_server iid="OAFIID:IDL:GNOME:Calendar:RepositoryLocator:1.0:83b25bb0-b68b-4c6b-86e7-c303e9897c21" - type="exe" - location="gnomecal"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Calendar Server"/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c deleted file mode 100644 index d6c69016a1..0000000000 --- a/calendar/gui/goto.c +++ /dev/null @@ -1,326 +0,0 @@ -/* Go to date dialog for gnomecal - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena <federico@nuclecu.unam.mx> - */ - -#include <config.h> -#include <gnome.h> -#include <cal-util/timeutil.h> -#include "gnome-cal.h" -#include "gnome-month-item.h" -#include "calendar-commands.h" -#include "mark.h" - - -static GtkWidget *goto_win; /* The goto dialog window */ -static GnomeMonthItem *month_item; /* The month item in the dialog */ -static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */ -static int current_index; /* The index of the day marked as current, or -1 if none */ - - -/* Updates the specified month item by marking it appropriately from the calendar the dialog refers - * to. Also marks the current day if appropriate. - */ -static void -update (void) -{ - GnomeCanvasItem *item; - time_t t; - struct tm tm; - - unmark_month_item (month_item); - mark_month_item (month_item, gnome_calendar); - - if (current_index != -1) { - item = gnome_month_item_num2child (month_item, - GNOME_MONTH_ITEM_DAY_LABEL + current_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG), - "fontset", NORMAL_DAY_FONTSET, - NULL); - current_index = -1; - } - - t = time (NULL); - tm = *localtime (&t); - - if (((tm.tm_year + 1900) == month_item->year) && (tm.tm_mon == month_item->month)) { - current_index = gnome_month_item_day2index (month_item, tm.tm_mday); - g_assert (current_index != -1); - - item = gnome_month_item_num2child (month_item, - GNOME_MONTH_ITEM_DAY_LABEL + current_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG), - "fontset", CURRENT_DAY_FONTSET, - NULL); - } -} - -/* Callback used when the year adjustment is changed */ -static void -year_changed (GtkAdjustment *adj, gpointer data) -{ - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "year", (int) adj->value, - NULL); - update (); -} - -/* Creates the year control with its adjustment */ -static GtkWidget * -create_year (int year) -{ - GtkWidget *hbox; - GtkAdjustment *adj; - GtkWidget *w; - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - - w = gtk_label_new (_("Year:")); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - adj = GTK_ADJUSTMENT (gtk_adjustment_new (year, 1900, 9999, 1, 10, 10)); - gtk_signal_connect (GTK_OBJECT (adj), "value_changed", - (GtkSignalFunc) year_changed, - NULL); - - w = gtk_spin_button_new (adj, 1.0, 0); - gtk_widget_set_usize (w, 60, 0); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - return hbox; -} - -/* Callback used when a month button is toggled */ -static void -month_toggled (GtkToggleButton *toggle, gpointer data) -{ - if (!toggle->active) - return; - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "month", GPOINTER_TO_INT (data), - NULL); - update (); -} - -/* Creates the months control */ -static GtkWidget * -create_months (int month) -{ - GtkWidget *table; - GtkWidget *w; - GSList *group; - int i, row, col; - struct tm tm; - char buf[100]; - - tm = *localtime (&gnome_calendar->selection_start_time); - - table = gtk_table_new (2, 6, TRUE); - - group = NULL; - - for (i = 0; i < 12; i++) { - row = i / 6; - col = i % 6; - - tm.tm_mon = i; - strftime (buf, 100, "%b", &tm); - - w = gtk_radio_button_new (group); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (w)); - gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (w), FALSE); - - gtk_container_add (GTK_CONTAINER (w), gtk_label_new (buf)); - - if (i == month) - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (w), TRUE); - - gtk_signal_connect (GTK_OBJECT (w), "toggled", - (GtkSignalFunc) month_toggled, - GINT_TO_POINTER (i)); - gtk_table_attach (GTK_TABLE (table), w, - col, col + 1, - row, row + 1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - gtk_widget_show_all (w); - } - - return table; -} - -/* Sets the scrolling region of the canvas to the allocation size */ -static void -set_scroll_region (GtkWidget *widget, GtkAllocation *allocation) -{ - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "width", (double) (allocation->width - 1), - "height", (double) (allocation->height - 1), - NULL); - - gnome_canvas_set_scroll_region (GNOME_CANVAS (widget), - 0, 0, - allocation->width, allocation->height); -} - -/* Event handler for day groups in the month item. A button press makes the calendar jump to the - * selected day and destroys the Go-to dialog box. - */ -static gint -day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) -{ - int child_num, day; - - child_num = gnome_month_item_child2num (month_item, item); - day = gnome_month_item_num2day (month_item, child_num); - - switch (event->type) { - case GDK_BUTTON_PRESS: - if ((event->button.button == 1) && (day != 0)) { - gnome_calendar_goto (gnome_calendar, - time_from_day (month_item->year, month_item->month, day)); - gtk_widget_destroy (goto_win); - } - break; - - default: - break; - } - - return FALSE; -} - -/* Creates the canvas with the month item for selecting days */ -static GtkWidget * -create_days (int day, int month, int year) -{ - GtkWidget *canvas; - int i; - GnomeCanvasItem *day_group; - - canvas = gnome_canvas_new (); - gtk_widget_set_usize (canvas, 150, 120); - - month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)))); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "month", month, - "year", year, - "start_on_monday", week_starts_on_monday, - NULL); - colorify_month_item (month_item, default_color_func, NULL); - month_item_prepare_prelight (month_item, default_color_func, NULL); - update (); - - /* Connect to size_allocate so that we can change the size of the month item and the - * scrolling region appropriately. - */ - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - (GtkSignalFunc) set_scroll_region, - NULL); - - /* Bind the day groups to our event handler */ - - for (i = 0; i < 42; i++) { - day_group = gnome_month_item_num2child (month_item, i + GNOME_MONTH_ITEM_DAY_GROUP); - gtk_signal_connect (GTK_OBJECT (day_group), "event", - (GtkSignalFunc) day_event, - NULL); - } - - return canvas; -} - -static void -goto_today (GtkWidget *widget, gpointer data) -{ - gnome_calendar_goto_today (gnome_calendar); - gtk_widget_destroy (goto_win); -} - -/* Creates a "goto date" dialog and runs it */ -void -goto_dialog (GnomeCalendar *gcal) -{ - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *w; - GtkWidget *days; - struct tm tm; - - gnome_calendar = gcal; - current_index = -1; - - tm = *localtime (&gnome_calendar->selection_start_time); - - goto_win = gnome_dialog_new (_("Go to date"), - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gnome_dialog_set_parent (GNOME_DIALOG (goto_win), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); - - - vbox = GNOME_DIALOG (goto_win)->vbox; - - /* Instructions */ - - w = gtk_label_new (_("Please select the date you want to go to.\n" - "When you click on a day, you will be taken\n" - "to that date.")); - gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Create month item before creating the year controls, since the - * latter ones need the month_item to be created. - */ - - days = create_days (tm.tm_mday, tm.tm_mon, tm.tm_year + 1900); - - /* Year */ - - w = create_year (tm.tm_year + 1900); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Month */ - - w = create_months (tm.tm_mon); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Days (canvas with month item) */ - - gtk_box_pack_start (GTK_BOX (vbox), days, TRUE, TRUE, 0); - gtk_widget_show (days); - - /* Today button */ - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - w = gtk_button_new_with_label (_("Go to today")); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) goto_today, - NULL); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Run! */ - - gtk_window_set_modal (GTK_WINDOW (goto_win), TRUE); - gnome_dialog_set_close (GNOME_DIALOG (goto_win), TRUE); - gnome_dialog_set_parent (GNOME_DIALOG (goto_win), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gnome_calendar)))); - gtk_widget_show (goto_win); -} diff --git a/calendar/gui/jump.xpm b/calendar/gui/jump.xpm deleted file mode 100644 index d974142d9a..0000000000 --- a/calendar/gui/jump.xpm +++ /dev/null @@ -1,14 +0,0 @@ -/* XPM */ -static char * jump_xpm[] = { -"16 8 3 1", -" c None", -". c #000000", -"+ c #FFFF00", -"................", -".++++++++++++++.", -".++++++++++++++.", -".++..++..++..++.", -".++..++..++..++.", -".++++++++++++++.", -".++++++++++++++.", -"................"}; diff --git a/calendar/gui/main.c b/calendar/gui/main.c deleted file mode 100644 index 6876fbd6b5..0000000000 --- a/calendar/gui/main.c +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* control-factory.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> -#include <glade/glade.h> -#include <bonobo.h> -#include <bonobo/bonobo-control.h> -#include <glade/glade.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - -#include <cal-util/timeutil.h> -#include <gui/alarm.h> -#include <gui/gnome-cal.h> -#include <gui/calendar-commands.h> -#include "component-factory.h" -#include "control-factory.h" - - -static void -init_bonobo (int *argc, char **argv) -{ -#ifdef USING_OAF - /* FIXME: VERSION instead of "0.0". */ - gnome_init_with_popt_table ("evolution-calendar", "0.0", - *argc, argv, oaf_popt_options, - 0, NULL); - oaf_init (*argc, argv); -#else - CORBA_Environment ev; - - CORBA_exception_init (&ev); - gnome_CORBA_init_with_popt_table ( - "evolution-calendar", "0.0", - argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - CORBA_exception_free (&ev); -#endif - - if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); -} - - -int -main (int argc, char **argv) -{ - init_bonobo (&argc, argv); - glade_gnome_init (); - alarm_init (); - e_cursors_init (); - - init_calendar (); - -#if 0 - //g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF); - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); -#endif - - control_factory_init (); - component_factory_init (); - - bonobo_main (); - fprintf (stderr, "main(): Out of bonobo_main(), we are dying cleanly. Have a nice day.\n"); - - return 0; -} diff --git a/calendar/gui/mark.c b/calendar/gui/mark.c deleted file mode 100644 index 383eca5196..0000000000 --- a/calendar/gui/mark.c +++ /dev/null @@ -1,297 +0,0 @@ -/* Evolution calendar - Functions to mark calendars - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <cal-util/timeutil.h> -#include "gnome-cal.h" -#include "calendar-commands.h" -#include "mark.h" - -/* Closure data */ -struct minfo -{ - GnomeMonthItem *mitem; - time_t start; - time_t end; -}; - - - -/* Frees the specified data when an object is destroyed */ -static void -free_data (GtkObject *object, gpointer data) -{ - g_free (data); -} - -/* If the array of "marked" attributes for the days in a a month item has not been created yet, this - * function creates the array and clears it. Otherwise, it just returns the existing array. - */ -static char * -get_attributes (GnomeMonthItem *mitem) -{ - char *attrs; - - attrs = gtk_object_get_data (GTK_OBJECT (mitem), "day_mark_attributes"); - - if (!attrs) { - attrs = g_new0 (char, 42); - gtk_object_set_data (GTK_OBJECT (mitem), "day_mark_attributes", attrs); - gtk_signal_connect (GTK_OBJECT (mitem), "destroy", - (GtkSignalFunc) free_data, - attrs); - } - - return attrs; -} - -void -colorify_month_item (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data) -{ - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail (func != NULL); - - unmark_month_item (mitem); - - /* We have to do this in several calls to gnome_canvas_item_set(), as color_spec_from_prop() - * returns a pointer to a static string -- and we need several values. - */ - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "heading_color", (* func) (COLOR_PROP_HEADING_COLOR, func_data), - NULL); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "outline_color", (* func) (COLOR_PROP_OUTLINE_COLOR, func_data), - NULL); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "day_box_color", (* func) (COLOR_PROP_EMPTY_DAY_BG, func_data), - NULL); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "day_color", (* func) (COLOR_PROP_DAY_FG, func_data), - NULL); -} - -/* In the month item, marks all the days that are touched by the specified time span. Assumes that - * the time span is completely contained within the month. The array of day attributes is modified - * accordingly. - */ -static void -mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end) -{ - struct tm tm; - int day_index; - - tm = *localtime (&start); - - for (; start <= end; start += 60 * 60 * 24) { - mktime (&tm); /* normalize the time */ - - /* Figure out the day index that corresponds to this time */ - - day_index = gnome_month_item_day2index (mitem, tm.tm_mday); - g_assert (day_index >= 0); - - /* Mark the day box */ - - mark_month_item_index (mitem, day_index, default_color_func, NULL); - - /* Next day */ - - tm.tm_mday++; - } -} - -static gboolean -mark_month_item_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - struct minfo *mi = (struct minfo *)data; - - mark_event_in_month (mi->mitem, MAX (istart, mi->start), MIN (iend, mi->end)); - - return TRUE; -} - -void -mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *gcal) -{ - struct minfo mi; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - mi.mitem = mitem; - mi.start = time_month_begin (time_from_day (mitem->year, mitem->month, 1)); - mi.end = time_month_end (mi.start); - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_EVENT, mi.start, mi.end, - mark_month_item_cb, &mi); -} - - -void -mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data) -{ - char *attrs; - GnomeCanvasItem *item; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail ((index >= 0) && (index < 42)); - g_return_if_fail (func != NULL); - - attrs = get_attributes (mitem); - - attrs[index] = TRUE; - - item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + index); - gnome_canvas_item_set (item, - "fill_color", (* func) (COLOR_PROP_MARK_DAY_BG, func_data), - NULL); -} - -void -unmark_month_item (GnomeMonthItem *mitem) -{ - int i; - char *attrs; - GnomeCanvasItem *item; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - - attrs = get_attributes (mitem); - - /* Find marked days and unmark them by turning off their marked attribute flag and changing - * the color. - */ - - for (i = 0; i < 42; i++) - if (attrs[i]) { - attrs[i] = FALSE; - - item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + i); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_EMPTY_DAY_BG), - NULL); - } -} - -/* Handles EnterNotify and LeaveNotify events from the month item's day groups, and performs - * appropriate prelighting. - */ -static gint -day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) -{ - GnomeMonthItem *mitem; - GnomeCanvasItem *box; - int child_num, day; - GetColorFunc func; - gpointer func_data; - char *color; - char *attrs; - - /* We only accept enters and leaves */ - - if (!((event->type == GDK_ENTER_NOTIFY) || (event->type == GDK_LEAVE_NOTIFY))) - return FALSE; - - /* Get index information */ - - mitem = GNOME_MONTH_ITEM (data); - child_num = gnome_month_item_child2num (mitem, item); - day = gnome_month_item_num2day (mitem, child_num); - - if (day == 0) - return FALSE; /* it was a day outside the month's range */ - - child_num -= GNOME_MONTH_ITEM_DAY_GROUP; - box = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + child_num); - - /* Get colors */ - - func = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_func"); - func_data = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_data"); - - /* Now actually set the proper color in the item */ - - switch (event->type) { - case GDK_ENTER_NOTIFY: - color = (* func) (COLOR_PROP_PRELIGHT_DAY_BG, func_data); - gnome_canvas_item_set (box, - "fill_color", color, - NULL); - break; - - case GDK_LEAVE_NOTIFY: - attrs = get_attributes (mitem); - color = (* func) (attrs[child_num] ? COLOR_PROP_MARK_DAY_BG : COLOR_PROP_EMPTY_DAY_BG, - func_data); - gnome_canvas_item_set (box, - "fill_color", color, - NULL); - break; - - default: - g_assert_not_reached (); - } - - return TRUE; -} - -void -month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data) -{ - GnomeCanvasItem *day_group; - int i; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail (func != NULL); - - /* Store the function in the object data */ - - gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_func", func); - gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_data", func_data); - - /* Connect the appropriate signals to perform prelighting */ - - for (i = 0; i < 42; i++) { - day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i); - gtk_signal_connect (GTK_OBJECT (day_group), "event", - (GtkSignalFunc) day_event, - mitem); - } -} - -char * -default_color_func (ColorProp propnum, gpointer data) -{ - return color_spec_from_prop (propnum); -} - - - diff --git a/calendar/gui/mark.h b/calendar/gui/mark.h deleted file mode 100644 index 76c82c580d..0000000000 --- a/calendar/gui/mark.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Evolution calendar - Functions to mark calendars - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef MARK_H -#define MARK_H - -/*#include "calendar.h"*/ -#include "gnome-month-item.h" - - - -/* These are the fonts used for the montly calendars */ - -#define HEADING_FONTSET "-adobe-helvetica-medium-r-*-*-14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-*-*-14-*-*-*-*-*-ksc5601.1987-0,*" -#define TITLE_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*" -#define DAY_HEADING_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*" -#define NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*" -#define CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*" -#define BIG_DAY_HEADING_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*" -#define BIG_NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*" -#define BIG_CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*" -#define EVENT_FONTSET "-adobe-helvetica-medium-r-*-*-10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*" - - -/* Functions of this type are used by the marking functions to fetch color specifications. Such - * a function must return a color spec based on the property passed to it. - */ -typedef char * (* GetColorFunc) (ColorProp propnum, gpointer data); - - -/* Sets the user-configured colors and font for a month item. It also tags the days as unmarked. */ -void colorify_month_item (GnomeMonthItem *month, GetColorFunc func, gpointer func_data); - -/* Takes a monthly calendar item and marks the days that have events - * scheduled for them in the specified calendar. It also highlights - * the current day. - */ -void mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *cal); - -/* Marks a day specified by index, not by day number */ -void mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data); - -/* Unmarks all the days in the specified month item */ -void unmark_month_item (GnomeMonthItem *mitem); - -/* Prepares a monthly calendar item to prelight when the mouse goes over the days. */ - -void month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data); - -/* This is the default prelight function you can use for most puposes. You can use NULL as the - * func_data. - */ -char *default_color_func (ColorProp prop_num, gpointer data); - - - -#endif diff --git a/calendar/gui/monthview.xpm b/calendar/gui/monthview.xpm deleted file mode 100644 index 1a1b1d936a..0000000000 --- a/calendar/gui/monthview.xpm +++ /dev/null @@ -1,46 +0,0 @@ -/* XPM */ -static char * monthview_xpm[] = { -"24 24 19 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #BABBCC", -"$ c #AAAFE2", -"% c #8B90C3", -"& c #E3E4F5", -"* c #A3A6C7", -"= c #5D66BA", -"- c #3945BB", -"; c #555FC5", -"> c #2E3BB1", -", c #727ACE", -"' c #C7CAEB", -") c #0010A8", -"! c #4550B5", -"~ c #1725AC", -"{ c #8E95D8", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++#$$%&+@+$*++@++. ", -" .++@+&=-;>,+@')!++@++. ", -" .@@@@%)%@%)@*~)!@@@@@. ", -" .++@++@'$=-+@+)!++@++. ", -" .++@++@{;>,+@+)!++@++. ", -" .@@@@@@@@%)@@@)!@@@@@. ", -" .++@+$)$+%)+@+)!++@++. ", -" .++@+'>,$=-+#$)>$+@++. ", -" .@@@@@#%%%#@#%%%%@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/gui/popup-menu.c b/calendar/gui/popup-menu.c deleted file mode 100644 index a90c38d490..0000000000 --- a/calendar/gui/popup-menu.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Popup menu utilities for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#include <config.h> -#include <gnome.h> -#include "popup-menu.h" -#include "../../e-util/e-gui-utils.h" - - -void -popup_menu (struct menu_item *items, int nitems, GdkEventButton *event) -{ - GtkWidget *menu; - GtkWidget *item; - int i; - - menu = gtk_menu_new (); - - /* Make sure the menu is destroyed when it disappears. */ - e_auto_kill_popup_menu_on_hide (GTK_MENU (menu)); - - for (i = 0; i < nitems; i++) { - if (items[i].text) { - item = gtk_menu_item_new_with_label (_(items[i].text)); - gtk_signal_connect (GTK_OBJECT (item), "activate", - items[i].callback, - items[i].data); - gtk_widget_set_sensitive (item, items[i].sensitive); - } else - item = gtk_menu_item_new (); - - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - } - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); -} diff --git a/calendar/gui/popup-menu.h b/calendar/gui/popup-menu.h deleted file mode 100644 index a4590dbb98..0000000000 --- a/calendar/gui/popup-menu.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Popup menu utilities for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#ifndef POPUP_MENU_H -#define POPUP_MENU_H - -#include <gdk/gdktypes.h> -#include <gtk/gtksignal.h> - - -struct menu_item { - char *text; - GtkSignalFunc callback; - gpointer data; - int sensitive; -}; - -void popup_menu (struct menu_item *items, int nitems, GdkEventButton *event); - - -#endif diff --git a/calendar/gui/print.c b/calendar/gui/print.c deleted file mode 100644 index 1554be0b96..0000000000 --- a/calendar/gui/print.c +++ /dev/null @@ -1,1313 +0,0 @@ -/* Evolution calendar - Print support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <sys/stat.h> -#include <math.h> -#include <gnome.h> -#include <libgnomeprint/gnome-print.h> -#include <libgnomeprint/gnome-print-copies.h> -#include <libgnomeprint/gnome-print-master.h> -#include <libgnomeprint/gnome-print-master-preview.h> -#include <libgnomeprint/gnome-print-preview.h> -#include <libgnomeprint/gnome-printer-profile.h> -#include <libgnomeprint/gnome-printer-dialog.h> -#include <e-util/e-dialog-widgets.h> -#include <cal-util/timeutil.h> -#include "calendar-commands.h" -#include "gnome-cal.h" -#include "print.h" - - - -/* copied from gnome-month-item.c this should be shared?? */ - -/* Number of days in a month, for normal and leap years */ -static const int days_in_month[2][12] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -/* The weird month of September 1752, where 3 Sep through 13 Sep were eliminated due to the - * Gregorian reformation. - */ -static const int sept_1752[42] = { - 0, 0, 1, 2, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 -}; - -#define REFORMATION_DAY 639787 /* First day of the reformation, counted from 1 Jan 1 */ -#define MISSING_DAYS 11 /* They corrected out 11 days */ -#define THURSDAY 4 /* First day of reformation */ -#define SATURDAY 6 /* Offset value; 1 Jan 1 was a Saturday */ -#define SEPT_1752_START 2 /* Start day within month */ -#define SEPT_1752_END 20 /* End day within month */ - -struct pdinfo -{ - GList *slots; -}; - -struct psinfo -{ - GList *events; -}; - -struct ptinfo -{ - GList *todos; -}; - -struct einfo -{ - char *text; - time_t start; - time_t end; - int count; -}; - - -/* Returns the number of leap years since year 1 up to (but not including) the specified year */ -static int -leap_years_up_to (int year) -{ - return (year / 4 /* trivial leapness */ - - ((year > 1700) ? (year / 100 - 17) : 0) /* minus centuries since 1700 */ - + ((year > 1600) ? ((year - 1600) / 400) : 0)); /* plus centuries since 1700 divisible by 400 */ -} - -/* Returns whether the specified year is a leap year */ -static int -is_leap_year (int year) -{ - if (year <= 1752) - return !(year % 4); - else - return (!(year % 4) && (year % 100)) || !(year % 400); -} - -/* Returns the 1-based day number within the year of the specified date */ -static int -day_in_year (int day, int month, int year) -{ - int is_leap, i; - - is_leap = is_leap_year (year); - - for (i = 0; i < month; i++) - day += days_in_month [is_leap][i]; - - return day; -} - -/* Returns the day of the week (zero-based, zero is Sunday) for the specified date. For the days - * that were removed on the Gregorian reformation, it returns Thursday. - */ -static int -day_in_week (int day, int month, int year) -{ - int n; - - n = (year - 1) * 365 + leap_years_up_to (year - 1) + day_in_year (day, month, year); - - if (n < REFORMATION_DAY) - return (n - 1 + SATURDAY) % 7; - - if (n >= (REFORMATION_DAY + MISSING_DAYS)) - return (n - 1 + SATURDAY - MISSING_DAYS) % 7; - - return THURSDAY; -} - -/* Fills the 42-element days array with the day numbers for the specified month. Slots outside the - * bounds of the month are filled with zeros. The starting and ending indexes of the days are - * returned in the start and end arguments. - */ -static void -build_month (int month, int year, int start_on_monday, int *days, int *start, int *end) -{ - int i; - int d_month, d_week; - - /* Note that months are zero-based, so September is month 8 */ - - if ((year == 1752) && (month == 8)) { - memcpy (days, sept_1752, 42 * sizeof (int)); - - if (start) - *start = SEPT_1752_START; - - if (end) - *end = SEPT_1752_END; - - return; - } - - for (i = 0; i < 42; i++) - days[i] = 0; - - d_month = days_in_month[is_leap_year (year)][month]; - d_week = day_in_week (1, month, year); - - if (start_on_monday) - d_week = (d_week + 6) % 7; - - for (i = 0; i < d_month; i++) - days[d_week + i] = i + 1; - - if (start) - *start = d_week; - - if (end) - *end = d_week + d_month - 1; -} - - -enum align_box { - ALIGN_LEFT=1, - ALIGN_RIGHT, - ALIGN_CENTRE, - ALIGN_BORDER= 1<<8 -}; - -/* width = width of border, -'ve is no border - fillcolour = shade of fill, -'ve is no fill */ -static void -print_border(GnomePrintContext *pc, double l, double r, double t, double b, double width, double fillcolour) -{ - int i; - gnome_print_gsave (pc); - if (fillcolour<0.0) - i=1; - else - i=0; - for (;i<2;i++) { - gnome_print_moveto(pc, l, t); - gnome_print_lineto(pc, l, b); - gnome_print_lineto(pc, r, b); - gnome_print_lineto(pc, r, t); - gnome_print_lineto(pc, l, t); - if (i==0) { - gnome_print_setrgbcolor(pc, fillcolour, fillcolour, fillcolour); - gnome_print_fill(pc); - if (width<0.0) - i=2; - } else { - gnome_print_setrgbcolor(pc, 0, 0, 0); - gnome_print_setlinewidth(pc, width); - gnome_print_stroke(pc); - } - } - gnome_print_grestore (pc); -} - -/* outputs 1 line of aligned text in a box */ -static void -print_text(GnomePrintContext *pc, GnomeFont *font, const char *text, enum align_box align, double l, double r, double t, double b) -{ - double w, x; - gnome_print_gsave (pc); - w = gnome_font_get_width_string(font, text); - switch (align&3) { - default: - case ALIGN_LEFT: - x = l; - break; - case ALIGN_RIGHT: - x = l+(r-l)-w-2; - break; - case ALIGN_CENTRE: - x = l+((r-l)-w)/2; - break; - } - gnome_print_moveto(pc, x, t-font->size); - gnome_print_setfont(pc, font); - gnome_print_setrgbcolor (pc, 0,0,0); - gnome_print_show(pc, text); - gnome_print_grestore (pc); -} - -/* gets/frees the font for you, as a bold font */ -static void -print_text_size(GnomePrintContext *pc, double size, const char *text, enum align_box align, double l, double r, double t, double b) -{ - GnomeFont *font; - - font = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, size); - print_text(pc, font, text, align, l, r, t, b); - gtk_object_unref (GTK_OBJECT (font)); -} - -static void -titled_box(GnomePrintContext *pc, const char *text, GnomeFont *font, enum align_box align, double *l, double *r, double *t, double *b, double linewidth) -{ - if (align&ALIGN_BORDER) { - gnome_print_gsave(pc); - print_border(pc, *l, *r, *t, *t-font->size-font->size*0.4, linewidth, 0.9); - print_border(pc, *l, *r, *t-font->size-font->size*0.4, *b, linewidth, -1.0); - gnome_print_grestore(pc); - *l+=2; - *r-=2; - *b+=2; - } - print_text(pc, font, text, align, *l, *r, *t, *b); - *t-=font->size*1.4; -} - -enum datefmt { - DATE_MONTH = 1 << 0, - DATE_DAY = 1 << 1, - DATE_DAYNAME = 1 << 2, - DATE_YEAR = 1 << 3 -}; - -static char *days[] = { - N_("1st"), N_("2nd"), N_("3rd"), N_("4th"), N_("5th"), - N_("6th"), N_("7th"), N_("8th"), N_("9th"), N_("10th"), - N_("11th"), N_("12th"), N_("13th"), N_("14th"), N_("15th"), - N_("16th"), N_("17th"), N_("18th"), N_("19th"), N_("20th"), - N_("21st"), N_("22nd"), N_("23rd"), N_("24th"), N_("25th"), - N_("26th"), N_("27th"), N_("28th"), N_("29th"), N_("30th"), - N_("31st") -}; - -/* - format the date 'nicely' and consistently for various headers -*/ -static char * -format_date(time_t time, int flags, char *buffer, int bufflen) -{ - char fmt[64]; - struct tm tm; - - tm = *localtime(&time); - fmt[0] = 0; - if (flags & DATE_DAYNAME) { - strcat(fmt, "%A"); - } - if (flags & DATE_DAY) { - if (flags & DATE_DAYNAME) - strcat(fmt, " "); - strcat(fmt, gettext(days[tm.tm_mday-1])); - } - if (flags & DATE_MONTH) { - if (flags & (DATE_DAY|DATE_DAYNAME)) - strcat(fmt, " "); - strcat(fmt, "%B"); - if ((flags & (DATE_DAY|DATE_YEAR)) == (DATE_DAY|DATE_YEAR)) - strcat(fmt, ","); - } - if (flags & DATE_YEAR) { - if (flags & (DATE_DAY|DATE_DAYNAME|DATE_MONTH)) - strcat(fmt, " "); - strcat(fmt, "%Y"); - } - strftime(buffer, bufflen, fmt, &tm); - return buffer; -} - - -/* - print out the month small, embolden any days with events. -*/ -static void -print_month_small (GnomePrintContext *pc, GnomeCalendar *gcal, - time_t month, double left, double right, double top, double bottom, - int titleflags, time_t greystart, time_t greyend, int bordertitle) -{ - GnomeFont *font, *font_bold, *font_normal; - time_t now, next; - int x, y; - int days[42]; - int day; - char buf[100]; - struct tm tm; - double xpad, ypad, size; - char *daynames[] = { _("Su"), _("Mo"), _("Tu"), _("We"), _("Th"), _("Fr"), _("Sa") }; - - xpad = (right-left)/7; - ypad = (top-bottom)/8.3; - if (xpad>ypad) - size=ypad; - else - size=xpad; - - size = (xpad+ypad)/3.0; - - tm = *localtime (&month); - - /* get month days */ - build_month(tm.tm_mon, tm.tm_year+1900, week_starts_on_monday, days, 0, 0); - - /* build day-busy bits */ - now = time_month_begin(month); - - /* get title */ - format_date(month, titleflags, buf, 100); - font = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 1, size*1.2); /* title font */ - if (bordertitle) - print_border(pc, - left, left+7*xpad, top, top-font->size*1.3, - 1.0, 0.9); - print_text(pc, font, buf, ALIGN_CENTRE, - left, left+7*xpad, top, top - font->size); - gtk_object_unref (GTK_OBJECT (font)); - - font_normal = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, size); - font_bold = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, size); - - gnome_print_setrgbcolor (pc, 0,0,0); - for (x=0;x<7;x++) { - print_text(pc, font_bold, daynames[(week_starts_on_monday?x+1:x)%7], ALIGN_CENTRE, - left+x*xpad, left+(x+1)*xpad, bottom+7*ypad, bottom+7*ypad-font_bold->size); - } - - for (y=0;y<6;y++) { - for (x=0;x<7;x++) { - day = days[y*7+x]; - if (day!=0) { - GList *uids; - - sprintf(buf, "%d", day); - - /* this is a slow messy way to do this ... but easy ... */ - uids = cal_client_get_objects_in_range (gcal->client, CALOBJ_TYPE_EVENT, now, time_day_end (now)); - font = uids ? font_bold : font_normal; - cal_obj_uid_list_free (uids); - - next = time_add_day(now, 1); - if ((now>=greystart && now<greyend) - || (greystart>=now && greystart<next)) { - print_border(pc, - left+x*xpad+xpad*0.1, - left+(x+1)*xpad+xpad*0.1, - bottom+(5-y)*ypad+font->size-ypad*0.15, - bottom+(5-y)*ypad-ypad*0.15, - -1.0, 0.75); - } - print_text(pc, font, buf, ALIGN_RIGHT, - left+x*xpad, left+(x+1)*xpad, bottom+(5-y)*ypad+font->size, bottom+(5-y)*ypad); - now = next; - } - } - } - gtk_object_unref (GTK_OBJECT (font_normal)); - gtk_object_unref (GTK_OBJECT (font_bold)); -} - - - -/* wraps text into the print context, not taking up more than its allowed space */ -static double -bound_text(GnomePrintContext *pc, GnomeFont *font, char *text, double left, double right, double top, double bottom, double indent) -{ - double maxwidth = right-left; - double width; - char *p; - char *wordstart; - int c; - char *outbuffer, *o, *outbuffendmarker; - int outbufflen; - int dump=0; - int first=1; - - g_return_val_if_fail(text!=NULL, top); - - if (top<bottom) { - /* too much to fit in appointment printout */ - return top; - } - - outbufflen = 1024; - outbuffer = g_malloc(outbufflen); - outbuffendmarker = outbuffer+outbufflen-2; - - top -= font->size; - gnome_print_setfont (pc, font); - - width=0; - p = text; - wordstart = outbuffer; - o = outbuffer; - while ((c=*p)) { - if (c=='\n') { - wordstart=o; - dump=1; - } else { - /* grow output buffer if required */ - if (o>=outbuffendmarker) { - char *newbuf; - outbufflen*=2; - newbuf = g_realloc(outbuffer, outbufflen); - o = newbuf+(o-outbuffer); - wordstart = newbuf+(o-outbuffer); - outbuffer = newbuf; - outbuffendmarker = outbuffer+outbufflen-2; - } - *o++=c; - if (c==' ') - wordstart = o; - width+=gnome_font_get_width(font, c); - if (width>maxwidth) - dump=1; - else - dump=0; - } - if (dump) { - if (wordstart==outbuffer) - wordstart=o; - c=*wordstart; - *wordstart=0; - gnome_print_moveto(pc, left, top); - gnome_print_show(pc, outbuffer); - *wordstart=c; - memcpy(outbuffer, wordstart, o-wordstart); - width = gnome_font_get_width_string_n(font, outbuffer, o-wordstart); - o=outbuffer+(o-wordstart); - wordstart = outbuffer; - top -= font->size; - if (top<bottom) { - /* too much to fit, drop the rest */ - g_free(outbuffer); - return top; - } - if (first) { - left += indent; - maxwidth -= indent; - first=0; - } - } - p++; - } - if (dump==0) { - *o=0; - gnome_print_moveto(pc, left, top); - gnome_print_show(pc, outbuffer); - top -= font->size; - } - g_free(outbuffer); - return top; -} - -/* - * Print Day Details - */ -static gboolean -print_day_details_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - CalComponentText text; - GList *l, *col = NULL; - struct pdinfo *pdi = (struct pdinfo *)data; - struct einfo *ei; - - ei = g_new (struct einfo, 1); - - cal_component_get_summary (comp, &text); - ei->text = g_strdup (text.value); - - ei->start = istart; - ei->end = iend; - ei->count = 0; - - for (l = pdi->slots; l; l = l->next) { - struct einfo *testei; - - col = (GList *)l->data; - testei = (struct einfo *)col->data; - - if (ei->start >= testei->end) { - col = g_list_prepend (col, ei); - l->data = col; - return TRUE; - } - - testei->count++; - ei->count++; - } - - col = NULL; - col = g_list_prepend (col, ei); - pdi->slots = g_list_append (pdi->slots, col); - - return TRUE; -} - -static void -print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom) -{ - struct pdinfo pdi; - time_t start, end; - GList *l; - int num_slots, i; - GnomeFont *font_hour, *font_minute, *font_summary; - double yinc, y, yend, x, xend; - double width=40, slot_width; - char buf[20]; - - yinc = (top-bottom)/24; - - /* fill static detail */ - font_hour = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, yinc/2); - font_minute = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, yinc/3); - font_summary = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, yinc/3); - - gnome_print_setrgbcolor (pc, 0, 0, 0); - - /* internal lines */ - gnome_print_setlinewidth(pc, 0.0); - gnome_print_moveto(pc, left+width, bottom); - gnome_print_lineto(pc, left+width, top); - gnome_print_stroke (pc); - - for (i=0;i<24;i++) { - y = top - yinc*(i+1); - print_border(pc, left+1, left+width-1, y, y+yinc-1, -1.0, 0.9); - gnome_print_setrgbcolor (pc, 0, 0, 0); - - /* the hour label/minute */ - sprintf(buf, "%d", i); - print_text(pc, font_hour, buf, ALIGN_RIGHT, left, left+width/2, y+yinc, y); - switch(i) { - case 12: sprintf(buf, _("pm")); break; - case 0: sprintf(buf, _("am")); break; - default: sprintf(buf, "00"); break; - } - print_text(pc, font_minute, buf, ALIGN_LEFT, left+width/2, left+width/2, y+yinc, y); - - /* internal lines */ - gnome_print_moveto(pc, left+width, y); - gnome_print_lineto(pc, right, y); - gnome_print_stroke (pc); - gnome_print_moveto(pc, left+width/2, y+yinc/2); - gnome_print_lineto(pc, right, y+yinc/2); - gnome_print_stroke (pc); - - } - - start = time_day_begin(whence); - end = time_day_end(start); - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_EVENT, start, end, - print_day_details_cb, &pdi); - - num_slots = g_list_length (pdi.slots); - slot_width = (right-left-width)/num_slots; - - for (i = num_slots, l = pdi.slots; l; i--, l = l->next) { - GList *e = (GList *)l->data; - - for (; e; e = e->next) { - struct einfo *ei = (struct einfo *)e->data; - - y = top - (top - bottom) * (ei->start - start) / (end - start) - 1; - yend = top - (top - bottom) * (ei->end - start) / (end - start) + 1; - x = left + width + slot_width * (num_slots - i); - - if (num_slots > 0) - x++; - - if (i == 0) - xend = x + (num_slots - ei->count) * slot_width - 2; - else - xend = x + slot_width - 2; - - print_border (pc, x, xend, y, yend, 0.0, 0.9); - - bound_text (pc, font_summary, ei->text, x, xend, y, yend, 0); - - g_free (ei); - } - g_list_free (e); - } - g_list_free (pdi.slots); - - print_border (pc, left, right, top, bottom, 1.0, -1.0); - - gtk_object_unref (GTK_OBJECT (font_hour)); - gtk_object_unref (GTK_OBJECT (font_minute)); - gtk_object_unref (GTK_OBJECT (font_summary)); -} - -/* - * Print Day Summary - */ -#if 0 -#define TIME_FMT "%X" -#else -#define TIME_FMT "%l:%M%p" -#endif - -static gboolean -print_day_summary_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - CalComponentText text; - struct psinfo *psi = (struct psinfo *)data; - struct einfo *ei; - - ei = g_new (struct einfo, 1); - - cal_component_get_summary (comp, &text); - ei->text = g_strdup (text.value); - - ei->start = istart; - ei->end = iend; - ei->count = 0; - - g_list_append (psi->events, ei); - - return TRUE; -} - -static void -print_day_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom, - double size, int totime, int titleformat) -{ - struct psinfo psi; - time_t start, end; - GList *l; - GnomeFont *font_summary; - double y, yend, x, xend, inc, incsmall; - char buf[100]; - double margin; - struct tm tm; - - /* fill static detail */ - font_summary = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, size); - - gnome_print_setfont (pc, font_summary); - - start = time_day_begin(whence); - end = time_day_end(start); - - tm = *localtime(&start); - - format_date(start, titleformat, buf, 100); - titled_box (pc, buf, font_summary, ALIGN_RIGHT | ALIGN_BORDER, - &left, &right, &top, &bottom, 0.0); - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_EVENT, start, end, - print_day_summary_cb, &psi); - inc = size*0.3; - incsmall = size*0.2; - - y = top-inc; - yend = bottom-incsmall; - - /* do a good rough approximation of the 'widest' time */ - tm.tm_year = 2000; - tm.tm_mon = 12; - tm.tm_mday = 22; - tm.tm_sec = 22; - tm.tm_min = 22; - tm.tm_hour = 23; - strftime(buf, 100, TIME_FMT, &tm); - margin = gnome_font_get_width_string(font_summary, buf); - - for (l = psi.events; l; l = l->next) { - struct einfo *ei = (struct einfo *)l->data; - - x = left + incsmall; - xend = right - inc; - - if (y - font_summary->size < bottom) - break; - - tm = *localtime (&ei->start); - strftime (buf, 100, TIME_FMT, &tm); - gnome_print_moveto (pc, x + (margin - - gnome_font_get_width_string (font_summary, buf)), - y - font_summary->size); - gnome_print_show (pc, buf); - - if (totime) { - tm = *localtime (&ei->end); - strftime (buf, 100, TIME_FMT, &tm); - gnome_print_moveto (pc, - (x + margin + inc - + (margin - - gnome_font_get_width_string (font_summary, buf))), - y - font_summary->size); - gnome_print_show (pc, buf); - - y = bound_text (pc, font_summary, ei->text, - x + margin * 2 + inc * 2, xend, - y, yend, 0); - } else { - /* we also indent back after each time is printed */ - y = bound_text (pc, font_summary, ei->text, - x + margin + inc, xend, - y, yend, -margin + inc); - } - - y += font_summary->size - inc; - - g_free (ei); - } - g_list_free (psi.events); - - gtk_object_unref (GTK_OBJECT (font_summary)); -} - -static void -print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom) -{ - double y, l, r, t, b; - time_t now; - int i; - - l = left; - r = (right-left)/2+left; - t = top; - y = (top-bottom)/3; - b = top-y; - now = time_week_begin(whence); /* returns sunday, we need monday */ - now = time_add_day(now, 1); - for (i = 0; i < 7; i++) { - print_day_summary (pc, gcal, now, l, r, t, b, - 10, TRUE, DATE_DAY | DATE_DAYNAME | DATE_MONTH); - now = time_add_day (now, 1); - switch (i) { - case 5: - y /= 2.0; - b += y; - case 0: - case 1: - case 3: - case 4: - t -= y; - b -= y; - break; - case 2: - l = r; - r = right; - t = top; - b = t-y; - break; - case 6: - break; - } - } -} - -static void -print_year_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom, int morerows) -{ - double y, x, l, r, t, b; - time_t now; - int xx, yy, rows, cols; - - l = left; - t = top; - if (morerows) { - rows=4; - cols=3; - } else { - rows=3; - cols=4; - } - y = (top-bottom)/rows; - x = (right-left)/cols; - r = l+x; - b = top-y; - now = time_year_begin(whence); - for (yy = 0; yy < rows; yy++) { - t = top - y * yy; - b = t - y; - for (xx = 0; xx < cols; xx++) { - l = left + x * xx; - r = l + x; - print_month_small (pc, gcal, now, - l + 8, r - 8, t - 8, b + 8, DATE_MONTH, 0, 0, TRUE); - now = time_add_month (now, 1); - } - } -} - -static void -print_month_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom) -{ - time_t now, today; - int days[42]; - int day; - struct tm tm; - int x, y; - char buf[100]; - GnomeFont *font_days; - - now = time_month_begin(whence); - tm = *localtime (&now); - - /* get month days */ - build_month(tm.tm_mon, tm.tm_year+1900, week_starts_on_monday, days, 0, 0); - - /* a little margin */ - top -= 4; - - /* do day names ... */ - font_days = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, 10); - gnome_print_setfont(pc, font_days); - for (x=0;x<7;x++) { - today = time_add_day(now, days[6+x]); - format_date(today, DATE_DAYNAME, buf, 100); - print_text(pc, font_days, buf, ALIGN_CENTRE, - (right-left)*x/7+left, (right-left)*(x+1)/7+left, - top, top-font_days->size); - } - top -= font_days->size*1.5; - gtk_object_unref (GTK_OBJECT (font_days)); - - for (y=0;y<6;y++) { - for (x=0;x<7;x++) { - day = days[y*7+x]; - if (day!=0) { - print_day_summary (pc, gcal, now, - (right-left)*x/7+left, - (right-left)*(x+1)/7+left, - top - (top-bottom)*y/6, - top - (top-bottom)*(y+1)/6, 6, FALSE, - day==1?(DATE_DAY|DATE_MONTH):DATE_DAY); - now = time_add_day(now, 1); - } - } - } -} - -/* - * Print to do details - */ -static gboolean -print_todo_details_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - CalComponentText text; - struct ptinfo *pti = (struct ptinfo *)data; - struct einfo *ei; - - ei = g_new0 (struct einfo, 1); - - cal_component_get_summary (comp, &text); - ei->text = g_strdup (text.value); - - g_list_append (pti->todos, ei); - - return TRUE; -} - -static void -print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t start, time_t end, - double left, double right, double top, double bottom) -{ - struct ptinfo pti; - GList *l; - GnomeFont *font_summary; - double y, yend, x, xend; - - font_summary = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, 10); - - gnome_print_setrgbcolor (pc, 0, 0, 0); - gnome_print_setlinewidth (pc, 0.0); - - titled_box (pc, _("TODO Items"), font_summary, - ALIGN_CENTRE | ALIGN_BORDER, &left, &right, &top, &bottom, 1.0); - - y = top - 3; - yend = bottom - 2; - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_TODO, start, end, - print_todo_details_cb, &pti); - - for (l = pti.todos; l; l = l->next) { - struct einfo *ei = (struct einfo *)l->data; - - x = left; - xend = right-2; - - if (y < bottom) - break; - - y = bound_text (pc, font_summary, ei->text, x + 2, xend, y, yend, 0); - y += font_summary->size; - gnome_print_moveto (pc, x, y - 3); - gnome_print_lineto (pc, xend, y - 3); - gnome_print_stroke (pc); - y -= 3; - - g_free (ei); - } - g_list_free (pti.todos); - - gtk_object_unref (GTK_OBJECT (font_summary)); -} - -#if 0 - -static GnomePrintContext * -print_context (int preview, char *paper) -{ - GtkWidget *toplevel, *canvas, *sw; - GnomePrinter *printer; - GnomePrintContext *pc; - - if (preview) { - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - gtk_widget_push_visual (gdk_rgb_get_visual ()); - - toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize (toplevel, 700, 700); - sw = gtk_scrolled_window_new (NULL, NULL); - canvas = gnome_canvas_new_aa (); - gtk_container_add (GTK_CONTAINER (toplevel), sw); - gtk_container_add (GTK_CONTAINER (sw), canvas); - - gnome_canvas_set_pixels_per_unit((GnomeCanvas *)canvas, 1); - - pc = gnome_print_preview_new ((GnomeCanvas *)canvas, paper); - - gtk_widget_show_all (toplevel); - - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - } else { - printer = gnome_printer_dialog_new_modal (); - - if (!printer) - return NULL; - - pc = gnome_print_context_new_with_paper_size (printer, paper); - } - - return pc; -} - -#endif - -/* Value for the PrintView enum */ -static const int print_view_map[] = { - PRINT_VIEW_DAY, - PRINT_VIEW_WEEK, - PRINT_VIEW_MONTH, - PRINT_VIEW_YEAR, - -1 -}; - -/* Creates the range selector widget for printing a calendar */ -static GtkWidget * -range_selector_new (GtkWidget *dialog, time_t at, int *view) -{ - GtkWidget *box; - GtkWidget *radio; - GSList *group; - char text[1024]; - struct tm tm; - time_t week_begin, week_end; - struct tm week_begin_tm, week_end_tm; - - box = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - - tm = *localtime (&at); - - /* Day */ - - strftime (text, sizeof (text), _("Current day (%a %b %d %Y)"), &tm); - radio = gtk_radio_button_new_with_label (NULL, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Week */ - - week_begin = time_week_begin (at); - week_end = time_add_day (time_week_end (at), -1); - - week_begin_tm = *localtime (&week_begin); - week_end_tm = *localtime (&week_end); - - /* FIXME: how to make this localization-friendly? */ - - if (week_begin_tm.tm_mon == week_end_tm.tm_mon) { - char month[128]; - char day1[128]; - char day2[128]; - - strftime (month, sizeof (month), _("%a"), &week_begin_tm); - strftime (day1, sizeof (day1), _("%b"), &week_begin_tm); - strftime (day2, sizeof (day2), _("%b"), &week_end_tm); - - g_snprintf (text, sizeof (text), _("Current week (%s %s %d - %s %d %d)"), - day1, month, week_begin_tm.tm_mday, - day2, week_end_tm.tm_mday, - week_begin_tm.tm_year + 1900); - } else { - char month1[128]; - char month2[128]; - char day1[128]; - char day2[128]; - - strftime (month1, sizeof (month1), _("%a"), &week_begin_tm); - strftime (month2, sizeof (month2), _("%a"), &week_end_tm); - strftime (day1, sizeof (day1), _("%b"), &week_begin_tm); - strftime (day2, sizeof (day2), _("%b"), &week_end_tm); - - if (week_begin_tm.tm_year == week_end_tm.tm_year) - g_snprintf (text, sizeof (text), - _("Current week (%s %s %d - %s %s %d %d)"), - day1, month1, week_begin_tm.tm_mday, - day2, month2, week_end_tm.tm_mday, - week_begin_tm.tm_year + 1900); - else - g_snprintf (text, sizeof (text), - _("Current week (%s %s %d %d - %s %s %d %d)"), - day1, month1, week_begin_tm.tm_mday, - week_begin_tm.tm_year + 1900, - day2, month2, week_end_tm.tm_mday, - week_end_tm.tm_year + 1900); - } - - radio = gtk_radio_button_new_with_label (group, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Month */ - - strftime (text, sizeof (text), _("Current month (%a %Y)"), &tm); - radio = gtk_radio_button_new_with_label (group, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Year */ - - strftime (text, sizeof (text), _("Current year (%Y)"), &tm); - radio = gtk_radio_button_new_with_label (group, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Select default */ - - e_dialog_widget_hook_value (dialog, radio, view, (gpointer) print_view_map); - - gtk_widget_show_all (box); - return box; -} - -void -print_calendar (GnomeCalendar *gcal, gboolean preview, time_t at, PrintView default_view) -{ - GnomePrinter *printer; - GnomePrintMaster *gpm; - GnomePrintContext *pc; - int copies, collate; - const GnomePaper *paper_info; - double l, r, t, b, todo, header; - char buf[100]; - time_t when; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - printer = NULL; - copies = 1; - collate = FALSE; - - if (!preview) { - GtkWidget *gpd; - GtkWidget *range; - int view; - - gpd = gnome_print_dialog_new (_("Print Calendar"), - GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); - - view = (int) default_view; - range = range_selector_new (gpd, at, &view); - gnome_print_dialog_construct_range_custom (GNOME_PRINT_DIALOG (gpd), range); - - gnome_dialog_set_default (GNOME_DIALOG (gpd), GNOME_PRINT_PRINT); - - /* Run dialog */ - - switch (gnome_dialog_run (GNOME_DIALOG (gpd))) { - case GNOME_PRINT_PRINT: - break; - - case GNOME_PRINT_PREVIEW: - preview = TRUE; - break; - - case -1: - return; - - default: - gnome_dialog_close (GNOME_DIALOG (gpd)); - return; - } - - e_dialog_get_values (gpd); - default_view = (PrintView) view; - - gnome_print_dialog_get_copies (GNOME_PRINT_DIALOG (gpd), &copies, &collate); - printer = gnome_print_dialog_get_printer (GNOME_PRINT_DIALOG (gpd)); - - gnome_dialog_close (GNOME_DIALOG (gpd)); - } - - /* FIXME: allow configuration of paper size */ - - gpm = gnome_print_master_new (); - - paper_info = gnome_paper_with_name (gnome_paper_name_default ()); - gnome_print_master_set_paper (gpm, paper_info); - - if (printer) - gnome_print_master_set_printer (gpm, printer); - - gnome_print_master_set_copies (gpm, copies, collate); - - pc = gnome_print_master_get_context (gpm); - - l = gnome_paper_lmargin (paper_info); - r = gnome_paper_pswidth (paper_info) - gnome_paper_rmargin (paper_info); - t = gnome_paper_psheight (paper_info) - gnome_paper_tmargin (paper_info); - b = gnome_paper_bmargin (paper_info); - - /* depending on the view, do a different output */ - switch (default_view) { - case PRINT_VIEW_DAY: { - int i, days = 1; - - for (i = 0; i < days; i++) { - todo = ((r - l) / 5) * 4 + l; - header = t - 70; - print_todo_details (pc, gcal, 0, INT_MAX, todo, r, header, b); - print_day_details (pc, gcal, at, l, todo - 2.0, header, b); - - print_border (pc, l, r, t, header + 2.0, 1.0, 0.9); - - print_month_small (pc, gcal, at, r - 190, r - 104, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, at, at, FALSE); - print_month_small (pc, gcal, time_add_month (at, 1), r - 90, r - 4, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); - - format_date (at, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_LEFT, l + 3, todo, t - 3, header); - - format_date (at, DATE_DAYNAME, buf, 100); - print_text_size (pc, 18, buf, ALIGN_LEFT, l + 3, todo, t - 27 - 4, header); - gnome_print_showpage (pc); - at = time_add_day (at, 1); - } - break; - } - - case PRINT_VIEW_WEEK: - header = t - 70; - print_week_summary (pc, gcal, at, l, r, header, b); - - /* more solid total outline */ - print_border (pc, l, r, header, b, 1.0, -1.0); - - /* header border */ - print_border (pc, l, r, t, header + 2.0, 1.0, 0.9); - - when = time_week_begin (at); - when = time_add_day (when, 1); - - print_month_small (pc, gcal, at, r - 90, r - 4, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, when, time_add_week (when, 1), - FALSE); - print_month_small (pc, gcal, time_add_month (at, -1), r - 190, r - 104, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, when, time_add_week (when, 1), - FALSE); - - format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_LEFT, l + 3, r, t - 4, header); - - when = time_add_day (when, 6); - format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_LEFT, l + 3, r, t - 24 - 3, header); - gnome_print_showpage (pc); - break; - - case PRINT_VIEW_MONTH: - header = t - 70; - gnome_print_rotate (pc, 90); - gnome_print_translate (pc, 0, -gnome_paper_pswidth (paper_info)); - /*print_month_summary(pc, cal, at, l, r, header, b);*/ - print_month_summary (pc, gcal, at, b, t, r - 70, l); - - print_border (pc, b, t, r, r - 72.0, 1.0, 0.9); - - print_month_small (pc, gcal, time_add_month (at, 1), - t - (t - b) / 7 + 2, t - 8, r - 4, r - 68, - DATE_MONTH | DATE_YEAR, 0, 0, FALSE); - print_month_small (pc, gcal, time_add_month (at, -1), - b + 8, b + (t - b) / 7 - 2, r - 4, r - 68, - DATE_MONTH | DATE_YEAR, 0, 0, FALSE); - - /* centered title */ - format_date (at, DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_CENTRE, b + 3, t, r - 3, l); - gnome_print_showpage (pc); - break; - - case PRINT_VIEW_YEAR: -#if 0 - /* landscape */ - gnome_print_rotate(pc, 90); - gnome_print_translate(pc, 0, -gnome_paper_pswidth(paper_info)); - print_year_summary(pc, gcal, at, b, t, r-50, l, FALSE); - - /* centered title */ - format_date(at, DATE_YEAR, buf, 100); - print_text_size(pc, 24, buf, ALIGN_CENTRE, b+3, t, r-3, l); -#else - /* portrait */ - print_year_summary(pc, gcal, at, l, r, t-50, b, TRUE); - - /* centered title */ - format_date(at, DATE_YEAR, buf, 100); - print_text_size(pc, 24, buf, ALIGN_CENTRE, l+3, r, t-3, b); -#endif - gnome_print_showpage(pc); - break; - - default: - g_assert_not_reached (); - } - - gnome_print_master_close (gpm); - - if (preview) { - GnomePrintMasterPreview *gpmp; - - gpmp = gnome_print_master_preview_new (gpm, _("Print Preview")); - gtk_widget_show (GTK_WIDGET (gpmp)); - } else - gnome_print_master_print (gpm); - - gtk_object_unref (GTK_OBJECT (gpm)); -} diff --git a/calendar/gui/print.h b/calendar/gui/print.h deleted file mode 100644 index e88c4a8e01..0000000000 --- a/calendar/gui/print.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Evolution calendar - Print support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef PRINT_H -#define PRINT_H - -#include "gnome-cal.h" - - - -typedef enum { - PRINT_VIEW_DAY, - PRINT_VIEW_WEEK, - PRINT_VIEW_MONTH, - PRINT_VIEW_YEAR -} PrintView; - -void print_calendar (GnomeCalendar *gcal, gboolean preview, time_t at, PrintView default_view); - - - -#endif diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c deleted file mode 100644 index 2555059af8..0000000000 --- a/calendar/gui/prop.c +++ /dev/null @@ -1,938 +0,0 @@ -/* Calendar properties dialog box - * - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: Miguel de Icaza <miguel@kernel.org> - * Federico Mena <federico@nuclecu.unam.mx> - */ -#include <config.h> -#ifdef HAVE_LANGINGO_H -#include <langinfo.h> -#else -#include <locale.h> -#endif -#include <gnome.h> -#include "gnome-cal.h" -#include "gnome-month-item.h" -#include "calendar-commands.h" -#include "mark.h" - -/* These specify the page numbers in the preferences notebook */ -enum { - PROP_TIME_DISPLAY, - PROP_COLORS, - PROP_TODO, - PROP_ALARMS -}; - -static GtkWidget *prop_win; /* The preferences dialog */ - -/* Widgets for the time display page */ - -static GtkWidget *time_format_12; /* Radio button for 12-hour format */ -static GtkWidget *time_format_24; /* Radio button for 24-hour format */ -static GtkWidget *start_on_sunday; /* Check button for weeks starting on Sunday */ -static GtkWidget *start_on_monday; /* Check button for weeks starting on Monday */ -static GtkWidget *start_omenu; /* Option menu for start of day */ -static GtkWidget *end_omenu; /* Option menu for end of day */ -static GtkWidget *start_items[24]; /* Menu items for start of day menu */ -static GtkWidget *end_items[24]; /* Menu items for end of day menu */ - -/* Widgets for the colors page */ - -static GtkWidget *color_pickers[COLOR_PROP_LAST]; -static GnomeCanvasItem *month_item; - -/* Widgets for the todo page */ -static GtkWidget *due_date_show_button; - -static GtkWidget *todo_item_time_remaining_show_button; - -static GtkWidget *todo_item_highlight_overdue; -static GtkWidget *todo_item_highlight_not_due_yet; -static GtkWidget *todo_item_highlight_due_today; - -static GtkWidget *priority_show_button; - -/* Widgets for the alarm page */ -static GtkWidget *enable_display_beep; -static GtkWidget *to_cb; -static GtkWidget *to_spin; -static GtkWidget *snooze_cb; -static GtkWidget *snooze_spin; - -/* prototypes */ -#if 0 -static void prop_apply_alarms (void); -#endif -static void create_alarm_page (void); -static void to_cb_changed (GtkWidget* object, gpointer data); -static void snooze_cb_changed (GtkWidget* object, gpointer data); - -GtkWidget* make_spin_button (int val, int low, int high); -void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, - enum AlarmType type, int y, gboolean sens, - GtkSignalFunc dirty_func); -void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type); - -/* Callback used when the property box is closed -- just sets the prop_win variable to null. */ -static int -prop_cancel (void) -{ - prop_win = NULL; - return FALSE; -} - -/* Returns the index of the active item in a menu */ -static int -get_active_index (GtkWidget *menu) -{ - GtkWidget *active; - - active = gtk_menu_get_active (GTK_MENU (menu)); - return GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (active))); -} - -/* Applies the settings in the time display page */ -static void -prop_apply_time_display (void) -{ - /* Day begin/end */ - - day_begin = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu))); - day_end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu))); - gnome_config_set_int ("/calendar/Calendar/Day start", day_begin); - gnome_config_set_int ("/calendar/Calendar/Day end", day_end); - - /* Time format */ - - am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active; - gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag); - - /* Week start */ - - week_starts_on_monday = GTK_TOGGLE_BUTTON (start_on_monday)->active; - gnome_config_set_bool ("/calendar/Calendar/Week starts on Monday", week_starts_on_monday); - - gnome_config_sync (); - time_format_changed (); -} - -/* Applies the settings in the colors page */ -static void -prop_apply_colors (void) -{ - int i; - char *cspec; - gushort r, g, b; - - for (i = 0; i < COLOR_PROP_LAST; i++) { - gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &b, NULL); - color_props[i].r = r; - color_props[i].g = g; - color_props[i].b = b; - - cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b); - gnome_config_set_string (color_props[i].key, cspec); - } - - gnome_config_sync (); - colors_changed (); -} -/* Applies the settings in the todo page (FIX THIS IF ITS NOT WRITTEN) */ -static void -prop_apply_todo(void) -{ - todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active; - - todo_item_dstatus_highlight_overdue = GTK_TOGGLE_BUTTON(todo_item_highlight_overdue)->active; - todo_item_dstatus_highlight_not_due_yet = GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet)->active; - todo_item_dstatus_highlight_due_today = GTK_TOGGLE_BUTTON(todo_item_highlight_due_today)->active; - - todo_show_priority = GTK_TOGGLE_BUTTON (priority_show_button)->active; - - todo_show_time_remaining = GTK_TOGGLE_BUTTON (todo_item_time_remaining_show_button)->active; - - /* storing the values */ - - gnome_config_set_bool("/calendar/Todo/show_time_remain", todo_show_time_remaining); - gnome_config_set_bool("/calendar/Todo/highlight_overdue", todo_item_dstatus_highlight_overdue); - - gnome_config_set_bool("/calendar/Todo/highlight_due_today", todo_item_dstatus_highlight_due_today); - - gnome_config_set_bool("/calendar/Todo/highlight_not_due_yet", todo_item_dstatus_highlight_not_due_yet); - gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date); - gnome_config_set_bool("/calendar/Todo/show_priority", todo_show_priority); - /* need to sync our config changes. */ - gnome_config_sync (); - - /* apply the current changes */ - todo_properties_changed(); -} - - -/* Callback used when the Apply button is clicked. */ -static void -prop_apply (GtkWidget *w, int page) -{ - switch (page) { - case PROP_TIME_DISPLAY: - prop_apply_time_display (); - break; - - case PROP_COLORS: - prop_apply_colors (); - break; - - case PROP_TODO: - prop_apply_todo (); - break; - - case PROP_ALARMS: -#if 0 - prop_apply_alarms (); -#endif - break; - - case -1: - break; - - default: - g_warning ("We have a loose penguin!"); - g_assert_not_reached (); - } -} - -/* Notifies the property box that the data has changed */ -static void -prop_changed (void) -{ - gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win)); -} - -/* Builds and returns a two-element radio button group surrounded by a frame. The radio buttons are - * stored in the specified variables, and the first radio button's state is set according to the - * specified flag value. The buttons are connected to the prop_changed() function to update the property - * box's dirty state. - */ -static GtkWidget * -build_two_radio_group (char *title, - char *radio_1_title, GtkWidget **radio_1_widget, - char *radio_2_title, GtkWidget **radio_2_widget, - int radio_1_value) -{ - GtkWidget *frame; - GtkWidget *vbox; - - frame = gtk_frame_new (title); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - *radio_1_widget = gtk_radio_button_new_with_label (NULL, radio_1_title); - gtk_box_pack_start (GTK_BOX (vbox), *radio_1_widget, FALSE, FALSE, 0); - - *radio_2_widget = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (*radio_1_widget), - radio_2_title); - gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_2_widget), !radio_1_value); - - gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled", - (GtkSignalFunc) prop_changed, - NULL); - - return frame; -} - -/* Callback invoked when a menu item from the start/end time option menus is selected. It adjusts - * the other menu to the proper time, if needed. - */ -static void -hour_activated (GtkWidget *widget, gpointer data) -{ - int start, end; - - if (data == start_omenu) { - /* Adjust the end menu */ - - start = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget))); - end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu))); - - if (end < start) - gtk_option_menu_set_history (GTK_OPTION_MENU (end_omenu), start); - } else if (data == end_omenu) { - /* Adjust the start menu */ - - end = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget))); - start = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu))); - - if (start > end) - gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end); - } else - g_assert_not_reached (); - - gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win)); -} - -/* Builds an option menu of 24 hours */ -static GtkWidget * -build_hours_menu (GtkWidget **items, int active) -{ - GtkWidget *omenu; - GtkWidget *menu; - int i; - char buf[100]; - struct tm tm; - int am_pm_flag; - - omenu = gtk_option_menu_new (); - menu = gtk_menu_new (); - am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active; - - memset (&tm, 0, sizeof (tm)); - - for (i = 0; i < 24; i++) { - tm.tm_hour = i; - if (am_pm_flag) - strftime (buf, 100, "%I:%M %p", &tm); - else - strftime (buf, 100, "%H:%M", &tm); - - items[i] = gtk_menu_item_new_with_label (buf); - gtk_object_set_user_data (GTK_OBJECT (items[i]), GINT_TO_POINTER (i)); - gtk_signal_connect (GTK_OBJECT (items[i]), "activate", - (GtkSignalFunc) hour_activated, - omenu); - - gtk_menu_append (GTK_MENU (menu), items[i]); - gtk_widget_show (items[i]); - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), active); - return omenu; -} - -/* Creates the time display page in the preferences dialog */ -static void -create_time_display_page (void) -{ - GtkWidget *table; - GtkWidget *vbox; - GtkWidget *frame; - GtkWidget *hbox2; - GtkWidget *hbox3; - GtkWidget *w; - - table = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL); - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), table, - gtk_label_new (_("Time display"))); - - /* Time format */ - - w = build_two_radio_group (_("Time format"), - _("12-hour (AM/PM)"), &time_format_12, - _("24-hour"), &time_format_24, - am_pm_flag); - gtk_table_attach (GTK_TABLE (table), w, - 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - - /* Weeks start on */ - - w = build_two_radio_group (_("Weeks start on"), - _("Sunday"), &start_on_sunday, - _("Monday"), &start_on_monday, - !week_starts_on_monday); - gtk_table_attach (GTK_TABLE (table), w, - 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - - /* Day range */ - - frame = gtk_frame_new (_("Day range")); - gtk_table_attach (GTK_TABLE (table), frame, - 1, 2, 0, 2, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - w = gtk_label_new (_("Please select the start and end hours you want\n" - "to be displayed in the day view and week view.\n" - "Times outside this range will not be displayed\n" - "by default.")); - gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - - hbox2 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0); - - /* Day start */ - - hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0); - - w = gtk_label_new (_("Day start:")); - gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0); - - start_omenu = build_hours_menu (start_items, day_begin); - gtk_box_pack_start (GTK_BOX (hbox3), start_omenu, FALSE, FALSE, 0); - - /* Day end */ - - hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0); - - w = gtk_label_new (_("Day end:")); - gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0); - - end_omenu = build_hours_menu (end_items, day_end); - gtk_box_pack_start (GTK_BOX (hbox3), end_omenu, FALSE, FALSE, 0); -} - -/* Called when the canvas for the month item is size allocated. We use this to change the canvas' - * scrolling region and the month item's size. - */ -static void -canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_item_set (month_item, - "width", (double) (allocation->width - 1), - "height", (double) (allocation->height - 1), - NULL); - - gnome_canvas_set_scroll_region (GNOME_CANVAS (widget), - 0, 0, - allocation->width, allocation->height); -} - -/* Returns a color spec based on the color pickers */ -static char * -color_spec_from_picker (int num) -{ - gushort r, g, b; - - gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL); - - return build_color_spec (r, g, b); -} - -/* Callback used to query color information for the properties box */ -static char * -fetch_color_spec (ColorProp propnum, gpointer data) -{ - return color_spec_from_picker (propnum); -} - -/* Marks fake event days in the month item sample */ -static void -fake_mark_days (void) -{ - static int day_nums[] = { 1, 4, 8, 16, 17, 18, 20, 25, 28 }; /* some random days */ - int first_day_index; - int i; - - first_day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), 1); - - for (i = 0; i < (sizeof (day_nums) / sizeof (day_nums[0])); i++) - mark_month_item_index (GNOME_MONTH_ITEM (month_item), first_day_index + day_nums[i] - 1, - fetch_color_spec, NULL); -} - -/* Switches the month item to the current date and highlights the current day's number */ -static void -set_current_day (void) -{ - struct tm tm; - time_t t; - GnomeCanvasItem *item; - int day_index; - - /* Set the date */ - - t = time (NULL); - tm = *localtime (&t); - - gnome_canvas_item_set (month_item, - "year", tm.tm_year + 1900, - "month", tm.tm_mon, - NULL); - - /* Highlight current day */ - - day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), tm.tm_mday); - item = gnome_month_item_num2child (GNOME_MONTH_ITEM (month_item), GNOME_MONTH_ITEM_DAY_LABEL + day_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_picker (COLOR_PROP_CURRENT_DAY_FG), - "fontset", CURRENT_DAY_FONTSET, - NULL); -} - -/* This is the version of a color spec query function that is appropriate for the preferences dialog */ -static char * -prop_color_func (ColorProp propnum, gpointer data) -{ - return color_spec_from_picker (propnum); -} - -/* Sets the colors of the month item to the current prerences */ -static void -reconfigure_month (void) -{ - colorify_month_item (GNOME_MONTH_ITEM (month_item), prop_color_func, NULL); - fake_mark_days (); - set_current_day (); - - /* Reset prelighting information */ - - month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), fetch_color_spec, NULL); -} - -/* Callback used when a color is changed */ -static void -color_set (void) -{ - reconfigure_month (); - prop_changed (); -} - -/* Creates the colors page in the preferences dialog */ -static void -create_colors_page (void) -{ - GtkWidget *frame; - GtkWidget *hbox; - GtkWidget *table; - GtkWidget *w; - int i; - - frame = gtk_frame_new (_("Colors for display")); - gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame, - gtk_label_new (_("Colors"))); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - table = gtk_table_new (COLOR_PROP_LAST, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); - - /* Create the color pickers */ - - for (i = 0; i < COLOR_PROP_LAST; i++) { - /* Label */ - - w = gtk_label_new (_(color_props[i].label)); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), w, - 0, 1, i, i + 1, - GTK_FILL, 0, - 0, 0); - - /* Color picker */ - - color_pickers[i] = gnome_color_picker_new (); - gnome_color_picker_set_title (GNOME_COLOR_PICKER (color_pickers[i]), _(color_props[i].label)); - gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (color_pickers[i]), - color_props[i].r, color_props[i].g, color_props[i].b, 0); - gtk_table_attach (GTK_TABLE (table), color_pickers[i], - 1, 2, i, i + 1, - 0, 0, - 0, 0); - gtk_signal_connect (GTK_OBJECT (color_pickers[i]), "color_set", - (GtkSignalFunc) color_set, - NULL); - } - - /* Create the sample calendar */ - - w = gnome_canvas_new (); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - - month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (w))); - gnome_canvas_item_set (month_item, - "start_on_monday", week_starts_on_monday, - NULL); - reconfigure_month (); - - gtk_signal_connect (GTK_OBJECT (w), "size_allocate", - canvas_size_allocate, - NULL); - -} - - -static void -set_todo_page_options(void) -{ - - - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -static void -todo_option_set (void) -{ - prop_changed (); - set_todo_page_options (); -} - -/* Creates the colors page in the preferences dialog */ -static GtkWidget * -build_list_options_frame(void) -{ - GtkWidget *frame; - GtkWidget *vbox; - frame = gtk_frame_new (_("Show on TODO List:")); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - due_date_show_button = gtk_check_button_new_with_label (_("Due Date")); - priority_show_button = gtk_check_button_new_with_label (_("Priority")); - todo_item_time_remaining_show_button = gtk_check_button_new_with_label (_("Time Until Due")); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date); - gtk_signal_connect (GTK_OBJECT(due_date_show_button), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_time_remaining_show_button), todo_show_time_remaining); - gtk_signal_connect (GTK_OBJECT(todo_item_time_remaining_show_button), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), todo_item_time_remaining_show_button, FALSE, FALSE, 0); - - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(priority_show_button), todo_show_priority); - gtk_signal_connect (GTK_OBJECT(priority_show_button), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), priority_show_button, FALSE, FALSE, 0); - return frame; -} -static GtkWidget * -build_style_list_options_frame(void) -{ - GtkWidget *frame; - GtkWidget *vbox; - - frame = gtk_frame_new (_("To Do List style options:")); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - todo_item_highlight_overdue = gtk_check_button_new_with_label (_("Highlight overdue items")); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_overdue), - todo_item_dstatus_highlight_overdue); - todo_item_highlight_not_due_yet = gtk_check_button_new_with_label (_("Highlight not yet due items")); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet), - todo_item_dstatus_highlight_overdue); - todo_item_highlight_due_today = gtk_check_button_new_with_label (_("Highlight items due today")); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_due_today), - todo_item_dstatus_highlight_overdue); - - gtk_signal_connect (GTK_OBJECT(todo_item_highlight_overdue), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_signal_connect (GTK_OBJECT(todo_item_highlight_not_due_yet), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_signal_connect (GTK_OBJECT(todo_item_highlight_due_today), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - - gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_overdue, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_due_today, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_not_due_yet, FALSE, FALSE, 0); - return frame; -} -static void -create_todo_page (void) -{ - GtkWidget *frame; - GtkWidget *main_box; - GtkWidget *hbox; - - - frame = gtk_frame_new (_("To Do List Properties")); - gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame, - gtk_label_new (_("To Do List"))); - - /* first vbox*/ - main_box = gtk_vbox_new(FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), main_box); - - - /* first hbox*/ - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (main_box), hbox); - - gtk_box_pack_start (GTK_BOX(hbox), build_list_options_frame(), FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(hbox), build_style_list_options_frame(), FALSE, FALSE, 0); - - set_todo_page_options(); -} - -/* Creates and displays the preferences dialog for the whole application */ -void -properties (GtkWidget *toplevel) -{ - static GnomeHelpMenuEntry help_entry = { NULL, "properties" }; - - help_entry.name = gnome_app_id; - - if (prop_win) - return; - - prop_win = gnome_property_box_new (); - gtk_window_set_title (GTK_WINDOW (prop_win), _("Preferences")); - gnome_dialog_set_parent (GNOME_DIALOG (prop_win), - GTK_WINDOW (gtk_widget_get_toplevel (toplevel))); - - create_time_display_page (); - create_colors_page (); - create_todo_page (); - create_alarm_page (); - - gtk_signal_connect (GTK_OBJECT (prop_win), "destroy", - (GtkSignalFunc) prop_cancel, NULL); - - gtk_signal_connect (GTK_OBJECT (prop_win), "delete_event", - (GtkSignalFunc) prop_cancel, NULL); - - gtk_signal_connect (GTK_OBJECT (prop_win), "apply", - (GtkSignalFunc) prop_apply, NULL); - - gtk_signal_connect (GTK_OBJECT (prop_win), "help", - GTK_SIGNAL_FUNC (gnome_help_pbox_display), - &help_entry); - - gtk_widget_show_all (prop_win); -} - -char * -build_color_spec (int r, int g, int b) -{ - static char spec[100]; - - sprintf (spec, "#%04x%04x%04x", r, g, b); - return spec; -} - -void -parse_color_spec (char *spec, int *r, int *g, int *b) -{ - g_return_if_fail (spec != NULL); - g_return_if_fail (r != NULL); - g_return_if_fail (r != NULL); - g_return_if_fail (r != NULL); - - if (sscanf (spec, "#%04x%04x%04x", r, g, b) != 3) { - g_warning ("Invalid color specification %s, returning black", spec); - - *r = *g = *b = 0; - } -} - -char * -color_spec_from_prop (ColorProp propnum) -{ - return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b); -} - -static void -create_alarm_page (void) -{ - GtkWidget *main_box; - GtkWidget *default_frame; - GtkWidget *default_table; - GtkWidget *misc_frame; - GtkWidget *misc_box; - GtkWidget *box, *l; - - main_box = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), - main_box, gtk_label_new (_("Alarms"))); - - /* build miscellaneous box */ - misc_frame = gtk_frame_new (_("Alarm Properties")); - gtk_container_set_border_width (GTK_CONTAINER (misc_frame), - GNOME_PAD_SMALL); - misc_box = gtk_vbox_new (FALSE, GNOME_PAD); - - gtk_container_set_border_width (GTK_CONTAINER (misc_frame), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (misc_frame), misc_box); - - gtk_box_pack_start (GTK_BOX (main_box), misc_frame, FALSE, FALSE, 0); - - enable_display_beep = gtk_check_button_new_with_label (_("Beep on display alarms")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_display_beep), - beep_on_display); - gtk_box_pack_start (GTK_BOX (misc_box), enable_display_beep, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (enable_display_beep), "toggled", - (GtkSignalFunc) prop_changed, - NULL); - - /* audio timeout widgets */ - box = gtk_hbox_new (FALSE, GNOME_PAD); - to_cb = gtk_check_button_new_with_label (_("Audio alarms timeout after")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (to_cb), - enable_aalarm_timeout); - gtk_signal_connect (GTK_OBJECT (to_cb), "toggled", - (GtkSignalFunc) to_cb_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), to_cb, FALSE, FALSE, 0); - to_spin = make_spin_button (audio_alarm_timeout, 1, MAX_AALARM_TIMEOUT); - gtk_widget_set_sensitive (to_spin, enable_aalarm_timeout); - gtk_signal_connect (GTK_OBJECT (to_spin), "changed", - (GtkSignalFunc) prop_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), to_spin, FALSE, FALSE, 0); - l = gtk_label_new (_(" seconds")); - gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0); - - /* snooze widgets */ - box = gtk_hbox_new (FALSE, GNOME_PAD); - snooze_cb = gtk_check_button_new_with_label (_("Enable snoozing for ")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (snooze_cb), - enable_snooze); - gtk_signal_connect (GTK_OBJECT (snooze_cb), "toggled", - (GtkSignalFunc) snooze_cb_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), snooze_cb, FALSE, FALSE, 0); - snooze_spin = make_spin_button (snooze_secs, 1, MAX_SNOOZE_SECS); - gtk_widget_set_sensitive (snooze_spin, enable_snooze); - gtk_signal_connect (GTK_OBJECT (snooze_spin), "changed", - (GtkSignalFunc) prop_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), snooze_spin, FALSE, FALSE, 0); - l = gtk_label_new (_(" seconds")); - gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0); - - /* populate default frame/box */ - default_frame = gtk_frame_new (_("Defaults")); - gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (main_box), default_frame, FALSE, FALSE, 0); - default_table = gtk_table_new (1, 1, 0); - gtk_container_set_border_width (GTK_CONTAINER (default_table), 4); - gtk_table_set_row_spacings (GTK_TABLE (default_table), 4); - gtk_table_set_col_spacings (GTK_TABLE (default_table), 4); - gtk_container_add (GTK_CONTAINER (default_frame), default_table); - -#warning "FIX ME" - /* - ee_create_ae (GTK_TABLE (default_table), _("Display"), - &alarm_defaults [ALARM_DISPLAY], ALARM_DISPLAY, 1, - FALSE, prop_changed); - ee_create_ae (GTK_TABLE (default_table), _("Audio"), - &alarm_defaults [ALARM_AUDIO], ALARM_AUDIO, 2, - FALSE, prop_changed); - ee_create_ae (GTK_TABLE (default_table), _("Program"), - &alarm_defaults [ALARM_PROGRAM], ALARM_PROGRAM, 3, - FALSE, prop_changed); - ee_create_ae (GTK_TABLE (default_table), _("Mail"), - &alarm_defaults [ALARM_MAIL], ALARM_MAIL, 4, - FALSE, prop_changed); - */ -} - -static void -prop_store_alarm_default_values (CalendarAlarm* alarm) -{ -#warning "FIX ME" - // ee_store_alarm (alarm, alarm->type); - - switch (alarm->type) { - case ALARM_DISPLAY: - gnome_config_push_prefix ("/calendar/alarms/def_disp_"); - break; - case ALARM_AUDIO: - gnome_config_push_prefix ("/calendar/alarms/def_audio_"); - break; - case ALARM_PROGRAM: - gnome_config_push_prefix ("/calendar/alarms/def_prog_"); - break; - case ALARM_MAIL: - gnome_config_push_prefix ("/calendar/alarms/def_mail_"); - break; - } - - gnome_config_set_int ("enabled", alarm->enabled); - gnome_config_set_int ("count", alarm->count); - gnome_config_set_int ("units", alarm->units); - if (alarm->data) - gnome_config_set_string ("data", alarm->data); - - gnome_config_pop_prefix (); - gnome_config_sync (); -} - -#if 0 -static void -prop_apply_alarms () -{ - int i; - for (i=0; i < 4; i++) - prop_store_alarm_default_values (&alarm_defaults [i]); - - beep_on_display = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enable_display_beep)); - gnome_config_set_bool ("/calendar/alarms/beep_on_display", beep_on_display); - enable_aalarm_timeout = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); - gnome_config_set_bool ("/calendar/alarms/enable_audio_timeout", enable_aalarm_timeout); - audio_alarm_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (to_spin)); - gnome_config_set_int ("/calendar/alarms/audio_alarm_timeout", audio_alarm_timeout); - enable_snooze = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb)); - gnome_config_set_bool ("/calendar/alarms/enable_snooze", enable_snooze); - snooze_secs = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (snooze_spin)); - gnome_config_set_int ("/calendar/alarms/snooze_secs", snooze_secs); - - gnome_config_sync(); -} -#endif - -static void -to_cb_changed (GtkWidget *object, gpointer data) -{ - gboolean active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); - gtk_widget_set_sensitive (to_spin, active); - prop_changed (); -} - -static void -snooze_cb_changed (GtkWidget *object, gpointer data) -{ - gboolean active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb)); - gtk_widget_set_sensitive (snooze_spin, active); - prop_changed (); -} - - diff --git a/calendar/gui/recur.xpm b/calendar/gui/recur.xpm deleted file mode 100644 index 49836b62e7..0000000000 --- a/calendar/gui/recur.xpm +++ /dev/null @@ -1,83 +0,0 @@ -/* XPM */ -static char * recur_xpm[] = { -"16 16 64 1", -" c None", -". c #350000", -"+ c #2A0000", -"@ c #1B0000", -"# c #280000", -"$ c #430000", -"% c #090000", -"& c #160000", -"* c #250000", -"= c #460000", -"- c #550000", -"; c #610000", -"> c #0D0000", -", c #1F0000", -"' c #4B0000", -") c #5E0000", -"! c #6B0000", -"~ c #750000", -"{ c #790000", -"] c #810000", -"^ c #FFFF83", -"/ c #FFFF89", -"( c #FFFF93", -"_ c #8B0000", -": c #900000", -"< c #930000", -"[ c #FFFF62", -"} c #A10000", -"| c #FFFF41", -"1 c #FFFF3B", -"2 c #FFFF31", -"3 c #B70000", -"4 c #B20000", -"5 c #AE0000", -"6 c #FFFF22", -"7 c #FFFF16", -"8 c #FFFF06", -"9 c #C90000", -"0 c #C10000", -"a c #BB0000", -"b c #FFF600", -"c c #FFE100", -"d c #FFC500", -"e c #E40000", -"f c #D70000", -"g c #CD0000", -"h c #FFDB00", -"i c #FFA900", -"j c #FF8500", -"k c #FF5900", -"l c #FF2800", -"m c #FC0000", -"n c #ED0000", -"o c #E10000", -"p c #FFAF00", -"q c #FF9400", -"r c #FF7400", -"s c #FF5000", -"t c #FF0100", -"u c #F30000", -"v c #E80000", -"w c #FF6900", -"x c #FF4900", -"y c #FF0800", -" ", -" . ", -" +. ", -" @#.$ ", -" %&*.=-; ", -" >,.')!~ ", -" &. !{] ", -" ^/( . _:< ", -" [[[ }}} ", -" |12 345 ", -" 678 90a ", -" bcd efg ", -" hdijklmnof ", -" pqrsltuv ", -" wxly ", -" "}; diff --git a/calendar/gui/task-assigned-to.xpm b/calendar/gui/task-assigned-to.xpm deleted file mode 100644 index f5b0ab6f25..0000000000 --- a/calendar/gui/task-assigned-to.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_assigned_to_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/task-assigned.xpm b/calendar/gui/task-assigned.xpm deleted file mode 100644 index 89faae95f1..0000000000 --- a/calendar/gui/task-assigned.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_assigned_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/task-recurring.xpm b/calendar/gui/task-recurring.xpm deleted file mode 100644 index b3c6126e03..0000000000 --- a/calendar/gui/task-recurring.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_recurring_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/task.xpm b/calendar/gui/task.xpm deleted file mode 100644 index 8115025e20..0000000000 --- a/calendar/gui/task.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf deleted file mode 100644 index bfe93b3c14..0000000000 --- a/calendar/gui/test.vcf +++ /dev/null @@ -1,133 +0,0 @@ -BEGIN:VCALENDAR -PRODID:-//GNOME//NONSGML GnomeCalendar//EN -TZ:MST -VERSION:0.13 -BEGIN:VEVENT -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980601T150000 -DTEND:19980601T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Cada dos dias de 06/01 al 07/01 -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D2 19980701T140000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T140000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:5 dias. -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980429T004635 -SUMMARY:Diariamente de 05/01 al 06/01 -STATUS:NEEDS ACTION -CLASS:PRIVATE -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 19980601T000000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VTODO -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980415T140000 -DUE:19691231T180000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Normal -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T120000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semanal -- 4 semanas -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 WE #4 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T003000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semana: Mi, Ju, Vi, Dom (10 veces) -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 SU WE TH FR #10 -END:VTODO - -END:VCALENDAR - diff --git a/calendar/gui/test2.vcf b/calendar/gui/test2.vcf deleted file mode 100644 index 6446507989..0000000000 --- a/calendar/gui/test2.vcf +++ /dev/null @@ -1,133 +0,0 @@ -BEGIN:VCALENDAR -PRODID:-//GNOME//NONSGML GnomeCalendar//EN -TZ:MST -VERSION:0.13 -BEGIN:VEVENT -UID:KOrganizer - 8469308861 -SEQUENCE:1 -DTSTART:19980601T150000 -DTEND:19980601T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Cada dos dias de 06/01 al 07/01 -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D2 19980701T140000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 8469308862 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T140000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:5 dias. -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 8469308863 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980429T004635 -SUMMARY:Diariamente de 05/01 al 06/01 -STATUS:NEEDS ACTION -CLASS:PRIVATE -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 19980601T000000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 18042893834 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 18042893835 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VTODO -UID:KOrganizer - 8469308866 -SEQUENCE:1 -DTSTART:19980415T140000 -DUE:19691231T180000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Normal -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 18042893837 -SEQUENCE:1 -DTSTART:19980415T120000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semanal -- 4 semanas -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 WE #4 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 18042893838 -SEQUENCE:1 -DTSTART:19980415T003000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semana: Mi, Ju, Vi, Dom (10 veces) -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 SU WE TH FR #10 -END:VTODO - -END:VCALENDAR - diff --git a/calendar/gui/topic.dat b/calendar/gui/topic.dat deleted file mode 100644 index edc7813b26..0000000000 --- a/calendar/gui/topic.dat +++ /dev/null @@ -1,2 +0,0 @@ -gnome-cal.html Manual -gnome-cal.html#cmdline Command line options
\ No newline at end of file diff --git a/calendar/gui/weekview.xpm b/calendar/gui/weekview.xpm deleted file mode 100644 index f4900856eb..0000000000 --- a/calendar/gui/weekview.xpm +++ /dev/null @@ -1,41 +0,0 @@ -/* XPM */ -static char * weekview_xpm[] = { -"24 24 14 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #E3E4F5", -"$ c #8B90C3", -"% c #AAAFE2", -"& c #C7CAEB", -"* c #4550B5", -"= c #555FC5", -"- c #2E3BB1", -"; c #0010A8", -"> c #BABBCC", -", c #A3A6C7", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++@+#$%%$%+@++@++. ", -" .++@++@+&*==-;+@++@++. ", -" .@@@@@@@@@@@$;@@@@@@@. ", -" .++@++@++@+%;%+@++@++. ", -" .++@++@++@+%;%+@++@++. ", -" .@@@@@@@@@@-->@@@@@@@. ", -" .++@++@++@+;*++@++@++. ", -" .++@++@++@+;*++@++@++. ", -" .@@@@@@@@@@$,@@@@@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/gui/workweekview.xpm b/calendar/gui/workweekview.xpm deleted file mode 100644 index f47061589c..0000000000 --- a/calendar/gui/workweekview.xpm +++ /dev/null @@ -1,43 +0,0 @@ -/* XPM */ -static char * workweekview_xpm[] = { -"24 24 16 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #E3E4F5", -"$ c #8B90C3", -"% c #AAAFE2", -"& c #0010A8", -"* c #3945BB", -"= c #555FC5", -"- c #4550B5", -"; c #727ACE", -"> c #C7CAEB", -", c #2E3BB1", -"' c #5D66BA", -") c #BABBCC", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++@+#$%%$%+@++@++. ", -" .++@++@+%&*=-=+@++@++. ", -" .@@@@@@@$&$@@@@@@@@@@. ", -" .++@++@+%&;%$#+@++@++. ", -" .++@++@+>-==,;+@++@++. ", -" .@@@@@@@@@@@$&@@@@@@@. ", -" .++@++@+#$#+$&+@++@++. ", -" .++@++@+>,;%'*+@++@++. ", -" .@@@@@@@@)$$$)@@@@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/gui/yearview.xpm b/calendar/gui/yearview.xpm deleted file mode 100644 index 9629150417..0000000000 --- a/calendar/gui/yearview.xpm +++ /dev/null @@ -1,45 +0,0 @@ -/* XPM */ -static char * yearview_xpm[] = { -"24 24 18 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #BABBCC", -"$ c #AAAFE2", -"% c #8B90C3", -"& c #E3E4F5", -"* c #C7CAEB", -"= c #5D66BA", -"- c #3945BB", -"; c #555FC5", -"> c #2E3BB1", -", c #727ACE", -"' c #4550B5", -") c #0010A8", -"! c #A3A6C7", -"~ c #8E95D8", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++#$$%&+@*$%&&%$$%$+. ", -" .+&=-;>,+#-;'*$)-;';+. ", -" .@%)%@%)!>=@@@%)%@@@@. ", -" .++@*$=-$),$%&$),$%&+. ", -" .++@~;>,$)-;>,*';;>,+. ", -" .@@@@@%)%)%@%)@@@@%)@. ", -" .+$)$+%)$)$+%)&%&+%)+. ", -" .+*>,$=-*>,$=-*>,$=-+. ", -" .@@#%%%#@#%%%#@#%%%#@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/idl/.cvsignore b/calendar/idl/.cvsignore deleted file mode 100644 index b840c21800..0000000000 --- a/calendar/idl/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile
\ No newline at end of file diff --git a/calendar/idl/Makefile.am b/calendar/idl/Makefile.am deleted file mode 100644 index ec6b4e45f0..0000000000 --- a/calendar/idl/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -idldir = $(datadir)/idl - -idl_DATA = \ - evolution-calendar.idl - -EXTRA_DIST = \ - $(idl_DATA) diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl deleted file mode 100644 index 4b9b9a7b34..0000000000 --- a/calendar/idl/evolution-calendar.idl +++ /dev/null @@ -1,181 +0,0 @@ -/* Evolution calendar interface - * - * Copyright (C) 2000 Eskil Heyn Olsen - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Eskil Heyn Olsen <deity@eskil.dk> - * Federico Mena-Quintero <federico@helixcode.com> - */ - -#ifndef _EVOLUTION_CALENDAR_IDL_ -#define _EVOLUTION_CALENDAR_IDL_ - -#include <Bonobo.idl> - -module Evolution { - -module Calendar { - /* A calendar object (event/todo/journal/etc), represented as an - * iCalendar string. - */ - typedef string CalObj; - - /* An unique identifier for a calendar object */ - typedef string CalObjUID; - - /* Sequence of unique identifiers */ - typedef sequence<CalObjUID> CalObjUIDSeq; - - /* Flags for getting UID sequences */ - typedef long CalObjType; - const CalObjType TYPE_EVENT = 1 << 0; - const CalObjType TYPE_TODO = 1 << 1; - const CalObjType TYPE_JOURNAL = 1 << 2; - const CalObjType TYPE_ANY = 0x07; - - /* Types of alarms */ - enum AlarmType { - MAIL, - PROGRAM, - DISPLAY, - AUDIO - }; - - /* Used to store a time_t */ - typedef unsigned long Time_t; - - /* Used to store pilot IDs */ - typedef unsigned long PilotID; - - /* An instance of a calendar object that actually occurs. These are - * "virtual" objects in that they are used to represent instances of - * recurring events and alarms. "Real" objects just contain the - * information required to figure out the times at which they recur or - * trigger. - */ - struct CalObjInstance { - CalObjUID uid; - Time_t start; - Time_t end; - }; - - typedef sequence<CalObjInstance> CalObjInstanceSeq; - - /* An alarm trigger instance */ - struct CalAlarmInstance { - CalObjUID uid; - AlarmType type; - Time_t trigger; - Time_t occur; - }; - - typedef sequence<CalAlarmInstance> CalAlarmInstanceSeq; - - interface Listener; - - /* Calendar client interface */ - interface Cal : Bonobo::Unknown { - exception NotFound {}; - exception InvalidRange {}; - exception InvalidObject {}; - - /* A calendar is identified by its URI */ - readonly attribute string uri; - - /* Gets the number of objects of the specified types */ - long get_n_objects (in CalObjType type); - - /* Gets an object based on its URI */ - CalObj get_object (in CalObjUID uid) - raises (NotFound); - - /* Gets a list of UIDs based on object type */ - CalObjUIDSeq get_uids (in CalObjType type); - - /* Gets a list of objects that occur or recur in the specified time range */ - CalObjUIDSeq get_objects_in_range (in CalObjType type, - in Time_t start, in Time_t end) - raises (InvalidRange); - - /* Gets the objects whose alarms trigger in the specified time - * range. - */ - CalAlarmInstanceSeq get_alarms_in_range (in Time_t start, in Time_t end) - raises (InvalidRange); - - /* Gets the alarms for the specified object that trigger in the - * specified time range. - */ - CalAlarmInstanceSeq get_alarms_for_object (in CalObjUID uid, - in Time_t start, in Time_t end) - raises (NotFound, InvalidRange); - - - /* something - * - */ - CalObjUID get_uid_by_pilot_id (in PilotID pilotid) - raises (NotFound); - - - /* - * update_pilot_id: - * @uid: Unique identifier for the event we want to update - * @pilot_id: new ID assigned by the pilot - * @pilot_status: Status to flag the event with - */ - void update_pilot_id (in CalObjUID uid, in PilotID pilot_id, in unsigned long pilot_status) - raises (NotFound); - - /* Updates an object by adding it if it does not exist or by - * changing an existing one. - */ - void update_object (in CalObjUID uid, in CalObj calobj) - raises (InvalidObject); - - /* Removes an object */ - void remove_object (in CalObjUID uid) - raises (NotFound); - }; - - /* Listener for changes in a calendar */ - interface Listener : Bonobo::Unknown { - /* Return status when loading a calendar; we need better error reporting */ - enum LoadStatus { - SUCCESS, /* All OK */ - ERROR, /* Generic error */ - IN_USE, /* Requested create while a calendar - * with the same URI was in use. - */ - METHOD_NOT_SUPPORTED /* A method handler is not registered */ - }; - - /* Called from a CalFactory when a calendar is initially loaded - * or created. The listener must remember the cal object. - */ - void cal_loaded (in LoadStatus status, in Cal cal); - - /* Called from a Calendar when an object is added or changed */ - void obj_updated (in CalObjUID uid); - - /* Called from a Calendar when an object is removed */ - void obj_removed (in CalObjUID uid); - }; - - /* A calendar factory, can load and create calendars */ - interface CalFactory : Bonobo::Unknown { - exception NilListener {}; - - /* Load a calendar from an URI */ - void load (in string uri, in Listener listener) - raises (NilListener); - - /* Create a new calendar at the specified URI */ - void create (in string uri, in Listener listener) - raises (NilListener); - }; -}; - -}; - -#endif diff --git a/calendar/pcs/.cvsignore b/calendar/pcs/.cvsignore deleted file mode 100644 index 7250bfdff6..0000000000 --- a/calendar/pcs/.cvsignore +++ /dev/null @@ -1,12 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -.pure -*.la -*.lo -evolution-calendar-stubs.c -evolution-calendar-skels.c -evolution-calendar-common.c -evolution-calendar.h -icalendar-test diff --git a/calendar/pcs/Makefile.am b/calendar/pcs/Makefile.am deleted file mode 100644 index b435b90229..0000000000 --- a/calendar/pcs/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"wombat-pcs\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_srcdir)/libical/src/libical \ - -I$(top_builddir)/libical/src/libical \ - $(BONOBO_VFS_GNOME_CFLAGS) \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" - -CORBA_GENERATED = \ - evolution-calendar.h \ - evolution-calendar-common.c \ - evolution-calendar-skels.c \ - evolution-calendar-stubs.c - -idls = \ - $(srcdir)/../idl/evolution-calendar.idl - -idl_flags = `$(GNOME_CONFIG) --cflags idl` -I $(datadir)/idl - -$(CORBA_GENERATED): $(idls) - $(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/evolution-calendar.idl - -noinst_LIBRARIES = libpcs.a - -libpcs_a_SOURCES = \ - $(CORBA_GENERATED) \ - cal.c \ - cal.h \ - cal-backend.c \ - cal-backend.h \ - cal-backend-file.c \ - cal-backend-file.h \ - cal-common.h \ - cal-factory.c \ - cal-factory.h \ - job.c \ - job.h - - -BUILT_SOURCES = $(CORBA_GENERATED) -CLEANFILES += $(BUILT_SOURCES) diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c deleted file mode 100644 index 5e74689095..0000000000 --- a/calendar/pcs/cal-backend-file.c +++ /dev/null @@ -1,1056 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include "cal-util/cal-recur.h" -#include "cal-backend-file.h" - - - -/* Private part of the CalBackendFile structure */ -struct _CalBackendFilePrivate { - /* URI where the calendar data is stored */ - GnomeVFSURI *uri; - - /* List of Cal objects with their listeners */ - GList *clients; - - /* Toplevel VCALENDAR component */ - icalcomponent *icalcomp; - - /* All the CalComponent objects in the calendar, hashed by UID. The - * hash key *is* the uid returned by cal_component_get_uid(); it is not - * copied, so don't free it when you remove an object from the hash - * table. - */ - GHashTable *comp_uid_hash; - - /* All event, to-do, and journal components in the calendar; they are - * here just for easy access (i.e. so that you don't have to iterate - * over the comp_uid_hash). If you need *all* the components in the - * calendar, iterate over the hash instead. - */ - GList *events; - GList *todos; - GList *journals; - - /* Idle handler for saving the calendar when it is dirty */ - guint idle_id; -}; - - - -static void cal_backend_file_class_init (CalBackendFileClass *class); -static void cal_backend_file_init (CalBackendFile *cbfile); -static void cal_backend_file_destroy (GtkObject *object); - -static GnomeVFSURI *cal_backend_file_get_uri (CalBackend *backend); -static void cal_backend_file_add_cal (CalBackend *backend, Cal *cal); -static CalBackendLoadStatus cal_backend_file_load (CalBackend *backend, GnomeVFSURI *uri); -static void cal_backend_file_create (CalBackend *backend, GnomeVFSURI *uri); - -static int cal_backend_file_get_n_objects (CalBackend *backend, CalObjType type); -static char *cal_backend_file_get_object (CalBackend *backend, const char *uid); -static GList *cal_backend_file_get_uids (CalBackend *backend, CalObjType type); -static GList *cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type, - time_t start, time_t end); -static GList *cal_backend_file_get_alarms_in_range (CalBackend *backend, time_t start, time_t end); -static gboolean cal_backend_file_get_alarms_for_object (CalBackend *backend, const char *uid, - time_t start, time_t end, - GList **alarms); -static gboolean cal_backend_file_update_object (CalBackend *backend, const char *uid, - const char *calobj); -static gboolean cal_backend_file_remove_object (CalBackend *backend, const char *uid); -static char *cal_backend_file_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id); -static void cal_backend_file_update_pilot_id (CalBackend *backend, - const char *uid, - unsigned long int pilot_id, - unsigned long int pilot_status); - - -static CalBackendClass *parent_class; - - - -/** - * cal_backend_file_get_type: - * @void: - * - * Registers the #CalBackendFile class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendFile class. - **/ -GtkType -cal_backend_file_get_type (void) -{ - static GtkType cal_backend_file_type = 0; - - if (!cal_backend_file_type) { - static const GtkTypeInfo cal_backend_file_info = { - "CalBackendFile", - sizeof (CalBackendFile), - sizeof (CalBackendFileClass), - (GtkClassInitFunc) cal_backend_file_class_init, - (GtkObjectInitFunc) cal_backend_file_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_backend_file_type = gtk_type_unique (CAL_BACKEND_TYPE, &cal_backend_file_info); - } - - return cal_backend_file_type; -} - -/* Class initialization function for the file backend */ -static void -cal_backend_file_class_init (CalBackendFileClass *class) -{ - GtkObjectClass *object_class; - CalBackendClass *backend_class; - - object_class = (GtkObjectClass *) class; - backend_class = (CalBackendClass *) class; - - parent_class = gtk_type_class (CAL_BACKEND_TYPE); - - object_class->destroy = cal_backend_file_destroy; - - backend_class->get_uri = cal_backend_file_get_uri; - backend_class->add_cal = cal_backend_file_add_cal; - backend_class->load = cal_backend_file_load; - backend_class->create = cal_backend_file_create; - backend_class->get_n_objects = cal_backend_file_get_n_objects; - backend_class->get_object = cal_backend_file_get_object; - backend_class->get_uids = cal_backend_file_get_uids; - backend_class->get_objects_in_range = cal_backend_file_get_objects_in_range; - backend_class->get_alarms_in_range = cal_backend_file_get_alarms_in_range; - backend_class->get_alarms_for_object = cal_backend_file_get_alarms_for_object; - backend_class->update_object = cal_backend_file_update_object; - backend_class->remove_object = cal_backend_file_remove_object; - backend_class->get_uid_by_pilot_id = cal_backend_file_get_uid_by_pilot_id; - backend_class->update_pilot_id = cal_backend_file_update_pilot_id; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_file_init (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - - priv = g_new0 (CalBackendFilePrivate, 1); - cbfile->priv = priv; -} - -/* g_hash_table_foreach() callback to destroy a CalComponent */ -static void -free_cal_component (gpointer key, gpointer value, gpointer data) -{ - CalComponent *comp; - - comp = CAL_COMPONENT (value); - gtk_object_unref (GTK_OBJECT (comp)); -} - -/* Saves the calendar data */ -static void -save (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - - priv = cbfile->priv; - g_assert (priv->uri != NULL); - g_assert (priv->icalcomp != NULL); - - /* FIXME */ - - /* FIXME: ensure we have the mandatory PRODID and VERSION properties, and throw - * in CALSCALE for good measure. - */ -} - -/* Destroy handler for the file backend */ -static void -cal_backend_file_destroy (GtkObject *object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE (object)); - - cbfile = CAL_BACKEND_FILE (object); - priv = cbfile->priv; - - g_assert (priv->clients == NULL); - - /* Save if necessary */ - - if (priv->idle_id != 0) { - save (cbfile); - g_source_remove (priv->idle_id); - priv->idle_id = 0; - } - - /* Clean up */ - - if (priv->uri) { - gnome_vfs_uri_unref (priv->uri); - priv->uri = NULL; - } - - if (priv->comp_uid_hash) { - g_hash_table_foreach (priv->comp_uid_hash, free_cal_component, NULL); - g_hash_table_destroy (priv->comp_uid_hash); - priv->comp_uid_hash = NULL; - } - - g_list_free (priv->events); - g_list_free (priv->todos); - g_list_free (priv->journals); - - priv->events = NULL; - priv->todos = NULL; - priv->journals = NULL; - - if (priv->icalcomp) { - icalcomponent_free (priv->icalcomp); - priv->icalcomp = NULL; - } - - g_free (priv); - cbfile->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* Looks up a component by its UID on the backend's component hash table */ -static CalComponent * -lookup_component (CalBackendFile *cbfile, const char *uid) -{ - CalBackendFilePrivate *priv; - CalComponent *comp; - - priv = cbfile->priv; - comp = g_hash_table_lookup (priv->comp_uid_hash, uid); - - return comp; -} - - - -/* Calendar backend methods */ - -/* Get_uri handler for the file backend */ -static GnomeVFSURI * -cal_backend_file_get_uri (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - g_assert (priv->uri != NULL); - - return priv->uri; -} - -/* Callback used when a Cal is destroyed */ -static void -cal_destroy_cb (GtkObject *object, gpointer data) -{ - Cal *cal; - Cal *lcal; - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - GList *l; - - cal = CAL (object); - - cbfile = CAL_BACKEND_FILE (data); - priv = cbfile->priv; - - /* Find the cal in the list of clients */ - - for (l = priv->clients; l; l = l->next) { - lcal = CAL (l->data); - - if (lcal == cal) - break; - } - - g_assert (l != NULL); - - /* Disconnect */ - - priv->clients = g_list_remove_link (priv->clients, l); - g_list_free_1 (l); - - /* When all clients go away, notify the parent factory about it so that - * it may decide whether to kill the backend or not. - */ - if (!priv->clients) - cal_backend_last_client_gone (CAL_BACKEND (cbfile)); -} - -/* Add_cal handler for the file backend */ -static void -cal_backend_file_add_cal (CalBackend *backend, Cal *cal) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_if_fail (priv->icalcomp != NULL); - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - /* We do not keep a reference to the Cal since the calendar user agent - * owns it. - */ - - gtk_signal_connect (GTK_OBJECT (cal), "destroy", - GTK_SIGNAL_FUNC (cal_destroy_cb), - backend); - - priv->clients = g_list_prepend (priv->clients, cal); -} - -/* Idle handler; we save the calendar since it is dirty */ -static gboolean -save_idle (gpointer data) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (data); - priv = cbfile->priv; - - g_assert (priv->icalcomp != NULL); - - save (cbfile); - - priv->idle_id = 0; - return FALSE; -} - -/* Marks the file backend as dirty and queues a save operation */ -static void -mark_dirty (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - - priv = cbfile->priv; - - if (priv->idle_id != 0) - return; - - priv->idle_id = g_idle_add (save_idle, cbfile); -} - -/* Checks if the specified component has a duplicated UID and if so changes it */ -static void -check_dup_uid (CalBackendFile *cbfile, CalComponent *comp) -{ - CalBackendFilePrivate *priv; - CalComponent *old_comp; - const char *uid; - char *new_uid; - - priv = cbfile->priv; - - cal_component_get_uid (comp, &uid); - - old_comp = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!old_comp) - return; /* Everything is fine */ - - g_message ("check_dup_uid(): Got object with duplicated UID `%s', changing it...", uid); - - new_uid = cal_component_gen_uid (); - cal_component_set_uid (comp, new_uid); - g_free (new_uid); - - /* FIXME: I think we need to reset the SEQUENCE property and reset the - * CREATED/DTSTAMP/LAST-MODIFIED. - */ - - mark_dirty (cbfile); -} - -/* Tries to add an icalcomponent to the file backend. We only store the objects - * of the types we support; all others just remain in the toplevel component so - * that we don't lose them. - */ -static void -add_component (CalBackendFile *cbfile, CalComponent *comp) -{ - CalBackendFilePrivate *priv; - GList **list; - const char *uid; - - priv = cbfile->priv; - - switch (cal_component_get_vtype (comp)) { - case CAL_COMPONENT_EVENT: - list = &priv->events; - break; - - case CAL_COMPONENT_TODO: - list = &priv->todos; - break; - - case CAL_COMPONENT_JOURNAL: - list = &priv->journals; - break; - - default: - g_assert_not_reached (); - return; - } - - /* Ensure that the UID is unique; some broken implementations spit - * components with duplicated UIDs. - */ - - check_dup_uid (cbfile, comp); - cal_component_get_uid (comp, &uid); - - g_hash_table_insert (priv->comp_uid_hash, (char *) uid, comp); - *list = g_list_prepend (*list, comp); -} - -/* Removes a component from the backend's hash and lists. Does not perform - * notification on the clients. - */ -static void -remove_component (CalBackendFile *cbfile, CalComponent *comp) -{ - CalBackendFilePrivate *priv; - const char *uid; - GList **list, *l; - - priv = cbfile->priv; - - cal_component_get_uid (comp, &uid); - g_hash_table_remove (priv->comp_uid_hash, uid); - - switch (cal_component_get_vtype (comp)) { - case CAL_COMPONENT_EVENT: - list = &priv->events; - break; - - case CAL_COMPONENT_TODO: - list = &priv->todos; - break; - - case CAL_COMPONENT_JOURNAL: - list = &priv->journals; - break; - - default: - /* Make the compiler shut up. */ - list = NULL; - g_assert_not_reached (); - } - - l = g_list_find (*list, comp); - g_assert (l != NULL); - - *list = g_list_remove_link (*list, l); - g_list_free_1 (l); - - gtk_object_unref (GTK_OBJECT (comp)); -} - -/* Scans the toplevel VCALENDAR component and stores the objects it finds */ -static void -scan_vcalendar (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - - priv = cbfile->priv; - g_assert (priv->icalcomp != NULL); - g_assert (priv->comp_uid_hash != NULL); - - for (icalcomp = icalcomponent_get_first_component (priv->icalcomp, ICAL_ANY_COMPONENT); - icalcomp; - icalcomp = icalcomponent_get_next_component (priv->icalcomp, ICAL_ANY_COMPONENT)) { - icalcomponent_kind kind; - CalComponent *comp; - - kind = icalcomponent_isa (icalcomp); - - if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT)) - continue; - - comp = cal_component_new (); - - if (!cal_component_set_icalcomponent (comp, icalcomp)) - continue; - - add_component (cbfile, comp); - } -} - -/* Callback used from icalparser_parse() */ -static char * -get_line (char *s, size_t size, void *data) -{ - FILE *file; - - file = data; - return fgets (s, size, file); -} - -/* Load handler for the file backend */ -static CalBackendLoadStatus -cal_backend_file_load (CalBackend *backend, GnomeVFSURI *uri) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - char *str_uri; - FILE *file; - icalparser *parser; - icalcomponent *icalcomp; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp == NULL, CAL_BACKEND_LOAD_ERROR); - g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR); - - /* FIXME: this looks rather bad; maybe we should check for local files - * and fail if they are remote. - */ - - str_uri = gnome_vfs_uri_to_string (uri, - (GNOME_VFS_URI_HIDE_USER_NAME - | GNOME_VFS_URI_HIDE_PASSWORD - | GNOME_VFS_URI_HIDE_HOST_NAME - | GNOME_VFS_URI_HIDE_HOST_PORT - | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); - - /* Load! */ - - file = fopen (str_uri, "r"); - g_free (str_uri); - - if (!file) - return CAL_BACKEND_LOAD_ERROR; - - parser = icalparser_new (); - icalparser_set_gen_data (parser, file); - - icalcomp = icalparser_parse (parser, get_line); - icalparser_free (parser); - - if (fclose (file) != 0) - return CAL_BACKEND_LOAD_ERROR; - - if (!icalcomp) - return CAL_BACKEND_LOAD_ERROR; - - /* FIXME: should we try to demangle XROOT components and individual - * components as well? - */ - - if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) - return CAL_BACKEND_LOAD_ERROR; - - priv->icalcomp = icalcomp; - - priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - scan_vcalendar (cbfile); - - /* Clean up */ - - gnome_vfs_uri_ref (uri); - priv->uri = uri; - - return CAL_BACKEND_LOAD_SUCCESS; -} - -/* Create handler for the file backend */ -static void -cal_backend_file_create (CalBackend *backend, GnomeVFSURI *uri) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalproperty *prop; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_if_fail (priv->icalcomp == NULL); - g_return_if_fail (uri != NULL); - - /* Create the new calendar information */ - - g_assert (priv->icalcomp == NULL); - priv->icalcomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT); - - /* RFC 2445, section 4.7.1 */ - prop = icalproperty_new_calscale ("GREGORIAN"); - icalcomponent_add_property (priv->icalcomp, prop); - - /* RFC 2445, section 4.7.3 */ - prop = icalproperty_new_prodid ("-//Helix Code//NONSGML Evolution Calendar//EN"); - icalcomponent_add_property (priv->icalcomp, prop); - - /* RFC 2445, section 4.7.4 */ - prop = icalproperty_new_version ("2.0"); - icalcomponent_add_property (priv->icalcomp, prop); - - /* Create our internal data */ - - g_assert (priv->comp_uid_hash == NULL); - priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - - /* Done */ - - gnome_vfs_uri_ref (uri); - - priv->uri = uri; - - mark_dirty (cbfile); -} - -/* Get_n_objects handler for the file backend */ -static int -cal_backend_file_get_n_objects (CalBackend *backend, CalObjType type) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - int n; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, -1); - - n = 0; - - if (type & CALOBJ_TYPE_EVENT) - n += g_list_length (priv->events); - - if (type & CALOBJ_TYPE_TODO) - n += g_list_length (priv->todos); - - if (type & CALOBJ_TYPE_JOURNAL) - n += g_list_length (priv->journals); - - return n; -} - -/* Get_object handler for the file backend */ -static char * -cal_backend_file_get_object (CalBackend *backend, const char *uid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - CalComponent *comp; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (uid != NULL, NULL); - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - g_assert (priv->comp_uid_hash != NULL); - - comp = lookup_component (cbfile, uid); - - if (!comp) - return NULL; - - return cal_component_get_as_string (comp); -} - -/* Builds a list of UIDs from a list of CalComponent objects */ -static void -build_uids_list (GList **list, GList *components) -{ - GList *l; - - for (l = components; l; l = l->next) { - CalComponent *comp; - const char *uid; - - comp = CAL_COMPONENT (l->data); - cal_component_get_uid (comp, &uid); - *list = g_list_prepend (*list, g_strdup (uid)); - } -} - -/* Get_uids handler for the file backend */ -static GList * -cal_backend_file_get_uids (CalBackend *backend, CalObjType type) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - GList *list; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - list = NULL; - - if (type & CALOBJ_TYPE_EVENT) - build_uids_list (&list, priv->events); - - if (type & CALOBJ_TYPE_TODO) - build_uids_list (&list, priv->todos); - - if (type & CALOBJ_TYPE_JOURNAL) - build_uids_list (&list, priv->journals); - - return list; -} - -/* Callback used from cal_recur_generate_instances(); adds the component's UID - * to our hash table. - */ -static gboolean -add_instance (CalComponent *comp, time_t start, time_t end, gpointer data) -{ - GHashTable *uid_hash; - const char *uid; - const char *old_uid; - - uid_hash = data; - - /* We only care that the component's UID is listed in the hash table; - * that's why we only allow generation of one instance (i.e. return - * FALSE every time). - */ - - cal_component_get_uid (comp, &uid); - - old_uid = g_hash_table_lookup (uid_hash, uid); - if (old_uid) - return FALSE; - - g_hash_table_insert (uid_hash, (char *) uid, NULL); - return FALSE; -} - -/* Populates a hash table with the UIDs of the components that occur or recur - * within a specific time range. - */ -static void -get_instances_in_range (GHashTable *uid_hash, GList *components, time_t start, time_t end) -{ - GList *l; - - for (l = components; l; l = l->next) { - CalComponent *comp; - - comp = CAL_COMPONENT (l->data); - cal_recur_generate_instances (comp, start, end, add_instance, uid_hash); - } -} - -/* Used from g_hash_table_foreach(), adds a UID from the hash table to our list */ -static void -add_uid_to_list (gpointer key, gpointer value, gpointer data) -{ - GList **list; - const char *uid; - char *uid_copy; - - list = data; - - uid = key; - uid_copy = g_strdup (uid); - - *list = g_list_prepend (*list, uid_copy); -} - -/* Get_objects_in_range handler for the file backend */ -static GList * -cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type, - time_t start, time_t end) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - GList *event_list; - GHashTable *uid_hash; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - - if (type & CALOBJ_TYPE_EVENT) - get_instances_in_range (uid_hash, priv->events, start, end); - - if (type & CALOBJ_TYPE_TODO) - get_instances_in_range (uid_hash, priv->todos, start, end); - - if (type & CALOBJ_TYPE_JOURNAL) - get_instances_in_range (uid_hash, priv->journals, start, end); - - event_list = NULL; - g_hash_table_foreach (uid_hash, add_uid_to_list, &event_list); - g_hash_table_destroy (uid_hash); - - return event_list; -} - -/* Get_alarms_in_range handler for the file backend */ -static GList * -cal_backend_file_get_alarms_in_range (CalBackend *backend, time_t start, time_t end) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - /* FIXME: have to deal with an unknown number of alarms; we can't just - * do the same thing as in cal-backend-imc. - */ - return NULL; -} - -/* Get_alarms_for_object handler for the file backend */ -static gboolean -cal_backend_file_get_alarms_for_object (CalBackend *backend, const char *uid, - time_t start, time_t end, - GList **alarms) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (start != -1 && end != -1, FALSE); - g_return_val_if_fail (start <= end, FALSE); - g_return_val_if_fail (alarms != NULL, FALSE); - - /* FIXME */ - - *alarms = NULL; - return FALSE; -} - -/* Notifies a backend's clients that an object was updated */ -static void -notify_update (CalBackendFile *cbfile, const char *uid) -{ - CalBackendFilePrivate *priv; - GList *l; - - priv = cbfile->priv; - - for (l = priv->clients; l; l = l->next) { - Cal *cal; - - cal = CAL (l->data); - cal_notify_update (cal, uid); - } -} - -/* Notifies a backend's clients that an object was removed */ -static void -notify_remove (CalBackendFile *cbfile, const char *uid) -{ - CalBackendFilePrivate *priv; - GList *l; - - priv = cbfile->priv; - - for (l = priv->clients; l; l = l->next) { - Cal *cal; - - cal = CAL (l->data); - cal_notify_remove (cal, uid); - } -} - -/* Update_object handler for the file backend */ -static gboolean -cal_backend_file_update_object (CalBackend *backend, const char *uid, const char *calobj) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - CalComponent *old_comp; - CalComponent *comp; - const char *comp_uid; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (calobj != NULL, FALSE); - - /* Pull the component from the string and ensure that it is sane */ - - icalcomp = icalparser_parse_string ((char *) calobj); - - if (!icalcomp) - return FALSE; - - kind = icalcomponent_isa (icalcomp); - - if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT)) { - /* We don't support this type of component */ - icalcomponent_free (icalcomp); - return FALSE; - } - - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { - gtk_object_unref (GTK_OBJECT (comp)); - icalcomponent_free (icalcomp); - return FALSE; - } - - /* Check the UID for sanity's sake */ - - cal_component_get_uid (comp, &comp_uid); - - if (strcmp (uid, comp_uid) != 0) { - gtk_object_unref (GTK_OBJECT (comp)); - return FALSE; - } - - /* Update the component */ - - old_comp = lookup_component (cbfile, uid); - - if (old_comp) - remove_component (cbfile, old_comp); - - add_component (cbfile, comp); -#if 0 - /* FIXME */ - new_ico->pilot_status = ICAL_PILOT_SYNC_MOD; -#endif - - mark_dirty (cbfile); - - /* FIXME: do the notification asynchronously */ - notify_update (cbfile, comp_uid); - - return TRUE; -} - -/* Remove_object handler for the file backend */ -static gboolean -cal_backend_file_remove_object (CalBackend *backend, const char *uid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - CalComponent *comp; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - - comp = lookup_component (cbfile, uid); - if (!comp) - return FALSE; - - remove_component (cbfile, comp); - - mark_dirty (cbfile); - - /* FIXME: do the notification asynchronously */ - notify_remove (cbfile, uid); - - return TRUE; -} - -/* Get_uid_by_pilot_id handler for the file backend */ -static char * -cal_backend_file_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - /* FIXME */ - return NULL; -} - -/* Update_pilot_id handler for the file backend */ -static void -cal_backend_file_update_pilot_id (CalBackend *backend, - const char *uid, - unsigned long int pilot_id, - unsigned long int pilot_status) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_if_fail (priv->icalcomp != NULL); - - g_return_if_fail (uid != NULL); - - /* FIXME */ -} diff --git a/calendar/pcs/cal-backend-file.h b/calendar/pcs/cal-backend-file.h deleted file mode 100644 index 376790751c..0000000000 --- a/calendar/pcs/cal-backend-file.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_FILE_H -#define CAL_BACKEND_FILE_H - -#include <libgnome/gnome-defs.h> -#include "cal-backend.h" - -BEGIN_GNOME_DECLS - - - -#define CAL_BACKEND_FILE_TYPE (cal_backend_file_get_type ()) -#define CAL_BACKEND_FILE(obj) (GTK_CHECK_CAST ((obj), CAL_BACKEND_FILE_TYPE, \ - CalBackendFile)) -#define CAL_BACKEND_FILE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_BACKEND_FILE_TYPE, \ - CalBackendFileClass)) -#define IS_CAL_BACKEND_FILE(obj) (GTK_CHECK_TYPE ((obj), CAL_BACKEND_FILE_TYPE)) -#define IS_CAL_BACKEND_FILE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_FILE_TYPE)) - -typedef struct _CalBackendFile CalBackendFile; -typedef struct _CalBackendFileClass CalBackendFileClass; - -typedef struct _CalBackendFilePrivate CalBackendFilePrivate; - -struct _CalBackendFile { - CalBackend backend; - - /* Private data */ - CalBackendFilePrivate *priv; -}; - -struct _CalBackendFileClass { - CalBackendClass parent_class; -}; - -GtkType cal_backend_file_get_type (void); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-imc.c b/calendar/pcs/cal-backend-imc.c deleted file mode 100644 index d50fc0d347..0000000000 --- a/calendar/pcs/cal-backend-imc.c +++ /dev/null @@ -1,1421 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - Internet Mail Consortium formats backend - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Federico Mena-Quintero <federico@helixcode.com> - * Seth Alves <alves@helixcode.com> - * Miguel de Icaza <miguel@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include "cal-backend-imc.h" -#include "cal-util/icalendar.h" - - - -/* Supported calendar formats from the IMC */ -typedef enum { - CAL_FORMAT_UNKNOWN, - CAL_FORMAT_VCALENDAR, - CAL_FORMAT_ICALENDAR -} CalendarFormat; - -/* Private part of the CalBackendIMC structure */ -typedef struct { - /* URI where the calendar data is stored */ - GnomeVFSURI *uri; - - /* Format of this calendar (iCalendar or vCalendar) */ - CalendarFormat format; - - /* List of Cal objects with their listeners */ - GList *clients; - - /* All the iCalObject structures in the calendar, hashed by UID. The - * hash key *is* icalobj->uid; it is not copied, so don't free it when - * you remove an object from the hash table. - */ - GHashTable *object_hash; - - /* All events, TODOs, and journals in the calendar */ - GList *events; - GList *todos; - GList *journals; - - /* Whether a calendar has been loaded */ - guint loaded : 1; - - /* Do we need to sync to permanent storage? */ - gboolean dirty : 1; -} IMCPrivate; - - - -static void cal_backend_imc_class_init (CalBackendIMCClass *class); -static void cal_backend_imc_init (CalBackendIMC *bimc); -static void cal_backend_imc_destroy (GtkObject *object); - -static GnomeVFSURI *cal_backend_imc_get_uri (CalBackend *backend); -static void cal_backend_imc_add_cal (CalBackend *backend, Cal *cal); -static CalBackendLoadStatus cal_backend_imc_load (CalBackend *backend, GnomeVFSURI *uri); -static void cal_backend_imc_create (CalBackend *backend, GnomeVFSURI *uri); - -static int cal_backend_imc_get_n_objects (CalBackend *backend, CalObjType type); -static char *cal_backend_imc_get_object (CalBackend *backend, const char *uid); -static GList *cal_backend_imc_get_uids (CalBackend *backend, CalObjType type); -static GList *cal_backend_imc_get_events_in_range (CalBackend *backend, time_t start, time_t end); -static GList *cal_backend_imc_get_alarms_in_range (CalBackend *backend, time_t start, time_t end); -static gboolean cal_backend_imc_get_alarms_for_object (CalBackend *backend, const char *uid, - time_t start, time_t end, - GList **alarms); -static gboolean cal_backend_imc_update_object (CalBackend *backend, const char *uid, - const char *calobj); -static gboolean cal_backend_imc_remove_object (CalBackend *backend, const char *uid); -static char *cal_backend_imc_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id); -static void cal_backend_imc_update_pilot_id (CalBackend *backend, - const char *uid, - unsigned long int pilot_id, - unsigned long int pilot_status); - - - -static void notify_update (CalBackendIMC *cbimc, const char *uid); - -static CalBackendClass *parent_class; - - - -/** - * cal_backend_imc_get_type: - * @void: - * - * Registers the #CalBackendIMC class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendIMC class. - **/ -GtkType -cal_backend_imc_get_type (void) -{ - static GtkType cal_backend_imc_type = 0; - - if (!cal_backend_imc_type) { - static const GtkTypeInfo cal_backend_imc_info = { - "CalBackendIMC", - sizeof (CalBackendIMC), - sizeof (CalBackendIMCClass), - (GtkClassInitFunc) cal_backend_imc_class_init, - (GtkObjectInitFunc) cal_backend_imc_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_backend_imc_type = gtk_type_unique (CAL_BACKEND_TYPE, &cal_backend_imc_info); - } - - return cal_backend_imc_type; -} - -/* Class initialization function for the IMC backend */ -static void -cal_backend_imc_class_init (CalBackendIMCClass *class) -{ - GtkObjectClass *object_class; - CalBackendClass *backend_class; - - object_class = (GtkObjectClass *) class; - backend_class = (CalBackendClass *) class; - - parent_class = gtk_type_class (CAL_BACKEND_TYPE); - - backend_class->get_uri = cal_backend_imc_get_uri; - backend_class->add_cal = cal_backend_imc_add_cal; - backend_class->load = cal_backend_imc_load; - backend_class->create = cal_backend_imc_create; - backend_class->get_n_objects = cal_backend_imc_get_n_objects; - backend_class->get_object = cal_backend_imc_get_object; - backend_class->get_uids = cal_backend_imc_get_uids; - backend_class->get_events_in_range = cal_backend_imc_get_events_in_range; - backend_class->get_alarms_in_range = cal_backend_imc_get_alarms_in_range; - backend_class->get_alarms_for_object = cal_backend_imc_get_alarms_for_object; - backend_class->update_object = cal_backend_imc_update_object; - backend_class->remove_object = cal_backend_imc_remove_object; - backend_class->get_uid_by_pilot_id = cal_backend_imc_get_uid_by_pilot_id; - backend_class->update_pilot_id = cal_backend_imc_update_pilot_id; - - object_class->destroy = cal_backend_imc_destroy; -} - -/* Object initialization function for the IMC backend */ -static void -cal_backend_imc_init (CalBackendIMC *cbimc) -{ - IMCPrivate *priv; - - priv = g_new0 (IMCPrivate, 1); - cbimc->priv = priv; - - priv->format = CAL_FORMAT_UNKNOWN; -} - -static void -save_to_vcal (CalBackendIMC *cbimc, char *fname) -{ - FILE *fp; - IMCPrivate *priv; - VObject *vcal; - GList *l; - - priv = cbimc->priv; - - if (g_file_exists (fname)) { - char *backup_name = g_strconcat (fname, "~", NULL); - - /* FIXME: do error checking on system calls!!!! */ - - if (g_file_exists (backup_name)) - unlink (backup_name); - - rename (fname, backup_name); - g_free (backup_name); - } - - vcal = newVObject (VCCalProp); - addPropValue (vcal, VCProdIdProp, - "-//Helix Code//NONSGML Evolution Calendar//EN"); - - /* Per the vCalendar spec, this must be "1.0" */ - addPropValue (vcal, VCVersionProp, "1.0"); - - /* FIXME: this should really iterate over the object hash table instead - * of the lists; that way we won't lose objects if they are of a type - * that we don't support but are in the calendar anyways. - */ - - for (l = priv->events; l; l = l->next) { - iCalObject *ical = l->data; - VObject *vobject = ical_object_to_vobject (ical); - addVObjectProp (vcal, vobject); - } - - for (l = priv->todos; l; l = l->next) { - iCalObject *ical = l->data; - VObject *vobject = ical_object_to_vobject (ical); - addVObjectProp (vcal, vobject); - } - - for (l = priv->journals; l; l = l->next) { - iCalObject *ical = l->data; - VObject *vobject = ical_object_to_vobject (ical); - addVObjectProp (vcal, vobject); - } - - fp = fopen(fname,"w"); - if (fp) { - writeVObject(fp, vcal); - fclose(fp); - } - cleanVObject (vcal); - cleanStrTbl (); -} - -/* Saves a calendar */ -static void -save (CalBackendIMC *cbimc) -{ - char *str_uri; - IMCPrivate *priv = cbimc->priv; - - str_uri = gnome_vfs_uri_to_string (priv->uri, - (GNOME_VFS_URI_HIDE_USER_NAME - | GNOME_VFS_URI_HIDE_PASSWORD - | GNOME_VFS_URI_HIDE_HOST_NAME - | GNOME_VFS_URI_HIDE_HOST_PORT - | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); - - if (!priv->dirty) - return; - - switch (priv->format) { - case CAL_FORMAT_VCALENDAR: - save_to_vcal (cbimc, str_uri); - break; - - case CAL_FORMAT_ICALENDAR: - /*icalendar_calendar_save (cbimc, str_uri);*/ - /* FIX ME */ - break; - - default: - g_message ("save(): Attempt to save a calendar with an unknown format!"); - break; - } - - printf ("cal-backend-imc: '%s' saved\n", str_uri); - - g_free (str_uri); -} - -/* g_hash_table_foreach() callback to destroy an iCalObject */ -static void -free_ical_object (gpointer key, gpointer value, gpointer data) -{ - iCalObject *ico; - - ico = value; - ical_object_unref (ico); -} - -/* Destroys an IMC backend's data */ -static void -destroy (CalBackendIMC *cbimc) -{ - IMCPrivate *priv; - - priv = cbimc->priv; - - if (priv->uri) { - gnome_vfs_uri_unref (priv->uri); - priv->uri = NULL; - } - - g_assert (priv->clients == NULL); - - if (priv->object_hash) { - g_hash_table_foreach (priv->object_hash, free_ical_object, NULL); - g_hash_table_destroy (priv->object_hash); - priv->object_hash = NULL; - } - - g_list_free (priv->events); - g_list_free (priv->todos); - g_list_free (priv->journals); - - priv->events = NULL; - priv->todos = NULL; - priv->journals = NULL; - - priv->loaded = FALSE; - priv->format = CAL_FORMAT_UNKNOWN; -} - -/* Destroy handler for the IMC backend */ -static void -cal_backend_imc_destroy (GtkObject *object) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_IMC (object)); - - cbimc = CAL_BACKEND_IMC (object); - priv = cbimc->priv; - - /* - if (priv->loaded) - save (cbimc); - */ - - destroy (cbimc); - - g_free (priv); - cbimc->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* iCalObject manipulation functions */ - -/* Looks up an object by its UID in the backend's object hash table */ -static iCalObject * -lookup_object (CalBackendIMC *cbimc, const char *uid) -{ - IMCPrivate *priv; - iCalObject *ico; - - priv = cbimc->priv; - ico = g_hash_table_lookup (priv->object_hash, uid); - - return ico; -} - -/* Ensures that an iCalObject has a unique identifier. If it doesn't have one, - * it will create one for it. - */ -static void -ensure_uid (iCalObject *ico) -{ - char *buf; - gulong str_time; - static guint seqno = 0; - - if (ico->uid) - return; - - str_time = (gulong) time (NULL); - - /* Is this good enough? */ - - buf = g_strdup_printf ("Evolution-Calendar-%d-%ld-%u", - (int) getpid(), str_time, seqno++); - ico->uid = buf; -} - -/* Adds an object to the calendar backend. Does *not* perform notification to - * calendar clients. - */ -static void -add_object (CalBackendIMC *cbimc, iCalObject *ico) -{ - IMCPrivate *priv; - - g_assert (ico != NULL); - - priv = cbimc->priv; - -#if 0 - /* FIXME: gnomecal old code */ - ico->new = 0; -#endif - - ensure_uid (ico); - g_hash_table_insert (priv->object_hash, ico->uid, ico); - - priv->dirty = TRUE; - - switch (ico->type) { - case ICAL_EVENT: - priv->events = g_list_prepend (priv->events, ico); -#if 0 - /* FIXME: gnomecal old code */ - ical_object_try_alarms (ico); -# ifdef DEBUGGING_MAIL_ALARM - ico->malarm.trigger = 0; - calendar_notify (0, ico); -# endif -#endif - break; - - case ICAL_TODO: - priv->todos = g_list_prepend (priv->todos, ico); - break; - - case ICAL_JOURNAL: - priv->journals = g_list_prepend (priv->journals, ico); - break; - - default: - g_assert_not_reached (); - } - -#if 0 - /* FIXME: gnomecal old code */ - ico->last_mod = time (NULL); -#endif -} - -/* Removes an object from the backend's hash and lists. Does not perform - * notification on the clients. - */ -static void -remove_object (CalBackendIMC *cbimc, iCalObject *ico) -{ - IMCPrivate *priv; - GList **list, *l; - - priv = cbimc->priv; - - g_assert (ico->uid != NULL); - g_hash_table_remove (priv->object_hash, ico->uid); - - priv->dirty = TRUE; - - switch (ico->type) { - case ICAL_EVENT: - list = &priv->events; - break; - - case ICAL_TODO: - list = &priv->todos; - break; - - case ICAL_JOURNAL: - list = &priv->journals; - break; - - default: - /* Make the compiler shut up. */ - list = NULL; - g_assert_not_reached (); - } - - l = g_list_find (*list, ico); - g_assert (l != NULL); - - *list = g_list_remove_link (*list, l); - g_list_free_1 (l); - - ical_object_unref (ico); -} - -/* Load a calendar from a VObject */ -static void -load_from_vobject (CalBackendIMC *cbimc, VObject *vobject) -{ - IMCPrivate *priv; - VObjectIterator i; - - priv = cbimc->priv; - - g_assert (!priv->loaded); - g_assert (priv->object_hash == NULL); - priv->object_hash = g_hash_table_new (g_str_hash, g_str_equal); - - initPropIterator (&i, vobject); - - while (moreIteration (&i)) { - VObject *this; - iCalObject *ical; - const char *object_name; - - this = nextVObject (&i); - object_name = vObjectName (this); -#if 0 - /* FIXME? What is this used for in gnomecal? */ - if (strcmp (object_name, VCDCreatedProp) == 0) { - cal->created = time_from_isodate (str_val (this)); - continue; - } -#endif - if (strcmp (object_name, VCLocationProp) == 0) - continue; /* FIXME: imlement */ - - if (strcmp (object_name, VCProdIdProp) == 0) - continue; /* FIXME: implement */ - - if (strcmp (object_name, VCVersionProp) == 0) - continue; /* FIXME: implement */ - - if (strcmp (object_name, VCTimeZoneProp) == 0) - continue; /* FIXME: implement */ - - ical = ical_object_create_from_vobject (this, object_name); - - /* FIXME: some broken files (ahem, old KOrganizer files) may - * have duplicated UIDs. This is Bad(tm). Deal with it by - * creating new UIDs for them and spitting some messages to the - * console. - */ - - if (ical) - add_object (cbimc, ical); - } -} - - - -/* Calendar backend methods */ - -/* Get_uri handler for the IMC backend */ -static GnomeVFSURI * -cal_backend_imc_get_uri (CalBackend *backend) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, NULL); - g_assert (priv->uri != NULL); - - return priv->uri; -} - -/* Callback used when a Cal is destroyed */ -static void -cal_destroy_cb (GtkObject *object, gpointer data) -{ - Cal *cal; - Cal *lcal; - CalBackendIMC *cbimc; - IMCPrivate *priv; - GList *l; - - fprintf (stderr, "cal_destroy_cb(): A Cal was destroyed!\n"); - - cal = CAL (object); - - cbimc = CAL_BACKEND_IMC (data); - priv = cbimc->priv; - - /* Find the cal in the list of clients */ - - for (l = priv->clients; l; l = l->next) { - lcal = CAL (l->data); - - if (lcal == cal) - break; - } - - g_assert (l != NULL); - - /* Disconnect */ - - priv->clients = g_list_remove_link (priv->clients, l); - g_list_free_1 (l); - - /* When all clients go away, notify the parent factory about it so that - * it may decide whether to kill the backend or not. - */ - if (!priv->clients) - cal_backend_last_client_gone (CAL_BACKEND (cbimc)); -} - -/* Add_cal handler for the IMC backend */ -static void -cal_backend_imc_add_cal (CalBackend *backend, Cal *cal) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_if_fail (priv->loaded); - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - /* We do not keep a reference to the Cal since the calendar user agent - * owns it. - */ - - gtk_signal_connect (GTK_OBJECT (cal), "destroy", - GTK_SIGNAL_FUNC (cal_destroy_cb), - backend); - - priv->clients = g_list_prepend (priv->clients, cal); -} - -static icalcomponent * -icalendar_parse_file (char *fname) -{ - FILE *fp; - icalcomponent *comp = NULL; - char *str; - struct stat st; - int n; - - fp = fopen (fname, "r"); - if (!fp) { - /* FIXME: remove message */ - g_message ("icalendar_parse_file(): Cannot open open calendar file."); - return NULL; - } - - stat (fname, &st); - - str = g_malloc (st.st_size + 2); - - n = fread (str, 1, st.st_size, fp); - if (n != st.st_size) { - /* FIXME: remove message, return error code instead */ - g_message ("icalendar_parse_file(): Read error."); - } - str[n] = '\0'; - - fclose (fp); - - comp = icalparser_parse_string (str); - g_free (str); - - return comp; -} - -static void -icalendar_calendar_load (CalBackendIMC *cbimc, char *fname) -{ - IMCPrivate *priv; - icalcomponent *comp; - icalcomponent *subcomp; - iCalObject *ical; - - priv = cbimc->priv; - - g_assert (!priv->loaded); - g_assert (priv->object_hash == NULL); - - priv->object_hash = g_hash_table_new (g_str_hash, g_str_equal); - - comp = icalendar_parse_file (fname); - subcomp = icalcomponent_get_first_component (comp, - ICAL_ANY_COMPONENT); - while (subcomp) { - ical = ical_object_create_from_icalcomponent (subcomp); - if (ical->type != ICAL_EVENT && - ical->type != ICAL_TODO && - ical->type != ICAL_JOURNAL) { - g_message ("icalendar_calendar_load(): Skipping unsupported " - "iCalendar component."); - } else - add_object (cbimc, ical); - - subcomp = icalcomponent_get_next_component (comp, - ICAL_ANY_COMPONENT); - } -} - -/* ics is to be used to designate a file containing (an arbitrary set of) - * calendaring and scheduling information. - * - * ifb is to be used to designate a file containing free or busy time - * information. - * - * anything else is assumed to be a vcal file. - * - * FIXME: should we return UNKNOWN at some point? - */ -static CalendarFormat -cal_get_type_from_filename (char *str_uri) -{ - int len; - - if (str_uri == NULL) - return CAL_FORMAT_VCALENDAR; - - len = strlen (str_uri); - if (len < 4) - return CAL_FORMAT_VCALENDAR; - - if (str_uri[len - 4] == '.' && str_uri[len - 3] == 'i' && - str_uri[len - 2] == 'c' && str_uri[len - 1] == 's') - return CAL_FORMAT_ICALENDAR; - - if (str_uri[len - 4] == '.' && str_uri[len - 3] == 'i' && - str_uri[len - 2] == 'f' && str_uri[len - 1] == 'b') - return CAL_FORMAT_ICALENDAR; - - if (str_uri[len - 4] == '.' && str_uri[len - 3] == 'i' && - str_uri[len - 2] == 'c' && str_uri[len - 1] == 's') - return CAL_FORMAT_ICALENDAR; - - if (len < 5) - return CAL_FORMAT_VCALENDAR; - - if (str_uri[len - 5] == '.' && str_uri[len - 4] == 'i' && - str_uri[len - 3] == 'c' && str_uri[len - 2] == 'a' && - str_uri[len - 1] == 'l') - return CAL_FORMAT_ICALENDAR; - - return CAL_FORMAT_VCALENDAR; -} - -/* Load handler for the IMC backend */ -static CalBackendLoadStatus -cal_backend_imc_load (CalBackend *backend, GnomeVFSURI *uri) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - VObject *vobject; - char *str_uri; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (!priv->loaded, CAL_BACKEND_LOAD_ERROR); - g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR); - - /* FIXME: this looks rather bad; maybe we should check for local files - * and fail if they are remote. - */ - - str_uri = gnome_vfs_uri_to_string (uri, - (GNOME_VFS_URI_HIDE_USER_NAME - | GNOME_VFS_URI_HIDE_PASSWORD - | GNOME_VFS_URI_HIDE_HOST_NAME - | GNOME_VFS_URI_HIDE_HOST_PORT - | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); - - /* look at the extension on the filename and decide if this is a - * iCalendar or vCalendar file. - */ - priv->format = cal_get_type_from_filename (str_uri); - - /* load */ - - switch (priv->format) { - case CAL_FORMAT_VCALENDAR: - vobject = Parse_MIME_FromFileName (str_uri); - - if (!vobject){ - g_free (str_uri); - return CAL_BACKEND_LOAD_ERROR; - } - - load_from_vobject (cbimc, vobject); - cleanVObject (vobject); - cleanStrTbl (); - break; - - case CAL_FORMAT_ICALENDAR: - icalendar_calendar_load (cbimc, str_uri); - break; - - default: - g_free (str_uri); - return CAL_BACKEND_LOAD_ERROR; - } - - g_free (str_uri); - - gnome_vfs_uri_ref (uri); - - priv->uri = uri; - priv->loaded = TRUE; - - return CAL_BACKEND_LOAD_SUCCESS; -} - -/* Create handler for the IMC backend */ -static void -cal_backend_imc_create (CalBackend *backend, GnomeVFSURI *uri) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - char *str_uri; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_if_fail (!priv->loaded); - g_return_if_fail (uri != NULL); - - /* Create the new calendar information */ - - g_assert (priv->object_hash == NULL); - priv->object_hash = g_hash_table_new (g_str_hash, g_str_equal); - - priv->dirty = TRUE; - - /* Done */ - - /* FIXME: this looks rather bad; maybe we should check for local files - * and fail if they are remote. - */ - - str_uri = gnome_vfs_uri_to_string (uri, - (GNOME_VFS_URI_HIDE_USER_NAME - | GNOME_VFS_URI_HIDE_PASSWORD - | GNOME_VFS_URI_HIDE_HOST_NAME - | GNOME_VFS_URI_HIDE_HOST_PORT - | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); - - /* look at the extension on the filename and decide if this is a - * iCalendar or vCalendar file. - */ - priv->format = cal_get_type_from_filename (str_uri); - - g_free (str_uri); - - gnome_vfs_uri_ref (uri); - - priv->uri = uri; - priv->loaded = TRUE; - - save (cbimc); -} - -struct get_n_objects_closure { - CalObjType type; - int n; -}; - -/* Counts the number of objects of the specified type. Called from - * g_hash_table_foreach(). - */ -static void -count_objects (gpointer key, gpointer value, gpointer data) -{ - iCalObject *ico; - struct get_n_objects_closure *c; - gboolean store; - - ico = value; - c = data; - - store = FALSE; - - if (ico->type == ICAL_EVENT) - store = (c->type & CALOBJ_TYPE_EVENT) != 0; - else if (ico->type == ICAL_TODO) - store = (c->type & CALOBJ_TYPE_TODO) != 0; - else if (ico->type == ICAL_JOURNAL) - store = (c->type & CALOBJ_TYPE_JOURNAL) != 0; - - if (store) - c->n++; -} - -/* Get_n_objects handler for the IMC backend */ -static int -cal_backend_imc_get_n_objects (CalBackend *backend, CalObjType type) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - struct get_n_objects_closure c; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, -1); - - c.type = type; - c.n = 0; - - g_hash_table_foreach (priv->object_hash, count_objects, &c); - - return c.n; -} - -/* Get_object handler for the IMC backend */ -static char * -cal_backend_imc_get_object (CalBackend *backend, const char *uid) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - iCalObject *ico; - char *buf; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (uid != NULL, NULL); - - g_return_val_if_fail (priv->loaded, NULL); - g_assert (priv->object_hash != NULL); - - ico = lookup_object (cbimc, uid); - - if (!ico) - return NULL; - - buf = ical_object_to_string (ico); - - return buf; -} - -struct get_uids_closure { - CalObjType type; - GList *uid_list; -}; - -/* Builds a list of UIDs for objects that match the sought type. Called from - * g_hash_table_foreach(). - */ -static void -build_uids_list (gpointer key, gpointer value, gpointer data) -{ - iCalObject *ico; - struct get_uids_closure *c; - gboolean store; - - ico = value; - c = data; - - store = FALSE; - - if (ico->type == ICAL_EVENT) - store = (c->type & CALOBJ_TYPE_EVENT) ? TRUE : FALSE; - else if (ico->type == ICAL_TODO) - store = (c->type & CALOBJ_TYPE_TODO) ? TRUE : FALSE; - else if (ico->type == ICAL_JOURNAL) - store = (c->type & CALOBJ_TYPE_JOURNAL) ? TRUE : FALSE; - - if (store) - c->uid_list = g_list_prepend (c->uid_list, g_strdup (ico->uid)); -} - -/* Get_uids handler for the IMC backend */ -static GList * -cal_backend_imc_get_uids (CalBackend *backend, CalObjType type) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - struct get_uids_closure c; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, NULL); - - c.type = type; - c.uid_list = NULL; - g_hash_table_foreach (priv->object_hash, build_uids_list, &c); - - return c.uid_list; -} - - - -static char * -cal_backend_imc_get_uid_by_pilot_id (CalBackend *backend, - unsigned long int pilot_id) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - GList *l; - iCalObject *obj = NULL; - - g_return_val_if_fail (backend != NULL, NULL); - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - g_return_val_if_fail (priv->loaded, NULL); - - for (l = priv->events; l; l = l->next){ - obj = l->data; - if (obj->pilot_id == pilot_id) - goto done; - } - - for (l = priv->todos; l; l = l->next){ - obj = l->data; - if (obj->pilot_id == pilot_id) - goto done; - } - - done: - if (!obj || obj->pilot_id != pilot_id) - return NULL; - - return g_strdup (obj->uid); -} - - -void -cal_backend_imc_update_pilot_id (CalBackend *backend, - const char *uid, - unsigned long int pilot_id, - unsigned long int pilot_status) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - iCalObject *obj; - - g_return_if_fail (backend != NULL); - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - g_return_if_fail (priv->loaded); - - obj = lookup_object (cbimc, uid); - - obj->pilot_id = pilot_id; - obj->pilot_status = pilot_status; - - save (cbimc); - - notify_update (cbimc, uid); -} - - - -/* Allocates and fills in a new CalObjInstance structure */ -static CalObjInstance * -build_cal_obj_instance (iCalObject *ico, time_t start, time_t end) -{ - CalObjInstance *icoi; - - g_assert (ico->uid != NULL); - - icoi = g_new (CalObjInstance, 1); - icoi->uid = g_strdup (ico->uid); - icoi->start = start; - icoi->end = end; - - return icoi; -} - -struct build_event_list_closure { - CalBackendIMC *cbimc; - GList *event_list; -}; - -/* Builds a sorted list of event object instances. Used as a callback from - * ical_object_generate_events(). - */ -static int -build_event_list (iCalObject *ico, time_t start, time_t end, void *data) -{ - CalObjInstance *icoi; - struct build_event_list_closure *c; - - c = data; - - icoi = build_cal_obj_instance (ico, start, end); - c->event_list = g_list_prepend (c->event_list, icoi); - - return TRUE; -} - -/* Compares two CalObjInstance structures by their start times. Called from - * g_list_sort(). - */ -static gint -compare_instance_func (gconstpointer a, gconstpointer b) -{ - const CalObjInstance *ca, *cb; - time_t diff; - - ca = a; - cb = b; - - diff = ca->start - cb->start; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - -/* Get_events_in_range handler for the IMC backend */ -static GList * -cal_backend_imc_get_events_in_range (CalBackend *backend, time_t start, time_t end) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - struct build_event_list_closure c; - GList *l; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, NULL); - - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - c.cbimc = cbimc; - c.event_list = NULL; - - for (l = priv->events; l; l = l->next) { - iCalObject *ico; - - ico = l->data; - ical_object_generate_events (ico, start, end, - build_event_list, &c); - } - - c.event_list = g_list_sort (c.event_list, compare_instance_func); - return c.event_list; -} - -struct build_alarm_list_closure { - time_t start; - time_t end; - GList *alarms; -}; - -/* Computes the offset in minutes from an alarm trigger to the actual event */ -static int -compute_alarm_offset (CalendarAlarm *a) -{ - int ofs; - - if (!a->enabled) - return -1; - - switch (a->units) { - case ALARM_MINUTES: - ofs = a->count * 60; - break; - - case ALARM_HOURS: - ofs = a->count * 3600; - break; - - case ALARM_DAYS: - ofs = a->count * 24 * 3600; - break; - - default: - ofs = -1; - g_assert_not_reached (); - } - - return ofs; -} - -/* Allocates and fills in a new CalAlarmInstance structure */ -static CalAlarmInstance * -build_cal_alarm_instance (iCalObject *ico, enum AlarmType type, time_t trigger, time_t occur) -{ - CalAlarmInstance *ai; - - g_assert (ico->uid != NULL); - - ai = g_new (CalAlarmInstance, 1); - ai->uid = g_strdup (ico->uid); - ai->type = type; - ai->trigger = trigger; - ai->occur = occur; - - return ai; -} - -/* Adds the specified alarm to the list if its trigger time falls within the - * requested range. - */ -static void -try_add_alarm (time_t occur_start, iCalObject *ico, CalendarAlarm *alarm, - struct build_alarm_list_closure *c) -{ - int ofs; - time_t trigger; - CalAlarmInstance *ai; - - if (!alarm->enabled) - return; - - ofs = compute_alarm_offset (alarm); - g_assert (ofs != -1); - - trigger = occur_start - ofs; - - if (trigger < c->start || trigger > c->end) - return; - - ai = build_cal_alarm_instance (ico, alarm->type, trigger, occur_start); - c->alarms = g_list_prepend (c->alarms, ai); -} - -/* Builds a list of alarm instances. Used as a callback from - * ical_object_generate_events(). - */ -static int -build_alarm_list (iCalObject *ico, time_t start, time_t end, void *data) -{ - struct build_alarm_list_closure *c; - - c = data; - - try_add_alarm (start, ico, &ico->dalarm, c); - try_add_alarm (start, ico, &ico->aalarm, c); - try_add_alarm (start, ico, &ico->palarm, c); - try_add_alarm (start, ico, &ico->malarm, c); - - return TRUE; -} - -/* Adds all the alarm triggers that occur within the specified time range */ -static GList * -add_alarms_for_object (GList *alarms, iCalObject *ico, time_t start, time_t end) -{ - struct build_alarm_list_closure c; - int dofs, aofs, pofs, mofs; - int max_ofs; - - dofs = compute_alarm_offset (&ico->dalarm); - aofs = compute_alarm_offset (&ico->aalarm); - pofs = compute_alarm_offset (&ico->palarm); - mofs = compute_alarm_offset (&ico->malarm); - - max_ofs = MAX (dofs, MAX (aofs, MAX (pofs, mofs))); - if (max_ofs == -1) - return alarms; - - c.start = start; - c.end = end; - c.alarms = alarms; - - ical_object_generate_events (ico, start, end, build_alarm_list, &c); - return c.alarms; -} - -/* Get_alarms_in_range handler for the IMC backend */ -static GList * -cal_backend_imc_get_alarms_in_range (CalBackend *backend, time_t start, time_t end) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - GList *l; - GList *alarms; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, NULL); - - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - /* Only VEVENT and VTODO components can have alarms */ - - alarms = NULL; - - for (l = priv->events; l; l = l->next) - alarms = add_alarms_for_object (alarms, (iCalObject *) l->data, start, end); - - for (l = priv->todos; l; l = l->next) - alarms = add_alarms_for_object (alarms, (iCalObject *) l->data, start, end); - - alarms = g_list_sort (alarms, compare_instance_func); - return alarms; -} - -/* Get_alarms_for_object handler for the IMC backend */ -static gboolean -cal_backend_imc_get_alarms_for_object (CalBackend *backend, const char *uid, - time_t start, time_t end, - GList **alarms) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - iCalObject *ico; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, FALSE); - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (start != -1 && end != -1, FALSE); - g_return_val_if_fail (start <= end, FALSE); - g_return_val_if_fail (alarms != NULL, FALSE); - - *alarms = NULL; - - ico = lookup_object (cbimc, uid); - if (!ico) - return FALSE; - - /* Only VEVENT and VTODO components can have alarms */ - - if (ico->type != ICAL_EVENT && ico->type != ICAL_TODO) - return TRUE; - - *alarms = add_alarms_for_object (*alarms, ico, start, end); - *alarms = g_list_sort (*alarms, compare_instance_func); - - return TRUE; -} - -/* Notifies a backend's clients that an object was updated */ -static void -notify_update (CalBackendIMC *cbimc, const char *uid) -{ - IMCPrivate *priv; - GList *l; - - priv = cbimc->priv; - - for (l = priv->clients; l; l = l->next) { - Cal *cal; - - cal = CAL (l->data); - cal_notify_update (cal, uid); - } -} - -/* Notifies a backend's clients that an object was removed */ -static void -notify_remove (CalBackendIMC *cbimc, const char *uid) -{ - IMCPrivate *priv; - GList *l; - - priv = cbimc->priv; - - for (l = priv->clients; l; l = l->next) { - Cal *cal; - - cal = CAL (l->data); - cal_notify_remove (cal, uid); - } -} - -/* Update_object handler for the IMC backend */ -static gboolean -cal_backend_imc_update_object (CalBackend *backend, const char *uid, const char *calobj) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - iCalObject *ico, *new_ico; - CalObjFindStatus status; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (calobj != NULL, FALSE); - - /* Pull the object from the string */ - - status = ical_object_find_in_string (uid, calobj, &new_ico); - - if (status != CAL_OBJ_FIND_SUCCESS) - return FALSE; - - /* Update the object */ - - ico = lookup_object (cbimc, uid); - - if (ico) - remove_object (cbimc, ico); - - add_object (cbimc, new_ico); - new_ico->pilot_status = ICAL_PILOT_SYNC_MOD; - save (cbimc); - - /* FIXME: do the notification asynchronously */ - - notify_update (cbimc, new_ico->uid); - - return TRUE; -} - -/* Remove_object handler for the IMC backend */ -static gboolean -cal_backend_imc_remove_object (CalBackend *backend, const char *uid) -{ - CalBackendIMC *cbimc; - IMCPrivate *priv; - iCalObject *ico; - - cbimc = CAL_BACKEND_IMC (backend); - priv = cbimc->priv; - - g_return_val_if_fail (priv->loaded, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - - ico = lookup_object (cbimc, uid); - if (!ico) - return FALSE; - - remove_object (cbimc, ico); - - priv->dirty = TRUE; - save (cbimc); - - /* FIXME: do the notification asynchronously */ - notify_remove (cbimc, uid); - - return TRUE; -} diff --git a/calendar/pcs/cal-backend-imc.h b/calendar/pcs/cal-backend-imc.h deleted file mode 100644 index 954bbc52cc..0000000000 --- a/calendar/pcs/cal-backend-imc.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Evolution calendar - Internet Mail Consortium formats backend - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Federico Mena-Quintero <federico@helixcode.com> - * Seth Alves <alves@helixcode.com> - * Miguel de Icaza <miguel@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_IMC_H -#define CAL_BACKEND_IMC_H - -#include <libgnome/gnome-defs.h> -#include "cal-backend.h" - -BEGIN_GNOME_DECLS - - - -#define CAL_BACKEND_IMC_TYPE (cal_backend_imc_get_type ()) -#define CAL_BACKEND_IMC(obj) (GTK_CHECK_CAST ((obj), CAL_BACKEND_IMC_TYPE, CalBackendIMC)) -#define CAL_BACKEND_IMC_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_BACKEND_IMC_TYPE, \ - CalBackendIMCClass)) -#define IS_CAL_BACKEND_IMC(obj) (GTK_CHECK_TYPE ((obj), CAL_BACKEND_IMC_TYPE)) -#define IS_CAL_BACKEND_IMC_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_IMC_TYPE)) - -typedef struct _CalBackendIMC CalBackendIMC; -typedef struct _CalBackendIMCClass CalBackendIMCClass; - -struct _CalBackendIMC { - CalBackend backend; - - /* Private data */ - gpointer priv; -}; - -struct _CalBackendIMCClass { - CalBackendClass parent_class; -}; - -GtkType cal_backend_imc_get_type (void); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c deleted file mode 100644 index e33cedeae8..0000000000 --- a/calendar/pcs/cal-backend.c +++ /dev/null @@ -1,403 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include <cal-util/calobj.h> -#include "cal-backend.h" -#include "libversit/vcc.h" - - - -/* Signal IDs */ -enum { - LAST_CLIENT_GONE, - LAST_SIGNAL -}; - -static void cal_backend_class_init (CalBackendClass *class); - -static GtkObjectClass *parent_class; - -static guint cal_backend_signals[LAST_SIGNAL]; - -#define CLASS(backend) (CAL_BACKEND_CLASS (GTK_OBJECT (backend)->klass)) - - - -/** - * cal_backend_get_type: - * @void: - * - * Registers the #CalBackend class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackend class. - **/ -GtkType -cal_backend_get_type (void) -{ - static GtkType cal_backend_type = 0; - - if (!cal_backend_type) { - static const GtkTypeInfo cal_backend_info = { - "CalBackend", - sizeof (CalBackend), - sizeof (CalBackendClass), - (GtkClassInitFunc) cal_backend_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_backend_type = - gtk_type_unique (GTK_TYPE_OBJECT, &cal_backend_info); - } - - return cal_backend_type; -} - -/* Class initialization function for the calendar backend */ -static void -cal_backend_class_init (CalBackendClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - cal_backend_signals[LAST_CLIENT_GONE] = - gtk_signal_new ("last_client_gone", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalBackendClass, last_client_gone), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, cal_backend_signals, LAST_SIGNAL); -} - - - -/** - * cal_backend_get_uri: - * @backend: A calendar backend. - * - * Queries the URI of a calendar backend, which must already have a loaded - * calendar. - * - * Return value: The URI where the calendar is stored. - **/ -GnomeVFSURI * -cal_backend_get_uri (CalBackend *backend) -{ - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - g_assert (CLASS (backend)->get_uri != NULL); - return (* CLASS (backend)->get_uri) (backend); -} - -/** - * cal_backend_add_cal: - * @backend: A calendar backend. - * @cal: A calendar client interface object. - * - * Adds a calendar client interface object to a calendar @backend. - * The calendar backend must already have a loaded calendar. - **/ -void -cal_backend_add_cal (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->add_cal != NULL); - (* CLASS (backend)->add_cal) (backend, cal); -} - -/** - * cal_backend_load: - * @backend: A calendar backend. - * @uri: URI that contains the calendar data. - * - * Loads a calendar backend with data from a calendar stored at the specified - * URI. - * - * Return value: An operation status code. - **/ -CalBackendLoadStatus -cal_backend_load (CalBackend *backend, GnomeVFSURI *uri) -{ - g_return_val_if_fail (backend != NULL, CAL_BACKEND_LOAD_ERROR); - g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_LOAD_ERROR); - g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR); - - g_assert (CLASS (backend)->load != NULL); - return (* CLASS (backend)->load) (backend, uri); -} - -/** - * cal_backend_create: - * @backend: A calendar backend. - * @uri: URI that will contain the calendar data. - * - * Creates a new empty calendar in a calendar backend. - **/ -void -cal_backend_create (CalBackend *backend, GnomeVFSURI *uri) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uri != NULL); - - g_assert (CLASS (backend)->create != NULL); - (* CLASS (backend)->create) (backend, uri); -} - -/** - * cal_backend_get_n_objects: - * @backend: A calendar backend. - * @type: Types of objects that will be included in the count. - * - * Queries the number of calendar objects of a particular type. - * - * Return value: Number of objects of the specified @type. - **/ -int -cal_backend_get_n_objects (CalBackend *backend, CalObjType type) -{ - g_return_val_if_fail (backend != NULL, -1); - g_return_val_if_fail (IS_CAL_BACKEND (backend), -1); - - g_assert (CLASS (backend)->get_n_objects != NULL); - return (* CLASS (backend)->get_n_objects) (backend, type); -} - -/** - * cal_backend_get_object: - * @backend: A calendar backend. - * @uid: Unique identifier for a calendar object. - * - * Queries a calendar backend for a calendar object based on its unique - * identifier. - * - * Return value: The string representation of a complete calendar wrapping the - * the sought object, or NULL if no object had the specified UID. A complete - * calendar is returned because you also need the timezone data. - **/ -char * -cal_backend_get_object (CalBackend *backend, const char *uid) -{ - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (uid != NULL, NULL); - - g_assert (CLASS (backend)->get_object != NULL); - return (* CLASS (backend)->get_object) (backend, uid); -} - -/** - * cal_backend_get_uids: - * @backend: A calendar backend. - * @type: Bitmask with types of objects to return. - * - * Builds a list of unique identifiers corresponding to calendar objects whose - * type matches one of the types specified in the @type flags. - * - * Return value: A list of strings that are the sought UIDs. The list should be - * freed using the cal_obj_uid_list_free() function. - **/ -GList * -cal_backend_get_uids (CalBackend *backend, CalObjType type) -{ - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - g_assert (CLASS (backend)->get_uids != NULL); - return (* CLASS (backend)->get_uids) (backend, type); -} - -/** - * cal_backend_get_objects_in_range: - * @backend: A calendar backend. - * @type: Bitmask with types of objects to return. - * @start: Start time for query. - * @end: End time for query. - * - * Builds a list of unique identifiers corresponding to calendar objects of the - * specified type that occur or recur within the specified time range. - * - * Return value: A list of UID strings. The list should be freed using the - * cal_obj_uid_list_free() function. - **/ -GList * -cal_backend_get_objects_in_range (CalBackend *backend, CalObjType type, - time_t start, time_t end) -{ - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - g_assert (CLASS (backend)->get_objects_in_range != NULL); - return (* CLASS (backend)->get_objects_in_range) (backend, type, start, end); -} - -/** - * cal_backend_get_alarms_in_range: - * @backend: A calendar backend. - * @start: Start time for query. - * @end: End time for query. - * - * Builds a sorted list of the alarms that trigger in the specified time range. - * - * Return value: A list of #CalAlarmInstance structures, sorted by trigger time. - **/ -GList * -cal_backend_get_alarms_in_range (CalBackend *backend, time_t start, time_t end) -{ - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - g_assert (CLASS (backend)->get_alarms_in_range != NULL); - return (* CLASS (backend)->get_alarms_in_range) (backend, start, end); -} - -/** - * cal_backend_get_alarms_for_object: - * @backend: A calendar backend. - * @uid: Unique identifier for a calendar object. - * @start: Start time for query. - * @end: End time for query. - * @alarms: Return value for the list of alarm instances. - * - * Builds a sorted list of the alarms of the specified event that trigger in a - * particular time range. - * - * Return value: TRUE on success, FALSE if the object was not found. - **/ -gboolean -cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid, - time_t start, time_t end, - GList **alarms) -{ - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (start != -1 && end != -1, FALSE); - g_return_val_if_fail (start <= end, FALSE); - g_return_val_if_fail (alarms != NULL, FALSE); - - g_assert (CLASS (backend)->get_alarms_for_object != NULL); - return (* CLASS (backend)->get_alarms_for_object) (backend, uid, start, end, alarms); -} - - -char *cal_backend_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id) -{ - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - g_assert (CLASS(backend)->get_uid_by_pilot_id != NULL); - return (* CLASS(backend)->get_uid_by_pilot_id) (backend, pilot_id); -} - - -void cal_backend_update_pilot_id (CalBackend *backend, const char *uid, - unsigned long int pilot_id, - unsigned long int pilot_status) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_assert (CLASS(backend)->update_pilot_id != NULL); - (* CLASS(backend)->update_pilot_id) (backend, uid, - pilot_id, pilot_status); -} - - - -/** - * cal_backend_update_object: - * @backend: A calendar backend. - * @uid: Unique identifier of the object to update. - * @calobj: String representation of the new calendar object. - * - * Updates an object in a calendar backend. It will replace any existing - * object that has the same UID as the specified one. The backend will in - * turn notify all of its clients about the change. - * - * Return value: TRUE on success, FALSE on being passed an invalid object or one - * with an unsupported type. - **/ -gboolean -cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj) -{ - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (calobj != NULL, FALSE); - - g_assert (CLASS (backend)->update_object != NULL); - return (* CLASS (backend)->update_object) (backend, uid, calobj); -} - -/** - * cal_backend_remove_object: - * @backend: A calendar backend. - * @uid: Unique identifier of the object to remove. - * - * Removes an object in a calendar backend. The backend will notify all of its - * clients about the change. - * - * Return value: TRUE on success, FALSE on being passed an UID for an object - * that does not exist in the backend. - **/ -gboolean -cal_backend_remove_object (CalBackend *backend, const char *uid) -{ - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - g_return_val_if_fail (uid != NULL, FALSE); - - g_assert (CLASS (backend)->remove_object != NULL); - return (* CLASS (backend)->remove_object) (backend, uid); -} - -/** - * cal_backend_last_client_gone: - * @backend: A calendar backend. - * - * Emits the "last_client_gone" signal of a calendar backend. This function is - * to be used only by backend implementations. - **/ -void -cal_backend_last_client_gone (CalBackend *backend) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - gtk_signal_emit (GTK_OBJECT (backend), cal_backend_signals[LAST_CLIENT_GONE]); -} diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h deleted file mode 100644 index e1122f4d1c..0000000000 --- a/calendar/pcs/cal-backend.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_H -#define CAL_BACKEND_H - -#include <libgnome/gnome-defs.h> -#include <libgnomevfs/gnome-vfs.h> -#include <cal-util/cal-util.h> -#include "calendar/pcs/evolution-calendar.h" -#include "cal-common.h" -#include "cal.h" - -BEGIN_GNOME_DECLS - - - -#define CAL_BACKEND_TYPE (cal_backend_get_type ()) -#define CAL_BACKEND(obj) (GTK_CHECK_CAST ((obj), CAL_BACKEND_TYPE, CalBackend)) -#define CAL_BACKEND_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_BACKEND_TYPE, \ - CalBackendClass)) -#define IS_CAL_BACKEND(obj) (GTK_CHECK_TYPE ((obj), CAL_BACKEND_TYPE)) -#define IS_CAL_BACKEND_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_TYPE)) - -/* Load status values */ -typedef enum { - CAL_BACKEND_LOAD_SUCCESS, /* Loading OK */ - CAL_BACKEND_LOAD_ERROR /* We need better error reporting in libversit */ -} CalBackendLoadStatus; - -struct _CalBackend { - GtkObject object; - - /* Private data */ - gpointer priv; -}; - -struct _CalBackendClass { - GtkObjectClass parent_class; - - /* Notification signals */ - void (* last_client_gone) (CalBackend *backend); - - /* Virtual methods */ - GnomeVFSURI *(* get_uri) (CalBackend *backend); - void (* add_cal) (CalBackend *backend, Cal *cal); - CalBackendLoadStatus (* load) (CalBackend *backend, GnomeVFSURI *uri); - void (* create) (CalBackend *backend, GnomeVFSURI *uri); - - int (* get_n_objects) (CalBackend *backend, CalObjType type); - char *(* get_object) (CalBackend *backend, const char *uid); - GList *(* get_uids) (CalBackend *backend, CalObjType type); - GList *(* get_objects_in_range) (CalBackend *backend, CalObjType type, - time_t start, time_t end); - GList *(* get_alarms_in_range) (CalBackend *backend, time_t start, time_t end); - gboolean (* get_alarms_for_object) (CalBackend *backend, const char *uid, - time_t start, time_t end, - GList **alarms); - gboolean (* update_object) (CalBackend *backend, const char *uid, const char *calobj); - gboolean (* remove_object) (CalBackend *backend, const char *uid); - char *(* get_uid_by_pilot_id) (CalBackend *backend, unsigned long int pilot_id); - void (* update_pilot_id) (CalBackend *backend, const char *uid, - unsigned long int pilot_id, unsigned long int pilot_status); -}; - -GtkType cal_backend_get_type (void); - -GnomeVFSURI *cal_backend_get_uri (CalBackend *backend); - -void cal_backend_add_cal (CalBackend *backend, Cal *cal); - -CalBackendLoadStatus cal_backend_load (CalBackend *backend, GnomeVFSURI *uri); - -void cal_backend_create (CalBackend *backend, GnomeVFSURI *uri); - -int cal_backend_get_n_objects (CalBackend *backend, CalObjType type); - -char *cal_backend_get_object (CalBackend *backend, const char *uid); - -GList *cal_backend_get_uids (CalBackend *backend, CalObjType type); - -GList *cal_backend_get_objects_in_range (CalBackend *backend, CalObjType type, - time_t start, time_t end); - -GList *cal_backend_get_alarms_in_range (CalBackend *backend, time_t start, time_t end); - -gboolean cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid, - time_t start, time_t end, - GList **alarms); - - -gboolean cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj); - -gboolean cal_backend_remove_object (CalBackend *backend, const char *uid); - -void cal_backend_last_client_gone (CalBackend *backend); - -char *cal_backend_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id); - -void cal_backend_update_pilot_id (CalBackend *backend, const char *uid, - unsigned long int pilot_id, - unsigned long int pilot_status); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/pcs/cal-common.h b/calendar/pcs/cal-common.h deleted file mode 100644 index e51ddf1bdd..0000000000 --- a/calendar/pcs/cal-common.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Evolution calendar server - common declarations - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_COMMON_H -#define CAL_COMMON_H - -#include <libgnome/gnome-defs.h> - -BEGIN_GNOME_DECLS - - - -typedef struct _CalBackend CalBackend; -typedef struct _CalBackendClass CalBackendClass; - -typedef struct _Cal Cal; -typedef struct _CalClass CalClass; - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c deleted file mode 100644 index ab19ccb8b3..0000000000 --- a/calendar/pcs/cal-factory.c +++ /dev/null @@ -1,858 +0,0 @@ -/* Evolution calendar factory - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <ctype.h> -#include <stdio.h> -#include <gtk/gtksignal.h> -#include "cal.h" -#include "cal-backend.h" -#include "cal-factory.h" -#include "job.h" - - - -/* Private part of the CalFactory structure */ -typedef struct { - /* Hash table from URI method strings to GtkType * for backend class types */ - GHashTable *methods; - - /* Hash table from GnomeVFSURI structures to CalBackend objects */ - GHashTable *backends; -} CalFactoryPrivate; - - - -/* Signal IDs */ -enum { - LAST_CALENDAR_GONE, - LAST_SIGNAL -}; - -static void cal_factory_class_init (CalFactoryClass *class); -static void cal_factory_init (CalFactory *factory); -static void cal_factory_destroy (GtkObject *object); - -static POA_Evolution_Calendar_CalFactory__vepv cal_factory_vepv; - -static BonoboObjectClass *parent_class; - -static guint cal_factory_signals[LAST_SIGNAL]; - - - -/** - * cal_factory_get_type: - * @void: - * - * Registers the #CalFactory class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalFactory class. - **/ -GtkType -cal_factory_get_type (void) -{ - static GtkType cal_factory_type = 0; - - if (!cal_factory_type) { - static const GtkTypeInfo cal_factory_info = { - "CalFactory", - sizeof (CalFactory), - sizeof (CalFactoryClass), - (GtkClassInitFunc) cal_factory_class_init, - (GtkObjectInitFunc) cal_factory_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_factory_type = gtk_type_unique (bonobo_object_get_type (), &cal_factory_info); - } - - return cal_factory_type; -} - -/* CORBA class initialization function for the calendar factory */ -static void -init_cal_factory_corba_class (void) -{ - cal_factory_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - cal_factory_vepv.Evolution_Calendar_CalFactory_epv = cal_factory_get_epv (); -} - -/* Class initialization function for the calendar factory */ -static void -cal_factory_class_init (CalFactoryClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (bonobo_object_get_type ()); - - cal_factory_signals[LAST_CALENDAR_GONE] = - gtk_signal_new ("last_calendar_gone", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalFactoryClass, last_calendar_gone), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, cal_factory_signals, LAST_SIGNAL); - - object_class->destroy = cal_factory_destroy; - - init_cal_factory_corba_class (); -} - -/* Object initialization function for the calendar factory */ -static void -cal_factory_init (CalFactory *factory) -{ - CalFactoryPrivate *priv; - - priv = g_new0 (CalFactoryPrivate, 1); - factory->priv = priv; - - priv->methods = g_hash_table_new (g_str_hash, g_str_equal); - priv->backends = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal); -} - -/* Frees a method/GtkType * pair from the methods hash table */ -static void -free_method (gpointer key, gpointer value, gpointer data) -{ - char *method; - GtkType *type; - - method = key; - type = value; - - g_free (method); - g_free (type); -} - -/* Frees a uri/backend pair from the backends hash table */ -static void -free_backend (gpointer key, gpointer value, gpointer data) -{ - GnomeVFSURI *uri; - CalBackend *backend; - - uri = key; - backend = value; - - gnome_vfs_uri_unref (uri); - gtk_object_unref (GTK_OBJECT (backend)); -} - -/* Destroy handler for the calendar */ -static void -cal_factory_destroy (GtkObject *object) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_FACTORY (object)); - - factory = CAL_FACTORY (object); - priv = factory->priv; - - g_hash_table_foreach (priv->methods, free_method, NULL); - g_hash_table_destroy (priv->methods); - priv->methods = NULL; - - /* Should we assert that there are no more backends? */ - - g_hash_table_foreach (priv->backends, free_backend, NULL); - g_hash_table_destroy (priv->backends); - priv->backends = NULL; - - g_free (priv); - factory->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* Loading and creating calendars */ - -/* Job data */ -typedef struct { - CalFactory *factory; - char *uri; - Evolution_Calendar_Listener listener; -} LoadCreateJobData; - -/* Queues a load or create request */ -static void -queue_load_create_job (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener, - JobFunc func) -{ - LoadCreateJobData *jd; - CORBA_Environment ev; - Evolution_Calendar_Listener listener_copy; - gboolean result; - - g_assert (uri != NULL); - - CORBA_exception_init (&ev); - result = CORBA_Object_is_nil (listener, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("queue_load_create_job(): could not see if the listener was NIL"); - CORBA_exception_free (&ev); - return; - } - CORBA_exception_free (&ev); - - if (result) { - g_message ("queue_load_create_job(): cannot operate on a NIL listener!"); - return; - } - - listener_copy = CORBA_Object_duplicate (listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("queue_load_create_job(): could not duplicate the listener"); - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); - - jd = g_new (LoadCreateJobData, 1); - jd->factory = factory; - jd->uri = g_strdup (uri); - jd->listener = listener_copy; - - job_add (func, jd); -} - -/* Looks up a calendar backend in a factory's hash table of uri->cal */ -static CalBackend * -lookup_backend (CalFactory *factory, GnomeVFSURI *uri) -{ - CalFactoryPrivate *priv; - CalBackend *backend; - - priv = factory->priv; - - backend = g_hash_table_lookup (priv->backends, uri); - return backend; -} - -/* Callback used when a backend loses its last connected client */ -static void -backend_last_client_gone_cb (CalBackend *backend, gpointer data) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - GnomeVFSURI *uri; - gpointer orig_key; - gboolean result; - GnomeVFSURI *orig_uri; - - fprintf (stderr, "backend_last_client_gone_cb() called!\n"); - - factory = CAL_FACTORY (data); - priv = factory->priv; - - /* Remove the backend from the hash table */ - - uri = cal_backend_get_uri (backend); - g_assert (uri != NULL); - - result = g_hash_table_lookup_extended (priv->backends, uri, &orig_key, NULL); - g_assert (result != FALSE); - - orig_uri = orig_key; - - g_hash_table_remove (priv->backends, orig_uri); - gnome_vfs_uri_unref (orig_uri); - - gtk_object_unref (GTK_OBJECT (backend)); - - /* Notify upstream if there are no more backends */ - - if (g_hash_table_size (priv->backends) == 0) - gtk_signal_emit (GTK_OBJECT (factory), cal_factory_signals[LAST_CALENDAR_GONE]); -} - -/* Adds a backend to the calendar factory's hash table */ -static void -add_backend (CalFactory *factory, GnomeVFSURI *uri, CalBackend *backend) -{ - CalFactoryPrivate *priv; - - priv = factory->priv; - - gnome_vfs_uri_ref (uri); - g_hash_table_insert (priv->backends, uri, backend); - - gtk_signal_connect (GTK_OBJECT (backend), "last_client_gone", - GTK_SIGNAL_FUNC (backend_last_client_gone_cb), - factory); -} - -/* Tries to launch a backend for the method of the specified URI. If there is - * no such method registered in the factory, it sends the listener the - * MethodNotSupported error code. - */ -static CalBackend * -launch_backend_for_uri (CalFactory *factory, GnomeVFSURI *uri, Evolution_Calendar_Listener listener) -{ - CalFactoryPrivate *priv; - char *method; - GtkType *type; - CalBackend *backend; - - priv = factory->priv; - - /* FIXME: add an accessor function to gnome-vfs */ - method = uri->method_string; - - type = g_hash_table_lookup (priv->methods, method); - - if (!type) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded ( - listener, - Evolution_Calendar_Listener_METHOD_NOT_SUPPORTED, - CORBA_OBJECT_NIL, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("launch_backend_for_uri(): could not notify the listener"); - - CORBA_exception_free (&ev); - return NULL; - } - - backend = gtk_type_new (*type); - if (!backend) - g_message ("launch_backend_for_uri(): could not launch the backend"); - - return backend; -} - -/* Loads a calendar backend and puts it in the factory's backend hash table */ -static CalBackend * -load_backend (CalFactory *factory, GnomeVFSURI *uri, Evolution_Calendar_Listener listener) -{ - CalFactoryPrivate *priv; - CalBackend *backend; - CalBackendLoadStatus status; - CORBA_Environment ev; - - priv = factory->priv; - - backend = launch_backend_for_uri (factory, uri, listener); - if (!backend) - return NULL; - - status = cal_backend_load (backend, uri); - - switch (status) { - case CAL_BACKEND_LOAD_SUCCESS: - add_backend (factory, uri, backend); - return backend; - - case CAL_BACKEND_LOAD_ERROR: - gtk_object_unref (GTK_OBJECT (backend)); - - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded (listener, - Evolution_Calendar_Listener_ERROR, - CORBA_OBJECT_NIL, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("load_backend(): could not notify the listener"); - - CORBA_exception_free (&ev); - return NULL; - - default: - g_assert_not_reached (); - return NULL; - } -} - -/* Creates a calendar backend and puts it in the factory's backend hash table */ -static CalBackend * -create_backend (CalFactory *factory, GnomeVFSURI *uri, Evolution_Calendar_Listener listener) -{ - CalFactoryPrivate *priv; - CalBackend *backend; - - priv = factory->priv; - - backend = launch_backend_for_uri (factory, uri, listener); - if (!backend) - return NULL; - - cal_backend_create (backend, uri); - - /* FIXME: add error reporting to cal_backend_create() */ -#if 0 - { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded (listener, - Evolution_Calendar_Listener_ERROR, - CORBA_OBJECT_NIL, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("create_fn(): could not notify the listener"); - - CORBA_exception_free (&ev); - } -#endif - - add_backend (factory, uri, backend); - - return backend; -} - -/* Adds a listener to a calendar backend by creating a calendar client interface - * object. - */ -static void -add_calendar_client (CalFactory *factory, CalBackend *backend, Evolution_Calendar_Listener listener) -{ - Cal *cal; - CORBA_Environment ev; - - cal = cal_new (backend, listener); - if (!cal) { - g_message ("add_calendar_client(): could not create the calendar client interface"); - - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded (listener, - Evolution_Calendar_Listener_ERROR, - CORBA_OBJECT_NIL, - &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("add_calendar_client(): could not notify the listener"); - - CORBA_exception_free (&ev); - return; - } - - cal_backend_add_cal (backend, cal); - - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded (listener, - Evolution_Calendar_Listener_SUCCESS, - bonobo_object_corba_objref (BONOBO_OBJECT (cal)), - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("add_calendar_client(): could not notify the listener"); - bonobo_object_unref (BONOBO_OBJECT (cal)); - } - - CORBA_exception_free (&ev); -} - -/* Job handler for the load calendar command */ -static void -load_fn (gpointer data) -{ - LoadCreateJobData *jd; - CalFactory *factory; - GnomeVFSURI *uri; - Evolution_Calendar_Listener listener; - CalBackend *backend; - CORBA_Environment ev; - - jd = data; - g_assert (jd->uri != NULL); - - /* Check the URI */ - - uri = gnome_vfs_uri_new (jd->uri); - g_free (jd->uri); - - factory = jd->factory; - listener = jd->listener; - g_free (jd); - - if (!uri) { - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded (listener, - Evolution_Calendar_Listener_ERROR, - CORBA_OBJECT_NIL, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("load_fn(): Could not notify the listener!"); - - CORBA_exception_free (&ev); - goto out; - } - - /* Look up the backend and create it if needed */ - - backend = lookup_backend (factory, uri); - - if (!backend) - backend = load_backend (factory, uri, listener); - - gnome_vfs_uri_unref (uri); - - if (backend) - add_calendar_client (factory, backend, listener); - - out: - - CORBA_exception_init (&ev); - CORBA_Object_release (listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("load_fn(): could not release the listener"); - - CORBA_exception_free (&ev); -} - -/* Job handler for the create calendar command */ -static void -create_fn (gpointer data) -{ - LoadCreateJobData *jd; - CalFactory *factory; - GnomeVFSURI *uri; - Evolution_Calendar_Listener listener; - CalBackend *backend; - CORBA_Environment ev; - - jd = data; - g_assert (jd->uri != NULL); - - /* Check the URI */ - - uri = gnome_vfs_uri_new (jd->uri); - g_free (jd->uri); - - factory = jd->factory; - listener = jd->listener; - g_free (jd); - - if (!uri) { - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded (listener, - Evolution_Calendar_Listener_ERROR, - CORBA_OBJECT_NIL, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("create_fn(): Could not notify the listener!"); - - CORBA_exception_free (&ev); - goto out; - } - - /* Check that the backend is not in use */ - - backend = lookup_backend (factory, uri); - - if (backend) { - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_cal_loaded (listener, - Evolution_Calendar_Listener_IN_USE, - CORBA_OBJECT_NIL, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("create_fn(): could not notify the listener"); - - CORBA_exception_free (&ev); - goto out; - } - - /* Create the backend */ - - backend = create_backend (factory, uri, listener); - - if (backend) - add_calendar_client (factory, backend, listener); - - gnome_vfs_uri_unref (uri); - - out: - - CORBA_exception_init (&ev); - CORBA_Object_release (listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("create_fn(): could not release the listener"); - - CORBA_exception_free (&ev); -} - - - -/* CORBA servant implementation */ - -/* CalFactory::load method */ -static void -CalFactory_load (PortableServer_Servant servant, - const CORBA_char *uri, - Evolution_Calendar_Listener listener, - CORBA_Environment *ev) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - CORBA_Environment ev2; - gboolean result; - - factory = CAL_FACTORY (bonobo_object_from_servant (servant)); - priv = factory->priv; - - CORBA_exception_init (&ev2); - result = CORBA_Object_is_nil (listener, &ev2); - - if (ev2._major != CORBA_NO_EXCEPTION || result) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_CalFactory_NilListener, - NULL); - - CORBA_exception_free (&ev2); - return; - } - CORBA_exception_free (&ev2); - - queue_load_create_job (factory, uri, listener, load_fn); -} - -/* CalFactory::create method */ -static void -CalFactory_create (PortableServer_Servant servant, - const CORBA_char *uri, - Evolution_Calendar_Listener listener, - CORBA_Environment *ev) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - - factory = CAL_FACTORY (bonobo_object_from_servant (servant)); - priv = factory->priv; - - queue_load_create_job (factory, uri, listener, create_fn); -} - -/** - * cal_factory_get_epv: - * @void: - * - * Creates an EPV for the CalFactory CORBA class. - * - * Return value: A newly-allocated EPV. - **/ -POA_Evolution_Calendar_CalFactory__epv * -cal_factory_get_epv (void) -{ - POA_Evolution_Calendar_CalFactory__epv *epv; - - epv = g_new0 (POA_Evolution_Calendar_CalFactory__epv, 1); - epv->load = CalFactory_load; - epv->create = CalFactory_create; - - return epv; -} - - - -/** - * cal_factory_construct: - * @factory: A calendar factory. - * @corba_factory: CORBA object for the calendar factory. - * - * Constructs a calendar factory by binding the corresponding CORBA object to - * it. - * - * Return value: The same object as the @factory argument. - **/ -CalFactory * -cal_factory_construct (CalFactory *factory, Evolution_Calendar_CalFactory corba_factory) -{ - g_return_val_if_fail (factory != NULL, NULL); - g_return_val_if_fail (IS_CAL_FACTORY (factory), NULL); - - bonobo_object_construct (BONOBO_OBJECT (factory), corba_factory); - return factory; -} - -/** - * cal_factory_corba_object_create: - * @object: #BonoboObject that will wrap the CORBA object. - * - * Creates and activates the CORBA object that is wrapped by the specified - * calendar factory @object. - * - * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of - * failure. - **/ -Evolution_Calendar_CalFactory -cal_factory_corba_object_create (BonoboObject *object) -{ - POA_Evolution_Calendar_CalFactory *servant; - CORBA_Environment ev; - - g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (IS_CAL_FACTORY (object), CORBA_OBJECT_NIL); - - servant = (POA_Evolution_Calendar_CalFactory *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &cal_factory_vepv; - - CORBA_exception_init (&ev); - POA_Evolution_Calendar_CalFactory__init ((PortableServer_Servant) servant, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_factory_corba_object_create(): could not init the servant"); - g_free (servant); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - return (Evolution_Calendar_CalFactory) bonobo_object_activate_servant (object, servant); -} - -/** - * cal_factory_new: - * @void: - * - * Creates a new #CalFactory object. - * - * Return value: A newly-created #CalFactory, or NULL if its corresponding CORBA - * object could not be created. - **/ -CalFactory * -cal_factory_new (void) -{ - CalFactory *factory; - CORBA_Environment ev; - Evolution_Calendar_CalFactory corba_factory; - gboolean retval; - - factory = gtk_type_new (CAL_FACTORY_TYPE); - - corba_factory = cal_factory_corba_object_create (BONOBO_OBJECT (factory)); - - CORBA_exception_init (&ev); - retval = CORBA_Object_is_nil (corba_factory, &ev); - - if (ev._major != CORBA_NO_EXCEPTION || retval) { - g_message ("cal_factory_new(): could not create the CORBA factory"); - bonobo_object_unref (BONOBO_OBJECT (factory)); - CORBA_exception_free (&ev); - return NULL; - } - CORBA_exception_free (&ev); - - return cal_factory_construct (factory, corba_factory); -} - -/* Returns the lowercase version of a string */ -static char * -str_tolower (const char *s) -{ - char *str; - char *p; - - str = g_strdup (s); - for (p = str; *p; p++) - if (isalpha (*p)) - *p = tolower (*p); - - return str; -} - -/** - * cal_factory_register_method: - * @factory: A calendar factory. - * @method: Method for the URI, i.e. "http", "file", etc. - * @backend_type: Class type of the backend to create for this @method. - * - * Registers the type of a #CalBackend subclass that will be used to handle URIs - * with a particular method. When the factory is asked to load a particular - * URI, it will look in its list of registered methods and create a backend of - * the appropriate type. - **/ -void -cal_factory_register_method (CalFactory *factory, const char *method, GtkType backend_type) -{ - CalFactoryPrivate *priv; - GtkType *type; - char *method_str; - - g_return_if_fail (factory != NULL); - g_return_if_fail (IS_CAL_FACTORY (factory)); - g_return_if_fail (method != NULL); - g_return_if_fail (backend_type != 0); - g_return_if_fail (gtk_type_is_a (backend_type, CAL_BACKEND_TYPE)); - - priv = factory->priv; - - method_str = str_tolower (method); - - type = g_hash_table_lookup (priv->methods, method_str); - if (type) { - g_message ("cal_factory_register_method(): Method `%s' already registered!", - method_str); - g_free (method_str); - return; - } - - type = g_new (GtkType, 1); - *type = backend_type; - - g_hash_table_insert (priv->methods, method_str, type); -} - -/** - * cal_factory_get_n_backends: - * @factory: A calendar factory. - * - * Queries the number of running calendar backends in a calendar factory. - * - * Return value: Number of running backends. - **/ -int -cal_factory_get_n_backends (CalFactory *factory) -{ - CalFactoryPrivate *priv; - - g_return_val_if_fail (factory != NULL, -1); - g_return_val_if_fail (IS_CAL_FACTORY (factory), -1); - - priv = factory->priv; - return g_hash_table_size (priv->backends); -} diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h deleted file mode 100644 index f96ba4ba92..0000000000 --- a/calendar/pcs/cal-factory.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Evolution calendar factory - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_FACTORY_H -#define CAL_FACTORY_H - -#include <libgnome/gnome-defs.h> -#include <bonobo/bonobo-object.h> - -#include "calendar/pcs/evolution-calendar.h" - -BEGIN_GNOME_DECLS - - - -#define CAL_FACTORY_TYPE (cal_factory_get_type ()) -#define CAL_FACTORY(obj) (GTK_CHECK_CAST ((obj), CAL_FACTORY_TYPE, CalFactory)) -#define CAL_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_FACTORY_TYPE, \ - CalFactoryClass)) -#define IS_CAL_FACTORY(obj) (GTK_CHECK_TYPE ((obj), CAL_FACTORY_TYPE)) -#define IS_CAL_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_FACTORY_TYPE)) - -typedef struct _CalFactory CalFactory; -typedef struct _CalFactoryClass CalFactoryClass; - -struct _CalFactory { - BonoboObject object; - - /* Private data */ - gpointer priv; -}; - -struct _CalFactoryClass { - BonoboObjectClass parent_class; - - /* Notification signals */ - void (* last_calendar_gone) (CalFactory *factory); -}; - -GtkType cal_factory_get_type (void); - -CalFactory *cal_factory_construct (CalFactory *factory, Evolution_Calendar_CalFactory corba_factory); -Evolution_Calendar_CalFactory cal_factory_corba_object_create (BonoboObject *object); - -CalFactory *cal_factory_new (void); - -void cal_factory_register_method (CalFactory *factory, const char *method, GtkType backend_type); - -int cal_factory_get_n_backends (CalFactory *factory); - -POA_Evolution_Calendar_CalFactory__epv *cal_factory_get_epv (void); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c deleted file mode 100644 index fdb7682e7c..0000000000 --- a/calendar/pcs/cal.c +++ /dev/null @@ -1,761 +0,0 @@ -/* Evolution calendar client interface object - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include "cal.h" -#include "cal-backend.h" - - - -/* Private part of the Cal structure */ -typedef struct { - /* Our backend */ - CalBackend *backend; - - /* Listener on the client we notify */ - Evolution_Calendar_Listener listener; -} CalPrivate; - - - -static void cal_class_init (CalClass *class); -static void cal_init (Cal *cal); -static void cal_destroy (GtkObject *object); - -static POA_Evolution_Calendar_Cal__vepv cal_vepv; - -static BonoboObjectClass *parent_class; - - - -/** - * cal_get_type: - * @void: - * - * Registers the #Cal class if necessary, and returns the type ID associated to - * it. - * - * Return value: The type ID of the #Cal class. - **/ -GtkType -cal_get_type (void) -{ - static GtkType cal_type = 0; - - if (!cal_type) { - static const GtkTypeInfo cal_info = { - "Cal", - sizeof (Cal), - sizeof (CalClass), - (GtkClassInitFunc) cal_class_init, - (GtkObjectInitFunc) cal_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - cal_type = gtk_type_unique (BONOBO_OBJECT_TYPE, &cal_info); - } - - return cal_type; -} - -/* CORBA class initialzation function for the calendar */ -static void -init_cal_corba_class (void) -{ - cal_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - cal_vepv.Evolution_Calendar_Cal_epv = cal_get_epv (); -} - -/* Class initialization function for the calendar */ -static void -cal_class_init (CalClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (BONOBO_OBJECT_TYPE); - - object_class->destroy = cal_destroy; - - init_cal_corba_class (); -} - -/* Object initialization function for the calendar */ -static void -cal_init (Cal *cal) -{ - CalPrivate *priv; - - priv = g_new0 (CalPrivate, 1); - cal->priv = priv; - - priv->listener = CORBA_OBJECT_NIL; -} - -/* Destroy handler for the calendar */ -static void -cal_destroy (GtkObject *object) -{ - Cal *cal; - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL (object)); - - cal = CAL (object); - priv = cal->priv; - - priv->backend = NULL; - - CORBA_exception_init (&ev); - CORBA_Object_release (priv->listener, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("cal_destroy(): could not release the listener"); - - CORBA_exception_free (&ev); - - g_free (priv); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* CORBA servant implementation */ - -/* Cal::get_uri method */ -static CORBA_char * -Cal_get_uri (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - GnomeVFSURI *uri; - char *str_uri; - CORBA_char *str_uri_copy; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - uri = cal_backend_get_uri (priv->backend); - str_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); - str_uri_copy = CORBA_string_dup (str_uri); - g_free (str_uri); - - return str_uri_copy; -} - -/* Converts a calendar object type from its CORBA representation to our own - * representation. - */ -static CalObjType -uncorba_obj_type (Evolution_Calendar_CalObjType type) -{ - return (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0) - | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0) - | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0)); -} - -/* Cal::get_n_objects method */ -static CORBA_long -Cal_get_n_objects (PortableServer_Servant servant, - Evolution_Calendar_CalObjType type, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - int t; - int n; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - t = uncorba_obj_type (type); - n = cal_backend_get_n_objects (priv->backend, t); - return n; -} - -/* Cal::get_object method */ -static Evolution_Calendar_CalObj -Cal_get_object (PortableServer_Servant servant, - const Evolution_Calendar_CalObjUID uid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - char *calobj; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - calobj = cal_backend_get_object (priv->backend, uid); - - if (calobj) { - CORBA_char *calobj_copy; - - calobj_copy = CORBA_string_dup (calobj); - g_free (calobj); - return calobj_copy; - } else { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_NotFound, - NULL); - return NULL; - } -} - -static Evolution_Calendar_CalObjUIDSeq * -build_uid_seq (GList *uids) -{ - Evolution_Calendar_CalObjUIDSeq *seq; - GList *l; - int n, i; - - n = g_list_length (uids); - - seq = Evolution_Calendar_CalObjUIDSeq__alloc (); - CORBA_sequence_set_release (seq, TRUE); - seq->_length = n; - seq->_buffer = CORBA_sequence_Evolution_Calendar_CalObjUID_allocbuf (n); - - /* Fill the sequence */ - - for (i = 0, l = uids; l; i++, l = l->next) { - char *uid; - - uid = l->data; - seq->_buffer[i] = CORBA_string_dup (uid); - } - - return seq; -} - -/* Cal::get_uids method */ -static Evolution_Calendar_CalObjUIDSeq * -Cal_get_uids (PortableServer_Servant servant, - Evolution_Calendar_CalObjType type, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - GList *uids; - Evolution_Calendar_CalObjUIDSeq *seq; - int t; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - t = uncorba_obj_type (type); - - uids = cal_backend_get_uids (priv->backend, t); - seq = build_uid_seq (uids); - - cal_obj_uid_list_free (uids); - - return seq; -} - -/* Cal::get_objects_in_range method */ -static Evolution_Calendar_CalObjUIDSeq * -Cal_get_objects_in_range (PortableServer_Servant servant, - Evolution_Calendar_CalObjType type, - Evolution_Calendar_Time_t start, - Evolution_Calendar_Time_t end, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - int t; - time_t t_start, t_end; - Evolution_Calendar_CalObjUIDSeq *seq; - GList *uids; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - t = uncorba_obj_type (type); - t_start = (time_t) start; - t_end = (time_t) end; - - if (t_start > t_end || t_start == -1 || t_end == -1) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_InvalidRange, - NULL); - return NULL; - } - - uids = cal_backend_get_objects_in_range (priv->backend, t, t_start, t_end); - seq = build_uid_seq (uids); - - cal_obj_uid_list_free (uids); - - return seq; -} - -#if 0 -/* Translates an enum AlarmType to its CORBA representation */ -static Evolution_Calendar_AlarmType -corba_alarm_type (enum AlarmType type) -{ - switch (type) { - case ALARM_MAIL: - return Evolution_Calendar_MAIL; - - case ALARM_PROGRAM: - return Evolution_Calendar_PROGRAM; - - case ALARM_DISPLAY: - return Evolution_Calendar_DISPLAY; - - case ALARM_AUDIO: - return Evolution_Calendar_AUDIO; - - default: - g_assert_not_reached (); - return Evolution_Calendar_DISPLAY; - } -} -#endif - -/* Builds a CORBA sequence of alarm instances from a CalAlarmInstance list. */ -static Evolution_Calendar_CalAlarmInstanceSeq * -build_alarm_instance_seq (GList *alarms) -{ - GList *l; - int n, i; - Evolution_Calendar_CalAlarmInstanceSeq *seq; - - n = g_list_length (alarms); - - seq = Evolution_Calendar_CalAlarmInstanceSeq__alloc (); - CORBA_sequence_set_release (seq, TRUE); - seq->_length = n; - seq->_buffer = CORBA_sequence_Evolution_Calendar_CalAlarmInstance_allocbuf (n); - - /* Fill the sequence */ - - for (i = 0, l = alarms; l; i++, l = l->next) { - CalAlarmInstance *ai; - Evolution_Calendar_CalAlarmInstance *corba_ai; - - ai = l->data; - corba_ai = &seq->_buffer[i]; - - corba_ai->uid = CORBA_string_dup (ai->uid); -#if 0 - corba_ai->type = corba_alarm_type (ai->type); -#endif - corba_ai->trigger = ai->trigger; - corba_ai->occur = ai->occur; - } - - return seq; -} - -/* Cal::get_alarms_in_range method */ -static Evolution_Calendar_CalAlarmInstanceSeq * -Cal_get_alarms_in_range (PortableServer_Servant servant, - Evolution_Calendar_Time_t start, - Evolution_Calendar_Time_t end, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - time_t t_start, t_end; - Evolution_Calendar_CalAlarmInstanceSeq *seq; - GList *alarms; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - t_start = (time_t) start; - t_end = (time_t) end; - - if (t_start > t_end || t_start == -1 || t_end == -1) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_InvalidRange, - NULL); - return NULL; - } - - /* Figure out the list and allocate the sequence */ - - alarms = cal_backend_get_alarms_in_range (priv->backend, t_start, t_end); - seq = build_alarm_instance_seq (alarms); - cal_alarm_instance_list_free (alarms); - - return seq; -} - -/* Cal::get_alarms_for_object method */ -static Evolution_Calendar_CalAlarmInstanceSeq * -Cal_get_alarms_for_object (PortableServer_Servant servant, - const Evolution_Calendar_CalObjUID uid, - Evolution_Calendar_Time_t start, - Evolution_Calendar_Time_t end, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - time_t t_start, t_end; - Evolution_Calendar_CalAlarmInstanceSeq *seq; - GList *alarms; - gboolean result; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - t_start = (time_t) start; - t_end = (time_t) end; - - if (t_start > t_end || t_start == -1 || t_end == -1) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_InvalidRange, - NULL); - return NULL; - } - - result = cal_backend_get_alarms_for_object (priv->backend, uid, t_start, t_end, &alarms); - if (!result) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_NotFound, - NULL); - return NULL; - } - - seq = build_alarm_instance_seq (alarms); - cal_alarm_instance_list_free (alarms); - - return seq; -} - -/* Cal::update_object method */ -static void -Cal_update_object (PortableServer_Servant servant, - const Evolution_Calendar_CalObjUID uid, - const Evolution_Calendar_CalObj calobj, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - if (!cal_backend_update_object (priv->backend, uid, calobj)) - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_InvalidObject, - NULL); -} - -/* Cal::remove_object method */ -static void -Cal_remove_object (PortableServer_Servant servant, - const Evolution_Calendar_CalObjUID uid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - if (!cal_backend_remove_object (priv->backend, uid)) - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_NotFound, - NULL); -} - - - -/* Cal::get_uid_by_pilot_id method */ -static Evolution_Calendar_CalObjUID -Cal_get_uid_by_pilot_id (PortableServer_Servant servant, - const Evolution_Calendar_PilotID pilot_id, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - char *uid; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - uid = cal_backend_get_uid_by_pilot_id (priv->backend, pilot_id); - - if (uid) { - CORBA_char *uid_copy; - - uid_copy = CORBA_string_dup (uid); - g_free (uid); - return uid_copy; - } else { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Evolution_Calendar_Cal_NotFound, - NULL); - return NULL; - } -} - - -/* Cal::update_pilot_id method */ -static void -Cal_update_pilot_id (PortableServer_Servant servant, - const Evolution_Calendar_CalObjUID uid, - const Evolution_Calendar_PilotID pilot_id, - const CORBA_unsigned_long pilot_status, - CORBA_Environment * ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_update_pilot_id (priv->backend, uid, - pilot_id, pilot_status); -} - - -/** - * cal_get_epv: - * @void: - * - * Creates an EPV for the Cal CORBA class. - * - * Return value: A newly-allocated EPV. - **/ -POA_Evolution_Calendar_Cal__epv * -cal_get_epv (void) -{ - POA_Evolution_Calendar_Cal__epv *epv; - - epv = g_new0 (POA_Evolution_Calendar_Cal__epv, 1); - epv->_get_uri = Cal_get_uri; - epv->get_n_objects = Cal_get_n_objects; - epv->get_object = Cal_get_object; - epv->get_uids = Cal_get_uids; - epv->get_objects_in_range = Cal_get_objects_in_range; - epv->get_alarms_in_range = Cal_get_alarms_in_range; - epv->get_alarms_for_object = Cal_get_alarms_for_object; - epv->update_object = Cal_update_object; - epv->remove_object = Cal_remove_object; - epv->get_uid_by_pilot_id = Cal_get_uid_by_pilot_id; - epv->update_pilot_id = Cal_update_pilot_id; - - return epv; -} - - - -/** - * cal_construct: - * @cal: A calendar client interface. - * @corba_cal: CORBA object for the calendar. - * @backend: Calendar backend that this @cal presents an interface to. - * @listener: Calendar listener for notification. - * - * Constructs a calendar client interface object by binding the corresponding - * CORBA object to it. The calendar interface is bound to the specified - * @backend, and will notify the @listener about changes to the calendar. - * - * Return value: The same object as the @cal argument. - **/ -Cal * -cal_construct (Cal *cal, - Evolution_Calendar_Cal corba_cal, - CalBackend *backend, - Evolution_Calendar_Listener listener) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_val_if_fail (cal != NULL, NULL); - g_return_val_if_fail (IS_CAL (cal), NULL); - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - priv = cal->priv; - - CORBA_exception_init (&ev); - priv->listener = CORBA_Object_duplicate (listener, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_construct: could not duplicate the listener"); - priv->listener = CORBA_OBJECT_NIL; - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - priv->backend = backend; - - bonobo_object_construct (BONOBO_OBJECT (cal), corba_cal); - return cal; -} - -/** - * cal_corba_object_create: - * @object: #BonoboObject that will wrap the CORBA object. - * - * Creates and activates the CORBA object that is wrapped by the specified - * calendar client interface @object. - * - * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of - * failure. - **/ -Evolution_Calendar_Cal -cal_corba_object_create (BonoboObject *object) -{ - POA_Evolution_Calendar_Cal *servant; - CORBA_Environment ev; - - g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (IS_CAL (object), CORBA_OBJECT_NIL); - - servant = (POA_Evolution_Calendar_Cal *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &cal_vepv; - - CORBA_exception_init (&ev); - POA_Evolution_Calendar_Cal__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_corba_object_create(): could not init the servant"); - g_free (servant); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - return (Evolution_Calendar_Cal) bonobo_object_activate_servant (object, servant); -} - -/** - * cal_new: - * @backend: A calendar backend. - * @listener: A calendar listener. - * - * Creates a new calendar client interface object and binds it to the specified - * @backend and @listener objects. - * - * Return value: A newly-created #Cal calendar client interface object, or NULL - * if its corresponding CORBA object could not be created. - **/ -Cal * -cal_new (CalBackend *backend, Evolution_Calendar_Listener listener) -{ - Cal *cal, *retval; - Evolution_Calendar_Cal corba_cal; - CORBA_Environment ev; - gboolean ret; - - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - cal = CAL (gtk_type_new (CAL_TYPE)); - corba_cal = cal_corba_object_create (BONOBO_OBJECT (cal)); - - CORBA_exception_init (&ev); - ret = CORBA_Object_is_nil ((CORBA_Object) corba_cal, &ev); - if (ev._major != CORBA_NO_EXCEPTION || ret) { - g_message ("cal_new(): could not create the CORBA object"); - bonobo_object_unref (BONOBO_OBJECT (cal)); - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - retval = cal_construct (cal, corba_cal, backend, listener); - if (!retval) { - g_message ("cal_new(): could not construct the calendar client interface"); - bonobo_object_unref (BONOBO_OBJECT (cal)); - return NULL; - } - - return retval; -} - -/** - * cal_notify_update: - * @cal: A calendar client interface. - * @uid: UID of object that was updated. - * - * Notifies a listener attached to a calendar client interface object about an - * update to a calendar object. - **/ -void -cal_notify_update (Cal *cal, const char *uid) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - g_return_if_fail (uid != NULL); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_obj_updated (priv->listener, (char *) uid, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("cal_notify_update(): could not notify the listener " - "about an updated object"); - - CORBA_exception_free (&ev); -} - -/** - * cal_notify_remove: - * @cal: A calendar client interface. - * @uid: UID of object that was removed. - * - * Notifies a listener attached to a calendar client interface object about a - * calendar object that was removed. - **/ -void -cal_notify_remove (Cal *cal, const char *uid) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - g_return_if_fail (uid != NULL); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - Evolution_Calendar_Listener_obj_removed (priv->listener, (char *) uid, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("cal_notify_remove(): could not notify the listener " - "about a removed object"); - - CORBA_exception_free (&ev); -} diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h deleted file mode 100644 index a11cedebbb..0000000000 --- a/calendar/pcs/cal.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Evolution calendar client interface object - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_H -#define CAL_H - -#include <libgnome/gnome-defs.h> -#include <bonobo/bonobo-object.h> -#include "calendar/pcs/evolution-calendar.h" -#include "cal-common.h" - -BEGIN_GNOME_DECLS - - - -#define CAL_TYPE (cal_get_type ()) -#define CAL(obj) (GTK_CHECK_CAST ((obj), CAL_TYPE, Cal)) -#define CAL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_TYPE, CalClass)) -#define IS_CAL(obj) (GTK_CHECK_TYPE ((obj), CAL_TYPE)) -#define IS_CAL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_TYPE)) - -struct _Cal { - BonoboObject object; - - /* Private data */ - gpointer priv; -}; - -struct _CalClass { - BonoboObjectClass parent_class; -}; - -GtkType cal_get_type (void); - -Cal *cal_construct (Cal *cal, - Evolution_Calendar_Cal corba_cal, - CalBackend *backend, - Evolution_Calendar_Listener listener); -Evolution_Calendar_Cal cal_corba_object_create (BonoboObject *object); - -Cal *cal_new (CalBackend *backend, Evolution_Calendar_Listener listener); - -void cal_notify_update (Cal *cal, const char *uid); -void cal_notify_remove (Cal *cal, const char *uid); - -POA_Evolution_Calendar_Cal__epv *cal_get_epv (void); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/pcs/job.c b/calendar/pcs/job.c deleted file mode 100644 index d97df6d883..0000000000 --- a/calendar/pcs/job.c +++ /dev/null @@ -1,98 +0,0 @@ -/* GNOME personal calendar server - job manager - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include "job.h" - - - -/* The job list */ - -typedef struct { - JobFunc func; - gpointer data; -} Job; - -static GSList *jobs_head; -static GSList *jobs_tail; - -static guint jobs_idle_id; - - - -/* Runs a job and dequeues it */ -static gboolean -run_job (gpointer data) -{ - Job *job; - GSList *l; - - g_assert (jobs_head != NULL); - - job = jobs_head->data; - (* job->func) (job->data); - g_free (job); - - l = jobs_head; - jobs_head = g_slist_remove_link (jobs_head, jobs_head); - g_slist_free_1 (l); - - if (!jobs_head) { - jobs_tail = NULL; - jobs_idle_id = 0; - return FALSE; - } else - return TRUE; -} - -/** - * job_add: - * @func: Function to run the job. - * @data: Data to pass to @function. - * - * Adds a job to the queue. The job will automatically be run asynchronously. - **/ -void -job_add (JobFunc func, gpointer data) -{ - Job *job; - - g_return_if_fail (func != NULL); - - job = g_new (Job, 1); - job->func = func; - job->data = data; - - if (!jobs_head) { - g_assert (jobs_tail == NULL); - g_assert (jobs_idle_id == 0); - - jobs_head = g_slist_append (NULL, job); - jobs_tail = jobs_head; - - jobs_idle_id = g_idle_add (run_job, NULL); - } else { - g_assert (jobs_tail != NULL); - g_assert (jobs_idle_id != 0); - - jobs_tail = g_slist_append (jobs_tail, job)->next; - } -} diff --git a/calendar/pcs/job.h b/calendar/pcs/job.h deleted file mode 100644 index c9bce24dd4..0000000000 --- a/calendar/pcs/job.h +++ /dev/null @@ -1,35 +0,0 @@ -/* GNOME personal calendar server - job manager - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef JOB_H -#define JOB_H - -#include <glib.h> - - - -typedef void (* JobFunc) (gpointer data); - -void job_add (JobFunc func, gpointer data); - - - -#endif |