aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog37
-rw-r--r--calendar/cal-util/calobj.c8
-rw-r--r--calendar/cal-util/calobj.h9
-rw-r--r--calendar/gui/calendar-commands.c27
-rw-r--r--calendar/gui/e-day-view.c47
-rw-r--r--calendar/gui/e-week-view.c51
-rw-r--r--calendar/gui/eventedit.c8
-rw-r--r--calendar/gui/popup-menu.c5
8 files changed, 150 insertions, 42 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ee62897fd5..62c9088e01 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,40 @@
+2000-05-02 Damon Chaplin <damon@helixcode.com>
+
+ * gui/calendar-commands.c (calendar_control_activate): set the active
+ radio button here. Oops - it wasn't a Bonobo problem after all.
+
+ * gui/popup-menu.c (popup_menu): added call to
+ e_auto_kill_popup_menu_on_hide() to destroy the menu.
+
+ * gui/e-week-view.c (e_week_view_show_popup_menu):
+ * gui/e-day-view.c (e_day_view_on_event_right_click): ico->user_data
+ isn't useful any more, since the event editor keeps its own iCalObject.
+ So for now we make the menu commands available even when the event is
+ being edited in the event editor.
+ Also corrected misspellings of 'occurance' -> 'occurrence'.
+
+ * gui/eventedit.c (event_editor_destroy): destroy the iCalObject.
+ The event editor now uses its own independent iCalObject.
+
+ * gui/e-week-view.c (e_week_view_on_unrecur_appointment):
+ * gui/e-day-view.c (e_day_view_on_unrecur_appointment): create a new
+ uid for the new single instance. I'm not sure what we should do about
+ the creation/last modification times of the objects.
+
+ * gui/e-week-view.c (e_week_view_on_edit_appointment):
+ * gui/e-day-view.c (e_day_view_on_edit_appointment): duplicate the
+ iCalObject before passing it to the event editor, since it will change
+ the fields. If we don't duplicate it we won't know what has changed
+ when we get the "update_event" callback.
+
+ * gui/e-week-view.c (e_week_view_key_press):
+ * gui/e-day-view.c (e_day_view_key_press): set the created and last_mod
+ times of the new iCalObject. We may want to set the default alarm as
+ well.
+
+ * cal-util/calobj.c (ical_gen_uid): made this function public so we
+ can generate new uids if necessary.
+
2000-05-01 Damon Chaplin <damon@helixcode.com>
* gui/gnome-cal.[hc] (gnome_calendar_get_current_time_range): new
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 1634ec084e..f185c31952 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -25,7 +25,7 @@ static gint compare_exdates (gconstpointer a, gconstpointer b);
-static char *
+char *
ical_gen_uid (void)
{
static char *hostname;
@@ -541,7 +541,9 @@ setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *
}
/*
- * Duplicates an iCalObject. Implementation is a grand hack
+ * Duplicates an iCalObject. Implementation is a grand hack.
+ * If you need the new ICalObject to have a new uid, free the current one,
+ * and call ical_gen_uid() to generate a new one.
*/
iCalObject *
ical_object_duplicate (iCalObject *o)
@@ -549,8 +551,6 @@ ical_object_duplicate (iCalObject *o)
VObject *vo;
iCalObject *new;
- /* FIXME!!!!! The UID needs to change!!! */
-
vo = ical_object_to_vobject (o);
switch (o->type){
case ICAL_EVENT:
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index 0fa82ee36e..25954b8098 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -247,13 +247,13 @@ typedef enum {
CalObjFindStatus ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico);
-char *ical_object_to_string (iCalObject *ico);
+char *ical_object_to_string (iCalObject *ico);
/* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple
* days on a monthly-by-pos recurrence. If no days are toggled, it returns -1.
*/
-int ical_object_get_first_weekday (int weekday_mask);
+int ical_object_get_first_weekday (int weekday_mask);
/* Returns the number of seconds configured to trigger the alarm in advance to an event */
int alarm_compute_offset (CalendarAlarm *a);
@@ -261,7 +261,10 @@ int alarm_compute_offset (CalendarAlarm *a);
/* Returns TRUE if the dates of both objects match, including any recurrence
rules. */
-gboolean ical_object_compare_dates (iCalObject *ico1, iCalObject *ico2);
+gboolean ical_object_compare_dates (iCalObject *ico1, iCalObject *ico2);
+
+/* Generates a new uid for a calendar object. Should be g_free'd eventually. */
+char *ical_gen_uid (void);
END_GNOME_DECLS
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index d1f88066a9..3b3f0edab0 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -521,6 +521,8 @@ calendar_control_activate (BonoboControl *control,
GtkWidget *toolbar;
GnomeUIBuilderData uibdata;
BonoboUIHandler *uih = bonobo_control_get_ui_handler (control);
+ gchar *page_name;
+ gint button;
g_assert (uih);
uibdata.connect_func = do_ui_signal_connect;
@@ -529,6 +531,8 @@ calendar_control_activate (BonoboControl *control,
uibdata.relay_func = NULL;
uibdata.destroy_func = NULL;
+ g_print ("In calendar_control_activate\n");
+
remote_uih = bonobo_control_get_remote_ui_handler (control);
bonobo_ui_handler_set_container (uih, remote_uih);
@@ -540,6 +544,26 @@ calendar_control_activate (BonoboControl *control,
/*gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));*/
+ /* Note that these indices should correspond with the button indices
+ in gnome_toolbar_view_buttons. */
+ page_name = gnome_calendar_get_current_view_name (cal);
+ if (!strcmp (page_name, "dayview")) {
+ button = 0;
+ } else if (!strcmp (page_name, "workweekview")) {
+ button = 1;
+ } else if (!strcmp (page_name, "weekview")) {
+ button = 2;
+ } else if (!strcmp (page_name, "monthview")) {
+ button = 3;
+ } else if (!strcmp (page_name, "yearview")) {
+ button = 4;
+ } else {
+ g_warning ("Unknown calendar view: %s", page_name);
+ button = 0;
+ }
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gnome_toolbar_view_buttons[button].widget), TRUE);
+
gtk_widget_show_all (toolbar);
bonobo_ui_handler_dock_add (uih, "/Toolbar",
@@ -611,6 +635,9 @@ calendar_control_deactivate (BonoboControl *control)
{
BonoboUIHandler *uih = bonobo_control_get_ui_handler (control);
g_assert (uih);
+
+ g_print ("In calendar_control_deactivate\n");
+
bonobo_ui_handler_dock_remove (uih, "/Toolbar");
bonobo_ui_handler_unset_container (uih);
}
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 6fa0ad17c1..6a1383d180 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -282,8 +282,8 @@ static void e_day_view_on_new_appointment (GtkWidget *widget,
gpointer data);
static void e_day_view_on_edit_appointment (GtkWidget *widget,
gpointer data);
-static void e_day_view_on_delete_occurance (GtkWidget *widget,
- gpointer data);
+static void e_day_view_on_delete_occurrence (GtkWidget *widget,
+ gpointer data);
static void e_day_view_on_delete_appointment (GtkWidget *widget,
gpointer data);
static void e_day_view_on_unrecur_appointment (GtkWidget *widget,
@@ -2227,10 +2227,10 @@ e_day_view_on_event_right_click (EDayView *day_view,
};
static struct menu_item recur_child_items[] = {
- { N_("Make this appointment movable"), (GtkSignalFunc) e_day_view_on_unrecur_appointment, NULL, TRUE },
{ N_("Edit this appointment..."), (GtkSignalFunc) e_day_view_on_edit_appointment, NULL, TRUE },
- { N_("Delete this occurance"), (GtkSignalFunc) e_day_view_on_delete_occurance, NULL, TRUE },
- { N_("Delete all occurances"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE },
+ { N_("Make this appointment movable"), (GtkSignalFunc) e_day_view_on_unrecur_appointment, NULL, TRUE },
+ { N_("Delete this occurrence"), (GtkSignalFunc) e_day_view_on_delete_occurrence, NULL, TRUE },
+ { N_("Delete all occurrences"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE },
{ NULL, NULL, NULL, TRUE },
{ N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE }
};
@@ -2250,23 +2250,26 @@ e_day_view_on_event_right_click (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
- /* Check if the event is being edited in the event editor. */
- not_being_edited = (event->ico->user_data == NULL);
+ /* This used to be set only if the event wasn't being edited
+ in the event editor, but we can't check that at present.
+ We could possibly set up another method of checking it. */
+ not_being_edited = TRUE;
if (event->ico->recur) {
items = 6;
context_menu = &recur_child_items[0];
+ context_menu[0].sensitive = not_being_edited;
+ context_menu[1].sensitive = not_being_edited;
+ context_menu[2].sensitive = not_being_edited;
context_menu[3].sensitive = not_being_edited;
context_menu[5].sensitive = have_selection;
} else {
items = 4;
context_menu = &child_items[0];
+ context_menu[0].sensitive = not_being_edited;
+ context_menu[1].sensitive = not_being_edited;
context_menu[3].sensitive = have_selection;
}
- /* These settings are common for each context sensitive menu */
- context_menu[0].sensitive = not_being_edited;
- context_menu[1].sensitive = not_being_edited;
- context_menu[2].sensitive = not_being_edited;
}
for (i = 0; i < items; i++)
@@ -2303,6 +2306,7 @@ e_day_view_on_edit_appointment (GtkWidget *widget, gpointer data)
EDayView *day_view;
EDayViewEvent *event;
GtkWidget *event_editor;
+ iCalObject *ico;
day_view = E_DAY_VIEW (data);
@@ -2310,13 +2314,17 @@ e_day_view_on_edit_appointment (GtkWidget *widget, gpointer data)
if (event == NULL)
return;
- event_editor = event_editor_new (day_view->calendar, event->ico);
+ /* We must duplicate the iCalObject, since the event editor will
+ change the fields. */
+ ico = ical_object_duplicate (event->ico);
+
+ event_editor = event_editor_new (day_view->calendar, ico);
gtk_widget_show (event_editor);
}
static void
-e_day_view_on_delete_occurance (GtkWidget *widget, gpointer data)
+e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
{
EDayView *day_view;
EDayViewEvent *event;
@@ -2362,16 +2370,21 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
if (event == NULL)
return;
- /* New object */
- /* FIXME: generate a new uid. */
+ /* For the unrecurred instance we duplicate the original object,
+ create a new uid for it, get rid of the recurrence rules, and set
+ the start & end times to the instances times. */
ico = ical_object_duplicate (event->ico);
+ g_free (ico->uid);
+ ico->uid = ical_gen_uid ();
g_free (ico->recur);
ico->recur = 0;
ico->dtstart = event->start;
ico->dtend = event->end;
- /* Duplicate, and eliminate the recurrency fields */
+ /* For the recurring object, we add a exception to get rid of the
+ instance. */
ical_object_add_exdate (event->ico, event->start);
+
gnome_calendar_object_changed (day_view->calendar, event->ico,
CHANGE_ALL);
gnome_calendar_add_object (day_view->calendar, ico);
@@ -3745,6 +3758,8 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event)
Note that user_name is a global variable. */
ico = ical_new ("", user_name, "");
ico->new = 1;
+ ico->created = time (NULL);
+ ico->last_mod = ico->created;
e_day_view_get_selected_time_range (day_view, &ico->dtstart,
&ico->dtend);
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 83eb6e5608..6f371a10c4 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -144,8 +144,8 @@ static void e_week_view_on_new_appointment (GtkWidget *widget,
gpointer data);
static void e_week_view_on_edit_appointment (GtkWidget *widget,
gpointer data);
-static void e_week_view_on_delete_occurance (GtkWidget *widget,
- gpointer data);
+static void e_week_view_on_delete_occurrence (GtkWidget *widget,
+ gpointer data);
static void e_week_view_on_delete_appointment (GtkWidget *widget,
gpointer data);
static void e_week_view_on_unrecur_appointment (GtkWidget *widget,
@@ -974,7 +974,7 @@ e_week_view_update_event (EWeekView *week_view,
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
-#if 0
+#if 1
g_print ("In e_week_view_update_event\n");
#endif
@@ -1007,10 +1007,12 @@ e_week_view_update_event (EWeekView *week_view,
update the event fairly easily without changing the events arrays
or computing a new layout. */
if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) {
+ g_print (" updating existing event\n");
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
if (ical_object_compare_dates (event->ico, ico)) {
+ g_print (" dates unchanged\n");
e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, ico);
gtk_widget_queue_draw (week_view->main_canvas);
return;
@@ -1018,6 +1020,7 @@ e_week_view_update_event (EWeekView *week_view,
/* The dates have changed, so we need to remove the
old occurrrences before adding the new ones. */
+ g_print (" dates changed\n");
e_week_view_foreach_event_with_uid (week_view, uid,
e_week_view_remove_event_cb,
NULL);
@@ -2463,6 +2466,8 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
Note that user_name is a global variable. */
ico = ical_new ("", user_name, "");
ico->new = 1;
+ ico->created = time (NULL);
+ ico->last_mod = ico->created;
ico->dtstart = week_view->day_starts[week_view->selection_start_day];
ico->dtend = week_view->day_starts[week_view->selection_end_day + 1];
@@ -2510,10 +2515,10 @@ e_week_view_show_popup_menu (EWeekView *week_view,
};
static struct menu_item recur_child_items[] = {
- { N_("Make this appointment movable"), (GtkSignalFunc) e_week_view_on_unrecur_appointment, NULL, TRUE },
{ N_("Edit this appointment..."), (GtkSignalFunc) e_week_view_on_edit_appointment, NULL, TRUE },
- { N_("Delete this occurance"), (GtkSignalFunc) e_week_view_on_delete_occurance, NULL, TRUE },
- { N_("Delete all occurances"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE },
+ { N_("Make this appointment movable"), (GtkSignalFunc) e_week_view_on_unrecur_appointment, NULL, TRUE },
+ { N_("Delete this occurrence"), (GtkSignalFunc) e_week_view_on_delete_occurrence, NULL, TRUE },
+ { N_("Delete all occurrences"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE },
{ NULL, NULL, NULL, TRUE },
{ N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE }
};
@@ -2529,23 +2534,26 @@ e_week_view_show_popup_menu (EWeekView *week_view,
event = &g_array_index (week_view->events,
EWeekViewEvent, event_num);
- /* Check if the event is being edited in the event editor. */
- not_being_edited = (event->ico->user_data == NULL);
+ /* This used to be set only if the event wasn't being edited
+ in the event editor, but we can't check that at present.
+ We could possibly set up another method of checking it. */
+ not_being_edited = TRUE;
if (event->ico->recur) {
num_items = 6;
context_menu = &recur_child_items[0];
+ context_menu[0].sensitive = not_being_edited;
+ context_menu[1].sensitive = not_being_edited;
+ context_menu[2].sensitive = not_being_edited;
context_menu[3].sensitive = not_being_edited;
context_menu[5].sensitive = have_selection;
} else {
num_items = 4;
context_menu = &child_items[0];
+ context_menu[0].sensitive = not_being_edited;
+ context_menu[1].sensitive = not_being_edited;
context_menu[3].sensitive = have_selection;
}
- /* These settings are common for each context sensitive menu */
- context_menu[0].sensitive = not_being_edited;
- context_menu[1].sensitive = not_being_edited;
- context_menu[2].sensitive = not_being_edited;
}
for (i = 0; i < num_items; i++)
@@ -2581,6 +2589,7 @@ e_week_view_on_edit_appointment (GtkWidget *widget, gpointer data)
EWeekView *week_view;
EWeekViewEvent *event;
GtkWidget *event_editor;
+ iCalObject *ico;
week_view = E_WEEK_VIEW (data);
@@ -2590,13 +2599,17 @@ e_week_view_on_edit_appointment (GtkWidget *widget, gpointer data)
event = &g_array_index (week_view->events, EWeekViewEvent,
week_view->popup_event_num);
- event_editor = event_editor_new (week_view->calendar, event->ico);
+ /* We must duplicate the iCalObject, since the event editor will
+ change the fields. */
+ ico = ical_object_duplicate (event->ico);
+
+ event_editor = event_editor_new (week_view->calendar, ico);
gtk_widget_show (event_editor);
}
static void
-e_week_view_on_delete_occurance (GtkWidget *widget, gpointer data)
+e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
{
EWeekView *week_view;
EWeekViewEvent *event;
@@ -2648,15 +2661,21 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
event = &g_array_index (week_view->events, EWeekViewEvent,
week_view->popup_event_num);
- /* New object */
+ /* For the unrecurred instance we duplicate the original object,
+ create a new uid for it, get rid of the recurrence rules, and set
+ the start & end times to the instances times. */
ico = ical_object_duplicate (event->ico);
+ g_free (ico->uid);
+ ico->uid = ical_gen_uid ();
g_free (ico->recur);
ico->recur = 0;
ico->dtstart = event->start;
ico->dtend = event->end;
- /* Duplicate, and eliminate the recurrency fields */
+ /* For the recurring object, we add a exception to get rid of the
+ instance. */
ical_object_add_exdate (event->ico, event->start);
+
gnome_calendar_object_changed (week_view->calendar, event->ico,
CHANGE_ALL);
gnome_calendar_add_object (week_view->calendar, ico);
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index 3505187035..ae18f485fd 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
/*
* EventEditor widget
* Copyright (C) 1998 the Free Software Foundation
@@ -1516,8 +1518,10 @@ event_editor_destroy (GtkObject *object)
ee = EVENT_EDITOR (object);
- if (ee->ical)
- ee->ical->user_data = NULL; /* we are no longer editing it */
+ if (ee->ical) {
+ ical_object_destroy (ee->ical);
+ ee->ical = NULL;
+ }
}
GtkWidget *
diff --git a/calendar/gui/popup-menu.c b/calendar/gui/popup-menu.c
index 3686183146..3b976a9033 100644
--- a/calendar/gui/popup-menu.c
+++ b/calendar/gui/popup-menu.c
@@ -17,7 +17,10 @@ popup_menu (struct menu_item *items, int nitems, GdkEventButton *event)
GtkWidget *item;
int i;
- menu = gtk_menu_new (); /* FIXME: this baby is never freed */
+ menu = gtk_menu_new ();
+
+ /* Make sure the menu is destroyed when it disappears. */
+ e_auto_kill_popup_menu_on_hide (menu);
for (i = 0; i < nitems; i++) {
if (items[i].text) {