From f3a444674878385818f5fb13f5e65bae9a50eca3 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Thu, 14 Mar 2002 19:08:20 +0000 Subject: add all day event editor mode 2002-03-14 JP Rosevear * idl/evolution-calendar.idl: add all day event editor mode * gui/component-factory.c: clean up exception handling (sc_user_create_new_item_cb): support the all day event id (create_object): add a user creatable all day appointment item * gui/comp-editor-factory.c (get_default_event): get a default event either all day or starting at the top of the hour (get_default_task): get a default task (edit_new): support the all day event mode * gui/calendar-commands.c: remove unused functions/verbs svn path=/trunk/; revision=16157 --- calendar/gui/calendar-commands.c | 51 ------------------------------- calendar/gui/calendar-component.c | 52 ++++++++++++++++++-------------- calendar/gui/comp-editor-factory.c | 61 +++++++++++++++++++++++++------------- calendar/gui/component-factory.c | 52 ++++++++++++++++++-------------- 4 files changed, 101 insertions(+), 115 deletions(-) (limited to 'calendar/gui') diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index b72f6b4cdb..4aa9eb7248 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -67,47 +67,6 @@ typedef struct { guint taskpad_focused : 1; } FocusData; -/* Callback for the new appointment command */ -static void -new_appointment_cb (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - gnome_calendar_new_appointment (gcal); -} - -static void -new_meeting_cb (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - time_t dtstart, dtend; - - gcal = GNOME_CALENDAR (data); - gnome_calendar_get_current_time_range (gcal, &dtstart, &dtend); - gnome_calendar_new_appointment_for (gcal, dtstart, dtend, FALSE, TRUE); -} - -static void -new_event_cb (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - time_t dtstart, dtend; - - gcal = GNOME_CALENDAR (data); - gnome_calendar_get_current_time_range (gcal, &dtstart, &dtend); - gnome_calendar_new_appointment_for (gcal, dtstart, dtend, TRUE, FALSE); -} - -static void -new_task_cb (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - gnome_calendar_new_task (gcal); -} - /* Prints the calendar at its current view and time range */ static void print (GnomeCalendar *gcal, gboolean preview) @@ -667,11 +626,6 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("CalendarPrint", file_print_cb), BONOBO_UI_VERB ("CalendarPrintPreview", file_print_preview_cb), - BONOBO_UI_VERB ("CalendarNewAppointment", new_appointment_cb), - BONOBO_UI_VERB ("CalendarNewMeeting", new_meeting_cb), - BONOBO_UI_VERB ("CalendarNewEvent", new_event_cb), - BONOBO_UI_VERB ("CalendarNewTask", new_task_cb), - BONOBO_UI_VERB ("Cut", cut_cmd), BONOBO_UI_VERB ("Copy", copy_cmd), BONOBO_UI_VERB ("Paste", paste_cmd), @@ -703,11 +657,6 @@ static EPixmap pixmaps [] = E_PIXMAP ("/menu/EditPlaceholder/Edit/Delete", "evolution-trash-mini.png"), E_PIXMAP ("/menu/File/Print/Print", "print.xpm"), E_PIXMAP ("/menu/File/Print/PrintPreview", "print-preview.xpm"), - E_PIXMAP ("/menu/ComponentActionsPlaceholder/Actions/NewAppointment", "new_appointment.xpm"), - E_PIXMAP ("/menu/ComponentActionsPlaceholder/Actions/NewEvent", "new_all_day_event.png"), - E_PIXMAP ("/menu/ComponentActionsPlaceholder/Actions/NewMeeting", "meeting.xpm"), - E_PIXMAP ("/menu/ComponentActionsPlaceholder/Actions/NewTask", "new_task-16.png"), - E_PIXMAP ("/menu/Tools/ComponentPlaceholder/CalendarSettings", "configure_16_calendar.xpm"), E_PIXMAP ("/menu/View/ViewBegin/Goto", "goto-16.png"), E_PIXMAP ("/Toolbar/New", "buttons/new_appointment.png"), diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index c601011250..211a79fa39 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -32,6 +32,7 @@ #include #include +#include #include "evolution-shell-component.h" #include "calendar-offline-handler.h" #include "component-factory.h" @@ -53,6 +54,7 @@ /* IDs for user creatable items */ #define CREATE_EVENT_ID "event" +#define CREATE_ALLDAY_EVENT_ID "allday-event" #define CREATE_MEETING_ID "meeting" #define CREATE_TASK_ID "task" @@ -157,7 +159,7 @@ stop_alarms (GnomeVFSURI *uri) CORBA_exception_init (&ev); an = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_AlarmNotify", 0, NULL, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { + if (BONOBO_EX (&ev)) { g_message ("stop_alarms(): Could not activate the alarm notification service"); CORBA_exception_free (&ev); return; @@ -173,28 +175,22 @@ stop_alarms (GnomeVFSURI *uri) GNOME_Evolution_Calendar_AlarmNotify_removeCalendar (an, str_uri, &ev); g_free (str_uri); - if (ev._major == CORBA_USER_EXCEPTION) { - char *ex_id; - - ex_id = CORBA_exception_id (&ev); - if (strcmp (ex_id, ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI) == 0) - g_message ("stop_alarms(): Invalid URI reported from the " - "alarm notification service"); - else if (strcmp (ex_id, ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound) == 0) { - /* This is OK; the service may not have loaded that calendar */ - } - } else if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI)) { + g_message ("stop_alarms(): Invalid URI reported from the alarm notification service"); + } else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound)) { + /* This is OK; the service may not have loaded that calendar */ + } else if (BONOBO_EX (&ev)) { g_message ("stop_alarms(): Could not issue the removeCalendar request"); - + } + CORBA_exception_free (&ev); /* Get rid of the service */ CORBA_exception_init (&ev); bonobo_object_release_unref (an, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("stop_alarms(): Could not unref the alarm notification service"); - CORBA_exception_free (&ev); } @@ -218,7 +214,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener of " "an unsupported folder type"); @@ -264,7 +260,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener " "of an invalid URI"); @@ -292,7 +288,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_OK, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener about success"); CORBA_exception_free (&ev); @@ -305,7 +301,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener about failure"); CORBA_exception_free (&ev); @@ -540,6 +536,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co switch (type) { case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT: + case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT: case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING: vtype = CAL_COMPONENT_EVENT; break; @@ -559,7 +556,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co factory = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_CompEditorFactory", 0, NULL, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { + if (BONOBO_EX (&ev)) { g_message ("create_component(): Could not activate the component editor factory"); CORBA_exception_free (&ev); g_free (real_uri); @@ -572,7 +569,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co CORBA_exception_init (&ev); GNOME_Evolution_Calendar_CompEditorFactory_editNew (factory, real_uri, type, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("create_component(): Exception while creating the component"); CORBA_exception_free (&ev); @@ -582,7 +579,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co CORBA_exception_init (&ev); bonobo_object_release_unref (factory, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("create_component(): Could not unref the calendar component factory"); CORBA_exception_free (&ev); @@ -602,6 +599,13 @@ sc_user_create_new_item_cb (EvolutionShellComponent *shell_component, else create_component (NULL, GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT); + } else if (strcmp (id, CREATE_ALLDAY_EVENT_ID) == 0) { + if (strcmp (parent_folder_type, FOLDER_CALENDAR) == 0) + create_component (parent_folder_physical_uri, + GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT); + else + create_component (NULL, + GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT); } else if (strcmp (id, CREATE_MEETING_ID) == 0) { if (strcmp (parent_folder_type, FOLDER_CALENDAR) == 0) create_component (parent_folder_physical_uri, @@ -690,6 +694,10 @@ create_object (void) _("New task"), _("_Task"), 't', "new_task-16.png"); + add_creatable_item (shell_component, CREATE_ALLDAY_EVENT_ID, + _("New All Day Appointment"), _("All _Day Appointment"), + 'd', "new_all_day_event.png"); + add_creatable_item (shell_component, CREATE_EVENT_ID, _("New appointment"), _("_Appointment"), 'a', "new_appointment.xpm"); diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c index fbf81248a7..54f0f00569 100644 --- a/calendar/gui/comp-editor-factory.c +++ b/calendar/gui/comp-editor-factory.c @@ -347,34 +347,54 @@ edit_existing (OpenClient *oc, const char *uid) * type. */ static CalComponent * -get_default_component (CalComponentVType vtype) +get_default_event (gboolean all_day) { CalComponent *comp; + struct icaltimetype itt; + CalComponentDateTime dt; + char *location; + icaltimezone *zone; - if (vtype == CAL_COMPONENT_EVENT) { - struct icaltimetype itt; - CalComponentDateTime dt; - char *location; - icaltimezone *zone; + comp = cal_comp_event_new_with_defaults (); - comp = cal_comp_event_new_with_defaults (); + location = calendar_config_get_timezone (); + zone = icaltimezone_get_builtin_timezone (location); + if (all_day) { itt = icaltime_today (); dt.value = &itt; - location = calendar_config_get_timezone (); - zone = icaltimezone_get_builtin_timezone (location); dt.tzid = icaltimezone_get_tzid (zone); - + cal_component_set_dtstart (comp, &dt); - cal_component_set_dtend (comp, &dt); - - cal_component_commit_sequence (comp); + cal_component_set_dtend (comp, &dt); } else { - comp = cal_component_new (); - cal_component_set_new_vtype (comp, vtype); + itt = icaltime_current_time_with_zone (zone); + itt.hour++; + itt.minute = 0; + itt.second = 0; + + dt.value = &itt; + dt.tzid = icaltimezone_get_tzid (zone); + + cal_component_set_dtstart (comp, &dt); + itt.hour++; + cal_component_set_dtend (comp, &dt); } + cal_component_commit_sequence (comp); + + return comp; +} + +static CalComponent * +get_default_task (void) +{ + CalComponent *comp; + + comp = cal_component_new (); + cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); + return comp; } @@ -385,25 +405,26 @@ edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompE CalComponent *comp; Component *c; CompEditor *editor; - CalComponentVType vtype; switch (type) { case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT: case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING: editor = COMP_EDITOR (event_editor_new ()); - vtype = CAL_COMPONENT_EVENT; + comp = get_default_event (FALSE); + break; + case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT: + editor = COMP_EDITOR (event_editor_new ()); + comp = get_default_event (TRUE); break; case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_TODO: editor = COMP_EDITOR (task_editor_new ()); - vtype = CAL_COMPONENT_TODO; + comp = get_default_task (); break; default: g_assert_not_reached (); return; } - comp = get_default_component (vtype); - c = g_new (Component, 1); c->parent = oc; cal_component_get_uid (comp, &c->uid); diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c index c601011250..211a79fa39 100644 --- a/calendar/gui/component-factory.c +++ b/calendar/gui/component-factory.c @@ -32,6 +32,7 @@ #include #include +#include #include "evolution-shell-component.h" #include "calendar-offline-handler.h" #include "component-factory.h" @@ -53,6 +54,7 @@ /* IDs for user creatable items */ #define CREATE_EVENT_ID "event" +#define CREATE_ALLDAY_EVENT_ID "allday-event" #define CREATE_MEETING_ID "meeting" #define CREATE_TASK_ID "task" @@ -157,7 +159,7 @@ stop_alarms (GnomeVFSURI *uri) CORBA_exception_init (&ev); an = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_AlarmNotify", 0, NULL, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { + if (BONOBO_EX (&ev)) { g_message ("stop_alarms(): Could not activate the alarm notification service"); CORBA_exception_free (&ev); return; @@ -173,28 +175,22 @@ stop_alarms (GnomeVFSURI *uri) GNOME_Evolution_Calendar_AlarmNotify_removeCalendar (an, str_uri, &ev); g_free (str_uri); - if (ev._major == CORBA_USER_EXCEPTION) { - char *ex_id; - - ex_id = CORBA_exception_id (&ev); - if (strcmp (ex_id, ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI) == 0) - g_message ("stop_alarms(): Invalid URI reported from the " - "alarm notification service"); - else if (strcmp (ex_id, ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound) == 0) { - /* This is OK; the service may not have loaded that calendar */ - } - } else if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI)) { + g_message ("stop_alarms(): Invalid URI reported from the alarm notification service"); + } else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound)) { + /* This is OK; the service may not have loaded that calendar */ + } else if (BONOBO_EX (&ev)) { g_message ("stop_alarms(): Could not issue the removeCalendar request"); - + } + CORBA_exception_free (&ev); /* Get rid of the service */ CORBA_exception_init (&ev); bonobo_object_release_unref (an, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("stop_alarms(): Could not unref the alarm notification service"); - CORBA_exception_free (&ev); } @@ -218,7 +214,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener of " "an unsupported folder type"); @@ -264,7 +260,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener " "of an invalid URI"); @@ -292,7 +288,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_OK, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener about success"); CORBA_exception_free (&ev); @@ -305,7 +301,7 @@ remove_folder (EvolutionShellComponent *shell_component, GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("remove_folder(): Could not notify the listener about failure"); CORBA_exception_free (&ev); @@ -540,6 +536,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co switch (type) { case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT: + case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT: case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING: vtype = CAL_COMPONENT_EVENT; break; @@ -559,7 +556,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co factory = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_CompEditorFactory", 0, NULL, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { + if (BONOBO_EX (&ev)) { g_message ("create_component(): Could not activate the component editor factory"); CORBA_exception_free (&ev); g_free (real_uri); @@ -572,7 +569,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co CORBA_exception_init (&ev); GNOME_Evolution_Calendar_CompEditorFactory_editNew (factory, real_uri, type, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("create_component(): Exception while creating the component"); CORBA_exception_free (&ev); @@ -582,7 +579,7 @@ create_component (const char *uri, GNOME_Evolution_Calendar_CompEditorFactory_Co CORBA_exception_init (&ev); bonobo_object_release_unref (factory, &ev); - if (ev._major != CORBA_NO_EXCEPTION) + if (BONOBO_EX (&ev)) g_message ("create_component(): Could not unref the calendar component factory"); CORBA_exception_free (&ev); @@ -602,6 +599,13 @@ sc_user_create_new_item_cb (EvolutionShellComponent *shell_component, else create_component (NULL, GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT); + } else if (strcmp (id, CREATE_ALLDAY_EVENT_ID) == 0) { + if (strcmp (parent_folder_type, FOLDER_CALENDAR) == 0) + create_component (parent_folder_physical_uri, + GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT); + else + create_component (NULL, + GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT); } else if (strcmp (id, CREATE_MEETING_ID) == 0) { if (strcmp (parent_folder_type, FOLDER_CALENDAR) == 0) create_component (parent_folder_physical_uri, @@ -690,6 +694,10 @@ create_object (void) _("New task"), _("_Task"), 't', "new_task-16.png"); + add_creatable_item (shell_component, CREATE_ALLDAY_EVENT_ID, + _("New All Day Appointment"), _("All _Day Appointment"), + 'd', "new_all_day_event.png"); + add_creatable_item (shell_component, CREATE_EVENT_ID, _("New appointment"), _("_Appointment"), 'a', "new_appointment.xpm"); -- cgit v1.2.3