aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/.cvsignore8
-rw-r--r--calendar/AUTHORS3
-rw-r--r--calendar/ChangeLog902
-rw-r--r--calendar/Makefile.am83
-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.c1248
-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.c1248
-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.c422
-rw-r--r--calendar/gnome-cal.h70
-rw-r--r--calendar/gnome-cal.html42
-rw-r--r--calendar/gnome-month-item.c876
-rw-r--r--calendar/gnome-month-item.h123
-rw-r--r--calendar/goto.c339
-rw-r--r--calendar/goto.xpm68
-rw-r--r--calendar/gui/Makefile.am83
-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.c422
-rw-r--r--calendar/gui/gnome-cal.h70
-rw-r--r--calendar/gui/gnome-cal.html42
-rw-r--r--calendar/gui/gnome-month-item.c876
-rw-r--r--calendar/gui/gnome-month-item.h123
-rw-r--r--calendar/gui/goto.c339
-rw-r--r--calendar/gui/icalendar-types39
-rw-r--r--calendar/gui/main.c700
-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.c700
-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.c1248
-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.c336
-rw-r--r--calendar/timeutil.h50
-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
111 files changed, 0 insertions, 29575 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 81c9707025..0000000000
--- a/calendar/ChangeLog
+++ /dev/null
@@ -1,902 +0,0 @@
-1998-08-21 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_object_create_from_vobject): If mail alarm or
- program alarm are missing the action, then set an empty default.
-
-1998-08-18 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-month-item.c (gnome_month_item_day2index): New public
- function to get the displayed day index of the specified date.
-
- * gnome-cal.c (gnome_calendar_goto_today): New public function to
- jump to the current day.
-
- * goto.c (day_event): Jump to the selected day when the user
- clicks the mouse, and prelight days as appropriate.
-
- * timeutil.c (time_from_day): New public function to build a
- time_t from a year/month/day triplet.
-
- * gnome-month-item.c (gnome_month_item_num2child):
- (gnome_month_item_child2num): New public functions to convert an
- index into a child and vice-versa, respectively.
- (gnome_month_item_num2day): New public function to convert a child
- number into a displayed day number.
-
- * goto.c (goto_dialog): Doh, use gnome-dialog properly :-)
-
- * gnome-month-item.c (create_items): Use g_strdup()ed day names
- from the start.
-
-1998-08-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * main.c (gnome_toolbar): Made it use goto.xpm.
-
- * Makefile.am (EXTRA_DIST): Added goto.xpm to the list of files.
-
-1998-08-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-month-item.c (gnome_month_item_set_arg): Doh. Actually
- recalculate the days using the month and year.
-
- * main.c: Added "Go to" button to quickly jump to a specific date.
-
- * goto.c: New file that defines the quick go-to date dialog.
-
- * Makefile.am (gnomecal_SOURCES): Added goto.c to the sources.
-
-1998-08-11 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
-
- * main.c (new_calendar): Made title i18n friendly. This was bug
- #215.
-
- * eventedit.c (ee_store_recur_end_to_ical): Set recur->enddate to
- recur->_enddate, not to itself, when adding recurring event and
- supplying an end date. This fixes (at least part of) bug #99.
-
-1998-08-10 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * month-view.[ch]: Start of the month view widget. This will use
- the generic month item and extend it to have the semantics desired
- for the gnomecal month view.
-
- * gnome-month-item.[ch]: New generic canvas item for the month
- view and the "small calendars". This is intended to be a
- high-level display engine for monthly calendars. This is a work
- in progress.
-
- * gnome-cal.h (GnomeCalendar): Added a month_view field.
-
- * gnome-cal.c (setup_widgets): Create the month view and insert it
- into the notebook.
-
- * Makefile.am: Added month-view.[ch] and gnome-month-item.[ch] to
- the sources.
-
-1998-08-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * main.c (about_calendar_cmd): Use an array of const strings to
- keep gcc happy.
-
- * alarm.c (alarm_compare_by_time): Use gconstpointer to keep gcc happy.
- * calendar.c (calendar_object_compare_by_start): Likewise.
- * gncal-full-day.c (child_compare_by_start): Likewise.
-
-1998-07-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c: Add support for --view flag.
- (session_save_state): Save the view mode;
- (new_calendar): Now takes a view mode flag.
-
- * gnome-cal.c (gnome_calendar_get_current_view_name): New
- function for enhancing the session management support for
- gnomecal.
- (gnome_calendar_set_view): New function that makes a given page
- active.
-
-1998-07-01 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
-
- * gncal.desktop: Added Portuguese translation.
-
-Mon Jun 22 13:01:16 1998 Havoc Pennington <hp@pobox.com>
-
- * main.c (session_save_state): Use gnome_geometry_string to get
- the geometry string.
-
-1998-06-04 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_rp_init_rule): Do not subtract 1 from
- tm->tm_mday for the default_day.
-
- * gnome-cal.c (gnome_calendar_new):
- (gnome_calendar_goto): Use the start of the day -- things expect
- it to be that way.
-
-1998-05-27 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
-
- * eventedit.c (ee_store_recur_rule_to_ical): Fill in
- ical->recur->interval from value in spin_button. This ixed an
- infinnite loop.
-
-1998-05-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (child_draw): Paint the decorations correctly.
- (child_draw_decor): Paint the recurrence/bell icons correctly.
-
-1998-05-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * eventedit.c (ee_rp_init_rule): Use the contents of
- ee->ical->dtstart for computing the predefined values of the recurrence.
-
- * gncal-full-day.c (gncal_full_day_unrealize): Fix the gc
- destruction in the unrealization code and fix the pixmap unrefing.
-
- * main.c (close_cmd): Remove a bad hack that disabled calendar
- widget destruction.
-
- * calobj.c (ical_object_generate_events): Fix for the weekly event
- generation. Was reported on the bug tracking system.
-
-1998-05-18 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-full-day.c (layout_children): Implemented ultra-cool
- layout for the events that share the same time range. Gals and
- guys you can now drop Outlook on the recycle bin.
-
- Which reminds me. We do not have a recycle bin. How could that
- happen in a project as cool as this one? Someone explain this to
- me.
-
-1998-05-18 Federico Mena <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (paint_back): Eliminated unnecessary border repainting.
-
-Sun May 17 17:55:03 1998 Havoc Pennington <hp@pobox.com>
-
- * gncal-todo.c (simple_todo_editor): Close dialog when return is pressed.
-
-1998-05-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (mark_gtk_calendar_day): Bug free version of the
- range computation in place.
-
- * gncal-year-view.c (year_view_mark_day): Use the same new version
- of the range computation here.
-
- * calobj.c (ical_object_generate_events): Fix the begin/end
- condition.
-
-1998-05-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * timeutil.c (isodate_from_time_t): Do not add the spurious
- padding.
-
- * calobj.c (store_date_list): Bug fix: I was using the wrong
- pointer when saving the exception date list.
- (set_date_list): Bug fix: load correctly the complete exception
- date list.
- (set_date_list): Use ',' for the exception date separator as the
- versit people can not get their standard right.
-
- * gncal-full-day.c (unrecur_appointment): Support for making an
- existing recurrent event `movable' for a day.
-
- * calobj.c (ical_object_add_exdate): New routine, used to add
- exception dates.
- (ical_object_duplicate): New routine: used to do the magic
- recur->no-recur event.
-
-1998-05-08 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-full-day.c (new_appointment): Use gtk_calendar freeze/thaw
-
- * gncal-year-view.c (gncal_year_view_set_year): Use gtkcalendar freeze/thaw.
-
- * eventedit.c (event_editor_init): Use gnome_dialog_set_close to
- avoid the ugly warning.
-
- * main.c (display_objedit): Default to the day the user is looking
- at.
-
-1998-05-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-day-panel.c (full_day_size_allocated): Do not emit a value
- changed signal if the value is the same.
-
-1998-05-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * prop.c (prop_apply): Only run the apply code once.
-
-1998-05-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-day-panel.c (update): Draw the day at startup.
- (gncal_day_panel_set): Fix selected-day display.
- (gncal_day_panel_new): Switch day on double clicks, not on single
- clicks.
-
- * calobj.c (ical_object_compute_end): Removed debug messages.
-
-1998-04-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * prop.c (prop_apply): Do not call prop_cancel, ths is now using
- GnomePropertyDialog.
-
-1998-04-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-week-view.c (sync_week): Use gnome_calendar_tag_calendar.
-
- * gnome-cal.c (gnome_calendar_tag_calendar): New routine used to
- fill a gtk_calendar with the events on a GnomeCalendar object.
-
- * gncal-week-view.c (gncal_week_view_new): Set the week to the day
- we double clicked.
-
-1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (calendar_notify): Apply black magic to get mail
- notifications to work.
-
- * gncal-full-day.c (child_focus_out): Temporary optimization, the
- child_focus_out is constantly calling the
- gnome_calendar_object_changed when the property editor has been
- invoked. This happens every time the mouse moves crosses the main
- window.
-
- * calendar.c (calendar_object_changed): Reschedule alarms when a
- calendar object has changed its times.
-
-Sat Apr 25 22:20:45 1998 Havoc Pennington <hp@pobox.com>
-
- * eventedit.c, eventedit.h: Descend from GnomeDialog. Took vbox
- out of class structure; use GnomeDialog vbox
- instead. gnome_dialog_set_destroy instead of destroying in button
- callbacks. Don't create buttons, separator, or vbox manually.
- #include <libgnomeui/gnome-dialog.h>.
-
-1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_object_create_from_vobject): Fixed alarm loading;
- Load snooze time and snooze count
-
-1998-04-23 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * calendar.c (calendar_save): Actually save the to-do entries.
-
- * gncal-todo.c (simple_todo_editor): Now you can add and edit
- to-do entries.
-
-1998-04-22 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c: Made it use popup_menu().
-
- * popup-menu.c: New file with utility functions for creating popup
- menus. Maybe such a thing would be useful in libgnomeui, a la
- gnome-app-helper?
-
- * Makefile.am (gnomecal_SOURCES): Added popup-menu.[ch] to the sources.
-
-1998-04-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * prop.c (properties): Added Calendar properties editor.
- (properties): Make the code use a propery box.
-
- * main.c: Save/load properties (fix to old commit).
-
-1998-04-21 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-todo.c: New widget for editing TODO lists. This will be
- worked on a lot.
-
- * Makefile.am (gnomecal_SOURCES): Added gncal-todo.[ch] to the sources.
-
- * gncal-day-panel.c: Make it use the new TODO widget.
-
-1998-04-21 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * timeutil.c (isodate_from_time_t): Do not save with the global
- time flag (Z at the end of the isodate). When we figure out a way
- to load times in GMT time, we will add this back
-
- * view-utils.c (popup_menu): Moved this routine here as there are
- more users of this code.
-
- * gncal-day-view.c (gncal_day_view_class_init): Add button press
- handler.
- (new_appointment): New routine for creating appointments on a day.
-
-
-
- * main.c (save_ok): Added call to gtk_window_set_wmclass.
-
- * gncal-day-panel.c (calendar_day_selected): Fix, years for mktime
- should substract 1900 and gtk_calendar stores years relative to
- year 0.
-
- * gncal-week-view.c (gncal_week_view_new): Make the week view
- descend from VBox so that we can add a label to it.
- (gncal_week_view_set): Display the ending day of the week
- correctly.
-
- Added a label that displays the week range.
-
-1998-04-21 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-cal.c: Made it use GncalDayPanel.
-
- * gncal-day-panel.c: New widget for the day view in the main
- calendar toplevel. It basically takes care of everything
- gnome-cal did by hand with respect to the day view.
-
- * Makefile.am (gnomecal_SOURCES): Added gncal-day-panel.[ch] to
- the rules.
-
- * main.c: Added a separator between the About menu item and the
- help topics.
-
-1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * eventedit.c (ee_ok): Mark the event as non-new after accepting changes.
-
-1998-04-20 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (gncal_full_day_get_day_start_yoffset): New
- public function that returns the y offset for the row
- corresponding to the "day begin" time.
-
- * gncal-full-day.c (gncal_full_day_key_press): Now any printable
- keystroke (not just Return) will activate the selected range.
-
- * gncal-full-day.c (paint_back): Made it use the new paint_row
- function instead of painting everything directly. We calculate
- areas in a smarter way so there is even less flicker than before,
- especially when selecting regions.
-
- * eventedit.c: Sensitize recurrence widgets properly.
-
- * calobj.c (duration_callback): Pass the correct pointer type to
- is_date_in_list().
-
-1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (duration_callback): Take exception dates into
- account.
-
- * gncal-full-day.c (new_appointment): Setup the event editor dates
- to those of the currently displayed day.
- (gncal_full_day_selection_range): Use sensible values in the case
- no range is selected.
- (new_appointment): Events now use the current day for event creation.
-
- * view-utils.c: Pretty up the time display.
-
- * calobj.c (ical_object_compute_end): Initialize
- ico->recur->enddate, otherwise we loop forever during final date computation.
-
- * eventedit.c: Now recurrence is toggled by a radio button in the
- recurrence page, as the checkbox is confusing.
-
- * calobj.c (is_date_in_list): Add support for the exclussion
- dates.
-
-1998-04-18 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-year-view.c (double_click): Fix this routine as well.
-
- * gncal-week-view.c (jump_to_day): Bind the gtkcalendar signals to
- the week.
-
- * gncal-year-view.c (gncal_year_view_set_year): Put things in the
- proper range. Now the year view actually matches this year.
-
- * gnome-cal.html: Added small documentation.
-
- * main.c: Add more icons to the menus; Rename some menubar
- entries; Add `new' icon to the toolbar.
- (dump_events): Added argument handling and dumping of events from
- the command line. Extremely cool.
-
- * getdate.y: Taken from the CVS source code. Used for date
- parsing in the command line.
-
- Internationalized getdate.y. Wee! It even works with spanish.
-
- * calobj.c (ical_object_to_vobject): Add Quoted printable property
- to items containing new lines.
- (duration): Use unsigned integers, to work around buggy calendar
- files generated by korganizer.
-
- * main.c (save_calendar_cmd): Do not ask for file name if we are
- saving.
- (save_as_calendar_cmd): New command.
-
-
-1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * alarm.c (alarm_kill, alarm_init, alarm_add): Implement the alarm
- management framework.
-
-1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * calobj.c (ical_new): Added mandatory status property.
- (ical_object_to_vobject): Only store "related" list if it exists.
- (store_list): Add terminating null char and free the correct data.
-
- * main.c (save_calendar_cmd): Implemented calendar saving.
- (open_calendar_cmd): Implemented calendar loading.
- (new_calendar_cmd): Implemented calendar creation.
- (new_calendar): Don't load our test calendar by default.
-
- * gncal-full-day.c (delete_appointment): Delete appointment implemented.
-
- * eventedit.c (ee_store_recur_values_to_ical): Free/create
- ical's recurrence appropriately.
- (ee_rp_init_rule): Initialize all missing parameters from ical.
- (ee_rp_init_ending_date): Initialize missing fields from ical.
-
-1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (gnome_calendar_remove_object): Add support for
- removing objects.
-
-1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_init_recurrence_page): New function that creates
- the recurrence page in the toplevel notebook.
- (ee_store_recur_values_to_ical): Now we can also store the recurrences.
-
-1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_object_generate_events): Implement
- RECUR_MONTHLY_BY_POS implemented.
- (ical_object_create_from_vobject): Fix the alarm
- initialization code.
- (save_alarm): Save alarms.
- (ical_object_generate_events): Fixed the recurrent code to take
- into account the recur->endate field (if at all specified).
-
- (ical_object_to_vobject): Implement recurrence rule saving.
-
-1998-04-16 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_store_alarm): Use menu_shell->children, not
- menu->children. Why does GtkMenu have a children field in the
- object structure?
- (check_dates): New function that insures that start_date < end_date.
- (check_times): In addition to checking whether the event spans the
- whole day, now it insures that start_time < end_time.
-
- * gncal-full-day.c (child_set_size): Now children get bigger
- temporarily while they are focused. This allows the handles not
- to "overlap" the rows used by the child and thus allow editing of
- very thin events.
- (recompute_motion): Fix for new child coordinates.
- (gncal_full_day_expose): Make it use find_child_by_window()
- instead of looking for it by hand.
-
- * bell.xpm recur.xpm: XPM files for events with alarm and
- recurrence, respectively.
-
-1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (button_1): Preserve the up/down cursor while dragging.
-
- * gncal-full-day.c (child_draw): Now children have a vertical
- handle as well. This can be used to move the child anytime, not
- only when it is focused.
- (recompute_motion): Modified for new drag behavior.
-
- * eventedit.c (ee_init_general_page): The general_owner may be
- null. Do the proper thing when creating the label.
- (ee_ok): Update the gnome calendar appropriately.
-
- * timeutil.h:
- * gncal-year-view.h: Add some missing prototypes.
-
- * gncal-full-day.c (child_popup_menu): Set the sensitivity of menu
- items according to whether the ical object is being edited or not.
-
- * eventedit.c (event_editor_new): Set the "being edited" flag on
- the ical object (stored as the ical object's user data).
- (event_editor_destroy): Release the flag.
-
- * calobj.h: The iCalObject structure now has a generic user_data pointer.
- * calobj.c (ical_object_set_user_data ical_object_get_user_data):
- Functions to set this data.
-
- * gncal-full-day.c (child_button_press): Do child popup menu correctly.
-
- * main.c (about_calendar_cmd): Fixed my address and added Arturo
- to the authors in the about box.
-
- * gncal-full-day.c (find_child_by_window): Compare child's widget
- windows by user_data (which will be the parent widget, that is,
- the text widget). We cannot assume that child->widget->window
- will be *the* window we are interested on because there may be
- child widgets with multiple windows.
-
-1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_foreach): Define iterator routine.
-
-1998-04-15 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx>
-
- * gncal-year-view.[hc]: Now using time_t for new and set.
- Random fixes, as well.
-
-1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (button_3): New popup menus activated with
- mouse button 3.
- (create_appointment): Create a new appointment from the popup
- menus. See the FIXME.
-
-1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-full-day.c (layout_kill_rows): Routine to destory rows
- array properly.
-
- * gncal-year-view.c (gncal_year_view_new): Add missing year in
- call to strftime.
-
- * calobj.c (ical_object_create_from_vobject): Fixed memory leaks
- from the return values of versit's fakeCString.
-
-1998-04-14 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx>
-
- * gncal-year-view.[hc]: New widget for the year view.
- * Makefile.am: added required compilation of the new files.
-
-1998-04-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (event_editor_setup_time_frame): Fixed some table
- expansions to make the dialog look nicer when resized.
-
- * calobj.c (ignore_space): Fixed compiler warning about unused
- computed value.
- (ocurrencelist): Replace str by p confusion. Removed unused
- variables value and q.
- (daynumber): Fixed a couple of warnings about unused values.
- (load_recurrence): Removed unused variable c. Added a default
- clause to the switch(type).
-
- * eventedit.c (ee_rp_init_frequency): Removed unused variable content.
- Fixed a compiler warning by adding a missing cast.
-
- * calobj.c (ical_object_create_from_vobject): Make the
- load_recurrence() part work correctly. Eliminated use of
- syntax_error variable.
-
-1998-04-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (child_key_press): Unfocus the child and focus
- the parent fullday widget when the user presses Esc.
-
- * gncal-week-view.c (gncal_week_view_update): Now takes object and
- flags parameters.
- * gncal-day-view.c (gncal_day_view_update): Likewise.
- * gncal-full-day.c (gncal_full_day_update): Likewise.
- (child_focus_in): New function. In conjunction with
- child_focus_out(), these only display the handles in the child
- when it is focused. The result is that the user can see more of
- the child's text when nothing is focused, and we can also display
- fatter and nicer drag handles.
-
- * gnome-cal.c (gnome_calendar_object_changed): Now takes an
- additional flags parameter
- (gnome_calendar_update_all): Made function static. Now takes
- changed object and flags parameters as well.
- (gnome_calendar_object_changed): Now takes additional flags
- parameter to indicate what changed in the specified object.
-
- * calobj.h (CalObjectChange): New enum with flags to describe what
- has been changed in an object.
-
- * gncal-full-day.h:
- * gncal-full-day.c (gncal_full_day_focus_child): New function to
- let the outside world decide which child to focus.
- (gncal_full_day_focus_child): Bleah. We have to synthesize a
- click because GtkText will not set the cursor when you focus it.
-
- * gnome-cal.c (day_view_range_activated): Focus the new child in
- the full day widget.
-
- * eventedit.c (event_editor_setup_time_frame): Re-aligned some
- widgets to make it look prettier.
- (ee_alarm_widgets): Likewise.
- (ee_init_general_page): Likewise.
- (ee_classification_widgets): Likewise.
- (event_editor_init_widgets): Likewise.
-
- * gnome-cal.c (day_view_range_activated): Create new object and
- add it to the calendar. You can now select a range in the
- full-day view, hit Return, and a new event will be added at the
- selected range. I still have to figure out how to focus this new child.
-
- * gncal-full-day.c (paint_back): Rewrote function to avoid
- painting an area more than once -- eliminate flicker.
- (paint_back_rows): New function that calls paint_back() only for
- the area of the specified rows.
- (gncal_full_day_button_press):
- (gncal_full_day_button_release):
- (gncal_full_day_motion): Made these functions use
- paint_back_rows() instead of paint_back(), to eliminate flicker. Wheee!
-
-1998-04-12 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-cal.c (setup_day_view): We now connect to the
- range_activated signal of the fullday widget instead of catching
- key presses ourselves.
- (day_view_range_activated): New function that creates a new
- iCalObject and inserts it into the calendar, not finished yet.
-
-1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (get_time_from_rows): New function, calculates
- a pair of time_t values from the specified start and number of rows.
-
- * gncal-full-day.h (GncalFullDayClass): New signal
- "range_activated". It is emitted when a range is selected and the
- user hits Return.
- (gncal_full_day_selection_range): New function, returns the
- selected range.
-
- * gncal-full-day.c (struct drag_info): Moved selection information
- to their own fields instead of sharing the child's drag fields.
- This allows us to keep the selection when a child is moved.
- (recompute_motion): Made the case when (row < di->sel_click_row)
- work correctly.
-
-1998-04-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (gnome_calendar_goto): Add support for navigating
- on the day view.
-
- * timeutil.c (time_start_of_day, time_end_of_day, time_day_hour):
- New time manipulation functions.
-
- * eventedit.c (ee_rp_init_frequency): Add the different frequency
- editors to a notebook. Make the notebook startup on the entry
- selected recurrence type;
-
-1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (recompute_motion): Now we support selecting a
- range in the main window (by clicking+dragging). It flickers
- horribly and is not perfect, but it is a start.
-
-1998-04-09 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c: #include <string.h>
-
- * gncal-full-day.c (child_map): Show instead of just map the child
- widget (otherwise the text widget gets confused and will not focus).
-
- * calobj.c (ical_object_to_vobject): Quote chars as 'x', not "x".
-
- * calobj.h: Added prototype for ical_object_to_vobject().
-
- * gnome-cal.c (gnome_calendar_object_changed): New function. This
- should be called when a calendar object is changed.
-
- * gncal-full-day.c (update_from_drag_info): Call
- gnome_calendar_object_changed() instead of updating manually.
-
- * calendar.c (calendar_add_object):
- (calendar_remove_object): Set the modified flag to true.
-
- * gncal-full-day.c (gncal_full_day_draw): Finished implementing
- this function.
-
-1998-04-08 Raja R Harinath <harinath@cs.umn.edu>
-
- * gncal.c (update_calendar): Say `#if 0', not `#ifdef 0'.
-
-1998-04-07 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c: Removed unused global variable parent_class.
-
- * eventedit.h: Renamed gtk_window field to window.
- Made the parent_class field in the EventEditorClass structure be a
- GtkWindowClass, not a gnome property box class.
- Added prototype for event_editor_get_type().
-
-1998-04-06 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-week-view.c (gncal_week_view_new): Use the new
- gtk_table_set_homogeneous() instead of setting the variable directly.
-
-1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_create_ae): Make it return void.
- (ee_alarm_widgets): Remove some unused variables.
- (ee_store_alarm): Make it return void.
- #include <string.h>
-
- * eventedit.h: #include "gnome-cal.h"
-
- * calobj.c (list_free): Don't use g_free in the g_list_foreach.
-
- * calendar.h: Add prototype for calendar_load().
-
- * timeutil.h: Add prototypes for time_add_*().
-
- * calendar.c:
- * calobj.c:
- * eventedit.c:
- * gnome-cal.c: #include "timeutil.h"
-
- * gncal-day-view.c (gncal_day_view_size_request): Make the minimum
- width equal or larger to the title width.
-
- * main.c: #include "eventedit.h"
- (main): Add a return statement.
- (new_calendar): Show stuff *after* the calendar has been loaded.
-
- * gnome-cal.c (gnome_calendar_load): Update the day view.
- (setup_widgets): Hackish setup of a day view widget - will fix later.
- (gnome_calendar_init): Initialize all fields.
-
- * gnome-cal.h: Added day_view field. Maybe this should be changed
- when the a complete day view panel is complete.
-
- * gncal-day-view.c (gncal_day_view_update): Draw after update, not
- before.
-
-1998-04-06 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
-
- * versit/.cvsignore: New file.
-
-Fri Apr 3 22:31:54 1998 Tom Tromey <tromey@cygnus.com>
-
- * calendar.c: Include <config.h>.
-
-1998-04-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * timeutil.c (time_add_year, time_add_year, time_add_week):
- Routines for time manipulation.
-
- * calobj.c (ical_object_destroy): Full destruction of the object.
-
- * eventedit.c: Finished the main event editor form; It still
- lacks the details and the recurrence bits. It now adds events
- and cancels.
-
-1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * view-utils.c (view_utils_draw_events): The "better" format
- string for strftime() wasn't better, after all :-(
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c: New full-day widget. It is still a work in
- progress. It will be similar to M$ Schedule's nifty full day view
- widget, but with Gtk's elegance :-)
-
- * Makefile.am (gnomecal_SOURCES): Added gncal-full-day.[ch] to the sources.
-
-1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * eventedit.c: Object editor widget. We dropped ObjEdit.
-
- * timeutil.c (time_from_isodate): Fix.
-
- * view-utils.c (view_utils_draw_events): Changed the display
- formats.
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * view-utils.c (view_utils_draw_events): Use better format
- specifier for strftime().
- (view_utils_draw_textured_frame): Ultra-nifty function to draw
- textured "metal" frames, like Netscape's handles.
-
-1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-day-view.c (gncal_day_view_update): Day events are now
- cached inside the widget. They get initialized at this time.
-
- * view-utils.c (view_utils_draw_events): Use the list of events.
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-day-view.c (gncal_day_view_set_shadow): New customization
- function. We can't decide on a stupid border type :-)
- (gncal_day_view_init): Made GTK_SHADOW_ETCHED_IN be the default
- shadow type. Looks good.
-
-1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c: New main program that uses our new datatypes and
- objects.
-
- * calendar.c (calendar_load_from_vobject, calendar_load):
- Implement loading of vCalendar objects and vCalendar files.
-
- * calobj.c (ical_object_create_from_vobject): Implement loading of
- vCalendar event and todo objects.
-
- * timeutil.c (isodate_from_time_t): New function.
-
- * gnome-cal.c, gnome-cal.h: Implement a toplevel widget, derived
- from GnomeApp. It holds all of the day views and arbitrates the
- display.
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-week-view.[ch]: New week view composite widget. This
- provides a full week view (7 day views plus busy time display --
- the latter is currently unimplemented).
-
-1998-04-01 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-day-view.c: New day view widget. It is intended to be a
- child widget of the week view composite widget.
-
- * calendar.c (calendar_get_objects_in_range):
- (calendar_get_events_in_range):
- (calendar_get_journal_in_range):
- (calendar_get_journal_in_range): These functions now take a
- sort_func parameter, which is of type GCompareFunc. If the
- specified value is non-NULL, it will return a sorted list.
- Otherwise, it will return an unordered list.
- (calendar_compare_by_dtstart): Provide a generic sorting routine
- for calendar objects.
-
-1998-04-01 Miguel de Icaza <miguel@kernel.org>
-
- * Start from scratch
-
-Tue Mar 31 23:46:50 1998 Tom Tromey <tromey@cygnus.com>
-
- * timeutil.c (format_simple_hour): `buf' now static.
-
-1998-03-31 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal.c: Removed #include "gtkcalendar.h", because it now comes
- from libgnomeui.
-
- * Makefile.am (gncal_SOURCES): Added new source files to the rules.
-
- * timeutil.c (format_simple_hour): New function, formats an
- hour/am_pm pair into a string of the form "3am", "12pm", "05h",
- "19h", etc. It is used by the day view widget for its labels.
-
-1998-03-31 Craig Small <csmall@small.dropbear.id.au>
-
- * Now has (non working) session maangement
- * Uses a clist for the dailylist like gtt
-
-Sat Mar 21 15:43:20 1998 Tom Tromey <tromey@cygnus.com>
-
- * gncal.c: Use gnome_message_box_*, not gnome_messagebox_*.
-
-1998-03-12 Craig Small <csmall@small.dropbear.id.au>
-
- * Now linked (in some horrible way) to the gtkcalendar widget.
-
-Sun Mar 8 16:38:10 1998 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.am (INCLUDES): Added GNOME_INCLUDEDIR.
- (gncal_LDADD): Don't include libsupport.a.
-
- * gncal.c (main): Use new gnome_init.
-
-1998-02-19 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal.c (main): Added app_id "gncal".
-
-1998-02-19 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
-
- * Makefile.am (gncal_LDADD): Added '$(INTLLIBS)'
-
-1998-02-18 Raja R Harinath <harinath@cs.umn.edu>
-
- * Makefile.am (gncal_LDADD): Include `libsupport.a'.
-
- * calcs.c (month_atoi): Replace buggy explicit loop string compare
- with strcasecmp.
- (day_atoi): Likewise.
-
-Sun Jan 25 23:38:30 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * menus.c: Replace "Quit" with "Exit".
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
deleted file mode 100644
index fb241739ee..0000000000
--- a/calendar/Makefile.am
+++ /dev/null
@@ -1,83 +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 \
- getdate.y \
- 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 \
- 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 \
- goto.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 33aff8cda8..0000000000
--- a/calendar/cal-util/calobj.c
+++ /dev/null
@@ -1,1248 +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);
- } else
- ical->palarm.data = g_strdup ("");
- }
- }
-
- /* malarm */
- ical->malarm.type = ALARM_MAIL;
- ical->malarm.enabled = 0;
- if (has (o, VCMAlarmProp)){
- ical->malarm.type = ALARM_MAIL;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->malarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCEmailAddressProp))){
- ical->malarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->malarm.data = g_strdup ("");
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_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 33aff8cda8..0000000000
--- a/calendar/calobj.c
+++ /dev/null
@@ -1,1248 +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);
- } else
- ical->palarm.data = g_strdup ("");
- }
- }
-
- /* malarm */
- ical->malarm.type = ALARM_MAIL;
- ical->malarm.enabled = 0;
- if (has (o, VCMAlarmProp)){
- ical->malarm.type = ALARM_MAIL;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->malarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCEmailAddressProp))){
- ical->malarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->malarm.data = g_strdup ("");
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_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 67061dd505..0000000000
--- a/calendar/gnome-cal.c
+++ /dev/null
@@ -1,422 +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_goto_today (GnomeCalendar *gcal)
-{
- gnome_calendar_goto (gcal, time (NULL));
-}
-
-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 7f1534714c..0000000000
--- a/calendar/gnome-cal.h
+++ /dev/null
@@ -1,70 +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);
-/* Jumps to the current day */
-void gnome_calendar_goto_today (GnomeCalendar *gcal);
-void gnome_calendar_tag_calendar (GnomeCalendar *cal,
- GtkCalendar *gtk_cal);
-char *gnome_calendar_get_current_view_name (GnomeCalendar *gcal);
-void gnome_calendar_set_view (GnomeCalendar *gcal,
- char *page_name);
-
-/* 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 045a32d59d..0000000000
--- a/calendar/gnome-month-item.c
+++ /dev/null
@@ -1,876 +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"
-
-
-
-
-/* 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[GNOME_MONTH_ITEM_HEAD_GROUP + i],
- "x", width * i,
- "y", 0.0,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", mitem->head_height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->head_anchor,
- mitem->head_padding,
- mitem->head_padding,
- width - mitem->head_padding,
- mitem->head_height - mitem->head_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->head_anchor,
- NULL);
- }
-}
-
-/* Resets the position of the days in the calendar */
-static void
-reshape_days (GnomeMonthItem *mitem)
-{
- double width, height;
- double x, y;
- int row, col;
- int i;
-
- width = mitem->width / 7;
- height = (mitem->height - mitem->head_height) / 6;
-
- i = 0;
-
- for (row = 0; row < 6; row++)
- for (col = 0; col < 7; col++) {
- /* Group */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i],
- "x", width * col,
- "y", mitem->head_height + height * row,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->day_anchor,
- mitem->day_padding,
- mitem->day_padding,
- width - mitem->day_padding,
- height - mitem->day_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->day_anchor,
- NULL);
-
- i++;
- }
-}
-
-/* Changes the positions and resizes the items in the calendar to match the new size of the
- * calendar.
- */
-static void
-reshape (GnomeMonthItem *mitem)
-{
- 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[GNOME_MONTH_ITEM_HEAD_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "fill_color", "black",
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_text_get_type (),
- "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 start, end;
- char buf[100];
-
- build_month (mitem->month, mitem->year, mitem->day_numbers, &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[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-
- /* Set days of month */
-
- for (; start <= end; start++, i++) {
- sprintf (buf, "%d", mitem->day_numbers[start]);
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", buf,
- NULL);
- }
-
- /* Clear days after end of month */
-
- for (; i < 42; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-}
-
-/* Creates the items for the days */
-static void
-create_days (GnomeMonthItem *mitem)
-{
- int i;
-
- /* Just create the items; they will be positioned and configured by a call to reshape() */
-
- for (i = 0; i < 42; i++) {
- /* Group */
- mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "outline_color", "black",
- "fill_color", "#d6d6d6d6d6d6",
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_text_get_type (),
- "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[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "text", mitem->day_names[mitem->start_on_monday ? ((i + 1) % 7) : i],
- NULL);
-}
-
-/* Creates all the canvas items that make up the calendar */
-static void
-create_items (GnomeMonthItem *mitem)
-{
- mitem->items = g_new (GnomeCanvasItem *, GNOME_MONTH_ITEM_LAST);
-
- create_headings (mitem);
- create_days (mitem);
-
- /* Initialize by default to three-letter day names */
-
- mitem->day_names[0] = g_strdup (_("Sun"));
- mitem->day_names[1] = g_strdup (_("Mon"));
- mitem->day_names[2] = g_strdup (_("Tue"));
- mitem->day_names[3] = g_strdup (_("Wed"));
- mitem->day_names[4] = g_strdup (_("Thu"));
- mitem->day_names[5] = g_strdup (_("Fri"));
- mitem->day_names[6] = g_strdup (_("Sat"));
-
- set_day_names (mitem);
- reshape (mitem);
-}
-
-static void
-gnome_month_item_init (GnomeMonthItem *mitem)
-{
- time_t t;
- struct tm *tm;
-
- /* Initialize to the current month by default */
-
- t = time (NULL);
- tm = localtime (&t);
-
- mitem->year = tm->tm_year + 1900;
- mitem->month = tm->tm_mon;
-
- mitem->x = 0.0;
- mitem->y = 0.0;
- mitem->width = 150.0; /* not unreasonable defaults, I hope */
- mitem->height = 100.0;
- mitem->anchor = GTK_ANCHOR_NW;
- mitem->head_padding = 0.0;
- mitem->day_padding = 2.0;
- mitem->head_height = 14.0;
- mitem->head_anchor = GTK_ANCHOR_CENTER;
- mitem->day_anchor = GTK_ANCHOR_CENTER;
-}
-
-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;
- }
-}
-
-GnomeCanvasItem *
-gnome_month_item_num2child (GnomeMonthItem *mitem, GnomeMonthItemChild child_num)
-{
- g_return_val_if_fail (mitem != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), NULL);
-
- return mitem->items[child_num];
-}
-
-GnomeMonthItemChild
-gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (child != NULL, -1);
- g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (child), -1);
-
- for (i = 0; i < GNOME_MONTH_ITEM_LAST; i++)
- if (mitem->items[i] == child)
- return i;
-
- return -1;
-}
-
-int
-gnome_month_item_num2day (GnomeMonthItem *mitem, GnomeMonthItemChild child_num)
-{
- g_return_val_if_fail (mitem != NULL, 0);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), 0);
-
- if ((child_num >= GNOME_MONTH_ITEM_DAY_GROUP) && (child_num < GNOME_MONTH_ITEM_LAST)) {
- child_num = (child_num - GNOME_MONTH_ITEM_DAY_GROUP) % 42;
- return mitem->day_numbers[child_num];
- } else
- return 0;
-}
-
-int
-gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (day_num >= 1, -1);
-
- /* Find first day of month */
-
- for (i = 0; mitem->day_numbers[i] == 0; i++)
- ;
-
- /* Find the specified day */
-
- for (; (mitem->day_numbers[i] != 0) && (i < 42); i++)
- if (mitem->day_numbers[i] == day_num)
- return i;
-
- /* Bail out */
-
- return -1;
-}
diff --git a/calendar/gnome-month-item.h b/calendar/gnome-month-item.h
deleted file mode 100644
index b1b11f9d01..0000000000
--- a/calendar/gnome-month-item.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* General-purpose monthly calendar canvas item for GNOME
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef GNOME_MONTH_ITEM_H
-#define GNOME_MONTH_ITEM_H
-
-#include <libgnome/gnome-defs.h>
-#include <gtk/gtkpacker.h> /* why the hell is GtkAnchorType here and not in gtkenums.h? */
-#include <libgnomeui/gnome-canvas.h>
-
-
-BEGIN_GNOME_DECLS
-
-
-/* These values are used to identify the canvas items that make up a complete GnomeMonthItem, which
- * is made up of the following "pieces":
- *
- * Headings line:
- * - 7 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * Day slots:
- * - 42 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * The headings are organized from left to right. The day slots are organized as a table in
- * row-major order.
- *
- * If you want to access the individual items of the GnomeMonthItem, you can use these numbers with
- * the gnome_month_item_num2child() function. If you want to convert a number into the
- * corresponding GnomeCanvasItem, you can use the gnome_month_item_child2num() function.
- */
-typedef enum {
- GNOME_MONTH_ITEM_HEAD_GROUP = 0, /* 7 groups for headings */
- GNOME_MONTH_ITEM_HEAD_BOX = 7, /* 7 boxes for headings */
- GNOME_MONTH_ITEM_HEAD_LABEL = 14, /* 7 labels for headings */
- GNOME_MONTH_ITEM_DAY_GROUP = 21, /* 42 groups for days */
- GNOME_MONTH_ITEM_DAY_BOX = 63, /* 42 boxes for days */
- GNOME_MONTH_ITEM_DAY_LABEL = 105, /* 42 labels for days */
- GNOME_MONTH_ITEM_LAST = 147 /* total number of items */
-} GnomeMonthItemChild;
-
-
-#define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ())
-#define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem))
-#define GNOME_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_MONTH_ITEM, GnomeMonthItemClass))
-#define GNOME_IS_MONTH_ITEM(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_MONTH_ITEM))
-#define GNOME_IS_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_MONTH_ITEM))
-
-
-typedef struct _GnomeMonthItem GnomeMonthItem;
-typedef struct _GnomeMonthItemClass GnomeMonthItemClass;
-
-struct _GnomeMonthItem {
- GnomeCanvasGroup group;
-
- int year; /* Year to show (full, no two-digit crap) */
- int month; /* Month to show (0-11) */
-
- double x, y; /* Position at anchor */
- double width, height; /* Size of calendar */
- GtkAnchorType anchor; /* Anchor side for calendar */
-
- double head_padding; /* Padding to use between heading lines and text */
- double day_padding; /* Padding to use between day number lines and text */
-
- char *day_names[7]; /* Names to use for the day labels, starting from Sunday */
-
- double head_height; /* Height of the headings row */
- GtkAnchorType head_anchor; /* Anchor side for the heading labels */
-
- GtkAnchorType day_anchor; /* Anchor side for the day number labels */
-
- GnomeCanvasItem **items; /* All the items that make up the calendar */
- int day_numbers[42]; /* The numbers of the days */
-
- int start_on_monday : 1; /* Start the week on Monday? If false, then start from Sunday */
-};
-
-struct _GnomeMonthItemClass {
- GnomeCanvasGroupClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType gnome_month_item_get_type (void);
-
-/* Creates a new month item with the specified group as parent */
-GnomeCanvasItem *gnome_month_item_new (GnomeCanvasGroup *parent);
-
-/* Constructor function useful for derived classes */
-void gnome_month_item_construct (GnomeMonthItem *mitem);
-
-/* Returns the child item defined by the child number (as specified on the GnomeMonthItemChild
- * enumeration above).
- */
-GnomeCanvasItem *gnome_month_item_num2child (GnomeMonthItem *mitem, GnomeMonthItemChild child_num);
-
-/* Returns the number of the specified child item, as defined on the GnomeMonthItemChild enumeration
- * above. If the specified object is not found, it returns -1.
- */
-GnomeMonthItemChild gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child);
-
-/* Returns the number of the day relevant to the specified child item. Day numbers are 1-based. If
- * the specified child is outside the range of displayed days, then it returns 0.
- */
-int gnome_month_item_num2day (GnomeMonthItem *mitem, GnomeMonthItemChild child_num);
-
-/* Returns the index (0-41) of the specified date within the table of days. If the day number is
- * invalid for the current monthly calendar, then -1 is returned.
- */
-int gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/goto.c b/calendar/goto.c
deleted file mode 100644
index 7ba464bd7c..0000000000
--- a/calendar/goto.c
+++ /dev/null
@@ -1,339 +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"
-#include "timeutil.h"
-
-
-static void
-highlight_current_day (GnomeMonthItem *mitem)
-{
- struct tm *tm;
- time_t t;
- GnomeCanvasItem *label;
- int i;
-
- t = time (NULL);
- tm = localtime (&t);
-
- /* First clear all the days to normal */
-
- for (i = 0; i < 42; i++) {
- label = gnome_month_item_num2child (mitem, i + GNOME_MONTH_ITEM_DAY_LABEL);
- gnome_canvas_item_set (label,
- "fill_color", "black",
- NULL);
- }
-
- /* Highlight the current day, if appropriate */
-
- if ((mitem->year == (tm->tm_year + 1900)) && (mitem->month == tm->tm_mon)) {
- i = gnome_month_item_day2index (mitem, tm->tm_mday);
- label = gnome_month_item_num2child (mitem, i + GNOME_MONTH_ITEM_DAY_LABEL);
- gnome_canvas_item_set (label,
- "fill_color", "blue",
- NULL);
- }
-}
-
-/* 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);
-}
-
-/* Event handler for day groups in the month item. A button press makes the calendar jump to the
- * selected day and destroys the Go-to dialog box. Days are prelighted as appropriate on
- * enter_notify and leave_notify events.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- GtkWidget *dialog;
- GnomeCalendar *gcal;
- GnomeMonthItem *mitem;
- GnomeCanvasItem *box;
- int child_num, day;
-
- dialog = GTK_WIDGET (data);
- gcal = gtk_object_get_data (GTK_OBJECT (dialog), "gnome_calendar");
- mitem = gtk_object_get_data (GTK_OBJECT (dialog), "month_item");
-
- child_num = gnome_month_item_child2num (mitem, item);
- day = gnome_month_item_num2day (mitem, child_num);
-
- if (day == 0)
- return FALSE;
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if ((event->button.button == 1) && (day != 0)) {
- gnome_calendar_goto (gcal, time_from_day (mitem->year, mitem->month, day));
- gtk_widget_destroy (dialog);
- }
- break;
-
- case GDK_ENTER_NOTIFY:
- box = gnome_month_item_num2child (mitem, child_num - GNOME_MONTH_ITEM_DAY_GROUP + GNOME_MONTH_ITEM_DAY_BOX);
- gnome_canvas_item_set (box,
- "fill_color", "#ea60ea60ea60",
- NULL);
- break;
-
- case GDK_LEAVE_NOTIFY:
- box = gnome_month_item_num2child (mitem, child_num - GNOME_MONTH_ITEM_DAY_GROUP + GNOME_MONTH_ITEM_DAY_BOX);
- gnome_canvas_item_set (box,
- "fill_color", "#d6d6d6d6d6d6",
- NULL);
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* 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;
- int i;
- GnomeCanvasItem *day_group;
-
- 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);
-
- /* Bind the day groups to our event handler */
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), i + GNOME_MONTH_ITEM_DAY_GROUP);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- dialog);
- }
-
- return canvas;
-}
-
-static void
-goto_today (GtkWidget *widget, gpointer data)
-{
- GtkWidget *dialog;
- GnomeCalendar *gcal;
-
- dialog = GTK_WIDGET (data);
- gcal = gtk_object_get_data (GTK_OBJECT (dialog), "gnome_calendar");
-
- gnome_calendar_goto_today (gcal);
- gtk_widget_destroy (dialog);
-}
-
-/* Creates a "goto date" dialog and runs it */
-void
-goto_dialog (GnomeCalendar *gcal)
-{
- GtkWidget *dialog;
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *w;
- struct tm *tm;
-
- tm = localtime (&gcal->current_display);
-
- dialog = gnome_dialog_new (_("Go to date"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gtk_object_set_data (GTK_OBJECT (dialog), "gnome_calendar", gcal);
-
- 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);
-
- /* Today button */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- w = gtk_button_new_with_label (_("Go to today"));
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) goto_today,
- dialog);
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Run! */
-
- gnome_dialog_set_modal (GNOME_DIALOG (dialog));
- gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE);
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (gcal));
- gtk_widget_show (dialog);
-}
diff --git a/calendar/goto.xpm b/calendar/goto.xpm
deleted file mode 100644
index c7173b4388..0000000000
--- a/calendar/goto.xpm
+++ /dev/null
@@ -1,68 +0,0 @@
-/* XPM */
-static char * goto_xpm[] = {
-"24 24 41 1",
-" c None",
-". c #212121",
-"+ c #EAD4CB",
-"@ c #E3C5BA",
-"# c #DBB4A4",
-"$ c #EEDED7",
-"% c #FAF7F5",
-"& c #F2E5E1",
-"* c #D2AC99",
-"= c #000000",
-"- c #8D9E7C",
-"; c #CDD9C2",
-"> c #DEE6D7",
-", c #DAE2D1",
-"' c #9BAD89",
-") c #B79382",
-"! c #707D63",
-"~ c #B4C6A2",
-"{ c #ACC098",
-"] c #636E57",
-"^ c #AB8A7A",
-"/ c #E4E9DD",
-"( c #657158",
-"_ c #C49F8D",
-": c #C3D1B5",
-"< c #808F70",
-"[ c #4C5442",
-"} c #58634E",
-"| c #E6EBE0",
-"1 c #D4DDC9",
-"2 c #CAD7BE",
-"3 c #90A17F",
-"4 c #5F6A53",
-"5 c #535C49",
-"6 c #E9EDE4",
-"7 c #616D56",
-"8 c #A8BC95",
-"9 c #7C8B6E",
-"0 c #4C5443",
-"a c #B6C2AA",
-"b c #5E6953",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ... ",
-" ..+@#.. ",
-" .$%&@*. ",
-" =======+#**. ",
-" =-;>,'=###). ",
-" =!~{]=##*^. ",
-" ==/;{(]=#*_. ",
-" ==/;:{<[}=)).. ",
-" =|12{{34=5=.. ",
-" =6{{{7= == ",
-" =>890= ",
-" =a]= ",
-" =b= ",
-" = ",
-" ",
-" ",
-" ",
-" "};
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
deleted file mode 100644
index fb241739ee..0000000000
--- a/calendar/gui/Makefile.am
+++ /dev/null
@@ -1,83 +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 \
- getdate.y \
- 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 \
- 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 \
- goto.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 67061dd505..0000000000
--- a/calendar/gui/gnome-cal.c
+++ /dev/null
@@ -1,422 +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_goto_today (GnomeCalendar *gcal)
-{
- gnome_calendar_goto (gcal, time (NULL));
-}
-
-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 7f1534714c..0000000000
--- a/calendar/gui/gnome-cal.h
+++ /dev/null
@@ -1,70 +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);
-/* Jumps to the current day */
-void gnome_calendar_goto_today (GnomeCalendar *gcal);
-void gnome_calendar_tag_calendar (GnomeCalendar *cal,
- GtkCalendar *gtk_cal);
-char *gnome_calendar_get_current_view_name (GnomeCalendar *gcal);
-void gnome_calendar_set_view (GnomeCalendar *gcal,
- char *page_name);
-
-/* 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 045a32d59d..0000000000
--- a/calendar/gui/gnome-month-item.c
+++ /dev/null
@@ -1,876 +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"
-
-
-
-
-/* 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[GNOME_MONTH_ITEM_HEAD_GROUP + i],
- "x", width * i,
- "y", 0.0,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", mitem->head_height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->head_anchor,
- mitem->head_padding,
- mitem->head_padding,
- width - mitem->head_padding,
- mitem->head_height - mitem->head_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->head_anchor,
- NULL);
- }
-}
-
-/* Resets the position of the days in the calendar */
-static void
-reshape_days (GnomeMonthItem *mitem)
-{
- double width, height;
- double x, y;
- int row, col;
- int i;
-
- width = mitem->width / 7;
- height = (mitem->height - mitem->head_height) / 6;
-
- i = 0;
-
- for (row = 0; row < 6; row++)
- for (col = 0; col < 7; col++) {
- /* Group */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i],
- "x", width * col,
- "y", mitem->head_height + height * row,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->day_anchor,
- mitem->day_padding,
- mitem->day_padding,
- width - mitem->day_padding,
- height - mitem->day_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->day_anchor,
- NULL);
-
- i++;
- }
-}
-
-/* Changes the positions and resizes the items in the calendar to match the new size of the
- * calendar.
- */
-static void
-reshape (GnomeMonthItem *mitem)
-{
- 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[GNOME_MONTH_ITEM_HEAD_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "fill_color", "black",
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_text_get_type (),
- "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 start, end;
- char buf[100];
-
- build_month (mitem->month, mitem->year, mitem->day_numbers, &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[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-
- /* Set days of month */
-
- for (; start <= end; start++, i++) {
- sprintf (buf, "%d", mitem->day_numbers[start]);
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", buf,
- NULL);
- }
-
- /* Clear days after end of month */
-
- for (; i < 42; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-}
-
-/* Creates the items for the days */
-static void
-create_days (GnomeMonthItem *mitem)
-{
- int i;
-
- /* Just create the items; they will be positioned and configured by a call to reshape() */
-
- for (i = 0; i < 42; i++) {
- /* Group */
- mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_rect_get_type (),
- "outline_color", "black",
- "fill_color", "#d6d6d6d6d6d6",
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_text_get_type (),
- "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[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "text", mitem->day_names[mitem->start_on_monday ? ((i + 1) % 7) : i],
- NULL);
-}
-
-/* Creates all the canvas items that make up the calendar */
-static void
-create_items (GnomeMonthItem *mitem)
-{
- mitem->items = g_new (GnomeCanvasItem *, GNOME_MONTH_ITEM_LAST);
-
- create_headings (mitem);
- create_days (mitem);
-
- /* Initialize by default to three-letter day names */
-
- mitem->day_names[0] = g_strdup (_("Sun"));
- mitem->day_names[1] = g_strdup (_("Mon"));
- mitem->day_names[2] = g_strdup (_("Tue"));
- mitem->day_names[3] = g_strdup (_("Wed"));
- mitem->day_names[4] = g_strdup (_("Thu"));
- mitem->day_names[5] = g_strdup (_("Fri"));
- mitem->day_names[6] = g_strdup (_("Sat"));
-
- set_day_names (mitem);
- reshape (mitem);
-}
-
-static void
-gnome_month_item_init (GnomeMonthItem *mitem)
-{
- time_t t;
- struct tm *tm;
-
- /* Initialize to the current month by default */
-
- t = time (NULL);
- tm = localtime (&t);
-
- mitem->year = tm->tm_year + 1900;
- mitem->month = tm->tm_mon;
-
- mitem->x = 0.0;
- mitem->y = 0.0;
- mitem->width = 150.0; /* not unreasonable defaults, I hope */
- mitem->height = 100.0;
- mitem->anchor = GTK_ANCHOR_NW;
- mitem->head_padding = 0.0;
- mitem->day_padding = 2.0;
- mitem->head_height = 14.0;
- mitem->head_anchor = GTK_ANCHOR_CENTER;
- mitem->day_anchor = GTK_ANCHOR_CENTER;
-}
-
-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;
- }
-}
-
-GnomeCanvasItem *
-gnome_month_item_num2child (GnomeMonthItem *mitem, GnomeMonthItemChild child_num)
-{
- g_return_val_if_fail (mitem != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), NULL);
-
- return mitem->items[child_num];
-}
-
-GnomeMonthItemChild
-gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (child != NULL, -1);
- g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (child), -1);
-
- for (i = 0; i < GNOME_MONTH_ITEM_LAST; i++)
- if (mitem->items[i] == child)
- return i;
-
- return -1;
-}
-
-int
-gnome_month_item_num2day (GnomeMonthItem *mitem, GnomeMonthItemChild child_num)
-{
- g_return_val_if_fail (mitem != NULL, 0);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), 0);
-
- if ((child_num >= GNOME_MONTH_ITEM_DAY_GROUP) && (child_num < GNOME_MONTH_ITEM_LAST)) {
- child_num = (child_num - GNOME_MONTH_ITEM_DAY_GROUP) % 42;
- return mitem->day_numbers[child_num];
- } else
- return 0;
-}
-
-int
-gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (day_num >= 1, -1);
-
- /* Find first day of month */
-
- for (i = 0; mitem->day_numbers[i] == 0; i++)
- ;
-
- /* Find the specified day */
-
- for (; (mitem->day_numbers[i] != 0) && (i < 42); i++)
- if (mitem->day_numbers[i] == day_num)
- return i;
-
- /* Bail out */
-
- return -1;
-}
diff --git a/calendar/gui/gnome-month-item.h b/calendar/gui/gnome-month-item.h
deleted file mode 100644
index b1b11f9d01..0000000000
--- a/calendar/gui/gnome-month-item.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* General-purpose monthly calendar canvas item for GNOME
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef GNOME_MONTH_ITEM_H
-#define GNOME_MONTH_ITEM_H
-
-#include <libgnome/gnome-defs.h>
-#include <gtk/gtkpacker.h> /* why the hell is GtkAnchorType here and not in gtkenums.h? */
-#include <libgnomeui/gnome-canvas.h>
-
-
-BEGIN_GNOME_DECLS
-
-
-/* These values are used to identify the canvas items that make up a complete GnomeMonthItem, which
- * is made up of the following "pieces":
- *
- * Headings line:
- * - 7 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * Day slots:
- * - 42 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * The headings are organized from left to right. The day slots are organized as a table in
- * row-major order.
- *
- * If you want to access the individual items of the GnomeMonthItem, you can use these numbers with
- * the gnome_month_item_num2child() function. If you want to convert a number into the
- * corresponding GnomeCanvasItem, you can use the gnome_month_item_child2num() function.
- */
-typedef enum {
- GNOME_MONTH_ITEM_HEAD_GROUP = 0, /* 7 groups for headings */
- GNOME_MONTH_ITEM_HEAD_BOX = 7, /* 7 boxes for headings */
- GNOME_MONTH_ITEM_HEAD_LABEL = 14, /* 7 labels for headings */
- GNOME_MONTH_ITEM_DAY_GROUP = 21, /* 42 groups for days */
- GNOME_MONTH_ITEM_DAY_BOX = 63, /* 42 boxes for days */
- GNOME_MONTH_ITEM_DAY_LABEL = 105, /* 42 labels for days */
- GNOME_MONTH_ITEM_LAST = 147 /* total number of items */
-} GnomeMonthItemChild;
-
-
-#define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ())
-#define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem))
-#define GNOME_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_MONTH_ITEM, GnomeMonthItemClass))
-#define GNOME_IS_MONTH_ITEM(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_MONTH_ITEM))
-#define GNOME_IS_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_MONTH_ITEM))
-
-
-typedef struct _GnomeMonthItem GnomeMonthItem;
-typedef struct _GnomeMonthItemClass GnomeMonthItemClass;
-
-struct _GnomeMonthItem {
- GnomeCanvasGroup group;
-
- int year; /* Year to show (full, no two-digit crap) */
- int month; /* Month to show (0-11) */
-
- double x, y; /* Position at anchor */
- double width, height; /* Size of calendar */
- GtkAnchorType anchor; /* Anchor side for calendar */
-
- double head_padding; /* Padding to use between heading lines and text */
- double day_padding; /* Padding to use between day number lines and text */
-
- char *day_names[7]; /* Names to use for the day labels, starting from Sunday */
-
- double head_height; /* Height of the headings row */
- GtkAnchorType head_anchor; /* Anchor side for the heading labels */
-
- GtkAnchorType day_anchor; /* Anchor side for the day number labels */
-
- GnomeCanvasItem **items; /* All the items that make up the calendar */
- int day_numbers[42]; /* The numbers of the days */
-
- int start_on_monday : 1; /* Start the week on Monday? If false, then start from Sunday */
-};
-
-struct _GnomeMonthItemClass {
- GnomeCanvasGroupClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType gnome_month_item_get_type (void);
-
-/* Creates a new month item with the specified group as parent */
-GnomeCanvasItem *gnome_month_item_new (GnomeCanvasGroup *parent);
-
-/* Constructor function useful for derived classes */
-void gnome_month_item_construct (GnomeMonthItem *mitem);
-
-/* Returns the child item defined by the child number (as specified on the GnomeMonthItemChild
- * enumeration above).
- */
-GnomeCanvasItem *gnome_month_item_num2child (GnomeMonthItem *mitem, GnomeMonthItemChild child_num);
-
-/* Returns the number of the specified child item, as defined on the GnomeMonthItemChild enumeration
- * above. If the specified object is not found, it returns -1.
- */
-GnomeMonthItemChild gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child);
-
-/* Returns the number of the day relevant to the specified child item. Day numbers are 1-based. If
- * the specified child is outside the range of displayed days, then it returns 0.
- */
-int gnome_month_item_num2day (GnomeMonthItem *mitem, GnomeMonthItemChild child_num);
-
-/* Returns the index (0-41) of the specified date within the table of days. If the day number is
- * invalid for the current monthly calendar, then -1 is returned.
- */
-int gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
deleted file mode 100644
index 7ba464bd7c..0000000000
--- a/calendar/gui/goto.c
+++ /dev/null
@@ -1,339 +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"
-#include "timeutil.h"
-
-
-static void
-highlight_current_day (GnomeMonthItem *mitem)
-{
- struct tm *tm;
- time_t t;
- GnomeCanvasItem *label;
- int i;
-
- t = time (NULL);
- tm = localtime (&t);
-
- /* First clear all the days to normal */
-
- for (i = 0; i < 42; i++) {
- label = gnome_month_item_num2child (mitem, i + GNOME_MONTH_ITEM_DAY_LABEL);
- gnome_canvas_item_set (label,
- "fill_color", "black",
- NULL);
- }
-
- /* Highlight the current day, if appropriate */
-
- if ((mitem->year == (tm->tm_year + 1900)) && (mitem->month == tm->tm_mon)) {
- i = gnome_month_item_day2index (mitem, tm->tm_mday);
- label = gnome_month_item_num2child (mitem, i + GNOME_MONTH_ITEM_DAY_LABEL);
- gnome_canvas_item_set (label,
- "fill_color", "blue",
- NULL);
- }
-}
-
-/* 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);
-}
-
-/* Event handler for day groups in the month item. A button press makes the calendar jump to the
- * selected day and destroys the Go-to dialog box. Days are prelighted as appropriate on
- * enter_notify and leave_notify events.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- GtkWidget *dialog;
- GnomeCalendar *gcal;
- GnomeMonthItem *mitem;
- GnomeCanvasItem *box;
- int child_num, day;
-
- dialog = GTK_WIDGET (data);
- gcal = gtk_object_get_data (GTK_OBJECT (dialog), "gnome_calendar");
- mitem = gtk_object_get_data (GTK_OBJECT (dialog), "month_item");
-
- child_num = gnome_month_item_child2num (mitem, item);
- day = gnome_month_item_num2day (mitem, child_num);
-
- if (day == 0)
- return FALSE;
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if ((event->button.button == 1) && (day != 0)) {
- gnome_calendar_goto (gcal, time_from_day (mitem->year, mitem->month, day));
- gtk_widget_destroy (dialog);
- }
- break;
-
- case GDK_ENTER_NOTIFY:
- box = gnome_month_item_num2child (mitem, child_num - GNOME_MONTH_ITEM_DAY_GROUP + GNOME_MONTH_ITEM_DAY_BOX);
- gnome_canvas_item_set (box,
- "fill_color", "#ea60ea60ea60",
- NULL);
- break;
-
- case GDK_LEAVE_NOTIFY:
- box = gnome_month_item_num2child (mitem, child_num - GNOME_MONTH_ITEM_DAY_GROUP + GNOME_MONTH_ITEM_DAY_BOX);
- gnome_canvas_item_set (box,
- "fill_color", "#d6d6d6d6d6d6",
- NULL);
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* 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;
- int i;
- GnomeCanvasItem *day_group;
-
- 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);
-
- /* Bind the day groups to our event handler */
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), i + GNOME_MONTH_ITEM_DAY_GROUP);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- dialog);
- }
-
- return canvas;
-}
-
-static void
-goto_today (GtkWidget *widget, gpointer data)
-{
- GtkWidget *dialog;
- GnomeCalendar *gcal;
-
- dialog = GTK_WIDGET (data);
- gcal = gtk_object_get_data (GTK_OBJECT (dialog), "gnome_calendar");
-
- gnome_calendar_goto_today (gcal);
- gtk_widget_destroy (dialog);
-}
-
-/* Creates a "goto date" dialog and runs it */
-void
-goto_dialog (GnomeCalendar *gcal)
-{
- GtkWidget *dialog;
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *w;
- struct tm *tm;
-
- tm = localtime (&gcal->current_display);
-
- dialog = gnome_dialog_new (_("Go to date"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gtk_object_set_data (GTK_OBJECT (dialog), "gnome_calendar", gcal);
-
- 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);
-
- /* Today button */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- w = gtk_button_new_with_label (_("Go to today"));
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) goto_today,
- dialog);
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Run! */
-
- gnome_dialog_set_modal (GNOME_DIALOG (dialog));
- gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE);
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (gcal));
- gtk_widget_show (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 9240acdfc1..0000000000
--- a/calendar/gui/main.c
+++ /dev/null
@@ -1,700 +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"
-#include "goto.xpm"
-
-#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_today (gcal);
-}
-
-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 (N_("Go to"), N_("Go to a specific date"), goto_clicked, goto_xpm),
-
- 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 9240acdfc1..0000000000
--- a/calendar/main.c
+++ /dev/null
@@ -1,700 +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"
-#include "goto.xpm"
-
-#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_today (gcal);
-}
-
-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 (N_("Go to"), N_("Go to a specific date"), goto_clicked, goto_xpm),
-
- 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 33aff8cda8..0000000000
--- a/calendar/pcs/calobj.c
+++ /dev/null
@@ -1,1248 +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);
- } else
- ical->palarm.data = g_strdup ("");
- }
- }
-
- /* malarm */
- ical->malarm.type = ALARM_MAIL;
- ical->malarm.enabled = 0;
- if (has (o, VCMAlarmProp)){
- ical->malarm.type = ALARM_MAIL;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->malarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCEmailAddressProp))){
- ical->malarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->malarm.data = g_strdup ("");
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_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 c27a8dbd45..0000000000
--- a/calendar/timeutil.c
+++ /dev/null
@@ -1,336 +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_from_day (int year, int month, int day)
-{
- struct tm tm;
-
- memset (&tm, 0, sizeof (tm));
- tm.tm_year = year - 1900;
- tm.tm_mon = month;
- tm.tm_mday = day;
-
- 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 dc0aa522bf..0000000000
--- a/calendar/timeutil.h
+++ /dev/null
@@ -1,50 +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);
-
-/* Converts the specified date to a time_t at the start of the specified day */
-time_t time_from_day (int year, int month, int day);
-
-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