aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog15
-rw-r--r--calendar/gui/calendar-commands.c7
-rw-r--r--calendar/gui/e-day-view.c126
-rw-r--r--calendar/gui/e-day-view.h5
-rw-r--r--calendar/gui/e-week-view.c23
-rw-r--r--calendar/gui/e-week-view.h5
-rw-r--r--calendar/gui/gnome-cal.c33
-rw-r--r--calendar/gui/gnome-cal.h7
8 files changed, 175 insertions, 46 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 9346a0ec97..ee62897fd5 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,18 @@
+2000-05-01 Damon Chaplin <damon@helixcode.com>
+
+ * gui/gnome-cal.[hc] (gnome_calendar_get_current_time_range): new
+ function to get the currently seleted time range form the current view.
+
+ * gui/calendar-commands.c (display_objedit): use the above function
+ to get the time for the new appointment.
+
+ * gui/e-week-view.c:
+ * gui/e-day-view.c: use a shallow copy of the ico when we update the
+ times (when resizing/dragging). Otherwise we won't detect that the
+ time has changed in the "update_event" callback.
+
+ Also added functions to get the currently selected time range.
+
2000-04-30 Seth Alves <alves@hungry.com>
* pcs/icalendar-save.c (icalcomponent_create_from_ical_object): set
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index e3ae6a4bc6..d1f88066a9 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -189,12 +189,11 @@ display_objedit (BonoboUIHandler *uih, void *user_data, const char *path)
iCalObject *ico;
GnomeCalendar *gcal = GNOME_CALENDAR (user_data);
- /* FIXME: Should get the selection time from the view, since they
- may not be using the gcal's times. */
ico = ical_new ("", user_name, "");
ico->new = 1;
- ico->dtstart = gcal->selection_start_time;
- ico->dtend = gcal->selection_end_time;
+
+ gnome_calendar_get_current_time_range (gcal, &ico->dtstart,
+ &ico->dtend);
ee = event_editor_new (gcal, ico);
gtk_widget_show (ee);
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 25b026407e..6fa0ad17c1 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -263,9 +263,6 @@ static void e_day_view_on_editing_started (EDayView *day_view,
static void e_day_view_on_editing_stopped (EDayView *day_view,
GnomeCanvasItem *item);
-static void e_day_view_get_selection_range (EDayView *day_view,
- time_t *start,
- time_t *end);
static time_t e_day_view_convert_grid_position_to_time (EDayView *day_view,
gint col,
gint row);
@@ -1102,7 +1099,8 @@ e_day_view_update_event (EDayView *day_view,
g_return_if_fail (E_IS_DAY_VIEW (day_view));
#if 0
- g_print ("In e_day_view_update_event\n");
+ g_print ("In e_day_view_update_event day_view:%p uid:%s\n",
+ day_view, uid);
#endif
/* If our calendar or time hasn't been set yet, just return. */
@@ -1258,6 +1256,11 @@ e_day_view_remove_event (EDayView *day_view,
{
g_return_if_fail (E_IS_DAY_VIEW (day_view));
+#if 0
+ g_print ("In e_day_view_remove_event day_view:%p uid:%s\n",
+ day_view, uid);
+#endif
+
e_day_view_foreach_event_with_uid (day_view, uid,
e_day_view_remove_event_cb, NULL);
@@ -1527,6 +1530,39 @@ e_day_view_set_selected_time_range (EDayView *day_view,
}
+/* Returns the selected time range. */
+void
+e_day_view_get_selected_time_range (EDayView *day_view,
+ time_t *start_time,
+ time_t *end_time)
+{
+ gint start_col, start_row, end_col, end_row;
+
+ start_col = day_view->selection_start_col;
+ start_row = day_view->selection_start_row;
+ end_col = day_view->selection_end_col;
+ end_row = day_view->selection_end_row;
+
+ if (start_col == -1) {
+ start_col = 0;
+ start_row = 0;
+ end_col = 0;
+ end_row = 0;
+ }
+
+ /* Check if the selection is only in the top canvas, in which case
+ we can simply use the day_starts array. */
+ if (day_view->selection_in_top_canvas) {
+ *start_time = day_view->day_starts[start_col];
+ *end_time = day_view->day_starts[end_col + 1];
+ } else {
+ /* Convert the start col + row into a time. */
+ *start_time = e_day_view_convert_grid_position_to_time (day_view, start_col, start_row);
+ *end_time = e_day_view_convert_grid_position_to_time (day_view, end_col, end_row + 1);
+ }
+}
+
+
static void
e_day_view_recalc_day_starts (EDayView *day_view,
time_t start_time)
@@ -2254,7 +2290,8 @@ e_day_view_on_new_appointment (GtkWidget *widget, gpointer data)
ico = ical_new ("", user_name, "");
ico->new = 1;
- e_day_view_get_selection_range (day_view, &ico->dtstart, &ico->dtend);
+ e_day_view_get_selected_time_range (day_view, &ico->dtstart,
+ &ico->dtend);
event_editor = event_editor_new (day_view->calendar, ico);
gtk_widget_show (event_editor);
}
@@ -2326,6 +2363,7 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
return;
/* New object */
+ /* FIXME: generate a new uid. */
ico = ical_object_duplicate (event->ico);
g_free (ico->recur);
ico->recur = 0;
@@ -2414,7 +2452,7 @@ e_day_view_update_calendar_selection_time (EDayView *day_view)
{
time_t start, end;
- e_day_view_get_selection_range (day_view, &start, &end);
+ e_day_view_get_selected_time_range (day_view, &start, &end);
gnome_calendar_set_selected_time_range (day_view->calendar,
start, end);
}
@@ -2726,15 +2764,21 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
{
EDayViewEvent *event;
gint event_num;
+ iCalObject ico;
event_num = day_view->resize_event_num;
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ /* We use a temporary shallow copy of the ico since we don't want to
+ change the original ico here. Otherwise we would not detect that
+ the event's time had changed in the "update_event" callback. */
+ ico = *event->ico;
+
if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) {
- event->ico->dtstart = day_view->day_starts[day_view->resize_start_row];
+ ico.dtstart = day_view->day_starts[day_view->resize_start_row];
} else {
- event->ico->dtend = day_view->day_starts[day_view->resize_end_row + 1];
+ ico.dtend = day_view->day_starts[day_view->resize_end_row + 1];
}
gnome_canvas_item_hide (day_view->resize_long_event_rect_item);
@@ -2742,8 +2786,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE;
/* Notify calendar of change */
- gnome_calendar_object_changed (day_view->calendar, event->ico,
- CHANGE_DATES);
+ gnome_calendar_object_changed (day_view->calendar, &ico, CHANGE_DATES);
}
@@ -2754,16 +2797,22 @@ e_day_view_finish_resize (EDayView *day_view)
{
EDayViewEvent *event;
gint day, event_num;
+ iCalObject ico;
day = day_view->resize_event_day;
event_num = day_view->resize_event_num;
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ /* We use a temporary shallow copy of the ico since we don't want to
+ change the original ico here. Otherwise we would not detect that
+ the event's time had changed in the "update_event" callback. */
+ ico = *event->ico;
+
if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) {
- event->ico->dtstart = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_start_row);
+ ico.dtstart = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_start_row);
} else {
- event->ico->dtend = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_end_row + 1);
+ ico.dtend = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_end_row + 1);
}
gnome_canvas_item_hide (day_view->resize_rect_item);
@@ -2778,8 +2827,7 @@ e_day_view_finish_resize (EDayView *day_view)
day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE;
/* Notify calendar of change */
- gnome_calendar_object_changed (day_view->calendar, event->ico,
- CHANGE_DATES);
+ gnome_calendar_object_changed (day_view->calendar, &ico, CHANGE_DATES);
}
@@ -3698,7 +3746,8 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event)
ico = ical_new ("", user_name, "");
ico->new = 1;
- e_day_view_get_selection_range (day_view, &ico->dtstart, &ico->dtend);
+ e_day_view_get_selected_time_range (day_view, &ico->dtstart,
+ &ico->dtend);
/* We add the event locally and start editing it. When we get the
"update_event" callback from the server, we basically ignore it.
@@ -3934,25 +3983,6 @@ e_day_view_on_editing_stopped (EDayView *day_view,
}
-/* Converts the selected range into a start and end time. */
-static void
-e_day_view_get_selection_range (EDayView *day_view,
- time_t *start,
- time_t *end)
-{
- /* Check if the selection is only in the top canvas, in which case
- we can simply use the day_starts array. */
- if (day_view->selection_in_top_canvas) {
- *start = day_view->day_starts[day_view->selection_start_col];
- *end = day_view->day_starts[day_view->selection_end_col + 1];
- } else {
- /* Convert the start col + row into a time. */
- *start = e_day_view_convert_grid_position_to_time (day_view, day_view->selection_start_col, day_view->selection_start_row);
- *end = e_day_view_convert_grid_position_to_time (day_view, day_view->selection_end_col, day_view->selection_end_row + 1);
- }
-}
-
-
/* FIXME: It is possible that we may produce an invalid time due to daylight
saving times (i.e. when clocks go forward there is a range of time which
is not valid). I don't know the best way to handle daylight saving time. */
@@ -4822,6 +4852,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
EDayViewPosition pos;
gint day, start_day, end_day, num_days;
gchar *event_uid;
+ iCalObject ico;
if ((data->length >= 0) && (data->format == 8)) {
pos = e_day_view_convert_position_in_top_canvas (day_view,
@@ -4854,8 +4885,14 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
|| strcmp (event_uid, event->ico->uid))
g_warning ("Unexpected event UID");
- event->ico->dtstart = day_view->day_starts[day];
- event->ico->dtend = day_view->day_starts[day + num_days];
+ /* We use a temporary shallow copy of the ico since we
+ don't want to change the original ico here.
+ Otherwise we would not detect that the event's time
+ had changed in the "update_event" callback. */
+ ico = *event->ico;
+
+ ico.dtstart = day_view->day_starts[day];
+ ico.dtend = day_view->day_starts[day + num_days];
gtk_drag_finish (context, TRUE, TRUE, time);
@@ -4864,8 +4901,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
/* Notify calendar of change */
gnome_calendar_object_changed (day_view->calendar,
- event->ico,
- CHANGE_DATES);
+ &ico, CHANGE_DATES);
return;
}
@@ -4889,6 +4925,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
EDayViewPosition pos;
gint day, row, start_row, end_row, num_rows, scroll_x, scroll_y;
gchar *event_uid;
+ iCalObject ico;
gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget),
&scroll_x, &scroll_y);
@@ -4922,8 +4959,14 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
|| strcmp (event_uid, event->ico->uid))
g_warning ("Unexpected event UID");
- event->ico->dtstart = e_day_view_convert_grid_position_to_time (day_view, day, row);
- event->ico->dtend = e_day_view_convert_grid_position_to_time (day_view, day, row + num_rows);
+ /* We use a temporary shallow copy of the ico since we
+ don't want to change the original ico here.
+ Otherwise we would not detect that the event's time
+ had changed in the "update_event" callback. */
+ ico = *event->ico;
+
+ ico.dtstart = e_day_view_convert_grid_position_to_time (day_view, day, row);
+ ico.dtend = e_day_view_convert_grid_position_to_time (day_view, day, row + num_rows);
gtk_drag_finish (context, TRUE, TRUE, time);
@@ -4932,8 +4975,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
/* Notify calendar of change */
gnome_calendar_object_changed (day_view->calendar,
- event->ico,
- CHANGE_DATES);
+ &ico, CHANGE_DATES);
return;
}
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index ea49fff0ee..b00a6f0b3c 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -419,6 +419,11 @@ void e_day_view_set_selected_time_range (EDayView *day_view,
time_t start_time,
time_t end_time);
+/* Returns the selected time range. */
+void e_day_view_get_selected_time_range (EDayView *day_view,
+ time_t *start_time,
+ time_t *end_time);
+
/* This reloads all calendar events. */
void e_day_view_update_all_events (EDayView *day_view);
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 7f6e1c0c9c..83eb6e5608 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -836,6 +836,27 @@ e_week_view_set_selected_time_range (EWeekView *week_view,
}
+/* Returns the selected time range. */
+void
+e_week_view_get_selected_time_range (EWeekView *week_view,
+ time_t *start_time,
+ time_t *end_time)
+{
+ gint start_day, end_day;
+
+ start_day = week_view->selection_start_day;
+ end_day = week_view->selection_end_day;
+
+ if (start_day == -1) {
+ start_day = 0;
+ end_day = 0;
+ }
+
+ *start_time = week_view->day_starts[start_day];
+ *end_time = week_view->day_starts[end_day + 1];
+}
+
+
/* Recalculates the time_t corresponding to the start of each day. */
static void
e_week_view_recalc_day_starts (EWeekView *week_view,
@@ -1858,7 +1879,9 @@ e_week_view_reshape_event_span (EWeekView *week_view,
"font_gdk", GTK_WIDGET (week_view)->style->font,
"anchor", GTK_ANCHOR_NW,
"clip", TRUE,
+#if 0
"max_lines", 1,
+#endif
"editable", TRUE,
"text", ico->summary ? ico->summary : "",
NULL);
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index c940f736d4..86031d2e58 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -311,6 +311,11 @@ void e_week_view_set_selected_time_range (EWeekView *week_view,
time_t start_time,
time_t end_time);
+/* Returns the selected time range. */
+void e_week_view_get_selected_time_range (EWeekView *week_view,
+ time_t *start_time,
+ time_t *end_time);
+
/* Whether to display 1 week or 1 month (5 weeks). It defaults to 1 week. */
gboolean e_week_view_get_display_month (EWeekView *week_view);
void e_week_view_set_display_month (EWeekView *week_view,
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index cb37240ba4..748a805e9f 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -930,6 +930,39 @@ gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
}
+/* Returns the selected time range for the current view. Note that this may be
+ different from the fields in the GnomeCalendar, since the view may clip
+ this or choose a more appropriate time. */
+void
+gnome_calendar_get_current_time_range (GnomeCalendar *gcal,
+ time_t *start_time,
+ time_t *end_time)
+{
+ GtkWidget *page;
+
+ page = get_current_page (gcal);
+
+ if (page == gcal->day_view
+ || page == gcal->work_week_view)
+ e_day_view_get_selected_time_range (E_DAY_VIEW (page),
+ start_time, end_time);
+ else if (page == gcal->week_view
+ || page == gcal->month_view)
+ e_week_view_get_selected_time_range (E_WEEK_VIEW (page),
+ start_time, end_time);
+#if 0
+ else if (page == gcal->year_view_sw)
+ year_view_set (YEAR_VIEW (gcal->year_view),
+ gcal->selection_start_time);
+#endif
+ else {
+ g_warning ("My penguin is gone!");
+ g_assert_not_reached ();
+ }
+}
+
+
+
/* This updates the month shown and the day selected in the calendar, if
necessary. */
static void
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index a512bbc9b4..20287c202b 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -95,6 +95,13 @@ void gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
time_t start_time,
time_t end_time);
+/* Returns the selected time range for the current view. Note that this may be
+ different from the fields in the GnomeCalendar, since the view may clip
+ this or choose a more appropriate time. */
+void gnome_calendar_get_current_time_range (GnomeCalendar *gcal,
+ time_t *start_time,
+ time_t *end_time);
+
/* Flags is a bitmask of CalObjectChange values */
void gnome_calendar_object_changed (GnomeCalendar *gcal,
iCalObject *obj,