diff options
author | JP Rosevear <jpr@ximian.com> | 2003-11-17 00:34:39 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2003-11-17 00:34:39 +0800 |
commit | 80b2e4700bb8b06089c8b36685366efd9d34b161 (patch) | |
tree | 48cfdb39dd3860cfaf6a7f28daa251fd9b6b8b65 | |
parent | dccfa1bc639a9d622e203ec0ad4f221487bb1a5f (diff) | |
download | gsoc2013-evolution-80b2e4700bb8b06089c8b36685366efd9d34b161.tar gsoc2013-evolution-80b2e4700bb8b06089c8b36685366efd9d34b161.tar.gz gsoc2013-evolution-80b2e4700bb8b06089c8b36685366efd9d34b161.tar.bz2 gsoc2013-evolution-80b2e4700bb8b06089c8b36685366efd9d34b161.tar.lz gsoc2013-evolution-80b2e4700bb8b06089c8b36685366efd9d34b161.tar.xz gsoc2013-evolution-80b2e4700bb8b06089c8b36685366efd9d34b161.tar.zst gsoc2013-evolution-80b2e4700bb8b06089c8b36685366efd9d34b161.zip |
set up a event to be edited (impl_requestCreateItem): implement
2003-11-16 JP Rosevear <jpr@ximian.com>
* gui/calendar-component.c (get_default_event): set up a event to
be edited
(impl_requestCreateItem): implement
svn path=/trunk/; revision=23371
-rw-r--r-- | calendar/ChangeLog | 6 | ||||
-rw-r--r-- | calendar/gui/calendar-component.c | 101 |
2 files changed, 90 insertions, 17 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a40fcdf9a6..535d877c09 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,9 @@ +2003-11-16 JP Rosevear <jpr@ximian.com> + + * gui/calendar-component.c (get_default_event): set up a event to + be edited + (impl_requestCreateItem): implement + 2003-11-14 JP Rosevear <jpr@ximian.com> * gui/*.[hc]: include e-source* from e-d-s diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 24880e98d0..7e89f6f0fa 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -26,38 +26,31 @@ #endif #include <string.h> - +#include <errno.h> +#include <bonobo/bonobo-control.h> +#include <bonobo/bonobo-i18n.h> +#include <bonobo/bonobo-exception.h> #include "calendar-config.h" #include "calendar-component.h" #include "calendar-commands.h" #include "gnome-cal.h" #include "migration.h" +#include "e-comp-editor-registry.h" +#include "comp-util.h" #include "dialogs/new-calendar.h" - +#include "dialogs/comp-editor.h" +#include "dialogs/event-editor.h" #include "widgets/misc/e-source-selector.h" -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkimagemenuitem.h> -#include <gtk/gtkmessagedialog.h> -#include <gtk/gtkstock.h> -#include <gal/util/e-util.h> - -#include <errno.h> - /* IDs for user creatable items */ #define CREATE_EVENT_ID "event" #define CREATE_MEETING_ID "meeting" #define CREATE_ALLDAY_EVENT_ID "allday-event" - #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; - struct _CalendarComponentPrivate { char *config_directory; @@ -71,6 +64,7 @@ struct _CalendarComponentPrivate { guint selected_not; }; +extern ECompEditorRegistry *comp_editor_registry; /* Utility functions. */ @@ -191,6 +185,46 @@ update_selection (CalendarComponent *calendar_component) g_slist_free (uids_selected); } +/* FIXME This is duplicated from comp-editor-factory.c, should it go in comp-util? */ +static ECalComponent * +get_default_event (ECal *client, gboolean all_day) +{ + ECalComponent *comp; + struct icaltimetype itt; + ECalComponentDateTime dt; + char *location; + icaltimezone *zone; + + comp = cal_comp_event_new_with_defaults (client); + + location = calendar_config_get_timezone (); + zone = icaltimezone_get_builtin_timezone (location); + + if (all_day) { + itt = icaltime_from_timet_with_zone (time (NULL), 1, zone); + + dt.value = &itt; + dt.tzid = icaltimezone_get_tzid (zone); + + e_cal_component_set_dtstart (comp, &dt); + e_cal_component_set_dtend (comp, &dt); + } else { + itt = icaltime_current_time_with_zone (zone); + icaltime_adjust (&itt, 0, 1, -itt.minute, -itt.second); + + dt.value = &itt; + dt.tzid = icaltimezone_get_tzid (zone); + + e_cal_component_set_dtstart (comp, &dt); + icaltime_adjust (&itt, 0, 1, 0, 0); + e_cal_component_set_dtend (comp, &dt); + } + + e_cal_component_commit_sequence (comp); + + return comp; +} + /* Callbacks. */ static void add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, @@ -480,9 +514,42 @@ impl_requestCreateItem (PortableServer_Servant servant, const CORBA_char *item_type_name, CORBA_Environment *ev) { - /* FIXME: fill me in */ + CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant)); + CalendarComponentPrivate *priv; + ECal *ecal; + ECalComponent *comp; + EventEditor *editor; + gboolean is_meeting = FALSE; + + priv = calendar_component->priv; + + ecal = gnome_calendar_get_default_client (priv->calendar); + if (!ecal) { + /* FIXME We should display a gui dialog or something */ + bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType); + g_warning (G_STRLOC ": No default client"); + } + + editor = event_editor_new (ecal); + + if (strcmp (item_type_name, CREATE_EVENT_ID) == 0) { + comp = get_default_event (ecal, FALSE); + } else if (strcmp (item_type_name, CREATE_ALLDAY_EVENT_ID) == 0) { + comp = get_default_event (ecal, TRUE); + } else if (strcmp (item_type_name, CREATE_MEETING_ID) == 0) { + comp = get_default_event (ecal, FALSE); + is_meeting = TRUE; + } else { + bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType); + return; + } + + comp_editor_edit_comp (COMP_EDITOR (editor), comp); + if (is_meeting) + event_editor_show_meeting (editor); + comp_editor_focus (COMP_EDITOR (editor)); - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL); + e_comp_editor_registry_add (comp_editor_registry, COMP_EDITOR (editor), TRUE); } |