aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog31
-rw-r--r--calendar/cal-client/cal-client.c23
-rw-r--r--calendar/cal-client/cal-client.h2
-rw-r--r--calendar/gui/calendar-model.c211
-rw-r--r--calendar/gui/e-day-view.c41
-rw-r--r--calendar/gui/e-week-view.c22
-rw-r--r--calendar/gui/gncal-todo.c8
-rw-r--r--calendar/gui/gnome-cal.c31
-rw-r--r--calendar/gui/gnome-cal.h4
9 files changed, 304 insertions, 69 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 7dda8739bd..bd4d231fde 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -21,6 +21,37 @@
* gui/e-day-view.[hc]: added support for keyboard navigation and
selection of the time range.
+2000-06-20 Federico Mena Quintero <federico@helixcode.com>
+
+ * gui/calendar-model.c (calendar_model_set_value_at): Implemented.
+ (calendar_model_is_cell_editable): Implemented.
+
+ * cal-client/cal-client.c (cal_client_update_object): Take in an
+ iCalObject instead of a stringified version.
+
+ * gui/gnome-cal.c (gnome_calendar_update_object): Removed.
+ (gnome_calendar_remove_object): Removed.
+ (save_ical_object_cb): Use the CalClient function.
+
+ * gui/e-day-view.c (e_day_view_on_delete_occurrence): Likewise.
+ (e_day_view_on_unrecur_appointment): Likewise.
+ (e_day_view_finish_long_event_resize): Likewise.
+ (e_day_view_finish_resize): Likewise.
+ (e_day_view_key_press): Likewise.
+ (e_day_view_on_editing_stopped): Likewise.
+ (e_day_view_on_top_canvas_drag_data_received): Likewise.
+ (e_day_view_on_main_canvas_drag_data_received): Likewise.
+ (e_day_view_on_delete_appointment): Likewise.
+
+ * gui/e-week-view.c (e_week_view_on_editing_stopped): Likewise.
+ (e_week_view_key_press): Likewise.
+ (e_week_view_on_delete_occurrence): Likewise.
+ (e_week_view_on_unrecur_appointment): Likewise.
+ (e_week_view_on_delete_appointment): Likewise.
+
+ * gui/gncal-todo.c (ok_button): Likewise.
+ (delete_todo): Likewise.
+
2000-06-19 Damon Chaplin <damon@helixcode.com>
* gui/event-editor-dialog.glade: tidied up dialog a bit, adding
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 007e284b7a..f1e60be3f3 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -979,22 +979,22 @@ cal_client_get_alarms_for_object (CalClient *client, const char *uid,
/**
* cal_client_update_object:
* @client: A calendar client.
- * @uid: Unique identifier of object to update.
- * @calobj: String representation of the new calendar object.
+ * @ico: A calendar object.
*
- * Asks a calendar to update an object based on its UID. Any existing object
- * with the specified UID will be replaced. The client program should not
- * assume that the object is actually in the server's storage until it has
- * received the "obj_updated" notification signal.
+ * Asks a calendar to update an object. Any existing object with the specified
+ * UID will be replaced. The client program should not assume that the object
+ * is actually in the server's storage until it has received the "obj_updated"
+ * notification signal.
*
* Return value: TRUE on success, FALSE on specifying an invalid object.
**/
gboolean
-cal_client_update_object (CalClient *client, const char *uid, const char *calobj)
+cal_client_update_object (CalClient *client, iCalObject *ico)
{
CalClientPrivate *priv;
CORBA_Environment ev;
gboolean retval;
+ char *obj_string;
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
@@ -1002,13 +1002,16 @@ cal_client_update_object (CalClient *client, const char *uid, const char *calobj
priv = client->priv;
g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE);
- g_return_val_if_fail (uid != NULL, FALSE);
- g_return_val_if_fail (calobj != NULL, FALSE);
+ g_return_val_if_fail (ico != NULL, FALSE);
+ g_return_val_if_fail (ico->uid != NULL, FALSE);
retval = FALSE;
+ obj_string = ical_object_to_string (ico);
+
CORBA_exception_init (&ev);
- Evolution_Calendar_Cal_update_object (priv->cal, uid, calobj, &ev);
+ Evolution_Calendar_Cal_update_object (priv->cal, ico->uid, obj_string, &ev);
+ g_free (obj_string);
if (ev._major == CORBA_USER_EXCEPTION &&
strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_InvalidObject) == 0)
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index 947c9dd5dc..7c67cfba2e 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -97,7 +97,7 @@ gboolean cal_client_get_alarms_for_object (CalClient *client, const char *uid,
time_t start, time_t end,
GList **alarms);
-gboolean cal_client_update_object (CalClient *client, const char *uid, const char *calobj);
+gboolean cal_client_update_object (CalClient *client, iCalObject *ico);
gboolean cal_client_remove_object (CalClient *client, const char *uid);
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index af83145812..49fefbcdd4 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -112,10 +112,10 @@ calendar_model_class_init (CalendarModelClass *class)
etm_class->column_count = calendar_model_column_count;
etm_class->row_count = calendar_model_row_count;
etm_class->value_at = calendar_model_value_at;
-#if 0
etm_class->set_value_at = calendar_model_set_value_at;
etm_class->is_cell_editable = calendar_model_is_cell_editable;
etm_class->duplicate_value = calendar_model_duplicate_value;
+#if 0
etm_class->free_value = calendar_model_free_value;
etm_class->initialize_value = calendar_model_initialize_value;
etm_class->value_is_empty = calendar_model_value_is_empty;
@@ -246,10 +246,8 @@ calendar_model_value_at (ETableModel *etm, int col, int row)
model = CALENDAR_MODEL (etm);
priv = model->priv;
- if (row >= priv->objects->len) {
- g_message ("calendar_model_value_at(): Requested invalid row index %d", row);
- return NULL;
- }
+ g_return_val_if_fail (col >= 0 && col < ICAL_OBJECT_FIELD_NUM_FIELDS, NULL);
+ g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL);
ico = g_array_index (priv->objects, iCalObject *, row);
g_assert (ico != NULL);
@@ -310,6 +308,209 @@ calendar_model_value_at (ETableModel *etm, int col, int row)
}
}
+/* Replaces a string */
+static void
+set_string (char **dest, char *value)
+{
+ if (*dest)
+ g_free (*dest);
+
+ if (value)
+ *dest = g_strdup (value);
+ else
+ *dest = NULL;
+}
+
+/* Replaces a time_t value */
+static void
+set_time_t (time_t *dest, time_t *value)
+{
+ *dest = *value;
+}
+
+/* Replaces a geo value */
+static void
+set_geo (iCalGeo *dest, iCalGeo *value)
+{
+ *dest = *value;
+}
+
+/* Replaces a person value */
+static void
+set_person (iCalPerson *dest, iCalPerson *value)
+{
+ /* FIXME */
+}
+
+/* Sets an int value */
+static void
+set_int (int *dest, int *value)
+{
+ *dest = *value;
+}
+
+/* set_value_at handler for the calendar table model */
+static void
+calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *value)
+{
+ CalendarModel *model;
+ CalendarModelPrivate *priv;
+ iCalObject *ico;
+
+ model = CALENDAR_MODEL (etm);
+ priv = model->priv;
+
+ g_return_if_fail (col >= 0 && col < ICAL_OBJECT_FIELD_NUM_FIELDS);
+ g_return_if_fail (row >= 0 && row < priv->objects->len);
+
+ ico = g_array_index (priv->objects, iCalObject *, row);
+ g_assert (ico != NULL);
+
+ switch (col) {
+ case ICAL_OBJECT_FIELD_COMMENT:
+ set_string (&ico->comment);
+ break;
+
+ case ICAL_OBJECT_FIELD_COMPLETED:
+ set_time_t (&ico->completed, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_CREATED:
+ set_time_t (&ico->created, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_DESCRIPTION:
+ set_string (&ico->desc, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_DTSTAMP:
+ set_time_t (&ico->dtstamp, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_DTSTART:
+ set_time_t (&ico->dtstart, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_DTEND:
+ set_time_t (&ico->dtend, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_GEO:
+ set_geo (&ico->geo, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_LAST_MOD:
+ set_time (&ico->last_mod, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_LOCATION:
+ set_string (&ico->location, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_ORGANIZER:
+ set_person (&ico->organizer, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_PERCENT:
+ set_int (&ico->percent, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_PRIORITY:
+ set_int (&ico->priority, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_SUMMARY:
+ set_string (&ico->summary, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_URL:
+ set_string (&ico->url, value);
+ break;
+
+ case ICAL_OBJECT_FIELD_HAS_ALARMS:
+ g_message ("calendar_model_set_value_at(): HAS_ALARMS is not a settable field!");
+ break;
+
+ default:
+ g_message ("calendar_model_set_value_at(): Requested invalid column %d", col);
+ break;
+ }
+
+ if (!cal_client_update_object (priv->client, ico))
+ g_message ("calendar_model_set_value_at(): Could not update the object!");
+}
+
+/* is_cell_editable handler for the calendar table model */
+static gboolean
+calendar_model_is_cell_editable (ETableModel *etm, int col, int row)
+{
+ CalendarModel *model;
+ CalendarModelPrivate *priv;
+
+ model = CALENDAR_MODEL (etm);
+ priv = model->priv;
+
+ g_return_val_if_fail (col >= 0 && col < ICAL_OBJECT_FIELD_NUM_FIELDS, NULL);
+ g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL);
+
+ switch (col) {
+ case ICAL_OBJECT_FIELD_HAS_ALARMS:
+ return FALSE;
+
+ default:
+ return TRUE;
+ }
+}
+
+/* duplicate_value handler for the calendar table model */
+static void *
+calendar_model_duplicate_value (ETableModel *etm, int col, const void *value)
+{
+ CalendarModel *model;
+ CalendarModelPrivate *priv;
+
+ model = CALENDAR_MODEL (etm);
+ priv = model->priv;
+
+ g_return_val_if_fail (col >= 0 && col < ICAL_OBJECT_FIELD_NUM_FIELDS, NULL);
+
+ switch (col) {
+ case ICAL_OBJECT_FIELD_COMMENT:
+
+ case ICAL_OBJECT_FIELD_COMPLETED:
+
+ case ICAL_OBJECT_FIELD_CREATED:
+
+ case ICAL_OBJECT_FIELD_DESCRIPTION:
+
+ case ICAL_OBJECT_FIELD_DTSTAMP:
+
+ case ICAL_OBJECT_FIELD_DTSTART:
+
+ case ICAL_OBJECT_FIELD_DTEND:
+
+ case ICAL_OBJECT_FIELD_GEO:
+
+ case ICAL_OBJECT_FIELD_LAST_MOD:
+
+ case ICAL_OBJECT_FIELD_LOCATION:
+
+ case ICAL_OBJECT_FIELD_ORGANIZER:
+
+ case ICAL_OBJECT_FIELD_PERCENT:
+
+ case ICAL_OBJECT_FIELD_PRIORITY:
+
+ case ICAL_OBJECT_FIELD_SUMMARY:
+
+ case ICAL_OBJECT_FIELD_URL:
+
+ case ICAL_OBJECT_FIELD_HAS_ALARMS:
+
+ default:
+ }
+}
+
/**
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 4e56ad3885..ab789437e7 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -2385,7 +2385,10 @@ e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
ico = ical_object_duplicate (event->ico);
ical_object_add_exdate (ico, event->start);
- gnome_calendar_update_object (day_view->calendar, ico);
+
+ if (!cal_client_update_object (day_view->calendar->client, ico))
+ g_message ("e_day_view_on_delete_occurrence(): Could not update the object!");
+
ical_object_unref (ico);
}
@@ -2405,7 +2408,8 @@ e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data)
if (day_view->editing_event_day >= 0)
e_day_view_stop_editing_event (day_view);
- gnome_calendar_remove_object (day_view->calendar, event->ico);
+ if (!cal_client_remove_object (day_view->calendar->client, event->ico->uid))
+ g_message ("e_day_view_on_delete_appointment(): Could not remove the object!");
}
@@ -2438,12 +2442,16 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
new_ico->dtend = event->end;
/* Now update both iCalObjects. Note that we do this last since at
- present the updates happen synchronously so our event may disappear.
- */
- gnome_calendar_update_object (day_view->calendar, ico);
+ * present the updates happen synchronously so our event may disappear.
+ */
+ if (!cal_client_update_object (day_view->calendar->client, ico))
+ g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
+
ical_object_unref (ico);
- gnome_calendar_update_object (day_view->calendar, new_ico);
+ if (!cal_client_update_object (day_view->calendar->client, new_ico))
+ g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
+
ical_object_unref (new_ico);
}
@@ -2947,7 +2955,8 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE;
- gnome_calendar_update_object (day_view->calendar, &ico);
+ if (!cal_client_update_object (day_view->calendar->client, &ico))
+ g_message ("e_day_view_finish_long_event_resize(): Could not update the object!");
}
@@ -2987,7 +2996,8 @@ e_day_view_finish_resize (EDayView *day_view)
day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE;
- gnome_calendar_update_object (day_view->calendar, &ico);
+ if (!cal_client_update_object (day_view->calendar->client, &ico))
+ g_message ("e_day_view_finish_resize(): Could not update the object!");
}
@@ -3983,7 +3993,9 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event)
g_warning ("Couldn't find event to start editing.\n");
}
- gnome_calendar_update_object (day_view->calendar, ico);
+ if (!cal_client_update_object (day_view->calendar->client, ico))
+ g_message ("e_day_view_key_press(): Could not update the object!");
+
ical_object_unref (ico);
return TRUE;
@@ -4470,7 +4482,8 @@ e_day_view_on_editing_stopped (EDayView *day_view,
event->ico->summary = text;
- gnome_calendar_update_object (day_view->calendar, event->ico);
+ if (!cal_client_update_object (day_view->calendar->client, event->ico))
+ g_message ("e_day_view_on_editing_stopped(): Could not update the object!");
}
@@ -5433,7 +5446,9 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
if (event->canvas_item)
gnome_canvas_item_show (event->canvas_item);
- gnome_calendar_update_object (day_view->calendar, &ico);
+ if (!cal_client_update_object (day_view->calendar->client, &ico))
+ g_message ("e_day_view_on_top_canvas_drag_data_received(): Could "
+ "not update the object!");
return;
}
}
@@ -5518,7 +5533,9 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
if (event->canvas_item)
gnome_canvas_item_show (event->canvas_item);
- gnome_calendar_update_object (day_view->calendar, &ico);
+ if (!cal_client_update_object (day_view->calendar->client, &ico))
+ g_message ("e_day_view_on_main_canvas_drag_data_received(): "
+ "Could not update the object!");
return;
}
}
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 2869847299..db27ef3404 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -2451,7 +2451,8 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
event->ico->summary = text;
- gnome_calendar_update_object (week_view->calendar, event->ico);
+ if (!cal_client_update_object (week_view->calendar->client, event->ico))
+ g_message ("e_week_view_on_editing_stopped(): Could not update the object!");
}
@@ -2606,7 +2607,9 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
g_warning ("Couldn't find event to start editing.\n");
}
- gnome_calendar_update_object (week_view->calendar, ico);
+ if (!cal_client_update_object (week_view->calendar->client, ico))
+ g_message ("e_week_view_key_press(): Could not update the object!");
+
ical_object_unref (ico);
return TRUE;
@@ -2739,7 +2742,9 @@ e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
ico = ical_object_duplicate (event->ico);
ical_object_add_exdate (ico, event->start);
- gnome_calendar_update_object (week_view->calendar, ico);
+ if (!cal_client_update_object (week_view->calendar->client, ico))
+ g_message ("e_week_view_on_delete_occurrence(): Could not update the object!");
+
ical_object_unref (ico);
}
@@ -2758,7 +2763,8 @@ e_week_view_on_delete_appointment (GtkWidget *widget, gpointer data)
event = &g_array_index (week_view->events, EWeekViewEvent,
week_view->popup_event_num);
- gnome_calendar_remove_object (week_view->calendar, event->ico);
+ if (!cal_client_remove_object (week_view->calendar->client, event->ico->uid))
+ g_message ("e_week_view_on_delete_appointment(): Could not remove the object!");
}
@@ -2795,10 +2801,14 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
/* Now update both iCalObjects. Note that we do this last since at
present the updates happen synchronously so our event may disappear.
*/
- gnome_calendar_update_object (week_view->calendar, ico);
+ if (!cal_client_update_object (week_view->calendar->client, ico))
+ g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
+
ical_object_unref (ico);
- gnome_calendar_update_object (week_view->calendar, new_ico);
+ if (!cal_client_update_object (week_view->calendar->client, new_ico))
+ g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
+
ical_object_unref (new_ico);
}
diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c
index e3c25b9e53..fb662c4b3c 100644
--- a/calendar/gui/gncal-todo.c
+++ b/calendar/gui/gncal-todo.c
@@ -82,7 +82,9 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog)
ico->comment = gtk_editable_get_chars( GTK_EDITABLE(comment), 0, -1);
ico->user_data = NULL;
- gnome_calendar_update_object (todo->calendar, ico);
+ if (!cal_client_update_object (todo->calendar->client, ico))
+ g_message ("ok_button(): Could not update the object!");
+
ical_object_unref (ico);
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -281,7 +283,9 @@ edit_todo (GncalTodo *todo)
static void
delete_todo (GncalTodo *todo)
{
- gnome_calendar_remove_object (todo->calendar, get_clist_selected_ico (todo->clist));
+ if (!cal_client_remove_object (todo->calendar->client,
+ get_clist_selected_ico (todo->clist)->uid))
+ g_message ("delete_todo(): Could not remove the object!");
}
static void
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index ed9ad98484..1e98737098 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1012,34 +1012,6 @@ gnome_calendar_open (GnomeCalendar *gcal,
return 1;
}
-void
-gnome_calendar_update_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- char *obj_string;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
- g_return_if_fail (obj->uid != NULL);
-
- obj_string = ical_object_to_string (obj);
- cal_client_update_object (gcal->client, obj->uid, obj_string);
- g_free (obj_string);
-}
-
-void
-gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- gboolean r;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
- g_return_if_fail (obj->uid != NULL);
-
- r = cal_client_remove_object (gcal->client, obj->uid);
-}
-
static void
stop_beeping (GtkObject* object, gpointer data)
{
@@ -1328,7 +1300,8 @@ save_ical_object_cb (EventEditor *ee, iCalObject *ico, gpointer data)
GnomeCalendar *gcal;
gcal = GNOME_CALENDAR (data);
- gnome_calendar_update_object (gcal, ico);
+ if (!cal_client_update_object (gcal->client, ico))
+ g_message ("save_ical_object_cb(): Could not update the object!");
}
void
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 015de10a65..77dc57a8c0 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -83,10 +83,6 @@ int gnome_calendar_open (GnomeCalendar *gcal,
int gnome_calendar_create (GnomeCalendar *gcal,
char *file);
*/
-void gnome_calendar_update_object (GnomeCalendar *gcal,
- iCalObject *obj);
-void gnome_calendar_remove_object (GnomeCalendar *gcal,
- iCalObject *obj);
void gnome_calendar_next (GnomeCalendar *gcal);
void gnome_calendar_previous (GnomeCalendar *gcal);
void gnome_calendar_goto (GnomeCalendar *gcal,