aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobody <nobody@localhost>1998-08-18 20:15:39 +0800
committernobody <nobody@localhost>1998-08-18 20:15:39 +0800
commit4d105ce62283b80927a36c72ec09708942fc4474 (patch)
tree7da6b0ea470febf8bc31638a17f7574950bcbdb6
parentb7c9e891f64f19f1cda1294e1816898518be3ed9 (diff)
downloadgsoc2013-evolution-GNOME_0_28_MARTIN.tar
gsoc2013-evolution-GNOME_0_28_MARTIN.tar.gz
gsoc2013-evolution-GNOME_0_28_MARTIN.tar.bz2
gsoc2013-evolution-GNOME_0_28_MARTIN.tar.lz
gsoc2013-evolution-GNOME_0_28_MARTIN.tar.xz
gsoc2013-evolution-GNOME_0_28_MARTIN.tar.zst
gsoc2013-evolution-GNOME_0_28_MARTIN.zip
This commit was manufactured by cvs2svn to create tagGNOME_0_28_MARTIN
'GNOME_0_28_MARTIN'. svn path=/tags/GNOME_0_28_MARTIN/; revision=323
-rw-r--r--calendar/.cvsignore8
-rw-r--r--calendar/AUTHORS3
-rw-r--r--calendar/ChangeLog866
-rw-r--r--calendar/Makefile.am82
-rw-r--r--calendar/TODO35
-rw-r--r--calendar/alarm.c145
-rw-r--r--calendar/alarm.h12
-rw-r--r--calendar/bell.xpm83
-rw-r--r--calendar/cal-util/calobj.c1246
-rw-r--r--calendar/cal-util/calobj.h199
-rw-r--r--calendar/cal_struct.h27
-rw-r--r--calendar/calcs.c253
-rw-r--r--calendar/calcs.h53
-rw-r--r--calendar/calendar.c396
-rw-r--r--calendar/calendar.h63
-rw-r--r--calendar/calobj.c1246
-rw-r--r--calendar/calobj.h199
-rw-r--r--calendar/clist.c97
-rw-r--r--calendar/clist.h2
-rw-r--r--calendar/eventedit.c1479
-rw-r--r--calendar/eventedit.h77
-rw-r--r--calendar/getdate.y1001
-rw-r--r--calendar/gncal-day-panel.c240
-rw-r--r--calendar/gncal-day-panel.h62
-rw-r--r--calendar/gncal-day-view.c398
-rw-r--r--calendar/gncal-day-view.h56
-rw-r--r--calendar/gncal-full-day.c2321
-rw-r--r--calendar/gncal-full-day.h74
-rw-r--r--calendar/gncal-todo.c356
-rw-r--r--calendar/gncal-todo.h52
-rw-r--r--calendar/gncal-week-view.c236
-rw-r--r--calendar/gncal-week-view.h55
-rw-r--r--calendar/gncal.c700
-rw-r--r--calendar/gncal.desktop17
-rw-r--r--calendar/gncal.h6
-rw-r--r--calendar/gnome-cal.c416
-rw-r--r--calendar/gnome-cal.h68
-rw-r--r--calendar/gnome-cal.html42
-rw-r--r--calendar/gnome-month-item.c832
-rw-r--r--calendar/gnome-month-item.h71
-rw-r--r--calendar/goto.c230
-rw-r--r--calendar/gui/Makefile.am82
-rw-r--r--calendar/gui/alarm-notify/alarm.c145
-rw-r--r--calendar/gui/alarm-notify/alarm.h12
-rw-r--r--calendar/gui/alarm.c145
-rw-r--r--calendar/gui/alarm.h12
-rw-r--r--calendar/gui/bell.xpm83
-rw-r--r--calendar/gui/cal_struct.h27
-rw-r--r--calendar/gui/calendar.c396
-rw-r--r--calendar/gui/calendar.h63
-rw-r--r--calendar/gui/eventedit.c1479
-rw-r--r--calendar/gui/eventedit.h77
-rw-r--r--calendar/gui/getdate.y1001
-rw-r--r--calendar/gui/gncal-day-panel.c240
-rw-r--r--calendar/gui/gncal-day-panel.h62
-rw-r--r--calendar/gui/gncal-day-view.c398
-rw-r--r--calendar/gui/gncal-day-view.h56
-rw-r--r--calendar/gui/gncal-full-day.c2321
-rw-r--r--calendar/gui/gncal-full-day.h74
-rw-r--r--calendar/gui/gncal-todo.c356
-rw-r--r--calendar/gui/gncal-todo.h52
-rw-r--r--calendar/gui/gncal-week-view.c236
-rw-r--r--calendar/gui/gncal-week-view.h55
-rw-r--r--calendar/gui/gncal.desktop17
-rw-r--r--calendar/gui/gnome-cal.c416
-rw-r--r--calendar/gui/gnome-cal.h68
-rw-r--r--calendar/gui/gnome-cal.html42
-rw-r--r--calendar/gui/gnome-month-item.c832
-rw-r--r--calendar/gui/gnome-month-item.h71
-rw-r--r--calendar/gui/goto.c230
-rw-r--r--calendar/gui/icalendar-types39
-rw-r--r--calendar/gui/main.c699
-rw-r--r--calendar/gui/main.h12
-rw-r--r--calendar/gui/month-view.c121
-rw-r--r--calendar/gui/month-view.h51
-rw-r--r--calendar/gui/popup-menu.c37
-rw-r--r--calendar/gui/popup-menu.h25
-rw-r--r--calendar/gui/prop.c154
-rw-r--r--calendar/gui/recur.xpm83
-rw-r--r--calendar/gui/test.vcf133
-rw-r--r--calendar/gui/topic.dat2
-rw-r--r--calendar/gui/view-utils.c126
-rw-r--r--calendar/gui/view-utils.h28
-rw-r--r--calendar/gui/year-view.c245
-rw-r--r--calendar/gui/year-view.h56
-rw-r--r--calendar/icalendar-types39
-rw-r--r--calendar/lexer.c441
-rw-r--r--calendar/main.c699
-rw-r--r--calendar/main.h12
-rw-r--r--calendar/menus.c147
-rw-r--r--calendar/menus.h17
-rw-r--r--calendar/month-view.c121
-rw-r--r--calendar/month-view.h51
-rw-r--r--calendar/objedit.c88
-rw-r--r--calendar/pcs/calobj.c1246
-rw-r--r--calendar/pcs/calobj.h199
-rw-r--r--calendar/popup-menu.c37
-rw-r--r--calendar/popup-menu.h25
-rw-r--r--calendar/prop.c154
-rw-r--r--calendar/recur.xpm83
-rw-r--r--calendar/test.vcf133
-rw-r--r--calendar/timeutil.c323
-rw-r--r--calendar/timeutil.h47
-rw-r--r--calendar/topic.dat2
-rw-r--r--calendar/view-utils.c126
-rw-r--r--calendar/view-utils.h28
-rw-r--r--calendar/views.c33
-rw-r--r--calendar/views.h4
-rw-r--r--calendar/year-view.c245
-rw-r--r--calendar/year-view.h56
-rw-r--r--libversit/.cvsignore3
-rw-r--r--libversit/Makefile.am13
-rw-r--r--libversit/README.TXT951
-rw-r--r--libversit/port.h88
-rw-r--r--libversit/vcaltest.c118
-rw-r--r--libversit/vcaltmp.c337
-rw-r--r--libversit/vcaltmp.h128
-rw-r--r--libversit/vcc.c2071
-rw-r--r--libversit/vcc.h80
-rw-r--r--libversit/vcc.y1217
-rw-r--r--libversit/vctest.c95
-rw-r--r--libversit/vobject.c1428
-rw-r--r--libversit/vobject.h362
123 files changed, 0 insertions, 35910 deletions
diff --git a/calendar/.cvsignore b/calendar/.cvsignore
deleted file mode 100644
index 2664490d31..0000000000
--- a/calendar/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-Makefile.in
-Makefile
-.deps
-_libs
-.libs
-gncal
-gnomecal
-getdate.c
diff --git a/calendar/AUTHORS b/calendar/AUTHORS
deleted file mode 100644
index 15dc73f4c7..0000000000
--- a/calendar/AUTHORS
+++ /dev/null
@@ -1,3 +0,0 @@
-Miguel de Icaza <miguel@kernel.org>
-Federico Mena <quartic@gimp.org>
-Arturo Esponosa <arturo@nuclecu.unam.mx>
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
deleted file mode 100644
index 182cb295d7..0000000000
--- a/calendar/ChangeLog
+++ /dev/null
@@ -1,866 +0,0 @@
-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 039e866306..0000000000
--- a/calendar/Makefile.am
+++ /dev/null
@@ -1,82 +0,0 @@
-SUBDIRS = versit gnomecard
-help_base = $(datadir)/gnome/help/cal
-
-CFLAGS += -Wall
-
-INCLUDES = \
- -I$(includedir) \
- $(GNOME_INCLUDEDIR) \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
- -I../../gcalendar
-
-bin_PROGRAMS = gnomecal
-
-gnomecal_SOURCES = \
- alarm.c \
- alarm.h \
- calendar.c \
- calendar.h \
- calobj.c \
- calobj.h \
- eventedit.c \
- eventedit.h \
- gncal-day-panel.c \
- gncal-day-panel.h \
- gncal-day-view.c \
- gncal-day-view.h \
- gncal-full-day.c \
- gncal-full-day.h \
- gncal-week-view.c \
- gncal-week-view.h \
- gncal-todo.c \
- gncal-todo.h \
- gncal-year-view.c \
- gncal-year-view.h \
- gnome-month-item.c \
- gnome-month-item.h \
- getdate.y \
- gnome-cal.c \
- gnome-cal.h \
- goto.c \
- main.c \
- main.h \
- month-view.c \
- month-view.h \
- popup-menu.c \
- popup-menu.h \
- prop.c \
- timeutil.c \
- timeutil.h \
- view-utils.h \
- view-utils.c \
- views.h \
- views.c
-
-LINK_FLAGS = \
- $(GNOME_LIBDIR) \
- $(GNOMEUI_LIBS) \
- $(INTLLIBS) versit/libversit.a
-
-
-#gncal_LDADD = $(LINK_FLAGS)
-#objedit_LDADD = $(LINK_FLAGS)
-
-gnomecal_LDADD = $(LINK_FLAGS)
-
-EXTRA_DIST = \
- gncal.desktop \
- topic.dat \
- gnome-cal.html \
- bell.xpm \
- recur.xpm
-
-
-Productivitydir = $(datadir)/apps/Productivity
-
-Productivity_DATA = gncal.desktop
-
-install-data-local:
- $(mkinstalldirs) $(help_base)/C
- $(INSTALL_DATA) $(srcdir)/topic.dat $(help_base)/C/topic.dat
- $(INSTALL_DATA) $(srcdir)/gnome-cal.html $(help_base)/C/gnome-cal.html
- cd $(help_base)/C; ln -sf gnome-cal.html index.html
diff --git a/calendar/TODO b/calendar/TODO
deleted file mode 100644
index f7898ed7ca..0000000000
--- a/calendar/TODO
+++ /dev/null
@@ -1,35 +0,0 @@
-Preferences:
-
-- Add possibility to start weeks also on monday (European calendar mode)
-
-- 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().
-
-Full day widget:
-
-- Display alarm/whatever flags somewhere.
-
-- Layout the children nicely like M$ Schedule or Netscape Calendar do
- (i.e. make them not overlap each other).
-
-Month view:
-
-- Write a month view widget.
-
-Week view:
-
-- Replace the calendar by a `task density' widget like in Solaris cm.
-
-General:
-
-- Write online help. Nice help. Lots of help.
diff --git a/calendar/alarm.c b/calendar/alarm.c
deleted file mode 100644
index 280d4125e3..0000000000
--- a/calendar/alarm.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Alarm handling for the GNOME Calendar.
- *
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#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 */
-int alarm_pipes [2];
-
-/* The list of pending alarms */
-static GList *alarms;
-
-static void *head_alarm;
-
-typedef struct {
- time_t activation_time;
- AlarmFunction fn;
- void *closure;
-} AlarmRecord;
-
-/*
- * SIGALRM handler. Notifies the callback about the alarm
- */
-static void
-alarm_activate ()
-{
- char c = 0;
-
- write (alarm_pipes [1], &c, 1);
-}
-
-static void
-alarm_ready (void *closure, int fd, GdkInputCondition cond)
-{
- AlarmRecord *ar = head_alarm;
- char c;
-
- if (read (alarm_pipes [0], &c, 1) != 1)
- return;
-
- if (ar == NULL){
- g_warning ("Empty events. This should not happen\n");
- return;
- }
- (*ar->fn)(ar->activation_time, ar->closure);
- alarms = g_list_remove (alarms, head_alarm);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- g_free (ar);
-}
-
-static int
-alarm_compare_by_time (gconstpointer a, gconstpointer b)
-{
- const AlarmRecord *ara = a;
- const AlarmRecord *arb = b;
- time_t diff;
-
- diff = ara->activation_time - arb->activation_time;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-void
-alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
-{
- time_t now = time (NULL);
- AlarmRecord *ar;
-
- /* If it already expired, do not add it */
- if (alarm_time < now)
- return;
-
- ar = g_new0 (AlarmRecord, 1);
- ar->activation_time = alarm_time;
- ar->fn = fn;
- ar->closure = closure;
-
- alarms = g_list_insert_sorted (alarms, ar, alarm_compare_by_time);
-
- /* If first alarm is not the previous first alarm, reschedule SIGALRM */
- if (head_alarm != alarms->data){
- struct itimerval itimer;
- int v;
-
- /* Set the timer to disable upon activation */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = alarm_time - now;
- itimer.it_value.tv_usec = 0;
- v = setitimer (ITIMER_REAL, &itimer, NULL);
- head_alarm = alarms->data;
- }
-}
-
-int
-alarm_kill (void *closure_key)
-{
- GList *p;
-
- for (p = alarms; p; p = p->next){
- AlarmRecord *ar = p->data;
-
- if (ar->closure == closure_key){
- alarms = g_list_remove (alarms, p->data);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- return 1;
- }
- }
- return 0;
-}
-
-void
-alarm_init (void)
-{
- struct sigaction sa;
- int flags;
-
- pipe (alarm_pipes);
-
- /* set non blocking mode */
- 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, 0);
-
- /* Setup the signal handler */
- sa.sa_handler = alarm_activate;
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = SA_RESTART;
- sigaction (SIGALRM, &sa, NULL);
-}
-
diff --git a/calendar/alarm.h b/calendar/alarm.h
deleted file mode 100644
index d37ff0c1bf..0000000000
--- a/calendar/alarm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef ALARM_H
-#define ALARM_H
-
-#include <time.h>
-
-typedef void (*AlarmFunction)(time_t time, void *closuse);
-
-void alarm_init (void);
-void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
-int alarm_kill (void *closure);
-
-#endif
diff --git a/calendar/bell.xpm b/calendar/bell.xpm
deleted file mode 100644
index b1ab537a17..0000000000
--- a/calendar/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/cal-util/calobj.c b/calendar/cal-util/calobj.c
deleted file mode 100644
index d8ca3fe5db..0000000000
--- a/calendar/cal-util/calobj.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/*
- * Calendar objects implementations.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <string.h>
-#include <glib.h>
-#include "calobj.h"
-#include "timeutil.h"
-#include "versit/vcc.h"
-
-iCalObject *
-ical_object_new (void)
-{
- iCalObject *ico;
-
- ico = g_new0 (iCalObject, 1);
-
- ico->seq = -1;
- ico->dtstamp = time (NULL);
-
- return ico;
-}
-
-static void
-default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
-{
- alarm->enabled = 0;
- alarm->type = type;
-
- if (type != ALARM_MAIL){
- alarm->count = 15;
- alarm->units = ALARM_MINUTES;
- } else {
- alarm->count = 1;
- alarm->units = ALARM_DAYS;
- }
-
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (def_mail);
- else
- alarm->data = g_strdup ("");
-}
-
-iCalObject *
-ical_new (char *comment, char *organizer, char *summary)
-{
- iCalObject *ico;
-
- ico = ical_object_new ();
-
- ico->comment = g_strdup (comment);
- ico->organizer = g_strdup (organizer);
- ico->summary = g_strdup (summary);
- ico->class = g_strdup ("PUBLIC");
- ico->status = g_strdup ("NEEDS ACTION");
-
- default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY);
- default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM);
- default_alarm (ico, &ico->malarm, organizer, ALARM_MAIL);
- default_alarm (ico, &ico->aalarm, organizer, ALARM_AUDIO);
-
- return 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);
-}
-
-#define free_if_defined(x) if (x){ g_free (x); x = 0; }
-#define lfree_if_defined(x) if (x){ list_free (x); x = 0; }
-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);
-}
-
-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))
- ;
- }
-}
-
-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
-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;
-}
-
-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;
-}
-
-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){
- 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);
- weekdaylist (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
- */
- 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');
- 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
- */
-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;
- }
-
- /* uid */
- if (has (o, VCUniqueStringProp)){
- ical->uid = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* 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);
- } 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 = "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);
- }
-
- /* related */
- if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo));
- 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)){
- ical->url = g_strdup (str_val (vo));
- 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);
- }
- }
- }
-
- /* 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);
- }
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_destroy (ical);
- return NULL;
- }
- free (the_str);
- }
- 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_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 (strlen (ical->summary)){
- s = addPropValue (o, VCSummaryProp, ical->summary);
- if (strchr (ical->summary, '\n'))
- addProp (s, VCQuotedPrintableProp);
- } else {
- addPropValue (o, VCSummaryProp, _("Appointment"));
- }
-
- /* 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->categories)
- store_list (o, VCCategoriesProp, ical->resources);
-
- /* priority */
- addPropValue (o, VCPriorityProp, to_str (ical->priority));
-
- /* transparency */
- addPropValue (o, VCTranspProp, to_str (ical->transp));
-
- /* related */
- if (ical->related)
- store_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);
- 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_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);
- 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;
-}
-
-static int
-generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
-{
- struct tm dt_start, dt_end, ref;
- time_t s_t, e_t;
-
- dt_start = *localtime (&ico->dtstart);
- dt_end = *localtime (&ico->dtend);
- ref = *localtime (&reference);
-
- dt_start.tm_mday = ref.tm_mday;
- dt_start.tm_mon = ref.tm_mon;
- dt_start.tm_year = ref.tm_year;
-
- dt_end.tm_mday = ref.tm_mday;
- dt_end.tm_mon = ref.tm_mon;
- dt_end.tm_year = ref.tm_year;
-
- s_t = mktime (&dt_start);
- if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
- return 1;
-
- e_t = mktime (&dt_end);
-
- if (s_t == -1 || e_t == -1){
- g_warning ("Produced invalid dates!\n");
- return 0;
- }
- return (*cb)(ico, s_t, e_t, closure);
-}
-
-#define time_in_range(x,a,b) ((x >= a) && (b ? x <= 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)
-{
- Recurrence *recur = ico->recur;
- time_t current;
- int first_week_day, i;
-
- if (!ico->recur){
- if ((end && (ico->dtstart < end) && ico->dtend > start) ||
- (end == 0 && ico->dtend > start)){
- time_t ev_s, ev_e;
-
- ev_s = ico->dtstart < start ? start : ico->dtstart;
- ev_e = ico->dtend > end ? end : ico->dtend;
- (*cb)(ico, ev_s, ev_e, closure);
- }
- return;
- }
-
- /* The event has a recurrence rule */
- if (end != 0){
- if (ico->dtstart > end)
- return;
- if (!IS_INFINITE (recur) && recur->enddate < start)
- return;
- }
-
- current = ico->dtstart;
- switch (recur->type){
- case RECUR_DAILY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, recur)){
- if (!generate (ico, current, cb, closure))
- return;
- }
-
- /* Advance */
- current = time_add_day (current, recur->interval);
-
- if (current == -1){
- g_warning ("RECUR_DAILY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
- break;
-
- case RECUR_WEEKLY:
- do {
- struct tm *tm = localtime (&current);
-
- if (time_in_range (current, start, end) && recur_in_range (current, recur)){
- if (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, (recur->interval-1) * 7 + 1);
- else
- current = time_add_day (current, 1);
-
- if (current == -1){
- g_warning ("RECUR_WEEKLY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
- break;
-
- case RECUR_MONTHLY_BY_POS:
- /* FIXME: We only deal with positives now */
- if (recur->u.month_pos < 0)
- return;
-
- if (recur->u.month_pos == 0)
- return;
-
- first_week_day = 7;
- for (i = 6; i >= 0; i--)
- if (recur->weekday & (1 << i))
- first_week_day = i;
-
- /* This should not happen, but take it into account */
- if (first_week_day == 7)
- return;
-
- do {
- struct tm tm;
- time_t t;
- int week_day_start;
-
- tm = *localtime (&current);
- tm.tm_mday = 1;
- t = mktime (&tm);
- tm = *localtime (&t);
- week_day_start = tm.tm_wday;
-
- tm.tm_mday = 7 * (recur->u.month_pos -
- ((week_day_start <= first_week_day ) ? 1 : 0)) -
- (week_day_start - first_week_day) + 1;
-
- t = mktime (&tm);
-
- if (time_in_range (t, start, end) && recur_in_range (current, recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance a month */
- current = mktime (&tm);
-
- tm.tm_mday = 1;
- tm.tm_mon += 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 = localtime (&current);
- time_t t;
- int p;
-
- p = tm->tm_mday;
- tm->tm_mday = recur->u.month_day;
- t = mktime (tm);
- if (time_in_range (t, start, end) && recur_in_range (current, recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance a month */
- tm->tm_mday = p;
- tm->tm_mon += recur->interval;
- current = mktime (tm);
- if (current == -1){
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
-
- case RECUR_YEARLY_BY_MONTH:
- case RECUR_YEARLY_BY_DAY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
- current = time_add_year (current, recur->interval);
- } while (current < end || (end == 0));
- }
-}
-
-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_end_of_day (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;
-}
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
deleted file mode 100644
index d18acd4f8a..0000000000
--- a/calendar/cal-util/calobj.h
+++ /dev/null
@@ -1,199 +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 "versit/vcc.h"
-
-BEGIN_GNOME_DECLS
-
-enum AlarmType {
- ALARM_MAIL,
- ALARM_PROGRAM,
- ALARM_DISPLAY,
- ALARM_AUDIO
-};
-
-enum AlarmUnit {
- ALARM_MINUTES,
- ALARM_HOURS,
- ALARM_DAYS
-};
-
-typedef struct {
- enum AlarmType type;
- int enabled;
- int count;
- enum AlarmUnit units;
- char *data;
-
- /* 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 struct {
- int valid; /* true if the Geography was specified */
- double latitude;
- double longitude;
-} iCalGeo;
-
-typedef enum {
- ICAL_OPAQUE,
- ICAL_TRANSPARENT
-} iCalTransp;
-
-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;
-
-#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 */
- 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 */
- time_t dtstamp;
- time_t dtstart;
- time_t dtend;
- GList *exdate; /* type: one or more time_t's */
- GList *exrule; /* type: one or more RECUR */
- iCalGeo geo;
- time_t last_mod;
- char *location;
- char *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;
-
- Recurrence *recur;
-
- int new;
- void *user_data; /* Generic data pointer */
-} 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_destroy (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);
-
-/* Returns the number of seconds configured to trigger the alarm in advance to an event */
-int alarm_compute_offset (CalendarAlarm *a);
-
-END_GNOME_DECLS
-
-#endif
-
diff --git a/calendar/cal_struct.h b/calendar/cal_struct.h
deleted file mode 100644
index 411036c7aa..0000000000
--- a/calendar/cal_struct.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#define MAX_SZ 30
-
-enum RepeatType {
- Single,
- Days,
- Months,
- WeekDays,
- MonthDays
-};
-
-
-struct actionitem {
- char date[MAX_SZ];
- int time; /* Minutes past midnight */
-};
-
-struct event {
- struct actionitem start;
- struct actionitem end;
-
- enum RepeatType repeat;
- int repeatcount;
- char description[MAX_SZ];
- char subtype[MAX_SZ];
- GList *properties;
-};
-
diff --git a/calendar/calcs.c b/calendar/calcs.c
deleted file mode 100644
index d6150f7b35..0000000000
--- a/calendar/calcs.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * calc.c Calculations to work out what day it is etc for the Calendar
- *
- * Most of this stuff was taken from the gcal source by Thomas Esken.
- * <esken@uni-muenster.de>
- * gcal is a text-based calendar program
- */
-
-#include <time.h>
-#include <glib.h>
-#include <ctype.h>
-#include "calcs.h"
-
-#include <config.h>
-
-#ifndef HAVE_STRCASECMP
-int strcasecmp(const char * /*s1*/, const char * /*s2*/);
-#endif
-
-/* Number of days in a month */
-static const int dvec[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-/* Number of past days of a month */
-static const int mvec[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
-Greg_struct greg_reform_date[6] = {
-/* {int year, int month, int f_day, int l_day} */
- { 1582, 10, 5, 14 },
- { 1700, 2, 19, 28 },
- { 1752, 9, 3, 13 },
- { 1753, 2, 18, 28 },
-/* must be left with all zeroes */
- { 0,0,0,0 }
-};
-Greg_struct *greg=greg_reform_date;
-
-
-
-/*
- * Computes the number of days in February and returns them,
- */
-int days_of_february(const int year)
-{
- return((year&3) ? 28 : (!(year%100)&&(year%400)) ? 28 : 29);
-}
-
-int is_leap_year(const int year)
-{
- return (days_of_february(year) == 29);
-}
-
-/*
- * Check wether a given date is calid.
- */
-int valid_date(const int day, const int month, const int year)
-{
- if ( day < 1
- || month < MONTH_MIN
- || month > MONTH_MAX
- || ( (month != 2)
- && (day > dvec[month-1]))
- || ( (month == 2)
- && (day > days_of_february (year))))
- return(FALSE);
-
- return(TRUE);
-}
-
-/*
- * Set a date back one day (to yesterday's date)
- */
-void prev_date(int *day, int *month, int *year)
-{
- (*day)--;
- if ( !*day || !valid_date(*day, *month, *year)) {
- (*month)--;
- if (*month < MONTH_MIN) {
- *month = MONTH_MAX;
- (*year)--;
- }
- if (*month ==2)
- *day = days_of_february(*year);
- else
- *day = dvec[*month-1];
- }
-} /* prev_date */
-
-/*
- * Set a date forward one day (to tomorrow's date)
- */
-void next_date(int *day, int *month, int *year)
-{
- (*day)++;
- if (!valid_date(*day, *month, *year)) {
- *day = DAY_MIN;
- if (*month == MONTH_MAX) {
- *month = MONTH_MIN;
- (*year)++;
- } else
- (*month)++;
- }
-} /* next_date */
-
-/*
- * Get date from the system
- */
-void get_system_date(int *day, int *month, int *year)
-{
- auto struct tm *sys_date;
- auto time_t sys_time;
-
-
- sys_time = time((time_t *)NULL);
- sys_date = localtime(&sys_time);
- *day = sys_date->tm_mday;
- *month = sys_date->tm_mon + 1;
- *year = sys_date->tm_year;
- if (*year < CENTURY)
- *year += CENTURY;
-} /* get_system_date */
-
-
-/*
- * Given a string with the name of a month, return 1..12 or 0 if not found
- */
-int month_atoi(const char *string)
-{
- int i;
- for (i = MONTH_MIN; i <= MONTH_MAX; i++)
- if (strcasecmp(string, (char *)get_month_name(i)) == 0)
- return i;
- return 0;
-}
-
-int day_atoi(const char *string)
-{
- int i;
- for (i = DAY_MIN; i <= DAY_MAX; i++)
- if (strcasecmp(string, (char *)get_day_name(i)) == 0)
- return i;
- return 0;
-}
-
-/*
- * Returns ordinal suffix (st, nd, rd, th) for a day
- */
-const char *day_suffix(int day)
-{
- static const char *suffix[]={"th", "st", "nd", "rd"};
- register int i;
-
- i = 0;
-
- if (day > 100)
- day %= 100;
- if (day < 11 || day > 13)
- i = day % 10;
- if (i > 3)
- i = 0;
-
- return(suffix[i]);
-} /* day_suffix */
-
-/*
- * Returns the short name of the day of week, format "%-3s"
- */
-const char *short3_day_name(const int day)
-{
- static const char *name[]={"invalid day", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
-
- return(((day<DAY_MIN)||(day>DAY_MAX)) ? name[0] : name[day]);
-} /* short3_day_name */
-
-/*
- * Returns the short name of day of week
- */
-const char *short_day_name(const int day)
-{
- static const char *name[]={"invalid day", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"};
-
- return(((day<DAY_MIN)||(day>DAY_MAX)) ? name[0] : name[day]);
-} /* short_day_name */
-
-/*
- * Returns the complete name of the day
- */
-const char *get_day_name(const int day)
-{
- static const char *name[]={"invalid day", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
-
- return(((day<DAY_MIN)||(day>DAY_MAX)) ? name[0] : name[day]);
-} /* day_name */
-
-/*
- * Returns the short name of the month
- */
-const char *short_month_name(const int month)
-{
- static const char *name[]={ "invalid month", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
- return(((month<MONTH_MIN)||(month>MONTH_MAX)) ? name[0] : name[month]);
-} /* short_month_name() */
-
-/*
- * Returns the name of the month
- */
-const char *get_month_name(const int month)
-{
- static const char *name[]={ "invalid month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
-
- return(((month<MONTH_MIN)||(month>MONTH_MAX)) ? name[0] : name[month]);
-} /* month_name() */
-
-/*
- * Compute the absolute number of days of the given date since 1 Jan 0001
- * respecting the missing period of the Gregorian Reformation
- * I am glad someone else worked this one out!! - cs
- */
-unsigned long int date2num(const int day, const int month, const int year)
-{
- auto unsigned long int julian_days;
-
- julian_days = (unsigned long int)((year-1)*(unsigned long int)(DAY_LAST)+((year-1)>>2));
-
- if (year > greg->year
- || ( (year == greg->year)
- && ( month > greg->month
- || ( (month == greg->month)
- && (day > greg->last_day)))))
- julian_days -= (unsigned long int)(greg->last_day - greg->first_day + 1);
- if (year > greg->year) {
- julian_days += (((year-1) / 400) - (greg->year / 400));
- julian_days -= (((year-1) / 100) - (greg->year / 100));
- if (!(greg->year % 100) && (greg->year % 400))
- julian_days--;
- }
- julian_days += (unsigned long int)mvec[month-1];
- julian_days += day;
- if ( (days_of_february(year) == 29) && (month > 2))
- julian_days++;
-
- return(julian_days);
-} /* date2num */
-
-/*
- * Computes the weekday of a Gregorian/Julian calendar date
- * (month must be 1..12) returns 1..7 (mo..su)
- */
-int weekday_of_date(const int day, const int month, const int year)
-{
- auto unsigned long int julian_days=date2num(day, month,year)%DAY_MAX;
-
- return((julian_days>2) ? (int)julian_days-2 : (int)julian_days+5);
-} /* weekday_of_date() */
-
diff --git a/calendar/calcs.h b/calendar/calcs.h
deleted file mode 100644
index f331bf7335..0000000000
--- a/calendar/calcs.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * function prototypes
- */
-int days_of_february(const int year);
-int is_leap_year(const int year);
-int valid_date(const int day, const int month, const int year);
-void get_system_date(int *day, int *month, int *year);
-void prev_date(int *day, int *month, int *year);
-void next_date(int *day, int *month, int *year);
-int month_atoi(const char *string);
-int day_atoi(const char *string);
-const char *day_suffix(int day);
-const char *short3_day_name(int day);
-const char *short_day_name(int day);
-const char *get_day_name(int day);
-const char *short_month_name(int month);
-const char *get_month_name(int month);
-unsigned long int date2num(const int day, const int month, const int year);
-int weekday_of_date(const int day, const int month, const int year);
-
-
-/*
- * Important preprocessor symbols for the internal ranges.
- */
-#define DAY_LAST 365 /* Last day in a NON leap year */
-#define DAY_MIN 1 /* Minimum day of week/month/year */
-#define DAY_MAX 7 /* Maximum day/amount of days of week */
-#define WEEK_MAX 52 /* Maximum week number of year */
-#define MONTH_LAST 31 /* Highest day number in a month */
-#define MONTH_MIN 1 /* Minimum month of year */
-#define MONTH_MAX 12 /* Maximum month of year */
-#define YEAR_MIN 1 /* Minimum year able to compute */
-#define YEAR_MAX 9999 /* Maximum year able to compute */
-#define EASTER_MIN 30 /* Minimum year for computing Easter Sunday (29+1) */
-#define EASTER_MAX YEAR_MAX /* Maximum year for computing Easter Sunday */
-#define MONTH_COLS 6 /* Maximum number of columns of a month */
-#define VEC_BLOCK 42 /* Maximum number of elements per month (7*6) */
-#define VEC_ELEMS 504 /* Maximum number of elements per year (42*12) */
-#define CENTURY 1900 /* Operating system standard starting century, DON'T change ! */
-
-/*
-* The Gregorian Reformation date record.
-*/
-typedef
- struct greg_type
- {
- int year; /* Year of Gregorian Reformation */
- int month; /* Month of Gregorian Reformation */
- int first_day; /* First missing day of Reformation period */
- int last_day; /* Last missing day of Reformation period */
- }
- Greg_struct;
-
diff --git a/calendar/calendar.c b/calendar/calendar.c
deleted file mode 100644
index a76d95758f..0000000000
--- a/calendar/calendar.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Calendar manager object
- *
- * This keeps track of a given calendar. Eventually this will abtract everything
- * related to getting calendars/saving calendars locally or to a remote Calendar Service
- *
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- *
- */
-
-#include <config.h>
-
-#include "alarm.h"
-#include "calendar.h"
-#include "timeutil.h"
-#include "versit/vcc.h"
-
-/* Our day range */
-time_t calendar_day_begin, calendar_day_end;
-
-Calendar *
-calendar_new (char *title)
-{
- Calendar *cal;
-
- cal = g_new0 (Calendar, 1);
- cal->title = g_strdup (title);
-
- return cal;
-}
-
-static void
-try_add (iCalObject *ico, CalendarAlarm *alarm, time_t start, time_t end)
-{
- alarm->trigger = start-alarm->offset;
-
- if (alarm->trigger < calendar_day_begin)
- return;
- if (alarm->trigger > calendar_day_end)
- return;
- alarm_add (alarm->trigger, calendar_notify, ico);
-}
-
-static int
-add_alarm (iCalObject *obj, time_t start, time_t end, void *closure)
-{
- if (obj->aalarm.enabled)
- try_add (obj, &obj->aalarm, start, end);
- if (obj->dalarm.enabled)
- try_add (obj, &obj->dalarm, start, end);
- if (obj->palarm.enabled)
- try_add (obj,&obj->palarm, start, end);
- if (obj->malarm.enabled)
- try_add (obj, &obj->malarm, start, end);
-
- return TRUE;
-}
-
-#define max(a,b) ((a > b) ? a : b)
-
-void
-ical_object_try_alarms (iCalObject *obj)
-{
- int ao, po, od, mo;
- int max_o;
-
- ao = alarm_compute_offset (&obj->aalarm);
- po = alarm_compute_offset (&obj->palarm);
- od = alarm_compute_offset (&obj->dalarm);
- mo = alarm_compute_offset (&obj->malarm);
-
- max_o = max (ao, max (po, max (od, mo)));
- if (max_o == -1)
- return;
-
- ical_object_generate_events (obj, calendar_day_begin, calendar_day_end + max_o, add_alarm, obj);
-}
-
-void
-calendar_add_object (Calendar *cal, iCalObject *obj)
-{
- obj->new = 0;
- switch (obj->type){
- case ICAL_EVENT:
- cal->events = g_list_prepend (cal->events, obj);
- ical_object_try_alarms (obj);
-#ifdef DEBUGGING_MAIL_ALARM
- obj->malarm.trigger = 0;
- calendar_notify (0, obj);
-#endif
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_prepend (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_prepend (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- if (!obj->uid){
- char buffer [80];
-
- snprintf (buffer, sizeof (buffer), "GnomeCalendar-%ld\n", time (NULL));
- }
-
- cal->modified = TRUE;
-
- /* FIXME: do we have to set the last_mod field in the object? */
-}
-
-void
-calendar_remove_object (Calendar *cal, iCalObject *obj)
-{
- switch (obj->type){
- case ICAL_EVENT:
- cal->events = g_list_remove (cal->events, obj);
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_remove (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_remove (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- cal->modified = TRUE;
-}
-
-void
-calendar_destroy (Calendar *cal)
-{
- g_list_foreach (cal->events, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->events);
-
- g_list_foreach (cal->todo, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->todo);
-
- g_list_foreach (cal->journal, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->journal);
-
- if (cal->title)
- g_free (cal->title);
- if (cal->filename)
- g_free (cal->filename);
-
- g_free (cal);
-}
-
-char *
-ice (time_t t)
-{
- static char buffer [100];
- struct tm *tm;
-
- tm = localtime (&t);
- sprintf (buffer, "%d/%d/%d", tm->tm_mday, tm->tm_mon, tm->tm_year);
- return buffer;
-}
-
-void
-calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
-{
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- ical_object_generate_events (object, start, end, cb, closure);
- }
-}
-
-void
-calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure)
-{
- calendar_iterate_on_objects (cal->events, start, end, cb, closure);
-}
-
-GList *
-calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func)
-{
- GList *new_events = 0;
-
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- if ((start <= object->dtstart) && (object->dtend <= end)){
- if (sort_func)
- new_events = g_list_insert_sorted (new_events, object, sort_func);
- else
- new_events = g_list_prepend (new_events, object);
- }
- }
-
- return new_events;
-}
-
-GList *
-calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->todo, start, end, sort_func);
-}
-
-GList *
-calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->journal, start, end, sort_func);
-}
-
-gint
-calendar_compare_by_dtstart (gpointer a, gpointer b)
-{
- iCalObject *obj1, *obj2;
- time_t diff;
-
- obj1 = a;
- obj2 = b;
-
- diff = obj1->dtstart - obj2->dtstart;
-
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-#define str_val(obj) (char *) vObjectUStringZValue (obj)
-
-/* Loads our calendar contents from a vObject */
-void
-calendar_load_from_vobject (Calendar *cal, VObject *vcal)
-{
- VObjectIterator i;
-
- initPropIterator (&i, vcal);
-
- while (moreIteration (&i)){
- VObject *this = nextVObject (&i);
- iCalObject *ical;
- const char *object_name = vObjectName (this);
-
- if (strcmp (object_name, VCDCreatedProp) == 0){
- cal->created = time_from_isodate (str_val (this));
- continue;
- }
-
- 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);
-
- if (ical)
- calendar_add_object (cal, ical);
- }
-}
-
-/* Loads a calendar from a file */
-char *
-calendar_load (Calendar *cal, char *fname)
-{
- VObject *vcal;
- time_t calendar_today;
-
- if (cal->filename){
- g_warning ("Calendar load called again\n");
- return "Internal error";
- }
-
- cal->filename = g_strdup (fname);
- vcal = Parse_MIME_FromFileName (fname);
- if (!vcal)
- return "Could not load the calendar";
-
- calendar_today = time (NULL);
- calendar_day_begin = time_start_of_day (calendar_today);
- calendar_day_end = time_end_of_day (calendar_today);
-
- calendar_load_from_vobject (cal, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
- return NULL;
-}
-
-void
-calendar_save (Calendar *cal, char *fname)
-{
- VObject *vcal;
- GList *l;
- time_t now = time (NULL);
-
- if (fname == NULL)
- fname = cal->filename;
-
- /* WE call localtime for the side effect of setting tzname */
- localtime (&now);
-
- vcal = newVObject (VCCalProp);
- addPropValue (vcal, VCProdIdProp, "-//GNOME//NONSGML GnomeCalendar//EN");
- addPropValue (vcal, VCTimeZoneProp, tzname [0]);
- addPropValue (vcal, VCVersionProp, VERSION);
- cal->temp = vcal;
-
- /* Events */
-
- for (l = cal->events; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- /* To-do entries */
-
- for (l = cal->todo; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- writeVObjectToFile (fname, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
-}
-
-static gint
-calendar_object_compare_by_start (gconstpointer a, gconstpointer b)
-{
- const CalendarObject *ca = a;
- const CalendarObject *cb = b;
- time_t diff;
-
- diff = ca->ev_start - cb->ev_start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
-{
- CalendarObject *co;
- GList **l = c;
-
- co = g_new (CalendarObject, 1);
- co->ev_start = start;
- co->ev_end = end;
- co->ico = obj;
- *l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start);
-
- return 1;
-}
-
-void
-calendar_destroy_event_list (GList *l)
-{
- GList *p;
-
- for (p = l; p; p = p->next)
- g_free (p->data);
- g_list_free (l);
-}
-
-GList *
-calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
-{
- GList *l = 0;
-
- calendar_iterate (cal, start, end, assemble_event_list, &l);
- return l;
-}
-
-void
-calendar_object_changed (Calendar *cal, iCalObject *obj, int flags)
-{
- if (!(flags & CHANGE_DATES))
- return;
-
- /* Remove any alarms on the alarm list for this object */
- while (alarm_kill (obj))
- ;
- ical_object_try_alarms (obj);
-}
diff --git a/calendar/calendar.h b/calendar/calendar.h
deleted file mode 100644
index 0a0e949d92..0000000000
--- a/calendar/calendar.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef CALENDAR_H
-#define CALENDAR_H
-
-#include "calobj.h"
-
-BEGIN_GNOME_DECLS
-
-typedef struct {
- /* This calendar's title */
- char *title;
-
- /* backing store for this calendar object */
- char *filename;
-
- /* The list of events; todo's and journal entries */
- GList *events;
- GList *todo;
- GList *journal;
-
- /* Time at which the calendar was created */
- time_t created;
-
- /* If the calendar was last modified */
- int modified;
- void *temp;
-} Calendar;
-
-/* This is only used by the calendar_get_events_in_range routine to get
- * a list of objects that recur on a specific date
- */
-typedef struct {
- time_t ev_start;
- time_t ev_end;
- iCalObject *ico;
-} CalendarObject;
-
-Calendar *calendar_new (char *title);
-char *calendar_load (Calendar *cal, char *fname);
-void calendar_save (Calendar *cal, char *fname);
-void calendar_add_object (Calendar *cal, iCalObject *obj);
-void calendar_remove_object (Calendar *cal, iCalObject *obj);
-void calendar_destroy (Calendar *cal);
-GList *calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-gint calendar_compare_by_dtstart (gpointer a, gpointer b);
-
-void calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure);
-void calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure);
-
-/* Note this routine returns a GList with CalendarObjects */
-GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
-
-/* Informs the calendar that obj information has changed */
-void calendar_object_changed (Calendar *cal, iCalObject *obj, int flags);
-
-/* Destroy the above list with this method */
-void calendar_destroy_event_list (GList *l);
-
-void calendar_notify (time_t, void *data);
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/calobj.c b/calendar/calobj.c
deleted file mode 100644
index d8ca3fe5db..0000000000
--- a/calendar/calobj.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/*
- * Calendar objects implementations.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <string.h>
-#include <glib.h>
-#include "calobj.h"
-#include "timeutil.h"
-#include "versit/vcc.h"
-
-iCalObject *
-ical_object_new (void)
-{
- iCalObject *ico;
-
- ico = g_new0 (iCalObject, 1);
-
- ico->seq = -1;
- ico->dtstamp = time (NULL);
-
- return ico;
-}
-
-static void
-default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
-{
- alarm->enabled = 0;
- alarm->type = type;
-
- if (type != ALARM_MAIL){
- alarm->count = 15;
- alarm->units = ALARM_MINUTES;
- } else {
- alarm->count = 1;
- alarm->units = ALARM_DAYS;
- }
-
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (def_mail);
- else
- alarm->data = g_strdup ("");
-}
-
-iCalObject *
-ical_new (char *comment, char *organizer, char *summary)
-{
- iCalObject *ico;
-
- ico = ical_object_new ();
-
- ico->comment = g_strdup (comment);
- ico->organizer = g_strdup (organizer);
- ico->summary = g_strdup (summary);
- ico->class = g_strdup ("PUBLIC");
- ico->status = g_strdup ("NEEDS ACTION");
-
- default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY);
- default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM);
- default_alarm (ico, &ico->malarm, organizer, ALARM_MAIL);
- default_alarm (ico, &ico->aalarm, organizer, ALARM_AUDIO);
-
- return 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);
-}
-
-#define free_if_defined(x) if (x){ g_free (x); x = 0; }
-#define lfree_if_defined(x) if (x){ list_free (x); x = 0; }
-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);
-}
-
-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))
- ;
- }
-}
-
-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
-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;
-}
-
-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;
-}
-
-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){
- 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);
- weekdaylist (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
- */
- 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');
- 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
- */
-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;
- }
-
- /* uid */
- if (has (o, VCUniqueStringProp)){
- ical->uid = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* 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);
- } 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 = "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);
- }
-
- /* related */
- if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo));
- 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)){
- ical->url = g_strdup (str_val (vo));
- 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);
- }
- }
- }
-
- /* 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);
- }
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_destroy (ical);
- return NULL;
- }
- free (the_str);
- }
- 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_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 (strlen (ical->summary)){
- s = addPropValue (o, VCSummaryProp, ical->summary);
- if (strchr (ical->summary, '\n'))
- addProp (s, VCQuotedPrintableProp);
- } else {
- addPropValue (o, VCSummaryProp, _("Appointment"));
- }
-
- /* 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->categories)
- store_list (o, VCCategoriesProp, ical->resources);
-
- /* priority */
- addPropValue (o, VCPriorityProp, to_str (ical->priority));
-
- /* transparency */
- addPropValue (o, VCTranspProp, to_str (ical->transp));
-
- /* related */
- if (ical->related)
- store_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);
- 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_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);
- 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;
-}
-
-static int
-generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
-{
- struct tm dt_start, dt_end, ref;
- time_t s_t, e_t;
-
- dt_start = *localtime (&ico->dtstart);
- dt_end = *localtime (&ico->dtend);
- ref = *localtime (&reference);
-
- dt_start.tm_mday = ref.tm_mday;
- dt_start.tm_mon = ref.tm_mon;
- dt_start.tm_year = ref.tm_year;
-
- dt_end.tm_mday = ref.tm_mday;
- dt_end.tm_mon = ref.tm_mon;
- dt_end.tm_year = ref.tm_year;
-
- s_t = mktime (&dt_start);
- if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
- return 1;
-
- e_t = mktime (&dt_end);
-
- if (s_t == -1 || e_t == -1){
- g_warning ("Produced invalid dates!\n");
- return 0;
- }
- return (*cb)(ico, s_t, e_t, closure);
-}
-
-#define time_in_range(x,a,b) ((x >= a) && (b ? x <= 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)
-{
- Recurrence *recur = ico->recur;
- time_t current;
- int first_week_day, i;
-
- if (!ico->recur){
- if ((end && (ico->dtstart < end) && ico->dtend > start) ||
- (end == 0 && ico->dtend > start)){
- time_t ev_s, ev_e;
-
- ev_s = ico->dtstart < start ? start : ico->dtstart;
- ev_e = ico->dtend > end ? end : ico->dtend;
- (*cb)(ico, ev_s, ev_e, closure);
- }
- return;
- }
-
- /* The event has a recurrence rule */
- if (end != 0){
- if (ico->dtstart > end)
- return;
- if (!IS_INFINITE (recur) && recur->enddate < start)
- return;
- }
-
- current = ico->dtstart;
- switch (recur->type){
- case RECUR_DAILY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, recur)){
- if (!generate (ico, current, cb, closure))
- return;
- }
-
- /* Advance */
- current = time_add_day (current, recur->interval);
-
- if (current == -1){
- g_warning ("RECUR_DAILY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
- break;
-
- case RECUR_WEEKLY:
- do {
- struct tm *tm = localtime (&current);
-
- if (time_in_range (current, start, end) && recur_in_range (current, recur)){
- if (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, (recur->interval-1) * 7 + 1);
- else
- current = time_add_day (current, 1);
-
- if (current == -1){
- g_warning ("RECUR_WEEKLY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
- break;
-
- case RECUR_MONTHLY_BY_POS:
- /* FIXME: We only deal with positives now */
- if (recur->u.month_pos < 0)
- return;
-
- if (recur->u.month_pos == 0)
- return;
-
- first_week_day = 7;
- for (i = 6; i >= 0; i--)
- if (recur->weekday & (1 << i))
- first_week_day = i;
-
- /* This should not happen, but take it into account */
- if (first_week_day == 7)
- return;
-
- do {
- struct tm tm;
- time_t t;
- int week_day_start;
-
- tm = *localtime (&current);
- tm.tm_mday = 1;
- t = mktime (&tm);
- tm = *localtime (&t);
- week_day_start = tm.tm_wday;
-
- tm.tm_mday = 7 * (recur->u.month_pos -
- ((week_day_start <= first_week_day ) ? 1 : 0)) -
- (week_day_start - first_week_day) + 1;
-
- t = mktime (&tm);
-
- if (time_in_range (t, start, end) && recur_in_range (current, recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance a month */
- current = mktime (&tm);
-
- tm.tm_mday = 1;
- tm.tm_mon += 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 = localtime (&current);
- time_t t;
- int p;
-
- p = tm->tm_mday;
- tm->tm_mday = recur->u.month_day;
- t = mktime (tm);
- if (time_in_range (t, start, end) && recur_in_range (current, recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance a month */
- tm->tm_mday = p;
- tm->tm_mon += recur->interval;
- current = mktime (tm);
- if (current == -1){
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
-
- case RECUR_YEARLY_BY_MONTH:
- case RECUR_YEARLY_BY_DAY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
- current = time_add_year (current, recur->interval);
- } while (current < end || (end == 0));
- }
-}
-
-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_end_of_day (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;
-}
diff --git a/calendar/calobj.h b/calendar/calobj.h
deleted file mode 100644
index d18acd4f8a..0000000000
--- a/calendar/calobj.h
+++ /dev/null
@@ -1,199 +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 "versit/vcc.h"
-
-BEGIN_GNOME_DECLS
-
-enum AlarmType {
- ALARM_MAIL,
- ALARM_PROGRAM,
- ALARM_DISPLAY,
- ALARM_AUDIO
-};
-
-enum AlarmUnit {
- ALARM_MINUTES,
- ALARM_HOURS,
- ALARM_DAYS
-};
-
-typedef struct {
- enum AlarmType type;
- int enabled;
- int count;
- enum AlarmUnit units;
- char *data;
-
- /* 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 struct {
- int valid; /* true if the Geography was specified */
- double latitude;
- double longitude;
-} iCalGeo;
-
-typedef enum {
- ICAL_OPAQUE,
- ICAL_TRANSPARENT
-} iCalTransp;
-
-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;
-
-#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 */
- 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 */
- time_t dtstamp;
- time_t dtstart;
- time_t dtend;
- GList *exdate; /* type: one or more time_t's */
- GList *exrule; /* type: one or more RECUR */
- iCalGeo geo;
- time_t last_mod;
- char *location;
- char *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;
-
- Recurrence *recur;
-
- int new;
- void *user_data; /* Generic data pointer */
-} 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_destroy (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);
-
-/* Returns the number of seconds configured to trigger the alarm in advance to an event */
-int alarm_compute_offset (CalendarAlarm *a);
-
-END_GNOME_DECLS
-
-#endif
-
diff --git a/calendar/clist.c b/calendar/clist.c
deleted file mode 100644
index 8491d45174..0000000000
--- a/calendar/clist.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * clist.c: All the good stuf to work with the clists that are used for the
- * tasklist.
- *
- * This file is largely based upon GTT code by Eckehard Berns.
- *
- * 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>
-
-static void
-select_row(GtkCList *clist, gint row, gint col, GdkEventButton *event)
-{
- if (!event) return;
-
- g_print("select_row, row=%d col=%d button=%d\n", row, col, event->button);
-}
-
-static void
-unselect_row(GtkCList *clist, gint row, gint col, GdkEventButton *event)
-{
- if (!event) return;
-
- g_print("unselect_row, row=%d col=%d button=%d\n", row, col, event->button);
-}
-
-static void
-click_column(GtkCList *clist, gint col)
-{
-
- g_print("click_column, col=%d\n ", col);
-}
-
-
-
-
-GtkWidget * create_clist(void)
-{
- GtkStyle *style;
- GdkGCValues vals;
-
- GtkWidget *clist;
- char *titles[2] = {
- N_("Time"),
- N_("Event")
- };
-
- titles[0] = _(titles[0]);
- titles[1] = _(titles[1]);
- clist = gtk_clist_new_with_titles(2,titles);
- gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 0, GTK_JUSTIFY_CENTER);
- style = gtk_widget_get_style(clist);
- g_return_val_if_fail(style != NULL, NULL);
- gdk_gc_get_values(style->fg_gc[0], &vals);
- gtk_clist_set_column_width(GTK_CLIST(clist), 0, gdk_string_width(vals.font, "00:00"));
- gtk_clist_set_policy(GTK_CLIST(clist),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_signal_connect(GTK_OBJECT(clist), "select_row",
- GTK_SIGNAL_FUNC(select_row), NULL);
- gtk_signal_connect(GTK_OBJECT(clist), "click_column",
- GTK_SIGNAL_FUNC(click_column), NULL);
- gtk_signal_connect(GTK_OBJECT(clist), "unselect_row",
- GTK_SIGNAL_FUNC(unselect_row), NULL);
- return clist;
-}
-
-void
-setup_clist(GtkWidget *clist)
-{
- char buf1[10];
- char buf2[1000] = "Programming GNOME";
- char *tmp[2] = { buf1, buf2 };
- int i, row;
-
- gtk_clist_freeze(GTK_CLIST(clist));
- gtk_clist_clear(GTK_CLIST(clist));
- for (i=0; i < 24; i++) {
- sprintf(buf1, "%d:00", i);
- row = gtk_clist_append(GTK_CLIST(clist), tmp);
- }
- gtk_clist_thaw(GTK_CLIST(clist));
-
-}
diff --git a/calendar/clist.h b/calendar/clist.h
deleted file mode 100644
index 061c1b316c..0000000000
--- a/calendar/clist.h
+++ /dev/null
@@ -1,2 +0,0 @@
-GtkWidget *create_clist(void);
-void setup_clist(GtkWidget *clist);
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
deleted file mode 100644
index 3189b11300..0000000000
--- a/calendar/eventedit.c
+++ /dev/null
@@ -1,1479 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors: Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <string.h>
-#include "calendar.h"
-#include "eventedit.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-static void event_editor_class_init (EventEditorClass *class);
-static void event_editor_init (EventEditor *ee);
-static void event_editor_destroy (GtkObject *object);
-
-/* Note: do not i18n these strings, they are part of the vCalendar protocol */
-static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
-
-static GnomeDialogClass *parent_class;
-
-struct numbered_item {
- char *text;
- int num;
-};
-
-
-guint
-event_editor_get_type (void)
-{
- static guint event_editor_type = 0;
-
- if(!event_editor_type) {
- GtkTypeInfo event_editor_info = {
- "EventEditor",
- sizeof(EventEditor),
- sizeof(EventEditorClass),
- (GtkClassInitFunc) event_editor_class_init,
- (GtkObjectInitFunc) event_editor_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
- };
- event_editor_type = gtk_type_unique (gnome_dialog_get_type (), &event_editor_info);
- }
- return event_editor_type;
-}
-
-static void
-event_editor_class_init (EventEditorClass *class)
-{
- GtkObjectClass *object_class;
-
- parent_class = gtk_type_class (gnome_dialog_get_type ());
- object_class = (GtkObjectClass*) class;
- object_class->destroy = event_editor_destroy;
-}
-
-GtkWidget *
-adjust (GtkWidget *w, gfloat x, gfloat y, gfloat xs, gfloat ys)
-{
- GtkWidget *a = gtk_alignment_new (x, y, xs, ys);
-
- gtk_container_add (GTK_CONTAINER (a), w);
- return a;
-}
-
-static 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;
-}
-
-/*
- * Checks if the day range occupies all the day, and if so, check the
- * box accordingly
- */
-static void
-ee_check_all_day (EventEditor *ee)
-{
- time_t ev_start, ev_end;
-
- ev_start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ev_end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (get_time_t_hour (ev_start) <= day_begin && get_time_t_hour (ev_end) >= day_end)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 1);
- else
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 0);
-}
-
-/*
- * Callback: checks that the dates are start < end
- */
-static void
-check_dates (GnomeDateEdit *gde, EventEditor *ee)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start > end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->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;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->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;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-}
-
-/*
- * 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)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start >= end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->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;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->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;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-
- /* Check whether the event spans the whole day */
-
- ee_check_all_day (ee);
-}
-
-/*
- * Callback: all day event box clicked
- */
-static void
-set_all_day (GtkToggleButton *toggle, EventEditor *ee)
-{
- struct tm *tm;
- time_t start_t;
-
- start_t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- tm = localtime (&start_t);
- tm->tm_hour = day_begin;
- tm->tm_min = 0;
- tm->tm_sec = 0;
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (tm));
-
- if (toggle->active)
- tm->tm_hour = day_end;
- else
- tm->tm_hour++;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (tm));
-}
-
-static GtkWidget *
-event_editor_setup_time_frame (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *start_time, *end_time;
- GtkTable *t;
-
- frame = gtk_frame_new (_("Time"));
- t = GTK_TABLE (ee->general_time_table = gtk_table_new (1, 1, 0));
- gtk_container_border_width (GTK_CONTAINER (t), 4);
- gtk_table_set_row_spacings (t, 4);
- gtk_table_set_col_spacings (t, 4);
- gtk_container_add (GTK_CONTAINER (frame), ee->general_time_table);
-
- /* 1. Start time */
- if (ee->ical->dtstart == 0){
- ee->ical->dtstart = time (NULL);
- ee->ical->dtend = time_add_minutes (ee->ical->dtstart, 30);
- }
- ee->start_time = start_time = gnome_date_edit_new (ee->ical->dtstart, TRUE, !am_pm_flag);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (start_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (start_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("Start time:")), 1, 2, 1, 2,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, start_time, 2, 3, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 2. End time */
- ee->end_time = end_time = gnome_date_edit_new (ee->ical->dtend, TRUE, !am_pm_flag);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) end_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (end_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (end_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("End time:")), 1, 2, 2, 3,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, end_time, 2, 3, 2, 3,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 3. All day checkbox */
- ee->general_allday = gtk_check_button_new_with_label (_("All day event"));
- gtk_signal_connect (GTK_OBJECT (ee->general_allday), "toggled",
- GTK_SIGNAL_FUNC (set_all_day), ee);
- gtk_table_attach (t, ee->general_allday, 3, 4, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 4, 0);
- ee_check_all_day (ee);
-
- return frame;
-}
-
-static GtkWidget *
-timesel_new (void)
-{
- GtkWidget *menu, *option_menu;
- char *items [] = { N_("Minutes"), N_("Hours"), N_("Days") };
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- for (i = 0; i < 3; i++){
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items [i]));
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- return option_menu;
-}
-
-/*
- * Set the sensitive state depending on whether the alarm enabled flag.
- */
-static void
-ee_alarm_setting (CalendarAlarm *alarm, int sensitive)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_count), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_timesel), sensitive);
-
- if (alarm->type == ALARM_PROGRAM || alarm->type == ALARM_MAIL){
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_entry), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_label), sensitive);
- }
-}
-
-static void
-alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm)
-{
- ee_alarm_setting (alarm, toggle->active);
-}
-
-#define FXS (GTK_FILL | GTK_EXPAND | GTK_SHRINK)
-#define FS (GTK_FILL | GTK_SHRINK)
-
-static void
-ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y)
-{
- GtkWidget *entry;
-
- alarm->w_enabled = gtk_check_button_new_with_label (str);
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (alarm_toggle), alarm);
- gtk_table_attach (table, alarm->w_enabled, 0, 1, y, y+1, FS, FS, 0, 0);
-
- alarm->w_count = make_spin_button (alarm->count, 0, 10000);
- gtk_table_attach (table, alarm->w_count, 1, 2, y, y+1, FS, FS, 0, 0);
-
- alarm->w_timesel = timesel_new ();
- gtk_option_menu_set_history (GTK_OPTION_MENU (alarm->w_timesel), alarm->units);
- gtk_table_attach (table, alarm->w_timesel, 2, 3, y, y+1, FS, FS, 0, 0);
-
- switch (type){
- case ALARM_MAIL:
- alarm->w_label = gtk_label_new (_("Mail to:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gtk_entry_new ();
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : "");
- break;
-
- case ALARM_PROGRAM:
- alarm->w_label = gtk_label_new (_("Run program:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gnome_file_entry_new ("alarm-program", _("Select program to run at alarm time"));
- entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry));
- gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : "");
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- break;
-
- default:
- break;
- }
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled), alarm->enabled);
- ee_alarm_setting (alarm, alarm->enabled);
-}
-
-static GtkWidget *
-ee_alarm_widgets (EventEditor *ee)
-{
- GtkWidget *table, *mailto, *mailte, *l;
-
- l = gtk_frame_new (_("Alarms"));
-
- table = gtk_table_new (1, 1, 0);
- gtk_container_border_width (GTK_CONTAINER (table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 4);
- gtk_container_add (GTK_CONTAINER (l), table);
-
- mailto = gtk_label_new (_("Mail to:"));
- mailte = gtk_entry_new ();
-
- ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1);
- ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2);
- ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3);
- ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4);
-
- return l;
-}
-
-static GtkWidget *
-ee_classification_widgets (EventEditor *ee)
-{
- GtkWidget *rpub, *rpriv, *rconf;
- GtkWidget *frame, *hbox;
-
- frame = gtk_frame_new (_("Classification"));
-
- hbox = gtk_hbox_new (TRUE, 0);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- rpub = gtk_radio_button_new_with_label (NULL, _("Public"));
- rpriv = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Private"));
- rconf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential"));
-
- gtk_box_pack_start (GTK_BOX (hbox), rpub, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rpriv, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rconf, FALSE, FALSE, 0);
-
- if (strcmp (ee->ical->class, class_names[0]))
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpub), TRUE);
- else if (strcmp (ee->ical->class, class_names[1]))
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpriv), TRUE);
- else if (strcmp (ee->ical->class, class_names[2]))
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rconf), TRUE);
-
- ee->general_radios = rpub;
-
- return frame;
-}
-
-/*
- * Retrieves the information from the CalendarAlarm widgets and stores them
- * on the CalendarAlarm generic values
- */
-void
-ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type)
-{
- GtkWidget *item;
- GtkMenu *menu;
- GList *child;
- int idx;
-
- if (alarm->data){
- g_free (alarm->data);
- alarm->data = 0;
- }
-
- alarm->enabled = GTK_TOGGLE_BUTTON (alarm->w_enabled)->active;
-
- if (!alarm->enabled)
- return;
-
- if (type == ALARM_PROGRAM)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (alarm->w_entry))));
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (alarm->w_entry)));
-
- /* Find out the index */
- menu = GTK_MENU (GTK_OPTION_MENU (alarm->w_timesel)->menu);
-
- item = gtk_menu_get_active (menu);
-
- for (idx = 0, child = GTK_MENU_SHELL (menu)->children; child->data != item; child = child->next)
- idx++;
-
- alarm->units = idx;
- alarm->count = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alarm->w_count));
-}
-
-static void
-ee_store_general_values_to_ical (EventEditor *ee)
-{
- GtkRadioButton *radio = GTK_RADIO_BUTTON (ee->general_radios);
- iCalObject *ical = ee->ical;
- GSList *list = radio->group;
- int idx;
- time_t now;
-
- now = time (NULL);
- ical->dtstart = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ical->dtend = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (ical->summary)
- g_free (ical->summary);
-
- ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
-
- ee_store_alarm (&ical->dalarm, ALARM_DISPLAY);
- ee_store_alarm (&ical->aalarm, ALARM_AUDIO);
- ee_store_alarm (&ical->palarm, ALARM_PROGRAM);
- ee_store_alarm (&ical->malarm, ALARM_MAIL);
-
- for (idx = 0; list; list = list->next) {
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
- idx++;
- }
- g_free (ical->class);
- ical->class = g_strdup (class_names [idx]);
-}
-
-static int
-option_menu_active_number (GtkWidget *omenu)
-{
- GtkWidget *menu;
- GtkWidget *item;
- struct numbered_item *ni;
-
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
- item = gtk_menu_get_active (GTK_MENU (menu));
-
- ni = gtk_object_get_user_data (GTK_OBJECT (item));
-
- return ni->num;
-}
-
-static int
-ee_store_recur_rule_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- int i, j;
- GSList *list;
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_rr_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_rr_group) - i - 1; /* buttons are stored in reverse order of insertion */
-
- /* None selected, no rule to be stored */
- if (i == 0)
- return 0;
-
- if (!ical->recur)
- ical->recur = g_new0 (Recurrence, 1);
-
- switch (i) {
- case 1:
- /* Daily */
- ical->recur->type = RECUR_DAILY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_day_period));
- break;
-
- case 2:
- /* Weekly */
- ical->recur->type = RECUR_WEEKLY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_week_period));
- ical->recur->weekday = 0;
-
- for (j = 0; j < 7; j++)
- if (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days[j])->active) {
- if (j == 6)
- ical->recur->weekday |= 1 << 0; /* sunday is at bit 0 */
- else
- ical->recur->weekday |= 1 << (j + 1);
- }
-
- break;
-
- case 3:
- /* Monthly */
-
- if (GTK_WIDGET_SENSITIVE (ee->recur_rr_month_date)) {
- /* by day */
-
- ical->recur->type = RECUR_MONTHLY_BY_DAY;
- ical->recur->u.month_day =
- gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_month_date));
- } else {
- /* by position */
-
- ical->recur->type = RECUR_MONTHLY_BY_POS;
-
- ical->recur->u.month_pos = option_menu_active_number (ee->recur_rr_month_day);
- ical->recur->u.month_day = option_menu_active_number (ee->recur_rr_month_weekday);
- }
-
-
- break;
-
- case 4:
- /* Yearly */
- ical->recur->type = RECUR_YEARLY_BY_DAY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_year_period));
- /* FIXME: need to specify anything else? I am assuming the code will look at the dtstart
- * to figure out when to recur. - Federico
- */
- break;
-
- default:
- g_assert_not_reached ();
- }
- return 1;
-}
-
-static void
-ee_store_recur_end_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GSList *list;
- int i;
-
- /* Ending date of recurrence */
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_ed_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_ed_group) - i - 1; /* the list is stored in reverse order of insertion */
-
- switch (i) {
- case 0:
- /* repeat forever */
- ical->recur->_enddate = 0;
- ical->recur->enddate = 0;
- ical->recur->duration = 0;
- break;
-
- case 1:
- /* end date */
- ical->recur->_enddate = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ed_end_on));
- ical->recur->enddate = ical->recur->_enddate;
- ical->recur->duration = 0;
- break;
-
- case 2:
- /* end after n occurrences */
- ical->recur->duration = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_ed_end_after));
- ical_object_compute_end (ical);
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static void
-free_exdate (iCalObject *ical)
-{
- GList *list;
-
- if (!ical->exdate)
- return;
-
- for (list = ical->exdate; list; list = list->next)
- g_free (list->data);
-
- g_list_free (ical->exdate);
- ical->exdate = NULL;
-}
-
-static void
-ee_store_recur_exceptions_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GtkCList *clist;
- int i;
- time_t *t;
-
- ical = ee->ical;
- clist = GTK_CLIST (ee->recur_ex_clist);
-
- free_exdate (ical);
-
- for (i = 0; i < clist->rows; i++) {
- t = gtk_clist_get_row_data (clist, i);
- ical->exdate = g_list_prepend (ical->exdate, t);
- }
-}
-
-static void
-ee_store_recur_values_to_ical (EventEditor *ee)
-{
- if (ee_store_recur_rule_to_ical (ee)){
- ee_store_recur_exceptions_to_ical (ee);
- ee_store_recur_end_to_ical (ee);
- } else if (ee->ical->recur) {
- g_free (ee->ical->recur);
- ee->ical->recur = NULL;
- if (ee->ical->exdate){
- GList *l = ee->ical->exdate;
-
- for (; l; l = l->next)
- g_free (l->data);
- g_list_free (l);
- }
- }
-}
-
-/*
- * Retrieves all of the information from the different widgets and updates
- * the iCalObject accordingly.
- */
-static void
-ee_store_dlg_values_to_ical (EventEditor *ee)
-{
- time_t now;
-
- ee_store_general_values_to_ical (ee);
- ee_store_recur_values_to_ical (ee);
-
- now = time (NULL);
-
- /* FIXME: This is not entirely correct; we should check if the values actually changed */
- ee->ical->last_mod = now;
-
- if (ee->ical->new)
- ee->ical->created = now;
-}
-
-static void
-ee_ok (GtkWidget *widget, EventEditor *ee)
-{
- ee_store_dlg_values_to_ical (ee);
-
- if (ee->ical->new)
- gnome_calendar_add_object (ee->gnome_cal, ee->ical);
- else
- gnome_calendar_object_changed (ee->gnome_cal, ee->ical, CHANGE_ALL);
-
- ee->ical->new = 0;
-}
-
-static void
-ee_cancel (GtkWidget *widget, EventEditor *ee)
-{
- if (ee->ical->new) {
- ical_object_destroy (ee->ical);
- ee->ical = NULL;
- }
-
-}
-
-static void
-ee_create_buttons (EventEditor *ee)
-{
- gnome_dialog_append_buttons(GNOME_DIALOG(ee),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL, NULL);
-
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 0, GTK_SIGNAL_FUNC(ee_ok), ee);
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 1, GTK_SIGNAL_FUNC(ee_cancel), ee);
-
- return;
-}
-
-/*
- * Load the contents in a delayed fashion, as the GtkText widget needs it
- */
-static void
-ee_fill_summary (GtkWidget *widget, EventEditor *ee)
-{
- int pos = 0;
-
- gtk_editable_insert_text (GTK_EDITABLE (ee->general_summary), ee->ical->summary,
- strlen (ee->ical->summary), &pos);
- gtk_text_thaw (GTK_TEXT (ee->general_summary));
-}
-
-enum {
- OWNER_LINE,
- DESC_LINE,
- SUMMARY_LINE,
- TIME_LINE,
- ALARM_LINE,
- CLASS_LINE
-};
-
-/* Create/setup the general page */
-static void
-ee_init_general_page (EventEditor *ee)
-{
- GtkWidget *l;
- GtkWidget *hbox;
-
- ee->general_table = gtk_table_new (1, 1, FALSE);
- gtk_container_border_width (GTK_CONTAINER (ee->general_table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), GTK_WIDGET (ee->general_table),
- gtk_label_new (_("General")));
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_table_attach (GTK_TABLE (ee->general_table), hbox,
- 0, 1, OWNER_LINE, OWNER_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 4);
-
- l = gtk_label_new (_("Owner:"));
- gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
-
- ee->general_owner = gtk_label_new (ee->ical->organizer ? ee->ical->organizer : _("?"));
- gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4);
-
- l = gtk_label_new (_("Summary:"));
- gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, DESC_LINE, DESC_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- ee->general_summary = gtk_text_new (NULL, NULL);
- gtk_text_freeze (GTK_TEXT (ee->general_summary));
- gtk_signal_connect (GTK_OBJECT (ee->general_summary), "realize",
- GTK_SIGNAL_FUNC (ee_fill_summary), ee);
- gtk_widget_set_usize (ee->general_summary, 0, 60);
- gtk_text_set_editable (GTK_TEXT (ee->general_summary), 1);
- gtk_table_attach (GTK_TABLE (ee->general_table), ee->general_summary,
- 0, 1, SUMMARY_LINE, SUMMARY_LINE+1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_alarm_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, ALARM_LINE, ALARM_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = event_editor_setup_time_frame (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, TIME_LINE, TIME_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_classification_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, CLASS_LINE, CLASS_LINE + 1,
- GTK_EXPAND | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-}
-
-static void
-ee_init_summary_page (EventEditor *ee)
-{
-}
-
-struct {
- char *name;
-} recurrence_types [] = {
- { N_("None") },
- { N_("Daily") },
- { N_("Weekly") },
- { N_("Monthly") },
- { N_("Yearly") },
- { 0 }
-};
-
-static void
-recurrence_toggled (GtkRadioButton *radio, EventEditor *ee)
-{
- GSList *list = ee->recur_rr_group;
- int which;
-
- if (!GTK_TOGGLE_BUTTON (radio)->active)
- return;
-
- for (which = 0; list; list = list->next, which++) {
- if (list->data == radio) {
- gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_rr_notebook), 4 - which);
- return;
- }
- }
-}
-
-static struct numbered_item weekday_positions[] = {
- { N_("1st"), 1 },
- { N_("2nd"), 2 },
- { N_("3rd"), 3 },
- { N_("4th"), 4 },
- { N_("5th"), 5 },
- { 0 }
-};
-
-static struct numbered_item weekday_names[] = {
- { N_("Monday"), 1 },
- { N_("Tuesday"), 2 },
- { N_("Wednesday"), 3 },
- { N_("Thursday"), 4 },
- { N_("Friday"), 5 },
- { N_("Saturday"), 6 },
- { N_("Sunday"), 0 }, /* on the spec, Sunday is zero */
- { 0 }
-};
-
-static GtkWidget *
-make_numbered_menu (struct numbered_item *items, int sel)
-{
- GtkWidget *option_menu, *menu;
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
-
- for (i = 0; items[i].text; i++) {
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_object_set_user_data (GTK_OBJECT (item), &items[i]);
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), sel);
-
- return option_menu;
-}
-
-static void
-month_sensitize (EventEditor *ee, int state)
-{
- gtk_widget_set_sensitive (ee->recur_rr_month_date, state);
- gtk_widget_set_sensitive (ee->recur_rr_month_date_label, state);
-
- gtk_widget_set_sensitive (ee->recur_rr_month_day, !state);
- gtk_widget_set_sensitive (ee->recur_rr_month_weekday, !state);
-}
-
-static void
-recur_month_enable_date (GtkToggleButton *button, EventEditor *ee)
-{
- month_sensitize (ee, button->active);
-}
-
-static void
-desensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), !toggle->active);
-}
-
-static void
-ee_rp_init_rule (EventEditor *ee)
-{
- static char *day_names [] = { N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat"), N_("Sun") };
- GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *b, *week_hbox, *week_day, *w;
- GtkWidget *none, *daily, *weekly, *monthly, *yearly;
- GtkNotebook *notebook;
- GSList *group;
- int i, page, day_period, week_period, month_period, year_period;
- int week_vector, default_day, def_pos, def_off;
- struct tm *tm;
-
- tm = localtime (&ee->ical->dtstart);
-
- f = gtk_frame_new (_("Recurrence rule"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (f), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), gtk_vseparator_new (), FALSE, FALSE, 0);
-
- ee->recur_rr_notebook = gtk_notebook_new ();
- notebook = GTK_NOTEBOOK (ee->recur_rr_notebook);
- gtk_box_pack_start (GTK_BOX (hbox), ee->recur_rr_notebook, TRUE, TRUE, 0);
-
- day_period = 1;
- week_period = 1;
- month_period = 1;
- year_period = 1;
-
- /* Default to today */
-
- week_vector = 1 << tm->tm_wday;
- default_day = tm->tm_mday;
- def_pos = 0;
- def_off = 0;
-
- /* Determine which should be the default selection */
-
- page = 0;
- if (ee->ical->recur) {
- enum RecurType type = ee->ical->recur->type;
- int interval = ee->ical->recur->interval;
-
- switch (type) {
- case RECUR_DAILY:
- page = 1;
- day_period = interval;
- break;
-
- case RECUR_WEEKLY:
- page = 2;
- week_period = interval;
- week_vector = ee->ical->recur->weekday;
- break;
-
- case RECUR_MONTHLY_BY_POS:
- page = 3;
- month_period = interval;
- def_pos = ee->ical->recur->u.month_pos;
- default_day = ee->ical->recur->u.month_day;
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- page = 3;
- month_period = interval;
- default_day = ee->ical->recur->u.month_day;
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- page = 4;
- year_period = interval;
- break;
-
- case RECUR_YEARLY_BY_DAY:
- page = 4;
- year_period = interval;
- break;
- }
- } else
- page = 0;
-
- /* The recurrency selector */
-
- for (i = 0, group = NULL; recurrence_types [i].name; i++) {
- r = gtk_radio_button_new_with_label (group, _(recurrence_types [i].name));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (r));
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == page);
- gtk_signal_connect (GTK_OBJECT (r), "toggled", GTK_SIGNAL_FUNC (recurrence_toggled), ee);
- gtk_box_pack_start (GTK_BOX (vbox), r, FALSE, FALSE, 0);
-
- if (i == 0)
- gtk_signal_connect (GTK_OBJECT (r), "toggled",
- (GtkSignalFunc) desensitize_on_toggle,
- ee->recur_hbox);
- }
-
- ee->recur_rr_group = group;
-
- /* 0. No recurrence */
- none = gtk_label_new ("");
-
- /* 1. The daily recurrence */
-
- daily = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (daily), b, FALSE, FALSE, 0);
-
- ee->recur_rr_day_period = make_spin_button (day_period, 1, 10000);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("Every")), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_day_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("day(s)")), FALSE, FALSE, 0);
-
- /* 2. The weekly recurrence */
-
- weekly = gtk_vbox_new (FALSE, 4);
-
- week_hbox = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_hbox, FALSE, FALSE, 0);
-
- /* 2.1 The week period selector */
-
- ee->recur_rr_week_period = make_spin_button (week_period, 1, 10000);
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("Every")), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), ee->recur_rr_week_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("week(s)")), FALSE, FALSE, 0);
-
- /* 2.2 The week day selector */
-
- week_day = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_day, FALSE, FALSE, 0);
-
- for (i = 0; i < 7; i++) {
- ee->recur_rr_week_days [i] = gtk_check_button_new_with_label (_(day_names [i]));
- gtk_box_pack_start (GTK_BOX (week_day), ee->recur_rr_week_days [i], FALSE, FALSE, 0);
-
- if (week_vector & (1 << ((i + 1) % 7))) /* on the spec, Sunday is 0 */
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days [i]), TRUE);
- }
-
- /* 3. The monthly recurrence */
-
- monthly = gtk_table_new (0, 0, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (monthly), 4);
- gtk_table_set_col_spacings (GTK_TABLE (monthly), 4);
-
- re = gtk_radio_button_new_with_label (NULL, _("Recur on the"));
- ee->recur_rr_month_date = make_spin_button (default_day, 1, 31);
- ee->recur_rr_month_date_label = w = gtk_label_new (_("th day of the month"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (monthly), re,
- 0, 1, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_date,
- 1, 2, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), w,
- 2, 3, 0, 1, FS, FS, 0, 0);
- gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee);
-
- r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (re)), _("Recur on the"));
- ee->recur_rr_month_day = make_numbered_menu (weekday_positions, def_pos);
- ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, default_day);
- gtk_table_attach (GTK_TABLE (monthly), r1,
- 0, 1, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_day,
- 1, 2, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_weekday,
- 2, 3, 1, 2, FS, FS, 0, 0);
-
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("Every")),
- 3, 4, 0, 2, FS, FS, 0, 0);
- ee->recur_rr_month_period = make_spin_button (month_period, 1, 10000);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_period,
- 4, 5, 0, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")),
- 5, 6, 0, 2, FS, FS, 0, 0);
-
- if (ee->ical->recur) {
- if (ee->ical->recur->type == RECUR_MONTHLY_BY_POS)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r1), 1);
- } else
- recur_month_enable_date (GTK_TOGGLE_BUTTON (re), ee);
-
- /* 4. The yearly recurrence */
-
- yearly = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (yearly), b, FALSE, FALSE, 0);
-
- ee->recur_rr_year_period = make_spin_button (year_period, 1, 10000);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("Every")), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_year_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("year(s)")), FALSE, FALSE, 0);
-
- /* Finish setting this up */
-
- gtk_notebook_append_page (notebook, none, gtk_label_new (""));
- gtk_notebook_append_page (notebook, daily, gtk_label_new (""));
- gtk_notebook_append_page (notebook, weekly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, monthly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, yearly, gtk_label_new (""));
- gtk_notebook_set_show_tabs (notebook, FALSE);
- gtk_notebook_set_show_border (notebook, FALSE);
-
- gtk_notebook_set_page (notebook, page);
-
- /* Attach to the main box */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), f, FALSE, FALSE, 0);
-}
-
-static void
-sensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), toggle->active);
-}
-
-static void
-ee_rp_init_ending_date (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
- GSList *group;
- GtkWidget *radio0, *radio1, *radio2;
- GtkWidget *hbox;
- GtkWidget *ihbox;
- GtkWidget *widget;
- time_t enddate;
- int repeat;
-
- frame = gtk_frame_new (_("Ending date"));
-
- vbox = gtk_vbox_new (TRUE, 4);
- gtk_container_border_width (GTK_CONTAINER (vbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- group = NULL;
-
- /* repeat forever */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio0 = gtk_radio_button_new_with_label (group, _("Repeat forever"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio0));
- gtk_box_pack_start (GTK_BOX (hbox), radio0, FALSE, FALSE, 0);
-
- /* end on date */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio1 = gtk_radio_button_new_with_label (group, _("End on"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio1));
- gtk_box_pack_start (GTK_BOX (hbox), radio1, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur)
- enddate = ee->ical->recur->enddate;
- else
- enddate = ee->ical->dtend;
-
- ee->recur_ed_end_on = widget = gnome_date_edit_new (enddate, FALSE, !am_pm_flag);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio1), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* end after n occurrences */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio2 = gtk_radio_button_new_with_label (group, _("End after"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio2));
- gtk_box_pack_start (GTK_BOX (hbox), radio2, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur && ee->ical->recur->duration)
- repeat = ee->ical->recur->duration;
- else
- repeat = 2;
-
- ee->recur_ed_end_after = widget = make_spin_button (repeat, 1, 10000);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_label_new (_("occurrence(s)"));
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio2), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* Activate appropriate item */
-
- if (ee->ical->recur) {
- if (ee->ical->recur->_enddate == 0) {
- if (ee->ical->recur->duration == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio0), TRUE);
- else {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (ee->recur_ed_end_after),
- ee->ical->recur->duration);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio2), TRUE);
- }
- } else {
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->recur_ed_end_on), ee->ical->recur->enddate);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio1), TRUE);
- }
- }
-
- /* Done, add to main table */
-
- ee->recur_ed_group = group;
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, FALSE, FALSE, 0);
-}
-
-static char *
-get_exception_string (time_t t)
-{
- static char buf[256];
-
- strftime (buf, sizeof(buf), "%a %b %d %Y", localtime (&t)); /* FIXME: how to i18n this? */
- return buf;
-}
-
-static void
-append_exception (EventEditor *ee, time_t t)
-{
- time_t *tt;
- char *c[1];
- int i;
-
- c[0] = get_exception_string (t);
-
- tt = g_new (time_t, 1);
- *tt = t;
-
- i = gtk_clist_append (GTK_CLIST (ee->recur_ex_clist), c);
- gtk_clist_set_row_data (GTK_CLIST (ee->recur_ex_clist), i, tt);
-
- gtk_widget_set_sensitive (ee->recur_ex_vbox, TRUE);
-}
-
-static void
-fill_exception_clist (EventEditor *ee)
-{
- GList *list;
-
- for (list = ee->ical->exdate; list; list = list->next)
- append_exception (ee, *((time_t *) list->data));
-}
-
-static void
-add_exception (GtkWidget *widget, EventEditor *ee)
-{
- time_t t;
-
- t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
- append_exception (ee, t);
-}
-
-static void
-change_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- time_t *t;
- int sel;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = (gint) clist->selection->data;
-
- t = gtk_clist_get_row_data (clist, sel);
- *t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
-
- gtk_clist_set_text (clist, sel, 0, get_exception_string (*t));
-}
-
-static void
-delete_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- int sel;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = (gint) clist->selection->data;
-
- g_free (gtk_clist_get_row_data (clist, sel)); /* free the time_t stored there */
-
- gtk_clist_remove (clist, sel);
-
- if (clist->rows == 0)
- gtk_widget_set_sensitive (ee->recur_ex_vbox, FALSE);
-}
-
-static void
-ee_rp_init_exceptions (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *ivbox;
- GtkWidget *widget;
-
- frame = gtk_frame_new (_("Exceptions"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- ee->recur_ex_date = widget = gnome_date_edit_new (time (NULL), FALSE, !am_pm_flag);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Add exception"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) add_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_vbox = ivbox = gtk_vbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ivbox, FALSE); /* at first there are no items to change or delete */
- gtk_box_pack_start (GTK_BOX (vbox), ivbox, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Change selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) change_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Delete selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) delete_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_clist = widget = gtk_clist_new (1);
- gtk_clist_set_selection_mode (GTK_CLIST (widget), GTK_SELECTION_BROWSE);
- gtk_clist_set_policy (GTK_CLIST (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- fill_exception_clist (ee);
- gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
-
- /* Done, add to main table */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, TRUE, TRUE, 0);
-}
-
-static void
-ee_init_recurrence_page (EventEditor *ee)
-{
- ee->recur_vbox = gtk_vbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (ee->recur_vbox), 4);
-
- ee->recur_hbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ee->recur_hbox, FALSE);
-
- ee->recur_page_label = gtk_label_new (_("Recurrence"));
-
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), ee->recur_vbox,
- ee->recur_page_label);
-
- ee_rp_init_rule (ee);
-
- /* pack here so that the box gets inserted after the recurrence rule frame */
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), ee->recur_hbox, FALSE, FALSE, 0);
-
- ee_rp_init_ending_date (ee);
- ee_rp_init_exceptions (ee);
-}
-
-static void
-event_editor_init_widgets (EventEditor *ee)
-{
- ee->notebook = gtk_notebook_new ();
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG(ee)->vbox), ee->notebook, 1, 1, 0);
-
- /* Init the various configuration pages */
- ee_init_general_page (ee);
- ee_init_summary_page (ee);
- ee_init_recurrence_page (ee);
-
- /* Buttons */
- ee_create_buttons(ee);
-
- /* We show all of the contained widgets */
- gtk_widget_show_all (GTK_BIN (ee)->child);
-}
-
-static void
-event_editor_init (EventEditor *ee)
-{
- ee->ical = 0;
- gnome_dialog_set_close (GNOME_DIALOG(ee), TRUE);
-}
-
-static void
-event_editor_destroy (GtkObject *object)
-{
- EventEditor *ee;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EVENT_EDITOR (object));
-
- ee = EVENT_EDITOR (object);
-
- if (ee->ical)
- ee->ical->user_data = NULL; /* we are no longer editing it */
-}
-
-GtkWidget *
-event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
-{
- GtkWidget *retval;
- EventEditor *ee;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- retval = gtk_type_new (event_editor_get_type ());
- ee = EVENT_EDITOR (retval);
-
- if (ical == 0){
- ical = ical_new ("", user_name, "");
- ical->new = 1;
- }
-
- ical->user_data = ee; /* so that the world can know we are editing it */
-
- ee->ical = ical;
- ee->gnome_cal = gcal;
- event_editor_init_widgets (ee);
-
- return retval;
-}
diff --git a/calendar/eventedit.h b/calendar/eventedit.h
deleted file mode 100644
index 9cb80e3912..0000000000
--- a/calendar/eventedit.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef EVENT_EDITOR_H
-#define EVENT_EDITOR_H
-
-#include "gnome-cal.h"
-#include <libgnomeui/gnome-dialog.h>
-
-BEGIN_GNOME_DECLS
-
-
-#define EVENT_EDITOR(obj) GTK_CHECK_CAST(obj, event_editor_get_type(), EventEditor)
-#define EVENT_EDITOR_CLASS(class) GTK_CHECK_CAST_CLASS(class, event_editor_get_type(), EventEditorClass)
-#define IS_EVENT_EDITOR(obj) GTK_CHECK_TYPE(obj, event_editor_get_type())
-
-
-typedef struct {
- GnomeDialog dialog;
- GtkWidget *notebook;
-
- GtkWidget *general;
- GtkWidget *general_table;
- GtkWidget *general_time_table;
- GtkWidget *general_allday;
- GtkWidget *general_owner;
- GtkWidget *general_summary;
- GtkWidget *start_time, *end_time;
- GtkWidget *general_radios;
-
- GtkWidget *recur_page_label;
- GtkWidget *recur_vbox;
- GtkWidget *recur_hbox;
-
- GSList *recur_rr_group;
- GtkWidget *recur_rr_notebook;
- GtkWidget *recur_rr_day_period;
- GtkWidget *recur_rr_week_period;
- GtkWidget *recur_rr_week_days [7];
- GtkWidget *recur_rr_month_date;
- GtkWidget *recur_rr_month_date_label;
- GtkWidget *recur_rr_month_day;
- GtkWidget *recur_rr_month_weekday;
- GtkWidget *recur_rr_month_period;
- GtkWidget *recur_rr_year_period;
-
- GSList *recur_ed_group;
- GtkWidget *recur_ed_end_on;
- GtkWidget *recur_ed_end_after;
-
- GtkWidget *recur_ex_date;
- GtkWidget *recur_ex_vbox;
- GtkWidget *recur_ex_clist;
-
- /* The associated ical object */
- iCalObject *ical;
-
- /* The calendar owner of this event */
- GnomeCalendar *gnome_cal;
-} EventEditor;
-
-typedef struct {
- GnomeDialogClass parent_class;
-} EventEditorClass;
-
-
-guint event_editor_get_type (void);
-GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/getdate.y b/calendar/getdate.y
deleted file mode 100644
index 6df71bddda..0000000000
--- a/calendar/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/gncal-day-panel.c b/calendar/gncal-day-panel.c
deleted file mode 100644
index 00d4f6f31e..0000000000
--- a/calendar/gncal-day-panel.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include "gncal-day-panel.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-guint
-gncal_day_panel_get_type (void)
-{
- static guint day_panel_type = 0;
-
- if (!day_panel_type) {
- GtkTypeInfo day_panel_info = {
- "GncalDayPanel",
- sizeof (GncalDayPanel),
- sizeof (GncalDayPanelClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) NULL,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_panel_type = gtk_type_unique (gtk_table_get_type (), &day_panel_info);
- }
-
- return day_panel_type;
-}
-
-static void
-day_view_range_activated (GncalFullDay *fullday, GncalDayPanel *dpanel)
-{
- iCalObject *ical;
-
- ical = ical_new ("", user_name, "");
- ical->new = 1;
-
- gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
-
- gnome_calendar_add_object (dpanel->calendar, ical);
- gncal_full_day_focus_child (fullday, ical);
-}
-
-static void
-full_day_size_allocated (GtkWidget *widget, GtkAllocation *allocation, GncalDayPanel *dpanel)
-{
- GtkAdjustment *adj;
- int yoffset;
- gfloat newval;
-
- adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
-
- yoffset = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));
-
- newval = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
- if (newval != adj->value)
- gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
-}
-
-static void
-calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- 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 = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- gnome_calendar_goto (dpanel->calendar, mktime (&tm));
-}
-
-static void
-retag_calendar (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- gnome_calendar_tag_calendar (dpanel->calendar, GTK_CALENDAR (dpanel->gtk_calendar));
-}
-
-GtkWidget *
-gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day)
-{
- GncalDayPanel *dpanel;
- GtkWidget *w;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dpanel = gtk_type_new (gncal_day_panel_get_type ());
-
- gtk_container_border_width (GTK_CONTAINER (dpanel), 4);
- gtk_table_set_row_spacings (GTK_TABLE (dpanel), 4);
- gtk_table_set_col_spacings (GTK_TABLE (dpanel), 4);
-
- dpanel->calendar = calendar;
-
- /* Date label */
-
- w = gtk_label_new ("");
- dpanel->date_label = GTK_LABEL (w);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 0, 1, 0, 1,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Full day */
-
- w = gtk_scrolled_window_new (NULL, NULL);
- dpanel->fullday_sw = GTK_SCROLLED_WINDOW (w);
- gtk_scrolled_window_set_policy (dpanel->fullday_sw,
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 0, 1, 1, 4,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- w = gncal_full_day_new (calendar, time_start_of_day (start_of_day), time_end_of_day (start_of_day));
- dpanel->fullday = GNCAL_FULL_DAY (w);
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "range_activated",
- (GtkSignalFunc) day_view_range_activated,
- dpanel);
- gtk_container_add (GTK_CONTAINER (dpanel->fullday_sw), w);
- gtk_widget_show (w);
-
- /* We'll scroll the list to the proper initial position */
-
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "size_allocate",
- (GtkSignalFunc) full_day_size_allocated,
- dpanel);
-
- /* Gtk calendar */
-
- w = gtk_calendar_new ();
- dpanel->gtk_calendar = GTK_CALENDAR (w);
- gtk_calendar_display_options (dpanel->gtk_calendar,
- GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);
- dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "day_selected_double_click",
- (GtkSignalFunc) calendar_day_selected,
- dpanel);
- gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC (retag_calendar), dpanel);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 1, 2, 1, 2,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Separator */
-
- w = gtk_hseparator_new ();
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 1, 2, 2, 3,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* To-do */
-
- w = gncal_todo_new (calendar);
- dpanel->todo = GNCAL_TODO (w);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 1, 2, 3, 4,
- GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Done */
-
- gncal_day_panel_set (dpanel, start_of_day);
-
- return GTK_WIDGET (dpanel);
-}
-
-static void
-update (GncalDayPanel *dpanel, int update_fullday, iCalObject *ico, int flags)
-{
- char buf [80];
-
- if (update_fullday){
- gncal_full_day_update (dpanel->fullday, ico, flags);
- retag_calendar (dpanel->gtk_calendar, dpanel);
- }
- gncal_todo_update (dpanel->todo, ico, flags);
-
- strftime (buf, sizeof (buf), "%a %b %d %Y", localtime (&dpanel->start_of_day));
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-}
-
-void
-gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- update (dpanel, TRUE, ico, flags);
-}
-
-void
-gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
-{
- char buf[80];
- struct tm tm;
-
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- dpanel->start_of_day = time_start_of_day (start_of_day);
- if (dpanel->fullday->lower == dpanel->start_of_day)
- return;
-
- tm = *localtime (&dpanel->start_of_day);
- strftime (buf, sizeof (buf), "%a %b %d %Y", &tm);
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-
- gncal_full_day_set_bounds (dpanel->fullday, dpanel->start_of_day, time_end_of_day (dpanel->start_of_day));
-
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- gtk_signal_handler_block (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- gtk_signal_handler_unblock (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
-
- update (dpanel, FALSE, NULL, 0);
-}
diff --git a/calendar/gncal-day-panel.h b/calendar/gncal-day-panel.h
deleted file mode 100644
index 8b62013ca7..0000000000
--- a/calendar/gncal-day-panel.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_PANEL_H
-#define GNCAL_DAY_PANEL_H
-
-#include <gtk/gtklabel.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gtkcalendar.h>
-#include "gnome-cal.h"
-#include "gncal-full-day.h"
-#include "gncal-todo.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_PANEL(obj) GTK_CHECK_CAST (obj, gncal_day_panel_get_type (), GncalDayPanel)
-#define GNCAL_DAY_PANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_panel_get_type (), GncalDayPanelClass)
-#define GNCAL_IS_DAY_PANEL(obj) GTK_CHECK_TYPE (obj, gncal_day_panel_get_type ())
-
-
-typedef struct _GncalDayPanel GncalDayPanel;
-typedef struct _GncalDayPanelClass GncalDayPanelClass;
-
-struct _GncalDayPanel {
- GtkTable table;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t start_of_day;
-
- GtkLabel *date_label;
- GncalFullDay *fullday;
- GtkScrolledWindow *fullday_sw;
- GtkCalendar *gtk_calendar;
- GncalTodo *todo;
-
- guint day_selected_id;
-};
-
-struct _GncalDayPanelClass {
- GtkTableClass parent_class;
-};
-
-
-guint gncal_day_panel_get_type (void);
-GtkWidget *gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day);
-
-void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
-void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c
deleted file mode 100644
index 85d61292f1..0000000000
--- a/calendar/gncal-day-view.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <gnome.h>
-#include "gncal-day-view.h"
-#include "timeutil.h"
-#include "view-utils.h"
-#include "main.h"
-#include "eventedit.h"
-#include "popup-menu.h"
-
-
-#define TEXT_BORDER 2
-#define MIN_INFO_WIDTH 50
-
-
-static void gncal_day_view_class_init (GncalDayViewClass *class);
-static void gncal_day_view_init (GncalDayView *dview);
-static void gncal_day_view_destroy (GtkObject *object);
-static void gncal_day_view_realize (GtkWidget *widget);
-static void gncal_day_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static gint gncal_day_view_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_day_view_button_press (GtkWidget *widget,
- GdkEventButton *event);
-
-
-static GtkWidgetClass *parent_class;
-
-
-guint
-gncal_day_view_get_type (void)
-{
- static guint day_view_type = 0;
-
- if (!day_view_type) {
- GtkTypeInfo day_view_info = {
- "GncalDayView",
- sizeof (GncalDayView),
- sizeof (GncalDayViewClass),
- (GtkClassInitFunc) gncal_day_view_class_init,
- (GtkObjectInitFunc) gncal_day_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_view_type = gtk_type_unique (gtk_widget_get_type (), &day_view_info);
- }
-
- return day_view_type;
-}
-
-static void
-gncal_day_view_class_init (GncalDayViewClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_widget_get_type ());
-
- object_class->destroy = gncal_day_view_destroy;
-
- widget_class->realize = gncal_day_view_realize;
- widget_class->size_request = gncal_day_view_size_request;
- widget_class->expose_event = gncal_day_view_expose;
- widget_class->button_press_event = gncal_day_view_button_press;
-}
-
-static void
-gncal_day_view_init (GncalDayView *dview)
-{
- GTK_WIDGET_UNSET_FLAGS (dview, GTK_NO_WINDOW);
-
- dview->calendar = NULL;
-
- dview->lower = 0;
- dview->upper = 0;
-
- dview->shadow_type = GTK_SHADOW_ETCHED_IN;
-}
-
-static void
-gncal_day_view_destroy (GtkObject *object)
-{
- GncalDayView *dview;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (object));
-
- dview = GNCAL_DAY_VIEW (object);
-
- if (dview->day_str)
- g_free (dview->day_str);
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static int
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalDayView *dayview = GNCAL_DAY_VIEW (data);
- iCalObject *ico;
- GtkWidget *ee;
- struct tm tm;
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- tm = *localtime (&dayview->lower);
- tm.tm_hour = day_begin;
- ico->dtstart = mktime (&tm);
- tm.tm_hour++;
- ico->dtend = mktime (&tm);
- ee = event_editor_new (dayview->calendar, ico);
- gtk_widget_show (ee);
- return 1;
-}
-
-static void
-context_menu (GncalDayView *dayview, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- main_items [0].data = dayview;
- popup_menu (main_items, 1, event);
-}
-
-static void
-switch_to_day (GncalDayView *dayview)
-{
-}
-
-static gint
-gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalDayView *dayview;
-
- dayview = GNCAL_DAY_VIEW (widget);
-
- if (event->button == 3)
- context_menu (dayview, event);
-
- if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
- gnome_calendar_dayjump (dayview->calendar, dayview->lower);
-
- return TRUE;
-}
-
-GtkWidget *
-gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalDayView *dview;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dview = gtk_type_new (gncal_day_view_get_type ());
-
- dview->calendar = calendar;
- dview->lower = lower;
- dview->upper = upper;
- dview->events = 0;
-
- gncal_day_view_update (dview, NULL, 0);
-
- return GTK_WIDGET (dview);
-}
-
-static void
-gncal_day_view_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-}
-
-static void
-gncal_day_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalDayView *dview;
- int str_width, width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- dview = GNCAL_DAY_VIEW (widget);
-
- /* border and min width */
-
- str_width = gdk_string_width (widget->style->font, dview->day_str);
-
- width = MAX (MIN_INFO_WIDTH, str_width);
-
- requisition->width = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + width;
- requisition->height = 2 * (widget->style->klass->ythickness + TEXT_BORDER);
-
- /* division line */
-
- requisition->height += 2 * TEXT_BORDER + widget->style->klass->ythickness;
-
- /* title and at least one line of text */
-
- requisition->height += 2 * (widget->style->font->ascent + widget->style->font->descent);
-}
-
-static gint
-gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalDayView *dview;
- int x1, y1, width, height;
- GdkRectangle rect, dest;
- GdkFont *font;
- int str_width;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_DAY_VIEW (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- dview = GNCAL_DAY_VIEW (widget);
-
- x1 = widget->style->klass->xthickness;
- y1 = widget->style->klass->ythickness;
- width = widget->allocation.width - 2 * x1;
- height = widget->allocation.height - 2 * y1;
-
- /* Clear and paint frame shadow */
-
- gdk_window_clear_area (widget->window,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, dview->shadow_type,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- /* Clear and paint title */
-
- font = widget->style->font;
-
- rect.x = x1;
- rect.y = y1;
- rect.width = width;
- rect.height = 2 * TEXT_BORDER + font->ascent + font->descent;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest)) {
- gdk_draw_rectangle (widget->window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- dest = rect;
-
- dest.x += TEXT_BORDER;
- dest.y += TEXT_BORDER;
- dest.width -= 2 * TEXT_BORDER;
- dest.height -= 2 * TEXT_BORDER;
-
- gdk_gc_set_clip_rectangle (widget->style->fg_gc[GTK_STATE_NORMAL], &dest);
-
- str_width = gdk_string_width (font, dview->day_str);
-
- gdk_draw_string (widget->window,
- font,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- dest.x + (dest.width - str_width) / 2,
- dest.y + font->ascent,
- dview->day_str);
-
- gdk_gc_set_clip_rectangle (widget->style->fg_gc[GTK_STATE_NORMAL], NULL);
- }
-
- /* Division line */
-
- gtk_draw_hline (widget->style,
- widget->window,
- GTK_STATE_NORMAL,
- rect.x,
- rect.x + rect.width - 1,
- rect.y + rect.height);
-
- /* Text */
-
- rect.x = x1 + TEXT_BORDER;
- rect.y = y1 + 3 * TEXT_BORDER + font->ascent + font->descent + widget->style->klass->ythickness;
- rect.width = width - 2 * TEXT_BORDER;
- rect.height = height - (rect.y - y1) - TEXT_BORDER;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest))
- view_utils_draw_events (widget,
- widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- &rect,
- VIEW_UTILS_DRAW_END | VIEW_UTILS_DRAW_SPLIT,
- dview->events,
- dview->lower,
- dview->upper);
-
- return FALSE;
-}
-
-void
-gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
-{
- struct tm tm;
- char buf[256];
-
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
- g_return_if_fail (dview->calendar->cal);
-
- if (dview->day_str)
- g_free (dview->day_str);
-
- tm = *localtime (&dview->lower);
- strftime (buf, sizeof (buf)-1, "%A %d", &tm);
- dview->day_str = g_strdup (buf);
-
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- dview->events = calendar_get_events_in_range (dview->calendar->cal,
- dview->lower,
- dview->upper);
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
-}
-
-void
-gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if ((lower != dview->lower) || (upper != dview->upper)) {
- dview->lower = lower;
- dview->upper = upper;
-
- gncal_day_view_update (dview, NULL, 0);
- }
-}
-
-void
-gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if (shadow_type != dview->shadow_type) {
- dview->shadow_type = shadow_type;
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
- }
-}
diff --git a/calendar/gncal-day-view.h b/calendar/gncal-day-view.h
deleted file mode 100644
index dae1897fb6..0000000000
--- a/calendar/gncal-day-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_VIEW_H
-#define GNCAL_DAY_VIEW_H
-
-
-#include <gtk/gtkwidget.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_VIEW(obj) GTK_CHECK_CAST (obj, gncal_day_view_get_type (), GncalDayView)
-#define GNCAL_DAY_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_view_get_type (), GncalDayViewClass)
-#define GNCAL_IS_DAY_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_day_view_get_type ())
-
-
-typedef struct _GncalDayView GncalDayView;
-typedef struct _GncalDayViewClass GncalDayViewClass;
-
-struct _GncalDayView {
- GtkWidget widget;
-
- GnomeCalendar *calendar;/* the calendar we are associated to */
-
- time_t lower; /* lower and upper times to display */
- time_t upper; /* these include the full day */
-
- char *day_str; /* what day is it? */
- GList *events; /* the events for the this day */
- GtkShadowType shadow_type;
-};
-
-struct _GncalDayViewClass {
- GtkWidgetClass parent_class;
-};
-
-
-guint gncal_day_view_get_type (void);
-GtkWidget *gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags);
-void gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper);
-
-void gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c
deleted file mode 100644
index 64e5ec6ef4..0000000000
--- a/calendar/gncal-full-day.c
+++ /dev/null
@@ -1,2321 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-#include <config.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-#include <gnome.h>
-#include "eventedit.h"
-#include "gncal-full-day.h"
-#include "view-utils.h"
-#include "main.h"
-#include "popup-menu.h"
-
-/* Images */
-#include "bell.xpm"
-#include "recur.xpm"
-
-#define TEXT_BORDER 2
-#define HANDLE_SIZE 8
-#define MIN_WIDTH 200
-#define XOR_RECT_WIDTH 2
-#define UNSELECT_TIMEOUT 150 /* ms */
-
-/* Size of the pixmaps */
-#define DECOR_WIDTH 16
-#define DECOR_HEIGHT 16
-
-typedef struct {
- iCalObject *ico;
- GtkWidget *widget;
- GdkWindow *window;
- GdkWindow *decor_window;
- int lower_row; /* zero is first displayed row */
- int rows_used;
- int x; /* coords of child's window */
- int y;
- int width;
- int height;
- int decor_width;
- int decor_height;
- int items; /* number of decoration bitmaps */
- time_t start, end;
-} Child;
-
-struct layout_row {
- int intersections;
- int *slots;
-};
-
-struct drag_info {
- enum {
- DRAG_NONE,
- DRAG_SELECT, /* selecting a range in the main window */
- DRAG_MOVE, /* moving a child */
- DRAG_SIZE_TOP, /* resizing a child */
- DRAG_SIZE_BOTTOM
- } drag_mode;
-
- Child *child;
- int child_click_y;
- int child_start_row;
- int child_rows_used;
-
- int sel_click_row;
- int sel_start_row;
- int sel_rows_used;
- guint32 click_time;
-};
-
-
-enum {
- RANGE_ACTIVATED,
- LAST_SIGNAL
-};
-
-
-static void gncal_full_day_class_init (GncalFullDayClass *class);
-static void gncal_full_day_init (GncalFullDay *fullday);
-static void gncal_full_day_destroy (GtkObject *object);
-static void gncal_full_day_map (GtkWidget *widget);
-static void gncal_full_day_unmap (GtkWidget *widget);
-static void gncal_full_day_realize (GtkWidget *widget);
-static void gncal_full_day_unrealize (GtkWidget *widget);
-static void gncal_full_day_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void gncal_full_day_draw_focus (GtkWidget *widget);
-static void gncal_full_day_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gncal_full_day_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint gncal_full_day_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_motion (GtkWidget *widget,
- GdkEventMotion *event);
-static gint gncal_full_day_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_full_day_key_press (GtkWidget *widget,
- GdkEventKey *event);
-static gint gncal_full_day_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint gncal_full_day_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-static void gncal_full_day_foreach (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data);
-
-static void range_activated (GncalFullDay *fullday);
-
-
-static GtkContainerClass *parent_class;
-
-static int fullday_signals[LAST_SIGNAL] = { 0 };
-
-/* The little images */
-static GdkPixmap *pixmap_bell, *pixmap_recur;
-
-static void
-get_tm_range (GncalFullDay *fullday,
- time_t time_lower, time_t time_upper,
- struct tm *lower, struct tm *upper,
- int *lower_row, int *rows_used)
-{
- struct tm tm_lower, tm_upper;
- int lmin, umin;
- int lrow;
-
- /* Lower */
-
- tm_lower = *localtime (&time_lower);
-
- if ((tm_lower.tm_min % fullday->interval) != 0) {
- tm_lower.tm_min -= tm_lower.tm_min % fullday->interval; /* round down */
- mktime (&tm_lower);
- }
-
- /* Upper */
-
- tm_upper = *localtime (&time_upper);
-
- if ((tm_upper.tm_min % fullday->interval) != 0) {
- tm_upper.tm_min += fullday->interval - (tm_upper.tm_min % fullday->interval); /* round up */
- mktime (&tm_upper);
- }
-
- if (lower)
- *lower = tm_lower;
-
- if (upper)
- *upper = tm_upper;
-
- lmin = 60 * tm_lower.tm_hour + tm_lower.tm_min;
- umin = 60 * tm_upper.tm_hour + tm_upper.tm_min;
-
- if (umin == 0) /* midnight of next day? */
- umin = 60 * 24;
-
- lrow = lmin / fullday->interval;
-
- if (lower_row)
- *lower_row = lrow;
-
- if (rows_used)
- *rows_used = (umin - lmin) / fullday->interval;
-}
-
-static void
-child_map (GncalFullDay *fullday, Child *child)
-{
- gdk_window_show (child->window);
- if (child->decor_width)
- gdk_window_show (child->decor_window);
- gtk_widget_show (child->widget); /* OK, not just a map... */
-}
-
-static void
-child_unmap (GncalFullDay *fullday, Child *child)
-{
- gdk_window_hide (child->window);
- gdk_window_hide (child->decor_window);
- if (GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
-}
-
-static void
-child_set_text_pos (Child *child)
-{
- GtkAllocation allocation;
- int has_focus;
- int handle_size;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- handle_size = (child->ico->recur) ? 0 : HANDLE_SIZE;
-
- allocation.x = handle_size;
- allocation.y = has_focus ? handle_size : 0;
- allocation.width = child->width - handle_size - child->decor_width;
- allocation.height = child->height - (has_focus ? (2 * handle_size) : 0);
-
- gtk_widget_size_request (child->widget, &child->widget->requisition); /* FIXME: is this needed? */
- gtk_widget_size_allocate (child->widget, &allocation);
-}
-
-static void
-child_realize (GncalFullDay *fullday, Child *child)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkWidget *widget;
- GdkColor c;
-
- widget = GTK_WIDGET (fullday);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = child->x;
- attributes.y = child->y;
- attributes.width = child->width - child->decor_width;;
- attributes.height = child->height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.cursor = fullday->up_down_cursor;
- attributes.event_mask = (GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_KEY_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR;
- child->window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_window_set_user_data (child->window, widget);
- gtk_style_set_background (widget->style, child->window, GTK_STATE_NORMAL);
- gtk_widget_set_parent_window (child->widget, child->window);
-
- /* Create the decoration window */
- attributes.x = child->x + child->width - child->decor_width;
- attributes.width = child->decor_width ? child->decor_width : 1;
- attributes.height = child->decor_height ? child->decor_height : 1;
- attributes.visual = gdk_imlib_get_visual ();
- attributes.colormap = gdk_imlib_get_colormap ();
- attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- child->decor_window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_color_white (gdk_imlib_get_colormap (), &c);
- gdk_window_set_background (child->decor_window, &c);
- gdk_window_set_user_data (child->decor_window, widget);
-
- if (!pixmap_bell){
- GdkImlibImage *imlib_bell, *imlib_recur;
- GdkPixmap *mask;
-
- imlib_bell = gdk_imlib_create_image_from_xpm_data (bell_xpm);
- gdk_imlib_render (imlib_bell, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_bell = gdk_imlib_move_image (imlib_bell);
- mask = gdk_imlib_move_mask (imlib_bell);
- gdk_imlib_destroy_image (imlib_bell);
- fullday->bell_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->bell_gc, mask);
-
- imlib_recur = gdk_imlib_create_image_from_xpm_data (recur_xpm);
- gdk_imlib_render (imlib_recur, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_recur = gdk_imlib_move_image (imlib_recur);
- mask = gdk_imlib_move_mask (imlib_recur);
- gdk_imlib_destroy_image (imlib_recur);
- fullday->recur_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->recur_gc, mask);
- }
- child_set_text_pos (child);
-}
-
-static void
-child_unrealize (GncalFullDay *fullday, Child *child)
-{
- gdk_window_set_user_data (child->window, NULL);
- gdk_window_destroy (child->window);
- child->window = NULL;
-}
-
-static void
-child_draw_decor (GncalFullDay *fullday, Child *child)
-{
- iCalObject *ico = child->ico;
- int ry = 0;
-
- if (ico->recur) {
- gdk_gc_set_clip_origin (fullday->recur_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->recur_gc,
- pixmap_recur,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-
- if (ico->dalarm.enabled || ico->malarm.enabled || ico->palarm.enabled || ico->aalarm.enabled) {
- gdk_gc_set_clip_origin (fullday->bell_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->bell_gc,
- pixmap_bell,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-}
-
-static void
-child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, GdkWindow *window, int draw_child)
-{
- GdkRectangle arect, rect, dest;
- int has_focus;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (!window || (window == child->window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->width;
- arect.height = child->height;
-
- area = &arect;
- }
-
- /* Left handle */
-
- rect.x = 0;
- rect.y = has_focus ? HANDLE_SIZE : 0;
- rect.width = HANDLE_SIZE;
- rect.height = has_focus ? (child->height - 2 * HANDLE_SIZE) : child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT);
-
- if (has_focus) {
- /* Top handle */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = child->width - child->decor_width;
- rect.height = HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
-
- /* Bottom handle */
-
- rect.y = child->height - HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
- }
-
- } else if (!window || (window == child->decor_window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->decor_width;
- arect.height = child->decor_height;
-
- area = &arect;
- }
-
- child_draw_decor (fullday, child);
- }
-
- if (draw_child)
- gtk_widget_draw (child->widget, NULL);
-}
-
-static void
-child_range_changed (GncalFullDay *fullday, Child *child)
-{
- struct tm start, end;
- int lower_row, rows_used;
- int f_lower_row;
-
- /* Calc display range for event */
-
- get_tm_range (fullday, child->start, child->end, &start, &end, &lower_row, &rows_used);
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, &f_lower_row, NULL);
-
- child->lower_row = lower_row - f_lower_row;
- child->rows_used = rows_used;
-}
-
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalFullDay *fullday;
- GtkWidget *ee;
- iCalObject *ico;
-
- fullday = GNCAL_FULL_DAY (data);
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- gncal_full_day_selection_range (fullday, &ico->dtstart, &ico->dtend);
- ee = event_editor_new (fullday->calendar, ico);
- gtk_widget_show (ee);
-}
-
-static void
-edit_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GtkWidget *ee;
-
- child = data;
-
- ee = event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
- gtk_widget_show (ee);
-}
-
-static void
-delete_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- gnome_calendar_remove_object (fullday->calendar, child->ico);
-}
-
-static void
-unrecur_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- iCalObject *new;
-
- child = data;
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- /* New object */
- new = ical_object_duplicate (child->ico);
- g_free (new->recur);
- new->recur = 0;
- new->dtstart = child->start;
- new->dtend = child->end;
-
- /* Duplicate, and eliminate the recurrency fields */
- ical_object_add_exdate (child->ico, child->start);
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_ALL);
-
- gnome_calendar_add_object (fullday->calendar, new);
-}
-
-static void
-child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
-{
- int sensitive, idx, items;
-
- static struct menu_item child_items[] = {
- { N_("Make this appointment movable"), (GtkSignalFunc) unrecur_appointment, NULL, TRUE },
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- child_items[0].data = child;
- child_items[1].data = child;
- child_items[2].data = child;
- child_items[4].data = fullday;
-
- sensitive = (child->ico->user_data == NULL);
-
- child_items[0].sensitive = sensitive;
- child_items[1].sensitive = sensitive;
- child_items[2].sensitive = sensitive;
-
- if (child->ico->recur){
- idx = 0;
- items = 5;
- } else {
- idx = 1;
- items = 4;
- }
- popup_menu (&child_items [idx], items, event);
-}
-
-static void
-child_realized_setup (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gdk_window_set_cursor (widget->window, fullday->beam_cursor);
-
- gtk_text_insert (GTK_TEXT (widget), NULL, NULL, NULL,
- child->ico->summary,
- strlen (child->ico->summary));
-}
-
-static void
-child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int height)
-{
- const int decor_width = child->decor_width;
-
- child->x = x;
- child->y = y;
- child->width = width;
- child->height = height;
-
- if (!child->window) /* realized? */
- return;
-
- child_set_text_pos (child);
- gdk_window_move_resize (child->window, x, y, width - decor_width, height);
-
- if (decor_width){
- gdk_window_move_resize (child->decor_window, x + width - decor_width, y,
- decor_width, child->decor_height);
- }
-}
-
-static int
-calc_row_height (GncalFullDay *fullday)
-{
- int f_rows;
- GtkWidget *widget;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- widget = GTK_WIDGET (fullday);
-
- return (widget->allocation.height - 2 * widget->style->klass->ythickness) / f_rows;
-}
-
-static void
-child_set_size (Child *child)
-{
- int row_height;
- int x, y, width, height;
- GncalFullDay *fullday;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- row_height = calc_row_height (fullday);
-
- x = child->x;
- y = child->lower_row * row_height + GTK_WIDGET (fullday)->style->klass->ythickness;
- width = child->width;
- height = child->rows_used * row_height;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget) && !child->ico->recur) {
- y -= HANDLE_SIZE;
- height += 2 * HANDLE_SIZE;
- }
-
- child_set_pos (fullday, child, x, y, width, height);
-}
-
-static gint
-child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- Child *child;
-
- child = data;
-
- child_set_size (child);
- gdk_window_raise (child->window);
-
- return FALSE;
-}
-
-static gint
-child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- char *text;
-
- child = data;
-
- child_set_size (child);
-
- /* Update summary in calendar object */
-
- text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
- if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
- return FALSE;
-
- if (child->ico->summary)
- g_free (child->ico->summary);
-
- child->ico->summary = text;
-
- /* Notify calendar of change */
-
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY);
-
- return FALSE;
-}
-
-static gint
-child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
-{
- if (event->keyval != GDK_Escape)
- return FALSE;
-
- /* If user pressed Esc, un-focus the child by focusing the fullday widget */
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
- gtk_widget_grab_focus (widget->parent);
-
- return FALSE;
-}
-
-static gint
-child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- if (event->button != 3)
- return FALSE;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
- child_popup_menu (fullday, child, event);
-
- return TRUE;
-}
-
-/*
- * compute the space required to display the decorations
- */
-static void
-child_compute_decor (Child *child)
-{
- iCalObject *ico = child->ico;
- int rows_used;
-
- child->items = 0;
- rows_used = (child->rows_used < 1) ? 1 : child->rows_used;
- if (ico->recur)
- child->items++;
- if (ico->dalarm.enabled || ico->aalarm.enabled || ico->palarm.enabled || ico->malarm.enabled)
- child->items++;
-
- if (child->items > rows_used){
- child->decor_width = DECOR_WIDTH * 2;
- child->decor_height = DECOR_HEIGHT;
- } else {
- child->decor_width = DECOR_WIDTH * (child->items ? 1 : 0);
- child->decor_height = DECOR_HEIGHT * child->items;
- }
-}
-
-static Child *
-child_new (GncalFullDay *fullday, time_t start, time_t end, iCalObject *ico)
-{
- Child *child;
-
- child = g_new (Child, 1);
-
- child->ico = ico;
- child->widget = gtk_text_new (NULL, NULL);
- child->window = NULL;
- child->x = 0;
- child->y = 0;
- child->width = 0;
- child->height = 0;
- child->start = start;
- child->end = end;
- child_range_changed (fullday, child);
- child_compute_decor (child);
-
- /* We set the i-beam cursor and the initial summary text upon realization */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "realize",
- (GtkSignalFunc) child_realized_setup,
- child);
-
- gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_in_event",
- (GtkSignalFunc) child_focus_in,
- child);
-
- gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_out_event",
- (GtkSignalFunc) child_focus_out,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event",
- (GtkSignalFunc) child_key_press,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "button_press_event",
- (GtkSignalFunc) child_button_press,
- child);
-
- /* Finish setup */
-
- gtk_text_set_editable (GTK_TEXT (child->widget), TRUE);
- gtk_text_set_word_wrap (GTK_TEXT (child->widget), TRUE);
-
- gtk_widget_set_parent (child->widget, GTK_WIDGET (fullday));
-
- return child;
-}
-
-static void
-child_destroy (GncalFullDay *fullday, Child *child)
-{
- /* Unparent the child widget manually as we don't have a remove method */
-
- gtk_widget_ref (child->widget);
-
- gtk_widget_unparent (child->widget);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_unmap (fullday, child);
-
- if (GTK_WIDGET_REALIZED (fullday))
- child_unrealize (fullday, child);
-
- gtk_widget_unref (child->widget);
-
- g_free (child);
-}
-
-static int
-calc_labels_width (GncalFullDay *fullday)
-{
- struct tm cur, upper;
- time_t tim, time_upper;
- int width, max_w;
- char buf[40];
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &cur, &upper, NULL, NULL);
-
- max_w = 0;
-
- tim = mktime (&cur);
- time_upper = mktime (&upper);
-
- while (tim < time_upper) {
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &cur);
- else
- strftime (buf, sizeof (buf), "%H:%M", &cur);
-
-
- width = gdk_string_width (GTK_WIDGET (fullday)->style->font, buf);
-
- if (width > max_w)
- max_w = width;
-
- cur.tm_min += fullday->interval;
- tim = mktime (&cur);
- }
-
- return max_w;
-}
-
-#define MAX_CHILDREN_ON_ROW 32
-
-#define xy(a,x,y) (a[((y) * MAX_CHILDREN_ON_ROW) + (x)])
-
-static int
-range_empty (char *array, int slot, int lower, int count)
-{
- int i;
-
- for (i = 0; i < count; i++)
- if (xy (array, slot, lower+i) != 0)
- return 0;
- return 1;
-}
-
-static void
-range_allocate (char *array, int slot, int lower, int count, int val)
-{
- int i;
-
- for (i = 0; i < count; i++)
- xy (array, slot, lower+i) = val;
-}
-
-static int
-can_expand (char *array, int *allocations, int top_slot, int val, int lower, int count)
-{
- int slot, i;
- int cols = 0;
-
- for (slot = allocations [val] + 1; slot < top_slot; slot++){
- for (i = 0; i < count; i++)
- if (xy (array, slot, lower+i))
- return cols;
- cols++;
- }
- return cols;
-}
-
-static void
-expand_space (char *array, int *allocations, int val, int lower, int count, int cols)
-{
- int j, i, slot;
-
- for (i = 0; i < count; i++){
- slot = allocations [val] + 1;
- for (j = 0; j < cols; j++)
- xy (array, slot, lower+i) = val;
- }
-}
-
-static void
-layout_children (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- int lines = (24 * 60) / fullday->interval;
- char *array = g_malloc0 (sizeof (char) * lines * MAX_CHILDREN_ON_ROW);
- GList *children;
- int val, slot;
- int *allocations, *columns;
- int top_slot = 0;
- int left_x, cols;
- int pixels_per_col, extra_pixels, extra, usable_pixels;
- int child_count;
-
- if (!fullday->children)
- return;
-
- /* initial allocation */
- child_count = g_list_length (fullday->children) + 2;
- allocations = g_malloc0 (sizeof (int) * child_count);
- columns = g_malloc0 (sizeof (int) * child_count);
- val = 1;
- for (children = fullday->children; children; children = children->next, val++){
- Child *child = children->data;
-
- allocations [val] = 0;
- columns [val] = 1;
- for (slot = 0; slot < MAX_CHILDREN_ON_ROW; slot++){
- if (range_empty (array, slot, child->lower_row, child->rows_used)){
- /*
- printf ("Child %d uses %d-%d allocates slot=%d\n", val, child->lower_row,
- child->lower_row + child->rows_used, slot);
- */
-
- range_allocate (array, slot, child->lower_row, child->rows_used, val);
- allocations [val] = slot;
- columns [val] = 1;
- if (slot+1 > top_slot)
- top_slot = slot+1;
- break;
- }
- }
- }
-#if DEBUGME
- for (val = 0; val < 48; val++){
- int j;
-
- printf ("%d: ", val);
- for (j = 0; j < top_slot; j++){
- printf (" %d", xy (array, j, val));
- }
- printf ("\n");
- }
-#endif
- /* Expand */
- val = 1;
- for (children = fullday->children; children; children = children->next, val++){
- Child *child = children->data;
-
- cols = can_expand (array, allocations, top_slot, val, child->lower_row, child->rows_used);
- /* printf ("Can expand regresa: %d\n", cols); */
- if (!cols)
- continue;
- expand_space (array, allocations, val, child->lower_row, child->rows_used, cols);
- columns [val] += cols;
- }
-
- /* Assign the spaces */
- widget = GTK_WIDGET (fullday);
- left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday);
-
- usable_pixels = widget->allocation.width-left_x - widget->style->klass->xthickness;
- pixels_per_col = usable_pixels / top_slot;
- extra_pixels = usable_pixels % top_slot;
-
- val = 1;
- for (children = fullday->children; children; children = children->next, val++){
- Child *child = children->data;
-
- child->x = left_x + pixels_per_col * allocations [val];
- extra = (allocations [val] + columns [val] == top_slot) ? extra_pixels : 0;
- child->width = pixels_per_col * columns [val] + extra;
- child_set_size (child);
-
- /* printf ("Setting child %d to %d for %d pixels\n", val, allocations [val], columns [val]); */
- }
- g_free (allocations);
- g_free (columns);
-}
-
-guint
-gncal_full_day_get_type (void)
-{
- static guint full_day_type = 0;
-
- if (!full_day_type) {
- GtkTypeInfo full_day_info = {
- "GncalFullDay",
- sizeof (GncalFullDay),
- sizeof (GncalFullDayClass),
- (GtkClassInitFunc) gncal_full_day_class_init,
- (GtkObjectInitFunc) gncal_full_day_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- full_day_type = gtk_type_unique (gtk_container_get_type (), &full_day_info);
- }
-
- return full_day_type;
-}
-
-static void
-gncal_full_day_class_init (GncalFullDayClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- parent_class = gtk_type_class (gtk_container_get_type ());
-
- fullday_signals[RANGE_ACTIVATED] =
- gtk_signal_new ("range_activated",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GncalFullDayClass, range_activated),
- gtk_signal_default_marshaller,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, fullday_signals, LAST_SIGNAL);
-
- object_class->destroy = gncal_full_day_destroy;
-
- widget_class->map = gncal_full_day_map;
- widget_class->unmap = gncal_full_day_unmap;
- widget_class->realize = gncal_full_day_realize;
- widget_class->unrealize = gncal_full_day_unrealize;
- widget_class->draw = gncal_full_day_draw;
- widget_class->draw_focus = gncal_full_day_draw_focus;
- widget_class->size_request = gncal_full_day_size_request;
- widget_class->size_allocate = gncal_full_day_size_allocate;
- widget_class->button_press_event = gncal_full_day_button_press;
- widget_class->button_release_event = gncal_full_day_button_release;
- widget_class->motion_notify_event = gncal_full_day_motion;
- widget_class->expose_event = gncal_full_day_expose;
- widget_class->key_press_event = gncal_full_day_key_press;
- widget_class->focus_in_event = gncal_full_day_focus_in;
- widget_class->focus_out_event = gncal_full_day_focus_out;
-
- container_class->foreach = gncal_full_day_foreach;
-
- class->range_activated = range_activated;
-}
-
-static void
-gncal_full_day_init (GncalFullDay *fullday)
-{
- GTK_WIDGET_UNSET_FLAGS (fullday, GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (fullday, GTK_CAN_FOCUS);
-
- fullday->calendar = NULL;
-
- fullday->lower = 0;
- fullday->upper = 0;
- fullday->interval = 30; /* 30 minutes by default */
-
- fullday->children = NULL;
- fullday->drag_info = g_new0 (struct drag_info, 1);
-
- fullday->up_down_cursor = NULL;
- fullday->beam_cursor = NULL;
- fullday->recur_gc = NULL;
- fullday->bell_gc = NULL;
-}
-
-static void
-gncal_full_day_destroy (GtkObject *object)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (object));
-
- fullday = GNCAL_FULL_DAY (object);
-
- /* Unparent the children manually as we don't have a remove method */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- gtk_widget_unparent (child->widget);
- }
-
- g_list_free (fullday->children);
- g_free (fullday->drag_info);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-GtkWidget *
-gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- fullday = gtk_type_new (gncal_full_day_get_type ());
-
- fullday->calendar = calendar;
-
- gncal_full_day_set_bounds (fullday, lower, upper);
-
- return GTK_WIDGET (fullday);
-}
-
-static void
-gncal_full_day_map (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_show (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_map (fullday, children->data);
-}
-
-static void
-gncal_full_day_unmap (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_hide (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_unmap (fullday, children->data);
-}
-
-static void
-gncal_full_day_realize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-
- fullday->up_down_cursor = gdk_cursor_new (GDK_DOUBLE_ARROW);
- fullday->beam_cursor = gdk_cursor_new (GDK_XTERM);
-
- for (children = fullday->children; children; children = children->next)
- child_realize (fullday, children->data);
-
-}
-
-static void
-gncal_full_day_unrealize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- fullday = GNCAL_FULL_DAY (widget);
-
- for (children = fullday->children; children; children = children->next)
- child_unrealize (fullday, children->data);
-
- gdk_cursor_destroy (fullday->up_down_cursor);
- fullday->up_down_cursor = NULL;
-
- gdk_cursor_destroy (fullday->beam_cursor);
- fullday->beam_cursor = NULL;
-
- if (fullday->bell_gc)
- gdk_gc_destroy (fullday->bell_gc);
- if (fullday->recur_gc)
- gdk_gc_destroy (fullday->recur_gc);
-
- if (pixmap_bell){
- gdk_pixmap_unref (pixmap_bell);
- pixmap_bell = NULL;
- }
-
- if (pixmap_recur){
- gdk_pixmap_unref (pixmap_recur);
- pixmap_recur = NULL;
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-struct paint_info {
- GtkWidget *widget;
- struct drag_info *di;
- GdkRectangle *area;
- int x1, y1, width, height;
- int labels_width;
- int row_height;
- struct tm start_tm;
-};
-
-static void
-paint_row (GncalFullDay *fullday, int row, struct paint_info *p)
-{
- GdkRectangle rect, dest;
- GdkGC *left_gc, *right_gc, *text_gc;
- int begin_row, end_row;
- struct tm tm;
- char buf[40];
-
- begin_row = (day_begin * 60) / fullday->interval;
- end_row = (day_end * 60) / fullday->interval;
-
- /* See which GCs we will use */
-
- if ((p->di->sel_rows_used != 0)
- && (row >= p->di->sel_start_row)
- && (row < (p->di->sel_start_row + p->di->sel_rows_used))) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_SELECTED];
- right_gc = left_gc;
- text_gc = p->widget->style->fg_gc[GTK_STATE_SELECTED];
- } else if ((row < begin_row) || (row >= end_row)) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_ACTIVE];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- } else {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_PRELIGHT];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- }
-
- /* Left background and text */
-
- rect.x = p->x1;
- rect.y = p->y1 + row * p->row_height;
- rect.width = 2 * TEXT_BORDER + p->labels_width;
- rect.height = p->row_height - 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest)) {
- gdk_draw_rectangle (p->widget->window,
- left_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- tm = p->start_tm;
- tm.tm_min += row * fullday->interval;
- mktime (&tm);
-
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &tm);
- else
- strftime (buf, sizeof (buf), "%H:%M", &tm);
-
- gdk_draw_string (p->widget->window,
- p->widget->style->font,
- text_gc,
- rect.x + TEXT_BORDER,
- rect.y + TEXT_BORDER + p->widget->style->font->ascent,
- buf);
- }
-
- /* Right background */
-
- rect.x += rect.width + p->widget->style->klass->xthickness;
- rect.width = p->width - (rect.x - p->x1);
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_rectangle (p->widget->window,
- right_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Horizontal division at bottom of row */
-
- rect.x = p->x1;
- rect.y += rect.height;
- rect.width = p->width;
- rect.height = 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_line (p->widget->window,
- p->widget->style->black_gc,
- rect.x, rect.y,
- rect.x + rect.width - 1, rect.y);
-}
-
-static void
-paint_back (GncalFullDay *fullday, GdkRectangle *area)
-{
- struct paint_info p;
- int start_row, end_row;
- int i;
- GdkRectangle rect, dest, aarea;
- int f_rows;
- int draw_focus;
-
- p.widget = GTK_WIDGET (fullday);
- p.di = fullday->drag_info;
-
- if (!area) {
- area = &aarea;
-
- area->x = 0;
- area->y = 0;
- area->width = p.widget->allocation.width;
- area->height = p.widget->allocation.height;
- }
- p.area = area;
-
- p.x1 = p.widget->style->klass->xthickness;
- p.y1 = p.widget->style->klass->ythickness;
- p.width = p.widget->allocation.width - 2 * p.x1;
- p.height = p.widget->allocation.height - 2 * p.y1;
-
- p.labels_width = calc_labels_width (fullday);
- p.row_height = calc_row_height (fullday);
- get_tm_range (fullday, fullday->lower, fullday->upper, &p.start_tm, NULL, NULL, &f_rows);
-
- /* Frame shadow */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = p.widget->allocation.width;
- rect.height = p.widget->style->klass->ythickness;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
-
- if (!draw_focus) {
- rect.y = p.widget->allocation.height - rect.height;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.y = p.widget->style->klass->ythickness;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.widget->allocation.height - 2 * rect.y;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.x = p.widget->allocation.width - rect.width;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (draw_focus)
- gtk_widget_draw_focus (p.widget);
-
- /* Rows */
-
- start_row = (area->y - p.y1) / p.row_height;
- end_row = (area->y + area->height - 1 - p.y1) / p.row_height;
-
- if (end_row >= f_rows)
- end_row = f_rows - 1;
-
- for (i = start_row; i <= end_row; i++)
- paint_row (fullday, i, &p);
-
- /* Slack area at bottom of widget */
-
- rect.x = p.x1;
- rect.y = p.y1 + f_rows * p.row_height;
- rect.width = p.width;
- rect.height = p.height - (rect.y - p.y1);
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gdk_draw_rectangle (p.widget->window,
- p.widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Vertical division */
-
- rect.x = p.x1 + 2 * TEXT_BORDER + p.labels_width;
- rect.y = p.y1;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gtk_draw_vline (p.widget->style, p.widget->window,
- GTK_STATE_NORMAL,
- rect.y,
- rect.y + rect.height - 1,
- rect.x);
-}
-
-static void
-paint_back_rows (GncalFullDay *fullday, int start_row, int rows_used)
-{
- int row_height;
- int xthickness, ythickness;
- GtkWidget *widget;
- GdkRectangle area;
-
- widget = GTK_WIDGET (fullday);
-
- row_height = calc_row_height (fullday);
-
- xthickness = widget->style->klass->xthickness;
- ythickness = widget->style->klass->ythickness;
-
- area.x = xthickness;
- area.y = ythickness + start_row * row_height;
- area.width = widget->allocation.width - 2 * xthickness;
- area.height = rows_used * row_height;
-
- paint_back (fullday, &area);
-}
-
-static void
-gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
- GdkRectangle rect, dest;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (area != NULL);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- paint_back (fullday, area);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- rect.x = child->x;
- rect.y = child->y;
- rect.width = child->width;
- rect.height = child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- }
- }
-}
-
-static void
-gncal_full_day_draw_focus (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- if (GTK_WIDGET_HAS_FOCUS (widget))
- gdk_draw_rectangle (widget->window,
- widget->style->black_gc,
- FALSE,
- 0, 0,
- widget->allocation.width - 1,
- widget->allocation.height - 1);
-}
-
-static void
-gncal_full_day_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalFullDay *fullday;
- int labels_width;
- int rows;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (requisition != NULL);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- /* Border and min width */
-
- labels_width = calc_labels_width (fullday);
-
- requisition->width = 2 * widget->style->klass->xthickness + 4 * TEXT_BORDER + labels_width + MIN_WIDTH;
- requisition->height = 2 * widget->style->klass->ythickness;
-
- /* Rows */
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &rows);
-
- requisition->height += (rows * (2 * TEXT_BORDER + widget->style->font->ascent + widget->style->font->descent)
- + (rows - 1)); /* division lines */
-}
-
-static void
-gncal_full_day_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (allocation != NULL);
-
- widget->allocation = *allocation;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- layout_children (fullday);
-}
-
-static Child *
-find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
-{
- GList *children;
- Child *child;
- GtkWidget *owner;
-
- *on_text = FALSE;
-
- gdk_window_get_user_data (window, (gpointer *) &owner);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->window == window || child->decor_window == window)
- return child;
-
- if (child->widget == owner) {
- *on_text = TRUE;
- return child;
- }
- }
-
- return NULL;
-}
-
-static void
-draw_xor_rect (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- struct drag_info *di;
- int i;
- int row_height;
- int ythickness;
-
- widget = GTK_WIDGET (fullday);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_INVERT);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_INCLUDE_INFERIORS);
-
- ythickness = widget->style->klass->ythickness;
-
- di = fullday->drag_info;
-
- row_height = calc_row_height (fullday);
-
- for (i = 0; i < XOR_RECT_WIDTH; i++)
- gdk_draw_rectangle (widget->window,
- widget->style->white_gc,
- FALSE,
- di->child->x + i,
- di->child_start_row * row_height + ythickness + i,
- di->child->width - 2 * i - 1,
- di->child_rows_used * row_height - 2 - 2 * i);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_COPY);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN);
-}
-
-static int
-get_row_from_y (GncalFullDay *fullday, int y, int round)
-{
- GtkWidget *widget;
- int row_height;
- int f_rows;
- int ythickness;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- row_height = calc_row_height (fullday);
-
- widget = GTK_WIDGET (fullday);
-
- ythickness = widget->style->klass->ythickness;
-
- y -= ythickness;
-
- if (y < 0)
- y = 0;
- else if (y >= (f_rows * row_height))
- y = f_rows * row_height - 1;
-
- if (round)
- y += row_height / 2;
-
- y /= row_height;
-
- if (y > f_rows)
- y = f_rows; /* note that this is 1 more than the last row's index */
-
- return y;
-}
-
-static int
-button_1 (GncalFullDay *fullday, GdkEventButton *event)
-{
- GtkWidget *widget;
- Child *child;
- int on_text;
- struct drag_info *di;
- gint y;
- int row_height;
- int has_focus;
- int old_start_row, old_rows_used;
- int old_max;
- int paint_start_row, paint_rows_used;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- di->drag_mode = DRAG_SELECT;
-
- old_start_row = di->sel_start_row;
- old_rows_used = di->sel_rows_used;
-
- di->sel_click_row = get_row_from_y (fullday, event->y, FALSE);
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = 1;
-
- di->click_time = event->time;
-
- gdk_pointer_grab (widget->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- if (old_rows_used == 0) {
- paint_start_row = di->sel_start_row;
- paint_rows_used = di->sel_rows_used;
- } else {
- paint_start_row = MIN (old_start_row, di->sel_start_row);
- old_max = old_start_row + old_rows_used - 1;
- paint_rows_used = MAX (old_max, di->sel_start_row) - paint_start_row + 1;
- }
-
- paint_back_rows (fullday, paint_start_row, paint_rows_used);
-
- return TRUE;
- } else {
- /* Clicked on a child? */
-
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text || child->ico->recur)
- return FALSE;
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (has_focus) {
- if (event->y < HANDLE_SIZE)
- di->drag_mode = DRAG_SIZE_TOP;
- else if (event->y >= (child->height - HANDLE_SIZE))
- di->drag_mode = DRAG_SIZE_BOTTOM;
- else
- di->drag_mode = DRAG_MOVE;
- } else
- di->drag_mode = DRAG_MOVE;
-
- row_height = calc_row_height (fullday);
-
- di->child = child;
-
- di->child_click_y = event->y;
- di->child_start_row = child->lower_row;
- di->child_rows_used = child->rows_used;
-
- gdk_pointer_grab (child->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- draw_xor_rect (fullday);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static int
-button_3 (GncalFullDay *fullday, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- GtkWidget *widget;
- Child *child;
- int on_text;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- main_items[0].data = fullday;
-
- popup_menu (main_items, sizeof (main_items) / sizeof (main_items[0]), event);
-
- return TRUE;
- } else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text)
- return FALSE;
-
- child_popup_menu (fullday, child, event);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- switch (event->button) {
- case 1:
- return button_1 (fullday, event);
-
- case 3:
- return button_3 (fullday, event);
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-recompute_motion (GncalFullDay *fullday, int y)
-{
- struct drag_info *di;
- int f_rows;
- int row;
- int has_focus;
-
- di = fullday->drag_info;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- switch (di->drag_mode) {
- case DRAG_SELECT:
- row = get_row_from_y (fullday, y, FALSE);
-
- if (row >= f_rows)
- row = f_rows - 1;
-
- if (row < di->sel_click_row) {
- di->sel_start_row = row;
- di->sel_rows_used = di->sel_click_row - row + 1;
- } else {
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = row - di->sel_start_row + 1;
- }
-
- break;
-
- case DRAG_MOVE:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- row = get_row_from_y (fullday, y - di->child_click_y + (has_focus ? HANDLE_SIZE : 0), TRUE);
-
- if (row > (f_rows - di->child_rows_used))
- row = f_rows - di->child_rows_used;
-
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_TOP:
- row = get_row_from_y (fullday, y + HANDLE_SIZE, TRUE);
-
- if (row > (di->child_start_row + di->child_rows_used - 1))
- row = di->child_start_row + di->child_rows_used - 1;
-
- di->child_rows_used = (di->child_start_row + di->child_rows_used) - row;
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_BOTTOM:
- row = get_row_from_y (fullday, y - HANDLE_SIZE, TRUE);
-
- if (row <= di->child_start_row)
- row = di->child_start_row + 1;
- else if (row > f_rows)
- row = f_rows;
-
- di->child_rows_used = row - di->child_start_row;
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-get_time_from_rows (GncalFullDay *fullday, int start_row, int rows_used, time_t *t_lower, time_t *t_upper)
-{
- struct tm tm;
- int row_height;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, NULL);
-
- row_height = calc_row_height (fullday);
-
- tm.tm_min += fullday->interval * start_row;
- *t_lower = mktime (&tm);
-
- tm.tm_min += fullday->interval * rows_used;
- *t_upper = mktime (&tm);
-}
-
-static void
-update_from_drag_info (GncalFullDay *fullday)
-{
- struct drag_info *di;
- GtkWidget *widget;
-
- di = fullday->drag_info;
-
- widget = GTK_WIDGET (fullday);
-
- get_time_from_rows (fullday, di->child_start_row, di->child_rows_used,
- &di->child->ico->dtstart,
- &di->child->ico->dtend);
-
- child_range_changed (fullday, di->child);
-
- /* Notify calendar of change */
-
- gnome_calendar_object_changed (fullday->calendar, di->child->ico, CHANGE_DATES);
-}
-
-static gint
-gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int retval;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- retval = FALSE;
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- if ((event->time - di->click_time) < UNSELECT_TIMEOUT)
- di->sel_rows_used = 0;
- else
- recompute_motion (fullday, y);
-
- gdk_pointer_ungrab (event->time);
-
- paint_back_rows (fullday, di->sel_start_row, MAX (di->sel_rows_used, 1));
-
- retval = TRUE;
- break;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- gdk_pointer_ungrab (event->time);
-
- update_from_drag_info (fullday);
-
- di->child_rows_used = 0;
-
- retval = TRUE;
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- di->drag_mode = DRAG_NONE;
- di->child = NULL;
-
- return retval;
-}
-
-static gint
-gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int old_min, old_max;
- int new_min, new_max;
- int new_start_row, new_rows_used;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- old_min = di->sel_start_row;
- old_max = di->sel_start_row + di->sel_rows_used - 1;
-
- recompute_motion (fullday, y);
-
- new_min = di->sel_start_row;
- new_max = di->sel_start_row + di->sel_rows_used - 1;
-
- new_start_row = MIN (old_min, new_min);
- new_rows_used = MAX (old_max, new_max) - new_start_row + 1;
-
- paint_back_rows (fullday, new_start_row, new_rows_used);
-
- return TRUE;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- draw_xor_rect (fullday);
-
- return TRUE;
-
- default:
- g_assert_not_reached ();
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalFullDay *fullday;
- Child *child;
- int on_text;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (event->window == widget->window)
- paint_back (fullday, &event->area);
- else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (child && !on_text)
- child_draw (fullday, child, &event->area, event->window, FALSE);
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_key_press (GtkWidget *widget, GdkEventKey *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- GList *children;
- Child *child;
- gint pos;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0)
- return FALSE;
-
- if (event->keyval == GDK_Return) {
- gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals[RANGE_ACTIVATED]);
- return TRUE;
- }
-
- if (event->length > 0) {
- /* This means some printable key was pressed */
-
- gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals[RANGE_ACTIVATED]);
-
- /* Find the new child, which should hopefully be focused, and insert the keypress */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget)) {
- pos = gtk_text_get_length (GTK_TEXT (child->widget));
-
- gtk_editable_insert_text (GTK_EDITABLE (child->widget),
- event->string,
- event->length,
- &pos);
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_in (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_out (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static void
-gncal_full_day_foreach (GtkContainer *container, GtkCallback callback, gpointer callback_data)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (container));
- g_return_if_fail (callback != NULL);
-
- fullday = GNCAL_FULL_DAY (container);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- (*callback) (child->widget, callback_data);
- }
-}
-
-static gint
-child_compare_by_start (gconstpointer a, gconstpointer b)
-{
- const Child *ca = a;
- const Child *cb = b;
- time_t diff;
-
- diff = ca->start - cb->start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GncalFullDay *fullday = c;
- Child *child;
-
- child = child_new (fullday, start, end, obj);
- fullday->children = g_list_insert_sorted (fullday->children, child, child_compare_by_start);
-
- return 1;
-}
-
-void
-gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if (!fullday->calendar->cal)
- return;
-
- /* Try to find child that changed */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico)
- break;
- }
-
- /* If child was found and nothing but the summary changed, we can just paint the child and return */
-
- if (children && !(flags & ~CHANGE_SUMMARY)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- return;
- }
-
- /* We have to regenerate and layout our list of children */
-
- for (children = fullday->children; children; children = children->next)
- child_destroy (fullday, children->data);
-
- g_list_free (fullday->children);
-
- fullday->children = NULL;
-
- calendar_iterate (fullday->calendar->cal,
- fullday->lower,
- fullday->upper,
- fullday_add_children,
- fullday);
-
- layout_children (fullday);
-
- /* Realize and map children */
-
- for (children = fullday->children; children; children = children->next) {
- if (GTK_WIDGET_REALIZED (fullday))
- child_realize (fullday, children->data);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_map (fullday, children->data);
- }
-
- gtk_widget_draw (GTK_WIDGET (fullday), NULL);
-}
-
-void
-gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if ((lower != fullday->lower) || (upper != fullday->upper)) {
- fullday->lower = lower;
- fullday->upper = upper;
-
- di = fullday->drag_info;
-
- di->sel_rows_used = 0; /* clear selection */
-
- gncal_full_day_update (fullday, NULL, 0);
- }
-}
-
-int
-gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper)
-{
- struct drag_info *di;
- time_t alower, aupper;
-
- g_return_val_if_fail (fullday != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), FALSE);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0){
- time_t now = time (NULL);
- struct tm tm = *localtime (&now);
- struct tm thisd = *localtime (&fullday->lower);
-
- thisd.tm_hour = tm.tm_hour;
- thisd.tm_min = tm.tm_min;
- thisd.tm_sec = 0;
- *lower = mktime (&thisd);
- thisd.tm_hour++;
- *upper = mktime (&thisd);
- return FALSE;
- }
-
- get_time_from_rows (fullday, di->sel_start_row, di->sel_rows_used, &alower, &aupper);
-
- if (lower)
- *lower = alower;
-
- if (upper)
- *upper= aupper;
-
- return TRUE;
-}
-
-void
-gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico)
-{
- GList *children;
- Child *child;
- GdkEvent event;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (ico != NULL);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico) {
- gtk_widget_grab_focus (child->widget);
-
- /* We synthesize a click because GtkText will not set the cursor and
- * the user will not be able to type-- this has to be fixed in
- * GtkText. */
-
- memset (&event, 0, sizeof (event));
-
- event.type = GDK_BUTTON_PRESS;
- event.button.window = child->widget->window;
- event.button.time = GDK_CURRENT_TIME;
- event.button.x = 0;
- event.button.y = 0;
- event.button.button = 1;
-
- gtk_widget_event (child->widget, &event);
-
- break;
- }
- }
-}
-
-int
-gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- int begin_row;
-
- g_return_val_if_fail (fullday != NULL, 0);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), 0);
-
- widget = GTK_WIDGET (fullday);
-
- begin_row = (day_begin * 60) / fullday->interval;
-
- return widget->style->klass->ythickness + begin_row * calc_row_height (fullday);
-}
-
-static void
-range_activated (GncalFullDay *fullday)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- di = fullday->drag_info;
-
- /* Remove selection; at this point someone should already have added an appointment */
-
- di->sel_rows_used = 0;
-
- paint_back (fullday, NULL);
-}
diff --git a/calendar/gncal-full-day.h b/calendar/gncal-full-day.h
deleted file mode 100644
index 287c5f63f6..0000000000
--- a/calendar/gncal-full-day.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_FULL_DAY_H
-#define GNCAL_FULL_DAY_H
-
-
-#include <gtk/gtkcontainer.h>
-#include <libgnome/gnome-defs.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_FULL_DAY(obj) GTK_CHECK_CAST (obj, gncal_full_day_get_type (), GncalFullDay)
-#define GNCAL_FULL_DAY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_full_day_get_type (), GncalFullDayClass)
-#define GNCAL_IS_FULL_DAY(obj) GTK_CHECK_TYPE (obj, gncal_full_day_get_type ())
-
-
-typedef struct _GncalFullDay GncalFullDay;
-typedef struct _GncalFullDayClass GncalFullDayClass;
-
-struct _GncalFullDay {
- GtkContainer container;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t lower; /* lower time to display */
- time_t upper; /* upper time to display */
- int interval; /* interval between rows in minutes */
-
- GList *children; /* container children */
- gpointer drag_info; /* internal drag information */
-
- GdkCursor *up_down_cursor; /* for dragging children */
- GdkCursor *beam_cursor; /* for the text widgets */
- GdkGC *recur_gc; /* The gc used to draw the recur image */
- GdkGC *bell_gc; /* The gc used to draw on imlib windows */
-
-};
-
-struct _GncalFullDayClass {
- GtkContainerClass parent_class;
-
- void (* range_activated) (GncalFullDay *fullday);
-};
-
-
-guint gncal_full_day_get_type (void);
-GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags);
-void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper);
-
-/* Returns the selected range in lower and upper. If nothing is
- * selected, return value is FALSE, otherwise it is TRUE.
- * The lower and upper values are always set to proper values, regardless of
- * the selection value
- */
-int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper);
-
-void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico);
-
-int gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-todo.c b/calendar/gncal-todo.c
deleted file mode 100644
index d527d6ff09..0000000000
--- a/calendar/gncal-todo.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/* 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 "gncal-todo.h"
-#include "main.h"
-#include "popup-menu.h"
-
-
-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)
-{
- iCalObject *ico;
- GncalTodo *todo;
- GtkEntry *entry;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo"));
- entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry"));
-
- if (ico->summary)
- g_free (ico->summary);
-
- ico->summary = g_strdup (gtk_entry_get_text (entry));
- ico->user_data = NULL;
-
- if (ico->new) {
- gnome_calendar_add_object (todo->calendar, ico);
- ico->new = FALSE;
- } else
- gnome_calendar_object_changed (todo->calendar, ico, CHANGE_ALL); /* ok, summary only... */
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
-cancel_button (GtkWidget *widget, GnomeDialog *dialog)
-{
- iCalObject *ico;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- ico->user_data = NULL;
-
- if (ico->new)
- ical_object_destroy (ico);
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static gint
-delete_event (GtkWidget *widget, GdkEvent *event, GnomeDialog *dialog)
-{
- cancel_button (NULL, dialog);
- return TRUE;
-}
-
-static void
-simple_todo_editor (GncalTodo *todo, iCalObject *ico)
-{
- GtkWidget *dialog;
- GtkWidget *hbox;
- GtkWidget *w;
- GtkWidget *entry;
-
- dialog = gnome_dialog_new (ico->new ? _("Create to-do item") : _("Edit to-do item"),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
-
- 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);
-
- w = gtk_label_new (_("Summary:"));
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- entry = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (entry), ico->summary);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_show (entry);
-
- ico->user_data = dialog;
-
- gtk_object_set_user_data (GTK_OBJECT (dialog), ico);
-
- gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo);
- gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry);
-
- 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 iCalObject *
-get_clist_selected_ico (GtkCList *clist)
-{
- gint sel;
-
- if (!clist->selection)
- return NULL;
-
- sel = (gint) clist->selection->data;
-
- return gtk_clist_get_row_data (clist, sel);
-}
-
-static void
-add_todo (GncalTodo *todo)
-{
- iCalObject *ico;
-
- ico = ical_new ("", user_name, "");
- ico->type = ICAL_TODO;
- ico->new = TRUE;
-
- simple_todo_editor (todo, ico);
-}
-
-static void
-edit_todo (GncalTodo *todo)
-{
- simple_todo_editor (todo, get_clist_selected_ico (todo->clist));
-}
-
-static void
-delete_todo (GncalTodo *todo)
-{
- gnome_calendar_remove_object (todo->calendar, get_clist_selected_ico (todo->clist));
-}
-
-static void
-add_activated (GtkWidget *widget, GncalTodo *todo)
-{
- add_todo (todo);
-}
-
-static void
-edit_activated (GtkWidget *widget, GncalTodo *todo)
-{
- 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;
-
- 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;
- }
-}
-
-static void
-gncal_todo_init (GncalTodo *todo)
-{
- GtkWidget *w;
- GtkWidget *hbox;
-
- 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 */
-
- w = gtk_clist_new (1);
- todo->clist = GTK_CLIST (w);
-
- gtk_clist_set_policy (todo->clist, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- 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_box_pack_start (GTK_BOX (todo), w, TRUE, TRUE, 0);
- 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 void
-insert_in_clist (GncalTodo *todo, iCalObject *ico)
-{
- int i;
- char *text[1] = { ico->summary };
- iCalObject *row_ico;
-
- if (ico->priority == 0)
- i = gtk_clist_append (todo->clist, text); /* items with undefined priority go to the end of the list */
- else {
-
- /* Find proper place in clist to insert object. Objects are sorted by priority. */
-
- for (i = 0; i < todo->clist->rows; i++) {
- row_ico = gtk_clist_get_row_data (todo->clist, i);
-
- if (ico->priority >= row_ico->priority)
- break;
- }
-
- gtk_clist_insert (todo->clist, i, text);
- }
-
- /* Set the appropriate "done" icon and hook the object to the row */
-
- gtk_clist_set_row_data (todo->clist, i, ico);
-}
-
-void
-gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
-{
- GList *list;
-
- g_return_if_fail (todo != NULL);
- g_return_if_fail (GNCAL_IS_TODO (todo));
-
- gtk_clist_freeze (todo->clist);
-
- gtk_clist_clear (todo->clist);
-
- for (list = todo->calendar->cal->todo; list; list = list->next)
- insert_in_clist (todo, list->data);
-
- gtk_clist_thaw (todo->clist);
-
- gtk_widget_set_sensitive (todo->edit_button, (todo->clist->rows > 0));
- gtk_widget_set_sensitive (todo->delete_button, (todo->clist->rows > 0));
-}
diff --git a/calendar/gncal-todo.h b/calendar/gncal-todo.h
deleted file mode 100644
index cb32c25421..0000000000
--- a/calendar/gncal-todo.h
+++ /dev/null
@@ -1,52 +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;
-};
-
-struct _GncalTodoClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_todo_get_type (void);
-GtkWidget *gncal_todo_new (GnomeCalendar *calendar);
-
-void gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
deleted file mode 100644
index 0e280163d9..0000000000
--- a/calendar/gncal-week-view.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <config.h>
-#include <string.h>
-#include "gncal-week-view.h"
-#include "timeutil.h"
-
-static void gncal_week_view_init (GncalWeekView *wview);
-
-
-guint
-gncal_week_view_get_type (void)
-{
- static guint week_view_type = 0;
-
- if (!week_view_type) {
- GtkTypeInfo week_view_info = {
- "GncalWeekView",
- sizeof (GncalWeekView),
- sizeof (GncalWeekViewClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_week_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- week_view_type = gtk_type_unique (gtk_vbox_get_type (), &week_view_info);
- }
-
- return week_view_type;
-}
-
-static void
-gncal_week_view_init (GncalWeekView *wview)
-{
- int i;
-
- wview->calendar = NULL;
- memset (&wview->start_of_week, 0, sizeof (wview->start_of_week));
-
- for (i = 0; i < 7; i++)
- wview->days[i] = NULL;
-
- wview->gtk_calendar = NULL;
-}
-
-static void
-jump_to_day (GtkCalendar *cal, GncalWeekView *wview, int day)
-{
- struct tm tm;
- time_t t;
- static int inside;
-
- if (inside)
- return;
- inside = 1;
- tm.tm_mday = day;
- tm.tm_mon = cal->month;
- tm.tm_year = cal->year - 1900;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- t = mktime (&tm);
-
- gncal_week_view_set (wview, t);
- inside = 0;
-}
-
-static void
-jump_to_day_click (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, cal->selected_day);
-}
-
-static void
-sync_week (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, wview->start_of_week.tm_mday + 7);
- gnome_calendar_tag_calendar (wview->calendar, wview->gtk_calendar);
-}
-
-static void
-double_click_on_weekday (GtkWidget *widget, GdkEvent *e, GncalWeekView *wview)
-{
-}
-
-GtkWidget *
-gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
-{
- GncalWeekView *wview;
- GtkWidget *table;
- int i;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- wview = gtk_type_new (gncal_week_view_get_type ());
-
- table = gtk_table_new (0, 0, 0);
- gtk_table_set_homogeneous (GTK_TABLE (table), TRUE);
- wview->label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (wview), wview->label, 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (wview), table, 1, 1, 0);
- wview->calendar = calendar;
- for (i = 0; i < 7; i++) {
- wview->days[i] = GNCAL_DAY_VIEW (gncal_day_view_new (calendar, 0, 0));
- gtk_signal_connect (GTK_OBJECT (wview->days [i]), "button_press_event",
- GTK_SIGNAL_FUNC(double_click_on_weekday), wview);
-
- if (i < 5)
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i, i + 1,
- 0, 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- else
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i - 2, i - 1,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- gtk_widget_show (GTK_WIDGET (wview->days[i]));
- }
-
- wview->gtk_calendar = GTK_CALENDAR (gtk_calendar_new ());
-
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "day_selected_double_click",
- GTK_SIGNAL_FUNC(jump_to_day_click), wview);
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC(sync_week), wview);
-
- gtk_calendar_display_options (wview->gtk_calendar,
- GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->gtk_calendar),
- 0, 3,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 4, 4);
- gtk_widget_show (GTK_WIDGET (wview->gtk_calendar));
-
- gncal_week_view_set (wview, start_of_week);
-
- return GTK_WIDGET (wview);
-}
-
-static void
-update (GncalWeekView *wview, int update_days, iCalObject *object, int flags)
-{
- int i;
-
- if (update_days)
- for (i = 0; i < 7; i++)
- gncal_day_view_update (wview->days[i], object, flags);
-
- /* FIXME: update extra widgets */
-}
-
-void
-gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- update (wview, TRUE, ico, flags);
-}
-
-void
-gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
-{
- struct tm tm;
- time_t day_start, day_end, week_start, week_end;
- int i;
-
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- tm = *localtime (&start_of_week);
-
- /* back up to start of week (Monday) */
-
- tm.tm_mday -= (tm.tm_wday == 0) ? 6 : (tm.tm_wday - 1);
-
- /* Start of day */
-
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- day_start = week_start = mktime (&tm);
-
- /* Calendar */
-
- gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- /* Day views */
-
- for (i = 0; i < 7; i++) { /* rest of days */
- tm.tm_mday++;
- day_end = mktime (&tm);
-
- gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
-
- day_start = day_end;
- }
-
- update (wview, FALSE, NULL, 0);
-
- /* The label */
- {
- char buf [80];
- int len;
- struct tm *t;
-
- week_end = time_add_day (week_start, 6);
- t = localtime (&week_start);
-
- strftime (buf, sizeof (buf), "%A %d %Y - ", t);
- len = strlen (buf);
-
- t = localtime (&week_end);
- strftime (buf + len, sizeof (buf) - len, "%A %d %Y", t);
- gtk_label_set (GTK_LABEL (wview->label), buf);
-
- }
-}
-
diff --git a/calendar/gncal-week-view.h b/calendar/gncal-week-view.h
deleted file mode 100644
index 1514890504..0000000000
--- a/calendar/gncal-week-view.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef WEEK_VIEW_H
-#define WEEK_VIEW_H
-
-
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gtkcalendar.h>
-#include "gnome-cal.h"
-#include "gncal-day-view.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_WEEK_VIEW(obj) GTK_CHECK_CAST (obj, gncal_week_view_get_type (), GncalWeekView)
-#define GNCAL_WEEK_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_week_view_get_type (), GncalWeekViewClass)
-#define GNCAL_IS_WEEK_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_week_view_get_type ())
-
-
-typedef struct _GncalWeekView GncalWeekView;
-typedef struct _GncalWeekViewClass GncalWeekViewClass;
-
-struct _GncalWeekView {
- GtkVBox box;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- struct tm start_of_week;
-
- GncalDayView *days[7]; /* the day view widgets */
- GtkCalendar *gtk_calendar; /* At least for now; see the FIXME comments in the .c file */
- GtkWidget *label;
-};
-
-struct _GncalWeekViewClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_week_view_get_type (void);
-GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week);
-
-void gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags);
-void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal.c b/calendar/gncal.c
deleted file mode 100644
index 232aa19135..0000000000
--- a/calendar/gncal.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * gnlp.c: LPQ/LPR stuff
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <time.h>
-#include <string.h>
-
-#include <gnome.h>
-#include <config.h>
-
-#include "gncal.h"
-#include "calcs.h"
-#include "clist.h"
-#include "gncal-week-view.h"
-
-void
-prueba (void)
-{
- GtkWidget *window;
- GtkWidget *wview;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
- gtk_container_border_width (GTK_CONTAINER (window), 6);
-
- wview = gncal_week_view_new (NULL, time (NULL));
- gtk_container_add (GTK_CONTAINER (window), wview);
- gtk_widget_show (wview);
-
- gtk_widget_show (window);
-}
-
-/* Function declarations */
-void parse_args(int argc, char *argv[]);
-static int save_state (GnomeClient *client,
- gint phase,
- GnomeRestartStyle save_style,
- gint shutdown,
- GnomeInteractStyle interact_style,
- gint fast,
- gpointer client_data);
-static void connect_client (GnomeClient *client,
- gint was_restarted,
- gpointer client_data);
-
-void discard_session (gchar *id);
-
-static GtkMenuEntry menu_items[] =
-{
- { N_("File/Exit"), N_("<control>Q"), menu_file_quit, NULL},
- { N_("Help/About"), N_("<control>A"), menu_help_about, NULL},
-};
-
-#define DAY_ARRAY_MAX 35
-/* The naughty global variables */
-int curr_day, old_day;
-int curr_month, old_month;
-int curr_year, old_year;
-GtkWidget *month_label;
-GtkWidget *year_label;
-GtkWidget *dailylist;
-GtkWidget *calendar_days[DAY_ARRAY_MAX];
-GtkWidget *calendar_buttons[DAY_ARRAY_MAX];
-GtkWidget *app;
-GtkWidget *calendar;
-
-int restarted = 0;
-/* Stuff we use for session state */
-int os_x = 0,
- os_y = 0,
- os_w = 0,
- os_h = 0;
-
-
-/* True if parsing determined that all the work is already done. */
-int just_exit = 0;
-
-/* These are the arguments that our application supports. */
-static struct argp_option arguments[] =
-{
-#define DISCARD_KEY -1
- { "discard-session", DISCARD_KEY, N_("ID"), 0, N_("Discard session"), 1 },
- { NULL, 0, NULL, 0, NULL, 0 }
-};
-
-/* Forward declaration of the function that gets called when one of
- our arguments is recognized. */
-static error_t parse_an_arg (int key, char *arg, struct argp_state *state);
-
-/* This structure defines our parser. It can be used to specify some
- options for how our parsing function should be called. */
-static struct argp parser =
-{
- arguments, /* Options. */
- parse_an_arg, /* The parser function. */
- NULL, /* Some docs. */
- NULL, /* Some more docs. */
- NULL, /* Child arguments -- gnome_init fills
- this in for us. */
- NULL, /* Help filter. */
- NULL /* Translation domain; for the app it
- can always be NULL. */
-};
-
-#define ELEMENTS(x) (sizeof (x) / sizeof (x [0]))
-
-GtkMenuFactory *
-create_menu ()
-{
- GtkMenuFactory *subfactory;
- int i;
-
- subfactory = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
- gtk_menu_factory_add_entries (subfactory, menu_items, ELEMENTS(menu_items));
-
- return subfactory;
-}
-
-/* place marker until i get get something better */
-void print_error(char *text)
-{
- GtkWidget *msgbox;
- char buf[512];
-
- if (errno == 0)
- sprintf(buf, "%s", text);
- else
- sprintf(buf, "%s (%s)", text, g_strerror(errno));
-
- g_warning("%s\n", buf);
- msgbox = gnome_message_box_new(buf, "error", "OK", NULL, NULL);
-
- gtk_widget_show(msgbox);
-}
-
-
-void menu_file_quit(GtkWidget *widget, gpointer data)
-{
- gtk_main_quit();
-}
-
-void menu_help_about(GtkWidget *widget, gpointer data)
-{
- GtkWidget *about;
- gchar *authors[] = {
- "Craig Small <csmall@small.dropbear.id.au>",
- NULL };
- about = gnome_about_new( _("Gnome Calendar"), VERSION,
- "(C) 1998",
- authors,
- /* Comments */
- _("This program shows a nice pretty "
- "calendar and will do scheduling "
- "real soon now!"),
- NULL);
-
- gtk_widget_show(about);
-}
-
-void dailylist_item_select(GtkWidget *widget, gpointer data)
-{
- int *x = (int*)data;
-
- g_print("Selected %d\n", x);
-}
-
-void update_today_list(void)
-{
- GtkWidget *listitem;
- GtkWidget *list_hbox;
- GtkWidget *hour_label;
- GtkWidget *event_label;
- char buf[50];
- int tmphr, tmpmin,i;
-
-}
-
-/*
- * updates the calendar that appears in the left collumn
- */
-void month_changed(GtkWidget *widget, gpointer data)
-{
- curr_month = GTK_CALENDAR(widget)->month;
- curr_year = GTK_CALENDAR(widget)->year;
-}
-
-void update_calendar()
-{
- int tmpday;
- int i;
- char buf[50];
- int month_changed;
- static int offset;
-
- gtk_calendar_unmark_day(GTK_CALENDAR(calendar),old_day);
- gtk_calendar_mark_day(GTK_CALENDAR(calendar), curr_day);
- printf("Date changed (nothing happens much\n");
-/* gtk_calendar_select_day(GTK_CALENDAR(calendar), curr_day); */
-#if 0
- /* Only update the whole calendar if the year or month has changed */
- tmpday=1;
- month_changed = FALSE;
- if (curr_month != old_month || curr_year != old_year) {
- month_changed = TRUE;
- offset = weekday_of_date(tmpday, curr_month, curr_year) - 1;
- }
-
- for(i=0; i < DAY_ARRAY_MAX; i++) {
- tmpday = i - offset +1;
- if (valid_date(tmpday, curr_month, curr_year)) {
- sprintf(buf, "%2d", tmpday);
- /*if (month_changed) {*/
- gtk_label_set(GTK_LABEL(calendar_days[i]), buf);
- gtk_widget_show(calendar_buttons[i]);
- /*}*/
- if (tmpday == curr_day) {
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i]), 2);
- gtk_widget_show(calendar_buttons[i]);
- } else {
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i]), 0);
- }
- } else if (month_changed) {
- gtk_label_set(GTK_LABEL(calendar_days[i]), "");
- gtk_widget_hide(calendar_buttons[i]);
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i]), 0);
- }
- } /* for i */
-#endif /* 0 */
-}
-
-/*
- * Updates all the main window widgets when the current day of interest is
- * changed
- */
-void update_today(void)
-{
- char buf[50];
-
- /* This needs to be fixed to get the right date order for the country*/
-/* if (curr_month != old_month) {
- gtk_label_set(GTK_LABEL(month_label), month_name(curr_month));
- }
- if (curr_year != old_year) {
- sprintf(buf, "%4d", curr_year);
- gtk_label_set(GTK_LABEL(year_label), buf);
- }*/
- update_today_list();
- update_calendar();
-}
-
-void next_day_but_clicked(GtkWidget *widget, gpointer data)
-{
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- next_date(&curr_day, &curr_month, &curr_year);
- update_today();
-}
-
-void prev_day_but_clicked(GtkWidget *widget, gpointer data)
-{
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- prev_date(&curr_day, &curr_month, &curr_year);
- update_today();
-}
-
-void today_but_clicked(GtkWidget *widget, gpointer data)
-{
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- get_system_date(&curr_day, &curr_month, &curr_year);
- update_today();
-}
-
-void prev_month_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 0 && curr_month == MONTH_MIN)
- return;
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_month--;
- if (curr_month < MONTH_MIN) {
- curr_month = MONTH_MAX;
- curr_year--;
- }
- update_today();
-}
-
-void next_month_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 3000 && curr_month == MONTH_MAX)
- return;
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_month++;
- if (curr_month > MONTH_MAX ) {
- curr_month = MONTH_MIN;
- curr_year++;
- }
- update_today();
-}
-
-void prev_year_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 0)
- return;
-
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_year--;
- update_today();
-}
-
-
-void next_year_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 3000)
- return;
-
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_year++;
- update_today();
-}
-
-
-void calendar_but_clicked(GtkWidget *widget, gpointer data)
-{
- char *ptr;
- int x;
-
- ptr = GTK_LABEL(GTK_BUTTON(widget)->child)->label;
- x = atoi(ptr);
-
- if (valid_date(x, curr_month, curr_year)) {
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_day = x;
- update_today();
- }
-}
-
-void test_foreach(GtkWidget *widget, gpointer data)
-{
- char *ptr;
-
- ptr = GTK_LABEL(GTK_BUTTON(widget)->child)->label;
- g_print("%s\n", ptr);
-}
-
-void show_main_window()
-{
- GtkWidget *main_vbox;
- /*GtkWidget *menubar;
- GtkAcceleratorTable *accel;*/
- GtkMenuFactory *menuf;
- GtkWidget *main_hbox;
- GtkWidget *left_vbox;
- GtkWidget *right_vbox;
- GtkWidget *date_hbox;
- GtkWidget *prev_mth_but;
- GtkWidget *next_mth_but;
- GtkWidget *prev_year_but;
- GtkWidget *next_year_but;
- GtkWidget *day_but_hbox;
- GtkWidget *prev_day_but;
- GtkWidget *today_but;
- GtkWidget *next_day_but;
- GtkWidget *separator;
- GtkWidget *cal_table;
- GtkWidget *day_name_label;
- GtkWidget *scrolledwindow;
- GtkWidget *scroll_hbox;
- GtkWidget *hour_list;
- GtkWidget *list_item;
- GtkWidget *dailylist_item;
- GtkWidget *event_label;
- int i,j;
- struct tm tm;
- char buf[50];
-
- bzero((char*)&tm, sizeof(struct tm));
- app = gnome_app_new("gncal", "Gnome Calendar");
- gtk_widget_realize(app);
- gtk_signal_connect(GTK_OBJECT(app), "delete_event",
- GTK_SIGNAL_FUNC(menu_file_quit), NULL);
- if (restarted) {
- gtk_widget_set_uposition(app, os_x, os_y);
- gtk_widget_set_usize(app, os_w, os_h);
- } else {
- gtk_widget_set_usize(app,300,300);
- }
- main_vbox = gtk_vbox_new(FALSE, 1);
- gnome_app_set_contents(GNOME_APP(app), main_vbox);
- gtk_widget_show(main_vbox);
-
- menuf = create_menu();
- gnome_app_set_menus(GNOME_APP(app), GTK_MENU_BAR(menuf->widget));
-
- main_hbox = gtk_hbox_new(FALSE,1);
- gtk_box_pack_start(GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 0);
- gtk_widget_show(main_hbox);
-
- left_vbox = gtk_vbox_new(FALSE, 1);
- gtk_box_pack_start(GTK_BOX(main_hbox), left_vbox, FALSE, TRUE,0);
- gtk_widget_show(left_vbox);
-
- separator = gtk_vseparator_new();
- gtk_box_pack_start(GTK_BOX(main_hbox), separator, FALSE, TRUE, 0);
- gtk_widget_show(separator);
-
- right_vbox = gtk_vbox_new(FALSE, 1);
- gtk_box_pack_start(GTK_BOX(main_hbox), right_vbox, TRUE, TRUE, 0);
- gtk_widget_show(right_vbox);
-
- date_hbox = gtk_hbox_new(FALSE, 1);
- gtk_box_pack_start(GTK_BOX(left_vbox), date_hbox, FALSE, FALSE, 0);
- gtk_widget_show(date_hbox);
-/*
- prev_mth_but = gtk_button_new_with_label("<");
- gtk_box_pack_start(GTK_BOX(date_hbox), prev_mth_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(prev_mth_but), "clicked", GTK_SIGNAL_FUNC(prev_month_but_clicked), NULL);
- gtk_widget_show(prev_mth_but);
-
- month_label = gtk_label_new("Fooary");
- gtk_box_pack_start(GTK_BOX(date_hbox), month_label, TRUE, FALSE, 0);
- gtk_widget_show(month_label);
-
- next_mth_but = gtk_button_new_with_label(">");
- gtk_box_pack_start(GTK_BOX(date_hbox), next_mth_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(next_mth_but), "clicked", GTK_SIGNAL_FUNC(next_month_but_clicked), NULL);
- gtk_widget_show(next_mth_but);
-
- prev_year_but = gtk_button_new_with_label("<");
- gtk_box_pack_start(GTK_BOX(date_hbox), prev_year_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(prev_year_but), "clicked", GTK_SIGNAL_FUNC(prev_year_but_clicked), NULL);
- gtk_widget_show(prev_year_but);
-
- year_label = gtk_label_new("1971");
- gtk_box_pack_start(GTK_BOX(date_hbox), year_label, TRUE, FALSE, 0);
- gtk_widget_show(year_label);
-
- next_year_but = gtk_button_new_with_label(">");
- gtk_box_pack_start(GTK_BOX(date_hbox), next_year_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(next_year_but), "clicked", GTK_SIGNAL_FUNC(next_year_but_clicked), NULL);
- gtk_widget_show(next_year_but);
-*/
- /* Build up the calendar table */
-/* cal_table = gtk_table_new(7,7,TRUE);
- gtk_box_pack_start(GTK_BOX(left_vbox), cal_table, FALSE, FALSE, 0);
- gtk_widget_show(cal_table);
-
- for(i=DAY_MIN; i <= DAY_MAX; i++) {
- day_name_label = gtk_label_new(short3_day_name(i));
- gtk_table_attach_defaults(GTK_TABLE(cal_table), day_name_label, i-1, i, 0, 1);
- gtk_widget_show(day_name_label);
- }
- for(j=0; j < 5; j++) {
- for(i=0; i < 7; i++) {
- calendar_buttons[i+j*7] = gtk_button_new();
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i+j*7]), 0);
- gtk_table_attach_defaults(GTK_TABLE(cal_table), calendar_buttons[i+j*7], i, i+1, j+2, j+3);
- gtk_signal_connect(GTK_OBJECT(calendar_buttons[i+j*7]), "clicked", GTK_SIGNAL_FUNC(calendar_but_clicked), NULL);
- gtk_widget_show(calendar_buttons[i+j*7]);
- calendar_days[i+j*7] = gtk_label_new("");
- gtk_container_add(GTK_CONTAINER(calendar_buttons[i+j*7]), calendar_days[i+j*7]);
- gtk_widget_show(calendar_days[i+j*7]);
- }
- }
-*/
- calendar = gtk_calendar_new();
- gtk_calendar_display_options(GTK_CALENDAR(calendar), GTK_CALENDAR_SHOW_DAY_NAMES | GTK_CALENDAR_SHOW_HEADING);
- gtk_box_pack_start(GTK_BOX(left_vbox), calendar, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(calendar), "month_changed",
- GTK_SIGNAL_FUNC(month_changed), NULL);
- gtk_widget_show(calendar);
-
-
- day_but_hbox = gtk_hbox_new(TRUE, 1);
- gtk_box_pack_start(GTK_BOX(left_vbox), day_but_hbox, FALSE, FALSE, 0);
- gtk_widget_show(day_but_hbox);
-
- prev_day_but = gtk_button_new_with_label("Prev");
- gtk_box_pack_start(GTK_BOX(day_but_hbox), prev_day_but, TRUE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(prev_day_but), "clicked", GTK_SIGNAL_FUNC(prev_day_but_clicked), NULL);
- gtk_widget_show(prev_day_but);
-
- today_but = gtk_button_new_with_label("Today");
- gtk_box_pack_start(GTK_BOX(day_but_hbox), today_but, TRUE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(today_but), "clicked", GTK_SIGNAL_FUNC(today_but_clicked), NULL);
- gtk_widget_show(today_but);
-
- next_day_but = gtk_button_new_with_label("Next");
- gtk_box_pack_start(GTK_BOX(day_but_hbox), next_day_but, TRUE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(next_day_but), "clicked", GTK_SIGNAL_FUNC(next_day_but_clicked), NULL);
- gtk_widget_show(next_day_but);
-
-
- dailylist = create_clist();
- gtk_box_pack_start(GTK_BOX(right_vbox), dailylist, TRUE, TRUE, 0);
- gtk_widget_show(dailylist);
- setup_clist(dailylist);
-
- gtk_widget_show(app);
-
-}
-
-
-int
-main(int argc, char *argv[])
-{
- GnomeClient *client;
-
- argp_program_version = VERSION;
-
-
- /* Initialise the i18n stuff */
- bindtextdomain(PACKAGE, GNOMELOCALEDIR);
- textdomain(PACKAGE);
-
- /* This create a default client and arrages for it to parse some
- command line arguments
- */
- client = gnome_client_new_default();
-
- /* Arrange to be told when something interesting happens. */
- gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
- GTK_SIGNAL_FUNC (save_state), (gpointer) argv[0]);
- gtk_signal_connect (GTK_OBJECT (client), "connect",
- GTK_SIGNAL_FUNC (connect_client), NULL);
-
- gnome_init("gncal", &parser, argc, argv, 0, NULL);
-
- show_main_window();
-
- /* Initialse date to the current day */
- old_day = old_month = old_year = 0;
- get_system_date(&curr_day, &curr_month, &curr_year);
- update_today();
-
- prueba ();
-
- gtk_main();
-
- return 0;
-}
-
-static error_t
-parse_an_arg (int key, char *arg, struct argp_state *state)
-{
- if (key == DISCARD_KEY)
- {
- discard_session (arg);
- just_exit = 1;
- return 0;
- }
-
- /* We didn't recognize it. */
- return ARGP_ERR_UNKNOWN;
-}
-
-
-/* Session Management routines */
-
-
-static int
-save_state (GnomeClient *client,
- gint phase,
- GnomeRestartStyle save_style,
- gint shutdown,
- GnomeInteractStyle interact_style,
- gint fast,
- gpointer client_data)
-{
- gchar *session_id;
- gchar *sess;
- gchar *buf;
- gchar *argv[3];
- gint x, y, w, h;
-
- session_id= gnome_client_get_id (client);
-
- /* The only state that gnome-hello has is the window geometry.
- Get it. */
- gdk_window_get_geometry (app->window, &x, &y, &w, &h, NULL);
-
- /* Save the state using gnome-config stuff. */
- sess = g_copy_strings ("/gncal/Saved-Session-",
- session_id,
- NULL);
-
- buf = g_copy_strings ( sess, "/x", NULL);
- gnome_config_set_int (buf, x);
- g_free(buf);
- buf = g_copy_strings ( sess, "/y", NULL);
- gnome_config_set_int (buf, y);
- g_free(buf);
- buf = g_copy_strings ( sess, "/w", NULL);
- gnome_config_set_int (buf, w);
- g_free(buf);
- buf = g_copy_strings ( sess, "/h", NULL);
- gnome_config_set_int (buf, h);
- g_free(buf);
-
- gnome_config_sync();
- g_free(sess);
-
- /* Here is the real SM code. We set the argv to the parameters needed
- to restart/discard the session that we've just saved and call
- the gnome_session_set_*_command to tell the session manager it. */
- argv[0] = (char*) client_data;
- argv[1] = "--discard-session";
- argv[2] = session_id;
- gnome_client_set_discard_command (client, 3, argv);
-
- /* Set commands to clone and restart this application. Note that we
- use the same values for both -- the session management code will
- automatically add whatever magic option is required to set the
- session id on startup. */
- gnome_client_set_clone_command (client, 1, argv);
- gnome_client_set_restart_command (client, 1, argv);
-
- g_print("save state\n");
- return TRUE;
-}
-
-/* Connected to session manager. If restarted from a former session:
- reads the state of the previous session. Sets os_* (prepare_app
- uses them) */
-void
-connect_client (GnomeClient *client, gint was_restarted, gpointer client_data)
-{
- gchar *session_id;
-
- /* Note that information is stored according to our *old*
- session id. The id can change across sessions. */
- session_id = gnome_client_get_previous_id (client);
-
- if (was_restarted && session_id != NULL)
- {
- gchar *sess;
- gchar *buf;
-
- restarted = 1;
-
- sess = g_copy_strings ("/gncal/Saved-Session-", session_id, NULL);
-
- buf = g_copy_strings ( sess, "/x", NULL);
- os_x = gnome_config_get_int (buf);
- g_free(buf);
- buf = g_copy_strings ( sess, "/y", NULL);
- os_y = gnome_config_get_int (buf);
- g_free(buf);
- buf = g_copy_strings ( sess, "/w", NULL);
- os_w = gnome_config_get_int (buf);
- g_free(buf);
- buf = g_copy_strings ( sess, "/h", NULL);
- os_h = gnome_config_get_int (buf);
- g_free(buf);
- }
-
- /* If we had an old session, we clean up after ourselves. */
- if (session_id != NULL)
- discard_session (session_id);
-
- return;
-}
-
-void
-discard_session (gchar *id)
-{
- gchar *sess;
-
- sess = g_copy_strings ("/gncal/Saved-Session-", id, NULL);
-
- /* we use the gnome_config_get_* to work around a bug in gnome-config
- (it's going under a redesign/rewrite, so i didn't correct it) */
- gnome_config_get_int ("/gncal/Bug/work-around=0");
-
- gnome_config_clean_section (sess);
- gnome_config_sync ();
-
- g_free (sess);
- return;
-}
-
diff --git a/calendar/gncal.desktop b/calendar/gncal.desktop
deleted file mode 100644
index 434997de04..0000000000
--- a/calendar/gncal.desktop
+++ /dev/null
@@ -1,17 +0,0 @@
-[Desktop Entry]
-Name=Calendar
-Name[es]=Calendario
-Name[fr]=Calendrier
-Name[de]=Kalender
-Name[no]=Kalender
-Name[pt]=Agenda
-Comment=Calendar application
-Comment[es]=Calendario de Gnome
-Comment[fr]=Calendrier Gnome
-Comment[de]=Gnome Kalender
-Comment[no]=Gnome Kalender
-Comment[pt]=Agenda Gnome
-Exec=gnomecal
-Icon=gnome-calendar.png
-Terminal=0
-Type=Application
diff --git a/calendar/gncal.h b/calendar/gncal.h
deleted file mode 100644
index 8d4790bf07..0000000000
--- a/calendar/gncal.h
+++ /dev/null
@@ -1,6 +0,0 @@
-
-void menu_file_quit(GtkWidget *widget, gpointer data);
-#define MIN_DAILY_HOUR 8
-#define MAX_DAILY_HOUR 19
-#define DAILY_MINUTE_STEP 15
-void menu_help_about(GtkWidget *widget, gpointer data); \ No newline at end of file
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
deleted file mode 100644
index 234f782fa3..0000000000
--- a/calendar/gnome-cal.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-#include "gncal-day-panel.h"
-#include "gncal-week-view.h"
-#include "gncal-year-view.h"
-#include "month-view.h"
-#include "timeutil.h"
-#include "views.h"
-#include "main.h"
-
-GnomeApp *parent_class;
-
-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) NULL,
- (GtkObjectInitFunc) NULL,
- (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());
- }
- return gnome_calendar_type;
-}
-
-static void
-setup_widgets (GnomeCalendar *gcal)
-{
- time_t now;
-
- now = time (NULL);
-
- gcal->notebook = gtk_notebook_new ();
- gcal->day_view = gncal_day_panel_new (gcal, now);
- gcal->week_view = gncal_week_view_new (gcal, now);
- gcal->month_view = month_view_new (gcal);
- gcal->year_view = gncal_year_view_new (gcal, now);
- gcal->task_view = tasks_create (gcal);
-
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->month_view, gtk_label_new (_("Month View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
-/* gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo"))); */
-
- gtk_widget_show_all (gcal->notebook);
-
- gnome_app_set_contents (GNOME_APP (gcal), gcal->notebook);
-
-}
-
-static GtkWidget *
-get_current_page (GnomeCalendar *gcal)
-{
- return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
-}
-
-char *
-gnome_calendar_get_current_view_name (GnomeCalendar *gcal)
-{
- GtkWidget *page = get_current_page (gcal);
-
- if (page == gcal->day_view)
- return "dayview";
- else if (page == gcal->week_view)
- return "weekview";
- else if (page == gcal->year_view)
- return "yearview";
- else
- return "dayview";
-}
-
-void
-gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
-{
- GtkWidget *current = get_current_page (gcal);
-
- g_return_if_fail (new_time != -1);
-
- new_time = time_start_of_day (new_time);
-
- if (current == gcal->day_view)
- gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time);
- else if (current == gcal->week_view)
- gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
- else if (current == gcal->year_view)
- gncal_year_view_set (GNCAL_YEAR_VIEW (gcal->year_view), new_time);
- else {
- g_warning ("My penguin is gone!");
- g_assert_not_reached ();
- }
-
- gcal->current_display = new_time;
-}
-
-static void
-gnome_calendar_direction (GnomeCalendar *gcal, int direction)
-{
- GtkWidget *cp = get_current_page (gcal);
- time_t new_time;
-
- if (cp == gcal->day_view)
- new_time = time_add_day (gcal->current_display, 1 * direction);
- else if (cp == gcal->week_view)
- new_time = time_add_day (gcal->current_display, 7 * direction);
- else if (cp == gcal->year_view)
- new_time = time_add_year (gcal->current_display, 1 * direction);
- else {
- g_warning ("Weee! Where did the penguin go?");
- g_assert_not_reached ();
- new_time = 0;
- }
-
- gnome_calendar_goto (gcal, new_time);
-}
-
-void
-gnome_calendar_next (GnomeCalendar *gcal)
-{
- gnome_calendar_direction (gcal, 1);
-}
-
-void
-gnome_calendar_previous (GnomeCalendar *gcal)
-{
- gnome_calendar_direction (gcal, -1);
-}
-
-void
-gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
-{
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), 0);
- gnome_calendar_goto (gcal, time);
-}
-
-void
-gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name)
-{
- int page = 0;
-
- if (strcmp (page_name, "dayview") == 0)
- page = 0;
- else if (strcmp (page_name, "weekview") == 0)
- page = 1;
- else if (strcmp (page_name, "yearview") == 0)
- page = 2;
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), page);
-}
-
-GtkWidget *
-gnome_calendar_new (char *title)
-{
- GtkWidget *retval;
- GnomeCalendar *gcal;
- GnomeApp *app;
-
- retval = gtk_type_new (gnome_calendar_get_type ());
- app = GNOME_APP (retval);
- gcal = GNOME_CALENDAR (retval);
-
- app->name = g_strdup ("calendar");
- app->prefix = g_copy_strings ("/", app->name, "/", NULL);
-
- gtk_window_set_title(GTK_WINDOW(retval), title);
-
- gcal->current_display = time_start_of_day (time (NULL));
- gcal->cal = calendar_new (title);
- setup_widgets (gcal);
- return retval;
-}
-
-static void
-gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
-{
- gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags);
- gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags);
- gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags);
-}
-
-int
-gnome_calendar_load (GnomeCalendar *gcal, char *file)
-{
- char *r;
-
- if ((r = calendar_load (gcal->cal, file)) != NULL){
- printf ("Error loading calendar: %s\n", r);
- return 0;
- }
- gnome_calendar_update_all (gcal, NULL, 0);
- return 1;
-}
-
-void
-gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- calendar_add_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
-}
-
-void
-gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- calendar_remove_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_ALL);
-}
-
-void
-gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- gcal->cal->modified = TRUE;
-
- gnome_calendar_update_all (gcal, obj, flags);
- calendar_object_changed (gcal->cal, obj, flags);
-}
-
-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
-}
-
-static void
-execute (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);
-}
-
-void
-mail_notify (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_copy_strings ("To: ", mail_address, "\n",
- "Subject: ", _("Reminder of your appointment at "),
- ctime (&app_time), "\n\n", text, "\n", NULL);
- write (p [1], command, strlen (command));
-
- g_free (command);
-}
-
-void
-calendar_notify (time_t time, void *data)
-{
- iCalObject *ico = data;
-
- if (ico->aalarm.enabled && ico->aalarm.trigger == time){
- printf ("bip\n");
- return;
- }
-
- if (ico->palarm.enabled && ico->palarm.trigger == time){
- execute (ico->palarm.data, 0);
- return;
- }
-
- if (ico->malarm.enabled && ico->malarm.trigger == time){
- time_t app = ico->malarm.trigger + ico->malarm.offset;
-
- mail_notify (ico->malarm.data, ico->summary, app);
- return;
- }
-
- if (ico->dalarm.enabled && ico->dalarm.trigger == time){
- time_t app = ico->dalarm.trigger + ico->dalarm.offset;
- GtkWidget *w;
- char *msg;
-
- msg = g_copy_strings (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, "Ok", NULL);
- gtk_widget_show (w);
- return;
- }
-}
-
-/*
- * called from the calendar_iterate routine to mark the days of a GtkCalendar
- */
-static int
-mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GtkCalendar *gtk_cal = c;
- struct tm tm_s;
- time_t t, day_end;
-
- tm_s = *localtime (&start);
- day_end = time_end_of_day (end);
-
- for (t = start; t <= day_end; t += 60*60*24){
- time_t new = mktime (&tm_s);
- struct tm tm_day;
-
- tm_day = *localtime (&new);
- gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday);
- tm_s.tm_mday++;
- }
- return TRUE;
-}
-
-/*
- * Tags the dates with appointments in a GtkCalendar based on the
- * GnomeCalendar contents
- */
-void
-gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
-{
- time_t month_begin, month_end;
- struct tm tm;
-
- /* compute month_begin */
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday = 0;
- tm.tm_mon = gtk_cal->month;
- tm.tm_year = gtk_cal->year - 1900;
- tm.tm_isdst= -1;
-
- month_begin = mktime (&tm);
- tm.tm_mon++;
- month_end = mktime (&tm);
-
- gtk_calendar_freeze (gtk_cal);
- gtk_calendar_clear_marks (gtk_cal);
- calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal);
- gtk_calendar_thaw (gtk_cal);
-}
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
deleted file mode 100644
index ec1290a652..0000000000
--- a/calendar/gnome-cal.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef GNOME_CALENDAR_APP_H
-#define GNOME_CALENDAR_APP_H
-
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gnome-app.h>
-#include <libgnomeui/gtkcalendar.h>
-
-#include "calendar.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())
-
-typedef struct {
- GnomeApp gnome_app;
- Calendar *cal;
- time_t current_display;
-
- GtkWidget *notebook;
- GtkWidget *day_view;
- GtkWidget *week_view;
- GtkWidget *month_view;
- GtkWidget *year_view;
- GtkWidget *task_view;
- void *event_editor;
-} GnomeCalendar;
-
-typedef struct {
- GnomeAppClass parent_class;
-} GnomeCalendarClass;
-
-guint gnome_calendar_get_type (void);
-GtkWidget *gnome_calendar_new (char *title);
-int gnome_calendar_load (GnomeCalendar *gcal,
- char *file);
-void gnome_calendar_add_object (GnomeCalendar *gcal,
- iCalObject *obj);
-void gnome_calendar_remove_object (GnomeCalendar *gcal,
- iCalObject *obj);
-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);
-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);
-
-/* Flags is a bitmask of CalObjectChange values */
-void gnome_calendar_object_changed (GnomeCalendar *gcal,
- iCalObject *obj,
- int flags);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gnome-cal.html b/calendar/gnome-cal.html
deleted file mode 100644
index eeb8d4e25e..0000000000
--- a/calendar/gnome-cal.html
+++ /dev/null
@@ -1,42 +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.
-</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/gnome-month-item.c b/calendar/gnome-month-item.c
deleted file mode 100644
index 9b00d4d3c8..0000000000
--- a/calendar/gnome-month-item.c
+++ /dev/null
@@ -1,832 +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"
-
-
-/* These are indices into the items array of a GnomeMonthItem structure */
-enum {
- ITEM_HEAD_GROUP = 0, /* 7 groups */
- ITEM_HEAD_BOX = 7, /* 7 boxes */
- ITEM_HEAD_LABEL = 14, /* 7 labels */
- ITEM_DAY_GROUP = 21, /* 42 groups */
- ITEM_DAY_BOX = 63, /* 42 boxes */
- ITEM_DAY_LABEL = 105 /* 42 labels */
-};
-
-
-/* Number of days in a month, for normal and leap years */
-static 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 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
-};
-
-
-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::head_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_READABLE, 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);
-
- 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;
-}
-
-/* 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[ITEM_HEAD_GROUP + i],
- "x", width * i,
- "y", 0.0,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[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[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[ITEM_DAY_GROUP + i],
- "x", width * col,
- "y", mitem->head_height + height * row,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[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[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)
-{
- reshape_headings (mitem);
- reshape_days (mitem);
-}
-
-/* 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[ITEM_HEAD_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[ITEM_HEAD_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_HEAD_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "fill_color", "black",
- NULL);
-
- /* Label */
- mitem->items[ITEM_HEAD_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_HEAD_GROUP + i]),
- gnome_canvas_text_get_type (),
- "fill_color", "white",
- "font", "-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1",
- NULL);
- }
-}
-
-/* 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 *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);
-
- 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, ofs;
- int days[42];
- int start, end;
- char buf[100];
-
- build_month (mitem->month, mitem->year, days, &start, &end);
-
- if (mitem->start_on_monday)
- ofs = (start + 6) % 7;
- else
- ofs = start;
-
- /* Clear days before start of month */
-
- for (i = 0; i < ofs; i++)
- gnome_canvas_item_set (mitem->items[ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-
- /* Set days of month */
-
- for (; start <= end; start++, i++) {
- sprintf (buf, "%d", days[start]);
- gnome_canvas_item_set (mitem->items[ITEM_DAY_LABEL + i],
- "text", buf,
- NULL);
- }
-
- /* Clear days after end of month */
-
- for (; i < 42; i++)
- gnome_canvas_item_set (mitem->items[ITEM_DAY_LABEL + i],
- "text", NULL,
- 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[ITEM_DAY_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[ITEM_DAY_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_DAY_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "outline_color", "black",
- "fill_color", "#d6d6d6",
- NULL);
-
- /* Label */
- mitem->items[ITEM_DAY_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_DAY_GROUP + i]),
- gnome_canvas_text_get_type (),
- "fill_color", "black",
- "font", "-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1",
- NULL);
- }
-
- 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[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)
-{
- /* 7 heading groups
- * 7 heading boxes
- * 7 heading labels
- * 42 day groups
- * 42 day boxes
- * 42 day labels
- * ------------------
- * 147 items total
- */
-
- mitem->items = g_new (GnomeCanvasItem *, 147);
-
- create_headings (mitem);
- create_days (mitem);
-
- /* Initialize by default to three-letter day names */
-
- mitem->day_names[0] = _("Sun");
- mitem->day_names[1] = _("Mon");
- mitem->day_names[2] = _("Tue");
- mitem->day_names[3] = _("Wed");
- mitem->day_names[4] = _("Thu");
- mitem->day_names[5] = _("Fri");
- mitem->day_names[6] = _("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;
-}
-
-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)
-{
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
-
- 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);
-}
-
-/* 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);
-}
-
-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));
- reanchor (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEIGHT:
- mitem->height = fabs (GTK_VALUE_DOUBLE (*arg));
- reanchor (mitem);
- 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);
- 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;
-
- default:
- break;
- }
-}
-
-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;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
diff --git a/calendar/gnome-month-item.h b/calendar/gnome-month-item.h
deleted file mode 100644
index f6523aff94..0000000000
--- a/calendar/gnome-month-item.h
+++ /dev/null
@@ -1,71 +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
-
-
-#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 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);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/goto.c b/calendar/goto.c
deleted file mode 100644
index a21e162e00..0000000000
--- a/calendar/goto.c
+++ /dev/null
@@ -1,230 +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 "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-static void
-highlight_current_day (GnomeMonthItem *mitem)
-{
- struct tm *tm;
- time_t t;
-
- t = time (NULL);
- tm = localtime (&t);
-
- if ((mitem->year == (tm->tm_year + 1900)) && (mitem->month == tm->tm_mon)) {
- ;
- /* FIXME */
- }
-}
-
-/* Callback used when the year adjustment is changed */
-static void
-year_changed (GtkAdjustment *adj, GtkWidget *dialog)
-{
- GnomeCanvasItem *mitem;
-
- mitem = gtk_object_get_data (GTK_OBJECT (dialog), "month_item");
- gnome_canvas_item_set (mitem,
- "year", (int) adj->value,
- NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
-}
-
-/* Creates the year control with its adjustment */
-static GtkWidget *
-create_year (GtkWidget *dialog, GnomeCalendar *gcal, 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,
- dialog);
-
- 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)
-{
- GtkWidget *dialog;
- GnomeCanvasItem *mitem;
-
- if (!toggle->active)
- return;
-
- dialog = gtk_object_get_user_data (GTK_OBJECT (toggle));
- mitem = gtk_object_get_data (GTK_OBJECT (dialog), "month_item");
- gnome_canvas_item_set (mitem,
- "month", GPOINTER_TO_INT (data),
- NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
-}
-
-/* Creates the months control */
-static GtkWidget *
-create_months (GtkWidget *dialog, GnomeCalendar *gcal, int month)
-{
- GtkWidget *table;
- GtkWidget *w;
- GSList *group;
- int i, row, col;
- struct tm tm;
- char buf[100];
-
- tm = *localtime (&gcal->current_display);
-
- 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_object_set_user_data (GTK_OBJECT (w), dialog);
- 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, gpointer data)
-{
- gnome_canvas_item_set (data,
- "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);
-}
-
-/* Creates the canvas with the month item for selecting days */
-static GtkWidget *
-create_days (GtkWidget *dialog, GnomeCalendar *gcal, int day, int month, int year)
-{
- GtkWidget *canvas;
- GnomeCanvasItem *mitem;
-
- canvas = gnome_canvas_new ();
- gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120);
-
- mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas)->root));
- gnome_canvas_item_set (mitem,
- "month", month,
- "year", year,
- NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
-
- gtk_object_set_data (GTK_OBJECT (dialog), "month_item", mitem);
-
- /* 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,
- mitem);
-
- return canvas;
-}
-
-/* Creates a "goto date" dialog and runs it */
-void
-goto_dialog (GnomeCalendar *gcal)
-{
- GtkWidget *dialog;
- GtkWidget *vbox;
- GtkWidget *w;
- struct tm *tm;
-
- tm = localtime (&gcal->current_display);
-
- dialog = gnome_dialog_new (_("Go to date"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
-
- vbox = GNOME_DIALOG (dialog)->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);
-
- /* Year */
-
- w = create_year (dialog, gcal, tm->tm_year + 1900);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Month */
-
- w = create_months (dialog, gcal, tm->tm_mon);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Days (canvas with month item) */
-
- w = create_days (dialog, gcal, tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
- gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-
- /* Run! */
-
- gnome_dialog_set_modal (GNOME_DIALOG (dialog));
-
- printf ("el dialogo regreso %d\n", gnome_dialog_run_and_destroy (GNOME_DIALOG (dialog)));
-}
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
deleted file mode 100644
index 039e866306..0000000000
--- a/calendar/gui/Makefile.am
+++ /dev/null
@@ -1,82 +0,0 @@
-SUBDIRS = versit gnomecard
-help_base = $(datadir)/gnome/help/cal
-
-CFLAGS += -Wall
-
-INCLUDES = \
- -I$(includedir) \
- $(GNOME_INCLUDEDIR) \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
- -I../../gcalendar
-
-bin_PROGRAMS = gnomecal
-
-gnomecal_SOURCES = \
- alarm.c \
- alarm.h \
- calendar.c \
- calendar.h \
- calobj.c \
- calobj.h \
- eventedit.c \
- eventedit.h \
- gncal-day-panel.c \
- gncal-day-panel.h \
- gncal-day-view.c \
- gncal-day-view.h \
- gncal-full-day.c \
- gncal-full-day.h \
- gncal-week-view.c \
- gncal-week-view.h \
- gncal-todo.c \
- gncal-todo.h \
- gncal-year-view.c \
- gncal-year-view.h \
- gnome-month-item.c \
- gnome-month-item.h \
- getdate.y \
- gnome-cal.c \
- gnome-cal.h \
- goto.c \
- main.c \
- main.h \
- month-view.c \
- month-view.h \
- popup-menu.c \
- popup-menu.h \
- prop.c \
- timeutil.c \
- timeutil.h \
- view-utils.h \
- view-utils.c \
- views.h \
- views.c
-
-LINK_FLAGS = \
- $(GNOME_LIBDIR) \
- $(GNOMEUI_LIBS) \
- $(INTLLIBS) versit/libversit.a
-
-
-#gncal_LDADD = $(LINK_FLAGS)
-#objedit_LDADD = $(LINK_FLAGS)
-
-gnomecal_LDADD = $(LINK_FLAGS)
-
-EXTRA_DIST = \
- gncal.desktop \
- topic.dat \
- gnome-cal.html \
- bell.xpm \
- recur.xpm
-
-
-Productivitydir = $(datadir)/apps/Productivity
-
-Productivity_DATA = gncal.desktop
-
-install-data-local:
- $(mkinstalldirs) $(help_base)/C
- $(INSTALL_DATA) $(srcdir)/topic.dat $(help_base)/C/topic.dat
- $(INSTALL_DATA) $(srcdir)/gnome-cal.html $(help_base)/C/gnome-cal.html
- cd $(help_base)/C; ln -sf gnome-cal.html index.html
diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c
deleted file mode 100644
index 280d4125e3..0000000000
--- a/calendar/gui/alarm-notify/alarm.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Alarm handling for the GNOME Calendar.
- *
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#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 */
-int alarm_pipes [2];
-
-/* The list of pending alarms */
-static GList *alarms;
-
-static void *head_alarm;
-
-typedef struct {
- time_t activation_time;
- AlarmFunction fn;
- void *closure;
-} AlarmRecord;
-
-/*
- * SIGALRM handler. Notifies the callback about the alarm
- */
-static void
-alarm_activate ()
-{
- char c = 0;
-
- write (alarm_pipes [1], &c, 1);
-}
-
-static void
-alarm_ready (void *closure, int fd, GdkInputCondition cond)
-{
- AlarmRecord *ar = head_alarm;
- char c;
-
- if (read (alarm_pipes [0], &c, 1) != 1)
- return;
-
- if (ar == NULL){
- g_warning ("Empty events. This should not happen\n");
- return;
- }
- (*ar->fn)(ar->activation_time, ar->closure);
- alarms = g_list_remove (alarms, head_alarm);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- g_free (ar);
-}
-
-static int
-alarm_compare_by_time (gconstpointer a, gconstpointer b)
-{
- const AlarmRecord *ara = a;
- const AlarmRecord *arb = b;
- time_t diff;
-
- diff = ara->activation_time - arb->activation_time;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-void
-alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
-{
- time_t now = time (NULL);
- AlarmRecord *ar;
-
- /* If it already expired, do not add it */
- if (alarm_time < now)
- return;
-
- ar = g_new0 (AlarmRecord, 1);
- ar->activation_time = alarm_time;
- ar->fn = fn;
- ar->closure = closure;
-
- alarms = g_list_insert_sorted (alarms, ar, alarm_compare_by_time);
-
- /* If first alarm is not the previous first alarm, reschedule SIGALRM */
- if (head_alarm != alarms->data){
- struct itimerval itimer;
- int v;
-
- /* Set the timer to disable upon activation */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = alarm_time - now;
- itimer.it_value.tv_usec = 0;
- v = setitimer (ITIMER_REAL, &itimer, NULL);
- head_alarm = alarms->data;
- }
-}
-
-int
-alarm_kill (void *closure_key)
-{
- GList *p;
-
- for (p = alarms; p; p = p->next){
- AlarmRecord *ar = p->data;
-
- if (ar->closure == closure_key){
- alarms = g_list_remove (alarms, p->data);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- return 1;
- }
- }
- return 0;
-}
-
-void
-alarm_init (void)
-{
- struct sigaction sa;
- int flags;
-
- pipe (alarm_pipes);
-
- /* set non blocking mode */
- 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, 0);
-
- /* Setup the signal handler */
- sa.sa_handler = alarm_activate;
- 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 d37ff0c1bf..0000000000
--- a/calendar/gui/alarm-notify/alarm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef ALARM_H
-#define ALARM_H
-
-#include <time.h>
-
-typedef void (*AlarmFunction)(time_t time, void *closuse);
-
-void alarm_init (void);
-void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
-int alarm_kill (void *closure);
-
-#endif
diff --git a/calendar/gui/alarm.c b/calendar/gui/alarm.c
deleted file mode 100644
index 280d4125e3..0000000000
--- a/calendar/gui/alarm.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Alarm handling for the GNOME Calendar.
- *
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#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 */
-int alarm_pipes [2];
-
-/* The list of pending alarms */
-static GList *alarms;
-
-static void *head_alarm;
-
-typedef struct {
- time_t activation_time;
- AlarmFunction fn;
- void *closure;
-} AlarmRecord;
-
-/*
- * SIGALRM handler. Notifies the callback about the alarm
- */
-static void
-alarm_activate ()
-{
- char c = 0;
-
- write (alarm_pipes [1], &c, 1);
-}
-
-static void
-alarm_ready (void *closure, int fd, GdkInputCondition cond)
-{
- AlarmRecord *ar = head_alarm;
- char c;
-
- if (read (alarm_pipes [0], &c, 1) != 1)
- return;
-
- if (ar == NULL){
- g_warning ("Empty events. This should not happen\n");
- return;
- }
- (*ar->fn)(ar->activation_time, ar->closure);
- alarms = g_list_remove (alarms, head_alarm);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- g_free (ar);
-}
-
-static int
-alarm_compare_by_time (gconstpointer a, gconstpointer b)
-{
- const AlarmRecord *ara = a;
- const AlarmRecord *arb = b;
- time_t diff;
-
- diff = ara->activation_time - arb->activation_time;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-void
-alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
-{
- time_t now = time (NULL);
- AlarmRecord *ar;
-
- /* If it already expired, do not add it */
- if (alarm_time < now)
- return;
-
- ar = g_new0 (AlarmRecord, 1);
- ar->activation_time = alarm_time;
- ar->fn = fn;
- ar->closure = closure;
-
- alarms = g_list_insert_sorted (alarms, ar, alarm_compare_by_time);
-
- /* If first alarm is not the previous first alarm, reschedule SIGALRM */
- if (head_alarm != alarms->data){
- struct itimerval itimer;
- int v;
-
- /* Set the timer to disable upon activation */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = alarm_time - now;
- itimer.it_value.tv_usec = 0;
- v = setitimer (ITIMER_REAL, &itimer, NULL);
- head_alarm = alarms->data;
- }
-}
-
-int
-alarm_kill (void *closure_key)
-{
- GList *p;
-
- for (p = alarms; p; p = p->next){
- AlarmRecord *ar = p->data;
-
- if (ar->closure == closure_key){
- alarms = g_list_remove (alarms, p->data);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- return 1;
- }
- }
- return 0;
-}
-
-void
-alarm_init (void)
-{
- struct sigaction sa;
- int flags;
-
- pipe (alarm_pipes);
-
- /* set non blocking mode */
- 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, 0);
-
- /* Setup the signal handler */
- sa.sa_handler = alarm_activate;
- 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 d37ff0c1bf..0000000000
--- a/calendar/gui/alarm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef ALARM_H
-#define ALARM_H
-
-#include <time.h>
-
-typedef void (*AlarmFunction)(time_t time, void *closuse);
-
-void alarm_init (void);
-void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
-int alarm_kill (void *closure);
-
-#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/cal_struct.h b/calendar/gui/cal_struct.h
deleted file mode 100644
index 411036c7aa..0000000000
--- a/calendar/gui/cal_struct.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#define MAX_SZ 30
-
-enum RepeatType {
- Single,
- Days,
- Months,
- WeekDays,
- MonthDays
-};
-
-
-struct actionitem {
- char date[MAX_SZ];
- int time; /* Minutes past midnight */
-};
-
-struct event {
- struct actionitem start;
- struct actionitem end;
-
- enum RepeatType repeat;
- int repeatcount;
- char description[MAX_SZ];
- char subtype[MAX_SZ];
- GList *properties;
-};
-
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
deleted file mode 100644
index a76d95758f..0000000000
--- a/calendar/gui/calendar.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Calendar manager object
- *
- * This keeps track of a given calendar. Eventually this will abtract everything
- * related to getting calendars/saving calendars locally or to a remote Calendar Service
- *
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- *
- */
-
-#include <config.h>
-
-#include "alarm.h"
-#include "calendar.h"
-#include "timeutil.h"
-#include "versit/vcc.h"
-
-/* Our day range */
-time_t calendar_day_begin, calendar_day_end;
-
-Calendar *
-calendar_new (char *title)
-{
- Calendar *cal;
-
- cal = g_new0 (Calendar, 1);
- cal->title = g_strdup (title);
-
- return cal;
-}
-
-static void
-try_add (iCalObject *ico, CalendarAlarm *alarm, time_t start, time_t end)
-{
- alarm->trigger = start-alarm->offset;
-
- if (alarm->trigger < calendar_day_begin)
- return;
- if (alarm->trigger > calendar_day_end)
- return;
- alarm_add (alarm->trigger, calendar_notify, ico);
-}
-
-static int
-add_alarm (iCalObject *obj, time_t start, time_t end, void *closure)
-{
- if (obj->aalarm.enabled)
- try_add (obj, &obj->aalarm, start, end);
- if (obj->dalarm.enabled)
- try_add (obj, &obj->dalarm, start, end);
- if (obj->palarm.enabled)
- try_add (obj,&obj->palarm, start, end);
- if (obj->malarm.enabled)
- try_add (obj, &obj->malarm, start, end);
-
- return TRUE;
-}
-
-#define max(a,b) ((a > b) ? a : b)
-
-void
-ical_object_try_alarms (iCalObject *obj)
-{
- int ao, po, od, mo;
- int max_o;
-
- ao = alarm_compute_offset (&obj->aalarm);
- po = alarm_compute_offset (&obj->palarm);
- od = alarm_compute_offset (&obj->dalarm);
- mo = alarm_compute_offset (&obj->malarm);
-
- max_o = max (ao, max (po, max (od, mo)));
- if (max_o == -1)
- return;
-
- ical_object_generate_events (obj, calendar_day_begin, calendar_day_end + max_o, add_alarm, obj);
-}
-
-void
-calendar_add_object (Calendar *cal, iCalObject *obj)
-{
- obj->new = 0;
- switch (obj->type){
- case ICAL_EVENT:
- cal->events = g_list_prepend (cal->events, obj);
- ical_object_try_alarms (obj);
-#ifdef DEBUGGING_MAIL_ALARM
- obj->malarm.trigger = 0;
- calendar_notify (0, obj);
-#endif
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_prepend (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_prepend (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- if (!obj->uid){
- char buffer [80];
-
- snprintf (buffer, sizeof (buffer), "GnomeCalendar-%ld\n", time (NULL));
- }
-
- cal->modified = TRUE;
-
- /* FIXME: do we have to set the last_mod field in the object? */
-}
-
-void
-calendar_remove_object (Calendar *cal, iCalObject *obj)
-{
- switch (obj->type){
- case ICAL_EVENT:
- cal->events = g_list_remove (cal->events, obj);
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_remove (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_remove (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- cal->modified = TRUE;
-}
-
-void
-calendar_destroy (Calendar *cal)
-{
- g_list_foreach (cal->events, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->events);
-
- g_list_foreach (cal->todo, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->todo);
-
- g_list_foreach (cal->journal, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->journal);
-
- if (cal->title)
- g_free (cal->title);
- if (cal->filename)
- g_free (cal->filename);
-
- g_free (cal);
-}
-
-char *
-ice (time_t t)
-{
- static char buffer [100];
- struct tm *tm;
-
- tm = localtime (&t);
- sprintf (buffer, "%d/%d/%d", tm->tm_mday, tm->tm_mon, tm->tm_year);
- return buffer;
-}
-
-void
-calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
-{
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- ical_object_generate_events (object, start, end, cb, closure);
- }
-}
-
-void
-calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure)
-{
- calendar_iterate_on_objects (cal->events, start, end, cb, closure);
-}
-
-GList *
-calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func)
-{
- GList *new_events = 0;
-
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- if ((start <= object->dtstart) && (object->dtend <= end)){
- if (sort_func)
- new_events = g_list_insert_sorted (new_events, object, sort_func);
- else
- new_events = g_list_prepend (new_events, object);
- }
- }
-
- return new_events;
-}
-
-GList *
-calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->todo, start, end, sort_func);
-}
-
-GList *
-calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->journal, start, end, sort_func);
-}
-
-gint
-calendar_compare_by_dtstart (gpointer a, gpointer b)
-{
- iCalObject *obj1, *obj2;
- time_t diff;
-
- obj1 = a;
- obj2 = b;
-
- diff = obj1->dtstart - obj2->dtstart;
-
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-#define str_val(obj) (char *) vObjectUStringZValue (obj)
-
-/* Loads our calendar contents from a vObject */
-void
-calendar_load_from_vobject (Calendar *cal, VObject *vcal)
-{
- VObjectIterator i;
-
- initPropIterator (&i, vcal);
-
- while (moreIteration (&i)){
- VObject *this = nextVObject (&i);
- iCalObject *ical;
- const char *object_name = vObjectName (this);
-
- if (strcmp (object_name, VCDCreatedProp) == 0){
- cal->created = time_from_isodate (str_val (this));
- continue;
- }
-
- 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);
-
- if (ical)
- calendar_add_object (cal, ical);
- }
-}
-
-/* Loads a calendar from a file */
-char *
-calendar_load (Calendar *cal, char *fname)
-{
- VObject *vcal;
- time_t calendar_today;
-
- if (cal->filename){
- g_warning ("Calendar load called again\n");
- return "Internal error";
- }
-
- cal->filename = g_strdup (fname);
- vcal = Parse_MIME_FromFileName (fname);
- if (!vcal)
- return "Could not load the calendar";
-
- calendar_today = time (NULL);
- calendar_day_begin = time_start_of_day (calendar_today);
- calendar_day_end = time_end_of_day (calendar_today);
-
- calendar_load_from_vobject (cal, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
- return NULL;
-}
-
-void
-calendar_save (Calendar *cal, char *fname)
-{
- VObject *vcal;
- GList *l;
- time_t now = time (NULL);
-
- if (fname == NULL)
- fname = cal->filename;
-
- /* WE call localtime for the side effect of setting tzname */
- localtime (&now);
-
- vcal = newVObject (VCCalProp);
- addPropValue (vcal, VCProdIdProp, "-//GNOME//NONSGML GnomeCalendar//EN");
- addPropValue (vcal, VCTimeZoneProp, tzname [0]);
- addPropValue (vcal, VCVersionProp, VERSION);
- cal->temp = vcal;
-
- /* Events */
-
- for (l = cal->events; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- /* To-do entries */
-
- for (l = cal->todo; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- writeVObjectToFile (fname, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
-}
-
-static gint
-calendar_object_compare_by_start (gconstpointer a, gconstpointer b)
-{
- const CalendarObject *ca = a;
- const CalendarObject *cb = b;
- time_t diff;
-
- diff = ca->ev_start - cb->ev_start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
-{
- CalendarObject *co;
- GList **l = c;
-
- co = g_new (CalendarObject, 1);
- co->ev_start = start;
- co->ev_end = end;
- co->ico = obj;
- *l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start);
-
- return 1;
-}
-
-void
-calendar_destroy_event_list (GList *l)
-{
- GList *p;
-
- for (p = l; p; p = p->next)
- g_free (p->data);
- g_list_free (l);
-}
-
-GList *
-calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
-{
- GList *l = 0;
-
- calendar_iterate (cal, start, end, assemble_event_list, &l);
- return l;
-}
-
-void
-calendar_object_changed (Calendar *cal, iCalObject *obj, int flags)
-{
- if (!(flags & CHANGE_DATES))
- return;
-
- /* Remove any alarms on the alarm list for this object */
- while (alarm_kill (obj))
- ;
- ical_object_try_alarms (obj);
-}
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
deleted file mode 100644
index 0a0e949d92..0000000000
--- a/calendar/gui/calendar.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef CALENDAR_H
-#define CALENDAR_H
-
-#include "calobj.h"
-
-BEGIN_GNOME_DECLS
-
-typedef struct {
- /* This calendar's title */
- char *title;
-
- /* backing store for this calendar object */
- char *filename;
-
- /* The list of events; todo's and journal entries */
- GList *events;
- GList *todo;
- GList *journal;
-
- /* Time at which the calendar was created */
- time_t created;
-
- /* If the calendar was last modified */
- int modified;
- void *temp;
-} Calendar;
-
-/* This is only used by the calendar_get_events_in_range routine to get
- * a list of objects that recur on a specific date
- */
-typedef struct {
- time_t ev_start;
- time_t ev_end;
- iCalObject *ico;
-} CalendarObject;
-
-Calendar *calendar_new (char *title);
-char *calendar_load (Calendar *cal, char *fname);
-void calendar_save (Calendar *cal, char *fname);
-void calendar_add_object (Calendar *cal, iCalObject *obj);
-void calendar_remove_object (Calendar *cal, iCalObject *obj);
-void calendar_destroy (Calendar *cal);
-GList *calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-gint calendar_compare_by_dtstart (gpointer a, gpointer b);
-
-void calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure);
-void calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure);
-
-/* Note this routine returns a GList with CalendarObjects */
-GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
-
-/* Informs the calendar that obj information has changed */
-void calendar_object_changed (Calendar *cal, iCalObject *obj, int flags);
-
-/* Destroy the above list with this method */
-void calendar_destroy_event_list (GList *l);
-
-void calendar_notify (time_t, void *data);
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
deleted file mode 100644
index 3189b11300..0000000000
--- a/calendar/gui/eventedit.c
+++ /dev/null
@@ -1,1479 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors: Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <string.h>
-#include "calendar.h"
-#include "eventedit.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-static void event_editor_class_init (EventEditorClass *class);
-static void event_editor_init (EventEditor *ee);
-static void event_editor_destroy (GtkObject *object);
-
-/* Note: do not i18n these strings, they are part of the vCalendar protocol */
-static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
-
-static GnomeDialogClass *parent_class;
-
-struct numbered_item {
- char *text;
- int num;
-};
-
-
-guint
-event_editor_get_type (void)
-{
- static guint event_editor_type = 0;
-
- if(!event_editor_type) {
- GtkTypeInfo event_editor_info = {
- "EventEditor",
- sizeof(EventEditor),
- sizeof(EventEditorClass),
- (GtkClassInitFunc) event_editor_class_init,
- (GtkObjectInitFunc) event_editor_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
- };
- event_editor_type = gtk_type_unique (gnome_dialog_get_type (), &event_editor_info);
- }
- return event_editor_type;
-}
-
-static void
-event_editor_class_init (EventEditorClass *class)
-{
- GtkObjectClass *object_class;
-
- parent_class = gtk_type_class (gnome_dialog_get_type ());
- object_class = (GtkObjectClass*) class;
- object_class->destroy = event_editor_destroy;
-}
-
-GtkWidget *
-adjust (GtkWidget *w, gfloat x, gfloat y, gfloat xs, gfloat ys)
-{
- GtkWidget *a = gtk_alignment_new (x, y, xs, ys);
-
- gtk_container_add (GTK_CONTAINER (a), w);
- return a;
-}
-
-static 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;
-}
-
-/*
- * Checks if the day range occupies all the day, and if so, check the
- * box accordingly
- */
-static void
-ee_check_all_day (EventEditor *ee)
-{
- time_t ev_start, ev_end;
-
- ev_start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ev_end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (get_time_t_hour (ev_start) <= day_begin && get_time_t_hour (ev_end) >= day_end)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 1);
- else
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 0);
-}
-
-/*
- * Callback: checks that the dates are start < end
- */
-static void
-check_dates (GnomeDateEdit *gde, EventEditor *ee)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start > end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->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;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->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;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-}
-
-/*
- * 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)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start >= end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->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;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->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;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-
- /* Check whether the event spans the whole day */
-
- ee_check_all_day (ee);
-}
-
-/*
- * Callback: all day event box clicked
- */
-static void
-set_all_day (GtkToggleButton *toggle, EventEditor *ee)
-{
- struct tm *tm;
- time_t start_t;
-
- start_t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- tm = localtime (&start_t);
- tm->tm_hour = day_begin;
- tm->tm_min = 0;
- tm->tm_sec = 0;
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (tm));
-
- if (toggle->active)
- tm->tm_hour = day_end;
- else
- tm->tm_hour++;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (tm));
-}
-
-static GtkWidget *
-event_editor_setup_time_frame (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *start_time, *end_time;
- GtkTable *t;
-
- frame = gtk_frame_new (_("Time"));
- t = GTK_TABLE (ee->general_time_table = gtk_table_new (1, 1, 0));
- gtk_container_border_width (GTK_CONTAINER (t), 4);
- gtk_table_set_row_spacings (t, 4);
- gtk_table_set_col_spacings (t, 4);
- gtk_container_add (GTK_CONTAINER (frame), ee->general_time_table);
-
- /* 1. Start time */
- if (ee->ical->dtstart == 0){
- ee->ical->dtstart = time (NULL);
- ee->ical->dtend = time_add_minutes (ee->ical->dtstart, 30);
- }
- ee->start_time = start_time = gnome_date_edit_new (ee->ical->dtstart, TRUE, !am_pm_flag);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (start_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (start_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("Start time:")), 1, 2, 1, 2,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, start_time, 2, 3, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 2. End time */
- ee->end_time = end_time = gnome_date_edit_new (ee->ical->dtend, TRUE, !am_pm_flag);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) end_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (end_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (end_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("End time:")), 1, 2, 2, 3,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, end_time, 2, 3, 2, 3,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 3. All day checkbox */
- ee->general_allday = gtk_check_button_new_with_label (_("All day event"));
- gtk_signal_connect (GTK_OBJECT (ee->general_allday), "toggled",
- GTK_SIGNAL_FUNC (set_all_day), ee);
- gtk_table_attach (t, ee->general_allday, 3, 4, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 4, 0);
- ee_check_all_day (ee);
-
- return frame;
-}
-
-static GtkWidget *
-timesel_new (void)
-{
- GtkWidget *menu, *option_menu;
- char *items [] = { N_("Minutes"), N_("Hours"), N_("Days") };
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- for (i = 0; i < 3; i++){
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items [i]));
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- return option_menu;
-}
-
-/*
- * Set the sensitive state depending on whether the alarm enabled flag.
- */
-static void
-ee_alarm_setting (CalendarAlarm *alarm, int sensitive)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_count), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_timesel), sensitive);
-
- if (alarm->type == ALARM_PROGRAM || alarm->type == ALARM_MAIL){
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_entry), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_label), sensitive);
- }
-}
-
-static void
-alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm)
-{
- ee_alarm_setting (alarm, toggle->active);
-}
-
-#define FXS (GTK_FILL | GTK_EXPAND | GTK_SHRINK)
-#define FS (GTK_FILL | GTK_SHRINK)
-
-static void
-ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y)
-{
- GtkWidget *entry;
-
- alarm->w_enabled = gtk_check_button_new_with_label (str);
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (alarm_toggle), alarm);
- gtk_table_attach (table, alarm->w_enabled, 0, 1, y, y+1, FS, FS, 0, 0);
-
- alarm->w_count = make_spin_button (alarm->count, 0, 10000);
- gtk_table_attach (table, alarm->w_count, 1, 2, y, y+1, FS, FS, 0, 0);
-
- alarm->w_timesel = timesel_new ();
- gtk_option_menu_set_history (GTK_OPTION_MENU (alarm->w_timesel), alarm->units);
- gtk_table_attach (table, alarm->w_timesel, 2, 3, y, y+1, FS, FS, 0, 0);
-
- switch (type){
- case ALARM_MAIL:
- alarm->w_label = gtk_label_new (_("Mail to:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gtk_entry_new ();
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : "");
- break;
-
- case ALARM_PROGRAM:
- alarm->w_label = gtk_label_new (_("Run program:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gnome_file_entry_new ("alarm-program", _("Select program to run at alarm time"));
- entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry));
- gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : "");
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- break;
-
- default:
- break;
- }
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled), alarm->enabled);
- ee_alarm_setting (alarm, alarm->enabled);
-}
-
-static GtkWidget *
-ee_alarm_widgets (EventEditor *ee)
-{
- GtkWidget *table, *mailto, *mailte, *l;
-
- l = gtk_frame_new (_("Alarms"));
-
- table = gtk_table_new (1, 1, 0);
- gtk_container_border_width (GTK_CONTAINER (table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 4);
- gtk_container_add (GTK_CONTAINER (l), table);
-
- mailto = gtk_label_new (_("Mail to:"));
- mailte = gtk_entry_new ();
-
- ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1);
- ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2);
- ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3);
- ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4);
-
- return l;
-}
-
-static GtkWidget *
-ee_classification_widgets (EventEditor *ee)
-{
- GtkWidget *rpub, *rpriv, *rconf;
- GtkWidget *frame, *hbox;
-
- frame = gtk_frame_new (_("Classification"));
-
- hbox = gtk_hbox_new (TRUE, 0);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- rpub = gtk_radio_button_new_with_label (NULL, _("Public"));
- rpriv = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Private"));
- rconf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential"));
-
- gtk_box_pack_start (GTK_BOX (hbox), rpub, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rpriv, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rconf, FALSE, FALSE, 0);
-
- if (strcmp (ee->ical->class, class_names[0]))
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpub), TRUE);
- else if (strcmp (ee->ical->class, class_names[1]))
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpriv), TRUE);
- else if (strcmp (ee->ical->class, class_names[2]))
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rconf), TRUE);
-
- ee->general_radios = rpub;
-
- return frame;
-}
-
-/*
- * Retrieves the information from the CalendarAlarm widgets and stores them
- * on the CalendarAlarm generic values
- */
-void
-ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type)
-{
- GtkWidget *item;
- GtkMenu *menu;
- GList *child;
- int idx;
-
- if (alarm->data){
- g_free (alarm->data);
- alarm->data = 0;
- }
-
- alarm->enabled = GTK_TOGGLE_BUTTON (alarm->w_enabled)->active;
-
- if (!alarm->enabled)
- return;
-
- if (type == ALARM_PROGRAM)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (alarm->w_entry))));
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (alarm->w_entry)));
-
- /* Find out the index */
- menu = GTK_MENU (GTK_OPTION_MENU (alarm->w_timesel)->menu);
-
- item = gtk_menu_get_active (menu);
-
- for (idx = 0, child = GTK_MENU_SHELL (menu)->children; child->data != item; child = child->next)
- idx++;
-
- alarm->units = idx;
- alarm->count = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alarm->w_count));
-}
-
-static void
-ee_store_general_values_to_ical (EventEditor *ee)
-{
- GtkRadioButton *radio = GTK_RADIO_BUTTON (ee->general_radios);
- iCalObject *ical = ee->ical;
- GSList *list = radio->group;
- int idx;
- time_t now;
-
- now = time (NULL);
- ical->dtstart = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ical->dtend = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (ical->summary)
- g_free (ical->summary);
-
- ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
-
- ee_store_alarm (&ical->dalarm, ALARM_DISPLAY);
- ee_store_alarm (&ical->aalarm, ALARM_AUDIO);
- ee_store_alarm (&ical->palarm, ALARM_PROGRAM);
- ee_store_alarm (&ical->malarm, ALARM_MAIL);
-
- for (idx = 0; list; list = list->next) {
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
- idx++;
- }
- g_free (ical->class);
- ical->class = g_strdup (class_names [idx]);
-}
-
-static int
-option_menu_active_number (GtkWidget *omenu)
-{
- GtkWidget *menu;
- GtkWidget *item;
- struct numbered_item *ni;
-
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
- item = gtk_menu_get_active (GTK_MENU (menu));
-
- ni = gtk_object_get_user_data (GTK_OBJECT (item));
-
- return ni->num;
-}
-
-static int
-ee_store_recur_rule_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- int i, j;
- GSList *list;
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_rr_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_rr_group) - i - 1; /* buttons are stored in reverse order of insertion */
-
- /* None selected, no rule to be stored */
- if (i == 0)
- return 0;
-
- if (!ical->recur)
- ical->recur = g_new0 (Recurrence, 1);
-
- switch (i) {
- case 1:
- /* Daily */
- ical->recur->type = RECUR_DAILY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_day_period));
- break;
-
- case 2:
- /* Weekly */
- ical->recur->type = RECUR_WEEKLY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_week_period));
- ical->recur->weekday = 0;
-
- for (j = 0; j < 7; j++)
- if (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days[j])->active) {
- if (j == 6)
- ical->recur->weekday |= 1 << 0; /* sunday is at bit 0 */
- else
- ical->recur->weekday |= 1 << (j + 1);
- }
-
- break;
-
- case 3:
- /* Monthly */
-
- if (GTK_WIDGET_SENSITIVE (ee->recur_rr_month_date)) {
- /* by day */
-
- ical->recur->type = RECUR_MONTHLY_BY_DAY;
- ical->recur->u.month_day =
- gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_month_date));
- } else {
- /* by position */
-
- ical->recur->type = RECUR_MONTHLY_BY_POS;
-
- ical->recur->u.month_pos = option_menu_active_number (ee->recur_rr_month_day);
- ical->recur->u.month_day = option_menu_active_number (ee->recur_rr_month_weekday);
- }
-
-
- break;
-
- case 4:
- /* Yearly */
- ical->recur->type = RECUR_YEARLY_BY_DAY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_year_period));
- /* FIXME: need to specify anything else? I am assuming the code will look at the dtstart
- * to figure out when to recur. - Federico
- */
- break;
-
- default:
- g_assert_not_reached ();
- }
- return 1;
-}
-
-static void
-ee_store_recur_end_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GSList *list;
- int i;
-
- /* Ending date of recurrence */
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_ed_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_ed_group) - i - 1; /* the list is stored in reverse order of insertion */
-
- switch (i) {
- case 0:
- /* repeat forever */
- ical->recur->_enddate = 0;
- ical->recur->enddate = 0;
- ical->recur->duration = 0;
- break;
-
- case 1:
- /* end date */
- ical->recur->_enddate = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ed_end_on));
- ical->recur->enddate = ical->recur->_enddate;
- ical->recur->duration = 0;
- break;
-
- case 2:
- /* end after n occurrences */
- ical->recur->duration = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_ed_end_after));
- ical_object_compute_end (ical);
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static void
-free_exdate (iCalObject *ical)
-{
- GList *list;
-
- if (!ical->exdate)
- return;
-
- for (list = ical->exdate; list; list = list->next)
- g_free (list->data);
-
- g_list_free (ical->exdate);
- ical->exdate = NULL;
-}
-
-static void
-ee_store_recur_exceptions_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GtkCList *clist;
- int i;
- time_t *t;
-
- ical = ee->ical;
- clist = GTK_CLIST (ee->recur_ex_clist);
-
- free_exdate (ical);
-
- for (i = 0; i < clist->rows; i++) {
- t = gtk_clist_get_row_data (clist, i);
- ical->exdate = g_list_prepend (ical->exdate, t);
- }
-}
-
-static void
-ee_store_recur_values_to_ical (EventEditor *ee)
-{
- if (ee_store_recur_rule_to_ical (ee)){
- ee_store_recur_exceptions_to_ical (ee);
- ee_store_recur_end_to_ical (ee);
- } else if (ee->ical->recur) {
- g_free (ee->ical->recur);
- ee->ical->recur = NULL;
- if (ee->ical->exdate){
- GList *l = ee->ical->exdate;
-
- for (; l; l = l->next)
- g_free (l->data);
- g_list_free (l);
- }
- }
-}
-
-/*
- * Retrieves all of the information from the different widgets and updates
- * the iCalObject accordingly.
- */
-static void
-ee_store_dlg_values_to_ical (EventEditor *ee)
-{
- time_t now;
-
- ee_store_general_values_to_ical (ee);
- ee_store_recur_values_to_ical (ee);
-
- now = time (NULL);
-
- /* FIXME: This is not entirely correct; we should check if the values actually changed */
- ee->ical->last_mod = now;
-
- if (ee->ical->new)
- ee->ical->created = now;
-}
-
-static void
-ee_ok (GtkWidget *widget, EventEditor *ee)
-{
- ee_store_dlg_values_to_ical (ee);
-
- if (ee->ical->new)
- gnome_calendar_add_object (ee->gnome_cal, ee->ical);
- else
- gnome_calendar_object_changed (ee->gnome_cal, ee->ical, CHANGE_ALL);
-
- ee->ical->new = 0;
-}
-
-static void
-ee_cancel (GtkWidget *widget, EventEditor *ee)
-{
- if (ee->ical->new) {
- ical_object_destroy (ee->ical);
- ee->ical = NULL;
- }
-
-}
-
-static void
-ee_create_buttons (EventEditor *ee)
-{
- gnome_dialog_append_buttons(GNOME_DIALOG(ee),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL, NULL);
-
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 0, GTK_SIGNAL_FUNC(ee_ok), ee);
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 1, GTK_SIGNAL_FUNC(ee_cancel), ee);
-
- return;
-}
-
-/*
- * Load the contents in a delayed fashion, as the GtkText widget needs it
- */
-static void
-ee_fill_summary (GtkWidget *widget, EventEditor *ee)
-{
- int pos = 0;
-
- gtk_editable_insert_text (GTK_EDITABLE (ee->general_summary), ee->ical->summary,
- strlen (ee->ical->summary), &pos);
- gtk_text_thaw (GTK_TEXT (ee->general_summary));
-}
-
-enum {
- OWNER_LINE,
- DESC_LINE,
- SUMMARY_LINE,
- TIME_LINE,
- ALARM_LINE,
- CLASS_LINE
-};
-
-/* Create/setup the general page */
-static void
-ee_init_general_page (EventEditor *ee)
-{
- GtkWidget *l;
- GtkWidget *hbox;
-
- ee->general_table = gtk_table_new (1, 1, FALSE);
- gtk_container_border_width (GTK_CONTAINER (ee->general_table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), GTK_WIDGET (ee->general_table),
- gtk_label_new (_("General")));
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_table_attach (GTK_TABLE (ee->general_table), hbox,
- 0, 1, OWNER_LINE, OWNER_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 4);
-
- l = gtk_label_new (_("Owner:"));
- gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
-
- ee->general_owner = gtk_label_new (ee->ical->organizer ? ee->ical->organizer : _("?"));
- gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4);
-
- l = gtk_label_new (_("Summary:"));
- gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, DESC_LINE, DESC_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- ee->general_summary = gtk_text_new (NULL, NULL);
- gtk_text_freeze (GTK_TEXT (ee->general_summary));
- gtk_signal_connect (GTK_OBJECT (ee->general_summary), "realize",
- GTK_SIGNAL_FUNC (ee_fill_summary), ee);
- gtk_widget_set_usize (ee->general_summary, 0, 60);
- gtk_text_set_editable (GTK_TEXT (ee->general_summary), 1);
- gtk_table_attach (GTK_TABLE (ee->general_table), ee->general_summary,
- 0, 1, SUMMARY_LINE, SUMMARY_LINE+1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_alarm_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, ALARM_LINE, ALARM_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = event_editor_setup_time_frame (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, TIME_LINE, TIME_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_classification_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, CLASS_LINE, CLASS_LINE + 1,
- GTK_EXPAND | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-}
-
-static void
-ee_init_summary_page (EventEditor *ee)
-{
-}
-
-struct {
- char *name;
-} recurrence_types [] = {
- { N_("None") },
- { N_("Daily") },
- { N_("Weekly") },
- { N_("Monthly") },
- { N_("Yearly") },
- { 0 }
-};
-
-static void
-recurrence_toggled (GtkRadioButton *radio, EventEditor *ee)
-{
- GSList *list = ee->recur_rr_group;
- int which;
-
- if (!GTK_TOGGLE_BUTTON (radio)->active)
- return;
-
- for (which = 0; list; list = list->next, which++) {
- if (list->data == radio) {
- gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_rr_notebook), 4 - which);
- return;
- }
- }
-}
-
-static struct numbered_item weekday_positions[] = {
- { N_("1st"), 1 },
- { N_("2nd"), 2 },
- { N_("3rd"), 3 },
- { N_("4th"), 4 },
- { N_("5th"), 5 },
- { 0 }
-};
-
-static struct numbered_item weekday_names[] = {
- { N_("Monday"), 1 },
- { N_("Tuesday"), 2 },
- { N_("Wednesday"), 3 },
- { N_("Thursday"), 4 },
- { N_("Friday"), 5 },
- { N_("Saturday"), 6 },
- { N_("Sunday"), 0 }, /* on the spec, Sunday is zero */
- { 0 }
-};
-
-static GtkWidget *
-make_numbered_menu (struct numbered_item *items, int sel)
-{
- GtkWidget *option_menu, *menu;
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
-
- for (i = 0; items[i].text; i++) {
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_object_set_user_data (GTK_OBJECT (item), &items[i]);
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), sel);
-
- return option_menu;
-}
-
-static void
-month_sensitize (EventEditor *ee, int state)
-{
- gtk_widget_set_sensitive (ee->recur_rr_month_date, state);
- gtk_widget_set_sensitive (ee->recur_rr_month_date_label, state);
-
- gtk_widget_set_sensitive (ee->recur_rr_month_day, !state);
- gtk_widget_set_sensitive (ee->recur_rr_month_weekday, !state);
-}
-
-static void
-recur_month_enable_date (GtkToggleButton *button, EventEditor *ee)
-{
- month_sensitize (ee, button->active);
-}
-
-static void
-desensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), !toggle->active);
-}
-
-static void
-ee_rp_init_rule (EventEditor *ee)
-{
- static char *day_names [] = { N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat"), N_("Sun") };
- GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *b, *week_hbox, *week_day, *w;
- GtkWidget *none, *daily, *weekly, *monthly, *yearly;
- GtkNotebook *notebook;
- GSList *group;
- int i, page, day_period, week_period, month_period, year_period;
- int week_vector, default_day, def_pos, def_off;
- struct tm *tm;
-
- tm = localtime (&ee->ical->dtstart);
-
- f = gtk_frame_new (_("Recurrence rule"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (f), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), gtk_vseparator_new (), FALSE, FALSE, 0);
-
- ee->recur_rr_notebook = gtk_notebook_new ();
- notebook = GTK_NOTEBOOK (ee->recur_rr_notebook);
- gtk_box_pack_start (GTK_BOX (hbox), ee->recur_rr_notebook, TRUE, TRUE, 0);
-
- day_period = 1;
- week_period = 1;
- month_period = 1;
- year_period = 1;
-
- /* Default to today */
-
- week_vector = 1 << tm->tm_wday;
- default_day = tm->tm_mday;
- def_pos = 0;
- def_off = 0;
-
- /* Determine which should be the default selection */
-
- page = 0;
- if (ee->ical->recur) {
- enum RecurType type = ee->ical->recur->type;
- int interval = ee->ical->recur->interval;
-
- switch (type) {
- case RECUR_DAILY:
- page = 1;
- day_period = interval;
- break;
-
- case RECUR_WEEKLY:
- page = 2;
- week_period = interval;
- week_vector = ee->ical->recur->weekday;
- break;
-
- case RECUR_MONTHLY_BY_POS:
- page = 3;
- month_period = interval;
- def_pos = ee->ical->recur->u.month_pos;
- default_day = ee->ical->recur->u.month_day;
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- page = 3;
- month_period = interval;
- default_day = ee->ical->recur->u.month_day;
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- page = 4;
- year_period = interval;
- break;
-
- case RECUR_YEARLY_BY_DAY:
- page = 4;
- year_period = interval;
- break;
- }
- } else
- page = 0;
-
- /* The recurrency selector */
-
- for (i = 0, group = NULL; recurrence_types [i].name; i++) {
- r = gtk_radio_button_new_with_label (group, _(recurrence_types [i].name));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (r));
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == page);
- gtk_signal_connect (GTK_OBJECT (r), "toggled", GTK_SIGNAL_FUNC (recurrence_toggled), ee);
- gtk_box_pack_start (GTK_BOX (vbox), r, FALSE, FALSE, 0);
-
- if (i == 0)
- gtk_signal_connect (GTK_OBJECT (r), "toggled",
- (GtkSignalFunc) desensitize_on_toggle,
- ee->recur_hbox);
- }
-
- ee->recur_rr_group = group;
-
- /* 0. No recurrence */
- none = gtk_label_new ("");
-
- /* 1. The daily recurrence */
-
- daily = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (daily), b, FALSE, FALSE, 0);
-
- ee->recur_rr_day_period = make_spin_button (day_period, 1, 10000);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("Every")), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_day_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("day(s)")), FALSE, FALSE, 0);
-
- /* 2. The weekly recurrence */
-
- weekly = gtk_vbox_new (FALSE, 4);
-
- week_hbox = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_hbox, FALSE, FALSE, 0);
-
- /* 2.1 The week period selector */
-
- ee->recur_rr_week_period = make_spin_button (week_period, 1, 10000);
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("Every")), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), ee->recur_rr_week_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("week(s)")), FALSE, FALSE, 0);
-
- /* 2.2 The week day selector */
-
- week_day = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_day, FALSE, FALSE, 0);
-
- for (i = 0; i < 7; i++) {
- ee->recur_rr_week_days [i] = gtk_check_button_new_with_label (_(day_names [i]));
- gtk_box_pack_start (GTK_BOX (week_day), ee->recur_rr_week_days [i], FALSE, FALSE, 0);
-
- if (week_vector & (1 << ((i + 1) % 7))) /* on the spec, Sunday is 0 */
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days [i]), TRUE);
- }
-
- /* 3. The monthly recurrence */
-
- monthly = gtk_table_new (0, 0, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (monthly), 4);
- gtk_table_set_col_spacings (GTK_TABLE (monthly), 4);
-
- re = gtk_radio_button_new_with_label (NULL, _("Recur on the"));
- ee->recur_rr_month_date = make_spin_button (default_day, 1, 31);
- ee->recur_rr_month_date_label = w = gtk_label_new (_("th day of the month"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (monthly), re,
- 0, 1, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_date,
- 1, 2, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), w,
- 2, 3, 0, 1, FS, FS, 0, 0);
- gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee);
-
- r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (re)), _("Recur on the"));
- ee->recur_rr_month_day = make_numbered_menu (weekday_positions, def_pos);
- ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, default_day);
- gtk_table_attach (GTK_TABLE (monthly), r1,
- 0, 1, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_day,
- 1, 2, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_weekday,
- 2, 3, 1, 2, FS, FS, 0, 0);
-
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("Every")),
- 3, 4, 0, 2, FS, FS, 0, 0);
- ee->recur_rr_month_period = make_spin_button (month_period, 1, 10000);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_period,
- 4, 5, 0, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")),
- 5, 6, 0, 2, FS, FS, 0, 0);
-
- if (ee->ical->recur) {
- if (ee->ical->recur->type == RECUR_MONTHLY_BY_POS)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r1), 1);
- } else
- recur_month_enable_date (GTK_TOGGLE_BUTTON (re), ee);
-
- /* 4. The yearly recurrence */
-
- yearly = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (yearly), b, FALSE, FALSE, 0);
-
- ee->recur_rr_year_period = make_spin_button (year_period, 1, 10000);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("Every")), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_year_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("year(s)")), FALSE, FALSE, 0);
-
- /* Finish setting this up */
-
- gtk_notebook_append_page (notebook, none, gtk_label_new (""));
- gtk_notebook_append_page (notebook, daily, gtk_label_new (""));
- gtk_notebook_append_page (notebook, weekly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, monthly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, yearly, gtk_label_new (""));
- gtk_notebook_set_show_tabs (notebook, FALSE);
- gtk_notebook_set_show_border (notebook, FALSE);
-
- gtk_notebook_set_page (notebook, page);
-
- /* Attach to the main box */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), f, FALSE, FALSE, 0);
-}
-
-static void
-sensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), toggle->active);
-}
-
-static void
-ee_rp_init_ending_date (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
- GSList *group;
- GtkWidget *radio0, *radio1, *radio2;
- GtkWidget *hbox;
- GtkWidget *ihbox;
- GtkWidget *widget;
- time_t enddate;
- int repeat;
-
- frame = gtk_frame_new (_("Ending date"));
-
- vbox = gtk_vbox_new (TRUE, 4);
- gtk_container_border_width (GTK_CONTAINER (vbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- group = NULL;
-
- /* repeat forever */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio0 = gtk_radio_button_new_with_label (group, _("Repeat forever"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio0));
- gtk_box_pack_start (GTK_BOX (hbox), radio0, FALSE, FALSE, 0);
-
- /* end on date */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio1 = gtk_radio_button_new_with_label (group, _("End on"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio1));
- gtk_box_pack_start (GTK_BOX (hbox), radio1, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur)
- enddate = ee->ical->recur->enddate;
- else
- enddate = ee->ical->dtend;
-
- ee->recur_ed_end_on = widget = gnome_date_edit_new (enddate, FALSE, !am_pm_flag);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio1), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* end after n occurrences */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio2 = gtk_radio_button_new_with_label (group, _("End after"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio2));
- gtk_box_pack_start (GTK_BOX (hbox), radio2, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur && ee->ical->recur->duration)
- repeat = ee->ical->recur->duration;
- else
- repeat = 2;
-
- ee->recur_ed_end_after = widget = make_spin_button (repeat, 1, 10000);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_label_new (_("occurrence(s)"));
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio2), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* Activate appropriate item */
-
- if (ee->ical->recur) {
- if (ee->ical->recur->_enddate == 0) {
- if (ee->ical->recur->duration == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio0), TRUE);
- else {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (ee->recur_ed_end_after),
- ee->ical->recur->duration);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio2), TRUE);
- }
- } else {
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->recur_ed_end_on), ee->ical->recur->enddate);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio1), TRUE);
- }
- }
-
- /* Done, add to main table */
-
- ee->recur_ed_group = group;
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, FALSE, FALSE, 0);
-}
-
-static char *
-get_exception_string (time_t t)
-{
- static char buf[256];
-
- strftime (buf, sizeof(buf), "%a %b %d %Y", localtime (&t)); /* FIXME: how to i18n this? */
- return buf;
-}
-
-static void
-append_exception (EventEditor *ee, time_t t)
-{
- time_t *tt;
- char *c[1];
- int i;
-
- c[0] = get_exception_string (t);
-
- tt = g_new (time_t, 1);
- *tt = t;
-
- i = gtk_clist_append (GTK_CLIST (ee->recur_ex_clist), c);
- gtk_clist_set_row_data (GTK_CLIST (ee->recur_ex_clist), i, tt);
-
- gtk_widget_set_sensitive (ee->recur_ex_vbox, TRUE);
-}
-
-static void
-fill_exception_clist (EventEditor *ee)
-{
- GList *list;
-
- for (list = ee->ical->exdate; list; list = list->next)
- append_exception (ee, *((time_t *) list->data));
-}
-
-static void
-add_exception (GtkWidget *widget, EventEditor *ee)
-{
- time_t t;
-
- t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
- append_exception (ee, t);
-}
-
-static void
-change_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- time_t *t;
- int sel;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = (gint) clist->selection->data;
-
- t = gtk_clist_get_row_data (clist, sel);
- *t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
-
- gtk_clist_set_text (clist, sel, 0, get_exception_string (*t));
-}
-
-static void
-delete_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- int sel;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = (gint) clist->selection->data;
-
- g_free (gtk_clist_get_row_data (clist, sel)); /* free the time_t stored there */
-
- gtk_clist_remove (clist, sel);
-
- if (clist->rows == 0)
- gtk_widget_set_sensitive (ee->recur_ex_vbox, FALSE);
-}
-
-static void
-ee_rp_init_exceptions (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *ivbox;
- GtkWidget *widget;
-
- frame = gtk_frame_new (_("Exceptions"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- ee->recur_ex_date = widget = gnome_date_edit_new (time (NULL), FALSE, !am_pm_flag);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Add exception"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) add_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_vbox = ivbox = gtk_vbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ivbox, FALSE); /* at first there are no items to change or delete */
- gtk_box_pack_start (GTK_BOX (vbox), ivbox, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Change selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) change_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Delete selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) delete_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_clist = widget = gtk_clist_new (1);
- gtk_clist_set_selection_mode (GTK_CLIST (widget), GTK_SELECTION_BROWSE);
- gtk_clist_set_policy (GTK_CLIST (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- fill_exception_clist (ee);
- gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
-
- /* Done, add to main table */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, TRUE, TRUE, 0);
-}
-
-static void
-ee_init_recurrence_page (EventEditor *ee)
-{
- ee->recur_vbox = gtk_vbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (ee->recur_vbox), 4);
-
- ee->recur_hbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ee->recur_hbox, FALSE);
-
- ee->recur_page_label = gtk_label_new (_("Recurrence"));
-
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), ee->recur_vbox,
- ee->recur_page_label);
-
- ee_rp_init_rule (ee);
-
- /* pack here so that the box gets inserted after the recurrence rule frame */
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), ee->recur_hbox, FALSE, FALSE, 0);
-
- ee_rp_init_ending_date (ee);
- ee_rp_init_exceptions (ee);
-}
-
-static void
-event_editor_init_widgets (EventEditor *ee)
-{
- ee->notebook = gtk_notebook_new ();
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG(ee)->vbox), ee->notebook, 1, 1, 0);
-
- /* Init the various configuration pages */
- ee_init_general_page (ee);
- ee_init_summary_page (ee);
- ee_init_recurrence_page (ee);
-
- /* Buttons */
- ee_create_buttons(ee);
-
- /* We show all of the contained widgets */
- gtk_widget_show_all (GTK_BIN (ee)->child);
-}
-
-static void
-event_editor_init (EventEditor *ee)
-{
- ee->ical = 0;
- gnome_dialog_set_close (GNOME_DIALOG(ee), TRUE);
-}
-
-static void
-event_editor_destroy (GtkObject *object)
-{
- EventEditor *ee;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EVENT_EDITOR (object));
-
- ee = EVENT_EDITOR (object);
-
- if (ee->ical)
- ee->ical->user_data = NULL; /* we are no longer editing it */
-}
-
-GtkWidget *
-event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
-{
- GtkWidget *retval;
- EventEditor *ee;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- retval = gtk_type_new (event_editor_get_type ());
- ee = EVENT_EDITOR (retval);
-
- if (ical == 0){
- ical = ical_new ("", user_name, "");
- ical->new = 1;
- }
-
- ical->user_data = ee; /* so that the world can know we are editing it */
-
- ee->ical = ical;
- ee->gnome_cal = gcal;
- event_editor_init_widgets (ee);
-
- return retval;
-}
diff --git a/calendar/gui/eventedit.h b/calendar/gui/eventedit.h
deleted file mode 100644
index 9cb80e3912..0000000000
--- a/calendar/gui/eventedit.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef EVENT_EDITOR_H
-#define EVENT_EDITOR_H
-
-#include "gnome-cal.h"
-#include <libgnomeui/gnome-dialog.h>
-
-BEGIN_GNOME_DECLS
-
-
-#define EVENT_EDITOR(obj) GTK_CHECK_CAST(obj, event_editor_get_type(), EventEditor)
-#define EVENT_EDITOR_CLASS(class) GTK_CHECK_CAST_CLASS(class, event_editor_get_type(), EventEditorClass)
-#define IS_EVENT_EDITOR(obj) GTK_CHECK_TYPE(obj, event_editor_get_type())
-
-
-typedef struct {
- GnomeDialog dialog;
- GtkWidget *notebook;
-
- GtkWidget *general;
- GtkWidget *general_table;
- GtkWidget *general_time_table;
- GtkWidget *general_allday;
- GtkWidget *general_owner;
- GtkWidget *general_summary;
- GtkWidget *start_time, *end_time;
- GtkWidget *general_radios;
-
- GtkWidget *recur_page_label;
- GtkWidget *recur_vbox;
- GtkWidget *recur_hbox;
-
- GSList *recur_rr_group;
- GtkWidget *recur_rr_notebook;
- GtkWidget *recur_rr_day_period;
- GtkWidget *recur_rr_week_period;
- GtkWidget *recur_rr_week_days [7];
- GtkWidget *recur_rr_month_date;
- GtkWidget *recur_rr_month_date_label;
- GtkWidget *recur_rr_month_day;
- GtkWidget *recur_rr_month_weekday;
- GtkWidget *recur_rr_month_period;
- GtkWidget *recur_rr_year_period;
-
- GSList *recur_ed_group;
- GtkWidget *recur_ed_end_on;
- GtkWidget *recur_ed_end_after;
-
- GtkWidget *recur_ex_date;
- GtkWidget *recur_ex_vbox;
- GtkWidget *recur_ex_clist;
-
- /* The associated ical object */
- iCalObject *ical;
-
- /* The calendar owner of this event */
- GnomeCalendar *gnome_cal;
-} EventEditor;
-
-typedef struct {
- GnomeDialogClass parent_class;
-} EventEditorClass;
-
-
-guint event_editor_get_type (void);
-GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *);
-
-
-END_GNOME_DECLS
-
-#endif
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-day-panel.c b/calendar/gui/gncal-day-panel.c
deleted file mode 100644
index 00d4f6f31e..0000000000
--- a/calendar/gui/gncal-day-panel.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include "gncal-day-panel.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-guint
-gncal_day_panel_get_type (void)
-{
- static guint day_panel_type = 0;
-
- if (!day_panel_type) {
- GtkTypeInfo day_panel_info = {
- "GncalDayPanel",
- sizeof (GncalDayPanel),
- sizeof (GncalDayPanelClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) NULL,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_panel_type = gtk_type_unique (gtk_table_get_type (), &day_panel_info);
- }
-
- return day_panel_type;
-}
-
-static void
-day_view_range_activated (GncalFullDay *fullday, GncalDayPanel *dpanel)
-{
- iCalObject *ical;
-
- ical = ical_new ("", user_name, "");
- ical->new = 1;
-
- gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
-
- gnome_calendar_add_object (dpanel->calendar, ical);
- gncal_full_day_focus_child (fullday, ical);
-}
-
-static void
-full_day_size_allocated (GtkWidget *widget, GtkAllocation *allocation, GncalDayPanel *dpanel)
-{
- GtkAdjustment *adj;
- int yoffset;
- gfloat newval;
-
- adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
-
- yoffset = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));
-
- newval = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
- if (newval != adj->value)
- gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
-}
-
-static void
-calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- 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 = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- gnome_calendar_goto (dpanel->calendar, mktime (&tm));
-}
-
-static void
-retag_calendar (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- gnome_calendar_tag_calendar (dpanel->calendar, GTK_CALENDAR (dpanel->gtk_calendar));
-}
-
-GtkWidget *
-gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day)
-{
- GncalDayPanel *dpanel;
- GtkWidget *w;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dpanel = gtk_type_new (gncal_day_panel_get_type ());
-
- gtk_container_border_width (GTK_CONTAINER (dpanel), 4);
- gtk_table_set_row_spacings (GTK_TABLE (dpanel), 4);
- gtk_table_set_col_spacings (GTK_TABLE (dpanel), 4);
-
- dpanel->calendar = calendar;
-
- /* Date label */
-
- w = gtk_label_new ("");
- dpanel->date_label = GTK_LABEL (w);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 0, 1, 0, 1,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Full day */
-
- w = gtk_scrolled_window_new (NULL, NULL);
- dpanel->fullday_sw = GTK_SCROLLED_WINDOW (w);
- gtk_scrolled_window_set_policy (dpanel->fullday_sw,
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 0, 1, 1, 4,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- w = gncal_full_day_new (calendar, time_start_of_day (start_of_day), time_end_of_day (start_of_day));
- dpanel->fullday = GNCAL_FULL_DAY (w);
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "range_activated",
- (GtkSignalFunc) day_view_range_activated,
- dpanel);
- gtk_container_add (GTK_CONTAINER (dpanel->fullday_sw), w);
- gtk_widget_show (w);
-
- /* We'll scroll the list to the proper initial position */
-
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "size_allocate",
- (GtkSignalFunc) full_day_size_allocated,
- dpanel);
-
- /* Gtk calendar */
-
- w = gtk_calendar_new ();
- dpanel->gtk_calendar = GTK_CALENDAR (w);
- gtk_calendar_display_options (dpanel->gtk_calendar,
- GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);
- dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "day_selected_double_click",
- (GtkSignalFunc) calendar_day_selected,
- dpanel);
- gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC (retag_calendar), dpanel);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 1, 2, 1, 2,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Separator */
-
- w = gtk_hseparator_new ();
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 1, 2, 2, 3,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* To-do */
-
- w = gncal_todo_new (calendar);
- dpanel->todo = GNCAL_TODO (w);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 1, 2, 3, 4,
- GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Done */
-
- gncal_day_panel_set (dpanel, start_of_day);
-
- return GTK_WIDGET (dpanel);
-}
-
-static void
-update (GncalDayPanel *dpanel, int update_fullday, iCalObject *ico, int flags)
-{
- char buf [80];
-
- if (update_fullday){
- gncal_full_day_update (dpanel->fullday, ico, flags);
- retag_calendar (dpanel->gtk_calendar, dpanel);
- }
- gncal_todo_update (dpanel->todo, ico, flags);
-
- strftime (buf, sizeof (buf), "%a %b %d %Y", localtime (&dpanel->start_of_day));
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-}
-
-void
-gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- update (dpanel, TRUE, ico, flags);
-}
-
-void
-gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
-{
- char buf[80];
- struct tm tm;
-
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- dpanel->start_of_day = time_start_of_day (start_of_day);
- if (dpanel->fullday->lower == dpanel->start_of_day)
- return;
-
- tm = *localtime (&dpanel->start_of_day);
- strftime (buf, sizeof (buf), "%a %b %d %Y", &tm);
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-
- gncal_full_day_set_bounds (dpanel->fullday, dpanel->start_of_day, time_end_of_day (dpanel->start_of_day));
-
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- gtk_signal_handler_block (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- gtk_signal_handler_unblock (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
-
- update (dpanel, FALSE, NULL, 0);
-}
diff --git a/calendar/gui/gncal-day-panel.h b/calendar/gui/gncal-day-panel.h
deleted file mode 100644
index 8b62013ca7..0000000000
--- a/calendar/gui/gncal-day-panel.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_PANEL_H
-#define GNCAL_DAY_PANEL_H
-
-#include <gtk/gtklabel.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gtkcalendar.h>
-#include "gnome-cal.h"
-#include "gncal-full-day.h"
-#include "gncal-todo.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_PANEL(obj) GTK_CHECK_CAST (obj, gncal_day_panel_get_type (), GncalDayPanel)
-#define GNCAL_DAY_PANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_panel_get_type (), GncalDayPanelClass)
-#define GNCAL_IS_DAY_PANEL(obj) GTK_CHECK_TYPE (obj, gncal_day_panel_get_type ())
-
-
-typedef struct _GncalDayPanel GncalDayPanel;
-typedef struct _GncalDayPanelClass GncalDayPanelClass;
-
-struct _GncalDayPanel {
- GtkTable table;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t start_of_day;
-
- GtkLabel *date_label;
- GncalFullDay *fullday;
- GtkScrolledWindow *fullday_sw;
- GtkCalendar *gtk_calendar;
- GncalTodo *todo;
-
- guint day_selected_id;
-};
-
-struct _GncalDayPanelClass {
- GtkTableClass parent_class;
-};
-
-
-guint gncal_day_panel_get_type (void);
-GtkWidget *gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day);
-
-void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
-void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c
deleted file mode 100644
index 85d61292f1..0000000000
--- a/calendar/gui/gncal-day-view.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <gnome.h>
-#include "gncal-day-view.h"
-#include "timeutil.h"
-#include "view-utils.h"
-#include "main.h"
-#include "eventedit.h"
-#include "popup-menu.h"
-
-
-#define TEXT_BORDER 2
-#define MIN_INFO_WIDTH 50
-
-
-static void gncal_day_view_class_init (GncalDayViewClass *class);
-static void gncal_day_view_init (GncalDayView *dview);
-static void gncal_day_view_destroy (GtkObject *object);
-static void gncal_day_view_realize (GtkWidget *widget);
-static void gncal_day_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static gint gncal_day_view_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_day_view_button_press (GtkWidget *widget,
- GdkEventButton *event);
-
-
-static GtkWidgetClass *parent_class;
-
-
-guint
-gncal_day_view_get_type (void)
-{
- static guint day_view_type = 0;
-
- if (!day_view_type) {
- GtkTypeInfo day_view_info = {
- "GncalDayView",
- sizeof (GncalDayView),
- sizeof (GncalDayViewClass),
- (GtkClassInitFunc) gncal_day_view_class_init,
- (GtkObjectInitFunc) gncal_day_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_view_type = gtk_type_unique (gtk_widget_get_type (), &day_view_info);
- }
-
- return day_view_type;
-}
-
-static void
-gncal_day_view_class_init (GncalDayViewClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_widget_get_type ());
-
- object_class->destroy = gncal_day_view_destroy;
-
- widget_class->realize = gncal_day_view_realize;
- widget_class->size_request = gncal_day_view_size_request;
- widget_class->expose_event = gncal_day_view_expose;
- widget_class->button_press_event = gncal_day_view_button_press;
-}
-
-static void
-gncal_day_view_init (GncalDayView *dview)
-{
- GTK_WIDGET_UNSET_FLAGS (dview, GTK_NO_WINDOW);
-
- dview->calendar = NULL;
-
- dview->lower = 0;
- dview->upper = 0;
-
- dview->shadow_type = GTK_SHADOW_ETCHED_IN;
-}
-
-static void
-gncal_day_view_destroy (GtkObject *object)
-{
- GncalDayView *dview;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (object));
-
- dview = GNCAL_DAY_VIEW (object);
-
- if (dview->day_str)
- g_free (dview->day_str);
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static int
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalDayView *dayview = GNCAL_DAY_VIEW (data);
- iCalObject *ico;
- GtkWidget *ee;
- struct tm tm;
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- tm = *localtime (&dayview->lower);
- tm.tm_hour = day_begin;
- ico->dtstart = mktime (&tm);
- tm.tm_hour++;
- ico->dtend = mktime (&tm);
- ee = event_editor_new (dayview->calendar, ico);
- gtk_widget_show (ee);
- return 1;
-}
-
-static void
-context_menu (GncalDayView *dayview, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- main_items [0].data = dayview;
- popup_menu (main_items, 1, event);
-}
-
-static void
-switch_to_day (GncalDayView *dayview)
-{
-}
-
-static gint
-gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalDayView *dayview;
-
- dayview = GNCAL_DAY_VIEW (widget);
-
- if (event->button == 3)
- context_menu (dayview, event);
-
- if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
- gnome_calendar_dayjump (dayview->calendar, dayview->lower);
-
- return TRUE;
-}
-
-GtkWidget *
-gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalDayView *dview;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dview = gtk_type_new (gncal_day_view_get_type ());
-
- dview->calendar = calendar;
- dview->lower = lower;
- dview->upper = upper;
- dview->events = 0;
-
- gncal_day_view_update (dview, NULL, 0);
-
- return GTK_WIDGET (dview);
-}
-
-static void
-gncal_day_view_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-}
-
-static void
-gncal_day_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalDayView *dview;
- int str_width, width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- dview = GNCAL_DAY_VIEW (widget);
-
- /* border and min width */
-
- str_width = gdk_string_width (widget->style->font, dview->day_str);
-
- width = MAX (MIN_INFO_WIDTH, str_width);
-
- requisition->width = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + width;
- requisition->height = 2 * (widget->style->klass->ythickness + TEXT_BORDER);
-
- /* division line */
-
- requisition->height += 2 * TEXT_BORDER + widget->style->klass->ythickness;
-
- /* title and at least one line of text */
-
- requisition->height += 2 * (widget->style->font->ascent + widget->style->font->descent);
-}
-
-static gint
-gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalDayView *dview;
- int x1, y1, width, height;
- GdkRectangle rect, dest;
- GdkFont *font;
- int str_width;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_DAY_VIEW (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- dview = GNCAL_DAY_VIEW (widget);
-
- x1 = widget->style->klass->xthickness;
- y1 = widget->style->klass->ythickness;
- width = widget->allocation.width - 2 * x1;
- height = widget->allocation.height - 2 * y1;
-
- /* Clear and paint frame shadow */
-
- gdk_window_clear_area (widget->window,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, dview->shadow_type,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- /* Clear and paint title */
-
- font = widget->style->font;
-
- rect.x = x1;
- rect.y = y1;
- rect.width = width;
- rect.height = 2 * TEXT_BORDER + font->ascent + font->descent;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest)) {
- gdk_draw_rectangle (widget->window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- dest = rect;
-
- dest.x += TEXT_BORDER;
- dest.y += TEXT_BORDER;
- dest.width -= 2 * TEXT_BORDER;
- dest.height -= 2 * TEXT_BORDER;
-
- gdk_gc_set_clip_rectangle (widget->style->fg_gc[GTK_STATE_NORMAL], &dest);
-
- str_width = gdk_string_width (font, dview->day_str);
-
- gdk_draw_string (widget->window,
- font,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- dest.x + (dest.width - str_width) / 2,
- dest.y + font->ascent,
- dview->day_str);
-
- gdk_gc_set_clip_rectangle (widget->style->fg_gc[GTK_STATE_NORMAL], NULL);
- }
-
- /* Division line */
-
- gtk_draw_hline (widget->style,
- widget->window,
- GTK_STATE_NORMAL,
- rect.x,
- rect.x + rect.width - 1,
- rect.y + rect.height);
-
- /* Text */
-
- rect.x = x1 + TEXT_BORDER;
- rect.y = y1 + 3 * TEXT_BORDER + font->ascent + font->descent + widget->style->klass->ythickness;
- rect.width = width - 2 * TEXT_BORDER;
- rect.height = height - (rect.y - y1) - TEXT_BORDER;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest))
- view_utils_draw_events (widget,
- widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- &rect,
- VIEW_UTILS_DRAW_END | VIEW_UTILS_DRAW_SPLIT,
- dview->events,
- dview->lower,
- dview->upper);
-
- return FALSE;
-}
-
-void
-gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
-{
- struct tm tm;
- char buf[256];
-
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
- g_return_if_fail (dview->calendar->cal);
-
- if (dview->day_str)
- g_free (dview->day_str);
-
- tm = *localtime (&dview->lower);
- strftime (buf, sizeof (buf)-1, "%A %d", &tm);
- dview->day_str = g_strdup (buf);
-
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- dview->events = calendar_get_events_in_range (dview->calendar->cal,
- dview->lower,
- dview->upper);
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
-}
-
-void
-gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if ((lower != dview->lower) || (upper != dview->upper)) {
- dview->lower = lower;
- dview->upper = upper;
-
- gncal_day_view_update (dview, NULL, 0);
- }
-}
-
-void
-gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if (shadow_type != dview->shadow_type) {
- dview->shadow_type = shadow_type;
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
- }
-}
diff --git a/calendar/gui/gncal-day-view.h b/calendar/gui/gncal-day-view.h
deleted file mode 100644
index dae1897fb6..0000000000
--- a/calendar/gui/gncal-day-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_VIEW_H
-#define GNCAL_DAY_VIEW_H
-
-
-#include <gtk/gtkwidget.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_VIEW(obj) GTK_CHECK_CAST (obj, gncal_day_view_get_type (), GncalDayView)
-#define GNCAL_DAY_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_view_get_type (), GncalDayViewClass)
-#define GNCAL_IS_DAY_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_day_view_get_type ())
-
-
-typedef struct _GncalDayView GncalDayView;
-typedef struct _GncalDayViewClass GncalDayViewClass;
-
-struct _GncalDayView {
- GtkWidget widget;
-
- GnomeCalendar *calendar;/* the calendar we are associated to */
-
- time_t lower; /* lower and upper times to display */
- time_t upper; /* these include the full day */
-
- char *day_str; /* what day is it? */
- GList *events; /* the events for the this day */
- GtkShadowType shadow_type;
-};
-
-struct _GncalDayViewClass {
- GtkWidgetClass parent_class;
-};
-
-
-guint gncal_day_view_get_type (void);
-GtkWidget *gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags);
-void gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper);
-
-void gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
deleted file mode 100644
index 64e5ec6ef4..0000000000
--- a/calendar/gui/gncal-full-day.c
+++ /dev/null
@@ -1,2321 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-#include <config.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-#include <gnome.h>
-#include "eventedit.h"
-#include "gncal-full-day.h"
-#include "view-utils.h"
-#include "main.h"
-#include "popup-menu.h"
-
-/* Images */
-#include "bell.xpm"
-#include "recur.xpm"
-
-#define TEXT_BORDER 2
-#define HANDLE_SIZE 8
-#define MIN_WIDTH 200
-#define XOR_RECT_WIDTH 2
-#define UNSELECT_TIMEOUT 150 /* ms */
-
-/* Size of the pixmaps */
-#define DECOR_WIDTH 16
-#define DECOR_HEIGHT 16
-
-typedef struct {
- iCalObject *ico;
- GtkWidget *widget;
- GdkWindow *window;
- GdkWindow *decor_window;
- int lower_row; /* zero is first displayed row */
- int rows_used;
- int x; /* coords of child's window */
- int y;
- int width;
- int height;
- int decor_width;
- int decor_height;
- int items; /* number of decoration bitmaps */
- time_t start, end;
-} Child;
-
-struct layout_row {
- int intersections;
- int *slots;
-};
-
-struct drag_info {
- enum {
- DRAG_NONE,
- DRAG_SELECT, /* selecting a range in the main window */
- DRAG_MOVE, /* moving a child */
- DRAG_SIZE_TOP, /* resizing a child */
- DRAG_SIZE_BOTTOM
- } drag_mode;
-
- Child *child;
- int child_click_y;
- int child_start_row;
- int child_rows_used;
-
- int sel_click_row;
- int sel_start_row;
- int sel_rows_used;
- guint32 click_time;
-};
-
-
-enum {
- RANGE_ACTIVATED,
- LAST_SIGNAL
-};
-
-
-static void gncal_full_day_class_init (GncalFullDayClass *class);
-static void gncal_full_day_init (GncalFullDay *fullday);
-static void gncal_full_day_destroy (GtkObject *object);
-static void gncal_full_day_map (GtkWidget *widget);
-static void gncal_full_day_unmap (GtkWidget *widget);
-static void gncal_full_day_realize (GtkWidget *widget);
-static void gncal_full_day_unrealize (GtkWidget *widget);
-static void gncal_full_day_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void gncal_full_day_draw_focus (GtkWidget *widget);
-static void gncal_full_day_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gncal_full_day_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint gncal_full_day_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_motion (GtkWidget *widget,
- GdkEventMotion *event);
-static gint gncal_full_day_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_full_day_key_press (GtkWidget *widget,
- GdkEventKey *event);
-static gint gncal_full_day_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint gncal_full_day_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-static void gncal_full_day_foreach (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data);
-
-static void range_activated (GncalFullDay *fullday);
-
-
-static GtkContainerClass *parent_class;
-
-static int fullday_signals[LAST_SIGNAL] = { 0 };
-
-/* The little images */
-static GdkPixmap *pixmap_bell, *pixmap_recur;
-
-static void
-get_tm_range (GncalFullDay *fullday,
- time_t time_lower, time_t time_upper,
- struct tm *lower, struct tm *upper,
- int *lower_row, int *rows_used)
-{
- struct tm tm_lower, tm_upper;
- int lmin, umin;
- int lrow;
-
- /* Lower */
-
- tm_lower = *localtime (&time_lower);
-
- if ((tm_lower.tm_min % fullday->interval) != 0) {
- tm_lower.tm_min -= tm_lower.tm_min % fullday->interval; /* round down */
- mktime (&tm_lower);
- }
-
- /* Upper */
-
- tm_upper = *localtime (&time_upper);
-
- if ((tm_upper.tm_min % fullday->interval) != 0) {
- tm_upper.tm_min += fullday->interval - (tm_upper.tm_min % fullday->interval); /* round up */
- mktime (&tm_upper);
- }
-
- if (lower)
- *lower = tm_lower;
-
- if (upper)
- *upper = tm_upper;
-
- lmin = 60 * tm_lower.tm_hour + tm_lower.tm_min;
- umin = 60 * tm_upper.tm_hour + tm_upper.tm_min;
-
- if (umin == 0) /* midnight of next day? */
- umin = 60 * 24;
-
- lrow = lmin / fullday->interval;
-
- if (lower_row)
- *lower_row = lrow;
-
- if (rows_used)
- *rows_used = (umin - lmin) / fullday->interval;
-}
-
-static void
-child_map (GncalFullDay *fullday, Child *child)
-{
- gdk_window_show (child->window);
- if (child->decor_width)
- gdk_window_show (child->decor_window);
- gtk_widget_show (child->widget); /* OK, not just a map... */
-}
-
-static void
-child_unmap (GncalFullDay *fullday, Child *child)
-{
- gdk_window_hide (child->window);
- gdk_window_hide (child->decor_window);
- if (GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
-}
-
-static void
-child_set_text_pos (Child *child)
-{
- GtkAllocation allocation;
- int has_focus;
- int handle_size;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- handle_size = (child->ico->recur) ? 0 : HANDLE_SIZE;
-
- allocation.x = handle_size;
- allocation.y = has_focus ? handle_size : 0;
- allocation.width = child->width - handle_size - child->decor_width;
- allocation.height = child->height - (has_focus ? (2 * handle_size) : 0);
-
- gtk_widget_size_request (child->widget, &child->widget->requisition); /* FIXME: is this needed? */
- gtk_widget_size_allocate (child->widget, &allocation);
-}
-
-static void
-child_realize (GncalFullDay *fullday, Child *child)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkWidget *widget;
- GdkColor c;
-
- widget = GTK_WIDGET (fullday);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = child->x;
- attributes.y = child->y;
- attributes.width = child->width - child->decor_width;;
- attributes.height = child->height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.cursor = fullday->up_down_cursor;
- attributes.event_mask = (GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_KEY_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR;
- child->window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_window_set_user_data (child->window, widget);
- gtk_style_set_background (widget->style, child->window, GTK_STATE_NORMAL);
- gtk_widget_set_parent_window (child->widget, child->window);
-
- /* Create the decoration window */
- attributes.x = child->x + child->width - child->decor_width;
- attributes.width = child->decor_width ? child->decor_width : 1;
- attributes.height = child->decor_height ? child->decor_height : 1;
- attributes.visual = gdk_imlib_get_visual ();
- attributes.colormap = gdk_imlib_get_colormap ();
- attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- child->decor_window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_color_white (gdk_imlib_get_colormap (), &c);
- gdk_window_set_background (child->decor_window, &c);
- gdk_window_set_user_data (child->decor_window, widget);
-
- if (!pixmap_bell){
- GdkImlibImage *imlib_bell, *imlib_recur;
- GdkPixmap *mask;
-
- imlib_bell = gdk_imlib_create_image_from_xpm_data (bell_xpm);
- gdk_imlib_render (imlib_bell, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_bell = gdk_imlib_move_image (imlib_bell);
- mask = gdk_imlib_move_mask (imlib_bell);
- gdk_imlib_destroy_image (imlib_bell);
- fullday->bell_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->bell_gc, mask);
-
- imlib_recur = gdk_imlib_create_image_from_xpm_data (recur_xpm);
- gdk_imlib_render (imlib_recur, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_recur = gdk_imlib_move_image (imlib_recur);
- mask = gdk_imlib_move_mask (imlib_recur);
- gdk_imlib_destroy_image (imlib_recur);
- fullday->recur_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->recur_gc, mask);
- }
- child_set_text_pos (child);
-}
-
-static void
-child_unrealize (GncalFullDay *fullday, Child *child)
-{
- gdk_window_set_user_data (child->window, NULL);
- gdk_window_destroy (child->window);
- child->window = NULL;
-}
-
-static void
-child_draw_decor (GncalFullDay *fullday, Child *child)
-{
- iCalObject *ico = child->ico;
- int ry = 0;
-
- if (ico->recur) {
- gdk_gc_set_clip_origin (fullday->recur_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->recur_gc,
- pixmap_recur,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-
- if (ico->dalarm.enabled || ico->malarm.enabled || ico->palarm.enabled || ico->aalarm.enabled) {
- gdk_gc_set_clip_origin (fullday->bell_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->bell_gc,
- pixmap_bell,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-}
-
-static void
-child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, GdkWindow *window, int draw_child)
-{
- GdkRectangle arect, rect, dest;
- int has_focus;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (!window || (window == child->window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->width;
- arect.height = child->height;
-
- area = &arect;
- }
-
- /* Left handle */
-
- rect.x = 0;
- rect.y = has_focus ? HANDLE_SIZE : 0;
- rect.width = HANDLE_SIZE;
- rect.height = has_focus ? (child->height - 2 * HANDLE_SIZE) : child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT);
-
- if (has_focus) {
- /* Top handle */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = child->width - child->decor_width;
- rect.height = HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
-
- /* Bottom handle */
-
- rect.y = child->height - HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
- }
-
- } else if (!window || (window == child->decor_window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->decor_width;
- arect.height = child->decor_height;
-
- area = &arect;
- }
-
- child_draw_decor (fullday, child);
- }
-
- if (draw_child)
- gtk_widget_draw (child->widget, NULL);
-}
-
-static void
-child_range_changed (GncalFullDay *fullday, Child *child)
-{
- struct tm start, end;
- int lower_row, rows_used;
- int f_lower_row;
-
- /* Calc display range for event */
-
- get_tm_range (fullday, child->start, child->end, &start, &end, &lower_row, &rows_used);
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, &f_lower_row, NULL);
-
- child->lower_row = lower_row - f_lower_row;
- child->rows_used = rows_used;
-}
-
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalFullDay *fullday;
- GtkWidget *ee;
- iCalObject *ico;
-
- fullday = GNCAL_FULL_DAY (data);
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- gncal_full_day_selection_range (fullday, &ico->dtstart, &ico->dtend);
- ee = event_editor_new (fullday->calendar, ico);
- gtk_widget_show (ee);
-}
-
-static void
-edit_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GtkWidget *ee;
-
- child = data;
-
- ee = event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
- gtk_widget_show (ee);
-}
-
-static void
-delete_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- gnome_calendar_remove_object (fullday->calendar, child->ico);
-}
-
-static void
-unrecur_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- iCalObject *new;
-
- child = data;
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- /* New object */
- new = ical_object_duplicate (child->ico);
- g_free (new->recur);
- new->recur = 0;
- new->dtstart = child->start;
- new->dtend = child->end;
-
- /* Duplicate, and eliminate the recurrency fields */
- ical_object_add_exdate (child->ico, child->start);
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_ALL);
-
- gnome_calendar_add_object (fullday->calendar, new);
-}
-
-static void
-child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
-{
- int sensitive, idx, items;
-
- static struct menu_item child_items[] = {
- { N_("Make this appointment movable"), (GtkSignalFunc) unrecur_appointment, NULL, TRUE },
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- child_items[0].data = child;
- child_items[1].data = child;
- child_items[2].data = child;
- child_items[4].data = fullday;
-
- sensitive = (child->ico->user_data == NULL);
-
- child_items[0].sensitive = sensitive;
- child_items[1].sensitive = sensitive;
- child_items[2].sensitive = sensitive;
-
- if (child->ico->recur){
- idx = 0;
- items = 5;
- } else {
- idx = 1;
- items = 4;
- }
- popup_menu (&child_items [idx], items, event);
-}
-
-static void
-child_realized_setup (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gdk_window_set_cursor (widget->window, fullday->beam_cursor);
-
- gtk_text_insert (GTK_TEXT (widget), NULL, NULL, NULL,
- child->ico->summary,
- strlen (child->ico->summary));
-}
-
-static void
-child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int height)
-{
- const int decor_width = child->decor_width;
-
- child->x = x;
- child->y = y;
- child->width = width;
- child->height = height;
-
- if (!child->window) /* realized? */
- return;
-
- child_set_text_pos (child);
- gdk_window_move_resize (child->window, x, y, width - decor_width, height);
-
- if (decor_width){
- gdk_window_move_resize (child->decor_window, x + width - decor_width, y,
- decor_width, child->decor_height);
- }
-}
-
-static int
-calc_row_height (GncalFullDay *fullday)
-{
- int f_rows;
- GtkWidget *widget;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- widget = GTK_WIDGET (fullday);
-
- return (widget->allocation.height - 2 * widget->style->klass->ythickness) / f_rows;
-}
-
-static void
-child_set_size (Child *child)
-{
- int row_height;
- int x, y, width, height;
- GncalFullDay *fullday;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- row_height = calc_row_height (fullday);
-
- x = child->x;
- y = child->lower_row * row_height + GTK_WIDGET (fullday)->style->klass->ythickness;
- width = child->width;
- height = child->rows_used * row_height;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget) && !child->ico->recur) {
- y -= HANDLE_SIZE;
- height += 2 * HANDLE_SIZE;
- }
-
- child_set_pos (fullday, child, x, y, width, height);
-}
-
-static gint
-child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- Child *child;
-
- child = data;
-
- child_set_size (child);
- gdk_window_raise (child->window);
-
- return FALSE;
-}
-
-static gint
-child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- char *text;
-
- child = data;
-
- child_set_size (child);
-
- /* Update summary in calendar object */
-
- text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
- if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
- return FALSE;
-
- if (child->ico->summary)
- g_free (child->ico->summary);
-
- child->ico->summary = text;
-
- /* Notify calendar of change */
-
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY);
-
- return FALSE;
-}
-
-static gint
-child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
-{
- if (event->keyval != GDK_Escape)
- return FALSE;
-
- /* If user pressed Esc, un-focus the child by focusing the fullday widget */
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
- gtk_widget_grab_focus (widget->parent);
-
- return FALSE;
-}
-
-static gint
-child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- if (event->button != 3)
- return FALSE;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
- child_popup_menu (fullday, child, event);
-
- return TRUE;
-}
-
-/*
- * compute the space required to display the decorations
- */
-static void
-child_compute_decor (Child *child)
-{
- iCalObject *ico = child->ico;
- int rows_used;
-
- child->items = 0;
- rows_used = (child->rows_used < 1) ? 1 : child->rows_used;
- if (ico->recur)
- child->items++;
- if (ico->dalarm.enabled || ico->aalarm.enabled || ico->palarm.enabled || ico->malarm.enabled)
- child->items++;
-
- if (child->items > rows_used){
- child->decor_width = DECOR_WIDTH * 2;
- child->decor_height = DECOR_HEIGHT;
- } else {
- child->decor_width = DECOR_WIDTH * (child->items ? 1 : 0);
- child->decor_height = DECOR_HEIGHT * child->items;
- }
-}
-
-static Child *
-child_new (GncalFullDay *fullday, time_t start, time_t end, iCalObject *ico)
-{
- Child *child;
-
- child = g_new (Child, 1);
-
- child->ico = ico;
- child->widget = gtk_text_new (NULL, NULL);
- child->window = NULL;
- child->x = 0;
- child->y = 0;
- child->width = 0;
- child->height = 0;
- child->start = start;
- child->end = end;
- child_range_changed (fullday, child);
- child_compute_decor (child);
-
- /* We set the i-beam cursor and the initial summary text upon realization */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "realize",
- (GtkSignalFunc) child_realized_setup,
- child);
-
- gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_in_event",
- (GtkSignalFunc) child_focus_in,
- child);
-
- gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_out_event",
- (GtkSignalFunc) child_focus_out,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event",
- (GtkSignalFunc) child_key_press,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "button_press_event",
- (GtkSignalFunc) child_button_press,
- child);
-
- /* Finish setup */
-
- gtk_text_set_editable (GTK_TEXT (child->widget), TRUE);
- gtk_text_set_word_wrap (GTK_TEXT (child->widget), TRUE);
-
- gtk_widget_set_parent (child->widget, GTK_WIDGET (fullday));
-
- return child;
-}
-
-static void
-child_destroy (GncalFullDay *fullday, Child *child)
-{
- /* Unparent the child widget manually as we don't have a remove method */
-
- gtk_widget_ref (child->widget);
-
- gtk_widget_unparent (child->widget);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_unmap (fullday, child);
-
- if (GTK_WIDGET_REALIZED (fullday))
- child_unrealize (fullday, child);
-
- gtk_widget_unref (child->widget);
-
- g_free (child);
-}
-
-static int
-calc_labels_width (GncalFullDay *fullday)
-{
- struct tm cur, upper;
- time_t tim, time_upper;
- int width, max_w;
- char buf[40];
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &cur, &upper, NULL, NULL);
-
- max_w = 0;
-
- tim = mktime (&cur);
- time_upper = mktime (&upper);
-
- while (tim < time_upper) {
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &cur);
- else
- strftime (buf, sizeof (buf), "%H:%M", &cur);
-
-
- width = gdk_string_width (GTK_WIDGET (fullday)->style->font, buf);
-
- if (width > max_w)
- max_w = width;
-
- cur.tm_min += fullday->interval;
- tim = mktime (&cur);
- }
-
- return max_w;
-}
-
-#define MAX_CHILDREN_ON_ROW 32
-
-#define xy(a,x,y) (a[((y) * MAX_CHILDREN_ON_ROW) + (x)])
-
-static int
-range_empty (char *array, int slot, int lower, int count)
-{
- int i;
-
- for (i = 0; i < count; i++)
- if (xy (array, slot, lower+i) != 0)
- return 0;
- return 1;
-}
-
-static void
-range_allocate (char *array, int slot, int lower, int count, int val)
-{
- int i;
-
- for (i = 0; i < count; i++)
- xy (array, slot, lower+i) = val;
-}
-
-static int
-can_expand (char *array, int *allocations, int top_slot, int val, int lower, int count)
-{
- int slot, i;
- int cols = 0;
-
- for (slot = allocations [val] + 1; slot < top_slot; slot++){
- for (i = 0; i < count; i++)
- if (xy (array, slot, lower+i))
- return cols;
- cols++;
- }
- return cols;
-}
-
-static void
-expand_space (char *array, int *allocations, int val, int lower, int count, int cols)
-{
- int j, i, slot;
-
- for (i = 0; i < count; i++){
- slot = allocations [val] + 1;
- for (j = 0; j < cols; j++)
- xy (array, slot, lower+i) = val;
- }
-}
-
-static void
-layout_children (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- int lines = (24 * 60) / fullday->interval;
- char *array = g_malloc0 (sizeof (char) * lines * MAX_CHILDREN_ON_ROW);
- GList *children;
- int val, slot;
- int *allocations, *columns;
- int top_slot = 0;
- int left_x, cols;
- int pixels_per_col, extra_pixels, extra, usable_pixels;
- int child_count;
-
- if (!fullday->children)
- return;
-
- /* initial allocation */
- child_count = g_list_length (fullday->children) + 2;
- allocations = g_malloc0 (sizeof (int) * child_count);
- columns = g_malloc0 (sizeof (int) * child_count);
- val = 1;
- for (children = fullday->children; children; children = children->next, val++){
- Child *child = children->data;
-
- allocations [val] = 0;
- columns [val] = 1;
- for (slot = 0; slot < MAX_CHILDREN_ON_ROW; slot++){
- if (range_empty (array, slot, child->lower_row, child->rows_used)){
- /*
- printf ("Child %d uses %d-%d allocates slot=%d\n", val, child->lower_row,
- child->lower_row + child->rows_used, slot);
- */
-
- range_allocate (array, slot, child->lower_row, child->rows_used, val);
- allocations [val] = slot;
- columns [val] = 1;
- if (slot+1 > top_slot)
- top_slot = slot+1;
- break;
- }
- }
- }
-#if DEBUGME
- for (val = 0; val < 48; val++){
- int j;
-
- printf ("%d: ", val);
- for (j = 0; j < top_slot; j++){
- printf (" %d", xy (array, j, val));
- }
- printf ("\n");
- }
-#endif
- /* Expand */
- val = 1;
- for (children = fullday->children; children; children = children->next, val++){
- Child *child = children->data;
-
- cols = can_expand (array, allocations, top_slot, val, child->lower_row, child->rows_used);
- /* printf ("Can expand regresa: %d\n", cols); */
- if (!cols)
- continue;
- expand_space (array, allocations, val, child->lower_row, child->rows_used, cols);
- columns [val] += cols;
- }
-
- /* Assign the spaces */
- widget = GTK_WIDGET (fullday);
- left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday);
-
- usable_pixels = widget->allocation.width-left_x - widget->style->klass->xthickness;
- pixels_per_col = usable_pixels / top_slot;
- extra_pixels = usable_pixels % top_slot;
-
- val = 1;
- for (children = fullday->children; children; children = children->next, val++){
- Child *child = children->data;
-
- child->x = left_x + pixels_per_col * allocations [val];
- extra = (allocations [val] + columns [val] == top_slot) ? extra_pixels : 0;
- child->width = pixels_per_col * columns [val] + extra;
- child_set_size (child);
-
- /* printf ("Setting child %d to %d for %d pixels\n", val, allocations [val], columns [val]); */
- }
- g_free (allocations);
- g_free (columns);
-}
-
-guint
-gncal_full_day_get_type (void)
-{
- static guint full_day_type = 0;
-
- if (!full_day_type) {
- GtkTypeInfo full_day_info = {
- "GncalFullDay",
- sizeof (GncalFullDay),
- sizeof (GncalFullDayClass),
- (GtkClassInitFunc) gncal_full_day_class_init,
- (GtkObjectInitFunc) gncal_full_day_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- full_day_type = gtk_type_unique (gtk_container_get_type (), &full_day_info);
- }
-
- return full_day_type;
-}
-
-static void
-gncal_full_day_class_init (GncalFullDayClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- parent_class = gtk_type_class (gtk_container_get_type ());
-
- fullday_signals[RANGE_ACTIVATED] =
- gtk_signal_new ("range_activated",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GncalFullDayClass, range_activated),
- gtk_signal_default_marshaller,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, fullday_signals, LAST_SIGNAL);
-
- object_class->destroy = gncal_full_day_destroy;
-
- widget_class->map = gncal_full_day_map;
- widget_class->unmap = gncal_full_day_unmap;
- widget_class->realize = gncal_full_day_realize;
- widget_class->unrealize = gncal_full_day_unrealize;
- widget_class->draw = gncal_full_day_draw;
- widget_class->draw_focus = gncal_full_day_draw_focus;
- widget_class->size_request = gncal_full_day_size_request;
- widget_class->size_allocate = gncal_full_day_size_allocate;
- widget_class->button_press_event = gncal_full_day_button_press;
- widget_class->button_release_event = gncal_full_day_button_release;
- widget_class->motion_notify_event = gncal_full_day_motion;
- widget_class->expose_event = gncal_full_day_expose;
- widget_class->key_press_event = gncal_full_day_key_press;
- widget_class->focus_in_event = gncal_full_day_focus_in;
- widget_class->focus_out_event = gncal_full_day_focus_out;
-
- container_class->foreach = gncal_full_day_foreach;
-
- class->range_activated = range_activated;
-}
-
-static void
-gncal_full_day_init (GncalFullDay *fullday)
-{
- GTK_WIDGET_UNSET_FLAGS (fullday, GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (fullday, GTK_CAN_FOCUS);
-
- fullday->calendar = NULL;
-
- fullday->lower = 0;
- fullday->upper = 0;
- fullday->interval = 30; /* 30 minutes by default */
-
- fullday->children = NULL;
- fullday->drag_info = g_new0 (struct drag_info, 1);
-
- fullday->up_down_cursor = NULL;
- fullday->beam_cursor = NULL;
- fullday->recur_gc = NULL;
- fullday->bell_gc = NULL;
-}
-
-static void
-gncal_full_day_destroy (GtkObject *object)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (object));
-
- fullday = GNCAL_FULL_DAY (object);
-
- /* Unparent the children manually as we don't have a remove method */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- gtk_widget_unparent (child->widget);
- }
-
- g_list_free (fullday->children);
- g_free (fullday->drag_info);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-GtkWidget *
-gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- fullday = gtk_type_new (gncal_full_day_get_type ());
-
- fullday->calendar = calendar;
-
- gncal_full_day_set_bounds (fullday, lower, upper);
-
- return GTK_WIDGET (fullday);
-}
-
-static void
-gncal_full_day_map (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_show (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_map (fullday, children->data);
-}
-
-static void
-gncal_full_day_unmap (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_hide (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_unmap (fullday, children->data);
-}
-
-static void
-gncal_full_day_realize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-
- fullday->up_down_cursor = gdk_cursor_new (GDK_DOUBLE_ARROW);
- fullday->beam_cursor = gdk_cursor_new (GDK_XTERM);
-
- for (children = fullday->children; children; children = children->next)
- child_realize (fullday, children->data);
-
-}
-
-static void
-gncal_full_day_unrealize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- fullday = GNCAL_FULL_DAY (widget);
-
- for (children = fullday->children; children; children = children->next)
- child_unrealize (fullday, children->data);
-
- gdk_cursor_destroy (fullday->up_down_cursor);
- fullday->up_down_cursor = NULL;
-
- gdk_cursor_destroy (fullday->beam_cursor);
- fullday->beam_cursor = NULL;
-
- if (fullday->bell_gc)
- gdk_gc_destroy (fullday->bell_gc);
- if (fullday->recur_gc)
- gdk_gc_destroy (fullday->recur_gc);
-
- if (pixmap_bell){
- gdk_pixmap_unref (pixmap_bell);
- pixmap_bell = NULL;
- }
-
- if (pixmap_recur){
- gdk_pixmap_unref (pixmap_recur);
- pixmap_recur = NULL;
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-struct paint_info {
- GtkWidget *widget;
- struct drag_info *di;
- GdkRectangle *area;
- int x1, y1, width, height;
- int labels_width;
- int row_height;
- struct tm start_tm;
-};
-
-static void
-paint_row (GncalFullDay *fullday, int row, struct paint_info *p)
-{
- GdkRectangle rect, dest;
- GdkGC *left_gc, *right_gc, *text_gc;
- int begin_row, end_row;
- struct tm tm;
- char buf[40];
-
- begin_row = (day_begin * 60) / fullday->interval;
- end_row = (day_end * 60) / fullday->interval;
-
- /* See which GCs we will use */
-
- if ((p->di->sel_rows_used != 0)
- && (row >= p->di->sel_start_row)
- && (row < (p->di->sel_start_row + p->di->sel_rows_used))) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_SELECTED];
- right_gc = left_gc;
- text_gc = p->widget->style->fg_gc[GTK_STATE_SELECTED];
- } else if ((row < begin_row) || (row >= end_row)) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_ACTIVE];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- } else {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_PRELIGHT];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- }
-
- /* Left background and text */
-
- rect.x = p->x1;
- rect.y = p->y1 + row * p->row_height;
- rect.width = 2 * TEXT_BORDER + p->labels_width;
- rect.height = p->row_height - 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest)) {
- gdk_draw_rectangle (p->widget->window,
- left_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- tm = p->start_tm;
- tm.tm_min += row * fullday->interval;
- mktime (&tm);
-
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &tm);
- else
- strftime (buf, sizeof (buf), "%H:%M", &tm);
-
- gdk_draw_string (p->widget->window,
- p->widget->style->font,
- text_gc,
- rect.x + TEXT_BORDER,
- rect.y + TEXT_BORDER + p->widget->style->font->ascent,
- buf);
- }
-
- /* Right background */
-
- rect.x += rect.width + p->widget->style->klass->xthickness;
- rect.width = p->width - (rect.x - p->x1);
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_rectangle (p->widget->window,
- right_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Horizontal division at bottom of row */
-
- rect.x = p->x1;
- rect.y += rect.height;
- rect.width = p->width;
- rect.height = 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_line (p->widget->window,
- p->widget->style->black_gc,
- rect.x, rect.y,
- rect.x + rect.width - 1, rect.y);
-}
-
-static void
-paint_back (GncalFullDay *fullday, GdkRectangle *area)
-{
- struct paint_info p;
- int start_row, end_row;
- int i;
- GdkRectangle rect, dest, aarea;
- int f_rows;
- int draw_focus;
-
- p.widget = GTK_WIDGET (fullday);
- p.di = fullday->drag_info;
-
- if (!area) {
- area = &aarea;
-
- area->x = 0;
- area->y = 0;
- area->width = p.widget->allocation.width;
- area->height = p.widget->allocation.height;
- }
- p.area = area;
-
- p.x1 = p.widget->style->klass->xthickness;
- p.y1 = p.widget->style->klass->ythickness;
- p.width = p.widget->allocation.width - 2 * p.x1;
- p.height = p.widget->allocation.height - 2 * p.y1;
-
- p.labels_width = calc_labels_width (fullday);
- p.row_height = calc_row_height (fullday);
- get_tm_range (fullday, fullday->lower, fullday->upper, &p.start_tm, NULL, NULL, &f_rows);
-
- /* Frame shadow */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = p.widget->allocation.width;
- rect.height = p.widget->style->klass->ythickness;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
-
- if (!draw_focus) {
- rect.y = p.widget->allocation.height - rect.height;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.y = p.widget->style->klass->ythickness;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.widget->allocation.height - 2 * rect.y;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.x = p.widget->allocation.width - rect.width;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (draw_focus)
- gtk_widget_draw_focus (p.widget);
-
- /* Rows */
-
- start_row = (area->y - p.y1) / p.row_height;
- end_row = (area->y + area->height - 1 - p.y1) / p.row_height;
-
- if (end_row >= f_rows)
- end_row = f_rows - 1;
-
- for (i = start_row; i <= end_row; i++)
- paint_row (fullday, i, &p);
-
- /* Slack area at bottom of widget */
-
- rect.x = p.x1;
- rect.y = p.y1 + f_rows * p.row_height;
- rect.width = p.width;
- rect.height = p.height - (rect.y - p.y1);
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gdk_draw_rectangle (p.widget->window,
- p.widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Vertical division */
-
- rect.x = p.x1 + 2 * TEXT_BORDER + p.labels_width;
- rect.y = p.y1;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gtk_draw_vline (p.widget->style, p.widget->window,
- GTK_STATE_NORMAL,
- rect.y,
- rect.y + rect.height - 1,
- rect.x);
-}
-
-static void
-paint_back_rows (GncalFullDay *fullday, int start_row, int rows_used)
-{
- int row_height;
- int xthickness, ythickness;
- GtkWidget *widget;
- GdkRectangle area;
-
- widget = GTK_WIDGET (fullday);
-
- row_height = calc_row_height (fullday);
-
- xthickness = widget->style->klass->xthickness;
- ythickness = widget->style->klass->ythickness;
-
- area.x = xthickness;
- area.y = ythickness + start_row * row_height;
- area.width = widget->allocation.width - 2 * xthickness;
- area.height = rows_used * row_height;
-
- paint_back (fullday, &area);
-}
-
-static void
-gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
- GdkRectangle rect, dest;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (area != NULL);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- paint_back (fullday, area);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- rect.x = child->x;
- rect.y = child->y;
- rect.width = child->width;
- rect.height = child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- }
- }
-}
-
-static void
-gncal_full_day_draw_focus (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- if (GTK_WIDGET_HAS_FOCUS (widget))
- gdk_draw_rectangle (widget->window,
- widget->style->black_gc,
- FALSE,
- 0, 0,
- widget->allocation.width - 1,
- widget->allocation.height - 1);
-}
-
-static void
-gncal_full_day_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalFullDay *fullday;
- int labels_width;
- int rows;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (requisition != NULL);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- /* Border and min width */
-
- labels_width = calc_labels_width (fullday);
-
- requisition->width = 2 * widget->style->klass->xthickness + 4 * TEXT_BORDER + labels_width + MIN_WIDTH;
- requisition->height = 2 * widget->style->klass->ythickness;
-
- /* Rows */
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &rows);
-
- requisition->height += (rows * (2 * TEXT_BORDER + widget->style->font->ascent + widget->style->font->descent)
- + (rows - 1)); /* division lines */
-}
-
-static void
-gncal_full_day_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (allocation != NULL);
-
- widget->allocation = *allocation;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- layout_children (fullday);
-}
-
-static Child *
-find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
-{
- GList *children;
- Child *child;
- GtkWidget *owner;
-
- *on_text = FALSE;
-
- gdk_window_get_user_data (window, (gpointer *) &owner);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->window == window || child->decor_window == window)
- return child;
-
- if (child->widget == owner) {
- *on_text = TRUE;
- return child;
- }
- }
-
- return NULL;
-}
-
-static void
-draw_xor_rect (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- struct drag_info *di;
- int i;
- int row_height;
- int ythickness;
-
- widget = GTK_WIDGET (fullday);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_INVERT);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_INCLUDE_INFERIORS);
-
- ythickness = widget->style->klass->ythickness;
-
- di = fullday->drag_info;
-
- row_height = calc_row_height (fullday);
-
- for (i = 0; i < XOR_RECT_WIDTH; i++)
- gdk_draw_rectangle (widget->window,
- widget->style->white_gc,
- FALSE,
- di->child->x + i,
- di->child_start_row * row_height + ythickness + i,
- di->child->width - 2 * i - 1,
- di->child_rows_used * row_height - 2 - 2 * i);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_COPY);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN);
-}
-
-static int
-get_row_from_y (GncalFullDay *fullday, int y, int round)
-{
- GtkWidget *widget;
- int row_height;
- int f_rows;
- int ythickness;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- row_height = calc_row_height (fullday);
-
- widget = GTK_WIDGET (fullday);
-
- ythickness = widget->style->klass->ythickness;
-
- y -= ythickness;
-
- if (y < 0)
- y = 0;
- else if (y >= (f_rows * row_height))
- y = f_rows * row_height - 1;
-
- if (round)
- y += row_height / 2;
-
- y /= row_height;
-
- if (y > f_rows)
- y = f_rows; /* note that this is 1 more than the last row's index */
-
- return y;
-}
-
-static int
-button_1 (GncalFullDay *fullday, GdkEventButton *event)
-{
- GtkWidget *widget;
- Child *child;
- int on_text;
- struct drag_info *di;
- gint y;
- int row_height;
- int has_focus;
- int old_start_row, old_rows_used;
- int old_max;
- int paint_start_row, paint_rows_used;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- di->drag_mode = DRAG_SELECT;
-
- old_start_row = di->sel_start_row;
- old_rows_used = di->sel_rows_used;
-
- di->sel_click_row = get_row_from_y (fullday, event->y, FALSE);
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = 1;
-
- di->click_time = event->time;
-
- gdk_pointer_grab (widget->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- if (old_rows_used == 0) {
- paint_start_row = di->sel_start_row;
- paint_rows_used = di->sel_rows_used;
- } else {
- paint_start_row = MIN (old_start_row, di->sel_start_row);
- old_max = old_start_row + old_rows_used - 1;
- paint_rows_used = MAX (old_max, di->sel_start_row) - paint_start_row + 1;
- }
-
- paint_back_rows (fullday, paint_start_row, paint_rows_used);
-
- return TRUE;
- } else {
- /* Clicked on a child? */
-
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text || child->ico->recur)
- return FALSE;
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (has_focus) {
- if (event->y < HANDLE_SIZE)
- di->drag_mode = DRAG_SIZE_TOP;
- else if (event->y >= (child->height - HANDLE_SIZE))
- di->drag_mode = DRAG_SIZE_BOTTOM;
- else
- di->drag_mode = DRAG_MOVE;
- } else
- di->drag_mode = DRAG_MOVE;
-
- row_height = calc_row_height (fullday);
-
- di->child = child;
-
- di->child_click_y = event->y;
- di->child_start_row = child->lower_row;
- di->child_rows_used = child->rows_used;
-
- gdk_pointer_grab (child->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- draw_xor_rect (fullday);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static int
-button_3 (GncalFullDay *fullday, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- GtkWidget *widget;
- Child *child;
- int on_text;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- main_items[0].data = fullday;
-
- popup_menu (main_items, sizeof (main_items) / sizeof (main_items[0]), event);
-
- return TRUE;
- } else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text)
- return FALSE;
-
- child_popup_menu (fullday, child, event);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- switch (event->button) {
- case 1:
- return button_1 (fullday, event);
-
- case 3:
- return button_3 (fullday, event);
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-recompute_motion (GncalFullDay *fullday, int y)
-{
- struct drag_info *di;
- int f_rows;
- int row;
- int has_focus;
-
- di = fullday->drag_info;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- switch (di->drag_mode) {
- case DRAG_SELECT:
- row = get_row_from_y (fullday, y, FALSE);
-
- if (row >= f_rows)
- row = f_rows - 1;
-
- if (row < di->sel_click_row) {
- di->sel_start_row = row;
- di->sel_rows_used = di->sel_click_row - row + 1;
- } else {
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = row - di->sel_start_row + 1;
- }
-
- break;
-
- case DRAG_MOVE:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- row = get_row_from_y (fullday, y - di->child_click_y + (has_focus ? HANDLE_SIZE : 0), TRUE);
-
- if (row > (f_rows - di->child_rows_used))
- row = f_rows - di->child_rows_used;
-
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_TOP:
- row = get_row_from_y (fullday, y + HANDLE_SIZE, TRUE);
-
- if (row > (di->child_start_row + di->child_rows_used - 1))
- row = di->child_start_row + di->child_rows_used - 1;
-
- di->child_rows_used = (di->child_start_row + di->child_rows_used) - row;
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_BOTTOM:
- row = get_row_from_y (fullday, y - HANDLE_SIZE, TRUE);
-
- if (row <= di->child_start_row)
- row = di->child_start_row + 1;
- else if (row > f_rows)
- row = f_rows;
-
- di->child_rows_used = row - di->child_start_row;
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-get_time_from_rows (GncalFullDay *fullday, int start_row, int rows_used, time_t *t_lower, time_t *t_upper)
-{
- struct tm tm;
- int row_height;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, NULL);
-
- row_height = calc_row_height (fullday);
-
- tm.tm_min += fullday->interval * start_row;
- *t_lower = mktime (&tm);
-
- tm.tm_min += fullday->interval * rows_used;
- *t_upper = mktime (&tm);
-}
-
-static void
-update_from_drag_info (GncalFullDay *fullday)
-{
- struct drag_info *di;
- GtkWidget *widget;
-
- di = fullday->drag_info;
-
- widget = GTK_WIDGET (fullday);
-
- get_time_from_rows (fullday, di->child_start_row, di->child_rows_used,
- &di->child->ico->dtstart,
- &di->child->ico->dtend);
-
- child_range_changed (fullday, di->child);
-
- /* Notify calendar of change */
-
- gnome_calendar_object_changed (fullday->calendar, di->child->ico, CHANGE_DATES);
-}
-
-static gint
-gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int retval;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- retval = FALSE;
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- if ((event->time - di->click_time) < UNSELECT_TIMEOUT)
- di->sel_rows_used = 0;
- else
- recompute_motion (fullday, y);
-
- gdk_pointer_ungrab (event->time);
-
- paint_back_rows (fullday, di->sel_start_row, MAX (di->sel_rows_used, 1));
-
- retval = TRUE;
- break;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- gdk_pointer_ungrab (event->time);
-
- update_from_drag_info (fullday);
-
- di->child_rows_used = 0;
-
- retval = TRUE;
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- di->drag_mode = DRAG_NONE;
- di->child = NULL;
-
- return retval;
-}
-
-static gint
-gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int old_min, old_max;
- int new_min, new_max;
- int new_start_row, new_rows_used;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- old_min = di->sel_start_row;
- old_max = di->sel_start_row + di->sel_rows_used - 1;
-
- recompute_motion (fullday, y);
-
- new_min = di->sel_start_row;
- new_max = di->sel_start_row + di->sel_rows_used - 1;
-
- new_start_row = MIN (old_min, new_min);
- new_rows_used = MAX (old_max, new_max) - new_start_row + 1;
-
- paint_back_rows (fullday, new_start_row, new_rows_used);
-
- return TRUE;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- draw_xor_rect (fullday);
-
- return TRUE;
-
- default:
- g_assert_not_reached ();
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalFullDay *fullday;
- Child *child;
- int on_text;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (event->window == widget->window)
- paint_back (fullday, &event->area);
- else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (child && !on_text)
- child_draw (fullday, child, &event->area, event->window, FALSE);
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_key_press (GtkWidget *widget, GdkEventKey *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- GList *children;
- Child *child;
- gint pos;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0)
- return FALSE;
-
- if (event->keyval == GDK_Return) {
- gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals[RANGE_ACTIVATED]);
- return TRUE;
- }
-
- if (event->length > 0) {
- /* This means some printable key was pressed */
-
- gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals[RANGE_ACTIVATED]);
-
- /* Find the new child, which should hopefully be focused, and insert the keypress */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget)) {
- pos = gtk_text_get_length (GTK_TEXT (child->widget));
-
- gtk_editable_insert_text (GTK_EDITABLE (child->widget),
- event->string,
- event->length,
- &pos);
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_in (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_out (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static void
-gncal_full_day_foreach (GtkContainer *container, GtkCallback callback, gpointer callback_data)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (container));
- g_return_if_fail (callback != NULL);
-
- fullday = GNCAL_FULL_DAY (container);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- (*callback) (child->widget, callback_data);
- }
-}
-
-static gint
-child_compare_by_start (gconstpointer a, gconstpointer b)
-{
- const Child *ca = a;
- const Child *cb = b;
- time_t diff;
-
- diff = ca->start - cb->start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GncalFullDay *fullday = c;
- Child *child;
-
- child = child_new (fullday, start, end, obj);
- fullday->children = g_list_insert_sorted (fullday->children, child, child_compare_by_start);
-
- return 1;
-}
-
-void
-gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if (!fullday->calendar->cal)
- return;
-
- /* Try to find child that changed */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico)
- break;
- }
-
- /* If child was found and nothing but the summary changed, we can just paint the child and return */
-
- if (children && !(flags & ~CHANGE_SUMMARY)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- return;
- }
-
- /* We have to regenerate and layout our list of children */
-
- for (children = fullday->children; children; children = children->next)
- child_destroy (fullday, children->data);
-
- g_list_free (fullday->children);
-
- fullday->children = NULL;
-
- calendar_iterate (fullday->calendar->cal,
- fullday->lower,
- fullday->upper,
- fullday_add_children,
- fullday);
-
- layout_children (fullday);
-
- /* Realize and map children */
-
- for (children = fullday->children; children; children = children->next) {
- if (GTK_WIDGET_REALIZED (fullday))
- child_realize (fullday, children->data);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_map (fullday, children->data);
- }
-
- gtk_widget_draw (GTK_WIDGET (fullday), NULL);
-}
-
-void
-gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if ((lower != fullday->lower) || (upper != fullday->upper)) {
- fullday->lower = lower;
- fullday->upper = upper;
-
- di = fullday->drag_info;
-
- di->sel_rows_used = 0; /* clear selection */
-
- gncal_full_day_update (fullday, NULL, 0);
- }
-}
-
-int
-gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper)
-{
- struct drag_info *di;
- time_t alower, aupper;
-
- g_return_val_if_fail (fullday != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), FALSE);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0){
- time_t now = time (NULL);
- struct tm tm = *localtime (&now);
- struct tm thisd = *localtime (&fullday->lower);
-
- thisd.tm_hour = tm.tm_hour;
- thisd.tm_min = tm.tm_min;
- thisd.tm_sec = 0;
- *lower = mktime (&thisd);
- thisd.tm_hour++;
- *upper = mktime (&thisd);
- return FALSE;
- }
-
- get_time_from_rows (fullday, di->sel_start_row, di->sel_rows_used, &alower, &aupper);
-
- if (lower)
- *lower = alower;
-
- if (upper)
- *upper= aupper;
-
- return TRUE;
-}
-
-void
-gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico)
-{
- GList *children;
- Child *child;
- GdkEvent event;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (ico != NULL);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico) {
- gtk_widget_grab_focus (child->widget);
-
- /* We synthesize a click because GtkText will not set the cursor and
- * the user will not be able to type-- this has to be fixed in
- * GtkText. */
-
- memset (&event, 0, sizeof (event));
-
- event.type = GDK_BUTTON_PRESS;
- event.button.window = child->widget->window;
- event.button.time = GDK_CURRENT_TIME;
- event.button.x = 0;
- event.button.y = 0;
- event.button.button = 1;
-
- gtk_widget_event (child->widget, &event);
-
- break;
- }
- }
-}
-
-int
-gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- int begin_row;
-
- g_return_val_if_fail (fullday != NULL, 0);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), 0);
-
- widget = GTK_WIDGET (fullday);
-
- begin_row = (day_begin * 60) / fullday->interval;
-
- return widget->style->klass->ythickness + begin_row * calc_row_height (fullday);
-}
-
-static void
-range_activated (GncalFullDay *fullday)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- di = fullday->drag_info;
-
- /* Remove selection; at this point someone should already have added an appointment */
-
- di->sel_rows_used = 0;
-
- paint_back (fullday, NULL);
-}
diff --git a/calendar/gui/gncal-full-day.h b/calendar/gui/gncal-full-day.h
deleted file mode 100644
index 287c5f63f6..0000000000
--- a/calendar/gui/gncal-full-day.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_FULL_DAY_H
-#define GNCAL_FULL_DAY_H
-
-
-#include <gtk/gtkcontainer.h>
-#include <libgnome/gnome-defs.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_FULL_DAY(obj) GTK_CHECK_CAST (obj, gncal_full_day_get_type (), GncalFullDay)
-#define GNCAL_FULL_DAY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_full_day_get_type (), GncalFullDayClass)
-#define GNCAL_IS_FULL_DAY(obj) GTK_CHECK_TYPE (obj, gncal_full_day_get_type ())
-
-
-typedef struct _GncalFullDay GncalFullDay;
-typedef struct _GncalFullDayClass GncalFullDayClass;
-
-struct _GncalFullDay {
- GtkContainer container;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t lower; /* lower time to display */
- time_t upper; /* upper time to display */
- int interval; /* interval between rows in minutes */
-
- GList *children; /* container children */
- gpointer drag_info; /* internal drag information */
-
- GdkCursor *up_down_cursor; /* for dragging children */
- GdkCursor *beam_cursor; /* for the text widgets */
- GdkGC *recur_gc; /* The gc used to draw the recur image */
- GdkGC *bell_gc; /* The gc used to draw on imlib windows */
-
-};
-
-struct _GncalFullDayClass {
- GtkContainerClass parent_class;
-
- void (* range_activated) (GncalFullDay *fullday);
-};
-
-
-guint gncal_full_day_get_type (void);
-GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags);
-void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper);
-
-/* Returns the selected range in lower and upper. If nothing is
- * selected, return value is FALSE, otherwise it is TRUE.
- * The lower and upper values are always set to proper values, regardless of
- * the selection value
- */
-int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper);
-
-void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico);
-
-int gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c
deleted file mode 100644
index d527d6ff09..0000000000
--- a/calendar/gui/gncal-todo.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/* 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 "gncal-todo.h"
-#include "main.h"
-#include "popup-menu.h"
-
-
-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)
-{
- iCalObject *ico;
- GncalTodo *todo;
- GtkEntry *entry;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo"));
- entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry"));
-
- if (ico->summary)
- g_free (ico->summary);
-
- ico->summary = g_strdup (gtk_entry_get_text (entry));
- ico->user_data = NULL;
-
- if (ico->new) {
- gnome_calendar_add_object (todo->calendar, ico);
- ico->new = FALSE;
- } else
- gnome_calendar_object_changed (todo->calendar, ico, CHANGE_ALL); /* ok, summary only... */
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
-cancel_button (GtkWidget *widget, GnomeDialog *dialog)
-{
- iCalObject *ico;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- ico->user_data = NULL;
-
- if (ico->new)
- ical_object_destroy (ico);
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static gint
-delete_event (GtkWidget *widget, GdkEvent *event, GnomeDialog *dialog)
-{
- cancel_button (NULL, dialog);
- return TRUE;
-}
-
-static void
-simple_todo_editor (GncalTodo *todo, iCalObject *ico)
-{
- GtkWidget *dialog;
- GtkWidget *hbox;
- GtkWidget *w;
- GtkWidget *entry;
-
- dialog = gnome_dialog_new (ico->new ? _("Create to-do item") : _("Edit to-do item"),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
-
- 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);
-
- w = gtk_label_new (_("Summary:"));
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- entry = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (entry), ico->summary);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_show (entry);
-
- ico->user_data = dialog;
-
- gtk_object_set_user_data (GTK_OBJECT (dialog), ico);
-
- gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo);
- gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry);
-
- 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 iCalObject *
-get_clist_selected_ico (GtkCList *clist)
-{
- gint sel;
-
- if (!clist->selection)
- return NULL;
-
- sel = (gint) clist->selection->data;
-
- return gtk_clist_get_row_data (clist, sel);
-}
-
-static void
-add_todo (GncalTodo *todo)
-{
- iCalObject *ico;
-
- ico = ical_new ("", user_name, "");
- ico->type = ICAL_TODO;
- ico->new = TRUE;
-
- simple_todo_editor (todo, ico);
-}
-
-static void
-edit_todo (GncalTodo *todo)
-{
- simple_todo_editor (todo, get_clist_selected_ico (todo->clist));
-}
-
-static void
-delete_todo (GncalTodo *todo)
-{
- gnome_calendar_remove_object (todo->calendar, get_clist_selected_ico (todo->clist));
-}
-
-static void
-add_activated (GtkWidget *widget, GncalTodo *todo)
-{
- add_todo (todo);
-}
-
-static void
-edit_activated (GtkWidget *widget, GncalTodo *todo)
-{
- 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;
-
- 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;
- }
-}
-
-static void
-gncal_todo_init (GncalTodo *todo)
-{
- GtkWidget *w;
- GtkWidget *hbox;
-
- 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 */
-
- w = gtk_clist_new (1);
- todo->clist = GTK_CLIST (w);
-
- gtk_clist_set_policy (todo->clist, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- 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_box_pack_start (GTK_BOX (todo), w, TRUE, TRUE, 0);
- 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 void
-insert_in_clist (GncalTodo *todo, iCalObject *ico)
-{
- int i;
- char *text[1] = { ico->summary };
- iCalObject *row_ico;
-
- if (ico->priority == 0)
- i = gtk_clist_append (todo->clist, text); /* items with undefined priority go to the end of the list */
- else {
-
- /* Find proper place in clist to insert object. Objects are sorted by priority. */
-
- for (i = 0; i < todo->clist->rows; i++) {
- row_ico = gtk_clist_get_row_data (todo->clist, i);
-
- if (ico->priority >= row_ico->priority)
- break;
- }
-
- gtk_clist_insert (todo->clist, i, text);
- }
-
- /* Set the appropriate "done" icon and hook the object to the row */
-
- gtk_clist_set_row_data (todo->clist, i, ico);
-}
-
-void
-gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
-{
- GList *list;
-
- g_return_if_fail (todo != NULL);
- g_return_if_fail (GNCAL_IS_TODO (todo));
-
- gtk_clist_freeze (todo->clist);
-
- gtk_clist_clear (todo->clist);
-
- for (list = todo->calendar->cal->todo; list; list = list->next)
- insert_in_clist (todo, list->data);
-
- gtk_clist_thaw (todo->clist);
-
- gtk_widget_set_sensitive (todo->edit_button, (todo->clist->rows > 0));
- gtk_widget_set_sensitive (todo->delete_button, (todo->clist->rows > 0));
-}
diff --git a/calendar/gui/gncal-todo.h b/calendar/gui/gncal-todo.h
deleted file mode 100644
index cb32c25421..0000000000
--- a/calendar/gui/gncal-todo.h
+++ /dev/null
@@ -1,52 +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;
-};
-
-struct _GncalTodoClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_todo_get_type (void);
-GtkWidget *gncal_todo_new (GnomeCalendar *calendar);
-
-void gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
deleted file mode 100644
index 0e280163d9..0000000000
--- a/calendar/gui/gncal-week-view.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <config.h>
-#include <string.h>
-#include "gncal-week-view.h"
-#include "timeutil.h"
-
-static void gncal_week_view_init (GncalWeekView *wview);
-
-
-guint
-gncal_week_view_get_type (void)
-{
- static guint week_view_type = 0;
-
- if (!week_view_type) {
- GtkTypeInfo week_view_info = {
- "GncalWeekView",
- sizeof (GncalWeekView),
- sizeof (GncalWeekViewClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_week_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- week_view_type = gtk_type_unique (gtk_vbox_get_type (), &week_view_info);
- }
-
- return week_view_type;
-}
-
-static void
-gncal_week_view_init (GncalWeekView *wview)
-{
- int i;
-
- wview->calendar = NULL;
- memset (&wview->start_of_week, 0, sizeof (wview->start_of_week));
-
- for (i = 0; i < 7; i++)
- wview->days[i] = NULL;
-
- wview->gtk_calendar = NULL;
-}
-
-static void
-jump_to_day (GtkCalendar *cal, GncalWeekView *wview, int day)
-{
- struct tm tm;
- time_t t;
- static int inside;
-
- if (inside)
- return;
- inside = 1;
- tm.tm_mday = day;
- tm.tm_mon = cal->month;
- tm.tm_year = cal->year - 1900;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- t = mktime (&tm);
-
- gncal_week_view_set (wview, t);
- inside = 0;
-}
-
-static void
-jump_to_day_click (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, cal->selected_day);
-}
-
-static void
-sync_week (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, wview->start_of_week.tm_mday + 7);
- gnome_calendar_tag_calendar (wview->calendar, wview->gtk_calendar);
-}
-
-static void
-double_click_on_weekday (GtkWidget *widget, GdkEvent *e, GncalWeekView *wview)
-{
-}
-
-GtkWidget *
-gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
-{
- GncalWeekView *wview;
- GtkWidget *table;
- int i;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- wview = gtk_type_new (gncal_week_view_get_type ());
-
- table = gtk_table_new (0, 0, 0);
- gtk_table_set_homogeneous (GTK_TABLE (table), TRUE);
- wview->label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (wview), wview->label, 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (wview), table, 1, 1, 0);
- wview->calendar = calendar;
- for (i = 0; i < 7; i++) {
- wview->days[i] = GNCAL_DAY_VIEW (gncal_day_view_new (calendar, 0, 0));
- gtk_signal_connect (GTK_OBJECT (wview->days [i]), "button_press_event",
- GTK_SIGNAL_FUNC(double_click_on_weekday), wview);
-
- if (i < 5)
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i, i + 1,
- 0, 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- else
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i - 2, i - 1,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- gtk_widget_show (GTK_WIDGET (wview->days[i]));
- }
-
- wview->gtk_calendar = GTK_CALENDAR (gtk_calendar_new ());
-
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "day_selected_double_click",
- GTK_SIGNAL_FUNC(jump_to_day_click), wview);
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC(sync_week), wview);
-
- gtk_calendar_display_options (wview->gtk_calendar,
- GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->gtk_calendar),
- 0, 3,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 4, 4);
- gtk_widget_show (GTK_WIDGET (wview->gtk_calendar));
-
- gncal_week_view_set (wview, start_of_week);
-
- return GTK_WIDGET (wview);
-}
-
-static void
-update (GncalWeekView *wview, int update_days, iCalObject *object, int flags)
-{
- int i;
-
- if (update_days)
- for (i = 0; i < 7; i++)
- gncal_day_view_update (wview->days[i], object, flags);
-
- /* FIXME: update extra widgets */
-}
-
-void
-gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- update (wview, TRUE, ico, flags);
-}
-
-void
-gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
-{
- struct tm tm;
- time_t day_start, day_end, week_start, week_end;
- int i;
-
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- tm = *localtime (&start_of_week);
-
- /* back up to start of week (Monday) */
-
- tm.tm_mday -= (tm.tm_wday == 0) ? 6 : (tm.tm_wday - 1);
-
- /* Start of day */
-
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- day_start = week_start = mktime (&tm);
-
- /* Calendar */
-
- gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- /* Day views */
-
- for (i = 0; i < 7; i++) { /* rest of days */
- tm.tm_mday++;
- day_end = mktime (&tm);
-
- gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
-
- day_start = day_end;
- }
-
- update (wview, FALSE, NULL, 0);
-
- /* The label */
- {
- char buf [80];
- int len;
- struct tm *t;
-
- week_end = time_add_day (week_start, 6);
- t = localtime (&week_start);
-
- strftime (buf, sizeof (buf), "%A %d %Y - ", t);
- len = strlen (buf);
-
- t = localtime (&week_end);
- strftime (buf + len, sizeof (buf) - len, "%A %d %Y", t);
- gtk_label_set (GTK_LABEL (wview->label), buf);
-
- }
-}
-
diff --git a/calendar/gui/gncal-week-view.h b/calendar/gui/gncal-week-view.h
deleted file mode 100644
index 1514890504..0000000000
--- a/calendar/gui/gncal-week-view.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef WEEK_VIEW_H
-#define WEEK_VIEW_H
-
-
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gtkcalendar.h>
-#include "gnome-cal.h"
-#include "gncal-day-view.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_WEEK_VIEW(obj) GTK_CHECK_CAST (obj, gncal_week_view_get_type (), GncalWeekView)
-#define GNCAL_WEEK_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_week_view_get_type (), GncalWeekViewClass)
-#define GNCAL_IS_WEEK_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_week_view_get_type ())
-
-
-typedef struct _GncalWeekView GncalWeekView;
-typedef struct _GncalWeekViewClass GncalWeekViewClass;
-
-struct _GncalWeekView {
- GtkVBox box;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- struct tm start_of_week;
-
- GncalDayView *days[7]; /* the day view widgets */
- GtkCalendar *gtk_calendar; /* At least for now; see the FIXME comments in the .c file */
- GtkWidget *label;
-};
-
-struct _GncalWeekViewClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_week_view_get_type (void);
-GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week);
-
-void gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags);
-void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal.desktop b/calendar/gui/gncal.desktop
deleted file mode 100644
index 434997de04..0000000000
--- a/calendar/gui/gncal.desktop
+++ /dev/null
@@ -1,17 +0,0 @@
-[Desktop Entry]
-Name=Calendar
-Name[es]=Calendario
-Name[fr]=Calendrier
-Name[de]=Kalender
-Name[no]=Kalender
-Name[pt]=Agenda
-Comment=Calendar application
-Comment[es]=Calendario de Gnome
-Comment[fr]=Calendrier Gnome
-Comment[de]=Gnome Kalender
-Comment[no]=Gnome Kalender
-Comment[pt]=Agenda Gnome
-Exec=gnomecal
-Icon=gnome-calendar.png
-Terminal=0
-Type=Application
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
deleted file mode 100644
index 234f782fa3..0000000000
--- a/calendar/gui/gnome-cal.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-#include "gncal-day-panel.h"
-#include "gncal-week-view.h"
-#include "gncal-year-view.h"
-#include "month-view.h"
-#include "timeutil.h"
-#include "views.h"
-#include "main.h"
-
-GnomeApp *parent_class;
-
-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) NULL,
- (GtkObjectInitFunc) NULL,
- (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());
- }
- return gnome_calendar_type;
-}
-
-static void
-setup_widgets (GnomeCalendar *gcal)
-{
- time_t now;
-
- now = time (NULL);
-
- gcal->notebook = gtk_notebook_new ();
- gcal->day_view = gncal_day_panel_new (gcal, now);
- gcal->week_view = gncal_week_view_new (gcal, now);
- gcal->month_view = month_view_new (gcal);
- gcal->year_view = gncal_year_view_new (gcal, now);
- gcal->task_view = tasks_create (gcal);
-
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->month_view, gtk_label_new (_("Month View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
-/* gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo"))); */
-
- gtk_widget_show_all (gcal->notebook);
-
- gnome_app_set_contents (GNOME_APP (gcal), gcal->notebook);
-
-}
-
-static GtkWidget *
-get_current_page (GnomeCalendar *gcal)
-{
- return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
-}
-
-char *
-gnome_calendar_get_current_view_name (GnomeCalendar *gcal)
-{
- GtkWidget *page = get_current_page (gcal);
-
- if (page == gcal->day_view)
- return "dayview";
- else if (page == gcal->week_view)
- return "weekview";
- else if (page == gcal->year_view)
- return "yearview";
- else
- return "dayview";
-}
-
-void
-gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
-{
- GtkWidget *current = get_current_page (gcal);
-
- g_return_if_fail (new_time != -1);
-
- new_time = time_start_of_day (new_time);
-
- if (current == gcal->day_view)
- gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time);
- else if (current == gcal->week_view)
- gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
- else if (current == gcal->year_view)
- gncal_year_view_set (GNCAL_YEAR_VIEW (gcal->year_view), new_time);
- else {
- g_warning ("My penguin is gone!");
- g_assert_not_reached ();
- }
-
- gcal->current_display = new_time;
-}
-
-static void
-gnome_calendar_direction (GnomeCalendar *gcal, int direction)
-{
- GtkWidget *cp = get_current_page (gcal);
- time_t new_time;
-
- if (cp == gcal->day_view)
- new_time = time_add_day (gcal->current_display, 1 * direction);
- else if (cp == gcal->week_view)
- new_time = time_add_day (gcal->current_display, 7 * direction);
- else if (cp == gcal->year_view)
- new_time = time_add_year (gcal->current_display, 1 * direction);
- else {
- g_warning ("Weee! Where did the penguin go?");
- g_assert_not_reached ();
- new_time = 0;
- }
-
- gnome_calendar_goto (gcal, new_time);
-}
-
-void
-gnome_calendar_next (GnomeCalendar *gcal)
-{
- gnome_calendar_direction (gcal, 1);
-}
-
-void
-gnome_calendar_previous (GnomeCalendar *gcal)
-{
- gnome_calendar_direction (gcal, -1);
-}
-
-void
-gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
-{
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), 0);
- gnome_calendar_goto (gcal, time);
-}
-
-void
-gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name)
-{
- int page = 0;
-
- if (strcmp (page_name, "dayview") == 0)
- page = 0;
- else if (strcmp (page_name, "weekview") == 0)
- page = 1;
- else if (strcmp (page_name, "yearview") == 0)
- page = 2;
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), page);
-}
-
-GtkWidget *
-gnome_calendar_new (char *title)
-{
- GtkWidget *retval;
- GnomeCalendar *gcal;
- GnomeApp *app;
-
- retval = gtk_type_new (gnome_calendar_get_type ());
- app = GNOME_APP (retval);
- gcal = GNOME_CALENDAR (retval);
-
- app->name = g_strdup ("calendar");
- app->prefix = g_copy_strings ("/", app->name, "/", NULL);
-
- gtk_window_set_title(GTK_WINDOW(retval), title);
-
- gcal->current_display = time_start_of_day (time (NULL));
- gcal->cal = calendar_new (title);
- setup_widgets (gcal);
- return retval;
-}
-
-static void
-gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
-{
- gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags);
- gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags);
- gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags);
-}
-
-int
-gnome_calendar_load (GnomeCalendar *gcal, char *file)
-{
- char *r;
-
- if ((r = calendar_load (gcal->cal, file)) != NULL){
- printf ("Error loading calendar: %s\n", r);
- return 0;
- }
- gnome_calendar_update_all (gcal, NULL, 0);
- return 1;
-}
-
-void
-gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- calendar_add_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
-}
-
-void
-gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- calendar_remove_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_ALL);
-}
-
-void
-gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- gcal->cal->modified = TRUE;
-
- gnome_calendar_update_all (gcal, obj, flags);
- calendar_object_changed (gcal->cal, obj, flags);
-}
-
-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
-}
-
-static void
-execute (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);
-}
-
-void
-mail_notify (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_copy_strings ("To: ", mail_address, "\n",
- "Subject: ", _("Reminder of your appointment at "),
- ctime (&app_time), "\n\n", text, "\n", NULL);
- write (p [1], command, strlen (command));
-
- g_free (command);
-}
-
-void
-calendar_notify (time_t time, void *data)
-{
- iCalObject *ico = data;
-
- if (ico->aalarm.enabled && ico->aalarm.trigger == time){
- printf ("bip\n");
- return;
- }
-
- if (ico->palarm.enabled && ico->palarm.trigger == time){
- execute (ico->palarm.data, 0);
- return;
- }
-
- if (ico->malarm.enabled && ico->malarm.trigger == time){
- time_t app = ico->malarm.trigger + ico->malarm.offset;
-
- mail_notify (ico->malarm.data, ico->summary, app);
- return;
- }
-
- if (ico->dalarm.enabled && ico->dalarm.trigger == time){
- time_t app = ico->dalarm.trigger + ico->dalarm.offset;
- GtkWidget *w;
- char *msg;
-
- msg = g_copy_strings (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, "Ok", NULL);
- gtk_widget_show (w);
- return;
- }
-}
-
-/*
- * called from the calendar_iterate routine to mark the days of a GtkCalendar
- */
-static int
-mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GtkCalendar *gtk_cal = c;
- struct tm tm_s;
- time_t t, day_end;
-
- tm_s = *localtime (&start);
- day_end = time_end_of_day (end);
-
- for (t = start; t <= day_end; t += 60*60*24){
- time_t new = mktime (&tm_s);
- struct tm tm_day;
-
- tm_day = *localtime (&new);
- gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday);
- tm_s.tm_mday++;
- }
- return TRUE;
-}
-
-/*
- * Tags the dates with appointments in a GtkCalendar based on the
- * GnomeCalendar contents
- */
-void
-gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
-{
- time_t month_begin, month_end;
- struct tm tm;
-
- /* compute month_begin */
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday = 0;
- tm.tm_mon = gtk_cal->month;
- tm.tm_year = gtk_cal->year - 1900;
- tm.tm_isdst= -1;
-
- month_begin = mktime (&tm);
- tm.tm_mon++;
- month_end = mktime (&tm);
-
- gtk_calendar_freeze (gtk_cal);
- gtk_calendar_clear_marks (gtk_cal);
- calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal);
- gtk_calendar_thaw (gtk_cal);
-}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
deleted file mode 100644
index ec1290a652..0000000000
--- a/calendar/gui/gnome-cal.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef GNOME_CALENDAR_APP_H
-#define GNOME_CALENDAR_APP_H
-
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gnome-app.h>
-#include <libgnomeui/gtkcalendar.h>
-
-#include "calendar.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())
-
-typedef struct {
- GnomeApp gnome_app;
- Calendar *cal;
- time_t current_display;
-
- GtkWidget *notebook;
- GtkWidget *day_view;
- GtkWidget *week_view;
- GtkWidget *month_view;
- GtkWidget *year_view;
- GtkWidget *task_view;
- void *event_editor;
-} GnomeCalendar;
-
-typedef struct {
- GnomeAppClass parent_class;
-} GnomeCalendarClass;
-
-guint gnome_calendar_get_type (void);
-GtkWidget *gnome_calendar_new (char *title);
-int gnome_calendar_load (GnomeCalendar *gcal,
- char *file);
-void gnome_calendar_add_object (GnomeCalendar *gcal,
- iCalObject *obj);
-void gnome_calendar_remove_object (GnomeCalendar *gcal,
- iCalObject *obj);
-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);
-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);
-
-/* Flags is a bitmask of CalObjectChange values */
-void gnome_calendar_object_changed (GnomeCalendar *gcal,
- iCalObject *obj,
- int flags);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gnome-cal.html b/calendar/gui/gnome-cal.html
deleted file mode 100644
index eeb8d4e25e..0000000000
--- a/calendar/gui/gnome-cal.html
+++ /dev/null
@@ -1,42 +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.
-</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-month-item.c b/calendar/gui/gnome-month-item.c
deleted file mode 100644
index 9b00d4d3c8..0000000000
--- a/calendar/gui/gnome-month-item.c
+++ /dev/null
@@ -1,832 +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"
-
-
-/* These are indices into the items array of a GnomeMonthItem structure */
-enum {
- ITEM_HEAD_GROUP = 0, /* 7 groups */
- ITEM_HEAD_BOX = 7, /* 7 boxes */
- ITEM_HEAD_LABEL = 14, /* 7 labels */
- ITEM_DAY_GROUP = 21, /* 42 groups */
- ITEM_DAY_BOX = 63, /* 42 boxes */
- ITEM_DAY_LABEL = 105 /* 42 labels */
-};
-
-
-/* Number of days in a month, for normal and leap years */
-static 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 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
-};
-
-
-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::head_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_READABLE, 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);
-
- 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;
-}
-
-/* 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[ITEM_HEAD_GROUP + i],
- "x", width * i,
- "y", 0.0,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[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[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[ITEM_DAY_GROUP + i],
- "x", width * col,
- "y", mitem->head_height + height * row,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[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[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)
-{
- reshape_headings (mitem);
- reshape_days (mitem);
-}
-
-/* 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[ITEM_HEAD_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[ITEM_HEAD_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_HEAD_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "fill_color", "black",
- NULL);
-
- /* Label */
- mitem->items[ITEM_HEAD_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_HEAD_GROUP + i]),
- gnome_canvas_text_get_type (),
- "fill_color", "white",
- "font", "-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1",
- NULL);
- }
-}
-
-/* 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 *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);
-
- 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, ofs;
- int days[42];
- int start, end;
- char buf[100];
-
- build_month (mitem->month, mitem->year, days, &start, &end);
-
- if (mitem->start_on_monday)
- ofs = (start + 6) % 7;
- else
- ofs = start;
-
- /* Clear days before start of month */
-
- for (i = 0; i < ofs; i++)
- gnome_canvas_item_set (mitem->items[ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-
- /* Set days of month */
-
- for (; start <= end; start++, i++) {
- sprintf (buf, "%d", days[start]);
- gnome_canvas_item_set (mitem->items[ITEM_DAY_LABEL + i],
- "text", buf,
- NULL);
- }
-
- /* Clear days after end of month */
-
- for (; i < 42; i++)
- gnome_canvas_item_set (mitem->items[ITEM_DAY_LABEL + i],
- "text", NULL,
- 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[ITEM_DAY_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[ITEM_DAY_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_DAY_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "outline_color", "black",
- "fill_color", "#d6d6d6",
- NULL);
-
- /* Label */
- mitem->items[ITEM_DAY_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[ITEM_DAY_GROUP + i]),
- gnome_canvas_text_get_type (),
- "fill_color", "black",
- "font", "-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1",
- NULL);
- }
-
- 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[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)
-{
- /* 7 heading groups
- * 7 heading boxes
- * 7 heading labels
- * 42 day groups
- * 42 day boxes
- * 42 day labels
- * ------------------
- * 147 items total
- */
-
- mitem->items = g_new (GnomeCanvasItem *, 147);
-
- create_headings (mitem);
- create_days (mitem);
-
- /* Initialize by default to three-letter day names */
-
- mitem->day_names[0] = _("Sun");
- mitem->day_names[1] = _("Mon");
- mitem->day_names[2] = _("Tue");
- mitem->day_names[3] = _("Wed");
- mitem->day_names[4] = _("Thu");
- mitem->day_names[5] = _("Fri");
- mitem->day_names[6] = _("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;
-}
-
-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)
-{
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
-
- 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);
-}
-
-/* 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);
-}
-
-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));
- reanchor (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEIGHT:
- mitem->height = fabs (GTK_VALUE_DOUBLE (*arg));
- reanchor (mitem);
- 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);
- 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;
-
- default:
- break;
- }
-}
-
-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;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
diff --git a/calendar/gui/gnome-month-item.h b/calendar/gui/gnome-month-item.h
deleted file mode 100644
index f6523aff94..0000000000
--- a/calendar/gui/gnome-month-item.h
+++ /dev/null
@@ -1,71 +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
-
-
-#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 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);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
deleted file mode 100644
index a21e162e00..0000000000
--- a/calendar/gui/goto.c
+++ /dev/null
@@ -1,230 +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 "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-static void
-highlight_current_day (GnomeMonthItem *mitem)
-{
- struct tm *tm;
- time_t t;
-
- t = time (NULL);
- tm = localtime (&t);
-
- if ((mitem->year == (tm->tm_year + 1900)) && (mitem->month == tm->tm_mon)) {
- ;
- /* FIXME */
- }
-}
-
-/* Callback used when the year adjustment is changed */
-static void
-year_changed (GtkAdjustment *adj, GtkWidget *dialog)
-{
- GnomeCanvasItem *mitem;
-
- mitem = gtk_object_get_data (GTK_OBJECT (dialog), "month_item");
- gnome_canvas_item_set (mitem,
- "year", (int) adj->value,
- NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
-}
-
-/* Creates the year control with its adjustment */
-static GtkWidget *
-create_year (GtkWidget *dialog, GnomeCalendar *gcal, 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,
- dialog);
-
- 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)
-{
- GtkWidget *dialog;
- GnomeCanvasItem *mitem;
-
- if (!toggle->active)
- return;
-
- dialog = gtk_object_get_user_data (GTK_OBJECT (toggle));
- mitem = gtk_object_get_data (GTK_OBJECT (dialog), "month_item");
- gnome_canvas_item_set (mitem,
- "month", GPOINTER_TO_INT (data),
- NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
-}
-
-/* Creates the months control */
-static GtkWidget *
-create_months (GtkWidget *dialog, GnomeCalendar *gcal, int month)
-{
- GtkWidget *table;
- GtkWidget *w;
- GSList *group;
- int i, row, col;
- struct tm tm;
- char buf[100];
-
- tm = *localtime (&gcal->current_display);
-
- 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_object_set_user_data (GTK_OBJECT (w), dialog);
- 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, gpointer data)
-{
- gnome_canvas_item_set (data,
- "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);
-}
-
-/* Creates the canvas with the month item for selecting days */
-static GtkWidget *
-create_days (GtkWidget *dialog, GnomeCalendar *gcal, int day, int month, int year)
-{
- GtkWidget *canvas;
- GnomeCanvasItem *mitem;
-
- canvas = gnome_canvas_new ();
- gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120);
-
- mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas)->root));
- gnome_canvas_item_set (mitem,
- "month", month,
- "year", year,
- NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
-
- gtk_object_set_data (GTK_OBJECT (dialog), "month_item", mitem);
-
- /* 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,
- mitem);
-
- return canvas;
-}
-
-/* Creates a "goto date" dialog and runs it */
-void
-goto_dialog (GnomeCalendar *gcal)
-{
- GtkWidget *dialog;
- GtkWidget *vbox;
- GtkWidget *w;
- struct tm *tm;
-
- tm = localtime (&gcal->current_display);
-
- dialog = gnome_dialog_new (_("Go to date"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
-
- vbox = GNOME_DIALOG (dialog)->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);
-
- /* Year */
-
- w = create_year (dialog, gcal, tm->tm_year + 1900);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Month */
-
- w = create_months (dialog, gcal, tm->tm_mon);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Days (canvas with month item) */
-
- w = create_days (dialog, gcal, tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
- gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-
- /* Run! */
-
- gnome_dialog_set_modal (GNOME_DIALOG (dialog));
-
- printf ("el dialogo regreso %d\n", gnome_dialog_run_and_destroy (GNOME_DIALOG (dialog)));
-}
diff --git a/calendar/gui/icalendar-types b/calendar/gui/icalendar-types
deleted file mode 100644
index e11f4c1789..0000000000
--- a/calendar/gui/icalendar-types
+++ /dev/null
@@ -1,39 +0,0 @@
-evento todo journal fbrequest fbreply busytime timezone
- attach attach attach
- attendee attendee attendee attendee attendee attendee
- categories categories categories
- class class class
- comment comment comment comment comment comment comment
- completed
- contact contact contact
- created created created created
- description description description
- dtstamp dtstamp
- dtend/duration due->dtend dtend [duration] dtend dtend
- dtstart dtstart dtstart dtstart dtstart dtstart dtstart
- exdate exdate exdate
- exrule exrule exrule
- geo geo
- last-mod last-mod last-mod last-mod last-mod
- location location
- organizer organizer organizer
- percent
- priority priority
- rstatus rstatus rstatus rstatus
- related related related
- resources resources
- rdate rdate rdate [rdate/rrule]
- rrule rrule rrule
- dtstamp dtstamp dtstamp dtstamp
- seq seq seq seq seq
- status status
- summary summary summary
- transp
- uid uid uid uid uid
- url url url url url
- recurid recurid recurid
- freebusy freebusy
- tzname
- tzoffset-to
- tzoffset-from
-
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
deleted file mode 100644
index ebb008927f..0000000000
--- a/calendar/gui/main.c
+++ /dev/null
@@ -1,699 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (quartic@gimp.org)
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <string.h>
-#include <ctype.h>
-#include "alarm.h"
-#include "calendar.h"
-#include "eventedit.h"
-#include "gnome-cal.h"
-#include "main.h"
-#include "timeutil.h"
-
-#define COOKIE_USER_HOME_DIR ((char *) -1)
-
-/* 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;
-
-/* The user's default calendar file */
-char *user_calendar_file;
-
-/* 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;
-
-/* Number of calendars active */
-int active_calendars = 0;
-
-/* A list of all of the calendars started */
-GList *all_calendars = NULL;
-
-static void new_calendar (char *full_name, char *calendar_file, char *geometry, char *view);
-
-/* For dumping part of a calendar */
-static time_t from_t, to_t;
-
-/* File to load instead of the user default's file */
-static char *load_file;
-
-/* If set, show events for the specified date and quit */
-static int show_events;
-
-static void
-init_username (void)
-{
- char *p;
- struct passwd *passwd;
-
- passwd = getpwuid (getuid ());
- if ((p = passwd->pw_name)) {
- char *comma;
-
- user_name = g_strdup (p);
- full_name = g_strdup (passwd->pw_gecos);
-
- /* Keep only the name from the gecos field */
- if ((comma = strchr (full_name, ',')) != NULL)
- *comma = 0;
- } else {
- if ((p = getenv ("USER"))) {
- user_name = g_strdup (p);
- full_name = g_strdup (p);
- return;
- } else {
- user_name = g_strdup ("unknown");
- full_name = g_strdup ("unknown");
- }
- }
- endpwent ();
-}
-
-static int
-range_check_hour (int hour)
-{
- if (hour < 0)
- hour = 0;
- else if (hour >= 24)
- hour = 23;
-
- return hour;
-}
-
-/*
- * Initializes the calendar internal variables, loads defaults
- */
-static void
-init_calendar (void)
-{
- init_username ();
- user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
-
- gnome_config_push_prefix (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 = range_check_hour (gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0"));
-
- if (day_end < day_begin){
- day_begin = 8;
- day_end = 17;
- }
-
- gnome_config_pop_prefix ();
-}
-
-static void save_calendar_cmd (GtkWidget *widget, void *data);
-
-static void
-about_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkWidget *about;
- const gchar *authors[] = {
- "Miguel de Icaza (miguel@kernel.org)",
- "Federico Mena (quartic@gimp.org)",
- "Arturo Espinosa (arturo@nuclecu.unam.mx)",
- NULL
- };
-
- about = gnome_about_new (_("Gnome Calendar"), VERSION,
- "(C) 1998 the Free Software Foundation",
- authors,
- _("The GNOME personal calendar and schedule manager."),
- NULL);
- gnome_dialog_run_and_destroy (GNOME_DIALOG (about));
-#if 0
- gtk_widget_show (about);
-#endif
-}
-
-static void
-display_objedit (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
- iCalObject *ico;
-
- /* Default to the day the user is looking at */
- ico = ical_new ("", user_name, "");
- ico->new = 1;
- ico->dtstart = time_add_minutes (gcal->current_display, day_begin * 60);
- ico->dtend = time_add_minutes (ico->dtstart, day_begin * 60 + 30 );
-
- ee = event_editor_new (gcal, ico);
- gtk_widget_show (ee);
-}
-
-static void
-display_objedit_today (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
-
- ee = event_editor_new (gcal, NULL);
- gtk_widget_show (ee);
-}
-
-static void
-close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
-{
- all_calendars = g_list_remove (all_calendars, gcal);
- if (gcal->cal->modified){
- if (!gcal->cal->filename)
- save_calendar_cmd (widget, gcal);
- else
- calendar_save (gcal->cal, gcal->cal->filename);
- }
-
- gtk_widget_destroy (GTK_WIDGET (gcal));
- active_calendars--;
-
- if (active_calendars == 0)
- gtk_main_quit ();
-}
-
-/*
- * Updates all of the open calendars when the day_begin/day_end values have changed
- */
-void
-day_range_changed (void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next){
- GnomeCalendar *cal = GNOME_CALENDAR (l->data);
-
- gtk_widget_queue_resize (cal->notebook);
- }
-}
-
-static void
-quit_cmd (void)
-{
- while (all_calendars){
- GnomeCalendar *cal = GNOME_CALENDAR (all_calendars->data);
-
- close_cmd (GTK_WIDGET (cal), cal);
- }
-}
-
-static void
-previous_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- gnome_calendar_previous (gcal);
-}
-
-static void
-next_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- gnome_calendar_next (gcal);
-}
-
-static void
-today_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- gnome_calendar_goto (gcal, time (NULL));
-}
-
-static void
-goto_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- goto_dialog (gcal);
-}
-
-static void
-new_calendar_cmd (GtkWidget *widget, void *data)
-{
- new_calendar (full_name, NULL, NULL, NULL);
-}
-
-static void
-open_ok (GtkWidget *widget, GtkFileSelection *fs)
-{
- /* FIXME: find out who owns this calendar and use that name */
- new_calendar ("Somebody", gtk_file_selection_get_filename (fs), NULL, NULL);
-
- gtk_widget_destroy (GTK_WIDGET (fs));
-}
-
-static void
-open_calendar_cmd (GtkWidget *widget, void *data)
-{
- 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;
-
- gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs)));
- gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal");
-
- if (gcal->cal->filename)
- g_free (gcal->cal->filename);
-
- gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs));
- calendar_save (gcal->cal, gcal->cal->filename);
- gtk_main_quit ();
-}
-
-static gint
-close_save (GtkWidget *w)
-{
- gtk_main_quit ();
- return TRUE;
-}
-
-static void
-save_as_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkFileSelection *fs;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar")));
- gtk_object_set_user_data (GTK_OBJECT (fs), 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
-save_calendar_cmd (GtkWidget *widget, void *data)
-{
- GnomeCalendar *gcal = data;
-
- if (gcal->cal->filename)
- calendar_save (gcal->cal, gcal->cal->filename);
- else
- save_as_calendar_cmd (widget, data);
-}
-
-static GnomeUIInfo gnome_cal_file_menu [] = {
- { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW },
-
- { GNOME_APP_UI_ITEM, N_("Open calendar..."), NULL, open_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN },
-
- { GNOME_APP_UI_ITEM, N_("Save calendar"), NULL, save_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
-
- { GNOME_APP_UI_ITEM, N_("Save calendar as..."), NULL, save_as_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
-
- { GNOME_APP_UI_SEPARATOR },
- { GNOME_APP_UI_ITEM, N_("Close this calendar"), NULL, close_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
-
- { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_about_menu [] = {
- { GNOME_APP_UI_ITEM, N_("About..."), NULL, about_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT },
- GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_HELP ("cal"),
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_edit_menu [] = {
- { GNOME_APP_UI_ITEM, N_("New appointment..."), NULL, display_objedit },
- { GNOME_APP_UI_ITEM, N_("New appointment for today..."), NULL, display_objedit_today },
- GNOMEUIINFO_SEPARATOR,
- { GNOME_APP_UI_ITEM, N_("Properties..."), NULL, properties, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP },
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_menu [] = {
- { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu },
- { GNOME_APP_UI_SUBTREE, N_("Calendar"), NULL, &gnome_cal_edit_menu },
- { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu },
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_toolbar [] = {
- { GNOME_APP_UI_ITEM, N_("New"), N_("Create a new appointment"), display_objedit, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_NEW },
-
- GNOMEUIINFO_SEPARATOR,
-
- { GNOME_APP_UI_ITEM, N_("Prev"), N_("Go back in time"), previous_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK },
-
- { GNOME_APP_UI_ITEM, N_("Today"), N_("Go to present time"), today_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HOME },
-
- { GNOME_APP_UI_ITEM, N_("Next"), N_("Go forward in time"), next_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD },
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Go to"), N_("Go to a specific date"), goto_clicked, GNOME_STOCK_PIXMAP_STOP),
-
- GNOMEUIINFO_END
-};
-
-static void
-setup_menu (GtkWidget *gcal)
-{
- gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal);
- gnome_app_create_toolbar_with_data (GNOME_APP (gcal), gnome_toolbar, gcal);
-}
-
-static gint
-calendar_close_event (GtkWidget *widget, GdkEvent *event, GnomeCalendar *gcal)
-{
- close_cmd (widget, gcal);
- return TRUE;
-}
-
-static void
-new_calendar (char *full_name, char *calendar_file, char *geometry, char *page)
-{
- 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 (width != -1)
- gtk_widget_set_usize (toplevel, width, height);
- }
- setup_menu (toplevel);
-
- if (page)
- gnome_calendar_set_view (GNOME_CALENDAR (toplevel), page);
-
- if (calendar_file && g_file_exists (calendar_file))
- gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file);
- else
- GNOME_CALENDAR (toplevel)->cal->filename = g_strdup (calendar_file);
-
- 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);
- gtk_widget_show (toplevel);
-}
-
-static void
-process_dates (void)
-{
- if (!from_t)
- from_t = time_start_of_day (time (NULL));
-
- if (!to_t || to_t < from_t)
- to_t = time_add_day (from_t, 1);
-}
-
-enum {
- GEOMETRY_KEY = -1,
- USERFILE_KEY = -2,
- VIEW_KEY = -3
-};
-
-static struct argp_option argp_options [] = {
- { "events", 'e', NULL, 0, N_("Show events and quit"), 0 },
- { "from", 'f', N_("DATE"), 0, N_("Specifies start date [for --events]"), 1 },
- { "file", 'F', N_("FILE"), 0, N_("File to load calendar from"), 1 },
- { "userfile", USERFILE_KEY, NULL, 0, N_("Load the user calendar"), 1 },
- { "geometry", GEOMETRY_KEY, N_("GEOMETRY"), 0, N_("Geometry for starting up"), 1 },
- { "view", VIEW_KEY, N_("VIEW"), 0, N_("The startup view mode"), 1 },
- { "to", 't', N_("DATE"), 0, N_("Specifies ending date [for --events]"), 1 },
- { NULL, 0, NULL, 0, NULL, 0 },
-};
-
-/* Lists used to startup various GnomeCalendars */
-static GList *start_calendars;
-static GList *start_geometries;
-static GList *start_views;
-
-static int
-same_day (struct tm *a, struct tm *b)
-{
- return (a->tm_mday == b->tm_mday &&
- a->tm_mon == b->tm_mon &&
- a->tm_year == b->tm_year);
-}
-
-static void
-dump_events (void)
-{
- Calendar *cal;
- GList *l;
- char *s;
- time_t now = time (NULL);
- struct tm today = *localtime (&now);
-
- process_dates ();
- init_calendar ();
-
- cal = calendar_new (full_name);
- s = calendar_load (cal, load_file ? load_file : user_calendar_file);
- if (s){
- printf ("error: %s\n", s);
- exit (1);
- }
- l = calendar_get_events_in_range (cal, from_t, to_t);
- for (; l; l = l->next){
- char start [80], end [80];
- CalendarObject *co = l->data;
- struct tm ts, te;
- char *format;
-
- ts = *localtime (&co->ev_start);
- te = *localtime (&co->ev_end);
-
- if (same_day (&today, &ts))
- format = "%H:%M";
- else
- format = "%A %d, %H:%M";
- strftime (start, sizeof (start), format, &ts);
-
- if (!same_day (&ts, &te))
- format = "%A %d, %H:%M";
- strftime (end, sizeof (start), format, &te);
-
- printf ("%s -- %s\n", start, end);
- printf (" %s\n", co->ico->summary);
- }
- calendar_destroy_event_list (l);
- calendar_destroy (cal);
- exit (0);
-}
-
-extern time_t get_date ();
-
-static error_t
-parse_an_arg (int key, char *arg, struct argp_state *state)
-{
- switch (key){
- case 'f':
- from_t = get_date (arg, NULL);
- break;
-
- case 't':
- to_t = get_date (arg, NULL);
- break;
-
- case GEOMETRY_KEY:
- start_geometries = g_list_append (start_geometries, arg);
- break;
-
- case USERFILE_KEY:
- /* This is a special key that tells the program to load
- * the user's calendar file. This allows session management
- * to work even if the User's home directory changes location
- * (ie, on a networked setup).
- */
- arg = COOKIE_USER_HOME_DIR;
- /* fall trough */
-
- case VIEW_KEY:
- start_views = g_list_append (start_views, arg);
- break;
-
- case 'F':
- start_calendars = g_list_append (start_calendars, arg);
- break;
-
- case 'e':
- show_events = 1;
- break;
-
- case ARGP_KEY_END:
- if (show_events)
- dump_events ();
-
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return 0;
-}
-
-static struct argp parser =
-{
- argp_options, parse_an_arg, NULL, NULL, NULL, NULL, NULL
-};
-
-static void
-session_die (void)
-{
- quit_cmd ();
-}
-
-/*
- * Save the session callback
- */
-static int
-session_save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_style, gint shutdown,
- GnomeInteractStyle interact_style, gint fast, gpointer client_data)
-{
- char *sess_id;
- char **argv = (char **) g_malloc (sizeof (char *) * ((active_calendars * 6) + 3));
- GList *l, *free_list = 0;
- int i;
-
- sess_id = gnome_client_get_id (client);
-
- argv [0] = client_data;
- for (i = 1, l = all_calendars; l; l = l->next){
- GnomeCalendar *gcal = GNOME_CALENDAR (l->data);
- char *geometry;
-
- geometry = gnome_geometry_string (GTK_WIDGET (gcal)->window);
-
- if (strcmp (gcal->cal->filename, user_calendar_file) == 0)
- argv [i++] = "--userfile";
- else {
- argv [i++] = "--file";
- argv [i++] = gcal->cal->filename;
- }
- argv [i++] = "--geometry";
- argv [i++] = geometry;
- argv [i++] = "--view";
- argv [i++] = gnome_calendar_get_current_view_name (gcal);
- free_list = g_list_append (free_list, geometry);
- calendar_save (gcal->cal, gcal->cal->filename);
- }
- argv [i] = NULL;
- gnome_client_set_clone_command (client, i, argv);
- gnome_client_set_restart_command (client, i, argv);
-
- for (l = free_list; l; l = l->next)
- g_free (l->data);
- g_list_free (free_list);
-
- return 1;
-}
-
-int
-main(int argc, char *argv[])
-{
- GnomeClient *client;
-
- argp_program_version = VERSION;
-
- bindtextdomain(PACKAGE, GNOMELOCALEDIR);
- textdomain(PACKAGE);
-
- client = gnome_client_new_default ();
- if (client){
- gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
- GTK_SIGNAL_FUNC (session_save_state), argv [0]);
- gtk_signal_connect (GTK_OBJECT (client), "die",
- GTK_SIGNAL_FUNC (session_die), NULL);
- }
- gnome_init ("calendar", &parser, argc, argv, 0, NULL);
-
- process_dates ();
- alarm_init ();
- init_calendar ();
-
- /*
- * Load all of the calendars specifies in the command line with
- * the geometry specificied -if any-
- */
- if (start_calendars){
- GList *p, *g, *v;
- char *title;
-
- p = start_calendars;
- g = start_geometries;
- v = start_views;
- while (p){
- char *file = p->data;
- char *geometry = g ? g->data : NULL;
- char *page_name = v ? v->data : NULL;
-
- if (file == COOKIE_USER_HOME_DIR)
- file = user_calendar_file;
-
- if (strcmp (file, user_calendar_file) == 0)
- title = full_name;
- else
- title = file;
- new_calendar (title, file, geometry, page_name);
-
- p = p->next;
- if (g)
- g = g->next;
- if (v)
- v = v->next;
- }
- g_list_free (p);
- } else {
- char *geometry = start_geometries ? start_geometries->data : NULL;
- char *page_name = start_views ? start_views->data : NULL;
-
- new_calendar (full_name, user_calendar_file, geometry, page_name);
- }
- gtk_main ();
- return 0;
-}
-
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
deleted file mode 100644
index 374f8199e6..0000000000
--- a/calendar/gui/main.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-extern int day_begin, day_end;
-extern char *user_name;
-extern int am_pm_flag;
-
-void properties (void);
-void day_range_changed (void);
-void goto_dialog (GnomeCalendar *gcal);
-
-#endif
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
deleted file mode 100644
index a23938b350..0000000000
--- a/calendar/gui/month-view.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include "month-view.h"
-
-
-static void month_view_class_init (MonthViewClass *class);
-static void month_view_init (MonthView *mv);
-static void month_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void month_view_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-
-static GnomeCanvasClass *parent_class;
-
-
-GtkType
-month_view_get_type (void)
-{
- static GtkType month_view_type = 0;
-
- if (!month_view_type) {
- GtkTypeInfo month_view_info = {
- "MonthView",
- sizeof (MonthView),
- sizeof (MonthViewClass),
- (GtkClassInitFunc) month_view_class_init,
- (GtkObjectInitFunc) month_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- month_view_type = gtk_type_unique (gnome_canvas_get_type (), &month_view_info);
- }
-
- return month_view_type;
-}
-
-static void
-month_view_class_init (MonthViewClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- widget_class->size_request = month_view_size_request;
- widget_class->size_allocate = month_view_size_allocate;
-}
-
-static void
-month_view_init (MonthView *mv)
-{
- mv->mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (mv->canvas.root));
- gnome_canvas_item_set (mv->mitem,
- "x", 0.0,
- "y", 0.0,
- "anchor", GTK_ANCHOR_NW,
- "day_anchor", GTK_ANCHOR_NE,
-#if 0
- "start_on_monday", TRUE,
-#endif
- NULL);
-}
-
-GtkWidget *
-month_view_new (GnomeCalendar *calendar)
-{
- MonthView *mv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- mv = gtk_type_new (month_view_get_type ());
-
- mv->calendar = calendar;
-
- return GTK_WIDGET (mv);
-}
-
-static void
-month_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (requisition != NULL);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_request)
- (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
-
- requisition->width = 200;
- requisition->height = 150;
-}
-
-static void
-month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- MonthView *mv;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (allocation != NULL);
-
- mv = MONTH_VIEW (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
- (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height);
- gnome_canvas_item_set (mv->mitem,
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
- NULL);
-}
diff --git a/calendar/gui/month-view.h b/calendar/gui/month-view.h
deleted file mode 100644
index 0f35817d78..0000000000
--- a/calendar/gui/month-view.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef MONTH_VIEW_H
-#define MONTH_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_MONTH_VIEW (month_view_get_type ())
-#define MONTH_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_MONTH_VIEW, MonthView))
-#define MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_MONTH_VIEW, MonthViewClass))
-#define IS_MONTH_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_MONTH_VIEW))
-#define IS_MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_MONTH_VIEW))
-
-
-typedef struct _MonthView MonthView;
-typedef struct _MonthViewClass MonthViewClass;
-
-struct _MonthView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- GnomeCanvasItem *mitem; /* The canvas month item used by this month view */
-};
-
-struct _MonthViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType month_view_get_type (void);
-
-/* Creates a new month view widget associated to the specified calendar */
-GtkWidget *month_view_new (GnomeCalendar *calendar);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/popup-menu.c b/calendar/gui/popup-menu.c
deleted file mode 100644
index 3686183146..0000000000
--- a/calendar/gui/popup-menu.c
+++ /dev/null
@@ -1,37 +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"
-
-
-void
-popup_menu (struct menu_item *items, int nitems, GdkEventButton *event)
-{
- GtkWidget *menu;
- GtkWidget *item;
- int i;
-
- menu = gtk_menu_new (); /* FIXME: this baby is never freed */
-
- 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/prop.c b/calendar/gui/prop.c
deleted file mode 100644
index 58abe2f8db..0000000000
--- a/calendar/gui/prop.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Calendar properties dialog box
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza <miguel@kernel.org>
- */
-#include <config.h>
-#include <gnome.h>
-#include "gnome-cal.h"
-#include "main.h"
-
-static GtkWidget *prop_win, *r1;
-static GtkObject *sa, *ea;
-
-static void
-start_changed (GtkAdjustment *sa, GtkAdjustment *ea)
-{
- if (sa->value > 23.0){
- sa->value = 23.0;
- ea->value = 24.0;
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- } else if (sa->value >= ea->value){
- ea->value = sa->value + 1.0;
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- }
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-static void
-end_changed (GtkAdjustment *ea, GtkAdjustment *sa)
-{
- if (ea->value < 1.0){
- ea->value = 1.0;
- sa->value = 0.0;
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- } else if (ea->value < sa->value){
- sa->value = ea->value - 1.0;
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- }
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-/* justifies the text */
-static GtkWidget *
-align (GtkWidget *w, float side)
-{
- GtkWidget *a;
-
- a = gtk_alignment_new (side, 0.5, 1.0, 1.0);
- gtk_container_add (GTK_CONTAINER (a), w);
-
- return a;
-}
-
-static int
-prop_cancel (void)
-{
- prop_win = 0;
- return FALSE;
-}
-
-static void
-prop_apply (GtkWidget *w, int page)
-{
- if (page != -1)
- return;
-
- day_begin = GTK_ADJUSTMENT (sa)->value;
- day_end = GTK_ADJUSTMENT (ea)->value;
- gnome_config_set_int ("/calendar/Calendar/Day start", day_begin);
- gnome_config_set_int ("/calendar/Calendar/Day end", day_end);
-
- am_pm_flag = (GTK_TOGGLE_BUTTON (r1)->active) == 0;
- gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag);
-
- gnome_config_sync ();
-
- day_range_changed ();
-}
-
-static void
-toggled ()
-{
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-void
-properties (void)
-{
- GtkWidget *t, *l, *ds, *de;
- GtkWidget *r2;
-
- if (prop_win)
- return;
-
- prop_win = gnome_property_box_new ();
-
- t = gtk_table_new (0, 0, 0);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), t,
- gtk_label_new (_("Calendar global parameters")));
-
- l = gtk_label_new (_("Day start:"));
- gtk_table_attach (GTK_TABLE (t), l,
- 0, 1, 0, 1, 0, 0, 0, 0);
- sa = gtk_adjustment_new (day_begin, 0.0, 25.00, 1.0, 1.0, 1.0);
- ds = gtk_hscale_new (GTK_ADJUSTMENT (sa));
- gtk_scale_set_digits (GTK_SCALE (ds), 0);
- gtk_table_attach (GTK_TABLE (t), ds,
- 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- l = gtk_label_new (_("Day end:"));
- gtk_table_attach (GTK_TABLE (t), l,
- 0, 1, 1, 2, 0, 0, 0, 0);
- ea = gtk_adjustment_new (day_end, 0.0, 25.00, 1.0, 1.0, 1.0);
- de = gtk_hscale_new (GTK_ADJUSTMENT (ea));
- gtk_scale_set_digits (GTK_SCALE (de), 0);
- gtk_table_attach (GTK_TABLE (t), de,
- 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- gtk_signal_connect (sa, "value_changed",
- GTK_SIGNAL_FUNC (start_changed), ea);
- gtk_signal_connect (ea, "value_changed",
- GTK_SIGNAL_FUNC (end_changed), sa);
-
- /* Nice spacing :-) */
- gtk_table_attach (GTK_TABLE (t), gtk_label_new (""),
- 0, 1, 2, 3, 0, 0, 0, 0);
-
- r1 = gtk_radio_button_new_with_label (NULL, _("24 hour format"));
- r2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (r1),
- _("12 hour format"));
- if (am_pm_flag)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r2), 1);
-
- gtk_signal_connect (GTK_OBJECT (r1), "toggled",
- GTK_SIGNAL_FUNC (toggled), NULL);
-
- gtk_table_attach (GTK_TABLE (t), align (r1, 0.0), 0, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (t), align (r2, 0.0), 0, 2, 4, 5, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
- GTK_SIGNAL_FUNC (prop_cancel), NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "delete_event",
- GTK_SIGNAL_FUNC (prop_cancel), NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "apply",
- GTK_SIGNAL_FUNC (prop_apply), NULL);
-
- gtk_widget_show_all (prop_win);
-}
-
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/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/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/view-utils.c b/calendar/gui/view-utils.c
deleted file mode 100644
index 1571c2f31e..0000000000
--- a/calendar/gui/view-utils.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <string.h>
-#include "view-utils.h"
-
-int am_pm_flag = 0;
-
-static char *
-nicetime (struct tm *tm)
-{
- static char buf [20];
-
- if (am_pm_flag){
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%l:%M%p", tm);
- else
- strftime (buf, sizeof (buf), "%l%p", tm);
- } else {
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%k:%M", tm);
- else
- strftime (buf, sizeof (buf), "%k", tm);
- }
- return buf;
-}
-
-void
-view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end)
-{
- int font_height;
- int x, y, max_y;
- char buf [40];
- struct tm tm_start, tm_end;
- char *str;
- iCalObject *ico;
- GList *list;
-
- gdk_gc_set_clip_rectangle (gc, area);
-
- font_height = widget->style->font->ascent + widget->style->font->descent;
-
- max_y = area->y + area->height - font_height * ((flags & VIEW_UTILS_DRAW_SPLIT) ? 2 : 1);
-
- for (y = area->y, list = events; (y < max_y) && list; y += font_height, list = list->next) {
- CalendarObject *co = list->data;
- ico = co->ico;
-
- tm_start = *localtime (&co->ev_start);
- tm_end = *localtime (&co->ev_end);
- str = ico->summary;
-
- strcpy (buf, nicetime (&tm_start));
-
- if (flags & VIEW_UTILS_DRAW_END){
- strcat (buf, "-");
- strcat (buf, nicetime (&tm_end));
- }
- gdk_draw_string (window,
- widget->style->font,
- gc,
- area->x,
- y + widget->style->font->ascent,
- buf);
-
- if (flags & VIEW_UTILS_DRAW_SPLIT) {
- y += font_height;
- x = widget->style->font->ascent; /* some indentation */
- } else
- x = gdk_string_width (widget->style->font, buf);
-
- gdk_draw_string (window,
- widget->style->font,
- gc,
- x,
- y + widget->style->font->ascent,
- str);
- }
- gdk_gc_set_clip_rectangle (gc, NULL);
-}
-
-void
-view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow)
-{
- int x, y;
- int xthick, ythick;
- GdkGC *light_gc, *dark_gc;
-
- gdk_draw_rectangle (window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- rect->x, rect->y,
- rect->width, rect->height);
-
- light_gc = widget->style->light_gc[GTK_STATE_NORMAL];
- dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL];
-
- xthick = widget->style->klass->xthickness;
- ythick = widget->style->klass->ythickness;
-
- gdk_gc_set_clip_rectangle (light_gc, rect);
- gdk_gc_set_clip_rectangle (dark_gc, rect);
-
- for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3)
- for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) {
- gdk_draw_point (window, light_gc, x, y);
- gdk_draw_point (window, dark_gc, x + 1, y + 1);
-
- gdk_draw_point (window, light_gc, x + 3, y + 1);
- gdk_draw_point (window, dark_gc, x + 4, y + 2);
- }
-
- gdk_gc_set_clip_rectangle (light_gc, NULL);
- gdk_gc_set_clip_rectangle (dark_gc, NULL);
-
- gtk_draw_shadow (widget->style, window,
- GTK_STATE_NORMAL, shadow,
- rect->x, rect->y,
- rect->width, rect->height);
-}
diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h
deleted file mode 100644
index a1876b6032..0000000000
--- a/calendar/gui/view-utils.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef VIEW_UTILS_H
-#define VIEW_UTILS_H
-
-
-#include <gtk/gtk.h>
-#include "calendar.h"
-
-
-enum {
- VIEW_UTILS_DRAW_END = 1 << 0,
- VIEW_UTILS_DRAW_SPLIT = 1 << 1
-};
-
-
-void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end);
-
-void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow);
-
-
-#endif
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
deleted file mode 100644
index 0a104f25a3..0000000000
--- a/calendar/gui/year-view.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Arturo Espinosa <arturo@nuclecu.unam.mx>
- *
- * Heavily based on Federico Mena's week view.
- *
- */
-
-#include "gncal-year-view.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-static void gncal_year_view_init (GncalYearView *yview);
-
-static void
-double_click(GtkCalendar *gc, GncalYearView *yview)
-{
- struct tm tm;
- time_t t;
-
- tm.tm_mday = gc->selected_day;
- tm.tm_mon = gc->month;
- tm.tm_year = gc->year - 1900;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- t = mktime (&tm);
-
- gnome_calendar_dayjump (yview->gcal, t);
-}
-
-static void
-do_nothing(GtkCalendarClass *c)
-{
-}
-
-static void
-select_day(GtkWidget *widget, gpointer data)
-{
- int i;
-
- GncalYearView *yview;
-
- yview = GNCAL_YEAR_VIEW(data);
-
- for (i = 0; i < 12; i++)
- gtk_signal_handler_block(GTK_OBJECT(yview->calendar[i]),
- yview->handler[i]);
-
- for (i = 0; i < 12; i++)
- if (GTK_CALENDAR(yview->calendar[i]) != GTK_CALENDAR(widget))
- gtk_calendar_select_day(GTK_CALENDAR(yview->calendar[i]), 0);
-
- for (i = 0; i < 12; i++)
- gtk_signal_handler_unblock(GTK_OBJECT(yview->calendar[i]),
- yview->handler[i]);
-}
-
-guint
-gncal_year_view_get_type (void)
-{
- static guint year_view_type = 0;
-
- if (!year_view_type) {
- GtkTypeInfo year_view_info = {
- "GncalYearView",
- sizeof (GncalYearView),
- sizeof (GncalYearViewClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_year_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- year_view_type = gtk_type_unique (gtk_table_get_type (),
- &year_view_info);
- }
-
- return year_view_type;
-}
-
-static void
-gncal_year_view_init (GncalYearView *yview)
-{
- int i;
-
- for (i = 0; i < 12; i++) {
- yview->calendar[i] = NULL;
- yview->handler [i] = 0;
- }
-
- yview->gcal = NULL;
- yview->year_label = NULL;
- yview->year = 0;
-}
-
-GtkWidget *
-gncal_year_view_new (GnomeCalendar *calendar, time_t date)
-{
- struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- char monthbuff[40];
- GncalYearView *yview;
- GtkWidget *frame, *vbox, *label;
- struct tm *tmptm;
- int i, x, y;
-
- yview = gtk_type_new (gncal_year_view_get_type ());
-
- tmptm = localtime(&date);
- yview->year = tmptm->tm_year;
- yview->gcal = calendar;
- my_tm.tm_year = tmptm->tm_year;
- yview->year_label = gtk_label_new("");
- gtk_table_attach (GTK_TABLE (yview),
- GTK_WIDGET (yview->year_label),
- 1, 2,
- 0, 1,
- 0, 0, 0, 5);
- gtk_widget_show(GTK_WIDGET(yview->year_label));
-
- for (x = 0; x < 3; x++)
- for (y = 0; y < 4; y++) {
-
- i = y * 3 + x;
-
- yview->calendar[i] = gtk_calendar_new();
- gtk_calendar_display_options(GTK_CALENDAR(yview->calendar[i]),
- GTK_CALENDAR_SHOW_DAY_NAMES |
- GTK_CALENDAR_NO_MONTH_CHANGE);
- frame = gtk_frame_new(NULL);
- vbox = gtk_vbox_new(0,0);
-
- yview->handler[i] =
- gtk_signal_connect(GTK_OBJECT(yview->calendar[i]), "day_selected",
- GTK_SIGNAL_FUNC(select_day), (gpointer *) yview);
-
- gtk_signal_connect(GTK_OBJECT(yview->calendar[i]), "day_selected_double_click",
- GTK_SIGNAL_FUNC(double_click), (gpointer *) yview);
-
- my_tm.tm_mon = i;
- strftime(monthbuff, 40, "%B", &my_tm);
- label = gtk_label_new(monthbuff);
-
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_box_pack_start(GTK_BOX(vbox), label, 0, 0, 0);
- gtk_box_pack_start(GTK_BOX(vbox), yview->calendar[i], 0, 0, 0);
-
- gtk_table_attach (GTK_TABLE (yview),
- GTK_WIDGET (frame),
- x, x + 1,
- y + 1, y + 2,
- 0, 0, 0, 0);
-
- gtk_widget_show (frame);
- gtk_widget_show (vbox);
- gtk_widget_show (GTK_WIDGET (yview->calendar[i]));
- }
-
- gncal_year_view_set (yview, date);
-
- return GTK_WIDGET (yview);
-}
-
-static void
-year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure)
-{
- GncalYearView *yview = (GncalYearView *) closure;
- struct tm tm_s;
- time_t t, day_end;
-
- tm_s = *localtime (&start);
- day_end = time_end_of_day (end);
-
- for (t = start; t <= day_end; t+= 60*60*24){
- time_t new = mktime (&tm_s);
- struct tm tm_day;
-
- tm_day = *localtime (&new);
- gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day.tm_mon]),
- tm_day.tm_mday);
- tm_s.tm_mday++;
- }
-}
-
-static void
-gncal_year_view_set_year (GncalYearView *yview, int year)
-{
- time_t year_begin, year_end;
- char buff[20];
- GList *l;
- int i;
-
- if (!yview->gcal->cal)
- return;
-
- snprintf(buff, 20, "%d", yview->year + 1900);
- gtk_label_set(GTK_LABEL(yview->year_label), buff);
-
- for (i = 0; i < 12; i++) {
- gtk_calendar_freeze (GTK_CALENDAR (yview->calendar [i]));
- gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year + 1900);
- gtk_calendar_clear_marks (GTK_CALENDAR (yview->calendar[i]));
- }
-
- year_begin = time_year_begin (yview->year);
- year_end = time_year_end (yview->year);
-
- l = calendar_get_events_in_range (yview->gcal->cal, year_begin, year_end);
- for (; l; l = l->next){
- CalendarObject *co = l->data;
-
- year_view_mark_day (co->ico, co->ev_start, co->ev_end, yview);
- }
- for (i = 0; i < 12; i++)
- gtk_calendar_thaw (GTK_CALENDAR (yview->calendar [i]));
-
- calendar_destroy_event_list (l);
-}
-
-void
-gncal_year_view_set (GncalYearView *yview, time_t date)
-{
- struct tm *tmptm;
-
- tmptm = localtime(&date);
- yview->year = tmptm->tm_year;
-
- gncal_year_view_set_year (yview, yview->year);
-}
-
-void
-gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
-{
- g_return_if_fail (yview != NULL);
- g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
-
- /* If only the summary changed, we dont care */
- if (flags && (flags & CHANGE_SUMMARY) == flags)
- return;
-
- gncal_year_view_set_year (yview, yview->year);
-}
diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h
deleted file mode 100644
index f31d5ae4a3..0000000000
--- a/calendar/gui/year-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Arturo Espinosa <arturo@nuclecu.unam.mx>
- *
- * Heavily based on Federico Mena's week view.
- *
- */
-
-#ifndef YEAR_VIEW_H
-#define YEAR_VIEW_H
-
-#include <time.h>
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gtkcalendar.h>
-
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_YEAR_VIEW(obj) GTK_CHECK_CAST (obj, gncal_year_view_get_type (), GncalYearView)
-#define GNCAL_YEAR_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_year_view_get_type (), GncalYearViewClass)
-#define GNCAL_IS_YEAR_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_year_view_get_type ())
-
-
-typedef struct _GncalYearView GncalYearView;
-typedef struct _GncalYearViewClass GncalYearViewClass;
-
-struct _GncalYearView {
- GtkTable table;
-
- GnomeCalendar *gcal; /* The calendar we are associated to */
- GtkWidget *calendar[12]; /* one calendar per month */
- guint handler[12]; /* for (un)blocking the calendars */
-
- GtkWidget *year_label;
- gint year;
-};
-
-struct _GncalYearViewClass {
- GtkTableClass parent_class;
-};
-
-
-guint gncal_year_view_get_type (void);
-GtkWidget *gncal_year_view_new (GnomeCalendar *calendar, time_t date);
-void gncal_year_view_set (GncalYearView *yview, time_t date);
-void gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/icalendar-types b/calendar/icalendar-types
deleted file mode 100644
index e11f4c1789..0000000000
--- a/calendar/icalendar-types
+++ /dev/null
@@ -1,39 +0,0 @@
-evento todo journal fbrequest fbreply busytime timezone
- attach attach attach
- attendee attendee attendee attendee attendee attendee
- categories categories categories
- class class class
- comment comment comment comment comment comment comment
- completed
- contact contact contact
- created created created created
- description description description
- dtstamp dtstamp
- dtend/duration due->dtend dtend [duration] dtend dtend
- dtstart dtstart dtstart dtstart dtstart dtstart dtstart
- exdate exdate exdate
- exrule exrule exrule
- geo geo
- last-mod last-mod last-mod last-mod last-mod
- location location
- organizer organizer organizer
- percent
- priority priority
- rstatus rstatus rstatus rstatus
- related related related
- resources resources
- rdate rdate rdate [rdate/rrule]
- rrule rrule rrule
- dtstamp dtstamp dtstamp dtstamp
- seq seq seq seq seq
- status status
- summary summary summary
- transp
- uid uid uid uid uid
- url url url url url
- recurid recurid recurid
- freebusy freebusy
- tzname
- tzoffset-to
- tzoffset-from
-
diff --git a/calendar/lexer.c b/calendar/lexer.c
deleted file mode 100644
index e03cb666fb..0000000000
--- a/calendar/lexer.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * lexer.c: Reads in the .calendar files
- */
-#include <stdio.h>
-#include <glib.h>
-#include "cal_struct.h"
-
-
-#define opener "["
-#define closer "]"
-#define VersionMajor 2
-
-GSList *eventlist;
-
-void print_glist(gpointer data, gpointer user_data)
-{
- struct event *myevent = (struct event*)data;
-
- if (data == NULL)
- return;
- printf ("===============================================\nNew event\n");
- printf ("Start: %s %02d:%02d End: %s %02d:%02d\n", myevent->start.date, myevent->start.time / 60, myevent->start.time % 60, myevent->end.date, myevent->end.time / 60, myevent->end.time % 60);
- printf ("Contents: %s\n", myevent->description);
- printf ("Repeat = %d (%d)", (int)(myevent->repeat), myevent->repeatcount);
-}
-
-
-int skip_chars(FILE *fp, char *terminator)
-{
- int c;
- int cnt;
-
- cnt = 0;
- while( (c = fgetc(fp)) != EOF) {
- if (c == terminator[cnt]) {
- cnt++;
- if (terminator[cnt] == '\0')
- return TRUE;
- } else
- cnt = 0;
- }
- return FALSE;
-}
-
-int peek_char(FILE *fp, char *c)
-{
- if ( ((*c) = fgetc(fp)) != EOF) {
- ungetc((*c), fp);
- return TRUE;
- } else
- return FALSE;
-}
-
-int skip_whitespace(FILE *fp)
-{
- int c;
-
- while( (c = fgetc(fp)) != EOF)
- if (!isspace(c)) {
- ungetc(c, fp);
- return TRUE;
- }
- return FALSE;
-}
-
-int get_until(FILE *fp, char terminator, char *buf)
-{
- int c;
-
- while( (c = fgetc(fp)) != EOF) {
- if (c == terminator) {
- *buf = '\0';
- return TRUE;
- }
- *buf = (char)c;
- buf++;
- }
- *buf = '\0';
- return FALSE;
-}
-
-int get_number(FILE *fp, int *x)
-{
- char buf[50];
- int c;
- int cnt;
-
- cnt = 0;
- buf[cnt] = '\0';
- while( (c= fgetc(fp)) != EOF) {
- if (!isdigit(c)) {
- ungetc(c, fp);
- *x = atoi(buf);
- return TRUE;
- }
- buf[cnt++] = (char)c;
- buf[cnt] = '\0';
- }
- *x = atoi(buf);
- return FALSE;
-}
-
-/* Get string until EOF or closer_char */
-int get_string(FILE *fp, char *string)
-{
- int c;
- int cnt;
-
- cnt = 0;
- while ( (c = fgetc(fp)) != EOF) {
- if (c == closer[0]) {
- string[cnt] = '\0';
- ungetc((char)c, fp);
- return TRUE;
- }
- string[cnt++] = (char)c;
- }
- return FALSE;
-}
-
-int get_dates(FILE *fp, char *keyword, struct event *ptr)
-{
- char *c;
- int x;
-
- if (strncmp("Single", keyword, 6) == 0) {
- ptr->repeat = Single;
- /* It's a single date */
- if (! skip_whitespace(fp) || !get_until(fp, ' ', ptr->start.date))
- return FALSE;
- if (! skip_chars(fp, "End"))
- return FALSE;
- return TRUE;
- } else if (strncmp("Days", keyword, 4) == 0) {
- ptr->repeat = Days;
- if (! skip_whitespace(fp) || !get_until(fp, ' ', ptr->start.date))
- return FALSE;
- if (! skip_whitespace(fp) || !get_number(fp, &(ptr->repeatcount)))
- return FALSE;
- if (! skip_chars(fp, "End"))
- return FALSE;
- return TRUE;
- }
-
- return FALSE;
-}
-
-int getid(FILE *fp, char *string)
-{
- int c;
- int cnt;
-
- cnt = 0;
- while( (c =fgetc(fp)) != EOF) {
- if (isalnum(c))
- string[cnt++] = (char)c;
- else {
- string[cnt] = '\0';
- return TRUE;
- }
- }
- string[cnt] = '\0';
- return FALSE;
-}
-
-int parse_appointment(FILE *fp, struct event *ptr, char keyword[])
-{
- char buf[50];
- int x,y,c;
-
- if (strcmp(keyword, "Start") == 0) {
- if ( ! skip_whitespace(fp) || ! get_number(fp, &x) ) {
- g_error("Unable to get start time");
- return FALSE;
- }
- g_print ("Appointment start = %02d:%02d\n", x/60, x % 60);
- ptr->start.time = x;
- return TRUE;
- }
-
- if (strcmp(keyword, "Length") == 0) {
- if ( ! skip_whitespace(fp) || ! get_number(fp, &x) ) {
- g_error("Unable to get length");
- return FALSE;
- }
- g_print ("Appointment length = %d\n", x);
- ptr->end.time = ptr->start.time + x;
- return TRUE;
- }
-
- if (strcmp(keyword, "Alarms") == 0) {
- while(TRUE) {
- skip_whitespace(fp);
- if (!peek_char(fp, (char*)&c)) {
- g_error("Cannot read alarm list");
- return FALSE;
- }
- if (!isdigit(c))
- break;
-
- if (! get_number(fp, &x))
- return FALSE;
-
- g_print("New alarm %d\n", x);
- }
- return TRUE;
- }
-
- g_print("Unknown keyword %s\n", keyword);
- return FALSE;
-}
-
-int parse_item(FILE *fp, struct event *ptr, char keyword[])
-{
- char buf[50];
- int x, y, c;
-
- if (strcmp(keyword, "Remind") == 0) {
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get remind level");
- return FALSE;
- }
- g_print("Remind level = %d\n", x);
- return TRUE;
- }
-
- if (strcmp(keyword, "Owner") == 0) {
- if (!get_string(fp, buf)) {
- g_error("Cannot get owner information");
- return FALSE;
- }
- g_print("Owner = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Uid") == 0) {
- if (!skip_whitespace(fp) || !get_until(fp, *closer, buf)) {
- g_error("Cannot get unique ID");
- return FALSE;
- }
- g_print("UID = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Contents") == 0) {
- if (!get_string(fp, buf)) {
- g_error("Cannot get item text");
- return FALSE;
- }
- g_print("Contents = %s\n", buf);
- strcpy(ptr->description,buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Text") == 0) {
- if (! skip_whitespace(fp) || ! get_number(fp, &x) ||
- (x < 0) || ! skip_whitespace(fp) || ! skip_chars(fp, opener) ) {
- g_error("Cannot get item text");
- return FALSE;
- }
- y = 0;
- while(y < x) {
- if ( (c = fgetc(fp)) == EOF) {
- g_error("Short item text");
- return FALSE;
- }
- buf[y++] = (char)c;
- }
- buf[y] = '\0';
- g_print("Text = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Dates") == 0) {
- if ( ! getid(fp, buf)) {
- g_error("Cannot get date");
- return FALSE;
- }
- return get_dates(fp, buf,ptr);
- }
-
- if (strcmp(keyword, "Deleted") == 0) {
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get deleted day");
- return FALSE;
- }
- g_print("%d/", x);
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get deleted month");
- return FALSE;
- }
- g_print("%d/", x);
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get deleted year");
- return FALSE;
- }
- g_print("%d\n", x);
- return TRUE;
- }
-
- if (strcmp(keyword, "Hilite") == 0) {
- if (! get_string(fp, buf) ) {
- g_error("Cannot get hilite data");
- return FALSE;
- }
- g_print("Hilite = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Todo") == 0) {
- g_print("Todo\n");
- return TRUE;
- }
-
-
- if (strcmp(keyword, "Done") == 0) {
- g_print("Done\n");
- return TRUE;
- }
-
- return FALSE;
-}
-
-void parse_ical_file(char const *file)
-{
- FILE *fp;
- int finished;
- char keyword[50];
- int file_major, file_minor;
- char c;
- int item_type;
- int incomplete_item;
- struct event *myevent;
-
- if ( (fp = fopen(file, "r")) == NULL) {
- g_error("couldn't open file");
- return;
- }
-
- finished = FALSE;
-
- if (!skip_whitespace(fp))
- return;
-
- if (! skip_chars(fp, "Calendar") || ! skip_whitespace(fp) ) {
- g_error("unable to find calendar file");
- fclose(fp);
- return;
- }
-
- if (! skip_chars(fp, opener) || ! skip_chars(fp, "v") ) {
- g_error("Unable to get version line");
- fclose(fp);
- return;
- }
- if (! get_number(fp, &file_major) || ! (file_major >=0) || (file_major > VersionMajor)) {
- g_error("Missing/bad major version");
- fclose(fp);
- return;
- }
-
- if (! skip_chars(fp, ".") || ! get_number(fp, &file_minor) ||
- ! skip_chars(fp, "]") || ! skip_whitespace(fp) ) {
- g_error("Missing minor version");
- fclose(fp);
- return;
- }
- if (file_minor > 0) {
- g_error("Bad minor version");
- fclose(fp);
- return;
- }
-
- while(TRUE) {
- g_print("----------------------------------------\n");
- item_type= 0;
- skip_whitespace(fp);
- if (! getid(fp,keyword) || ! skip_whitespace(fp) ||
- ! skip_chars(fp, opener) || ! skip_whitespace(fp) ) {
- fclose(fp);
- return;
- }
-
- if (strcmp(keyword, "Appt") == 0) {
- g_print("New Appointment\n");
- item_type = 1;
-
- } else if (strcmp(keyword, "Note") == 0) {
- g_print("New Note\n");
- item_type = 2;
- } else
- g_print("New ??? (%s)\n", keyword);
-
- incomplete_item = TRUE;
- myevent = g_malloc0(sizeof(struct event));
- while(incomplete_item) {
- if (! skip_whitespace(fp) || ! peek_char(fp, &c)) {
- g_warning("Incomplete item\n");
- fclose(fp);
- return;
- }
- if (c == closer[0]) {
- (void)fgetc(fp);
- g_print("done!\n");
- incomplete_item = FALSE;
- g_slist_append(eventlist, myevent);
- break;
- }
-
- if (! getid(fp,keyword) || ! skip_whitespace(fp) ||
- ! skip_chars(fp, opener) ) {
- g_error("Error reading item property name");
- fclose(fp);
- return;
- }
- if ( ! parse_item(fp, myevent, keyword) && ! parse_appointment(fp, myevent, keyword) ) {
- g_warning("Unable to parse line\n");
- fclose(fp);
- return;
- }
- if ( ! skip_whitespace(fp) || ! skip_chars(fp, closer)) {
- g_error("Error reading item property");
- fclose(fp);
- return;
- }
- } /* while */
- } /* while */
-}
-
-
-
-
-int main(int argc, char *argv[])
-{
-
- eventlist = g_slist_alloc();
- parse_ical_file("/home/csmall/.calendar");
- g_slist_foreach(eventlist, print_glist, NULL);
- return 0;
-}
-
diff --git a/calendar/main.c b/calendar/main.c
deleted file mode 100644
index ebb008927f..0000000000
--- a/calendar/main.c
+++ /dev/null
@@ -1,699 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (quartic@gimp.org)
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <string.h>
-#include <ctype.h>
-#include "alarm.h"
-#include "calendar.h"
-#include "eventedit.h"
-#include "gnome-cal.h"
-#include "main.h"
-#include "timeutil.h"
-
-#define COOKIE_USER_HOME_DIR ((char *) -1)
-
-/* 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;
-
-/* The user's default calendar file */
-char *user_calendar_file;
-
-/* 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;
-
-/* Number of calendars active */
-int active_calendars = 0;
-
-/* A list of all of the calendars started */
-GList *all_calendars = NULL;
-
-static void new_calendar (char *full_name, char *calendar_file, char *geometry, char *view);
-
-/* For dumping part of a calendar */
-static time_t from_t, to_t;
-
-/* File to load instead of the user default's file */
-static char *load_file;
-
-/* If set, show events for the specified date and quit */
-static int show_events;
-
-static void
-init_username (void)
-{
- char *p;
- struct passwd *passwd;
-
- passwd = getpwuid (getuid ());
- if ((p = passwd->pw_name)) {
- char *comma;
-
- user_name = g_strdup (p);
- full_name = g_strdup (passwd->pw_gecos);
-
- /* Keep only the name from the gecos field */
- if ((comma = strchr (full_name, ',')) != NULL)
- *comma = 0;
- } else {
- if ((p = getenv ("USER"))) {
- user_name = g_strdup (p);
- full_name = g_strdup (p);
- return;
- } else {
- user_name = g_strdup ("unknown");
- full_name = g_strdup ("unknown");
- }
- }
- endpwent ();
-}
-
-static int
-range_check_hour (int hour)
-{
- if (hour < 0)
- hour = 0;
- else if (hour >= 24)
- hour = 23;
-
- return hour;
-}
-
-/*
- * Initializes the calendar internal variables, loads defaults
- */
-static void
-init_calendar (void)
-{
- init_username ();
- user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
-
- gnome_config_push_prefix (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 = range_check_hour (gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0"));
-
- if (day_end < day_begin){
- day_begin = 8;
- day_end = 17;
- }
-
- gnome_config_pop_prefix ();
-}
-
-static void save_calendar_cmd (GtkWidget *widget, void *data);
-
-static void
-about_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkWidget *about;
- const gchar *authors[] = {
- "Miguel de Icaza (miguel@kernel.org)",
- "Federico Mena (quartic@gimp.org)",
- "Arturo Espinosa (arturo@nuclecu.unam.mx)",
- NULL
- };
-
- about = gnome_about_new (_("Gnome Calendar"), VERSION,
- "(C) 1998 the Free Software Foundation",
- authors,
- _("The GNOME personal calendar and schedule manager."),
- NULL);
- gnome_dialog_run_and_destroy (GNOME_DIALOG (about));
-#if 0
- gtk_widget_show (about);
-#endif
-}
-
-static void
-display_objedit (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
- iCalObject *ico;
-
- /* Default to the day the user is looking at */
- ico = ical_new ("", user_name, "");
- ico->new = 1;
- ico->dtstart = time_add_minutes (gcal->current_display, day_begin * 60);
- ico->dtend = time_add_minutes (ico->dtstart, day_begin * 60 + 30 );
-
- ee = event_editor_new (gcal, ico);
- gtk_widget_show (ee);
-}
-
-static void
-display_objedit_today (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
-
- ee = event_editor_new (gcal, NULL);
- gtk_widget_show (ee);
-}
-
-static void
-close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
-{
- all_calendars = g_list_remove (all_calendars, gcal);
- if (gcal->cal->modified){
- if (!gcal->cal->filename)
- save_calendar_cmd (widget, gcal);
- else
- calendar_save (gcal->cal, gcal->cal->filename);
- }
-
- gtk_widget_destroy (GTK_WIDGET (gcal));
- active_calendars--;
-
- if (active_calendars == 0)
- gtk_main_quit ();
-}
-
-/*
- * Updates all of the open calendars when the day_begin/day_end values have changed
- */
-void
-day_range_changed (void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next){
- GnomeCalendar *cal = GNOME_CALENDAR (l->data);
-
- gtk_widget_queue_resize (cal->notebook);
- }
-}
-
-static void
-quit_cmd (void)
-{
- while (all_calendars){
- GnomeCalendar *cal = GNOME_CALENDAR (all_calendars->data);
-
- close_cmd (GTK_WIDGET (cal), cal);
- }
-}
-
-static void
-previous_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- gnome_calendar_previous (gcal);
-}
-
-static void
-next_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- gnome_calendar_next (gcal);
-}
-
-static void
-today_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- gnome_calendar_goto (gcal, time (NULL));
-}
-
-static void
-goto_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- goto_dialog (gcal);
-}
-
-static void
-new_calendar_cmd (GtkWidget *widget, void *data)
-{
- new_calendar (full_name, NULL, NULL, NULL);
-}
-
-static void
-open_ok (GtkWidget *widget, GtkFileSelection *fs)
-{
- /* FIXME: find out who owns this calendar and use that name */
- new_calendar ("Somebody", gtk_file_selection_get_filename (fs), NULL, NULL);
-
- gtk_widget_destroy (GTK_WIDGET (fs));
-}
-
-static void
-open_calendar_cmd (GtkWidget *widget, void *data)
-{
- 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;
-
- gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs)));
- gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal");
-
- if (gcal->cal->filename)
- g_free (gcal->cal->filename);
-
- gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs));
- calendar_save (gcal->cal, gcal->cal->filename);
- gtk_main_quit ();
-}
-
-static gint
-close_save (GtkWidget *w)
-{
- gtk_main_quit ();
- return TRUE;
-}
-
-static void
-save_as_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkFileSelection *fs;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar")));
- gtk_object_set_user_data (GTK_OBJECT (fs), 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
-save_calendar_cmd (GtkWidget *widget, void *data)
-{
- GnomeCalendar *gcal = data;
-
- if (gcal->cal->filename)
- calendar_save (gcal->cal, gcal->cal->filename);
- else
- save_as_calendar_cmd (widget, data);
-}
-
-static GnomeUIInfo gnome_cal_file_menu [] = {
- { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW },
-
- { GNOME_APP_UI_ITEM, N_("Open calendar..."), NULL, open_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN },
-
- { GNOME_APP_UI_ITEM, N_("Save calendar"), NULL, save_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
-
- { GNOME_APP_UI_ITEM, N_("Save calendar as..."), NULL, save_as_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
-
- { GNOME_APP_UI_SEPARATOR },
- { GNOME_APP_UI_ITEM, N_("Close this calendar"), NULL, close_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
-
- { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_about_menu [] = {
- { GNOME_APP_UI_ITEM, N_("About..."), NULL, about_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT },
- GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_HELP ("cal"),
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_edit_menu [] = {
- { GNOME_APP_UI_ITEM, N_("New appointment..."), NULL, display_objedit },
- { GNOME_APP_UI_ITEM, N_("New appointment for today..."), NULL, display_objedit_today },
- GNOMEUIINFO_SEPARATOR,
- { GNOME_APP_UI_ITEM, N_("Properties..."), NULL, properties, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP },
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_menu [] = {
- { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu },
- { GNOME_APP_UI_SUBTREE, N_("Calendar"), NULL, &gnome_cal_edit_menu },
- { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu },
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_toolbar [] = {
- { GNOME_APP_UI_ITEM, N_("New"), N_("Create a new appointment"), display_objedit, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_NEW },
-
- GNOMEUIINFO_SEPARATOR,
-
- { GNOME_APP_UI_ITEM, N_("Prev"), N_("Go back in time"), previous_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK },
-
- { GNOME_APP_UI_ITEM, N_("Today"), N_("Go to present time"), today_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HOME },
-
- { GNOME_APP_UI_ITEM, N_("Next"), N_("Go forward in time"), next_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD },
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Go to"), N_("Go to a specific date"), goto_clicked, GNOME_STOCK_PIXMAP_STOP),
-
- GNOMEUIINFO_END
-};
-
-static void
-setup_menu (GtkWidget *gcal)
-{
- gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal);
- gnome_app_create_toolbar_with_data (GNOME_APP (gcal), gnome_toolbar, gcal);
-}
-
-static gint
-calendar_close_event (GtkWidget *widget, GdkEvent *event, GnomeCalendar *gcal)
-{
- close_cmd (widget, gcal);
- return TRUE;
-}
-
-static void
-new_calendar (char *full_name, char *calendar_file, char *geometry, char *page)
-{
- 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 (width != -1)
- gtk_widget_set_usize (toplevel, width, height);
- }
- setup_menu (toplevel);
-
- if (page)
- gnome_calendar_set_view (GNOME_CALENDAR (toplevel), page);
-
- if (calendar_file && g_file_exists (calendar_file))
- gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file);
- else
- GNOME_CALENDAR (toplevel)->cal->filename = g_strdup (calendar_file);
-
- 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);
- gtk_widget_show (toplevel);
-}
-
-static void
-process_dates (void)
-{
- if (!from_t)
- from_t = time_start_of_day (time (NULL));
-
- if (!to_t || to_t < from_t)
- to_t = time_add_day (from_t, 1);
-}
-
-enum {
- GEOMETRY_KEY = -1,
- USERFILE_KEY = -2,
- VIEW_KEY = -3
-};
-
-static struct argp_option argp_options [] = {
- { "events", 'e', NULL, 0, N_("Show events and quit"), 0 },
- { "from", 'f', N_("DATE"), 0, N_("Specifies start date [for --events]"), 1 },
- { "file", 'F', N_("FILE"), 0, N_("File to load calendar from"), 1 },
- { "userfile", USERFILE_KEY, NULL, 0, N_("Load the user calendar"), 1 },
- { "geometry", GEOMETRY_KEY, N_("GEOMETRY"), 0, N_("Geometry for starting up"), 1 },
- { "view", VIEW_KEY, N_("VIEW"), 0, N_("The startup view mode"), 1 },
- { "to", 't', N_("DATE"), 0, N_("Specifies ending date [for --events]"), 1 },
- { NULL, 0, NULL, 0, NULL, 0 },
-};
-
-/* Lists used to startup various GnomeCalendars */
-static GList *start_calendars;
-static GList *start_geometries;
-static GList *start_views;
-
-static int
-same_day (struct tm *a, struct tm *b)
-{
- return (a->tm_mday == b->tm_mday &&
- a->tm_mon == b->tm_mon &&
- a->tm_year == b->tm_year);
-}
-
-static void
-dump_events (void)
-{
- Calendar *cal;
- GList *l;
- char *s;
- time_t now = time (NULL);
- struct tm today = *localtime (&now);
-
- process_dates ();
- init_calendar ();
-
- cal = calendar_new (full_name);
- s = calendar_load (cal, load_file ? load_file : user_calendar_file);
- if (s){
- printf ("error: %s\n", s);
- exit (1);
- }
- l = calendar_get_events_in_range (cal, from_t, to_t);
- for (; l; l = l->next){
- char start [80], end [80];
- CalendarObject *co = l->data;
- struct tm ts, te;
- char *format;
-
- ts = *localtime (&co->ev_start);
- te = *localtime (&co->ev_end);
-
- if (same_day (&today, &ts))
- format = "%H:%M";
- else
- format = "%A %d, %H:%M";
- strftime (start, sizeof (start), format, &ts);
-
- if (!same_day (&ts, &te))
- format = "%A %d, %H:%M";
- strftime (end, sizeof (start), format, &te);
-
- printf ("%s -- %s\n", start, end);
- printf (" %s\n", co->ico->summary);
- }
- calendar_destroy_event_list (l);
- calendar_destroy (cal);
- exit (0);
-}
-
-extern time_t get_date ();
-
-static error_t
-parse_an_arg (int key, char *arg, struct argp_state *state)
-{
- switch (key){
- case 'f':
- from_t = get_date (arg, NULL);
- break;
-
- case 't':
- to_t = get_date (arg, NULL);
- break;
-
- case GEOMETRY_KEY:
- start_geometries = g_list_append (start_geometries, arg);
- break;
-
- case USERFILE_KEY:
- /* This is a special key that tells the program to load
- * the user's calendar file. This allows session management
- * to work even if the User's home directory changes location
- * (ie, on a networked setup).
- */
- arg = COOKIE_USER_HOME_DIR;
- /* fall trough */
-
- case VIEW_KEY:
- start_views = g_list_append (start_views, arg);
- break;
-
- case 'F':
- start_calendars = g_list_append (start_calendars, arg);
- break;
-
- case 'e':
- show_events = 1;
- break;
-
- case ARGP_KEY_END:
- if (show_events)
- dump_events ();
-
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return 0;
-}
-
-static struct argp parser =
-{
- argp_options, parse_an_arg, NULL, NULL, NULL, NULL, NULL
-};
-
-static void
-session_die (void)
-{
- quit_cmd ();
-}
-
-/*
- * Save the session callback
- */
-static int
-session_save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_style, gint shutdown,
- GnomeInteractStyle interact_style, gint fast, gpointer client_data)
-{
- char *sess_id;
- char **argv = (char **) g_malloc (sizeof (char *) * ((active_calendars * 6) + 3));
- GList *l, *free_list = 0;
- int i;
-
- sess_id = gnome_client_get_id (client);
-
- argv [0] = client_data;
- for (i = 1, l = all_calendars; l; l = l->next){
- GnomeCalendar *gcal = GNOME_CALENDAR (l->data);
- char *geometry;
-
- geometry = gnome_geometry_string (GTK_WIDGET (gcal)->window);
-
- if (strcmp (gcal->cal->filename, user_calendar_file) == 0)
- argv [i++] = "--userfile";
- else {
- argv [i++] = "--file";
- argv [i++] = gcal->cal->filename;
- }
- argv [i++] = "--geometry";
- argv [i++] = geometry;
- argv [i++] = "--view";
- argv [i++] = gnome_calendar_get_current_view_name (gcal);
- free_list = g_list_append (free_list, geometry);
- calendar_save (gcal->cal, gcal->cal->filename);
- }
- argv [i] = NULL;
- gnome_client_set_clone_command (client, i, argv);
- gnome_client_set_restart_command (client, i, argv);
-
- for (l = free_list; l; l = l->next)
- g_free (l->data);
- g_list_free (free_list);
-
- return 1;
-}
-
-int
-main(int argc, char *argv[])
-{
- GnomeClient *client;
-
- argp_program_version = VERSION;
-
- bindtextdomain(PACKAGE, GNOMELOCALEDIR);
- textdomain(PACKAGE);
-
- client = gnome_client_new_default ();
- if (client){
- gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
- GTK_SIGNAL_FUNC (session_save_state), argv [0]);
- gtk_signal_connect (GTK_OBJECT (client), "die",
- GTK_SIGNAL_FUNC (session_die), NULL);
- }
- gnome_init ("calendar", &parser, argc, argv, 0, NULL);
-
- process_dates ();
- alarm_init ();
- init_calendar ();
-
- /*
- * Load all of the calendars specifies in the command line with
- * the geometry specificied -if any-
- */
- if (start_calendars){
- GList *p, *g, *v;
- char *title;
-
- p = start_calendars;
- g = start_geometries;
- v = start_views;
- while (p){
- char *file = p->data;
- char *geometry = g ? g->data : NULL;
- char *page_name = v ? v->data : NULL;
-
- if (file == COOKIE_USER_HOME_DIR)
- file = user_calendar_file;
-
- if (strcmp (file, user_calendar_file) == 0)
- title = full_name;
- else
- title = file;
- new_calendar (title, file, geometry, page_name);
-
- p = p->next;
- if (g)
- g = g->next;
- if (v)
- v = v->next;
- }
- g_list_free (p);
- } else {
- char *geometry = start_geometries ? start_geometries->data : NULL;
- char *page_name = start_views ? start_views->data : NULL;
-
- new_calendar (full_name, user_calendar_file, geometry, page_name);
- }
- gtk_main ();
- return 0;
-}
-
diff --git a/calendar/main.h b/calendar/main.h
deleted file mode 100644
index 374f8199e6..0000000000
--- a/calendar/main.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-extern int day_begin, day_end;
-extern char *user_name;
-extern int am_pm_flag;
-
-void properties (void);
-void day_range_changed (void);
-void goto_dialog (GnomeCalendar *gcal);
-
-#endif
diff --git a/calendar/menus.c b/calendar/menus.c
deleted file mode 100644
index c42a52a981..0000000000
--- a/calendar/menus.c
+++ /dev/null
@@ -1,147 +0,0 @@
-#include <gtk/gtk.h>
-#include <strings.h>
-
-#include "gncal.h"
-
-
-static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar *
- path);
-static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar
-key, gchar modifiers, gchar * path);
-void menus_init(void);
-void menus_create(GtkMenuEntry * entries, int nmenu_entries);
-
-
-/* this is the GtkMenuEntry structure used to create new menus. The
- * first member is the menu definition string. The second, the
- * default accelerator key used to access this menu function with
- * the keyboard. The third is the callback function to call when
- * this menu item is selected (by the accelerator key, or with the
- * mouse.) The member is the data to pass to your callback function.
- */
-
-static GtkMenuEntry menu_items[] =
-{
- {"<Main>/File/Exit", "<control>Q", menu_file_quit, NULL},
- {"<Main>/Help/About", NULL, menu_help_about, NULL},
-
-};
-
-static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
-
-static int initialize = TRUE;
-static GtkMenuFactory *factory = NULL;
-static GtkMenuFactory *subfactory[1];
-static GHashTable *entry_ht = NULL;
-
-void get_main_menu(GtkWidget ** menubar, GtkAcceleratorTable ** table)
-{
- if (initialize)
- menus_init();
-
- if (menubar)
- *menubar = subfactory[0]->widget;
- if (table)
- *table = subfactory[0]->table;
-}
-
-void menus_init(void)
-{
- if (initialize) {
- initialize = FALSE;
-
- factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
- subfactory[0] = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
-
- gtk_menu_factory_add_subfactory(factory, subfactory[0], "<Main>");
- menus_create(menu_items, nmenu_items);
- }
-}
-
-void menus_create(GtkMenuEntry * entries, int nmenu_entries)
-{
- char *accelerator;
- int i;
-
- if (initialize)
- menus_init();
-
- if (entry_ht)
- for (i = 0; i < nmenu_entries; i++) {
- accelerator = g_hash_table_lookup(entry_ht, entries[i].path);
- if (accelerator) {
- if (accelerator[0] == '\0')
- entries[i].accelerator = NULL;
- else
- entries[i].accelerator = accelerator;
- }
- }
- gtk_menu_factory_add_entries(factory, entries, nmenu_entries);
-
-
- for (i = 0; i < nmenu_entries; i++)
- if (entries[i].widget) {
- gtk_signal_connect(GTK_OBJECT(entries[i].widget), "install_accelerator",
- (GtkSignalFunc) menus_install_accel,
- entries[i].path);
- gtk_signal_connect(GTK_OBJECT(entries[i].widget), "remove_accelerator",
- (GtkSignalFunc) menus_remove_accel,
- entries[i].path);
- }
-}
-
-static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar
-key, gchar modifiers, gchar * path)
-{
- char accel[64];
- char *t1, t2[2];
-
- accel[0] = '\0';
- if (modifiers & GDK_CONTROL_MASK)
- strcat(accel, "<control>");
- if (modifiers & GDK_SHIFT_MASK)
- strcat(accel, "<shift>");
- if (modifiers & GDK_MOD1_MASK)
- strcat(accel, "<alt>");
-
- t2[0] = key;
- t2[1] = '\0';
- strcat(accel, t2);
-
- if (entry_ht) {
- t1 = g_hash_table_lookup(entry_ht, path);
- g_free(t1);
- } else
- entry_ht = g_hash_table_new(g_string_hash, g_string_equal);
-
- g_hash_table_insert(entry_ht, path, g_strdup(accel));
-
- return TRUE;
-}
-
-static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar *
- path)
-{
- char *t;
-
- if (entry_ht) {
- t = g_hash_table_lookup(entry_ht, path);
- g_free(t);
-
- g_hash_table_insert(entry_ht, path, g_strdup(""));
- }
-}
-
-void menus_set_sensitive(char *path, int sensitive)
-{
- GtkMenuPath *menu_path;
-
- if (initialize)
- menus_init();
-
- menu_path = gtk_menu_factory_find(factory, path);
- if (menu_path)
- gtk_widget_set_sensitive(menu_path->widget, sensitive);
- else
- g_warning("Unable to set sensitivity for menu which doesn't exist: %s", path);
-}
diff --git a/calendar/menus.h b/calendar/menus.h
deleted file mode 100644
index 2cf5ab08e2..0000000000
--- a/calendar/menus.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __MENUS_H__
-#define __MENUS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include <gtk/gtk.h>
-
-void get_main_menu (GtkWidget **menubar, GtkAcceleratorTable **table);
-void menus_create(GtkMenuEntry *entries, int nmenu_entries);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MENUS_H__ */
diff --git a/calendar/month-view.c b/calendar/month-view.c
deleted file mode 100644
index a23938b350..0000000000
--- a/calendar/month-view.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include "month-view.h"
-
-
-static void month_view_class_init (MonthViewClass *class);
-static void month_view_init (MonthView *mv);
-static void month_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void month_view_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-
-static GnomeCanvasClass *parent_class;
-
-
-GtkType
-month_view_get_type (void)
-{
- static GtkType month_view_type = 0;
-
- if (!month_view_type) {
- GtkTypeInfo month_view_info = {
- "MonthView",
- sizeof (MonthView),
- sizeof (MonthViewClass),
- (GtkClassInitFunc) month_view_class_init,
- (GtkObjectInitFunc) month_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- month_view_type = gtk_type_unique (gnome_canvas_get_type (), &month_view_info);
- }
-
- return month_view_type;
-}
-
-static void
-month_view_class_init (MonthViewClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- widget_class->size_request = month_view_size_request;
- widget_class->size_allocate = month_view_size_allocate;
-}
-
-static void
-month_view_init (MonthView *mv)
-{
- mv->mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (mv->canvas.root));
- gnome_canvas_item_set (mv->mitem,
- "x", 0.0,
- "y", 0.0,
- "anchor", GTK_ANCHOR_NW,
- "day_anchor", GTK_ANCHOR_NE,
-#if 0
- "start_on_monday", TRUE,
-#endif
- NULL);
-}
-
-GtkWidget *
-month_view_new (GnomeCalendar *calendar)
-{
- MonthView *mv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- mv = gtk_type_new (month_view_get_type ());
-
- mv->calendar = calendar;
-
- return GTK_WIDGET (mv);
-}
-
-static void
-month_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (requisition != NULL);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_request)
- (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
-
- requisition->width = 200;
- requisition->height = 150;
-}
-
-static void
-month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- MonthView *mv;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (allocation != NULL);
-
- mv = MONTH_VIEW (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
- (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height);
- gnome_canvas_item_set (mv->mitem,
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
- NULL);
-}
diff --git a/calendar/month-view.h b/calendar/month-view.h
deleted file mode 100644
index 0f35817d78..0000000000
--- a/calendar/month-view.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef MONTH_VIEW_H
-#define MONTH_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_MONTH_VIEW (month_view_get_type ())
-#define MONTH_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_MONTH_VIEW, MonthView))
-#define MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_MONTH_VIEW, MonthViewClass))
-#define IS_MONTH_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_MONTH_VIEW))
-#define IS_MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_MONTH_VIEW))
-
-
-typedef struct _MonthView MonthView;
-typedef struct _MonthViewClass MonthViewClass;
-
-struct _MonthView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- GnomeCanvasItem *mitem; /* The canvas month item used by this month view */
-};
-
-struct _MonthViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType month_view_get_type (void);
-
-/* Creates a new month view widget associated to the specified calendar */
-GtkWidget *month_view_new (GnomeCalendar *calendar);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/objedit.c b/calendar/objedit.c
deleted file mode 100644
index 3a15e76f82..0000000000
--- a/calendar/objedit.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Calendar Object editor.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#include <gnome.h>
-
-/* Day start and day end in hours */
-int day_start, day_end;
-
-typedef struct {
- GtkWidget *property_box;
-
- GtkWidget *general;
-
- GtkTable *general_table;
- GtkWidget *general_time_table;
-} ObjEditor;
-
-GtkWidget *
-calendar_object_editor_setup_time_frame (ObjEditor *oe)
-{
- GtkWidget *frame;
- GtkWidget *start_time, *end_time;
- GtkTable *t;
-
- frame = gtk_frame_new (_("Time"));
- t = GTK_TABLE (oe->general_time_table = gtk_table_new (1, 1, 0));
- gtk_container_add (GTK_CONTAINER (frame), oe->general_time_table);
-
- start_time = gnome_date_edit_new (0);
- end_time = gnome_date_edit_new (0);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_start, day_end);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) end_time, day_start, day_end);
-
- gtk_table_attach (t, gtk_label_new (_("Start time")), 1, 2, 1, 2, 0, 0, 0, 0);
- gtk_table_attach (t, gtk_label_new (_("End time")), 1, 2, 2, 3, 0, 0, 0, 0);
-
- gtk_table_attach (t, start_time, 2, 3, 1, 2, 0, 0, 0, 0);
- gtk_table_attach (t, end_time, 2, 3, 2, 3, 0, 0, 0, 0);
- return frame;
-}
-
-void
-calendar_general_editor_new (ObjEditor *oe)
-{
- GtkWidget *frame;
-
- oe->general = gtk_hbox_new (0, 0);
- oe->general_table = (GtkTable *) gtk_table_new (1, 1, 0);
-
- gtk_box_pack_start (GTK_BOX (oe->general), (GtkWidget *) oe->general_table, 1, 1, 0);
-
- frame = calendar_object_editor_setup_time_frame (oe);
- gtk_table_attach (oe->general_table, frame,
- 1, 2, 1, 2,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-
- gnome_property_box_append_page (oe->property_box, oe->general, gtk_label_new (_("General")));
-}
-
-ObjEditor *
-calendar_object_editor_new (void)
-{
- ObjEditor *oe;
-
- oe = g_new0 (ObjEditor, 1);
-
- oe->property_box = gnome_property_box_new ();
- calendar_general_editor_new (oe);
-
- return oe;
-}
-
-main (int argc, char *argv [])
-{
- ObjEditor *oe;
-
- day_start = 7;
- day_end = 19;
- gnome_init ("myapp", NULL, argc, argv, 0, NULL);
-
- oe = calendar_object_editor_new ();
- gtk_widget_show_all (oe->property_box);
- gtk_main ();
-}
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
deleted file mode 100644
index d8ca3fe5db..0000000000
--- a/calendar/pcs/calobj.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/*
- * Calendar objects implementations.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <string.h>
-#include <glib.h>
-#include "calobj.h"
-#include "timeutil.h"
-#include "versit/vcc.h"
-
-iCalObject *
-ical_object_new (void)
-{
- iCalObject *ico;
-
- ico = g_new0 (iCalObject, 1);
-
- ico->seq = -1;
- ico->dtstamp = time (NULL);
-
- return ico;
-}
-
-static void
-default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
-{
- alarm->enabled = 0;
- alarm->type = type;
-
- if (type != ALARM_MAIL){
- alarm->count = 15;
- alarm->units = ALARM_MINUTES;
- } else {
- alarm->count = 1;
- alarm->units = ALARM_DAYS;
- }
-
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (def_mail);
- else
- alarm->data = g_strdup ("");
-}
-
-iCalObject *
-ical_new (char *comment, char *organizer, char *summary)
-{
- iCalObject *ico;
-
- ico = ical_object_new ();
-
- ico->comment = g_strdup (comment);
- ico->organizer = g_strdup (organizer);
- ico->summary = g_strdup (summary);
- ico->class = g_strdup ("PUBLIC");
- ico->status = g_strdup ("NEEDS ACTION");
-
- default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY);
- default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM);
- default_alarm (ico, &ico->malarm, organizer, ALARM_MAIL);
- default_alarm (ico, &ico->aalarm, organizer, ALARM_AUDIO);
-
- return 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);
-}
-
-#define free_if_defined(x) if (x){ g_free (x); x = 0; }
-#define lfree_if_defined(x) if (x){ list_free (x); x = 0; }
-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);
-}
-
-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))
- ;
- }
-}
-
-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
-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;
-}
-
-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;
-}
-
-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){
- 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);
- weekdaylist (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
- */
- 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');
- 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
- */
-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;
- }
-
- /* uid */
- if (has (o, VCUniqueStringProp)){
- ical->uid = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* 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);
- } 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 = "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);
- }
-
- /* related */
- if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo));
- 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)){
- ical->url = g_strdup (str_val (vo));
- 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);
- }
- }
- }
-
- /* 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);
- }
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_destroy (ical);
- return NULL;
- }
- free (the_str);
- }
- 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_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 (strlen (ical->summary)){
- s = addPropValue (o, VCSummaryProp, ical->summary);
- if (strchr (ical->summary, '\n'))
- addProp (s, VCQuotedPrintableProp);
- } else {
- addPropValue (o, VCSummaryProp, _("Appointment"));
- }
-
- /* 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->categories)
- store_list (o, VCCategoriesProp, ical->resources);
-
- /* priority */
- addPropValue (o, VCPriorityProp, to_str (ical->priority));
-
- /* transparency */
- addPropValue (o, VCTranspProp, to_str (ical->transp));
-
- /* related */
- if (ical->related)
- store_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);
- 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_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);
- 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;
-}
-
-static int
-generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
-{
- struct tm dt_start, dt_end, ref;
- time_t s_t, e_t;
-
- dt_start = *localtime (&ico->dtstart);
- dt_end = *localtime (&ico->dtend);
- ref = *localtime (&reference);
-
- dt_start.tm_mday = ref.tm_mday;
- dt_start.tm_mon = ref.tm_mon;
- dt_start.tm_year = ref.tm_year;
-
- dt_end.tm_mday = ref.tm_mday;
- dt_end.tm_mon = ref.tm_mon;
- dt_end.tm_year = ref.tm_year;
-
- s_t = mktime (&dt_start);
- if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
- return 1;
-
- e_t = mktime (&dt_end);
-
- if (s_t == -1 || e_t == -1){
- g_warning ("Produced invalid dates!\n");
- return 0;
- }
- return (*cb)(ico, s_t, e_t, closure);
-}
-
-#define time_in_range(x,a,b) ((x >= a) && (b ? x <= 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)
-{
- Recurrence *recur = ico->recur;
- time_t current;
- int first_week_day, i;
-
- if (!ico->recur){
- if ((end && (ico->dtstart < end) && ico->dtend > start) ||
- (end == 0 && ico->dtend > start)){
- time_t ev_s, ev_e;
-
- ev_s = ico->dtstart < start ? start : ico->dtstart;
- ev_e = ico->dtend > end ? end : ico->dtend;
- (*cb)(ico, ev_s, ev_e, closure);
- }
- return;
- }
-
- /* The event has a recurrence rule */
- if (end != 0){
- if (ico->dtstart > end)
- return;
- if (!IS_INFINITE (recur) && recur->enddate < start)
- return;
- }
-
- current = ico->dtstart;
- switch (recur->type){
- case RECUR_DAILY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, recur)){
- if (!generate (ico, current, cb, closure))
- return;
- }
-
- /* Advance */
- current = time_add_day (current, recur->interval);
-
- if (current == -1){
- g_warning ("RECUR_DAILY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
- break;
-
- case RECUR_WEEKLY:
- do {
- struct tm *tm = localtime (&current);
-
- if (time_in_range (current, start, end) && recur_in_range (current, recur)){
- if (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, (recur->interval-1) * 7 + 1);
- else
- current = time_add_day (current, 1);
-
- if (current == -1){
- g_warning ("RECUR_WEEKLY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
- break;
-
- case RECUR_MONTHLY_BY_POS:
- /* FIXME: We only deal with positives now */
- if (recur->u.month_pos < 0)
- return;
-
- if (recur->u.month_pos == 0)
- return;
-
- first_week_day = 7;
- for (i = 6; i >= 0; i--)
- if (recur->weekday & (1 << i))
- first_week_day = i;
-
- /* This should not happen, but take it into account */
- if (first_week_day == 7)
- return;
-
- do {
- struct tm tm;
- time_t t;
- int week_day_start;
-
- tm = *localtime (&current);
- tm.tm_mday = 1;
- t = mktime (&tm);
- tm = *localtime (&t);
- week_day_start = tm.tm_wday;
-
- tm.tm_mday = 7 * (recur->u.month_pos -
- ((week_day_start <= first_week_day ) ? 1 : 0)) -
- (week_day_start - first_week_day) + 1;
-
- t = mktime (&tm);
-
- if (time_in_range (t, start, end) && recur_in_range (current, recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance a month */
- current = mktime (&tm);
-
- tm.tm_mday = 1;
- tm.tm_mon += 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 = localtime (&current);
- time_t t;
- int p;
-
- p = tm->tm_mday;
- tm->tm_mday = recur->u.month_day;
- t = mktime (tm);
- if (time_in_range (t, start, end) && recur_in_range (current, recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance a month */
- tm->tm_mday = p;
- tm->tm_mon += recur->interval;
- current = mktime (tm);
- if (current == -1){
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
-
- case RECUR_YEARLY_BY_MONTH:
- case RECUR_YEARLY_BY_DAY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
- current = time_add_year (current, recur->interval);
- } while (current < end || (end == 0));
- }
-}
-
-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_end_of_day (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;
-}
diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h
deleted file mode 100644
index d18acd4f8a..0000000000
--- a/calendar/pcs/calobj.h
+++ /dev/null
@@ -1,199 +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 "versit/vcc.h"
-
-BEGIN_GNOME_DECLS
-
-enum AlarmType {
- ALARM_MAIL,
- ALARM_PROGRAM,
- ALARM_DISPLAY,
- ALARM_AUDIO
-};
-
-enum AlarmUnit {
- ALARM_MINUTES,
- ALARM_HOURS,
- ALARM_DAYS
-};
-
-typedef struct {
- enum AlarmType type;
- int enabled;
- int count;
- enum AlarmUnit units;
- char *data;
-
- /* 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 struct {
- int valid; /* true if the Geography was specified */
- double latitude;
- double longitude;
-} iCalGeo;
-
-typedef enum {
- ICAL_OPAQUE,
- ICAL_TRANSPARENT
-} iCalTransp;
-
-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;
-
-#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 */
- 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 */
- time_t dtstamp;
- time_t dtstart;
- time_t dtend;
- GList *exdate; /* type: one or more time_t's */
- GList *exrule; /* type: one or more RECUR */
- iCalGeo geo;
- time_t last_mod;
- char *location;
- char *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;
-
- Recurrence *recur;
-
- int new;
- void *user_data; /* Generic data pointer */
-} 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_destroy (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);
-
-/* Returns the number of seconds configured to trigger the alarm in advance to an event */
-int alarm_compute_offset (CalendarAlarm *a);
-
-END_GNOME_DECLS
-
-#endif
-
diff --git a/calendar/popup-menu.c b/calendar/popup-menu.c
deleted file mode 100644
index 3686183146..0000000000
--- a/calendar/popup-menu.c
+++ /dev/null
@@ -1,37 +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"
-
-
-void
-popup_menu (struct menu_item *items, int nitems, GdkEventButton *event)
-{
- GtkWidget *menu;
- GtkWidget *item;
- int i;
-
- menu = gtk_menu_new (); /* FIXME: this baby is never freed */
-
- 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/popup-menu.h b/calendar/popup-menu.h
deleted file mode 100644
index a4590dbb98..0000000000
--- a/calendar/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/prop.c b/calendar/prop.c
deleted file mode 100644
index 58abe2f8db..0000000000
--- a/calendar/prop.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Calendar properties dialog box
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza <miguel@kernel.org>
- */
-#include <config.h>
-#include <gnome.h>
-#include "gnome-cal.h"
-#include "main.h"
-
-static GtkWidget *prop_win, *r1;
-static GtkObject *sa, *ea;
-
-static void
-start_changed (GtkAdjustment *sa, GtkAdjustment *ea)
-{
- if (sa->value > 23.0){
- sa->value = 23.0;
- ea->value = 24.0;
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- } else if (sa->value >= ea->value){
- ea->value = sa->value + 1.0;
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- }
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-static void
-end_changed (GtkAdjustment *ea, GtkAdjustment *sa)
-{
- if (ea->value < 1.0){
- ea->value = 1.0;
- sa->value = 0.0;
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- } else if (ea->value < sa->value){
- sa->value = ea->value - 1.0;
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- }
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-/* justifies the text */
-static GtkWidget *
-align (GtkWidget *w, float side)
-{
- GtkWidget *a;
-
- a = gtk_alignment_new (side, 0.5, 1.0, 1.0);
- gtk_container_add (GTK_CONTAINER (a), w);
-
- return a;
-}
-
-static int
-prop_cancel (void)
-{
- prop_win = 0;
- return FALSE;
-}
-
-static void
-prop_apply (GtkWidget *w, int page)
-{
- if (page != -1)
- return;
-
- day_begin = GTK_ADJUSTMENT (sa)->value;
- day_end = GTK_ADJUSTMENT (ea)->value;
- gnome_config_set_int ("/calendar/Calendar/Day start", day_begin);
- gnome_config_set_int ("/calendar/Calendar/Day end", day_end);
-
- am_pm_flag = (GTK_TOGGLE_BUTTON (r1)->active) == 0;
- gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag);
-
- gnome_config_sync ();
-
- day_range_changed ();
-}
-
-static void
-toggled ()
-{
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-void
-properties (void)
-{
- GtkWidget *t, *l, *ds, *de;
- GtkWidget *r2;
-
- if (prop_win)
- return;
-
- prop_win = gnome_property_box_new ();
-
- t = gtk_table_new (0, 0, 0);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), t,
- gtk_label_new (_("Calendar global parameters")));
-
- l = gtk_label_new (_("Day start:"));
- gtk_table_attach (GTK_TABLE (t), l,
- 0, 1, 0, 1, 0, 0, 0, 0);
- sa = gtk_adjustment_new (day_begin, 0.0, 25.00, 1.0, 1.0, 1.0);
- ds = gtk_hscale_new (GTK_ADJUSTMENT (sa));
- gtk_scale_set_digits (GTK_SCALE (ds), 0);
- gtk_table_attach (GTK_TABLE (t), ds,
- 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- l = gtk_label_new (_("Day end:"));
- gtk_table_attach (GTK_TABLE (t), l,
- 0, 1, 1, 2, 0, 0, 0, 0);
- ea = gtk_adjustment_new (day_end, 0.0, 25.00, 1.0, 1.0, 1.0);
- de = gtk_hscale_new (GTK_ADJUSTMENT (ea));
- gtk_scale_set_digits (GTK_SCALE (de), 0);
- gtk_table_attach (GTK_TABLE (t), de,
- 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- gtk_signal_connect (sa, "value_changed",
- GTK_SIGNAL_FUNC (start_changed), ea);
- gtk_signal_connect (ea, "value_changed",
- GTK_SIGNAL_FUNC (end_changed), sa);
-
- /* Nice spacing :-) */
- gtk_table_attach (GTK_TABLE (t), gtk_label_new (""),
- 0, 1, 2, 3, 0, 0, 0, 0);
-
- r1 = gtk_radio_button_new_with_label (NULL, _("24 hour format"));
- r2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (r1),
- _("12 hour format"));
- if (am_pm_flag)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r2), 1);
-
- gtk_signal_connect (GTK_OBJECT (r1), "toggled",
- GTK_SIGNAL_FUNC (toggled), NULL);
-
- gtk_table_attach (GTK_TABLE (t), align (r1, 0.0), 0, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (t), align (r2, 0.0), 0, 2, 4, 5, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
- GTK_SIGNAL_FUNC (prop_cancel), NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "delete_event",
- GTK_SIGNAL_FUNC (prop_cancel), NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "apply",
- GTK_SIGNAL_FUNC (prop_apply), NULL);
-
- gtk_widget_show_all (prop_win);
-}
-
diff --git a/calendar/recur.xpm b/calendar/recur.xpm
deleted file mode 100644
index 49836b62e7..0000000000
--- a/calendar/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/test.vcf b/calendar/test.vcf
deleted file mode 100644
index bfe93b3c14..0000000000
--- a/calendar/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/timeutil.c b/calendar/timeutil.c
deleted file mode 100644
index f23277ce37..0000000000
--- a/calendar/timeutil.c
+++ /dev/null
@@ -1,323 +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 "timeutil.h"
-
-#define digit_at(x,y) (x [y] - '0')
-
-time_t
-time_from_isodate (char *str)
-{
- struct tm my_tm;
- time_t t;
-
- 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);
- 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)
- sprintf (buf, "%d%s",
- (hour == 0) ? 12 : (hour > 12) ? (hour - 12) : hour,
- (hour < 12) ? _("am") : _("pm"));
- else
- sprintf (buf, "%02d%s", hour, _("h"));
-
- return buf;
-
-}
-
-time_t
-time_add_day (time_t time, int days)
-{
- struct tm *tm = localtime (&time);
- time_t new_time;
-
- tm->tm_mday += days;
- if ((new_time = mktime (tm)) == -1){
- g_warning ("mktime could not handling adding a day with\n");
- print_time_t (time);
- return time;
- }
- return new_time;
-}
-
-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_warning ("mktime could not handling adding a day with\n");
- print_time_t (time);
- return time;
- }
- 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_warning ("mktime could not handling adding a year with\n");
- 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);
-}
-
-
-time_t
-time_start_of_day (time_t t)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- return mktime (&tm);
-}
-
-time_t
-time_end_of_day (time_t t)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday++;
-
- return mktime (&tm);
-}
-
-time_t
-time_year_begin (int year)
-{
- struct tm tm;
- time_t retval;
-
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_year = year;
- tm.tm_mon = 0;
- tm.tm_mday = 1;
- tm.tm_isdst = -1;
-
- retval = mktime (&tm);
- return retval;
-}
-
-time_t
-time_year_end (int year)
-{
- struct tm tm;
-
- tm.tm_hour = 23;
- tm.tm_min = 59;
- tm.tm_sec = 59;
- tm.tm_year = year;
- tm.tm_mon = 11;
- tm.tm_mday = 31;
- tm.tm_isdst = -1;
-
- return mktime (&tm);
-}
-
-time_t
-time_week_begin (time_t t)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_mday -= tm.tm_wday;
- return mktime (&tm);
-}
-
-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/timeutil.h b/calendar/timeutil.h
deleted file mode 100644
index a5a6d7b2d7..0000000000
--- a/calendar/timeutil.h
+++ /dev/null
@@ -1,47 +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>
-
-
-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_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);
-
-time_t time_start_of_day (time_t t);
-time_t time_end_of_day (time_t t);
-time_t time_day_hour (time_t t, int hour);
-time_t time_year_begin (int year);
-time_t time_year_end (int year);
-time_t time_week_begin (time_t t);
-time_t parse_date (char *str);
-time_t time_month_begin (time_t t);
-time_t time_month_end (time_t t);
-
-void print_time_t (time_t t);
-
-#endif
diff --git a/calendar/topic.dat b/calendar/topic.dat
deleted file mode 100644
index edc7813b26..0000000000
--- a/calendar/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/view-utils.c b/calendar/view-utils.c
deleted file mode 100644
index 1571c2f31e..0000000000
--- a/calendar/view-utils.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <string.h>
-#include "view-utils.h"
-
-int am_pm_flag = 0;
-
-static char *
-nicetime (struct tm *tm)
-{
- static char buf [20];
-
- if (am_pm_flag){
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%l:%M%p", tm);
- else
- strftime (buf, sizeof (buf), "%l%p", tm);
- } else {
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%k:%M", tm);
- else
- strftime (buf, sizeof (buf), "%k", tm);
- }
- return buf;
-}
-
-void
-view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end)
-{
- int font_height;
- int x, y, max_y;
- char buf [40];
- struct tm tm_start, tm_end;
- char *str;
- iCalObject *ico;
- GList *list;
-
- gdk_gc_set_clip_rectangle (gc, area);
-
- font_height = widget->style->font->ascent + widget->style->font->descent;
-
- max_y = area->y + area->height - font_height * ((flags & VIEW_UTILS_DRAW_SPLIT) ? 2 : 1);
-
- for (y = area->y, list = events; (y < max_y) && list; y += font_height, list = list->next) {
- CalendarObject *co = list->data;
- ico = co->ico;
-
- tm_start = *localtime (&co->ev_start);
- tm_end = *localtime (&co->ev_end);
- str = ico->summary;
-
- strcpy (buf, nicetime (&tm_start));
-
- if (flags & VIEW_UTILS_DRAW_END){
- strcat (buf, "-");
- strcat (buf, nicetime (&tm_end));
- }
- gdk_draw_string (window,
- widget->style->font,
- gc,
- area->x,
- y + widget->style->font->ascent,
- buf);
-
- if (flags & VIEW_UTILS_DRAW_SPLIT) {
- y += font_height;
- x = widget->style->font->ascent; /* some indentation */
- } else
- x = gdk_string_width (widget->style->font, buf);
-
- gdk_draw_string (window,
- widget->style->font,
- gc,
- x,
- y + widget->style->font->ascent,
- str);
- }
- gdk_gc_set_clip_rectangle (gc, NULL);
-}
-
-void
-view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow)
-{
- int x, y;
- int xthick, ythick;
- GdkGC *light_gc, *dark_gc;
-
- gdk_draw_rectangle (window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- rect->x, rect->y,
- rect->width, rect->height);
-
- light_gc = widget->style->light_gc[GTK_STATE_NORMAL];
- dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL];
-
- xthick = widget->style->klass->xthickness;
- ythick = widget->style->klass->ythickness;
-
- gdk_gc_set_clip_rectangle (light_gc, rect);
- gdk_gc_set_clip_rectangle (dark_gc, rect);
-
- for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3)
- for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) {
- gdk_draw_point (window, light_gc, x, y);
- gdk_draw_point (window, dark_gc, x + 1, y + 1);
-
- gdk_draw_point (window, light_gc, x + 3, y + 1);
- gdk_draw_point (window, dark_gc, x + 4, y + 2);
- }
-
- gdk_gc_set_clip_rectangle (light_gc, NULL);
- gdk_gc_set_clip_rectangle (dark_gc, NULL);
-
- gtk_draw_shadow (widget->style, window,
- GTK_STATE_NORMAL, shadow,
- rect->x, rect->y,
- rect->width, rect->height);
-}
diff --git a/calendar/view-utils.h b/calendar/view-utils.h
deleted file mode 100644
index a1876b6032..0000000000
--- a/calendar/view-utils.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef VIEW_UTILS_H
-#define VIEW_UTILS_H
-
-
-#include <gtk/gtk.h>
-#include "calendar.h"
-
-
-enum {
- VIEW_UTILS_DRAW_END = 1 << 0,
- VIEW_UTILS_DRAW_SPLIT = 1 << 1
-};
-
-
-void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end);
-
-void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow);
-
-
-#endif
diff --git a/calendar/views.c b/calendar/views.c
deleted file mode 100644
index 5e09b28754..0000000000
--- a/calendar/views.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Calendar views.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <gnome.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-
-GtkWidget *
-day_view_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Day View");
-}
-
-GtkWidget *
-week_view_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Week View");
-}
-
-GtkWidget *
-year_view_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Year View");
-}
-
-GtkWidget *
-tasks_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Tasks View");
-}
diff --git a/calendar/views.h b/calendar/views.h
deleted file mode 100644
index d7162cfcbd..0000000000
--- a/calendar/views.h
+++ /dev/null
@@ -1,4 +0,0 @@
-GtkWidget *day_view_create (GnomeCalendar *gcal);
-GtkWidget *week_view_create (GnomeCalendar *gcal);
-GtkWidget *year_view_create (GnomeCalendar *gcal);
-GtkWidget *tasks_create (GnomeCalendar *gcal);
diff --git a/calendar/year-view.c b/calendar/year-view.c
deleted file mode 100644
index 0a104f25a3..0000000000
--- a/calendar/year-view.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Arturo Espinosa <arturo@nuclecu.unam.mx>
- *
- * Heavily based on Federico Mena's week view.
- *
- */
-
-#include "gncal-year-view.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-static void gncal_year_view_init (GncalYearView *yview);
-
-static void
-double_click(GtkCalendar *gc, GncalYearView *yview)
-{
- struct tm tm;
- time_t t;
-
- tm.tm_mday = gc->selected_day;
- tm.tm_mon = gc->month;
- tm.tm_year = gc->year - 1900;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- t = mktime (&tm);
-
- gnome_calendar_dayjump (yview->gcal, t);
-}
-
-static void
-do_nothing(GtkCalendarClass *c)
-{
-}
-
-static void
-select_day(GtkWidget *widget, gpointer data)
-{
- int i;
-
- GncalYearView *yview;
-
- yview = GNCAL_YEAR_VIEW(data);
-
- for (i = 0; i < 12; i++)
- gtk_signal_handler_block(GTK_OBJECT(yview->calendar[i]),
- yview->handler[i]);
-
- for (i = 0; i < 12; i++)
- if (GTK_CALENDAR(yview->calendar[i]) != GTK_CALENDAR(widget))
- gtk_calendar_select_day(GTK_CALENDAR(yview->calendar[i]), 0);
-
- for (i = 0; i < 12; i++)
- gtk_signal_handler_unblock(GTK_OBJECT(yview->calendar[i]),
- yview->handler[i]);
-}
-
-guint
-gncal_year_view_get_type (void)
-{
- static guint year_view_type = 0;
-
- if (!year_view_type) {
- GtkTypeInfo year_view_info = {
- "GncalYearView",
- sizeof (GncalYearView),
- sizeof (GncalYearViewClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_year_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- year_view_type = gtk_type_unique (gtk_table_get_type (),
- &year_view_info);
- }
-
- return year_view_type;
-}
-
-static void
-gncal_year_view_init (GncalYearView *yview)
-{
- int i;
-
- for (i = 0; i < 12; i++) {
- yview->calendar[i] = NULL;
- yview->handler [i] = 0;
- }
-
- yview->gcal = NULL;
- yview->year_label = NULL;
- yview->year = 0;
-}
-
-GtkWidget *
-gncal_year_view_new (GnomeCalendar *calendar, time_t date)
-{
- struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- char monthbuff[40];
- GncalYearView *yview;
- GtkWidget *frame, *vbox, *label;
- struct tm *tmptm;
- int i, x, y;
-
- yview = gtk_type_new (gncal_year_view_get_type ());
-
- tmptm = localtime(&date);
- yview->year = tmptm->tm_year;
- yview->gcal = calendar;
- my_tm.tm_year = tmptm->tm_year;
- yview->year_label = gtk_label_new("");
- gtk_table_attach (GTK_TABLE (yview),
- GTK_WIDGET (yview->year_label),
- 1, 2,
- 0, 1,
- 0, 0, 0, 5);
- gtk_widget_show(GTK_WIDGET(yview->year_label));
-
- for (x = 0; x < 3; x++)
- for (y = 0; y < 4; y++) {
-
- i = y * 3 + x;
-
- yview->calendar[i] = gtk_calendar_new();
- gtk_calendar_display_options(GTK_CALENDAR(yview->calendar[i]),
- GTK_CALENDAR_SHOW_DAY_NAMES |
- GTK_CALENDAR_NO_MONTH_CHANGE);
- frame = gtk_frame_new(NULL);
- vbox = gtk_vbox_new(0,0);
-
- yview->handler[i] =
- gtk_signal_connect(GTK_OBJECT(yview->calendar[i]), "day_selected",
- GTK_SIGNAL_FUNC(select_day), (gpointer *) yview);
-
- gtk_signal_connect(GTK_OBJECT(yview->calendar[i]), "day_selected_double_click",
- GTK_SIGNAL_FUNC(double_click), (gpointer *) yview);
-
- my_tm.tm_mon = i;
- strftime(monthbuff, 40, "%B", &my_tm);
- label = gtk_label_new(monthbuff);
-
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_box_pack_start(GTK_BOX(vbox), label, 0, 0, 0);
- gtk_box_pack_start(GTK_BOX(vbox), yview->calendar[i], 0, 0, 0);
-
- gtk_table_attach (GTK_TABLE (yview),
- GTK_WIDGET (frame),
- x, x + 1,
- y + 1, y + 2,
- 0, 0, 0, 0);
-
- gtk_widget_show (frame);
- gtk_widget_show (vbox);
- gtk_widget_show (GTK_WIDGET (yview->calendar[i]));
- }
-
- gncal_year_view_set (yview, date);
-
- return GTK_WIDGET (yview);
-}
-
-static void
-year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure)
-{
- GncalYearView *yview = (GncalYearView *) closure;
- struct tm tm_s;
- time_t t, day_end;
-
- tm_s = *localtime (&start);
- day_end = time_end_of_day (end);
-
- for (t = start; t <= day_end; t+= 60*60*24){
- time_t new = mktime (&tm_s);
- struct tm tm_day;
-
- tm_day = *localtime (&new);
- gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day.tm_mon]),
- tm_day.tm_mday);
- tm_s.tm_mday++;
- }
-}
-
-static void
-gncal_year_view_set_year (GncalYearView *yview, int year)
-{
- time_t year_begin, year_end;
- char buff[20];
- GList *l;
- int i;
-
- if (!yview->gcal->cal)
- return;
-
- snprintf(buff, 20, "%d", yview->year + 1900);
- gtk_label_set(GTK_LABEL(yview->year_label), buff);
-
- for (i = 0; i < 12; i++) {
- gtk_calendar_freeze (GTK_CALENDAR (yview->calendar [i]));
- gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year + 1900);
- gtk_calendar_clear_marks (GTK_CALENDAR (yview->calendar[i]));
- }
-
- year_begin = time_year_begin (yview->year);
- year_end = time_year_end (yview->year);
-
- l = calendar_get_events_in_range (yview->gcal->cal, year_begin, year_end);
- for (; l; l = l->next){
- CalendarObject *co = l->data;
-
- year_view_mark_day (co->ico, co->ev_start, co->ev_end, yview);
- }
- for (i = 0; i < 12; i++)
- gtk_calendar_thaw (GTK_CALENDAR (yview->calendar [i]));
-
- calendar_destroy_event_list (l);
-}
-
-void
-gncal_year_view_set (GncalYearView *yview, time_t date)
-{
- struct tm *tmptm;
-
- tmptm = localtime(&date);
- yview->year = tmptm->tm_year;
-
- gncal_year_view_set_year (yview, yview->year);
-}
-
-void
-gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
-{
- g_return_if_fail (yview != NULL);
- g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
-
- /* If only the summary changed, we dont care */
- if (flags && (flags & CHANGE_SUMMARY) == flags)
- return;
-
- gncal_year_view_set_year (yview, yview->year);
-}
diff --git a/calendar/year-view.h b/calendar/year-view.h
deleted file mode 100644
index f31d5ae4a3..0000000000
--- a/calendar/year-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Arturo Espinosa <arturo@nuclecu.unam.mx>
- *
- * Heavily based on Federico Mena's week view.
- *
- */
-
-#ifndef YEAR_VIEW_H
-#define YEAR_VIEW_H
-
-#include <time.h>
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gtkcalendar.h>
-
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_YEAR_VIEW(obj) GTK_CHECK_CAST (obj, gncal_year_view_get_type (), GncalYearView)
-#define GNCAL_YEAR_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_year_view_get_type (), GncalYearViewClass)
-#define GNCAL_IS_YEAR_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_year_view_get_type ())
-
-
-typedef struct _GncalYearView GncalYearView;
-typedef struct _GncalYearViewClass GncalYearViewClass;
-
-struct _GncalYearView {
- GtkTable table;
-
- GnomeCalendar *gcal; /* The calendar we are associated to */
- GtkWidget *calendar[12]; /* one calendar per month */
- guint handler[12]; /* for (un)blocking the calendars */
-
- GtkWidget *year_label;
- gint year;
-};
-
-struct _GncalYearViewClass {
- GtkTableClass parent_class;
-};
-
-
-guint gncal_year_view_get_type (void);
-GtkWidget *gncal_year_view_new (GnomeCalendar *calendar, time_t date);
-void gncal_year_view_set (GncalYearView *yview, time_t date);
-void gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/libversit/.cvsignore b/libversit/.cvsignore
deleted file mode 100644
index e995588475..0000000000
--- a/libversit/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.deps
-Makefile
-Makefile.in
diff --git a/libversit/Makefile.am b/libversit/Makefile.am
deleted file mode 100644
index 05de8da370..0000000000
--- a/libversit/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-
-lib_LIBRARIES = libversit.a
-
-libversit_a_SOURCES = \
- vcc.y \
- vcc.h \
- vobject.c \
- vobject.h \
- port.h \
- vcaltmp.c \
- vcaltmp.h
-
-EXTRA_DIST = README.TXT vcaltest.c vctest.c
diff --git a/libversit/README.TXT b/libversit/README.TXT
deleted file mode 100644
index c8ce8b0979..0000000000
--- a/libversit/README.TXT
+++ /dev/null
@@ -1,951 +0,0 @@
-NOTE: If you used the earlier APIs released by Versit
-then you will want to look at the document "migrate.doc"
-included with this package. It contains a discussion of
-the differences between the old API and this one.
-
-----------------------------------------------------------------
-
-The vCard/vCalendar C interface is implemented in the set
-of files as follows:
-
-vcc.y, yacc source, and vcc.c, the yacc output you will use
-implements the core parser
-
-vobject.c implements an API that insulates the caller from
-the parser and changes in the vCard/vCalendar BNF
-
-port.h defines compilation environment dependent stuff
-
-vcc.h and vobject.h are header files for their .c counterparts
-
-vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
-which you may find useful.
-
-test.c is a standalone test driver that exercises some of
-the features of the APIs provided. Invoke test.exe on a
-VCARD/VCALENDAR input text file and you will see the pretty
-print output of the internal representation (this pretty print
-output should give you a good idea of how the internal
-representation looks like -- there is one such output in the
-following too). Also, a file with the .out suffix is generated
-to show that the internal representation can be written back
-in the original text format.
-
------------------------------------------------------------------
-
-
- VObject for VCard/VCalendar
-
-Table of Contents
-=================
-1. VObject
-2. Internal Representations of VCard/VCalendar
-3. Iterating Through VObject's Properties or Values
-4. Pretty Printing a VObject Tree
-5. Building A VObject Representation of A VCard/VCalendar
-6. Converting A VObject Representation Into Its Textual Representation
-7. Miscellaneous Notes On VObject APIs usages
-8. Brief descriptions of each APIs
-9. Additional Programming Notes.
-
-This document is mainly about the VObject and its APIs. The main
-use of a VObject is to represent a VCard or a VCalendar inside
-a program. However, its use is not limited to aforemention as it
-can represent an arbitrary information that makes up of a tree or
-forest of properties/values.
-
-1. VObject
- =======
-A VObject can have a name (id) and a list of associated properties and
-a value. Each property is itself a VObject.
-
-2. Internal Representations of VCard/VCalendar
- ===========================================
-A list of VCard or a VCalendar is represented by a list of VObjects.
-The name (id) of the VObjects in the list is either VCCardProp or
-VCCalProp. Each of these VObjects can have a list of properties.
-Since a property is represented as a VObject, each of these properties
-can have a name, a list of properties, and a value.
-
-For example, the input file "vobject.vcf":
-
-BEGIN:VCARD
-N:Alden;Roland
-FN:Roland H. Alden
-ORG:AT&T;Versit Project Office
-TITLE:Consultant
-EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-EMAIL;INTERNET:ralden@sfgate.com
-EMAIL;MCIMail:242-2200
-LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111
-LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111=0A=
-U.S.A.
-TEL;WORK;PREF;MSG:+1 415 296 9106
-TEL;WORK;FAX:+1 415 296 9016
-TEL;MSG;CELL:+1 415 608 5981
-ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-SOUND:ROW-LAND H ALL-DIN
-LOGO;GIF;BASE64:
- R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- QjExMSEhIRAQEO///87v9973/73n95zW71K13jGl1nvG50Kt3iGc1gCMzq3e94zO
- 7xCU1nO952O15wAAACwAAAAApgBOAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zv
- /8CgcEj8QTaeywWTyWCUno2kSK0KI5tLc8vtNi+WiHVMlj0mFK96nalsxOW4fPSw
- cNj4tQc+7xcjGh4WExJTJYUTFkp3eU0eEH6RkpOUlTARhRoWm5ydFpCWoS0QEqAu
- ARKaHRcVjV0borEoFl0cSre4Sq67FA+yvwAeTU8XHZ7HmxS6u2wVfMCVpAE3pJoW
- ylrMptDcOqSF4OHg3eQ5pInInb7lcc86mNbLzBXsZbRfUOn6ucyNHvVWJHCpQFDf
- MWwEEzLqx2YCQCqF3OnItClJNmYcJD7cSAKTuI/gtnEcOQKkyVIk6/+ds5CkFcMM
- 61LiENikwi1jBnNyuvUSjwWZOS5uIZarqNFcNl32XMMB6I06GgoJ+bZp1ZKeDl8E
- +MC1K1cBIhZ4HUu2LAsCZdOWRQDt20lxIlccSHsgrNq7Xc/ixcsWmNu34WKyYJCW
- gQjCe9XqTZy2L4pv04gg2sSKSc8OLgTcBSuWsdkVaD2TdXyiQxebFyjo1Gnx6tJm
- LuaqrdtZtNfFtruSNmF5IKujwIsmJbjwtRqNJhrcNVw79wcRAgogmE4ArIjQzj/s
- JvHAGCFDQR4UqigPK4sBe62XwO51OwADiMcqUG+iOdcFAL+hW20BfAoEexlwAnu6
- mZDAXQ1EVh//WfhxJB5gIbHgwFgOTOiVAgOuVQKAfKFg3weGwSBYFZMp4hpDGKyA
- 3lgJKECWgiMQyBVpW+0V4oJjNfhCNkR1IgWEb21QlRK9GdfFCgeOZYBsXgm4noYj
- GEBhAQHYh0J8XenoQnFGdrkUciJY6FUAK15ogozakcBhliKsyZWHDMZQ0wWC/Aim
- DB6h01KRr/lXQgFxAqDcWDACgCZpUnrVQJtjwTnWjS6MWAYqqfDnSaEkJOlVXQBo
- 2pWTMUJ53WgAuPncCR9q6VQMAYjZlXWJmknCoSUM2p4BC+SaKwG88hoZlvfFMM4f
- hQh5TXkv+RklWYtC91mopJIAKFkJlDAW/wF25ShnLbeo5gmQ+1FGkJdrKCuCi2OR
- BuwHBcwqKgABrMtVAgpem61XkLbAJ7n8uiIpvGVhO4KpH1QLbbpqLheZvQCkGoNL
- thSzSTg2UGVBBzbtaxwKsYrmgLvRAlCmWgwMAADD66rKAgR3XlGspcdkZYK8ibU7
- asgEl+XAyB8I7PCqMWiWncGGimpfAgO4ypXSPpOVLwsRCDJxRD2AoyeRRv5kApO5
- fXwzwvfOKLKtaTWtbQxccmGLTZy8xYlVSvXbhbk0M2YzrYfJJ0K8m+V9NgxpyC04
- UycI/aiuiH9Y8NftDUwWp1Wm5UABnAUKwwRsPFGBt4Oc9PZvGvNLwf8JOZt8Arpe
- eY23yDovwIDiBX74NAsPVLDJj3Hh4JEExsKcjrlKf9DsCVx3ZfLqAKBuG1s/A90C
- z2KjYHjjyPOdG1spz6BBUr+BcUxUb1nDCTa/VZD2Uv+YkLPAKJC9dNEh7628WgqI
- ybzlaA+ufxMa6bxC6ciLUQLcx5UGIAAsAkDA6wQkOxrcY39yo4cQMNWCAPTKV1R4
- wPkgaBxzOc8FtMiF1NoGoXBRJjgoPApmPsjCFlbMdzCM4TFy50IXxI2DPcHAv2rY
- gghsEIeu8CAPW6ABIPYEFkOsAeaMyIz0JfGJUExBBGRIRX0IMYovWCIT1eBELNpA
- i1vcgta8iANPCIQOghzQABl30J0tXqBla4wjFLFQxZzAUY42CIAd5OYBCuKxB2c4
- I0b28EcrQKADgmSKB9RYyDhA4BqCxIBqrtjIMTwoFeCjYSU3KZMQAAA7
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-PRODID:-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-START:19960523T120000
-END:19960523T130000
-SUBTYPE:PHONE CALL
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-DESCRIPTION:VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland
-END:VEVENT
-BEGIN:VEVENT
-START:19960523T113000
-END:19960523T115500
-SUBTYPE:LUNCH
-SUMMARY:Eat in the cafeteria today
-END:VEVENT
-END:VCALENDAR
-
-END:VCARD
-
-
-will conceptually be be represented as
- vcard
- VCNameProp
- VCFamilyNameProp=Alden
- VCGivenNameProp=Roland
- VCFullNameProp=Roland H.Alden
- ....
-
-note that
- EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-will be represented as:
- VCEmailAddress=sf!rincon!ralden@alden.attmail.com
- VCWork
- VCPreferred
- VCInternet
-where the lower level properties are properties of the property
-VCEmailAddress.
-
-Groupings are flattened out in the VObject representation such
-that:
- a.b:blah
- a.c:blahblah
-are represented as:
- b=blah
- VCGrouping=a
- c=blahblah
- VCGrouping=a
-i.e. one can read the above as:
- the property "b" has value "blah" and property "VCGrouping"
- with the value "a".
- the property "c" has value "blahblah" and property "VCGrouping"
- with the value "a".
-likewise, multi-level groupings are flatten similarly. e.g.
- a.b.c:blah
- a.b.e:blahblah
--->
- c=blah
- VCGrouping=b
- VCGrouping=a
- e=blahblah
- VCGrouping=b
- VCGrouping=a
-which read:
- the property "c" has value "blah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
- the property "e" has value "blahblah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
-
-3. Iterating Through VObject's Properties or Values
- ================================================
-The following is a skeletal form of iterating through
-all properties of a vobject, o:
-
- // assume the object of interest, o, is of type VObject
- VObjectIterator i;
- initPropIterator(&i,o);
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- // ... do something with "each" property
- }
-
-Use the API vObjectName() to access a VObject's name.
-Use the API vObjectValueType() to determine if a VObject has
- a value. For VCard/VCalendar application, you
- should not need this function as practically
- all values are either of type VCVT_USTRINGZ or
- VCVT_RAW (i.e set by setVObjectUStringZValue and
- setVObjectAnyValue APIs respectively), and the
- value returned by calls to vObjectUStringZValue
- and vObjectAnyValue are 0 if a VObject has no
- value. (There is a minor exception where VObject with
- VCDataSizeProp has value that is set by
- setVObjectLongValue).
-Use the APIs vObject???Value() to access a VObject's value.
- where ??? is the expected type.
-Use the APIs setvObject???Value() to set or modify a VObject's value.
- where ??? is the expected type.
-Use the API isAPropertyOf() to query if a name match the name of
- a property of a VObject. Since isAPropertyOf() return
- the matching property, we can use that to retrieve
- a property and subsequently the value of the property.
-
-4. Pretty Printing a VObject Tree
- ==============================
-VObject tree can be pretty printed with the printVObject() function.
-The output of pretty printing a VObject representation of the input
-test file "vobject.vcf" is shown below. Note that the indentation
-indicates the tree hirerarchy where the immediate children nodes
-of a parent node is all at the same indentation level and the
-immediate children nodes are the immediate properties of the
-associated parent nodes. In the following, {N,FN,ORG,TITLE,...}
-are immediate properties of VCARD. {F and G} are properties of N
-with value {"Alden" and "Roland"} respectively; FN has no property
-but has the value "Roland H. Alden"; EMAIL has value and
-the properties WORK, PREF, and INTERNET.
-
-
-VCARD
- N
- F="Alden"
- G="Roland"
- FN="Roland H. Alden"
- ORG
- ORGNAME="AT&T"
- OUN="Versit Project Office"
- TITLE="Consultant"
- EMAIL="sf!rincon!ralden@alden.attmail.com"
- WORK
- PREF
- INTERNET
- EMAIL="ralden@sfgate.com"
- INTERNET
- EMAIL="242-2200"
- MCIMail
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111"
- DOM
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111
- U.S.A."
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- TEL="+1 415 296 9106"
- WORK
- PREF
- MSG
- TEL="+1 415 296 9016"
- WORK
- FAX
- TEL="+1 415 608 5981"
- MSG
- CELL
- ADR
- EXT ADD="Suite 2208"
- STREET="One Pine Street"
- L="San Francisco"
- R="CA"
- PC="94111"
- C="U.S.A."
- SOUND="ROW-LAND H ALL-DIN"
- LOGO=[raw data]
- GIF
- BASE64
- DataSize=1482
-VCALENDAR
- DCREATED="19960523T100522"
- PRODID="-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN"
- VERSION="0.3"
- VEVENT
- START="19960523T120000"
- END="19960523T130000"
- SUBTYPE="PHONE CALL"
- SUMMARY="VERSIT PDI PR Teleconference/Interview"
- DESCRIPTION="VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland"
- VEVENT
- START="19960523T113000"
- END="19960523T115500"
- SUBTYPE="LUNCH"
- SUMMARY="Eat in the cafeteria today"
-
-5. Building A VObject Representation of A VCard/VCalendar
- ======================================================
-The parser in vcc.y converts an input file with one or more
-VCard/VCalendar that is in their textual representation
-into their corresponding VObject representation.
-
-VObject representation of a VCard/VCalendar can also be built
-directly with calls to the VObject building APIs. e.g.
-
- VObject *prop;
- VObject *vcard = newVObject(VCCardProp);
- prop = addProp(vcard,VCNameProp);
- addPropValue(prop,VCFamilyNameProp,"Alden");
- addPropValue(prop,VCGivenNameProp,"Roland");
- addPropValue(vcard,VCFullNameProp,"Roland H. Alden");
- ....
-
-6. Converting A VObject Representation Into Its Textual Representation
- ===================================================================
-The VObject representation can be converted back to its textual
-representation via the call to writeVObject() or writeMemVObject()
-API. e.g.
- a. to write to a file:
- // assume vcard is of type VObject
- FILE *fp = fopen("alden.vcf","w");
- writeVObject(fp,vcard);
- a. to write to memory, and let the API allocate the required memory.
- char* clipboard = writeVObject(0,0,vcard);
- ... do something to clipboard
- free(clipboard);
- b. to write to a user allocated buffer:
- char clipboard[16384];
- int len = 16384;
- char *buf = writeVObject(clipboard,&len,vcard);
- ... buf will be equal to clipboard if the write
- is successful otherwise 0.
-
-In the case of writing to memory, the memory buffer can be either
-allocated by the API or the user. If the user allocate the
-memory for the buffer, then the length of the buffer needs to be
-communicated to the API via a variable. The variable passed as
-the length argument will be overwritten with the actual size
-of the text output. A 0 return value from writeMemVObject()
-indicates an error which could be caused by overflowing the
-size of the buffer or lack of heap memory.
-
-7. Miscellaneous Notes On VObject APIs usages
- ==========================================
-a. vcc.h -- contains basic interfaces to the parser:
- VObject* Parse_MIME(const char *input, unsigned long len);
- VObject* Parse_MIME_FromFile(FILE *file);
- -- both of this return a null-terminated list of
- VObject that is either a VCARD or VCALENDAR.
- To iterate through this list, do
- VObject *t, *v;
- v = Parse_Mime_FromFile(fp);
- while (v) {
- // ... do something to v.
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- note that call to cleanVObject will release
- resource used to represent the VObject.
-
-b. vobject.h -- contains basic interfaces to the VObject APIs.
- see the header for more details.
- The structure of VObject is purposely (hiddened) not exposed
- to the user. Every access has to be done via
- the APIs. This way, if we need to change the
- structure or implementation, the client need not
- recompile as long as the interfaces remain the
- same.
-
-c. values of a property is determined by the property definition
- itself. The vobject APIs does not attempt to enforce
- any of such definition. It is the consumer responsibility
- to know what value is expected from a property. e.g
- most properties have unicode string value, so to access
- the value of these type of properties, you will use
- the vObjectUStringZValue() to read the value and
- setVObjectUStringZValue() to set or modify the value.
- Refer to the VCard and VCalendar specifications for
- the definition of each property.
-
-d. properties name (id) are case incensitive.
-
-8. Brief descriptions of each APIs
- ===============================
- * the predefined properties' names (id) are listed under vobject.h
- each is of the form VC*Prop. e.g.
- #define VC7bitProp "7BIT"
- #define VCAAlarmProp "AALARM"
- ....
-
- * consumer of a VObject can only define pointers to VObject.
-
- * a variable of type VObjectIterator, say "i", can be used to iterate
- through a VObject's properties, say "o". The APIs related to
- VObjectIterator are:
- void initPropIterator(VObjectIterator *i, VObject *o);
- -- e.g. usage
- initPropIterator(&i,o);
- int moreIteration(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) { ... }
- VObject* nextVObject(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- }
-
- * VObject can be chained together to form a list. e.g. of such
- use is in the parser where the return value of the parser is
- a link list of VObject. A link list of VObject can be
- built by:
- void addList(VObject **o, VObject *p);
- and iterated by
- VObject* nextVObjectInList(VObject *o);
- -- next VObjectInList return 0 if the list
- is exhausted.
-
- * the following APIs are mainly used to construct a VObject tree:
- VObject* newVObject(const char *id);
- -- used extensively internally by VObject APIs but when
- used externally, its use is mainly limited to the
- construction of top level object (e.g. an object
- with VCCardProp or VCCalendarProp id).
-
- void deleteVObject(VObject *p);
- -- to deallocate single VObject, for most user, use
- cleanVObject(VObject *o) instead for freeing all
- resources associated with the VObject.
-
- char* dupStr(const char *s, unsigned int size);
- -- duplicate a string s. If size is 0, the string is
- assume to be a null-terminated.
-
- void deleteStr(const char *p);
- -- used to deallocate a string allocated by dupStr();
-
- void setVObjectName(VObject *o, const char* id);
- -- set the id of VObject o. This function is not
- normally used by the user. The setting of id
- is normally done as part of other APIs (e.g.
- addProp()).
-
- void setVObjectStringZValue(VObject *o, const char *s);
- -- set a string value of a VObject.
-
- void setVObjectUStringZValue(VObject *o, const wchar_t *s);
- -- set a Unicode string value of a VObject.
-
- void setVObjectIntegerValue(VObject *o, unsigned int i);
- -- set an integer value of a VObject.
-
- void setVObjectLongValue(VObject *o, unsigned long l);
- -- set an long integer value of a VObject.
-
- void setVObjectAnyValue(VObject *o, void *t);
- -- set any value of a VObject. The value type is
- unspecified.
-
- VObject* setValueWithSize(VObject *prop, void *val, unsigned int size);
- -- set a raw data (stream of bytes) value of a VObject
- whose size is size. The internal VObject representation
- is
- this object = val
- VCDataSizeProp=size
- i.e. the value val will be attached to the VObject prop
- and a property of VCDataSize whose value is size
- is also added to the object.
-
- void setVObjectVObjectValue(VObject *o, VObject *p);
- -- set a VObject as the value of another VObject.
-
- const char* vObjectName(VObject *o);
- -- retrieve the VObject's Name (i.e. id).
-
- const char* vObjectStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated string.
-
- const wchar_t* vObjectUStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated unicode string.
-
- unsigned int vObjectIntegerValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- integer.
-
- unsigned long vObjectLongValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- long integer.
-
- void* vObjectAnyValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- any value.
-
- VObject* vObjectVObjectValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- a VObject.
-
- VObject* addVObjectProp(VObject *o, VObject *p);
- -- add a VObject p as a property of VObject o.
- (not normally used externally for building a
- VObject).
-
- VObject* addProp(VObject *o, const char *id);
- -- add a property whose name is id to VObject o.
-
- VObject* addPropValue(VObject *o, const char *id, const char *v);
- -- add a property whose name is id and whose value
- is a null-terminated string to VObject o.
-
- VObject* addPropSizedValue(VObject *o, const char *id,
- const char *v, unsigned int size);
- -- add a property whose name is id and whose value
- is a stream of bytes of size size, to VObject o.
-
- VObject* addGroup(VObject *o, const char *g);
- -- add a group g to VObject o.
- e.g. if g is a.b.c, you will have
- o
- c
- VCGroupingProp=b
- VCGroupingProp=a
- and the object c is returned.
-
- VObject* isAPropertyOf(VObject *o, const char *id);
- -- query if a property by the name id is in o and
- return the VObject that represent that property.
-
- void printVObject(VObject *o);
- -- pretty print VObject o to stdout (for debugging use).
-
- void writeVObject(FILE *fp, VObject *o);
- -- convert VObject o to its textual representation and
- write it to file.
-
- char* writeMemVObject(char *s, int *len, VObject *o);
- -- convert VObject o to its textual representation and
- write it to memory. If s is 0, then memory required
- to hold the textual representation will be allocated
- by this API. If a variable len is passed, len will
- be overwriten with the byte size of the textual
- representation. If s is non-zero, then s has to
- be a user allocated buffer whose size has be passed
- in len as a variable. Memory allocated by the API
- has to be freed with call to free. The return value
- of this API is either the user supplied buffer,
- the memory allocated by the API, or 0 (in case of
- failure).
-
- void cleanStrTbl();
- -- this function has to be called when all
- VObject has been destroyed.
-
- void cleanVObject(VObject *o);
- -- release all resources used by VObject o.
-
- wchar_t* fakeUnicode(const char *ps, int *bytes);
- -- convert char* to wchar_t*.
-
- extern int uStrLen(const wchar_t *u);
- -- length of unicode u.
-
- char *fakeCString(const wchar_t *u);
- -- convert wchar_t to CString (blindly assumes that
- this could be done).
-
-9. Additional Programming Notes
- ============================
-In the following notes, please refers to the listing
-of Example.vcf and its VObject Representation
-(shown at the end of this section).
-
-* Handling the Return Value of the VCard/VCalendar Parser
- The example input text file contains two root VObjects
- (a VCalendar and a VCard). The output of the VCard/VCalendar
- parser is a null-terminated list of VObjects. For this
- particular input file, the list will have two VObjects.
- The following shows a template for iterating through the
- output of the Parser:
-
- VObject *t, *v;
- v = Parse_Mime_fromFileName("example.vcf");
- while (v) {
- // currently, v will either be a VCard or a VCalendar
- // do whatever your application need to do to
- // v here ...
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
-
-* Iterating Through a VCard/VCalendar VObject
- From the VObject APIs point of view, a VCard VObject
- is the same as a VCalendar VObject. However, the application
- needs to know what are in a VCard or a VCalendar.
- For example, A VCalendar VObject can have VCDCreatedProp,
- a VCGEOLocationProp, etc, and one or more VCEventProp and
- or VCTodoProp. The VCEventProp and VCTodoProp can have
- many properties of their own, which in turn could have
- more properties (e.g. VCDAlarmProp can be a VCEventProp
- VObject's property, and VCRunTimeProp can be a
- VCDAlarmProp VObject's property. Because a VObject tree
- can be arbitrarily complex, in general, to process all
- properties and values of a VObject tree, a recursive walk
- is desirable. An example recursive VObject tree walk
- can be found in the vobject.c source lines for printVObject*
- and writeVObject* APIs. Depending on what the application need
- to do with a VCard or a VCalendar, a recursive walk
- of the VObject tree may or may not be desirable. An example
- template of a non-recursive walk is shown below:
-
- void processVCardVCalendar(char *inputFile)
- {
- VObject *t, *v;
- v = Parse_Mime_fromFileName(inputFile);
- while (v) {
- char *n = vObjectName(v);
- if (strcmp(n,VCCardProp) == 0) {
- do_VCard(v);
- }
- else if (strcmp(n,VCCalendarProp) == 0) {
- do_VCalendar(v);
- }
- else {
- // don't know how to handle anything else!
- }
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- }
-
- void do_VCard(VObject *vcard)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primarly purpose of this example is to
- // show how to iterate through a VCard VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCNameProp)==0) {
- do_name(eachProp);
- }
- else if (strcmp(n,VCEmailProp)==0) {
- do_email(eachProp);
- }
- else if (strcmp(n,VCLabelProp)==0) {
- do_label(eachProp);
- }
- else if ....
- }
- }
-
- void do_VCalendar(VObject *vcal)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primarly purpose of this example is to
- // show how to iterate through a VCalendar VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCDCreatedProp)==0) {
- do_DCreated(eachProp);
- }
- else if (strcmp(n,VCVersionProp)==0) {
- do_Version(eachProp);
- }
- else if (strcmp(n,VCTodoProp)==0) {
- do_Todo(eachProp);
- }
- else if (strcmp(n,VCEventProp)==0) {
- do_Event(eachProp);
- }
- else if ....
- }
- }
-
- void do_Todo(VObject *vtodo) { ... }
-
- void do_Event(VObject *vevent) { ... }
-
- ...
-
-* Property's Values and Properties
- The VObject APIs do not attempt to check for the
- correctness of the values of a property. Nor do they
- will prevent the user from attaching a non-VCard/VCalendar
- standard property to a VCard/VCalendar property. Take
- the example of line [11] of the example, "O.K" is not
- a valid value of VCStatusProp. It is up to the application
- to accept or reject the value of a property.
-
-* Output of printVObject
- PrintVObject pretty prints a VObject tree in human
- readable form. See the listing at the end of the file
- for an example output of printVObject on the example
- input file "Example.vcf".
-
- Note that binary data are not shown in the output of
- printVObject. Instead, a note is made ([raw data]) to
- indicate that there exists such a binary data.
-
-* Note on Binary Data
- When the value of a property is a binary data, it is only
- useful to know the size of the binary data.
-
- In the case of the VCard/VCalendar parser, it chooses
- to represent the size information as a separate property
- called VCDataSizeProp whose value is the size of the binary
- data. The APIs sequence to construct the VObject subtree
- of line [44] of Example.vcf is
-
- // VObject *vcard;
- VObject *p1 = addProp(vcard,VCLogoProp);
- (void) addProp(p1,VCGIFProp);
- (void) addProp(p1,VCBASE64Prop);
- VObject *p2 = addProp(p1,VCDataSizeProp);
- (void) setVObjectLongValue(p2,1482);
- setVObjectAnyValue(vcard,...pointer to binary data);
-
- Note the presence of VCBase64Prop will cause the
- writeVObject API to output the binary data as BASE64 text.
- For VCard/VCalendar application, having the VCBase64Prop
- property is pratically always neccessary for property with
- binary data as its value.
-
-* Note on Quoted-Printable String
- String value with embedded newline are written out as
- quoted-prinatable string. It is therefore important
- to mark a property with a string value that has
- one or more embedded newlines, with the VCQutedPrintableProp
- property. e.g.
-
- // VObject *root;
- char *msg="To be\nor\nnot to be";
- VObject *p = addPropValue(root,VCDescriptionProp,msg);
- // the following is how you mark a property with
- // a property. In this case, the marker is
- // VCQuotedPrintableProp
- addProp(p,VCQuotedPrintableProp);
-
-* Note on Unicode
- Although, the current parser takes ASCII text file only,
- string values are all stored as Unicode in the VObject tree.
- For now, when using the VObject APIs to construct a
- VObject tree, one should always convert ASCII string value
- to a Unicode string value:
-
- // VObject *root;
- VObject *p = addProp(root,VCSomeProp);
- setVObjectUStringZValue(p,fakeUnicode(someASCIIStringZvalue));
-
- An API is provided to simplify the above process:
-
- addPropValue(root,VCSomeProp,someASCIIStringZValue);
-
- Note that someASCIISTringZValue is automatically converted to
- Unicode by addPropValue API, where as, the former code
- sequence do an explicit call to fakeUnicode.
-
- To read back the value, one should use the vObjectUStringZValue
- API not vObjectStringZValue API. The value returned by the
- vObjectUStringZValue API is a Unicode string. If the application
- do not know how to handle Unicode string, it can use the
- fakeCString API to convert it back to ASCII string (as long
- as the conversion is meaningful).
-
- Note that fakeCString return a heap allocated memory. It is
- important to call deleteStr on fakeCString return value if
- it is not longer required (or there will be memory leak).
-
- NOTE: Unfortunately, at the point when this document is written,
- there is still no consensus on how Unicode is to be handled
- in the textual representation of VCard/VCalendar. So, there
- is no version of writeVObject and the parser to output and
- input Unicode textual representation of VCard/VCalendar.
-
-
-Example.vcf
------------
-line
-number Input Text (example.vcf)
------- ----------
-1 BEGIN:VCALENDAR
-2 DCREATED:19961102T100522
-3 GEO:0,0
-4 VERSION:1.0
-5 BEGIN:VEVENT
-6 DTSTART:19961103T000000
-7 DTEND:20000101T000000
-8 DESCRIPTION;QUOTED-PRINTABLE:To be =0A=
-9 or =0A=
-10 not to be
-11 STATUS:O.K.
-12 X-ACTION:No action required
-13 DALARM:19961103T114500;5;3;Enjoy
-14 MALARM:19970101T120000;;;johny@nowhere.com;Call Mom.
-15 END:VEVENT
-16
-17 BEGIN:VTODO
-18 DUE:19960614T0173000
-19 DESCRIPTION:Relex.
-20 END:VTODO
-21
-22 END:VCALENDAR
-23
-24 BEGIN:VCARD
-25 N:Alden;Roland
-26 FN:Roland H. Alden
-27 ORG:AT&T;Versit Project Office
-28 TITLE:Consultant
-29 EMAIL;WORK;PREF;INTERNET:ralden@ralden.com
-30 LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-31 Suite 2208=0A=
-32 One Pine Street=0A=
-33 San Francisco, CA 94111
-34 LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-35 Suite 2208=0A=
-36 One Pine Street=0A=
-37 San Francisco, CA 94111=0A=
-38 U.S.A.
-39 TEL;WORK;PREF;MSG:+1 415 296 9106
-40 TEL;WORK;FAX:+1 415 296 9016
-41 TEL;MSG;CELL:+1 415 608 5981
-42 ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-43 SOUND:ROW-LAND H ALL-DIN
-44 LOGO;GIF;BASE64:
-45 R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- ... 30 lines of BASE64 data not shown here.
-76 END:VCARD
-
-
-VObject Representation of Example.vcf:
--------------------------------------
-line
-in
-text
-file VObject Tree as Printed by printVObject API
----- -------------------------------------------
-1 VCALENDAR
-2 DCREATED="19961102T100522"
-3 GEO="0,0"
-4 VERSION="1.0"
-5 VEVENT
-6 DTSTART="19961103T000000"
-7 DTEND="20000101T000000"
-8 DESCRIPTION="To be
-9 or
-10 not to be"
-8 QUOTED-PRINTABLE
-11 STATUS="O.K."
-12 X-ACTION="No action required"
-13 DALARM
-13 RUNTIME="19961103T114500"
-13 SNOOZETIME="5"
-13 REPEATCOUNT="3"
-13 DISPLAYSTRING="Enjoy"
-14 MALARM
-14 RUNTIME="19970101T120000"
-14 EMAIL="johny@nowhere.com"
-14 NOTE="Call Mom"
-17 VTODO
-18 DUE="19960614T0173000"
-19 DESCRIPTION="Relex."
-24 VCARD
-25 N
-25 F="Alden"
-25 G="Roland"
-26 FN="Roland H. Alden"
-27 ORG
-27 ORGNAME="AT&T"
-27 OUN="Versit Project Office"
-28 TITLE="Consultant"
-29 EMAIL="ralden@alden.com"
-29 WORK
-29 PREF
-29 INTERNET
-30 LABEL="Roland H. Alden
-31 Suite 2208
-32 One Pine Street
-33 San Francisco, CA 94111"
-30 DOM
-30 POSTAL
-30 PARCEL
-30 HOME
-30 WORK
-30 QUOTED-PRINTABLE
-34 LABEL="Roland H. Alden
-35 Suite 2208
-36 One Pine Street
-37 San Francisco, CA 94111
-38 U.S.A."
-34 POSTAL
-34 PARCEL
-34 HOME
-34 WORK
-34 QUOTED-PRINTABLE
-39 TEL="+1 415 296 9106"
-39 WORK
-39 PREF
-39 MSG
-40 TEL="+1 415 296 9016"
-40 WORK
-40 FAX
-41 TEL="+1 415 608 5981"
-41 MSG
-41 CELL
-42 ADR
-42 EXT ADD="Suite 2208"
-42 STREET="One Pine Street"
-42 L="San Francisco"
-42 R="CA"
-42 PC="94111"
-42 C="U.S.A."
-43 SOUND="ROW-LAND H ALL-DIN"
-44 LOGO=[raw data]
-44 GIF
-44 BASE64
-44 DATASIZE=1482
-
diff --git a/libversit/port.h b/libversit/port.h
deleted file mode 100644
index 6dba3567fe..0000000000
--- a/libversit/port.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#ifndef __PORT_H__
-#define __PORT_H__ 1
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-// some of these #defines are commented out because
-// Visual C++ sets them on the compiler command line instead
-
-//#define _DEBUG
-//#define WIN32
-//#define WIN16
-//#define _WINDOWS
-//#define __MWERKS__
-//#define INCLUDEMFC
-
-#define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard"
-#define vCalendarClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCalendar"
-
-/* The above strings vCardClipboardFormat and vCalendarClipboardFormat
-are globally unique IDs which can be used to generate clipboard format
-ID's as per the requirements of a specific platform. For example, in
-Windows they are used as the parameter in a call to RegisterClipboardFormat.
-For example:
-
- CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat);
-
-*/
-
-#define vCardMimeType "text/x-vCard"
-#define vCalendarMimeType "text/x-vCalendar"
-
-#define DLLEXPORT(t) t
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#define stricmp strcasecmp
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif // __PORT_H__
diff --git a/libversit/vcaltest.c b/libversit/vcaltest.c
deleted file mode 100644
index 5528aab1d1..0000000000
--- a/libversit/vcaltest.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "vcaltmp.h"
-
-#if 0
-This testcase would generate a file call "frankcal.vcf" with
-the following content:
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-GEO:37.24,-17.87
-PRODID:-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-DTSTART:19960523T120000
-DTEND:19960523T130000
-DESCRIPTION;QUOTED-PRINTABLE:VERSIT PDI PR Teleconference/Interview =0A=
-With Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar=0A=
-activities with European Press representatives.
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-SUBTYPE:PHONE CALL
-STATUS:CONFIRMED
-TRANSP:19960523T100522-4000F100582713-009251
-UID:http://www.ibm.com/raleigh/fdawson/~c:\or2\orgfiles\versit.or2
-DALARM:19960523T114500;5;3;Your Telecon Starts At Noon!!!;
-MALARM:19960522T120000;;;fdawson@raleigh.ibm.com;Remember 05/23 Noon Telecon!!!;
-PALARM:19960523T115500;;;c:\or2\organize.exe c:\or2\orgfiles\versit.or2;
-X-LDC-OR2-OLE:c:\temp\agenda.doc
-END:VEVENT
-
-BEGIN:VTODO
-DUE:19960614T0173000
-DESCRIPTION:Review VCalendar helper API.
-END:VTODO
-
-END:VCALENDAR
-
-#endif
-
-FILE *cfp;
-
-void testVcalAPIs() {
- FILE *fp;
- VObject *vcal, *vevent;
-#if _CONSOLE
- cfp = stdout;
-#else
- cfp = fopen("vcaltest.out","w");
-#endif
- if (cfp == 0) return;
- vcal = vcsCreateVCal(
- "19960523T100522",
- "37.24,-17.87",
- "-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN",
- 0,
- "0.3"
- );
-
- vevent = vcsAddEvent(
- vcal,
- "19960523T120000",
- "19960523T130000",
- "VERSIT PDI PR Teleconference/Interview \nWith Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar\nactivities with European Press representatives.",
- "VERSIT PDI PR Teleconference/Interview",
- "PHONE CALL",
- 0,
- "CONFIRMED",
- "19960523T100522-4000F100582713-009251",
- "http://www.ibm.com/raleigh/fdawson/~c:\\or2\\orgfiles\\versit.or2",
- 0
- );
-
- vcsAddDAlarm(vevent, "19960523T114500", "5", "3",
- "Your Telecon Starts At Noon!!!");
- vcsAddMAlarm(vevent, "19960522T120000", 0, 0, "fdawson@raleigh.ibm.com",
- "Remember 05/23 Noon Telecon!!!");
- vcsAddPAlarm(vevent, "19960523T115500", 0 ,0,
- "c:\\or2\\organize.exe c:\\or2\\orgfiles\\versit.or2");
-
- addPropValue(vevent, "X-LDC-OR2-OLE", "c:\\temp\\agenda.doc");
-
- vcsAddTodo(
- vcal,
- 0,
- "19960614T0173000",
- 0,
- "Review VCalendar helper API.",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- );
-
- /* now do something to the resulting VObject */
- /* pretty print on stdout for fun */
- printVObject(cfp,vcal);
- /* open the output text file */
-
-#define OUTFILE "frankcal.vcf"
-
- fp = fopen(OUTFILE, "w");
- if (fp) {
- /* write it in text form */
- writeVObject(fp,vcal);
- fclose(fp);
- }
- else {
- fprintf(cfp,"open output file '%s' failed\n", OUTFILE);
- }
- if (cfp != stdout) fclose(cfp);
- }
-
-void main() {
- testVcalAPIs();
- }
-
diff --git a/libversit/vcaltmp.c b/libversit/vcaltmp.c
deleted file mode 100644
index bd79e27975..0000000000
--- a/libversit/vcaltmp.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
-This module provides some helper APIs for creating
-a VCalendar object.
-
-Note on APIs:
- 1. The APIs does not attempt to verify if the arguments
- passed are correct.
- 2. Where the argument to an API is not applicable, pass
- the value 0.
- 3. See the test program at the bottom of this file as an
- example of usage.
- 4. This code calls APIs in vobject.c.
-
-*/
-
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-
-#include <stdio.h>
-#include <string.h>
-#include "vcaltmp.h"
-
-
-DLLEXPORT(VObject*) vcsCreateVCal(
- char *date_created,
- char *location,
- char *product_id,
- char *time_zone,
- char *version
- )
- {
- VObject *vcal = newVObject(VCCalProp);
-#define Z(p,v) if (v) addPropValue(vcal,p,v);
- Z(VCDCreatedProp, date_created);
- Z(VCLocationProp, location)
- Z(VCProdIdProp, product_id)
- Z(VCTimeZoneProp, time_zone)
- Z(VCVersionProp, version)
-#undef Z
- return vcal;
- }
-
-
-DLLEXPORT(VObject*) vcsAddEvent(
- VObject *vcal,
- char *start_date_time,
- char *end_date_time,
- char *description,
- char *summary,
- char *categories,
- char *classification,
- char *status,
- char *transparency,
- char *uid,
- char *url
- )
- {
- VObject *vevent = addProp(vcal,VCEventProp);
-#define Z(p,v) if (v) addPropValue(vevent,p,v);
- Z(VCDTstartProp,start_date_time);
- Z(VCDTendProp,end_date_time);
- if (description) {
- VObject *p = addPropValue(vevent,VCDescriptionProp,description);
- if (strchr(description,'\n'))
- addProp(p,VCQuotedPrintableProp);
- }
- Z(VCSummaryProp,summary);
- Z(VCCategoriesProp,categories);
- Z(VCClassProp,classification);
- Z(VCStatusProp,status);
- Z(VCTranspProp,transparency);
- Z(VCUniqueStringProp,uid);
- Z(VCURLProp,url);
-#undef Z
- return vevent;
- }
-
-
-DLLEXPORT(VObject*) vcsAddTodo(
- VObject *vcal,
- char *start_date_time,
- char *due_date_time,
- char *date_time_complete,
- char *description,
- char *summary,
- char *priority,
- char *classification,
- char *status,
- char *uid,
- char *url
- )
- {
- VObject *vtodo = addProp(vcal,VCTodoProp);
-#define Z(p,v) if (v) addPropValue(vtodo,p,v);
- Z(VCDTstartProp,start_date_time);
- Z(VCDueProp,due_date_time);
- Z(VCCompletedProp,date_time_complete);
- if (description) {
- VObject *p = addPropValue(vtodo,VCDescriptionProp,description);
- if (strchr(description,'\n'))
- addProp(p,VCQuotedPrintableProp);
- }
- Z(VCSummaryProp,summary);
- Z(VCPriorityProp,priority);
- Z(VCClassProp,classification);
- Z(VCStatusProp,status);
- Z(VCUniqueStringProp,uid);
- Z(VCURLProp,url);
-#undef Z
- return vtodo;
- }
-
-
-DLLEXPORT(VObject*) vcsAddAAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *audio_content
- )
- {
- VObject *aalarm= addProp(vevent,VCAAlarmProp);
-#define Z(p,v) if (v) addPropValue(aalarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCAudioContentProp,audio_content);
-#undef Z
- return aalarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddMAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *email_address,
- char *note
- )
- {
- VObject *malarm= addProp(vevent,VCMAlarmProp);
-#define Z(p,v) if (v) addPropValue(malarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCEmailAddressProp,email_address);
- Z(VCNoteProp,note);
-#undef Z
- return malarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddDAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *display_string
- )
- {
- VObject *dalarm= addProp(vevent,VCDAlarmProp);
-#define Z(p,v) if (v) addPropValue(dalarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCDisplayStringProp,display_string);
-#undef Z
- return dalarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddPAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *procedure_name
- )
- {
- VObject *palarm= addProp(vevent,VCPAlarmProp);
-#define Z(p,v) if (v) addPropValue(palarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCProcedureNameProp,procedure_name);
-#undef Z
- return palarm;
- }
-
-
-#ifdef _TEST
-
-#if 0
-This testcase would generate a file call "frankcal.vcf" with
-the following content:
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-GEO:37.24,-17.87
-PRODID:-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-DTSTART:19960523T120000
-DTEND:19960523T130000
-DESCRIPTION;QUOTED-PRINTABLE:VERSIT PDI PR Teleconference/Interview =0A=
-With Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar=0A=
-activities with European Press representatives.
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-CATEGORIES:PHONE CALL
-STATUS:CONFIRMED
-TRANSP:19960523T100522-4000F100582713-009251
-UID:http://www.ibm.com/raleigh/fdawson/~c:\or2\orgfiles\versit.or2
-DALARM:19960523T114500;5;3;Your Telecon Starts At Noon!!!;
-MALARM:19960522T120000;;;fdawson@raleigh.ibm.com;Remember 05/23 Noon Telecon!!!;
-PALARM:19960523T115500;;;c:\or2\organize.exe c:\or2\orgfiles\versit.or2;
-X-LDC-OR2-OLE:c:\temp\agenda.doc
-END:VEVENT
-
-BEGIN:VTODO
-DUE:19960614T0173000
-DESCRIPTION:Review VCalendar helper API.
-END:VTODO
-
-END:VCALENDAR
-
-#endif
-
-void testVcalAPIs() {
- FILE *fp;
- VObject *vcal = vcsCreateVCal(
- "19960523T100522",
- "37.24,-17.87",
- "-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN",
- 0,
- "0.3"
- );
-
- VObject *vevent = vcsAddEvent(
- vcal,
- "19960523T120000",
- "19960523T130000",
- "VERSIT PDI PR Teleconference/Interview \nWith Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar\nactivities with European Press representatives.",
- "VERSIT PDI PR Teleconference/Interview",
- "PHONE CALL",
- 0,
- "CONFIRMED",
- "19960523T100522-4000F100582713-009251",
- "http://www.ibm.com/raleigh/fdawson/~c:\\or2\\orgfiles\\versit.or2",
- 0
- );
-
- vcsAddDAlarm(vevent, "19960523T114500", "5", "3",
- "Your Telecon Starts At Noon!!!");
- vcsAddMAlarm(vevent, "19960522T120000", 0, 0, "fdawson@raleigh.ibm.com",
- "Remember 05/23 Noon Telecon!!!");
- vcsAddPAlarm(vevent, "19960523T115500", 0 ,0,
- "c:\\or2\\organize.exe c:\\or2\\orgfiles\\versit.or2");
-
- addPropValue(vevent, "X-LDC-OR2-OLE", "c:\\temp\\agenda.doc");
-
- vcsAddTodo(
- vcal,
- 0,
- "19960614T0173000",
- 0,
- "Review VCalendar helper API.",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- );
-
- /* now do something to the resulting VObject */
- /* pretty print on stdout for fun */
- printVObject(vcal);
- /* open the output text file */
-
-#define OUTFILE "frankcal.vcf"
-
- fp = fopen(OUTFILE, "w");
- if (fp) {
- /* write it in text form */
- writeVObject(fp,vcal);
- fclose(fp);
- }
- else {
- printf("open output file '%s' failed\n", OUTFILE);
- }
- }
-
-void main() {
- testVcalAPIs();
- }
-
-#endif
-
-
-// end of source file vcaltmp.c
diff --git a/libversit/vcaltmp.h b/libversit/vcaltmp.h
deleted file mode 100644
index 4c4afde963..0000000000
--- a/libversit/vcaltmp.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#include "vcc.h"
-
-#ifndef __VCALTMP_H__
-#define __VCALTMP_H__
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-extern DLLEXPORT(VObject*) vcsCreateVCal(
- char *date_created,
- char *location,
- char *product_id,
- char *time_zone,
- char *version
- );
-
-extern DLLEXPORT(VObject*) vcsAddEvent(
- VObject *vcal,
- char *start_date_time,
- char *end_date_time,
- char *description,
- char *summary,
- char *categories,
- char *classification,
- char *status,
- char *transparency,
- char *uid,
- char *url
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddTodo(
- VObject *vcal,
- char *start_date_time,
- char *due_date_time,
- char *date_time_complete,
- char *description,
- char *summary,
- char *priority,
- char *classification,
- char *status,
- char *uid,
- char *url
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddAAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *audio_content
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddMAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *email_address,
- char *note
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddDAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *display_string
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddPAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *procedure_name
- );
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VCALTMP_H__ */
-
-
diff --git a/libversit/vcc.c b/libversit/vcc.c
deleted file mode 100644
index 02ab47cb8e..0000000000
--- a/libversit/vcc.c
+++ /dev/null
@@ -1,2071 +0,0 @@
-
-/* A Bison parser, made from vcc.y
- by GNU Bison version 1.25
- */
-
-#define YYBISON 1 /* Identify Bison output. */
-
-#define EQ 258
-#define COLON 259
-#define DOT 260
-#define SEMICOLON 261
-#define SPACE 262
-#define HTAB 263
-#define LINESEP 264
-#define NEWLINE 265
-#define BEGIN_VCARD 266
-#define END_VCARD 267
-#define BEGIN_VCAL 268
-#define END_VCAL 269
-#define BEGIN_VEVENT 270
-#define END_VEVENT 271
-#define BEGIN_VTODO 272
-#define END_VTODO 273
-#define ID 274
-#define STRING 275
-
-#line 1 "vcc.y"
-
-
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
- * src: vcc.c
- * doc: Parser for vCard and vCalendar. Note that this code is
- * generated by a yacc parser generator. Generally it should not
- * be edited by hand. The real source is vcc.y. The #line directives
- * can be commented out here to make it easier to trace through
- * in a debugger. However, if a bug is found it should
- * be fixed in vcc.y and this file regenerated.
- */
-
-
-/* debugging utilities */
-#if __DEBUG
-#define DBG_(x) printf x
-#else
-#define DBG_(x)
-#endif
-
-/**** External Functions ****/
-
-/* assign local name to parser variables and functions so that
- we can use more than one yacc based parser.
-*/
-
-#define yyparse mime_parse
-#define yylex mime_lex
-#define yyerror mime_error
-#define yychar mime_char
-/* #define p_yyval p_mime_val */
-#undef yyval
-#define yyval mime_yyval
-/* #define p_yylval p_mime_lval */
-#undef yylval
-#define yylval mime_yylval
-#define yydebug mime_debug
-#define yynerrs mime_nerrs
-#define yyerrflag mime_errflag
-#define yyss mime_ss
-#define yyssp mime_ssp
-#define yyvs mime_vs
-#define yyvsp mime_vsp
-#define yylhs mime_lhs
-#define yylen mime_len
-#define yydefred mime_defred
-#define yydgoto mime_dgoto
-#define yysindex mime_sindex
-#define yyrindex mime_rindex
-#define yygindex mime_gindex
-#define yytable mime_table
-#define yycheck mime_check
-#define yyname mime_name
-#define yyrule mime_rule
-#define YYPREFIX "mime_"
-
-
-#ifndef _NO_LINE_FOLDING
-#define _SUPPORT_LINE_FOLDING 1
-#endif
-
-/* undef below if compile with MFC */
-/* #define INCLUDEMFC 1 */
-
-#if defined(WIN32) || defined(_WIN32)
-#ifdef INCLUDEMFC
-#include <afx.h>
-#endif
-#endif
-
-#include <string.h>
-#ifndef __MWERKS__
-#include <malloc.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "vcc.h"
-
-/**** Types, Constants ****/
-
-#define YYDEBUG 0 /* 1 to compile in some debugging code */
-#define MAXTOKEN 256 /* maximum token (line) length */
-#define YYSTACKSIZE 50 // ~unref ?
-#define MAXLEVEL 10 /* max # of nested objects parseable */
- /* (includes outermost) */
-
-
-/**** Global Variables ****/
-int mime_lineNum, mime_numErrors; /* yyerror() can use these */
-static VObject* vObjList;
-static VObject *curProp;
-static VObject *curObj;
-static VObject* ObjStack[MAXLEVEL];
-static int ObjStackTop;
-
-
-/* A helpful utility for the rest of the app. */
-#if __CPLUSPLUS__
-extern "C" {
-#endif
-
- extern void Parse_Debug(const char *s);
- extern void yyerror(char *s);
-
-#if __CPLUSPLUS__
- };
-#endif
-
-int yyparse();
-
-enum LexMode {
- L_NORMAL,
- L_VCARD,
- L_VCAL,
- L_VEVENT,
- L_VTODO,
- L_VALUES,
- L_BASE64,
- L_QUOTED_PRINTABLE
- };
-
-/**** Private Forward Declarations ****/
-static int pushVObject(const char *prop);
-static VObject* popVObject();
-static char* lexDataFromBase64();
-static void lexPopMode(int top);
-static int lexWithinMode(enum LexMode mode);
-static void lexPushMode(enum LexMode mode);
-static void enterProps(const char *s);
-static void enterAttr(const char *s1, const char *s2);
-static void enterValues(const char *value);
-static void mime_error_(char *s);
-
-
-#line 179 "vcc.y"
-typedef union {
- char *str;
- VObject *vobj;
- } YYSTYPE;
-#include <stdio.h>
-
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
-#endif
-#endif
-
-
-
-#define YYFINAL 62
-#define YYFLAG -32768
-#define YYNTBASE 21
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 51)
-
-static const char yytranslate[] = { 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20
-};
-
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 2, 3, 7, 9, 11, 13, 14, 19, 20,
- 24, 27, 29, 30, 36, 38, 39, 43, 45, 48,
- 50, 53, 55, 59, 61, 62, 67, 69, 71, 72,
- 73, 78, 79, 83, 86, 88, 90, 92, 94, 95,
- 100, 101, 105, 106, 111, 112
-};
-
-static const short yyrhs[] = { 22,
- 0, 0, 24, 23, 22, 0, 24, 0, 25, 0,
- 40, 0, 0, 11, 26, 28, 12, 0, 0, 11,
- 27, 12, 0, 29, 28, 0, 29, 0, 0, 31,
- 4, 30, 37, 9, 0, 1, 0, 0, 36, 32,
- 33, 0, 36, 0, 34, 33, 0, 34, 0, 6,
- 35, 0, 36, 0, 36, 3, 36, 0, 19, 0,
- 0, 39, 6, 38, 37, 0, 39, 0, 20, 0,
- 0, 0, 13, 41, 43, 14, 0, 0, 13, 42,
- 14, 0, 44, 43, 0, 44, 0, 45, 0, 48,
- 0, 28, 0, 0, 15, 46, 28, 16, 0, 0,
- 15, 47, 16, 0, 0, 17, 49, 28, 18, 0,
- 0, 17, 50, 18, 0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
- 207, 210, 213, 213, 217, 218, 221, 227, 232, 238,
- 244, 245, 248, 252, 258, 261, 266, 266, 272, 273,
- 276, 279, 283, 290, 293, 294, 294, 298, 299, 303,
- 307, 309, 312, 315, 316, 319, 321, 322, 325, 332,
- 337, 343, 349, 356, 361, 367
-};
-#endif
-
-
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
-
-static const char * const yytname[] = { "$","error","$undefined.","EQ","COLON",
-"DOT","SEMICOLON","SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD",
-"BEGIN_VCAL","END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO",
-"ID","STRING","mime","vobjects","@1","vobject","vcard","@2","@3","items","item",
-"@4","prop","@5","attr_params","attr_param","attr","name","values","@6","value",
-"vcal","@7","@8","calitems","calitem","eventitem","@9","@10","todoitem","@11",
-"@12", NULL
-};
-#endif
-
-static const short yyr1[] = { 0,
- 21, 23, 22, 22, 24, 24, 26, 25, 27, 25,
- 28, 28, 30, 29, 29, 32, 31, 31, 33, 33,
- 34, 35, 35, 36, 38, 37, 37, 39, 39, 41,
- 40, 42, 40, 43, 43, 44, 44, 44, 46, 45,
- 47, 45, 49, 48, 50, 48
-};
-
-static const short yyr2[] = { 0,
- 1, 0, 3, 1, 1, 1, 0, 4, 0, 3,
- 2, 1, 0, 5, 1, 0, 3, 1, 2, 1,
- 2, 1, 3, 1, 0, 4, 1, 1, 0, 0,
- 4, 0, 3, 2, 1, 1, 1, 1, 0, 4,
- 0, 3, 0, 4, 0, 3
-};
-
-static const short yydefact[] = { 0,
- 7, 30, 1, 2, 5, 6, 0, 0, 0, 0,
- 0, 15, 24, 0, 0, 0, 16, 10, 39, 43,
- 38, 0, 0, 36, 37, 33, 3, 8, 11, 13,
- 0, 0, 0, 0, 0, 31, 34, 29, 0, 17,
- 20, 0, 42, 0, 46, 28, 0, 27, 21, 22,
- 19, 40, 44, 14, 25, 0, 29, 23, 26, 0,
- 0, 0
-};
-
-static const short yydefgoto[] = { 60,
- 3, 11, 4, 5, 7, 8, 21, 15, 38, 16,
- 31, 40, 41, 49, 17, 47, 57, 48, 6, 9,
- 10, 22, 23, 24, 32, 33, 25, 34, 35
-};
-
-static const short yypact[] = { -9,
- -6, -5,-32768, 7,-32768,-32768, 2, -1, 19, 15,
- -9,-32768,-32768, 1, 0, 26, 27,-32768, 16, 17,
--32768, 23, 9,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
- 33, 2, 24, 2, 25,-32768,-32768, 13, 22,-32768,
- 33, 28,-32768, 29,-32768,-32768, 36, 40,-32768, 39,
--32768,-32768,-32768,-32768,-32768, 22, 13,-32768,-32768, 48,
- 49,-32768
-};
-
-static const short yypgoto[] = {-32768,
- 41,-32768,-32768,-32768,-32768,-32768, -7,-32768,-32768,-32768,
--32768, 10,-32768,-32768, -34, -4,-32768,-32768,-32768,-32768,
--32768, 31,-32768,-32768,-32768,-32768,-32768,-32768,-32768
-};
-
-
-#define YYLAST 54
-
-
-static const short yytable[] = { 14,
- 12, 1, 12, 2, 50, -9, -4, 29, -32, 12,
- 18, -12, 28, -12, -12, -12, -12, -12, 13, 12,
- 13, 58, -35, 19, 42, 20, 44, 13, 26, 30,
- -18, -41, 46, 19, -45, 20, 36, 13, 39, 43,
- 13, 56, 45, 52, 54, 55, 53, 61, 62, 0,
- 51, 27, 59, 37
-};
-
-static const short yycheck[] = { 7,
- 1, 11, 1, 13, 39, 12, 0, 15, 14, 1,
- 12, 12, 12, 14, 15, 16, 17, 18, 19, 1,
- 19, 56, 14, 15, 32, 17, 34, 19, 14, 4,
- 4, 16, 20, 15, 18, 17, 14, 19, 6, 16,
- 19, 3, 18, 16, 9, 6, 18, 0, 0, -1,
- 41, 11, 57, 23
-};
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/lib/bison.simple"
-
-/* Skeleton output parser for bison,
- Copyright (C) 1984, 1989, 1990 Free Software Foundation, 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
-#include <alloca.h>
-#else /* not sparc */
-#if defined (MSDOS) && !defined (__TURBOC__)
-#include <malloc.h>
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
-#include <malloc.h>
- #pragma alloca
-#else /* not MSDOS, __TURBOC__, or _AIX */
-#ifdef __hpux
-#ifdef __cplusplus
-extern "C" {
-void *alloca (unsigned int);
-};
-#else /* not __cplusplus */
-void *alloca ();
-#endif /* not __cplusplus */
-#endif /* __hpux */
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc. */
-#endif /* not GNU C. */
-#endif /* alloca not defined. */
-
-/* This is the parser code that is written into each bison parser
- when the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
-
-/* Note: there must be only one dollar sign in this file.
- It is replaced by the list of actions, each action
- as one case of the switch. */
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY -2
-#define YYEOF 0
-#define YYACCEPT return(0)
-#define YYABORT return(1)
-#define YYERROR goto yyerrlab1
-/* Like YYERROR except do call yyerror.
- This remains here temporarily to ease the
- transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-#define YYFAIL goto yyerrlab
-#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(token, value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { yychar = (token), yylval = (value); \
- yychar1 = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { yyerror ("syntax error: cannot back up"); YYERROR; } \
-while (0)
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-#ifndef YYPURE
-#define YYLEX yylex()
-#endif
-
-#ifdef YYPURE
-#ifdef YYLSP_NEEDED
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval, &yylloc)
-#endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval)
-#endif
-#endif /* not YYLSP_NEEDED */
-#endif
-
-/* If nonreentrant, generate the variables here */
-
-#ifndef YYPURE
-
-int yychar; /* the lookahead symbol */
-YYSTYPE yylval; /* the semantic value of the */
- /* lookahead symbol */
-
-#ifdef YYLSP_NEEDED
-YYLTYPE yylloc; /* location data for the lookahead */
- /* symbol */
-#endif
-
-int yynerrs; /* number of parse errors so far */
-#endif /* not YYPURE */
-
-#if YYDEBUG != 0
-int yydebug; /* nonzero means print parse trace */
-/* Since this is uninitialized, it does not stop multiple parsers
- from coexisting. */
-#endif
-
-/* YYINITDEPTH indicates the initial size of the parser's stacks */
-
-#ifndef YYINITDEPTH
-#define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH is the maximum size the stacks can grow to
- (effective only if the built-in stack extension method is used). */
-
-#if YYMAXDEPTH == 0
-#undef YYMAXDEPTH
-#endif
-
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH 10000
-#endif
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-int yyparse (void);
-#endif
-
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else /* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- int count;
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#else /* __cplusplus */
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (char *to, char *from, int count)
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#endif
-#endif
-
-#line 196 "/usr/lib/bison.simple"
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-int
-yyparse(YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
-{
- register int yystate;
- register int yyn;
- register short *yyssp;
- register YYSTYPE *yyvsp;
- int yyerrstatus; /* number of tokens to shift before error messages enabled */
- int yychar1 = 0; /* lookahead token as an internal (translated) token number */
-
- short yyssa[YYINITDEPTH]; /* the state stack */
- YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
-
- short *yyss = yyssa; /* refer to the stacks thru separate pointers */
- YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
-
-#ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK (yyvsp--, yyssp--)
-#endif
-
- int yystacksize = YYINITDEPTH;
-
-#ifdef YYPURE
- int yychar;
- YYSTYPE yylval;
- int yynerrs;
-#ifdef YYLSP_NEEDED
- YYLTYPE yylloc;
-#endif
-#endif
-
- YYSTYPE yyval; /* the variable used to return */
- /* semantic values from the action */
- /* routines */
-
- int yylen;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Starting parse\n");
-#endif
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss - 1;
- yyvsp = yyvs;
-#ifdef YYLSP_NEEDED
- yylsp = yyls;
-#endif
-
-/* Push a new state, which is found in yystate . */
-/* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks. */
-yynewstate:
-
- *++yyssp = yystate;
-
- if (yyssp >= yyss + yystacksize - 1)
- {
- /* Give user a chance to reallocate the stack */
- /* Use copies of these so that the &'s don't force the real ones into memory. */
- YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
-#ifdef YYLSP_NEEDED
- YYLTYPE *yyls1 = yyls;
-#endif
-
- /* Get the current used size of the three stacks, in elements. */
- int size = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- /* Each stack pointer address is followed by the size of
- the data in use in that stack, in bytes. */
-#ifdef YYLSP_NEEDED
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
-#else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
-#endif
-
- yyss = yyss1; yyvs = yyvs1;
-#ifdef YYLSP_NEEDED
- yyls = yyls1;
-#endif
-#else /* no yyoverflow */
- /* Extend the stack our own way. */
- if (yystacksize >= YYMAXDEPTH)
- {
- yyerror("parser stack overflow");
- return 2;
- }
- yystacksize *= 2;
- if (yystacksize > YYMAXDEPTH)
- yystacksize = YYMAXDEPTH;
- yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
- __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
- yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
-#endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + size - 1;
- yyvsp = yyvs + size - 1;
-#ifdef YYLSP_NEEDED
- yylsp = yyls + size - 1;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Stack size increased to %d\n", yystacksize);
-#endif
-
- if (yyssp >= yyss + yystacksize - 1)
- YYABORT;
- }
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Entering state %d\n", yystate);
-#endif
-
- goto yybackup;
- yybackup:
-
-/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
-/* yyresume: */
-
- /* First try to decide what to do without reference to lookahead token. */
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* yychar is either YYEMPTY or YYEOF
- or a valid token in external form. */
-
- if (yychar == YYEMPTY)
- {
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Reading a token: ");
-#endif
- yychar = YYLEX;
- }
-
- /* Convert token to internal form (in yychar1) for indexing tables with */
-
- if (yychar <= 0) /* This means end of input. */
- {
- yychar1 = 0;
- yychar = YYEOF; /* Don't call YYLEX any more */
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Now at end of input.\n");
-#endif
- }
- else
- {
- yychar1 = YYTRANSLATE(yychar);
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
-#ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-#endif
- fprintf (stderr, ")\n");
- }
-#endif
- }
-
- yyn += yychar1;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
- goto yydefault;
-
- yyn = yytable[yyn];
-
- /* yyn is what to do for this token type in this state.
- Negative => reduce, -yyn is rule number.
- Positive => shift, yyn is new state.
- New state is final state => don't bother to shift,
- just return success.
- 0, or most negative number => error. */
-
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrlab;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Shift the lookahead token. */
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
-#endif
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- /* count tokens shifted since error; after three, turn off error status. */
- if (yyerrstatus) yyerrstatus--;
-
- yystate = yyn;
- goto yynewstate;
-
-/* Do the default action for the current state. */
-yydefault:
-
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
-
-/* Do a reduction. yyn is the number of a rule to reduce with. */
-yyreduce:
- yylen = yyr2[yyn];
- if (yylen > 0)
- yyval = yyvsp[1-yylen]; /* implement default value of the action */
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- int i;
-
- fprintf (stderr, "Reducing via rule %d (line %d), ",
- yyn, yyrline[yyn]);
-
- /* Print the symbols being reduced, and their result. */
- for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
- fprintf (stderr, "%s ", yytname[yyrhs[i]]);
- fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
- }
-#endif
-
-
- switch (yyn) {
-
-case 2:
-#line 211 "vcc.y"
-{ addList(&vObjList, yyvsp[0].vobj); curObj = 0; ;
- break;}
-case 4:
-#line 214 "vcc.y"
-{ addList(&vObjList, yyvsp[0].vobj); curObj = 0; ;
- break;}
-case 7:
-#line 223 "vcc.y"
-{
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- ;
- break;}
-case 8:
-#line 228 "vcc.y"
-{
- lexPopMode(0);
- yyval.vobj = popVObject();
- ;
- break;}
-case 9:
-#line 233 "vcc.y"
-{
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- ;
- break;}
-case 10:
-#line 238 "vcc.y"
-{
- lexPopMode(0);
- yyval.vobj = popVObject();
- ;
- break;}
-case 13:
-#line 249 "vcc.y"
-{
- lexPushMode(L_VALUES);
- ;
- break;}
-case 14:
-#line 253 "vcc.y"
-{
- if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
- lexPopMode(0);
- lexPopMode(0);
- ;
- break;}
-case 16:
-#line 262 "vcc.y"
-{
- enterProps(yyvsp[0].str);
- ;
- break;}
-case 18:
-#line 267 "vcc.y"
-{
- enterProps(yyvsp[0].str);
- ;
- break;}
-case 22:
-#line 280 "vcc.y"
-{
- enterAttr(yyvsp[0].str,0);
- ;
- break;}
-case 23:
-#line 284 "vcc.y"
-{
- enterAttr(yyvsp[-2].str,yyvsp[0].str);
-
- ;
- break;}
-case 25:
-#line 293 "vcc.y"
-{ enterValues(yyvsp[-1].str); ;
- break;}
-case 27:
-#line 295 "vcc.y"
-{ enterValues(yyvsp[0].str); ;
- break;}
-case 29:
-#line 300 "vcc.y"
-{ yyval.str = 0; ;
- break;}
-case 30:
-#line 305 "vcc.y"
-{ if (!pushVObject(VCCalProp)) YYERROR; ;
- break;}
-case 31:
-#line 308 "vcc.y"
-{ yyval.vobj = popVObject(); ;
- break;}
-case 32:
-#line 310 "vcc.y"
-{ if (!pushVObject(VCCalProp)) YYERROR; ;
- break;}
-case 33:
-#line 312 "vcc.y"
-{ yyval.vobj = popVObject(); ;
- break;}
-case 39:
-#line 327 "vcc.y"
-{
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- ;
- break;}
-case 40:
-#line 333 "vcc.y"
-{
- lexPopMode(0);
- popVObject();
- ;
- break;}
-case 41:
-#line 338 "vcc.y"
-{
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- ;
- break;}
-case 42:
-#line 343 "vcc.y"
-{
- lexPopMode(0);
- popVObject();
- ;
- break;}
-case 43:
-#line 351 "vcc.y"
-{
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- ;
- break;}
-case 44:
-#line 357 "vcc.y"
-{
- lexPopMode(0);
- popVObject();
- ;
- break;}
-case 45:
-#line 362 "vcc.y"
-{
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- ;
- break;}
-case 46:
-#line 367 "vcc.y"
-{
- lexPopMode(0);
- popVObject();
- ;
- break;}
-}
- /* the action file gets copied in in place of this dollarsign */
-#line 498 "/usr/lib/bison.simple"
-
- yyvsp -= yylen;
- yyssp -= yylen;
-#ifdef YYLSP_NEEDED
- yylsp -= yylen;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
-#endif
-
- *++yyvsp = yyval;
-
-#ifdef YYLSP_NEEDED
- yylsp++;
- if (yylen == 0)
- {
- yylsp->first_line = yylloc.first_line;
- yylsp->first_column = yylloc.first_column;
- yylsp->last_line = (yylsp-1)->last_line;
- yylsp->last_column = (yylsp-1)->last_column;
- yylsp->text = 0;
- }
- else
- {
- yylsp->last_line = (yylsp+yylen-1)->last_line;
- yylsp->last_column = (yylsp+yylen-1)->last_column;
- }
-#endif
-
- /* Now "shift" the result of the reduction.
- Determine what state that goes to,
- based on the state we popped back to
- and the rule number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTBASE];
-
- goto yynewstate;
-
-yyerrlab: /* here on detecting error */
-
- if (! yyerrstatus)
- /* If not already recovering from an error, report this error. */
- {
- ++yynerrs;
-
-#ifdef YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (yyn > YYFLAG && yyn < YYLAST)
- {
- int size = 0;
- char *msg;
- int x, count;
-
- count = 0;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) malloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- {
- strcat(msg, count == 0 ? ", expecting `" : " or `");
- strcat(msg, yytname[x]);
- strcat(msg, "'");
- count++;
- }
- }
- yyerror(msg);
- free(msg);
- }
- else
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
- }
-
- goto yyerrlab1;
-yyerrlab1: /* here on error raised explicitly by an action */
-
- if (yyerrstatus == 3)
- {
- /* if just tried and failed to reuse lookahead token after an error, discard it. */
-
- /* return failure if at end of input */
- if (yychar == YYEOF)
- YYABORT;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
-#endif
-
- yychar = YYEMPTY;
- }
-
- /* Else will try to reuse lookahead token
- after shifting the error token. */
-
- yyerrstatus = 3; /* Each real token shifted decrements this */
-
- goto yyerrhandle;
-
-yyerrdefault: /* current state does not do anything special for the error token. */
-
-#if 0
- /* This is wrong; only states that explicitly want error tokens
- should shift them. */
- yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
- if (yyn) goto yydefault;
-#endif
-
-yyerrpop: /* pop the current state because it cannot handle the error token */
-
- if (yyssp == yyss) YYABORT;
- yyvsp--;
- yystate = *--yyssp;
-#ifdef YYLSP_NEEDED
- yylsp--;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "Error: state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
-#endif
-
-yyerrhandle:
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yyerrdefault;
-
- yyn += YYTERROR;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
- goto yyerrdefault;
-
- yyn = yytable[yyn];
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrpop;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrpop;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting error token, ");
-#endif
-
- *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- yystate = yyn;
- goto yynewstate;
-}
-#line 373 "vcc.y"
-
-/*/////////////////////////////////////////////////////////////////////////*/
-static int pushVObject(const char *prop)
- {
- VObject *newObj;
- if (ObjStackTop == MAXLEVEL)
- return FALSE;
-
- ObjStack[++ObjStackTop] = curObj;
-
- if (curObj) {
- newObj = addProp(curObj,prop);
- curObj = newObj;
- }
- else
- curObj = newVObject(prop);
-
- return TRUE;
- }
-
-
-/*/////////////////////////////////////////////////////////////////////////*/
-/* This pops the recently built vCard off the stack and returns it. */
-static VObject* popVObject()
- {
- VObject *oldObj;
- if (ObjStackTop < 0) {
- yyerror("pop on empty Object Stack\n");
- return 0;
- }
- oldObj = curObj;
- curObj = ObjStack[ObjStackTop--];
-
- return oldObj;
- }
-
-
-static void enterValues(const char *value)
- {
- if (fieldedProp && *fieldedProp) {
- if (value) {
- addPropValue(curProp,*fieldedProp,value);
- }
- /* else this field is empty, advance to next field */
- fieldedProp++;
- }
- else {
- if (value) {
- setVObjectUStringZValue_(curProp,fakeUnicode(value,0));
- }
- }
- deleteStr(value);
- }
-
-static void enterProps(const char *s)
- {
- curProp = addGroup(curObj,s);
- deleteStr(s);
- }
-
-static void enterAttr(const char *s1, const char *s2)
- {
- const char *p1, *p2;
- p1 = lookupProp_(s1);
- if (s2) {
- VObject *a;
- p2 = lookupProp_(s2);
- a = addProp(curProp,p1);
- setVObjectStringZValue(a,p2);
- }
- else
- addProp(curProp,p1);
- if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0))
- lexPushMode(L_BASE64);
- else if (stricmp(p1,VCQuotedPrintableProp) == 0
- || (s2 && stricmp(p2,VCQuotedPrintableProp)==0))
- lexPushMode(L_QUOTED_PRINTABLE);
- deleteStr(s1); deleteStr(s2);
- }
-
-
-#define MAX_LEX_LOOKAHEAD_0 32
-#define MAX_LEX_LOOKAHEAD 64
-#define MAX_LEX_MODE_STACK_SIZE 10
-#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
-
-struct LexBuf {
- /* input */
-#ifdef INCLUDEMFC
- CFile *inputFile;
-#else
- FILE *inputFile;
-#endif
- char *inputString;
- unsigned long curPos;
- unsigned long inputLen;
- /* lookahead buffer */
- /* -- lookahead buffer is short instead of char so that EOF
- / can be represented correctly.
- */
- unsigned long len;
- short buf[MAX_LEX_LOOKAHEAD];
- unsigned long getPtr;
- /* context stack */
- unsigned long lexModeStackTop;
- enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
- /* token buffer */
- unsigned long maxToken;
- char *strs;
- unsigned long strsLen;
- } lexBuf;
-
-static void lexPushMode(enum LexMode mode)
- {
- if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
- yyerror("lexical context stack overflow");
- else {
- lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
- }
- }
-
-static void lexPopMode(int top)
- {
- /* special case of pop for ease of error recovery -- this
- version will never underflow */
- if (top)
- lexBuf.lexModeStackTop = 0;
- else
- if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--;
- }
-
-static int lexWithinMode(enum LexMode mode) {
- unsigned long i;
- for (i=0;i<lexBuf.lexModeStackTop;i++)
- if (mode == lexBuf.lexModeStack[i]) return 1;
- return 0;
- }
-
-static char lexGetc_()
- {
- /* get next char from input, no buffering. */
- if (lexBuf.curPos == lexBuf.inputLen)
- return EOF;
- else if (lexBuf.inputString)
- return *(lexBuf.inputString + lexBuf.curPos++);
- else {
-#ifdef INCLUDEMFC
- char result;
- return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
-#else
- return fgetc(lexBuf.inputFile);
-#endif
- }
- }
-
-static int lexGeta()
- {
- ++lexBuf.len;
- return (lexBuf.buf[lexBuf.getPtr] = lexGetc_());
- }
-
-static int lexGeta_(int i)
- {
- ++lexBuf.len;
- return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
- }
-
-static void lexSkipLookahead() {
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* don't skip EOF. */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- }
-
-static int lexLookahead() {
- int c = (lexBuf.len)?
- lexBuf.buf[lexBuf.getPtr]:
- lexGeta();
- /* do the \r\n -> \n or \r -> \n translation here */
- if (c == '\r') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
- lexGeta_(1);
- if (a == '\n') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = c = '\n';
- }
- else if (c == '\n') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[lexBuf.getPtr+1]:
- lexGeta_(1);
- if (a == '\r') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = '\n';
- }
- return c;
- }
-
-static int lexGetc() {
- int c = lexLookahead();
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* EOF will remain in lookahead buffer */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- return c;
- }
-
-static void lexSkipLookaheadWord() {
- if (lexBuf.strsLen <= lexBuf.len) {
- lexBuf.len -= lexBuf.strsLen;
- lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
- }
- }
-
-static void lexClearToken()
- {
- lexBuf.strsLen = 0;
- }
-
-static void lexAppendc(int c)
- {
- lexBuf.strs[lexBuf.strsLen] = c;
- /* append up to zero termination */
- if (c == 0) return;
- lexBuf.strsLen++;
- if (lexBuf.strsLen > lexBuf.maxToken) {
- /* double the token string size */
- lexBuf.maxToken <<= 1;
- lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
- }
- }
-
-static char* lexStr() {
- return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
- }
-
-static void lexSkipWhite() {
- int c = lexLookahead();
- while (c == ' ' || c == '\t') {
- lexSkipLookahead();
- c = lexLookahead();
- }
- }
-
-static char* lexGetWord() {
- int c;
- lexSkipWhite();
- lexClearToken();
- c = lexLookahead();
- while (c != EOF && !strchr("\t\n ;:=",c)) {
- lexAppendc(c);
- lexSkipLookahead();
- c = lexLookahead();
- }
- lexAppendc(0);
- return lexStr();
- }
-
-static void lexPushLookahead(char *s, int len) {
- int putptr;
- if (len == 0) len = strlen(s);
- putptr = (int)lexBuf.getPtr - len;
- /* this function assumes that length of word to push back
- / is not greater than MAX_LEX_LOOKAHEAD.
- */
- if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
- lexBuf.getPtr = putptr;
- while (*s) {
- lexBuf.buf[putptr] = *s++;
- putptr = (putptr + 1) % MAX_LEX_LOOKAHEAD;
- }
- lexBuf.len += len;
- }
-
-static void lexPushLookaheadc(int c) {
- int putptr;
- /* can't putback EOF, because it never leaves lookahead buffer */
- if (c == EOF) return;
- putptr = (int)lexBuf.getPtr - 1;
- if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
- lexBuf.getPtr = putptr;
- lexBuf.buf[putptr] = c;
- lexBuf.len += 1;
- }
-
-static char* lexLookaheadWord() {
- /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
- / and thing bigger than that will stop the lookahead and return 0;
- / leading white spaces are not recoverable.
- */
- int c;
- int len = 0;
- int curgetptr = 0;
- lexSkipWhite();
- lexClearToken();
- curgetptr = (int)lexBuf.getPtr; // remember!
- while (len < (MAX_LEX_LOOKAHEAD_0)) {
- c = lexGetc();
- len++;
- if (c == EOF || strchr("\t\n ;:=", c)) {
- lexAppendc(0);
- /* restore lookahead buf. */
- lexBuf.len += len;
- lexBuf.getPtr = curgetptr;
- return lexStr();
- }
- else
- lexAppendc(c);
- }
- lexBuf.len += len; /* char that has been moved to lookahead buffer */
- lexBuf.getPtr = curgetptr;
- return 0;
- }
-
-#ifdef _SUPPORT_LINE_FOLDING
-static void handleMoreRFC822LineBreak(int c) {
- /* suport RFC 822 line break in cases like
- * ADR: foo;
- * morefoo;
- * more foo;
- */
- if (c == ';') {
- int a;
- lexSkipLookahead();
- /* skip white spaces */
- a = lexLookahead();
- while (a == ' ' || a == '\t') {
- lexSkipLookahead();
- a = lexLookahead();
- }
- if (a == '\n') {
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- /* continuation, throw away all the \n and spaces read so
- * far
- */
- lexSkipWhite();
- lexPushLookaheadc(';');
- }
- else {
- lexPushLookaheadc('\n');
- lexPushLookaheadc(';');
- }
- }
- else {
- lexPushLookaheadc(';');
- }
- }
- }
-
-static char* lexGet1Value() {
- int size = 0;
- int c;
- lexSkipWhite();
- c = lexLookahead();
- lexClearToken();
- while (c != EOF && c != ';') {
- if (c == '\n') {
- int a;
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- lexAppendc(' ');
- lexSkipLookahead();
- }
- else {
- lexPushLookaheadc('\n');
- break;
- }
- }
- else {
- lexAppendc(c);
- lexSkipLookahead();
- }
- c = lexLookahead();
- }
- lexAppendc(0);
- handleMoreRFC822LineBreak(c);
- return c==EOF?0:lexStr();
- }
-#endif
-
-static char* lexGetStrUntil(char *termset) {
- int size = 0;
- int c = lexLookahead();
- lexClearToken();
- while (c != EOF && !strchr(termset,c)) {
- lexAppendc(c);
- lexSkipLookahead();
- c = lexLookahead();
- }
- lexAppendc(0);
- return c==EOF?0:lexStr();
- }
-
-static int match_begin_name(int end) {
- char *n = lexLookaheadWord();
- int token = ID;
- if (n) {
- if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
- else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
- else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
- else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
- deleteStr(n);
- return token;
- }
- return 0;
- }
-
-
-#ifdef INCLUDEMFC
-void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
-#else
-void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
-#endif
- {
- // initialize lex mode stack
- lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
-
- // iniatialize lex buffer.
- lexBuf.inputString = (char*) inputstring;
- lexBuf.inputLen = inputlen;
- lexBuf.curPos = 0;
- lexBuf.inputFile = inputfile;
-
- lexBuf.len = 0;
- lexBuf.getPtr = 0;
-
- lexBuf.maxToken = MAXTOKEN;
- lexBuf.strs = (char*)malloc(MAXTOKEN);
- lexBuf.strsLen = 0;
-
- }
-
-static void finiLex() {
- free(lexBuf.strs);
- }
-
-
-/*/////////////////////////////////////////////////////////////////////////*/
-/* This parses and converts the base64 format for binary encoding into
- * a decoded buffer (allocated with new). See RFC 1521.
- */
-static char * lexGetDataFromBase64()
- {
- unsigned long bytesLen = 0, bytesMax = 0;
- int quadIx = 0, pad = 0;
- unsigned long trip = 0;
- unsigned char b;
- int c;
- unsigned char *bytes = NULL;
- unsigned char *oldBytes = NULL;
-
- DBG_(("db: lexGetDataFromBase64\n"));
- while (1) {
- c = lexGetc();
- if (c == '\n') {
- ++mime_lineNum;
- if (lexLookahead() == '\n') {
- /* a '\n' character by itself means end of data */
- break;
- }
- else continue; /* ignore '\n' */
- }
- else {
- if ((c >= 'A') && (c <= 'Z'))
- b = (unsigned char)(c - 'A');
- else if ((c >= 'a') && (c <= 'z'))
- b = (unsigned char)(c - 'a') + 26;
- else if ((c >= '0') && (c <= '9'))
- b = (unsigned char)(c - '0') + 52;
- else if (c == '+')
- b = 62;
- else if (c == '/')
- b = 63;
- else if (c == '=') {
- b = 0;
- pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
- } else { /* error condition */
- if (bytes) free(bytes);
- else if (oldBytes) free(oldBytes);
- // error recovery: skip until 2 adjacent newlines.
- DBG_(("db: invalid character 0x%x '%c'\n", c,c));
- if (c != EOF) {
- c = lexGetc();
- while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
- ++mime_lineNum;
- break;
- }
- c = lexGetc();
- }
- }
- return NULL;
- }
- trip = (trip << 6) | b;
- if (++quadIx == 4) {
- unsigned char outBytes[3];
- int numOut;
- int i;
- for (i = 0; i < 3; i++) {
- outBytes[2-i] = (unsigned char)(trip & 0xFF);
- trip >>= 8;
- }
- numOut = 3 - pad;
- if (bytesLen + numOut > bytesMax) {
- if (!bytes) {
- bytesMax = 1024;
- bytes = (unsigned char*)malloc((size_t)bytesMax);
- }
- else {
- bytesMax <<= 2;
- oldBytes = bytes;
- bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax);
- }
- if (bytes == 0) {
- mime_error("out of memory while processing BASE64 data\n");
- }
- }
- if (bytes) {
- memcpy(bytes + bytesLen, outBytes, numOut);
- bytesLen += numOut;
- }
- trip = 0;
- quadIx = 0;
- }
- }
- } /* while */
- DBG_(("db: bytesLen = %d\n", bytesLen));
- /* kludge: all this won't be necessary if we have tree form
- representation */
- if (bytes) {
- setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
- free(bytes);
- }
- else if (oldBytes) {
- setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
- free(oldBytes);
- }
- return 0;
- }
-
-static int match_begin_end_name(int end) {
- int token;
- lexSkipWhite();
- if (lexLookahead() != ':') return ID;
- lexSkipLookahead();
- lexSkipWhite();
- token = match_begin_name(end);
- if (token == ID) {
- lexPushLookaheadc(':');
- DBG_(("db: ID '%s'\n", yylval.str));
- return ID;
- }
- else if (token != 0) {
- lexSkipLookaheadWord();
- deleteStr(yylval.str);
- DBG_(("db: begin/end %d\n", token));
- return token;
- }
- return 0;
- }
-
-static char* lexGetQuotedPrintable()
- {
- char cur;
- unsigned long len = 0;
-
- lexClearToken();
- do {
- cur = lexGetc();
- switch (cur) {
- case '=': {
- int c = 0;
- int next[2];
- int i;
- for (i = 0; i < 2; i++) {
- next[i] = lexGetc();
- if (next[i] >= '0' && next[i] <= '9')
- c = c * 16 + next[i] - '0';
- else if (next[i] >= 'A' && next[i] <= 'F')
- c = c * 16 + next[i] - 'A' + 10;
- else
- break;
- }
- if (i == 0) {
- /* single '=' follow by LINESEP is continuation sign? */
- if (next[0] == '\n') {
- ++mime_lineNum;
- }
- else {
- lexPushLookaheadc('=');
- goto EndString;
- }
- }
- else if (i == 1) {
- lexPushLookaheadc(next[1]);
- lexPushLookaheadc(next[0]);
- lexAppendc('=');
- } else {
- lexAppendc(c);
- }
- break;
- } /* '=' */
- case '\n': {
- lexPushLookaheadc('\n');
- goto EndString;
- }
- case (char)EOF:
- break;
- default:
- lexAppendc(cur);
- break;
- } /* switch */
- } while (cur != (char)EOF);
-
-EndString:
- lexAppendc(0);
- return lexStr();
- } /* LexQuotedPrintable */
-
-static int yylex() {
- int token = 0;
-
- int lexmode = LEXMODE();
- if (lexmode == L_VALUES) {
- int c = lexGetc();
- if (c == ';') {
- DBG_(("db: SEMICOLON\n"));
- lexPushLookaheadc(c);
- handleMoreRFC822LineBreak(c);
- lexSkipLookahead();
- return SEMICOLON;
- }
- else if (strchr("\n",c)) {
- ++mime_lineNum;
- /* consume all line separator(s) adjacent to each other */
- c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }
- DBG_(("db: LINESEP\n"));
- return LINESEP;
- }
- else {
- char *p = 0;
- lexPushLookaheadc(c);
- if (lexWithinMode(L_BASE64)) {
- /* get each char and convert to bin on the fly... */
- p = lexGetDataFromBase64();
- yylval.str = p;
- return STRING;
- }
- else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
- p = lexGetQuotedPrintable();
- }
- else {
-#ifdef _SUPPORT_LINE_FOLDING
- p = lexGet1Value();
-#else
- p = lexGetStrUntil(";\n");
-#endif
- }
- if (p) {
- DBG_(("db: STRING: '%s'\n", p));
- yylval.str = p;
- return STRING;
- }
- else return 0;
- }
- }
- else {
- /* normal mode */
- while (1) {
- int c = lexGetc();
- switch(c) {
- case ':': {
- /* consume all line separator(s) adjacent to each other */
- /* ignoring linesep immediately after colon. */
- c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }
- DBG_(("db: COLON\n"));
- return COLON;
- }
- case ';':
- DBG_(("db: SEMICOLON\n"));
- return SEMICOLON;
- case '=':
- DBG_(("db: EQ\n"));
- return EQ;
- /* ignore whitespace in this mode */
- case '\t':
- case ' ': continue;
- case '\n': {
- ++mime_lineNum;
- continue;
- }
- case EOF: return 0;
- break;
- default: {
- lexPushLookaheadc(c);
- if (isalpha(c)) {
- char *t = lexGetWord();
- yylval.str = t;
- if (!stricmp(t, "begin")) {
- return match_begin_end_name(0);
- }
- else if (!stricmp(t,"end")) {
- return match_begin_end_name(1);
- }
- else {
- DBG_(("db: ID '%s'\n", t));
- return ID;
- }
- }
- else {
- /* unknow token */
- return 0;
- }
- break;
- }
- }
- }
- }
- return 0;
- }
-
-
-/***************************************************************************/
-/*** Public Functions ****/
-/***************************************************************************/
-
-static VObject* Parse_MIMEHelper()
- {
- ObjStackTop = -1;
- mime_numErrors = 0;
- mime_lineNum = 1;
- vObjList = 0;
- curObj = 0;
-
- if (yyparse() != 0)
- return 0;
-
- finiLex();
- return vObjList;
- }
-
-/*/////////////////////////////////////////////////////////////////////////*/
-DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
- {
- initLex(input, len, 0);
- return Parse_MIMEHelper();
- }
-
-
-#if INCLUDEMFC
-
-DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
- {
- unsigned long startPos;
- VObject *result;
-
- initLex(0,-1,file);
- startPos = file->GetPosition();
- if (!(result = Parse_MIMEHelper()))
- file->Seek(startPos, CFile::begin);
- return result;
- }
-
-#else
-
-VObject* Parse_MIME_FromFile(FILE *file)
- {
- VObject *result;
- long startPos;
-
- initLex(0,(unsigned long)-1,file);
- startPos = ftell(file);
- if (!(result = Parse_MIMEHelper())) {
- fseek(file,startPos,SEEK_SET);
- }
- return result;
- }
-
-DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
- {
- FILE *fp = fopen(fname,"r");
- if (fp) {
- VObject* o = Parse_MIME_FromFile(fp);
- fclose(fp);
- return o;
- }
- else {
- char msg[80];
- sprintf(msg, "can't open file '%s' for reading\n", fname);
- mime_error_(msg);
- return 0;
- }
- }
-
-#endif
-
-/*/////////////////////////////////////////////////////////////////////////*/
-static void YYDebug(const char *s)
-{
-/* Parse_Debug(s); */
-}
-
-
-static MimeErrorHandler mimeErrorHandler;
-
-DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me)
- {
- mimeErrorHandler = me;
- }
-
-static void mime_error(char *s)
- {
- char msg[256];
- if (mimeErrorHandler) {
- sprintf(msg,"%s at line %d", s, mime_lineNum);
- mimeErrorHandler(msg);
- }
- }
-
-static void mime_error_(char *s)
- {
- if (mimeErrorHandler) {
- mimeErrorHandler(s);
- }
- }
-
diff --git a/libversit/vcc.h b/libversit/vcc.h
deleted file mode 100644
index 0e52034710..0000000000
--- a/libversit/vcc.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#ifndef __VCC_H__
-#define __VCC_H__ 1
-
-#include "vobject.h"
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-typedef void (*MimeErrorHandler)(char *);
-
-extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
-
-extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
-extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
-
-
-/* NOTE regarding Parse_MIME_FromFile
-The function above, Parse_MIME_FromFile, comes in two flavors,
-neither of which is exported from the DLL. Each version takes
-a CFile or FILE* as a parameter, neither of which can be
-passed across a DLL interface (at least that is my experience).
-If you are linking this code into your build directly then
-you may find them a more convenient API that the other flavors
-that take a file name. If you use them with the DLL LIB you
-will get a link error.
-*/
-
-
-#if INCLUDEMFC
-extern VObject* Parse_MIME_FromFile(CFile *file);
-#else
-extern VObject* Parse_MIME_FromFile(FILE *file);
-#endif
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VCC_H__ */
-
diff --git a/libversit/vcc.y b/libversit/vcc.y
deleted file mode 100644
index b8b9933f2c..0000000000
--- a/libversit/vcc.y
+++ /dev/null
@@ -1,1217 +0,0 @@
-%{
-
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
- * src: vcc.c
- * doc: Parser for vCard and vCalendar. Note that this code is
- * generated by a yacc parser generator. Generally it should not
- * be edited by hand. The real source is vcc.y. The #line directives
- * can be commented out here to make it easier to trace through
- * in a debugger. However, if a bug is found it should
- * be fixed in vcc.y and this file regenerated.
- */
-
-
-/* debugging utilities */
-#if __DEBUG
-#define DBG_(x) printf x
-#else
-#define DBG_(x)
-#endif
-
-/**** External Functions ****/
-
-/* assign local name to parser variables and functions so that
- we can use more than one yacc based parser.
-*/
-
-#define yyparse mime_parse
-#define yylex mime_lex
-#define yyerror mime_error
-#define yychar mime_char
-/* #define p_yyval p_mime_val */
-#undef yyval
-#define yyval mime_yyval
-/* #define p_yylval p_mime_lval */
-#undef yylval
-#define yylval mime_yylval
-#define yydebug mime_debug
-#define yynerrs mime_nerrs
-#define yyerrflag mime_errflag
-#define yyss mime_ss
-#define yyssp mime_ssp
-#define yyvs mime_vs
-#define yyvsp mime_vsp
-#define yylhs mime_lhs
-#define yylen mime_len
-#define yydefred mime_defred
-#define yydgoto mime_dgoto
-#define yysindex mime_sindex
-#define yyrindex mime_rindex
-#define yygindex mime_gindex
-#define yytable mime_table
-#define yycheck mime_check
-#define yyname mime_name
-#define yyrule mime_rule
-#define YYPREFIX "mime_"
-
-
-#ifndef _NO_LINE_FOLDING
-#define _SUPPORT_LINE_FOLDING 1
-#endif
-
-/* undef below if compile with MFC */
-/* #define INCLUDEMFC 1 */
-
-#if defined(WIN32) || defined(_WIN32)
-#ifdef INCLUDEMFC
-#include <afx.h>
-#endif
-#endif
-
-#include <string.h>
-#ifndef __MWERKS__
-#include <malloc.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "vcc.h"
-
-/**** Types, Constants ****/
-
-#define YYDEBUG 0 /* 1 to compile in some debugging code */
-#define MAXTOKEN 256 /* maximum token (line) length */
-#define YYSTACKSIZE 50 // ~unref ?
-#define MAXLEVEL 10 /* max # of nested objects parseable */
- /* (includes outermost) */
-
-
-/**** Global Variables ****/
-int mime_lineNum, mime_numErrors; /* yyerror() can use these */
-static VObject* vObjList;
-static VObject *curProp;
-static VObject *curObj;
-static VObject* ObjStack[MAXLEVEL];
-static int ObjStackTop;
-
-
-/* A helpful utility for the rest of the app. */
-#if __CPLUSPLUS__
-extern "C" {
-#endif
-
- extern void Parse_Debug(const char *s);
- extern void yyerror(char *s);
-
-#if __CPLUSPLUS__
- };
-#endif
-
-int yyparse();
-
-enum LexMode {
- L_NORMAL,
- L_VCARD,
- L_VCAL,
- L_VEVENT,
- L_VTODO,
- L_VALUES,
- L_BASE64,
- L_QUOTED_PRINTABLE
- };
-
-/**** Private Forward Declarations ****/
-static int pushVObject(const char *prop);
-static VObject* popVObject();
-static char* lexDataFromBase64();
-static void lexPopMode(int top);
-static int lexWithinMode(enum LexMode mode);
-static void lexPushMode(enum LexMode mode);
-static void enterProps(const char *s);
-static void enterAttr(const char *s1, const char *s2);
-static void enterValues(const char *value);
-static void mime_error_(char *s);
-
-%}
-
-/***************************************************************************/
-/*** The grammar ****/
-/***************************************************************************/
-
-%union {
- char *str;
- VObject *vobj;
- }
-
-%token
- EQ COLON DOT SEMICOLON SPACE HTAB LINESEP NEWLINE
- BEGIN_VCARD END_VCARD BEGIN_VCAL END_VCAL
- BEGIN_VEVENT END_VEVENT BEGIN_VTODO END_VTODO
- ID
-
-/*
- * NEWLINE is the token that would occur outside a vCard,
- * while LINESEP is the token that would occur inside a vCard.
- */
-
-%token <str>
- STRING ID
-
-%type <str> name value
-
-%type <vobj> vcard vcal vobject
-
-%start mime
-
-%%
-
-
-mime: vobjects
- ;
-
-vobjects: vobject
- { addList(&vObjList, $1); curObj = 0; }
- vobjects
- | vobject
- { addList(&vObjList, $1); curObj = 0; }
- ;
-
-vobject: vcard
- | vcal
- ;
-
-vcard:
- BEGIN_VCARD
- {
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- }
- items END_VCARD
- {
- lexPopMode(0);
- $$ = popVObject();
- }
- | BEGIN_VCARD
- {
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- }
- END_VCARD
- {
- lexPopMode(0);
- $$ = popVObject();
- }
- ;
-
-items: item items
- | item
- ;
-
-item: prop COLON
- {
- lexPushMode(L_VALUES);
- }
- values LINESEP
- {
- if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
- lexPopMode(0);
- lexPopMode(0);
- }
- | error
- ;
-
-prop: name
- {
- enterProps($1);
- }
- attr_params
- | name
- {
- enterProps($1);
- }
- ;
-
-attr_params: attr_param attr_params
- | attr_param
- ;
-
-attr_param: SEMICOLON attr
- ;
-
-attr: name
- {
- enterAttr($1,0);
- }
- | name EQ name
- {
- enterAttr($1,$3);
-
- }
- ;
-
-name: ID
- ;
-
-values: value SEMICOLON { enterValues($1); } values
- | value
- { enterValues($1); }
- ;
-
-value: STRING
- |
- { $$ = 0; }
- ;
-
-vcal:
- BEGIN_VCAL
- { if (!pushVObject(VCCalProp)) YYERROR; }
- calitems
- END_VCAL
- { $$ = popVObject(); }
- | BEGIN_VCAL
- { if (!pushVObject(VCCalProp)) YYERROR; }
- END_VCAL
- { $$ = popVObject(); }
- ;
-
-calitems: calitem calitems
- | calitem
- ;
-
-calitem:
- eventitem
- | todoitem
- | items
- ;
-
-eventitem:
- BEGIN_VEVENT
- {
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- }
- items
- END_VEVENT
- {
- lexPopMode(0);
- popVObject();
- }
- | BEGIN_VEVENT
- {
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- }
- END_VEVENT
- {
- lexPopMode(0);
- popVObject();
- }
- ;
-
-todoitem:
- BEGIN_VTODO
- {
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- }
- items
- END_VTODO
- {
- lexPopMode(0);
- popVObject();
- }
- | BEGIN_VTODO
- {
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- }
- END_VTODO
- {
- lexPopMode(0);
- popVObject();
- }
- ;
-
-%%
-/*/////////////////////////////////////////////////////////////////////////*/
-static int pushVObject(const char *prop)
- {
- VObject *newObj;
- if (ObjStackTop == MAXLEVEL)
- return FALSE;
-
- ObjStack[++ObjStackTop] = curObj;
-
- if (curObj) {
- newObj = addProp(curObj,prop);
- curObj = newObj;
- }
- else
- curObj = newVObject(prop);
-
- return TRUE;
- }
-
-
-/*/////////////////////////////////////////////////////////////////////////*/
-/* This pops the recently built vCard off the stack and returns it. */
-static VObject* popVObject()
- {
- VObject *oldObj;
- if (ObjStackTop < 0) {
- yyerror("pop on empty Object Stack\n");
- return 0;
- }
- oldObj = curObj;
- curObj = ObjStack[ObjStackTop--];
-
- return oldObj;
- }
-
-
-static void enterValues(const char *value)
- {
- if (fieldedProp && *fieldedProp) {
- if (value) {
- addPropValue(curProp,*fieldedProp,value);
- }
- /* else this field is empty, advance to next field */
- fieldedProp++;
- }
- else {
- if (value) {
- setVObjectUStringZValue_(curProp,fakeUnicode(value,0));
- }
- }
- deleteStr(value);
- }
-
-static void enterProps(const char *s)
- {
- curProp = addGroup(curObj,s);
- deleteStr(s);
- }
-
-static void enterAttr(const char *s1, const char *s2)
- {
- const char *p1, *p2;
- p1 = lookupProp_(s1);
- if (s2) {
- VObject *a;
- p2 = lookupProp_(s2);
- a = addProp(curProp,p1);
- setVObjectStringZValue(a,p2);
- }
- else
- addProp(curProp,p1);
- if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0))
- lexPushMode(L_BASE64);
- else if (stricmp(p1,VCQuotedPrintableProp) == 0
- || (s2 && stricmp(p2,VCQuotedPrintableProp)==0))
- lexPushMode(L_QUOTED_PRINTABLE);
- deleteStr(s1); deleteStr(s2);
- }
-
-
-#define MAX_LEX_LOOKAHEAD_0 32
-#define MAX_LEX_LOOKAHEAD 64
-#define MAX_LEX_MODE_STACK_SIZE 10
-#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
-
-struct LexBuf {
- /* input */
-#ifdef INCLUDEMFC
- CFile *inputFile;
-#else
- FILE *inputFile;
-#endif
- char *inputString;
- unsigned long curPos;
- unsigned long inputLen;
- /* lookahead buffer */
- /* -- lookahead buffer is short instead of char so that EOF
- / can be represented correctly.
- */
- unsigned long len;
- short buf[MAX_LEX_LOOKAHEAD];
- unsigned long getPtr;
- /* context stack */
- unsigned long lexModeStackTop;
- enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
- /* token buffer */
- unsigned long maxToken;
- char *strs;
- unsigned long strsLen;
- } lexBuf;
-
-static void lexPushMode(enum LexMode mode)
- {
- if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
- yyerror("lexical context stack overflow");
- else {
- lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
- }
- }
-
-static void lexPopMode(int top)
- {
- /* special case of pop for ease of error recovery -- this
- version will never underflow */
- if (top)
- lexBuf.lexModeStackTop = 0;
- else
- if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--;
- }
-
-static int lexWithinMode(enum LexMode mode) {
- unsigned long i;
- for (i=0;i<lexBuf.lexModeStackTop;i++)
- if (mode == lexBuf.lexModeStack[i]) return 1;
- return 0;
- }
-
-static char lexGetc_()
- {
- /* get next char from input, no buffering. */
- if (lexBuf.curPos == lexBuf.inputLen)
- return EOF;
- else if (lexBuf.inputString)
- return *(lexBuf.inputString + lexBuf.curPos++);
- else {
-#ifdef INCLUDEMFC
- char result;
- return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
-#else
- return fgetc(lexBuf.inputFile);
-#endif
- }
- }
-
-static int lexGeta()
- {
- ++lexBuf.len;
- return (lexBuf.buf[lexBuf.getPtr] = lexGetc_());
- }
-
-static int lexGeta_(int i)
- {
- ++lexBuf.len;
- return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
- }
-
-static void lexSkipLookahead() {
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* don't skip EOF. */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- }
-
-static int lexLookahead() {
- int c = (lexBuf.len)?
- lexBuf.buf[lexBuf.getPtr]:
- lexGeta();
- /* do the \r\n -> \n or \r -> \n translation here */
- if (c == '\r') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
- lexGeta_(1);
- if (a == '\n') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = c = '\n';
- }
- else if (c == '\n') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[lexBuf.getPtr+1]:
- lexGeta_(1);
- if (a == '\r') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = '\n';
- }
- return c;
- }
-
-static int lexGetc() {
- int c = lexLookahead();
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* EOF will remain in lookahead buffer */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- return c;
- }
-
-static void lexSkipLookaheadWord() {
- if (lexBuf.strsLen <= lexBuf.len) {
- lexBuf.len -= lexBuf.strsLen;
- lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
- }
- }
-
-static void lexClearToken()
- {
- lexBuf.strsLen = 0;
- }
-
-static void lexAppendc(int c)
- {
- lexBuf.strs[lexBuf.strsLen] = c;
- /* append up to zero termination */
- if (c == 0) return;
- lexBuf.strsLen++;
- if (lexBuf.strsLen > lexBuf.maxToken) {
- /* double the token string size */
- lexBuf.maxToken <<= 1;
- lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
- }
- }
-
-static char* lexStr() {
- return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
- }
-
-static void lexSkipWhite() {
- int c = lexLookahead();
- while (c == ' ' || c == '\t') {
- lexSkipLookahead();
- c = lexLookahead();
- }
- }
-
-static char* lexGetWord() {
- int c;
- lexSkipWhite();
- lexClearToken();
- c = lexLookahead();
- while (c != EOF && !strchr("\t\n ;:=",c)) {
- lexAppendc(c);
- lexSkipLookahead();
- c = lexLookahead();
- }
- lexAppendc(0);
- return lexStr();
- }
-
-static void lexPushLookahead(char *s, int len) {
- int putptr;
- if (len == 0) len = strlen(s);
- putptr = (int)lexBuf.getPtr - len;
- /* this function assumes that length of word to push back
- / is not greater than MAX_LEX_LOOKAHEAD.
- */
- if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
- lexBuf.getPtr = putptr;
- while (*s) {
- lexBuf.buf[putptr] = *s++;
- putptr = (putptr + 1) % MAX_LEX_LOOKAHEAD;
- }
- lexBuf.len += len;
- }
-
-static void lexPushLookaheadc(int c) {
- int putptr;
- /* can't putback EOF, because it never leaves lookahead buffer */
- if (c == EOF) return;
- putptr = (int)lexBuf.getPtr - 1;
- if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
- lexBuf.getPtr = putptr;
- lexBuf.buf[putptr] = c;
- lexBuf.len += 1;
- }
-
-static char* lexLookaheadWord() {
- /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
- / and thing bigger than that will stop the lookahead and return 0;
- / leading white spaces are not recoverable.
- */
- int c;
- int len = 0;
- int curgetptr = 0;
- lexSkipWhite();
- lexClearToken();
- curgetptr = (int)lexBuf.getPtr; // remember!
- while (len < (MAX_LEX_LOOKAHEAD_0)) {
- c = lexGetc();
- len++;
- if (c == EOF || strchr("\t\n ;:=", c)) {
- lexAppendc(0);
- /* restore lookahead buf. */
- lexBuf.len += len;
- lexBuf.getPtr = curgetptr;
- return lexStr();
- }
- else
- lexAppendc(c);
- }
- lexBuf.len += len; /* char that has been moved to lookahead buffer */
- lexBuf.getPtr = curgetptr;
- return 0;
- }
-
-#ifdef _SUPPORT_LINE_FOLDING
-static void handleMoreRFC822LineBreak(int c) {
- /* suport RFC 822 line break in cases like
- * ADR: foo;
- * morefoo;
- * more foo;
- */
- if (c == ';') {
- int a;
- lexSkipLookahead();
- /* skip white spaces */
- a = lexLookahead();
- while (a == ' ' || a == '\t') {
- lexSkipLookahead();
- a = lexLookahead();
- }
- if (a == '\n') {
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- /* continuation, throw away all the \n and spaces read so
- * far
- */
- lexSkipWhite();
- lexPushLookaheadc(';');
- }
- else {
- lexPushLookaheadc('\n');
- lexPushLookaheadc(';');
- }
- }
- else {
- lexPushLookaheadc(';');
- }
- }
- }
-
-static char* lexGet1Value() {
- int size = 0;
- int c;
- lexSkipWhite();
- c = lexLookahead();
- lexClearToken();
- while (c != EOF && c != ';') {
- if (c == '\n') {
- int a;
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- lexAppendc(' ');
- lexSkipLookahead();
- }
- else {
- lexPushLookaheadc('\n');
- break;
- }
- }
- else {
- lexAppendc(c);
- lexSkipLookahead();
- }
- c = lexLookahead();
- }
- lexAppendc(0);
- handleMoreRFC822LineBreak(c);
- return c==EOF?0:lexStr();
- }
-#endif
-
-static char* lexGetStrUntil(char *termset) {
- int size = 0;
- int c = lexLookahead();
- lexClearToken();
- while (c != EOF && !strchr(termset,c)) {
- lexAppendc(c);
- lexSkipLookahead();
- c = lexLookahead();
- }
- lexAppendc(0);
- return c==EOF?0:lexStr();
- }
-
-static int match_begin_name(int end) {
- char *n = lexLookaheadWord();
- int token = ID;
- if (n) {
- if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
- else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
- else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
- else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
- deleteStr(n);
- return token;
- }
- return 0;
- }
-
-
-#ifdef INCLUDEMFC
-void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
-#else
-void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
-#endif
- {
- // initialize lex mode stack
- lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
-
- // iniatialize lex buffer.
- lexBuf.inputString = (char*) inputstring;
- lexBuf.inputLen = inputlen;
- lexBuf.curPos = 0;
- lexBuf.inputFile = inputfile;
-
- lexBuf.len = 0;
- lexBuf.getPtr = 0;
-
- lexBuf.maxToken = MAXTOKEN;
- lexBuf.strs = (char*)malloc(MAXTOKEN);
- lexBuf.strsLen = 0;
-
- }
-
-static void finiLex() {
- free(lexBuf.strs);
- }
-
-
-/*/////////////////////////////////////////////////////////////////////////*/
-/* This parses and converts the base64 format for binary encoding into
- * a decoded buffer (allocated with new). See RFC 1521.
- */
-static char * lexGetDataFromBase64()
- {
- unsigned long bytesLen = 0, bytesMax = 0;
- int quadIx = 0, pad = 0;
- unsigned long trip = 0;
- unsigned char b;
- int c;
- unsigned char *bytes = NULL;
- unsigned char *oldBytes = NULL;
-
- DBG_(("db: lexGetDataFromBase64\n"));
- while (1) {
- c = lexGetc();
- if (c == '\n') {
- ++mime_lineNum;
- if (lexLookahead() == '\n') {
- /* a '\n' character by itself means end of data */
- break;
- }
- else continue; /* ignore '\n' */
- }
- else {
- if ((c >= 'A') && (c <= 'Z'))
- b = (unsigned char)(c - 'A');
- else if ((c >= 'a') && (c <= 'z'))
- b = (unsigned char)(c - 'a') + 26;
- else if ((c >= '0') && (c <= '9'))
- b = (unsigned char)(c - '0') + 52;
- else if (c == '+')
- b = 62;
- else if (c == '/')
- b = 63;
- else if (c == '=') {
- b = 0;
- pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
- } else { /* error condition */
- if (bytes) free(bytes);
- else if (oldBytes) free(oldBytes);
- // error recovery: skip until 2 adjacent newlines.
- DBG_(("db: invalid character 0x%x '%c'\n", c,c));
- if (c != EOF) {
- c = lexGetc();
- while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
- ++mime_lineNum;
- break;
- }
- c = lexGetc();
- }
- }
- return NULL;
- }
- trip = (trip << 6) | b;
- if (++quadIx == 4) {
- unsigned char outBytes[3];
- int numOut;
- int i;
- for (i = 0; i < 3; i++) {
- outBytes[2-i] = (unsigned char)(trip & 0xFF);
- trip >>= 8;
- }
- numOut = 3 - pad;
- if (bytesLen + numOut > bytesMax) {
- if (!bytes) {
- bytesMax = 1024;
- bytes = (unsigned char*)malloc((size_t)bytesMax);
- }
- else {
- bytesMax <<= 2;
- oldBytes = bytes;
- bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax);
- }
- if (bytes == 0) {
- mime_error("out of memory while processing BASE64 data\n");
- }
- }
- if (bytes) {
- memcpy(bytes + bytesLen, outBytes, numOut);
- bytesLen += numOut;
- }
- trip = 0;
- quadIx = 0;
- }
- }
- } /* while */
- DBG_(("db: bytesLen = %d\n", bytesLen));
- /* kludge: all this won't be necessary if we have tree form
- representation */
- if (bytes) {
- setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
- free(bytes);
- }
- else if (oldBytes) {
- setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
- free(oldBytes);
- }
- return 0;
- }
-
-static int match_begin_end_name(int end) {
- int token;
- lexSkipWhite();
- if (lexLookahead() != ':') return ID;
- lexSkipLookahead();
- lexSkipWhite();
- token = match_begin_name(end);
- if (token == ID) {
- lexPushLookaheadc(':');
- DBG_(("db: ID '%s'\n", yylval.str));
- return ID;
- }
- else if (token != 0) {
- lexSkipLookaheadWord();
- deleteStr(yylval.str);
- DBG_(("db: begin/end %d\n", token));
- return token;
- }
- return 0;
- }
-
-static char* lexGetQuotedPrintable()
- {
- char cur;
- unsigned long len = 0;
-
- lexClearToken();
- do {
- cur = lexGetc();
- switch (cur) {
- case '=': {
- int c = 0;
- int next[2];
- int i;
- for (i = 0; i < 2; i++) {
- next[i] = lexGetc();
- if (next[i] >= '0' && next[i] <= '9')
- c = c * 16 + next[i] - '0';
- else if (next[i] >= 'A' && next[i] <= 'F')
- c = c * 16 + next[i] - 'A' + 10;
- else
- break;
- }
- if (i == 0) {
- /* single '=' follow by LINESEP is continuation sign? */
- if (next[0] == '\n') {
- ++mime_lineNum;
- }
- else {
- lexPushLookaheadc('=');
- goto EndString;
- }
- }
- else if (i == 1) {
- lexPushLookaheadc(next[1]);
- lexPushLookaheadc(next[0]);
- lexAppendc('=');
- } else {
- lexAppendc(c);
- }
- break;
- } /* '=' */
- case '\n': {
- lexPushLookaheadc('\n');
- goto EndString;
- }
- case (char)EOF:
- break;
- default:
- lexAppendc(cur);
- break;
- } /* switch */
- } while (cur != (char)EOF);
-
-EndString:
- lexAppendc(0);
- return lexStr();
- } /* LexQuotedPrintable */
-
-static int yylex() {
- int token = 0;
-
- int lexmode = LEXMODE();
- if (lexmode == L_VALUES) {
- int c = lexGetc();
- if (c == ';') {
- DBG_(("db: SEMICOLON\n"));
- lexPushLookaheadc(c);
- handleMoreRFC822LineBreak(c);
- lexSkipLookahead();
- return SEMICOLON;
- }
- else if (strchr("\n",c)) {
- ++mime_lineNum;
- /* consume all line separator(s) adjacent to each other */
- c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }
- DBG_(("db: LINESEP\n"));
- return LINESEP;
- }
- else {
- char *p = 0;
- lexPushLookaheadc(c);
- if (lexWithinMode(L_BASE64)) {
- /* get each char and convert to bin on the fly... */
- p = lexGetDataFromBase64();
- yylval.str = p;
- return STRING;
- }
- else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
- p = lexGetQuotedPrintable();
- }
- else {
-#ifdef _SUPPORT_LINE_FOLDING
- p = lexGet1Value();
-#else
- p = lexGetStrUntil(";\n");
-#endif
- }
- if (p) {
- DBG_(("db: STRING: '%s'\n", p));
- yylval.str = p;
- return STRING;
- }
- else return 0;
- }
- }
- else {
- /* normal mode */
- while (1) {
- int c = lexGetc();
- switch(c) {
- case ':': {
- /* consume all line separator(s) adjacent to each other */
- /* ignoring linesep immediately after colon. */
- c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }
- DBG_(("db: COLON\n"));
- return COLON;
- }
- case ';':
- DBG_(("db: SEMICOLON\n"));
- return SEMICOLON;
- case '=':
- DBG_(("db: EQ\n"));
- return EQ;
- /* ignore whitespace in this mode */
- case '\t':
- case ' ': continue;
- case '\n': {
- ++mime_lineNum;
- continue;
- }
- case EOF: return 0;
- break;
- default: {
- lexPushLookaheadc(c);
- if (isalpha(c)) {
- char *t = lexGetWord();
- yylval.str = t;
- if (!stricmp(t, "begin")) {
- return match_begin_end_name(0);
- }
- else if (!stricmp(t,"end")) {
- return match_begin_end_name(1);
- }
- else {
- DBG_(("db: ID '%s'\n", t));
- return ID;
- }
- }
- else {
- /* unknow token */
- return 0;
- }
- break;
- }
- }
- }
- }
- return 0;
- }
-
-
-/***************************************************************************/
-/*** Public Functions ****/
-/***************************************************************************/
-
-static VObject* Parse_MIMEHelper()
- {
- ObjStackTop = -1;
- mime_numErrors = 0;
- mime_lineNum = 1;
- vObjList = 0;
- curObj = 0;
-
- if (yyparse() != 0)
- return 0;
-
- finiLex();
- return vObjList;
- }
-
-/*/////////////////////////////////////////////////////////////////////////*/
-DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
- {
- initLex(input, len, 0);
- return Parse_MIMEHelper();
- }
-
-
-#if INCLUDEMFC
-
-DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
- {
- unsigned long startPos;
- VObject *result;
-
- initLex(0,-1,file);
- startPos = file->GetPosition();
- if (!(result = Parse_MIMEHelper()))
- file->Seek(startPos, CFile::begin);
- return result;
- }
-
-#else
-
-VObject* Parse_MIME_FromFile(FILE *file)
- {
- VObject *result;
- long startPos;
-
- initLex(0,(unsigned long)-1,file);
- startPos = ftell(file);
- if (!(result = Parse_MIMEHelper())) {
- fseek(file,startPos,SEEK_SET);
- }
- return result;
- }
-
-DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
- {
- FILE *fp = fopen(fname,"r");
- if (fp) {
- VObject* o = Parse_MIME_FromFile(fp);
- fclose(fp);
- return o;
- }
- else {
- char msg[80];
- sprintf(msg, "can't open file '%s' for reading\n", fname);
- mime_error_(msg);
- return 0;
- }
- }
-
-#endif
-
-/*/////////////////////////////////////////////////////////////////////////*/
-static void YYDebug(const char *s)
-{
-/* Parse_Debug(s); */
-}
-
-
-static MimeErrorHandler mimeErrorHandler;
-
-DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me)
- {
- mimeErrorHandler = me;
- }
-
-static void mime_error(char *s)
- {
- char msg[256];
- if (mimeErrorHandler) {
- sprintf(msg,"%s at line %d", s, mime_lineNum);
- mimeErrorHandler(msg);
- }
- }
-
-static void mime_error_(char *s)
- {
- if (mimeErrorHandler) {
- mimeErrorHandler(s);
- }
- }
-
diff --git a/libversit/vctest.c b/libversit/vctest.c
deleted file mode 100644
index b14e6c1b4e..0000000000
--- a/libversit/vctest.c
+++ /dev/null
@@ -1,95 +0,0 @@
-
-#include <stdio.h>
-#include <string.h>
-#include "vcc.h"
-
-FILE *cfp;
-
-void myMimeErrorHandler(char *s)
-{
- printf("%s\n", s);
-}
-
-void main(int argc, char **argv)
-{
- int testmem = 0;
-
- char * foo[2] = {"foo","alden.vcf"};
-
-argc = 2;
-argv = foo;
-
-#ifdef _CONSOLE
- cfp = stdout;
- registerMimeErrorHandler(myMimeErrorHandler);
-#else
- cfp = fopen("vctest.out", "w");
- if (!cfp) return;
-#endif
- ++argv;
- while (--argc) {
- FILE *fp;
- if (strcmp(*argv,"-testmem") == 0) {
- testmem = 1;
- argv++;
- continue;
- }
- fprintf(cfp,"processing %s\n",*argv);
- fp = fopen(*argv,"r");
- if (!fp) {
- fprintf(cfp,"error opening file\n");
- }
- else {
- VObject *v, *t;
- FILE *ofp;
- char buf[256];
- char *p;
- strcpy(buf,*argv);
- p = strchr(buf,'.');
- if (p) *p = 0;
- strcat(buf,".out");
- fprintf(cfp,"reading text input from '%s'...\n", *argv);
- //v = Parse_MIME_FromFile(fp);
- v = Parse_MIME_FromFileName(*argv);
- writeVObjectToFile(buf,v);
- cleanVObject(v);
-
- /*
- fprintf(cfp,"pretty print internal format of '%s'...\n", *argv);
- ofp = fopen(buf,"w");
- while (v) {
- printVObject(cfp,v);
- if (testmem) {
- char *s, *p;
- fprintf(cfp,"test writing to mem...\n");
- p = s = writeMemVObject(0,0,v);
- if (s) {
- while (*s) {
- fputc(*s,ofp);
- s++;
- }
- free(p);
- }
- }
- else {
- writeVObject(ofp,v);
- }
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
-
- fclose(ofp);
- fclose(fp);
- */
- }
-
- cleanStrTbl();
- argv++;
-
- }
-
- if (cfp != stdout) fclose(cfp);
-
-}
-
diff --git a/libversit/vobject.c b/libversit/vobject.c
deleted file mode 100644
index 74ac4fadfb..0000000000
--- a/libversit/vobject.c
+++ /dev/null
@@ -1,1428 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
- * src: vobject.c
- * doc: vobject and APIs to construct vobject, APIs pretty print
- * vobject, and convert a vobject into its textual representation.
- */
-
-#ifndef MWERKS
-#include <malloc.h>
-#endif
-
-#include "vobject.h"
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-
-#define NAME_OF(o) o->id
-#define VALUE_TYPE(o) o->valType
-#define STRINGZ_VALUE_OF(o) o->val.strs
-#define USTRINGZ_VALUE_OF(o) o->val.ustrs
-#define INTEGER_VALUE_OF(o) o->val.i
-#define LONG_VALUE_OF(o) o->val.l
-#define ANY_VALUE_OF(o) o->val.any
-#define VOBJECT_VALUE_OF(o) o->val.vobj
-
-typedef union ValueItem {
- const char *strs;
- const wchar_t *ustrs;
- unsigned int i;
- unsigned long l;
- void *any;
- VObject *vobj;
- } ValueItem;
-
-struct VObject {
- VObject *next;
- const char *id;
- VObject *prop;
- unsigned short valType;
- ValueItem val;
- };
-
-typedef struct StrItem StrItem;
-
-struct StrItem {
- StrItem *next;
- const char *s;
- unsigned int refCnt;
- };
-
-const char** fieldedProp;
-
-
-
-/*----------------------------------------------------------------------
- The following functions involve with memory allocation:
- newVObject
- deleteVObject
- dupStr
- deleteStr
- newStrItem
- deleteStrItem
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(VObject*) newVObject_(const char *id)
-{
- VObject *p = (VObject*)malloc(sizeof(VObject));
- p->next = 0;
- p->id = id;
- p->prop = 0;
- VALUE_TYPE(p) = 0;
- ANY_VALUE_OF(p) = 0;
- return p;
-}
-
-DLLEXPORT(VObject*) newVObject(const char *id)
-{
- return newVObject_(lookupStr(id));
-}
-
-DLLEXPORT(void) deleteVObject(VObject *p)
-{
- unUseStr(p->id);
- free(p);
-}
-
-DLLEXPORT(char*) dupStr(const char *s, unsigned int size)
-{
- char *t;
- if (size == 0) {
- size = strlen(s);
- }
- t = (char*)malloc(size+1);
- if (t) {
- memcpy(t,s,size);
- t[size] = 0;
- return t;
- }
- else {
- return (char*)0;
- }
-}
-
-DLLEXPORT(void) deleteStr(const char *p)
-{
- if (p) free((void*)p);
-}
-
-
-static StrItem* newStrItem(const char *s, StrItem *next)
-{
- StrItem *p = (StrItem*)malloc(sizeof(StrItem));
- p->next = next;
- p->s = s;
- p->refCnt = 1;
- return p;
-}
-
-static void deleteStrItem(StrItem *p)
-{
- free((void*)p);
-}
-
-
-/*----------------------------------------------------------------------
- The following function provide accesses to VObject's value.
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(const char*) vObjectName(VObject *o)
-{
- return NAME_OF(o);
-}
-
-DLLEXPORT(void) setVObjectName(VObject *o, const char* id)
-{
- NAME_OF(o) = id;
-}
-
-DLLEXPORT(const char*) vObjectStringZValue(VObject *o)
-{
- return STRINGZ_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s)
-{
- STRINGZ_VALUE_OF(o) = dupStr(s,0);
- VALUE_TYPE(o) = VCVT_STRINGZ;
-}
-
-DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s)
-{
- STRINGZ_VALUE_OF(o) = s;
- VALUE_TYPE(o) = VCVT_STRINGZ;
-}
-
-DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o)
-{
- return USTRINGZ_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s)
-{
- USTRINGZ_VALUE_OF(o) = (wchar_t*) dupStr((char*)s,(uStrLen(s)+1)*2);
- VALUE_TYPE(o) = VCVT_USTRINGZ;
-}
-
-DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s)
-{
- USTRINGZ_VALUE_OF(o) = s;
- VALUE_TYPE(o) = VCVT_USTRINGZ;
-}
-
-DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o)
-{
- return INTEGER_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i)
-{
- INTEGER_VALUE_OF(o) = i;
- VALUE_TYPE(o) = VCVT_UINT;
-}
-
-DLLEXPORT(unsigned long) vObjectLongValue(VObject *o)
-{
- return LONG_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l)
-{
- LONG_VALUE_OF(o) = l;
- VALUE_TYPE(o) = VCVT_ULONG;
-}
-
-DLLEXPORT(void*) vObjectAnyValue(VObject *o)
-{
- return ANY_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t)
-{
- ANY_VALUE_OF(o) = t;
- VALUE_TYPE(o) = VCVT_RAW;
-}
-
-DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o)
-{
- return VOBJECT_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p)
-{
- VOBJECT_VALUE_OF(o) = p;
- VALUE_TYPE(o) = VCVT_VOBJECT;
-}
-
-DLLEXPORT(int) vObjectValueType(VObject *o)
-{
- return VALUE_TYPE(o);
-}
-
-
-/*----------------------------------------------------------------------
- The following functions can be used to build VObject.
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p)
-{
- /* circular link list pointed to tail */
- /*
- o {next,id,prop,val}
- V
- pn {next,id,prop,val}
- V
- ...
- p1 {next,id,prop,val}
- V
- pn
- -->
- o {next,id,prop,val}
- V
- pn {next,id,prop,val}
- V
- p {next,id,prop,val}
- ...
- p1 {next,id,prop,val}
- V
- pn
- */
-
- VObject *tail = o->prop;
- if (tail) {
- p->next = tail->next;
- o->prop = tail->next = p;
- }
- else {
- o->prop = p->next = p;
- }
- return p;
-}
-
-DLLEXPORT(VObject*) addProp(VObject *o, const char *id)
-{
- return addVObjectProp(o,newVObject(id));
-}
-
-DLLEXPORT(VObject*) addProp_(VObject *o, const char *id)
-{
- return addVObjectProp(o,newVObject_(id));
-}
-
-DLLEXPORT(void) addList(VObject **o, VObject *p)
-{
- p->next = 0;
- if (*o == 0) {
- *o = p;
- }
- else {
- VObject *t = *o;
- while (t->next) {
- t = t->next;
- }
- t->next = p;
- }
-}
-
-DLLEXPORT(VObject*) nextVObjectInList(VObject *o)
-{
- return o->next;
-}
-
-DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size)
-{
- VObject *sizeProp;
- setVObjectAnyValue(prop, val);
- sizeProp = addProp(prop,VCDataSizeProp);
- setVObjectLongValue(sizeProp, size);
- return prop;
-}
-
-DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size)
-{
- void *p = dupStr((const char *)val,size);
- return setValueWithSize_(prop,p,p?size:0);
-}
-
-DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o)
-{
- i->start = o->prop;
- i->next = 0;
-}
-
-DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o)
-{
- i->start = o->next;
- i->next = 0;
-}
-
-DLLEXPORT(int) moreIteration(VObjectIterator *i)
-{
- return (i->start && (i->next==0 || i->next!=i->start));
-}
-
-DLLEXPORT(VObject*) nextVObject(VObjectIterator *i)
-{
- if (i->start && i->next != i->start) {
- if (i->next == 0) {
- i->next = i->start->next;
- return i->next;
- }
- else {
- i->next = i->next->next;
- return i->next;
- }
- }
- else return (VObject*)0;
-}
-
-DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id)
-{
- VObjectIterator i;
- initPropIterator(&i,o);
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- if (!stricmp(id,each->id))
- return each;
- }
- return (VObject*)0;
-}
-
-DLLEXPORT(VObject*) addGroup(VObject *o, const char *g)
-{
- /*
- a.b.c
- -->
- prop(c)
- prop(VCGrouping=b)
- prop(VCGrouping=a)
- */
- char *dot = strrchr(g,'.');
- if (dot) {
- VObject *p, *t;
- char *gs, *n = dot+1;
- gs = dupStr(g,0); /* so we can write to it. */
- /* used to be
- * t = p = addProp_(o,lookupProp_(n));
- */
- t = p = addProp_(o,lookupProp(n));
- dot = strrchr(gs,'.');
- *dot = 0;
- do {
- dot = strrchr(gs,'.');
- if (dot) {
- n = dot+1;
- *dot=0;
- }
- else
- n = gs;
- /* property(VCGroupingProp=n);
- * and the value may have VCGrouping property
- */
- t = addProp(t,VCGroupingProp);
- setVObjectStringZValue(t,lookupProp_(n));
- } while (n != gs);
- deleteStr(gs);
- return p;
- }
- else
- return addProp_(o,lookupProp(g));
-}
-
-DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v)
-{
- VObject *prop;
- prop = addProp(o,p);
- setVObjectUStringZValue_(prop, fakeUnicode(v,0));
- return prop;
-}
-
-DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v,
- unsigned int size)
-{
- VObject *prop;
- prop = addProp(o,p);
- setValueWithSize_(prop, (void*)v, size);
- return prop;
-}
-
-DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v,
- unsigned int size)
-{
- return addPropSizedValue_(o,p,dupStr(v,size),size);
-}
-
-
-
-/*----------------------------------------------------------------------
- The following pretty print a VObject
- ----------------------------------------------------------------------*/
-
-static void printVObject_(FILE *fp, VObject *o, int level);
-
-static void indent(FILE *fp, int level)
-{
- int i;
- for (i=0;i<level*4;i++) {
- fputc(' ', fp);
- }
-}
-
-static void printValue(FILE *fp, VObject *o, int level)
-{
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ: {
- char c;
- char *t,*s;
- s = t = fakeCString(USTRINGZ_VALUE_OF(o));
- fputc('"',fp);
- while (c=*t,c) {
- fputc(c,fp);
- if (c == '\n') indent(fp,level+2);
- t++;
- }
- fputc('"',fp);
- deleteStr(s);
- break;
- }
- case VCVT_STRINGZ: {
- char c;
- const char *s = STRINGZ_VALUE_OF(o);
- fputc('"',fp);
- while (c=*s,c) {
- fputc(c,fp);
- if (c == '\n') indent(fp,level+2);
- s++;
- }
- fputc('"',fp);
- break;
- }
- case VCVT_UINT:
- fprintf(fp,"%d", INTEGER_VALUE_OF(o)); break;
- case VCVT_ULONG:
- fprintf(fp,"%ld", LONG_VALUE_OF(o)); break;
- case VCVT_RAW:
- fprintf(fp,"[raw data]"); break;
- case VCVT_VOBJECT:
- fprintf(fp,"[vobject]\n");
- printVObject_(fp,VOBJECT_VALUE_OF(o),level+1);
- break;
- case 0:
- fprintf(fp,"[none]"); break;
- default:
- fprintf(fp,"[unknown]"); break;
- }
-}
-
-static void printNameValue(FILE *fp,VObject *o, int level)
-{
- indent(fp,level);
- if (NAME_OF(o)) {
- fprintf(fp,"%s", NAME_OF(o));
- }
- if (VALUE_TYPE(o)) {
- fputc('=',fp);
- printValue(fp,o, level);
- }
- fprintf(fp,"\n");
-}
-
-static void printVObject_(FILE *fp, VObject *o, int level)
- {
- VObjectIterator t;
- if (o == 0) {
- fprintf(fp,"[NULL]\n");
- return;
- }
- printNameValue(fp,o,level);
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- printVObject_(fp,eachProp,level+1);
- }
- }
-
-void printVObject(FILE *fp,VObject *o)
-{
- printVObject_(fp,o,0);
-}
-
-DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- printVObject(fp,o);
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- while (list) {
- printVObject(fp,list);
- list = nextVObjectInList(list);
- }
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) cleanVObject(VObject *o)
-{
- if (o == 0) return;
- if (o->prop) {
- /* destroy time: cannot use the iterator here.
- Have to break the cycle in the circular link
- list and turns it into regular NULL-terminated
- list -- since at some point of destruction,
- the reference entry for the iterator to work
- will not longer be valid.
- */
- VObject *p;
- p = o->prop->next;
- o->prop->next = 0;
- do {
- VObject *t = p->next;
- cleanVObject(p);
- p = t;
- } while (p);
- }
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ:
- case VCVT_STRINGZ:
- case VCVT_RAW:
- // assume they are all allocated by malloc.
- free((char*)STRINGZ_VALUE_OF(o));
- break;
- case VCVT_VOBJECT:
- cleanVObject(VOBJECT_VALUE_OF(o));
- break;
- }
- deleteVObject(o);
-}
-
-DLLEXPORT(void) cleanVObjects(VObject *list)
-{
- while (list) {
- VObject *t = list;
- list = nextVObjectInList(list);
- cleanVObject(t);
- }
-}
-
-/*----------------------------------------------------------------------
- The following is a String Table Facilities.
- ----------------------------------------------------------------------*/
-
-#define STRTBLSIZE 255
-
-static StrItem *strTbl[STRTBLSIZE];
-
-static unsigned int hashStr(const char *s)
-{
- unsigned int h = 0;
- int i;
- for (i=0;s[i];i++) {
- h += s[i]*i;
- }
- return h % STRTBLSIZE;
-}
-
-DLLEXPORT(const char*) lookupStr(const char *s)
-{
- StrItem *t;
- unsigned int h = hashStr(s);
- if ((t = strTbl[h]) != 0) {
- do {
- if (stricmp(t->s,s) == 0) {
- t->refCnt++;
- return t->s;
- }
- t = t->next;
- } while (t);
- }
- s = dupStr(s,0);
- strTbl[h] = newStrItem(s,strTbl[h]);
- return s;
-}
-
-DLLEXPORT(void) unUseStr(const char *s)
-{
- StrItem *t, *p;
- unsigned int h = hashStr(s);
- if ((t = strTbl[h]) != 0) {
- p = t;
- do {
- if (stricmp(t->s,s) == 0) {
- t->refCnt--;
- if (t->refCnt == 0) {
- if (p == strTbl[h]) {
- strTbl[h] = t->next;
- }
- else {
- p->next = t->next;
- }
- deleteStr(t->s);
- deleteStrItem(t);
- return;
- }
- }
- p = t;
- t = t->next;
- } while (t);
- }
-}
-
-DLLEXPORT(void) cleanStrTbl()
-{
- int i;
- for (i=0; i<STRTBLSIZE;i++) {
- StrItem *t = strTbl[i];
- while (t) {
- StrItem *p;
- deleteStr(t->s);
- p = t;
- t = t->next;
- deleteStrItem(p);
- } while (t);
- strTbl[i] = 0;
- }
-}
-
-
-struct PreDefProp {
- const char *name;
- const char *alias;
- const char** fields;
- unsigned int flags;
- };
-
-/* flags in PreDefProp */
-#define PD_BEGIN 0x1
-#define PD_INTERNAL 0x2
-
-static const char *adrFields[] = {
- VCPostalBoxProp,
- VCExtAddressProp,
- VCStreetAddressProp,
- VCCityProp,
- VCRegionProp,
- VCPostalCodeProp,
- VCCountryNameProp,
- 0
-};
-
-static const char *nameFields[] = {
- VCFamilyNameProp,
- VCGivenNameProp,
- VCAdditionalNamesProp,
- VCNamePrefixesProp,
- VCNameSuffixesProp,
- NULL
- };
-
-static const char *orgFields[] = {
- VCOrgNameProp,
- VCOrgUnitProp,
- VCOrgUnit2Prop,
- VCOrgUnit3Prop,
- VCOrgUnit4Prop,
- NULL
- };
-
-static const char *AAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCAudioContentProp,
- 0
- };
-
-/* ExDate -- has unamed fields */
-/* RDate -- has unamed fields */
-
-static const char *DAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCDisplayStringProp,
- 0
- };
-
-static const char *MAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCEmailAddressProp,
- VCNoteProp,
- 0
- };
-
-static const char *PAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCProcedureNameProp,
- 0
- };
-
-static struct PreDefProp propNames[] = {
- { VC7bitProp, 0, 0, 0 },
- { VC8bitProp, 0, 0, 0 },
- { VCAAlarmProp, 0, AAlarmFields, 0 },
- { VCAdditionalNamesProp, 0, 0, 0 },
- { VCAdrProp, 0, adrFields, 0 },
- { VCAgentProp, 0, 0, 0 },
- { VCAIFFProp, 0, 0, 0 },
- { VCAOLProp, 0, 0, 0 },
- { VCAppleLinkProp, 0, 0, 0 },
- { VCAttachProp, 0, 0, 0 },
- { VCAttendeeProp, 0, 0, 0 },
- { VCATTMailProp, 0, 0, 0 },
- { VCAudioContentProp, 0, 0, 0 },
- { VCAVIProp, 0, 0, 0 },
- { VCBase64Prop, 0, 0, 0 },
- { VCBBSProp, 0, 0, 0 },
- { VCBirthDateProp, 0, 0, 0 },
- { VCBMPProp, 0, 0, 0 },
- { VCBodyProp, 0, 0, 0 },
- { VCBusinessRoleProp, 0, 0, 0 },
- { VCCalProp, 0, 0, PD_BEGIN },
- { VCCaptionProp, 0, 0, 0 },
- { VCCardProp, 0, 0, PD_BEGIN },
- { VCCarProp, 0, 0, 0 },
- { VCCategoriesProp, 0, 0, 0 },
- { VCCellularProp, 0, 0, 0 },
- { VCCGMProp, 0, 0, 0 },
- { VCCharSetProp, 0, 0, 0 },
- { VCCIDProp, VCContentIDProp, 0, 0 },
- { VCCISProp, 0, 0, 0 },
- { VCCityProp, 0, 0, 0 },
- { VCClassProp, 0, 0, 0 },
- { VCCommentProp, 0, 0, 0 },
- { VCCompletedProp, 0, 0, 0 },
- { VCContentIDProp, 0, 0, 0 },
- { VCCountryNameProp, 0, 0, 0 },
- { VCDAlarmProp, 0, DAlarmFields, 0 },
- { VCDataSizeProp, 0, 0, PD_INTERNAL },
- { VCDayLightProp, 0, 0, 0 },
- { VCDCreatedProp, 0, 0, 0 },
- { VCDeliveryLabelProp, 0, 0, 0 },
- { VCDescriptionProp, 0, 0, 0 },
- { VCDIBProp, 0, 0, 0 },
- { VCDisplayStringProp, 0, 0, 0 },
- { VCDomesticProp, 0, 0, 0 },
- { VCDTendProp, 0, 0, 0 },
- { VCDTstartProp, 0, 0, 0 },
- { VCDueProp, 0, 0, 0 },
- { VCEmailAddressProp, 0, 0, 0 },
- { VCEncodingProp, 0, 0, 0 },
- { VCEndProp, 0, 0, 0 },
- { VCEventProp, 0, 0, PD_BEGIN },
- { VCEWorldProp, 0, 0, 0 },
- { VCExNumProp, 0, 0, 0 },
- { VCExpDateProp, 0, 0, 0 },
- { VCExpectProp, 0, 0, 0 },
- { VCExtAddressProp, 0, 0, 0 },
- { VCFamilyNameProp, 0, 0, 0 },
- { VCFaxProp, 0, 0, 0 },
- { VCFullNameProp, 0, 0, 0 },
- { VCGeoLocationProp, 0, 0, 0 },
- { VCGeoProp, 0, 0, 0 },
- { VCGIFProp, 0, 0, 0 },
- { VCGivenNameProp, 0, 0, 0 },
- { VCGroupingProp, 0, 0, 0 },
- { VCHomeProp, 0, 0, 0 },
- { VCIBMMailProp, 0, 0, 0 },
- { VCInlineProp, 0, 0, 0 },
- { VCInternationalProp, 0, 0, 0 },
- { VCInternetProp, 0, 0, 0 },
- { VCISDNProp, 0, 0, 0 },
- { VCJPEGProp, 0, 0, 0 },
- { VCLanguageProp, 0, 0, 0 },
- { VCLastModifiedProp, 0, 0, 0 },
- { VCLastRevisedProp, 0, 0, 0 },
- { VCLocationProp, 0, 0, 0 },
- { VCLogoProp, 0, 0, 0 },
- { VCMailerProp, 0, 0, 0 },
- { VCMAlarmProp, 0, MAlarmFields, 0 },
- { VCMCIMailProp, 0, 0, 0 },
- { VCMessageProp, 0, 0, 0 },
- { VCMETProp, 0, 0, 0 },
- { VCModemProp, 0, 0, 0 },
- { VCMPEG2Prop, 0, 0, 0 },
- { VCMPEGProp, 0, 0, 0 },
- { VCMSNProp, 0, 0, 0 },
- { VCNamePrefixesProp, 0, 0, 0 },
- { VCNameProp, 0, nameFields, 0 },
- { VCNameSuffixesProp, 0, 0, 0 },
- { VCNoteProp, 0, 0, 0 },
- { VCOrgNameProp, 0, 0, 0 },
- { VCOrgProp, 0, orgFields, 0 },
- { VCOrgUnit2Prop, 0, 0, 0 },
- { VCOrgUnit3Prop, 0, 0, 0 },
- { VCOrgUnit4Prop, 0, 0, 0 },
- { VCOrgUnitProp, 0, 0, 0 },
- { VCPagerProp, 0, 0, 0 },
- { VCPAlarmProp, 0, PAlarmFields, 0 },
- { VCParcelProp, 0, 0, 0 },
- { VCPartProp, 0, 0, 0 },
- { VCPCMProp, 0, 0, 0 },
- { VCPDFProp, 0, 0, 0 },
- { VCPGPProp, 0, 0, 0 },
- { VCPhotoProp, 0, 0, 0 },
- { VCPICTProp, 0, 0, 0 },
- { VCPMBProp, 0, 0, 0 },
- { VCPostalBoxProp, 0, 0, 0 },
- { VCPostalCodeProp, 0, 0, 0 },
- { VCPostalProp, 0, 0, 0 },
- { VCPowerShareProp, 0, 0, 0 },
- { VCPreferredProp, 0, 0, 0 },
- { VCPriorityProp, 0, 0, 0 },
- { VCProcedureNameProp, 0, 0, 0 },
- { VCProdIdProp, 0, 0, 0 },
- { VCProdigyProp, 0, 0, 0 },
- { VCPronunciationProp, 0, 0, 0 },
- { VCPSProp, 0, 0, 0 },
- { VCPublicKeyProp, 0, 0, 0 },
- { VCQPProp, VCQuotedPrintableProp, 0, 0 },
- { VCQuickTimeProp, 0, 0, 0 },
- { VCQuotedPrintableProp, 0, 0, 0 },
- { VCRDateProp, 0, 0, 0 },
- { VCRegionProp, 0, 0, 0 },
- { VCRelatedToProp, 0, 0, 0 },
- { VCRepeatCountProp, 0, 0, 0 },
- { VCResourcesProp, 0, 0, 0 },
- { VCRNumProp, 0, 0, 0 },
- { VCRoleProp, 0, 0, 0 },
- { VCRRuleProp, 0, 0, 0 },
- { VCRSVPProp, 0, 0, 0 },
- { VCRunTimeProp, 0, 0, 0 },
- { VCSequenceProp, 0, 0, 0 },
- { VCSnoozeTimeProp, 0, 0, 0 },
- { VCStartProp, 0, 0, 0 },
- { VCStatusProp, 0, 0, 0 },
- { VCStreetAddressProp, 0, 0, 0 },
- { VCSubTypeProp, 0, 0, 0 },
- { VCSummaryProp, 0, 0, 0 },
- { VCTelephoneProp, 0, 0, 0 },
- { VCTIFFProp, 0, 0, 0 },
- { VCTimeZoneProp, 0, 0, 0 },
- { VCTitleProp, 0, 0, 0 },
- { VCTLXProp, 0, 0, 0 },
- { VCTodoProp, 0, 0, PD_BEGIN },
- { VCTranspProp, 0, 0, 0 },
- { VCUniqueStringProp, 0, 0, 0 },
- { VCURLProp, 0, 0, 0 },
- { VCURLValueProp, 0, 0, 0 },
- { VCValueProp, 0, 0, 0 },
- { VCVersionProp, 0, 0, 0 },
- { VCVideoProp, 0, 0, 0 },
- { VCVoiceProp, 0, 0, 0 },
- { VCWAVEProp, 0, 0, 0 },
- { VCWMFProp, 0, 0, 0 },
- { VCWorkProp, 0, 0, 0 },
- { VCX400Prop, 0, 0, 0 },
- { VCX509Prop, 0, 0, 0 },
- { VCXRuleProp, 0, 0, 0 },
- { 0,0,0,0 }
- };
-
-
-static struct PreDefProp* lookupPropInfo(const char* str)
-{
- /* brute force for now, could use a hash table here. */
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- return &propNames[i];
- }
-
- return 0;
-}
-
-
-DLLEXPORT(const char*) lookupProp_(const char* str)
-{
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- const char* s;
- s = propNames[i].alias?propNames[i].alias:propNames[i].name;
- return lookupStr(s);
- }
- return lookupStr(str);
-}
-
-
-DLLEXPORT(const char*) lookupProp(const char* str)
-{
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- const char *s;
- fieldedProp = propNames[i].fields;
- s = propNames[i].alias?propNames[i].alias:propNames[i].name;
- return lookupStr(s);
- }
- fieldedProp = 0;
- return lookupStr(str);
-}
-
-
-/*----------------------------------------------------------------------
- APIs to Output text form.
- ----------------------------------------------------------------------*/
-#define OFILE_REALLOC_SIZE 256
-typedef struct OFile {
- FILE *fp;
- char *s;
- int len;
- int limit;
- int alloc:1;
- int fail:1;
- } OFile;
-
-#if 0
-static void appendsOFile(OFile *fp, const char *s)
-{
- int slen;
- if (fp->fail) return;
- slen = strlen(s);
- if (fp->fp) {
- fwrite(s,1,slen,fp->fp);
- }
- else {
-stuff:
- if (fp->len + slen < fp->limit) {
- memcpy(fp->s+fp->len,s,slen);
- fp->len += slen;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen;
- fp->s = (char *) realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-
-static void appendcOFile(OFile *fp, char c)
-{
- if (fp->fail) return;
- if (fp->fp) {
- fputc(c,fp->fp);
- }
- else {
-stuff:
- if (fp->len+1 < fp->limit) {
- fp->s[fp->len] = c;
- fp->len++;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- fp->s = (char *) realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-#else
-static void appendcOFile_(OFile *fp, char c)
-{
- if (fp->fail) return;
- if (fp->fp) {
- fputc(c,fp->fp);
- }
- else {
-stuff:
- if (fp->len+1 < fp->limit) {
- fp->s[fp->len] = c;
- fp->len++;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- fp->s = realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-
-static void appendcOFile(OFile *fp, char c)
-{
- if (c == '\n') {
- /* write out as <CR><LF> */
- appendcOFile_(fp,0xd);
- appendcOFile_(fp,0xa);
- }
- else
- appendcOFile_(fp,c);
-}
-
-static void appendsOFile(OFile *fp, const char *s)
-{
- int i, slen;
- slen = strlen(s);
- for (i=0; i<slen; i++) {
- appendcOFile(fp,s[i]);
- }
-}
-
-#endif
-
-static void initOFile(OFile *fp, FILE *ofp)
-{
- fp->fp = ofp;
- fp->s = 0;
- fp->len = 0;
- fp->limit = 0;
- fp->alloc = 0;
- fp->fail = 0;
-}
-
-static void initMemOFile(OFile *fp, char *s, int len)
-{
- fp->fp = 0;
- fp->s = s;
- fp->len = 0;
- fp->limit = s?len:0;
- fp->alloc = s?0:1;
- fp->fail = 0;
-}
-
-
-static int writeBase64(OFile *fp, unsigned char *s, long len)
-{
- long cur = 0;
- int i, numQuads = 0;
- unsigned long trip;
- unsigned char b;
- char quad[5];
-#define MAXQUADS 16
-
- quad[4] = 0;
-
- while (cur < len) {
- // collect the triplet of bytes into 'trip'
- trip = 0;
- for (i = 0; i < 3; i++) {
- b = (cur < len) ? *(s + cur) : 0;
- cur++;
- trip = trip << 8 | b;
- }
- // fill in 'quad' with the appropriate four characters
- for (i = 3; i >= 0; i--) {
- b = (unsigned char)(trip & 0x3F);
- trip = trip >> 6;
- if ((3 - i) < (cur - len))
- quad[i] = '='; // pad char
- else if (b < 26) quad[i] = (char)b + 'A';
- else if (b < 52) quad[i] = (char)(b - 26) + 'a';
- else if (b < 62) quad[i] = (char)(b - 52) + '0';
- else if (b == 62) quad[i] = '+';
- else quad[i] = '/';
- }
- // now output 'quad' with appropriate whitespace and line ending
- appendsOFile(fp, (numQuads == 0 ? " " : ""));
- appendsOFile(fp, quad);
- appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : "")));
- numQuads = (numQuads + 1) % MAXQUADS;
- }
- appendcOFile(fp,'\n');
-
- return 1;
-}
-
-static void writeQPString(OFile *fp, const char *s)
-{
- const char *p = s;
- while (*p) {
- if (*p == '\n') {
- if (p[1]) appendsOFile(fp,"=0A=");
- }
- appendcOFile(fp,*p);
- p++;
- }
-}
-
-
-
-static void writeVObject_(OFile *fp, VObject *o);
-
-static void writeValue(OFile *fp, VObject *o, unsigned long size)
-{
- if (o == 0) return;
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ: {
- char *s = fakeCString(USTRINGZ_VALUE_OF(o));
- writeQPString(fp, s);
- deleteStr(s);
- break;
- }
- case VCVT_STRINGZ: {
- writeQPString(fp, STRINGZ_VALUE_OF(o));
- break;
- }
- case VCVT_UINT: {
- char buf[16];
- sprintf(buf,"%u", INTEGER_VALUE_OF(o));
- appendsOFile(fp,buf);
- break;
- }
- case VCVT_ULONG: {
- char buf[16];
- sprintf(buf,"%lu", LONG_VALUE_OF(o));
- appendsOFile(fp,buf);
- break;
- }
- case VCVT_RAW: {
- appendcOFile(fp,'\n');
- writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size);
- break;
- }
- case VCVT_VOBJECT:
- appendcOFile(fp,'\n');
- writeVObject_(fp,VOBJECT_VALUE_OF(o));
- break;
- }
-}
-
-static void writeAttrValue(OFile *fp, VObject *o)
-{
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- pi = lookupPropInfo(NAME_OF(o));
- if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
- appendcOFile(fp,';');
- appendsOFile(fp,NAME_OF(o));
- }
- else
- appendcOFile(fp,';');
- if (VALUE_TYPE(o)) {
- appendcOFile(fp,'=');
- writeValue(fp,o,0);
- }
-}
-
-static void writeGroup(OFile *fp, VObject *o)
-{
- char buf1[256];
- char buf2[256];
- strcpy(buf1,NAME_OF(o));
- while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
- strcpy(buf2,STRINGZ_VALUE_OF(o));
- strcat(buf2,".");
- strcat(buf2,buf1);
- strcpy(buf1,buf2);
- }
- appendsOFile(fp,buf1);
-}
-
-static int inList(const char **list, const char *s)
-{
- if (list == 0) return 0;
- while (*list) {
- if (stricmp(*list,s) == 0) return 1;
- list++;
- }
- return 0;
-}
-
-static void writeProp(OFile *fp, VObject *o)
-{
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- VObjectIterator t;
- const char **fields_ = 0;
- pi = lookupPropInfo(NAME_OF(o));
- if (pi && ((pi->flags & PD_BEGIN) != 0)) {
- writeVObject_(fp,o);
- return;
- }
- if (isAPropertyOf(o,VCGroupingProp))
- writeGroup(fp,o);
- else
- appendsOFile(fp,NAME_OF(o));
- if (pi) fields_ = pi->fields;
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- const char *s;
- VObject *eachProp = nextVObject(&t);
- s = NAME_OF(eachProp);
- if (stricmp(VCGroupingProp,s) && !inList(fields_,s))
- writeAttrValue(fp,eachProp);
- }
- if (fields_) {
- int i = 0, n = 0;
- const char** fields = fields_;
- /* output prop as fields */
- appendcOFile(fp,':');
- while (*fields) {
- VObject *t = isAPropertyOf(o,*fields);
- i++;
- if (t) n = i;
- fields++;
- }
- fields = fields_;
- for (i=0;i<n;i++) {
- writeValue(fp,isAPropertyOf(o,*fields),0);
- fields++;
- if (i<(n-1)) appendcOFile(fp,';');
- }
- }
- }
-
- if (VALUE_TYPE(o)) {
- unsigned long size = 0;
- VObject *p = isAPropertyOf(o,VCDataSizeProp);
- if (p) size = LONG_VALUE_OF(p);
- appendcOFile(fp,':');
- writeValue(fp,o,size);
- }
-
- appendcOFile(fp,'\n');
-}
-
-static void writeVObject_(OFile *fp, VObject *o)
-{
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- pi = lookupPropInfo(NAME_OF(o));
-
- if (pi && ((pi->flags & PD_BEGIN) != 0)) {
- VObjectIterator t;
- const char *begin = NAME_OF(o);
- appendsOFile(fp,"BEGIN:");
- appendsOFile(fp,begin);
- appendcOFile(fp,'\n');
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- writeProp(fp, eachProp);
- }
- appendsOFile(fp,"END:");
- appendsOFile(fp,begin);
- appendsOFile(fp,"\n\n");
- }
- }
-}
-
-void writeVObject(FILE *fp, VObject *o)
-{
- OFile ofp;
- initOFile(&ofp,fp);
- writeVObject_(&ofp,o);
-}
-
-DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- writeVObject(fp,o);
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- while (list) {
- writeVObject(fp,list);
- list = nextVObjectInList(list);
- }
- fclose(fp);
- }
-}
-
-DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o)
-{
- OFile ofp;
- initMemOFile(&ofp,s,len?*len:0);
- writeVObject_(&ofp,o);
- if (len) *len = ofp.len;
- appendcOFile(&ofp,0);
- return ofp.s;
-}
-
-DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list)
-{
- OFile ofp;
- initMemOFile(&ofp,s,len?*len:0);
- while (list) {
- writeVObject_(&ofp,list);
- list = nextVObjectInList(list);
- }
- if (len) *len = ofp.len;
- appendcOFile(&ofp,0);
- return ofp.s;
-}
-
-/*----------------------------------------------------------------------
- APIs to do fake Unicode stuff.
- ----------------------------------------------------------------------*/
-DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes)
-{
- wchar_t *r, *pw;
- int len = strlen(ps)+1;
-
- pw = r = (wchar_t*)malloc(sizeof(wchar_t)*len);
- if (bytes)
- *bytes = len * sizeof(wchar_t);
-
- while (*ps) {
- if (*ps == '\n')
- *pw = (wchar_t)0x2028;
- else if (*ps == '\r')
- *pw = (wchar_t)0x2029;
- else
- *pw = (wchar_t)(unsigned char)*ps;
- ps++; pw++;
- }
- *pw = (wchar_t)0;
-
- return r;
-}
-
-DLLEXPORT(int) uStrLen(const wchar_t *u)
-{
- int i = 0;
- while (*u != (wchar_t)0) { u++; i++; }
- return i;
-}
-
-DLLEXPORT(char*) fakeCString(const wchar_t *u)
-{
- char *s, *t;
- int len = uStrLen(u) + 1;
- t = s = (char*)malloc(len);
- while (*u) {
- if (*u == (wchar_t)0x2028)
- *t = '\n';
- else if (*u == (wchar_t)0x2029)
- *t = '\r';
- else
- *t = (char)*u;
- u++; t++;
- }
- *t = 0;
- return s;
-}
-
-// end of source file vobject.c
diff --git a/libversit/vobject.h b/libversit/vobject.h
deleted file mode 100644
index d5f1fa291f..0000000000
--- a/libversit/vobject.h
+++ /dev/null
@@ -1,362 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
-
-The vCard/vCalendar C interface is implemented in the set
-of files as follows:
-
-vcc.y, yacc source, and vcc.c, the yacc output you will use
-implements the core parser
-
-vobject.c implements an API that insulates the caller from
-the parser and changes in the vCard/vCalendar BNF
-
-port.h defines compilation environment dependent stuff
-
-vcc.h and vobject.h are header files for their .c counterparts
-
-vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
-which you may find useful.
-
-test.c is a standalone test driver that exercises some of
-the features of the APIs provided. Invoke test.exe on a
-VCARD/VCALENDAR input text file and you will see the pretty
-print output of the internal representation (this pretty print
-output should give you a good idea of how the internal
-representation looks like -- there is one such output in the
-following too). Also, a file with the .out suffix is generated
-to show that the internal representation can be written back
-in the original text format.
-
-For more information on this API see the readme.txt file
-which accompanied this distribution.
-
- Also visit:
-
- http://www.versit.com
- http://www.ralden.com
-
-*/
-
-
-#ifndef __VOBJECT_H__
-#define __VOBJECT_H__ 1
-
-
-#include "port.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-
-#define VC7bitProp "7BIT"
-#define VC8bitProp "8BIT"
-#define VCAAlarmProp "AALARM"
-#define VCAdditionalNamesProp "ADDN"
-#define VCAdrProp "ADR"
-#define VCAgentProp "AGENT"
-#define VCAIFFProp "AIFF"
-#define VCAOLProp "AOL"
-#define VCAppleLinkProp "APPLELINK"
-#define VCAttachProp "ATTACH"
-#define VCAttendeeProp "ATTENDEE"
-#define VCATTMailProp "ATTMAIL"
-#define VCAudioContentProp "AUDIOCONTENT"
-#define VCAVIProp "AVI"
-#define VCBase64Prop "BASE64"
-#define VCBBSProp "BBS"
-#define VCBirthDateProp "BDAY"
-#define VCBMPProp "BMP"
-#define VCBodyProp "BODY"
-#define VCBusinessRoleProp "ROLE"
-#define VCCalProp "VCALENDAR"
-#define VCCaptionProp "CAP"
-#define VCCardProp "VCARD"
-#define VCCarProp "CAR"
-#define VCCategoriesProp "CATEGORIES"
-#define VCCellularProp "CELL"
-#define VCCGMProp "CGM"
-#define VCCharSetProp "CS"
-#define VCCIDProp "CID"
-#define VCCISProp "CIS"
-#define VCCityProp "L"
-#define VCClassProp "CLASS"
-#define VCCommentProp "NOTE"
-#define VCCompletedProp "COMPLETED"
-#define VCContentIDProp "CONTENT-ID"
-#define VCCountryNameProp "C"
-#define VCDAlarmProp "DALARM"
-#define VCDataSizeProp "DATASIZE"
-#define VCDayLightProp "DAYLIGHT"
-#define VCDCreatedProp "DCREATED"
-#define VCDeliveryLabelProp "LABEL"
-#define VCDescriptionProp "DESCRIPTION"
-#define VCDIBProp "DIB"
-#define VCDisplayStringProp "DISPLAYSTRING"
-#define VCDomesticProp "DOM"
-#define VCDTendProp "DTEND"
-#define VCDTstartProp "DTSTART"
-#define VCDueProp "DUE"
-#define VCEmailAddressProp "EMAIL"
-#define VCEncodingProp "ENCODING"
-#define VCEndProp "END"
-#define VCEventProp "VEVENT"
-#define VCEWorldProp "EWORLD"
-#define VCExNumProp "EXNUM"
-#define VCExpDateProp "EXDATE"
-#define VCExpectProp "EXPECT"
-#define VCExtAddressProp "EXT ADD"
-#define VCFamilyNameProp "F"
-#define VCFaxProp "FAX"
-#define VCFullNameProp "FN"
-#define VCGeoProp "GEO"
-#define VCGeoLocationProp "GEO"
-#define VCGIFProp "GIF"
-#define VCGivenNameProp "G"
-#define VCGroupingProp "Grouping"
-#define VCHomeProp "HOME"
-#define VCIBMMailProp "IBMMail"
-#define VCInlineProp "INLINE"
-#define VCInternationalProp "INTL"
-#define VCInternetProp "INTERNET"
-#define VCISDNProp "ISDN"
-#define VCJPEGProp "JPEG"
-#define VCLanguageProp "LANG"
-#define VCLastModifiedProp "LAST-MODIFIED"
-#define VCLastRevisedProp "REV"
-#define VCLocationProp "LOCATION"
-#define VCLogoProp "LOGO"
-#define VCMailerProp "MAILER"
-#define VCMAlarmProp "MALARM"
-#define VCMCIMailProp "MCIMAIL"
-#define VCMessageProp "MSG"
-#define VCMETProp "MET"
-#define VCModemProp "MODEM"
-#define VCMPEG2Prop "MPEG2"
-#define VCMPEGProp "MPEG"
-#define VCMSNProp "MSN"
-#define VCNamePrefixesProp "NPRE"
-#define VCNameProp "N"
-#define VCNameSuffixesProp "NSUF"
-#define VCNoteProp "NOTE"
-#define VCOrgNameProp "ORGNAME"
-#define VCOrgProp "ORG"
-#define VCOrgUnit2Prop "OUN2"
-#define VCOrgUnit3Prop "OUN3"
-#define VCOrgUnit4Prop "OUN4"
-#define VCOrgUnitProp "OUN"
-#define VCPagerProp "PAGER"
-#define VCPAlarmProp "PALARM"
-#define VCParcelProp "PARCEL"
-#define VCPartProp "PART"
-#define VCPCMProp "PCM"
-#define VCPDFProp "PDF"
-#define VCPGPProp "PGP"
-#define VCPhotoProp "PHOTO"
-#define VCPICTProp "PICT"
-#define VCPMBProp "PMB"
-#define VCPostalBoxProp "BOX"
-#define VCPostalCodeProp "PC"
-#define VCPostalProp "POSTAL"
-#define VCPowerShareProp "POWERSHARE"
-#define VCPreferredProp "PREF"
-#define VCPriorityProp "PRIORITY"
-#define VCProcedureNameProp "PROCEDURENAME"
-#define VCProdIdProp "PRODID"
-#define VCProdigyProp "PRODIGY"
-#define VCPronunciationProp "SOUND"
-#define VCPSProp "PS"
-#define VCPublicKeyProp "KEY"
-#define VCQPProp "QP"
-#define VCQuickTimeProp "QTIME"
-#define VCQuotedPrintableProp "QUOTED-PRINTABLE"
-#define VCRDateProp "RDATE"
-#define VCRegionProp "R"
-#define VCRelatedToProp "RELATED-TO"
-#define VCRepeatCountProp "REPEATCOUNT"
-#define VCResourcesProp "RESOURCES"
-#define VCRNumProp "RNUM"
-#define VCRoleProp "ROLE"
-#define VCRRuleProp "RRULE"
-#define VCRSVPProp "RSVP"
-#define VCRunTimeProp "RUNTIME"
-#define VCSequenceProp "SEQUENCE"
-#define VCSnoozeTimeProp "SNOOZETIME"
-#define VCStartProp "START"
-#define VCStatusProp "STATUS"
-#define VCStreetAddressProp "STREET"
-#define VCSubTypeProp "SUBTYPE"
-#define VCSummaryProp "SUMMARY"
-#define VCTelephoneProp "TEL"
-#define VCTIFFProp "TIFF"
-#define VCTimeZoneProp "TZ"
-#define VCTitleProp "TITLE"
-#define VCTLXProp "TLX"
-#define VCTodoProp "VTODO"
-#define VCTranspProp "TRANSP"
-#define VCUniqueStringProp "UID"
-#define VCURLProp "URL"
-#define VCURLValueProp "URLVAL"
-#define VCValueProp "VALUE"
-#define VCVersionProp "VERSION"
-#define VCVideoProp "VIDEO"
-#define VCVoiceProp "VOICE"
-#define VCWAVEProp "WAVE"
-#define VCWMFProp "WMF"
-#define VCWorkProp "WORK"
-#define VCX400Prop "X400"
-#define VCX509Prop "X509"
-#define VCXRuleProp "XRULE"
-
-
-typedef struct VObject VObject;
-
-typedef struct VObjectIterator {
- VObject* start;
- VObject* next;
- } VObjectIterator;
-
-extern DLLEXPORT(VObject*) newVObject(const char *id);
-extern DLLEXPORT(void) deleteVObject(VObject *p);
-extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size);
-extern DLLEXPORT(void) deleteStr(const char *p);
-extern DLLEXPORT(void) unUseStr(const char *s);
-
-extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id);
-extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s);
-extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s);
-extern DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s);
-extern DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s);
-extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i);
-extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l);
-extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t);
-extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size);
-extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size);
-
-extern DLLEXPORT(const char*) vObjectName(VObject *o);
-extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o);
-extern DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o);
-extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o);
-extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o);
-extern DLLEXPORT(void*) vObjectAnyValue(VObject *o);
-extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o);
-extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p);
-
-extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p);
-extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id);
-extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id);
-extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v);
-extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
-extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
-extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g);
-extern DLLEXPORT(void) addList(VObject **o, VObject *p);
-
-extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id);
-
-extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o);
-extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o);
-extern DLLEXPORT(int) moreIteration(VObjectIterator *i);
-extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i);
-
-extern DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o);
-extern DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list);
-
-extern DLLEXPORT(const char*) lookupStr(const char *s);
-extern DLLEXPORT(void) cleanStrTbl();
-
-extern DLLEXPORT(void) cleanVObject(VObject *o);
-extern DLLEXPORT(void) cleanVObjects(VObject *list);
-
-extern DLLEXPORT(const char*) lookupProp(const char* str);
-extern DLLEXPORT(const char*) lookupProp_(const char* str);
-
-extern DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes);
-extern DLLEXPORT(int) uStrLen(const wchar_t *u);
-extern DLLEXPORT(char*) fakeCString(const wchar_t *u);
-
-extern DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o);
-extern DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list);
-extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o);
-extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list);
-
-extern DLLEXPORT(int) vObjectValueType(VObject *o);
-
-/* return type of vObjectValueType: */
-#define VCVT_NOVALUE 0
- /* if the VObject has no value associated with it. */
-#define VCVT_STRINGZ 1
- /* if the VObject has value set by setVObjectStringZValue. */
-#define VCVT_USTRINGZ 2
- /* if the VObject has value set by setVObjectUStringZValue. */
-#define VCVT_UINT 3
- /* if the VObject has value set by setVObjectIntegerValue. */
-#define VCVT_ULONG 4
- /* if the VObject has value set by setVObjectLongValue. */
-#define VCVT_RAW 5
- /* if the VObject has value set by setVObjectAnyValue. */
-#define VCVT_VOBJECT 6
- /* if the VObject has value set by setVObjectVObjectValue. */
-
-extern const char** fieldedProp;
-
-/* NOTE regarding printVObject and writeVObject
-
-The functions below are not exported from the DLL because they
-take a FILE* as a parameter, which cannot be passed across a DLL
-interface (at least that is my experience). Instead you can use
-their companion functions which take file names or pointers
-to memory. However, if you are linking this code into
-your build directly then you may find them a more convenient API
-and you can go ahead and use them. If you try to use them with
-the DLL LIB you will get a link error.
-*/
-extern void printVObject(FILE *fp,VObject *o);
-extern void writeVObject(FILE *fp, VObject *o);
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VOBJECT_H__ */
-
-