From 19150e7c7b614544188f93dbffd748a2846d2a1b Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Thu, 1 Jun 2000 00:48:01 +0000 Subject: Added a hash table to map calendar objects to their respective event 2000-05-31 Federico Mena Quintero * gui/gnome-cal.h (GnomeCalendar): Added a hash table to map calendar objects to their respective event editors. * gui/gnome-cal.c (gnome_calendar_init): Create the object_editor_hash. (gnome_calendar_destroy): Free the object_editor_hash. (gnome_calendar_edit_object): New function to centralize the launching of event editors; if one already exists for a particular calendar object, we just raise its window. (edit): Use gnome_calendar_edit_object(). * gui/calendar-commands.c (display_objedit): Use gnome_calendar_edit_object(). (display_objedit_today): Likewise. * gui/e-day-view.c (e_day_view_on_new_appointment): Likewise. (e_day_view_on_edit_appointment): Likewise. * gui/e-week-view.c (e_week_view_on_new_appointment): Likewise. (e_week_view_on_edit_appointment): Likewise. * gui/event-editor.c (event_editor_new): Do not take in an iCalObject; rather provide an event_editor_set_ical_object() function. We need this because a single editor may be switched between different calendar objects. Also, do not show the event editor; leave it up to the client code. (event_editor_construct): Likewise. (clear_widgets): New function to clear the widgets to default values. (fill_widgets): New function to fill in the widgets from the iCalObject. We don't do this in init_widgets() anymore. (free_exception_clist_data): New function to free the exceptions clist data. We were leaking the row data. (init_widgets): Hook to the destroy signal of the exceptions clist. (event_editor_set_ical_object): New function. Now it also makes a copy of the calendar object for the event editor; clients do not need to copy it anymore. (event_editor_destroy): Unref the UI handler as well. (event_editor_class_init): New "ical_object_released" signal to notify the parent that we are no longer editing the calendar object. (make_title_from_ico): Handle NULL objects. * gui/event-editor.h (EventEditor): Removed fields that are no longer used. svn path=/trunk/; revision=3317 --- calendar/gui/calendar-commands.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'calendar/gui/calendar-commands.c') diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 5726f45362..afc8580d09 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -20,7 +20,6 @@ #include #include #include -#include "eventedit.h" #include "gnome-cal.h" #include "calendar-commands.h" @@ -185,28 +184,44 @@ about_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) static void display_objedit (BonoboUIHandler *uih, void *user_data, const char *path) { - GtkWidget *ee; + GnomeCalendar *gcal; iCalObject *ico; - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - ico = ical_new ("", user_name, ""); - ico->new = 1; + gcal = GNOME_CALENDAR (user_data); + ico = ical_new ("", user_name, ""); + ico->new = TRUE; gnome_calendar_get_current_time_range (gcal, &ico->dtstart, &ico->dtend); - ee = event_editor_new (gcal, ico); - gtk_widget_show (ee); + gnome_calendar_edit_object (gcal, ico); + ical_object_unref (ico); } static void display_objedit_today (BonoboUIHandler *uih, void *user_data, const char *path) { - GtkWidget *ee; - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); + GnomeCalendar *gcal; + iCalObject *ico; + struct tm tm; + + gcal = GNOME_CALENDAR (user_data); + + ico = ical_new ("", user_name, ""); + ico->new = TRUE; + ico->dtstart = time (NULL); + + tm = *localtime (&ico->dtstart); + tm.tm_hour++; + ico->dtend = mktime (&tm); + if (ico->dtend == -1) { + g_message ("display_objedit_today(): mktime() generated -1 invalid time!"); + ical_object_unref (ico); + return; + } - ee = event_editor_new (gcal, NULL); - gtk_widget_show (ee); + gnome_calendar_edit_object (gcal, ico); + ical_object_unref (ico); } void -- cgit v1.2.3