aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2004-01-15 21:46:47 +0800
committerRadek Doulik <rodo@src.gnome.org>2004-01-15 21:46:47 +0800
commitf9377c48533c15010ef9a76c8d6126ebe4732f88 (patch)
treec55b25b4f1c84f7367698c8f9a74b7cce794f9b9
parent4edeba938a920fe2501776031090a479bc9dee67 (diff)
downloadgsoc2013-evolution-f9377c48533c15010ef9a76c8d6126ebe4732f88.tar.gz
gsoc2013-evolution-f9377c48533c15010ef9a76c8d6126ebe4732f88.tar.zst
gsoc2013-evolution-f9377c48533c15010ef9a76c8d6126ebe4732f88.zip
fixes #23281, some refactoring and list view get_selected_time_range
implementation 2004-01-15 Radek Doulik <rodo@ximian.com> * gui/calendar-component.c (impl_requestCreateItem): merge with JP's changes 2004-01-14 Radek Doulik <rodo@ximian.com> * gui/e-cal-list-view.c (e_cal_list_view_get_selected_time_range): new implementation, use time range from selected event * gui/e-cal-view.c (e_calendar_view_get_selected_time_range): return gboolean, TRUE if requested time was set, FALSE otherwise (e_calendar_view_new_appointment_full): use current time if time range is unavailable * gui/calendar-component.c (impl_requestCreateItem): use e_calendar_view_new_appointment_full instead of cal_comp_event_new_with_current_time * gui/e-cal-view.c (e_calendar_view_new_appointment_full): new helper function * gui/comp-editor-factory.c (edit_new): use cal_comp_event_new_with_current_time * gui/calendar-component.c (impl_requestCreateItem): use cal_comp_event_new_with_current_time * gui/comp-util.c (cal_comp_event_new_with_current_time): new function, cut'n'pasted from get_default_event (calendar-component.c and comp-editor-factory.c) svn path=/trunk/; revision=24238
-rw-r--r--calendar/ChangeLog32
-rw-r--r--calendar/gui/calendar-component.c94
-rw-r--r--calendar/gui/comp-editor-factory.c46
-rw-r--r--calendar/gui/comp-util.c43
-rw-r--r--calendar/gui/comp-util.h1
-rw-r--r--calendar/gui/e-cal-list-view.c46
-rw-r--r--calendar/gui/e-cal-view.c40
-rw-r--r--calendar/gui/e-cal-view.h15
-rw-r--r--calendar/gui/e-calendar-view.c40
-rw-r--r--calendar/gui/e-calendar-view.h15
-rw-r--r--calendar/gui/e-day-view.c6
-rw-r--r--calendar/gui/e-week-view.c6
12 files changed, 226 insertions, 158 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 923e1512e3..52691a0e08 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,35 @@
+2004-01-15 Radek Doulik <rodo@ximian.com>
+
+ * gui/calendar-component.c (impl_requestCreateItem): merge with
+ JP's changes
+
+2004-01-14 Radek Doulik <rodo@ximian.com>
+
+ * gui/e-cal-list-view.c (e_cal_list_view_get_selected_time_range):
+ new implementation, use time range from selected event
+
+ * gui/e-cal-view.c (e_calendar_view_get_selected_time_range):
+ return gboolean, TRUE if requested time was set, FALSE otherwise
+ (e_calendar_view_new_appointment_full): use current time if time
+ range is unavailable
+
+ * gui/calendar-component.c (impl_requestCreateItem): use
+ e_calendar_view_new_appointment_full instead of
+ cal_comp_event_new_with_current_time
+
+ * gui/e-cal-view.c (e_calendar_view_new_appointment_full): new
+ helper function
+
+ * gui/comp-editor-factory.c (edit_new): use
+ cal_comp_event_new_with_current_time
+
+ * gui/calendar-component.c (impl_requestCreateItem): use
+ cal_comp_event_new_with_current_time
+
+ * gui/comp-util.c (cal_comp_event_new_with_current_time): new
+ function, cut'n'pasted from get_default_event
+ (calendar-component.c and comp-editor-factory.c)
+
2004-01-14 JP Rosevear <jpr@ximian.com>
* gui/tasks-component.c (impl_requestCreateItem): new utility
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 194d4ec563..6baccb487b 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -31,6 +31,7 @@
#include <bonobo/bonobo-i18n.h>
#include <bonobo/bonobo-exception.h>
#include "e-pub-utils.h"
+#include "e-cal-view.h"
#include "calendar-config-keys.h"
#include "calendar-config.h"
#include "calendar-component.h"
@@ -228,48 +229,6 @@ update_primary_selection (CalendarComponent *calendar_component)
}
}
-/* 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);
-
- g_return_val_if_fail (comp, NULL);
-
- 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,
@@ -808,30 +767,34 @@ setup_create_ecal (CalendarComponent *calendar_component)
static void
create_new_event (CalendarComponent *calendar_component, gboolean is_allday, gboolean is_meeting, CORBA_Environment *ev)
{
- CalendarComponentPrivate *priv;
- ECalComponent *comp;
- EventEditor *editor;
+ CalendarComponentPrivate *priv = calendar_component->priv;
gboolean read_only;
-
- priv = calendar_component->priv;
-
+ ECalendarView *view;
+
if (!setup_create_ecal (calendar_component)) {
bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
return;
}
-
- if (!e_cal_is_read_only (priv->create_ecal, &read_only, NULL) || read_only);
+ if (!e_cal_is_read_only (priv->create_ecal, &read_only, NULL) || read_only)
return;
- editor = event_editor_new (priv->create_ecal);
- comp = get_default_event (priv->create_ecal, is_allday);
+ view = E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (priv->calendar));
+ if (view)
+ e_calendar_view_new_appointment_full (view, is_allday, is_meeting);
+ else {
+ ECalComponent *comp;
+ EventEditor *editor;
+
+ editor = event_editor_new (priv->create_ecal);
+ comp = cal_comp_event_new_with_current_time (priv->create_ecal, is_allday);
- comp_editor_edit_comp (COMP_EDITOR (editor), comp);
- if (is_meeting)
- event_editor_show_meeting (editor);
- comp_editor_focus (COMP_EDITOR (editor));
+ comp_editor_edit_comp (COMP_EDITOR (editor), comp);
+ if (is_meeting)
+ event_editor_show_meeting (editor);
+ comp_editor_focus (COMP_EDITOR (editor));
- e_comp_editor_registry_add (comp_editor_registry, COMP_EDITOR (editor), TRUE);
+ e_comp_editor_registry_add (comp_editor_registry, COMP_EDITOR (editor), TRUE);
+ }
}
static void
@@ -840,24 +803,19 @@ impl_requestCreateItem (PortableServer_Servant servant,
CORBA_Environment *ev)
{
CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant));
- CalendarComponentPrivate *priv;
-
- priv = calendar_component->priv;
- if (strcmp (item_type_name, CREATE_EVENT_ID) == 0) {
+ if (strcmp (item_type_name, CREATE_EVENT_ID) == 0)
create_new_event (calendar_component, FALSE, FALSE, ev);
- } else if (strcmp (item_type_name, CREATE_ALLDAY_EVENT_ID) == 0) {
+ else if (strcmp (item_type_name, CREATE_ALLDAY_EVENT_ID) == 0)
create_new_event (calendar_component, TRUE, FALSE, ev);
- } else if (strcmp (item_type_name, CREATE_MEETING_ID) == 0) {
+ else if (strcmp (item_type_name, CREATE_MEETING_ID) == 0)
create_new_event (calendar_component, FALSE, TRUE, ev);
- } else if (strcmp (item_type_name, CREATE_CALENDAR_ID) == 0) {
- calendar_setup_new_calendar (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (priv->calendar))));
- } else {
+ else if (strcmp (item_type_name, CREATE_CALENDAR_ID) == 0)
+ calendar_setup_new_calendar (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (calendar_component->priv->calendar))));
+ else
bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType);
- }
}
-
/* Initialization. */
static void
diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c
index 04a53b30b3..e3904bbbf2 100644
--- a/calendar/gui/comp-editor-factory.c
+++ b/calendar/gui/comp-editor-factory.c
@@ -291,48 +291,6 @@ edit_existing (OpenClient *oc, const char *uid)
e_comp_editor_registry_add (comp_editor_registry, editor, TRUE);
}
-/* Creates a component with the appropriate defaults for the specified component
- * type.
- */
-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;
-}
-
static ECalComponent *
get_default_task (ECal *client)
{
@@ -354,11 +312,11 @@ edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompE
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT:
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING:
editor = COMP_EDITOR (event_editor_new (oc->client));
- comp = get_default_event (oc->client, FALSE);
+ comp = cal_comp_event_new_with_current_time (oc->client, FALSE);
break;
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT:
editor = COMP_EDITOR (event_editor_new (oc->client));
- comp = get_default_event (oc->client, TRUE);
+ comp = cal_comp_event_new_with_current_time (oc->client, TRUE);
break;
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_TODO:
editor = COMP_EDITOR (task_editor_new (oc->client));
diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c
index 170adb0cf5..f08bd100b2 100644
--- a/calendar/gui/comp-util.c
+++ b/calendar/gui/comp-util.c
@@ -24,6 +24,8 @@
#endif
#include <string.h>
+#include <time.h>
+#include "e-cal-view.h"
#include "calendar-config.h"
#include "comp-util.h"
#include "dialogs/delete-comp.h"
@@ -315,6 +317,47 @@ cal_comp_event_new_with_defaults (ECal *client)
}
ECalComponent *
+cal_comp_event_new_with_current_time (ECal *client, gboolean all_day)
+{
+ ECalComponent *comp;
+ struct icaltimetype itt;
+ ECalComponentDateTime dt;
+ char *location;
+ icaltimezone *zone;
+
+ comp = cal_comp_event_new_with_defaults (client);
+
+ g_return_val_if_fail (comp, NULL);
+
+ 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;
+}
+
+ECalComponent *
cal_comp_task_new_with_defaults (ECal *client)
{
ECalComponent *comp;
diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h
index 0f4542aba1..26c7881e99 100644
--- a/calendar/gui/comp-util.h
+++ b/calendar/gui/comp-util.h
@@ -40,6 +40,7 @@ gboolean cal_comp_is_on_server (ECalComponent *comp,
ECal *client);
ECalComponent *cal_comp_event_new_with_defaults (ECal *client);
+ECalComponent *cal_comp_event_new_with_current_time (ECal *client, gboolean all_day);
ECalComponent *cal_comp_task_new_with_defaults (ECal *client);
#endif
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 74973e36f7..f7c6917ac8 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -76,6 +76,7 @@ static void e_cal_list_view_destroy (GtkObject *object);
static void e_cal_list_view_update_query (ECalendarView *cal_view);
static GList *e_cal_list_view_get_selected_events (ECalendarView *cal_view);
+static gboolean e_cal_list_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
static gboolean e_cal_list_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time,
time_t *end_time);
@@ -109,6 +110,7 @@ e_cal_list_view_class_init (ECalListViewClass *class)
widget_class->popup_menu = e_cal_list_view_popup_menu;
view_class->get_selected_events = e_cal_list_view_get_selected_events;
+ view_class->get_selected_time_range = e_cal_list_view_get_selected_time_range;
view_class->get_visible_time_range = e_cal_list_view_get_visible_time_range;
view_class->update_query = e_cal_list_view_update_query;
@@ -430,6 +432,50 @@ e_cal_list_view_on_table_right_click (GtkWidget *table, gint row, gint col, GdkE
return TRUE;
}
+static gboolean
+e_cal_list_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time)
+{
+ GList *selected;
+ icaltimezone *zone;
+
+ selected = e_calendar_view_get_selected_events (cal_view);
+ if (selected) {
+ ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
+ ECalComponentDateTime dtstart, dtend;
+ ECalComponent *comp;
+
+ comp = e_cal_component_new ();
+ e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ if (start_time) {
+ e_cal_component_get_dtstart (comp, &dtstart);
+ if (dtstart.tzid) {
+ zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (comp), dtstart.tzid);
+ } else {
+ zone = NULL;
+ }
+ *start_time = icaltime_as_timet_with_zone (*dtstart.value, zone);
+ e_cal_component_free_datetime (&dtstart);
+ }
+ if (end_time) {
+ e_cal_component_get_dtend (comp, &dtend);
+ if (dtend.tzid) {
+ zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (comp), dtend.tzid);
+ } else {
+ zone = NULL;
+ }
+ *end_time = icaltime_as_timet_with_zone (*dtend.value, zone);
+ e_cal_component_free_datetime (&dtend);
+ }
+
+ g_object_unref (comp);
+ g_list_free (selected);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static GList *
e_cal_list_view_get_selected_events (ECalendarView *cal_view)
{
diff --git a/calendar/gui/e-cal-view.c b/calendar/gui/e-cal-view.c
index 9ff5f500e3..59322d6be0 100644
--- a/calendar/gui/e-cal-view.c
+++ b/calendar/gui/e-cal-view.c
@@ -23,6 +23,7 @@
#include <config.h>
#include <string.h>
+#include <time.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkstock.h>
#include <gdk/gdkkeysyms.h>
@@ -617,15 +618,17 @@ e_calendar_view_get_selected_events (ECalendarView *cal_view)
return NULL;
}
-void
+gboolean
e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time)
{
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+ g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE);
if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) {
- E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range (
+ return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range (
cal_view, start_time, end_time);
}
+
+ return FALSE;
}
void
@@ -935,21 +938,17 @@ on_new_appointment (GtkWidget *widget, gpointer user_data)
static void
on_new_event (GtkWidget *widget, gpointer user_data)
{
- time_t dtstart, dtend;
ECalendarView *cal_view = (ECalendarView *) user_data;
- e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend);
- e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE);
+ e_calendar_view_new_appointment_full (cal_view, TRUE, FALSE);
}
static void
on_new_meeting (GtkWidget *widget, gpointer user_data)
{
- time_t dtstart, dtend;
ECalendarView *cal_view = (ECalendarView *) user_data;
- e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend);
- e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE);
+ e_calendar_view_new_appointment_full (cal_view, FALSE, TRUE);
}
static void
@@ -1417,9 +1416,9 @@ e_calendar_view_open_event (ECalendarView *cal_view)
*/
void
e_calendar_view_new_appointment_for (ECalendarView *cal_view,
- time_t dtstart, time_t dtend,
- gboolean all_day,
- gboolean meeting)
+ time_t dtstart, time_t dtend,
+ gboolean all_day,
+ gboolean meeting)
{
ECalendarViewPrivate *priv;
struct icaltimetype itt;
@@ -1489,14 +1488,25 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
* the calendar view.
*/
void
-e_calendar_view_new_appointment (ECalendarView *cal_view)
+e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, gboolean meeting)
{
time_t dtstart, dtend;
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
- e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend);
- e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE);
+ if (!e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend)) {
+ dtstart = time (NULL);
+ dtend = dtstart + 3600;
+ }
+ e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, all_day, meeting);
+}
+
+void
+e_calendar_view_new_appointment (ECalendarView *cal_view)
+{
+ g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+
+ e_calendar_view_new_appointment_full (cal_view, FALSE, FALSE);
}
/**
diff --git a/calendar/gui/e-cal-view.h b/calendar/gui/e-cal-view.h
index ebd830c9a0..28190b5672 100644
--- a/calendar/gui/e-cal-view.h
+++ b/calendar/gui/e-cal-view.h
@@ -91,7 +91,7 @@ struct _ECalendarViewClass {
/* Virtual methods */
GList * (* get_selected_events) (ECalendarView *cal_view); /* a GList of ECalendarViewEvent's */
- void (* get_selected_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
+ gboolean (* get_selected_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void (* set_selected_time_range) (ECalendarView *cal_view, time_t start_time, time_t end_time);
gboolean (* get_visible_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void (* update_query) (ECalendarView *cal_view);
@@ -115,7 +115,7 @@ void e_calendar_view_set_use_24_hour_format (ECalendarView *view, gboo
void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message);
GList *e_calendar_view_get_selected_events (ECalendarView *cal_view);
-void e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
+gboolean e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time);
gboolean e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void e_calendar_view_update_query (ECalendarView *cal_view);
@@ -132,10 +132,13 @@ GtkMenu *e_calendar_view_create_popup_menu (ECalendarView *cal_view);
void e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart,
icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas);
void e_calendar_view_new_appointment_for (ECalendarView *cal_view,
- time_t dtstart,
- time_t dtend,
- gboolean all_day,
- gboolean meeting);
+ time_t dtstart,
+ time_t dtend,
+ gboolean all_day,
+ gboolean meeting);
+void e_calendar_view_new_appointment_full (ECalendarView *cal_view,
+ gboolean all_day,
+ gboolean meeting);
void e_calendar_view_new_appointment (ECalendarView *cal_view);
void e_calendar_view_edit_appointment (ECalendarView *cal_view,
ECal *client,
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 9ff5f500e3..59322d6be0 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -23,6 +23,7 @@
#include <config.h>
#include <string.h>
+#include <time.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkstock.h>
#include <gdk/gdkkeysyms.h>
@@ -617,15 +618,17 @@ e_calendar_view_get_selected_events (ECalendarView *cal_view)
return NULL;
}
-void
+gboolean
e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time)
{
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+ g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE);
if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) {
- E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range (
+ return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range (
cal_view, start_time, end_time);
}
+
+ return FALSE;
}
void
@@ -935,21 +938,17 @@ on_new_appointment (GtkWidget *widget, gpointer user_data)
static void
on_new_event (GtkWidget *widget, gpointer user_data)
{
- time_t dtstart, dtend;
ECalendarView *cal_view = (ECalendarView *) user_data;
- e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend);
- e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE);
+ e_calendar_view_new_appointment_full (cal_view, TRUE, FALSE);
}
static void
on_new_meeting (GtkWidget *widget, gpointer user_data)
{
- time_t dtstart, dtend;
ECalendarView *cal_view = (ECalendarView *) user_data;
- e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend);
- e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE);
+ e_calendar_view_new_appointment_full (cal_view, FALSE, TRUE);
}
static void
@@ -1417,9 +1416,9 @@ e_calendar_view_open_event (ECalendarView *cal_view)
*/
void
e_calendar_view_new_appointment_for (ECalendarView *cal_view,
- time_t dtstart, time_t dtend,
- gboolean all_day,
- gboolean meeting)
+ time_t dtstart, time_t dtend,
+ gboolean all_day,
+ gboolean meeting)
{
ECalendarViewPrivate *priv;
struct icaltimetype itt;
@@ -1489,14 +1488,25 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
* the calendar view.
*/
void
-e_calendar_view_new_appointment (ECalendarView *cal_view)
+e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, gboolean meeting)
{
time_t dtstart, dtend;
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
- e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend);
- e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE);
+ if (!e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend)) {
+ dtstart = time (NULL);
+ dtend = dtstart + 3600;
+ }
+ e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, all_day, meeting);
+}
+
+void
+e_calendar_view_new_appointment (ECalendarView *cal_view)
+{
+ g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+
+ e_calendar_view_new_appointment_full (cal_view, FALSE, FALSE);
}
/**
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index ebd830c9a0..28190b5672 100644
--- a/calendar/gui/e-calendar-view.h
+++ b/calendar/gui/e-calendar-view.h
@@ -91,7 +91,7 @@ struct _ECalendarViewClass {
/* Virtual methods */
GList * (* get_selected_events) (ECalendarView *cal_view); /* a GList of ECalendarViewEvent's */
- void (* get_selected_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
+ gboolean (* get_selected_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void (* set_selected_time_range) (ECalendarView *cal_view, time_t start_time, time_t end_time);
gboolean (* get_visible_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void (* update_query) (ECalendarView *cal_view);
@@ -115,7 +115,7 @@ void e_calendar_view_set_use_24_hour_format (ECalendarView *view, gboo
void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message);
GList *e_calendar_view_get_selected_events (ECalendarView *cal_view);
-void e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
+gboolean e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time);
gboolean e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
void e_calendar_view_update_query (ECalendarView *cal_view);
@@ -132,10 +132,13 @@ GtkMenu *e_calendar_view_create_popup_menu (ECalendarView *cal_view);
void e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart,
icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas);
void e_calendar_view_new_appointment_for (ECalendarView *cal_view,
- time_t dtstart,
- time_t dtend,
- gboolean all_day,
- gboolean meeting);
+ time_t dtstart,
+ time_t dtend,
+ gboolean all_day,
+ gboolean meeting);
+void e_calendar_view_new_appointment_full (ECalendarView *cal_view,
+ gboolean all_day,
+ gboolean meeting);
void e_calendar_view_new_appointment (ECalendarView *cal_view);
void e_calendar_view_edit_appointment (ECalendarView *cal_view,
ECal *client,
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index ed35a118ce..d7ab97144d 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -160,7 +160,7 @@ static gboolean e_day_view_do_key_press (GtkWidget *widget,
GdkEventKey *event);
static gboolean e_day_view_popup_menu (GtkWidget *widget);
static GList *e_day_view_get_selected_events (ECalendarView *cal_view);
-static void e_day_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
+static gboolean e_day_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
static void e_day_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time);
static gboolean e_day_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
static void e_day_view_update_query (ECalendarView *cal_view);
@@ -2033,7 +2033,7 @@ e_day_view_find_work_week_start (EDayView *day_view,
}
/* Returns the selected time range. */
-static void
+static gboolean
e_day_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time)
{
gint start_col, start_row, end_col, end_row;
@@ -2068,6 +2068,8 @@ e_day_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time,
if (end_time)
*end_time = end;
+
+ return TRUE;
}
/* Gets the visible time range. Returns FALSE if no time range has been set. */
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 025bd1cadc..61703486a4 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -120,7 +120,7 @@ static gboolean e_week_view_get_next_tab_event (EWeekView *week_view,
static gboolean e_week_view_focus (GtkWidget *widget,
GtkDirectionType direction);
static GList *e_week_view_get_selected_events (ECalendarView *cal_view);
-static void e_week_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
+static gboolean e_week_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
static void e_week_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time);
static gboolean e_week_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time);
static void e_week_view_update_query (ECalendarView *cal_view);
@@ -1364,7 +1364,7 @@ e_week_view_set_selected_time_range_visible (EWeekView *week_view,
/* Returns the selected time range. */
-static void
+static gboolean
e_week_view_get_selected_time_range (ECalendarView *cal_view,
time_t *start_time,
time_t *end_time)
@@ -1385,6 +1385,8 @@ e_week_view_get_selected_time_range (ECalendarView *cal_view,
if (end_time)
*end_time = week_view->day_starts[end_day + 1];
+
+ return TRUE;
}
/* Gets the visible time range. Returns FALSE if no time range has been set. */