aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@src.gnome.org>2003-08-08 22:58:02 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2003-08-08 22:58:02 +0800
commitfa0a110592ab3feda8051417d5dd198e96308367 (patch)
tree30611ac69b73e59a48b89acd0d40c154ef303ece
parentdc84df9871b3171a21d62feec988160f3c608103 (diff)
downloadgsoc2013-evolution-fa0a110592ab3feda8051417d5dd198e96308367.tar.gz
gsoc2013-evolution-fa0a110592ab3feda8051417d5dd198e96308367.tar.zst
gsoc2013-evolution-fa0a110592ab3feda8051417d5dd198e96308367.zip
Merged ECalendarTable changes from new-calendar-branch
svn path=/trunk/; revision=22143
-rw-r--r--calendar/ChangeLog115
-rw-r--r--calendar/cal-client/cal-client.c19
-rw-r--r--calendar/cal-client/cal-client.h3
-rw-r--r--calendar/cal-util/cal-util.c14
-rw-r--r--calendar/cal-util/cal-util.h2
-rw-r--r--calendar/gui/Makefile.am2
-rw-r--r--calendar/gui/calendar-config.c10
-rw-r--r--calendar/gui/calendar-model.c2476
-rw-r--r--calendar/gui/calendar-model.h99
-rw-r--r--calendar/gui/dialogs/comp-editor.c3
-rw-r--r--calendar/gui/e-cal-view.c5
-rw-r--r--calendar/gui/e-calendar-table.c275
-rw-r--r--calendar/gui/e-calendar-table.etspec35
-rw-r--r--calendar/gui/e-calendar-table.h36
-rw-r--r--calendar/gui/e-calendar-view.c5
-rw-r--r--calendar/gui/e-day-view.c2
-rw-r--r--calendar/gui/e-tasks.c28
-rw-r--r--calendar/gui/gnome-cal.c38
-rw-r--r--calendar/gui/print.c17
-rw-r--r--libical/ChangeLog5
-rw-r--r--libical/src/libical/icalcomponent.c13
21 files changed, 385 insertions, 2817 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 6d3099d53a..11b06bd2dd 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,107 @@
+2003-08-08 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/e-cal-model-calendar.c (ecmc_fill_component_from_model):
+ implemented new virtual method.
+ (ecmc_class_init): initialize new virtual method.
+
+2003-08-08 Rodrigo Moya <rodrigo@ximian.com>
+
+ * cal-client/cal-client.c (cal_client_update_object_with_mod):
+ cal_client_get_component_as_string_internal expects now a
+ icalcomponent, not a CalComponent.
+
+ * gui/e-cal-model.h: added fill_component_from_model virtual method.
+
+ * gui/e-cal-model.c (e_cal_model_get_default_client): return
+ the default URI as per the configuration if we've got that
+ client loaded. If not, return the first client.
+ (get_dtstart): retrieve the value from the icalproperty.
+ (set_summary): implemented correctly.
+ (set_categories, set_classification, set_description): changed
+ to really get an ECalModelComponent.
+ (ecm_append_row): pass the correct arguments to the set_ functions
+ and call the class' fill_component_from_model method to fill in the
+ created icalcomponent.
+
+ * gui/e-cal-model-tasks.c (set_due): added missing function.
+ (ecmt_set_value_at): implemented case for DUE field.
+ (ecmt_fill_component_from_model): implemented new virtual method.
+ (ecmt_append_row): removed.
+
+ * gui/e-cal-model-calendar.c (ecmc_append_row): removed.
+
+ * gui/e-calendar-table.c (e_calendar_table_init): initialize
+ missing fields. Disabled call to g_object_unref on the 'extras'
+ object, since it causes GLib warnings. Something is wrong here.
+
+2003-08-08 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/e-cal-model.c (cal_opened_cb): don't call remove_client,
+ since the client, at this point, hasn't been added anywhere.
+ (ecm_finalize): don't call e_cal_model_remove_all_clients, since
+ that function triggers notifications on the model.
+ (query_obj_updated_cb): free all the date fields.
+
+2003-08-07 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/e-cal-model.c (ecm_value_at): don't convert to an integer
+ the return value from get_color.
+ (ecm_get_color_for_component): use correct GTK 2.x color values.
+
+ * gui/e-calendar-table.c: replace all CAL_COMPONENT_FIELD...
+ with the correct E_CAL_MODEL_*_FIELD...
+
+2003-08-07 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/e-cal-model-tasks.c (get_completed, get_due): added
+ missing implementation.
+ (ecmt_class_init): initialize missing virtual method.
+
+ * gui/gnome-cal.c (gnome_calendar_construct): fixed typo.
+
+2003-08-07 Rodrigo Moya <rodrigo@ximian.com>
+
+ * cal-client/cal-client.[ch] (cal_client_get_component_as_string):
+ * cal-util/cal-util.[ch] (cal_util_add_timezone_from_component):
+ use icalcomponent's instead of CalComponent's.
+
+ * gui/Makefile.am:
+ * gui/calendar-model.[ch]: removed old model class.
+
+ * gui/e-calendar-table.[ch]: use ECalModelTasks class instead
+ of CalendarModel.
+ (e_calendar_table_set_status_message): new function.
+ (get_selected_comp): return an ECalModelComponent.
+ (get_selected_objects): return a list of ECalModelComponent's.
+ (delete_selected_components): use the CalClient associated
+ with each component.
+ (copy_row_cb): adapted to changes in get_selected_comp.
+
+ * gui/e-tasks.c:
+ * gui/print.c:
+ * gui/dialogs/comp-editor.c (save_as_cmd):
+ * gui/e-day-view.c (e_day_view_on_drag_data_get):
+ * gui/e-cal-view.c (e_cal_view_copy_clipboard, on_save_as): pass
+ an icalcomponent to cal_util_add_timezones_from_component and
+ cal_client_get_component_as_string.
+
+ * gui/e-cal-model.[ch] (e_cal_model_set_use_24_hour_format):
+ (e_cal_model_get_default_client):
+ (e_cal_model_set_default_category): new functions.
+
+ * gui/e-cal-model-tasks.[ch] (e_cal_model_tasks_mark_task_complete):
+ new function.
+ (ecmt_get_color_for_component): chain the call to the parent class
+ so that it assigns the per-client color to 'normal' tasks.
+
+ * gui/calendar-config.c (calendar_config_configure_e_calendar_table):
+ call e_cal_model_set_use_24_hour_format.
+
+2003-08-07 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/e-cal-model.c (ecm_get_color_for_component): use the color
+ palette from Tuomas.
+
2003-08-06 Rodrigo Moya <rodrigo@ximian.com>
* gui/e-cal-model.[ch]: removed 'create_component_with_defaults'
@@ -45,11 +149,6 @@
* gui/e-cal-model-tasks.c (ecmt_get_color_for_component): implemented
new class' virtual method.
-2003-08-05 Jack Jia <jack.jia@sun.com>
-
- * gui/dialogs/event-page.glade: changed one of the "Con_fidential" to
- "Co_nfidential" since we already have "File" using the same 'F' key.
-
2003-08-05 Rodrigo Moya <rodrigo@ximian.com>
* cal-client_/cal-client.c (cal_client_get_default_object): use
@@ -103,11 +202,6 @@
* gui/e-cal-model-tasks.[ch]: new class for the tasks model.
-2003-08-01 Lorenzo Gil <lgs@sicem.biz>
-
- * gui/e-alarm-list.c: added the include <config.h> line at the
- beginning to enable gettext.
-
2003-07-31 Rodrigo Moya <rodrigo@ximian.com>
* gui/e-cal-model.[ch]: new class, based on CalendarModel to be
@@ -120,6 +214,7 @@
* cal-client/cal-client-multi.[ch]:
* cal-client/Makefile.am: removed obsolete code.
+>>>>>>> 1.1841.2.20
2003-07-29 Rodrigo Moya <rodrigo@ximian.com>
Fixes all "alarm daemon doesn't start with session"
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 740d8f4062..762e2c7e4a 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -2562,7 +2562,7 @@ free_timezone_string (gpointer key, gpointer value, gpointer data)
as before. */
static char*
cal_client_get_component_as_string_internal (CalClient *client,
- CalComponent *comp,
+ icalcomponent *icalcomp,
gboolean include_all_timezones)
{
GHashTable *timezone_hash;
@@ -2570,7 +2570,6 @@ cal_client_get_component_as_string_internal (CalClient *client,
int initial_vcal_string_len;
ForeachTZIDCallbackData cbdata;
char *obj_string;
-
CalClientPrivate *priv;
priv = client->priv;
@@ -2583,8 +2582,7 @@ cal_client_get_component_as_string_internal (CalClient *client,
cbdata.timezone_hash = timezone_hash;
cbdata.include_all_timezones = include_all_timezones;
cbdata.success = TRUE;
- icalcomponent_foreach_tzid (cal_component_get_icalcomponent (comp),
- foreach_tzid_callback, &cbdata);
+ icalcomponent_foreach_tzid (icalcomp, foreach_tzid_callback, &cbdata);
if (!cbdata.success) {
g_hash_table_foreach (timezone_hash, free_timezone_string,
NULL);
@@ -2607,7 +2605,7 @@ cal_client_get_component_as_string_internal (CalClient *client,
vcal_string);
/* Get the string for the VEVENT/VTODO. */
- obj_string = cal_component_get_as_string (comp);
+ obj_string = g_strdup (icalcomponent_as_ical_string (icalcomp));
/* If there were any timezones to send, create a complete VCALENDAR,
else just send the VEVENT/VTODO string. */
@@ -2630,7 +2628,7 @@ cal_client_get_component_as_string_internal (CalClient *client,
/**
* cal_client_get_component_as_string:
* @client: A calendar client.
- * @comp: A calendar component object.
+ * @icalcomp: A calendar component object.
*
* Gets a calendar component as an iCalendar string, with a toplevel
* VCALENDAR component and all VTIMEZONEs needed for the component.
@@ -2639,11 +2637,9 @@ cal_client_get_component_as_string_internal (CalClient *client,
* failure. The string should be freed after use.
**/
char*
-cal_client_get_component_as_string (CalClient *client,
- CalComponent *comp)
+cal_client_get_component_as_string (CalClient *client, icalcomponent *icalcomp)
{
- return cal_client_get_component_as_string_internal (client, comp,
- TRUE);
+ return cal_client_get_component_as_string_internal (client, icalcomp, TRUE);
}
CalClientResult
@@ -2665,7 +2661,8 @@ cal_client_update_object_with_mod (CalClient *client, CalComponent *comp, CalObj
cal_component_commit_sequence (comp);
obj_string = cal_client_get_component_as_string_internal (client,
- comp, FALSE);
+ cal_component_get_icalcomponent (comp),
+ FALSE);
if (obj_string == NULL)
return CAL_CLIENT_RESULT_INVALID_OBJECT;
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index baf2072868..376c674c58 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -223,8 +223,7 @@ icaltimezone *cal_client_resolve_tzid_cb (const char *tzid, gpointer data);
/* Returns a complete VCALENDAR for a VEVENT/VTODO including all VTIMEZONEs
used by the component. It also includes a 'METHOD:PUBLISH' property. */
-char* cal_client_get_component_as_string (CalClient *client,
- CalComponent *comp);
+char* cal_client_get_component_as_string (CalClient *client, icalcomponent *icalcomp);
diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c
index ad495bca77..9bedf7d53c 100644
--- a/calendar/cal-util/cal-util.c
+++ b/calendar/cal-util/cal-util.c
@@ -612,7 +612,7 @@ cal_util_expand_uri (char *uri, gboolean tasks)
/* callback for icalcomponent_foreach_tzid */
typedef struct {
icalcomponent *vcal_comp;
- CalComponent *comp;
+ icalcomponent *icalcomp;
} ForeachTzidData;
static void
@@ -631,8 +631,7 @@ add_timezone_cb (icalparameter *param, void *data)
if (tz)
return;
- tz = icalcomponent_get_timezone (cal_component_get_icalcomponent (f_data->comp),
- tzid);
+ tz = icalcomponent_get_timezone (f_data->icalcomp, tzid);
if (!tz) {
tz = icaltimezone_get_builtin_timezone_from_tzid (tzid);
if (!tz)
@@ -651,15 +650,14 @@ add_timezone_cb (icalparameter *param, void *data)
* in the given CalComponent. */
void
cal_util_add_timezones_from_component (icalcomponent *vcal_comp,
- CalComponent *comp)
+ icalcomponent *icalcomp)
{
ForeachTzidData f_data;
g_return_if_fail (vcal_comp != NULL);
- g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (icalcomp != NULL);;
f_data.vcal_comp = vcal_comp;
- f_data.comp = comp;
- icalcomponent_foreach_tzid (cal_component_get_icalcomponent (comp),
- add_timezone_cb, &f_data);
+ f_data.icalcomp = icalcomp;
+ icalcomponent_foreach_tzid (icalcomp, add_timezone_cb, &f_data);
}
diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h
index 3bf2a0d3ab..19c73270b3 100644
--- a/calendar/cal-util/cal-util.h
+++ b/calendar/cal-util/cal-util.h
@@ -97,7 +97,7 @@ int cal_util_priority_from_string (const char *string);
char *cal_util_expand_uri (char *uri, gboolean tasks);
void cal_util_add_timezones_from_component (icalcomponent *vcal_comp,
- CalComponent *comp);
+ icalcomponent *icalcomp);
/* The static capabilities to be supported by backends */
#define CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT "no-alarm-repeat"
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index d40c2da78c..eef7821858 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -98,8 +98,6 @@ libevolution_calendar_la_SOURCES = \
calendar-commands.h \
calendar-component.c \
calendar-component.h \
- calendar-model.c \
- calendar-model.h \
calendar-offline-handler.c \
calendar-offline-handler.h \
calendar-view.c \
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 84f334beff..2ac2a4062b 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -631,7 +631,7 @@ calendar_config_configure_e_cell_date_edit (ECellDateEdit *ecde)
void
calendar_config_configure_e_calendar_table (ECalendarTable *cal_table)
{
- CalendarModel *model;
+ ECalModel *model;
gboolean use_24_hour;
char *location;
icaltimezone *zone;
@@ -641,17 +641,13 @@ calendar_config_configure_e_calendar_table (ECalendarTable *cal_table)
use_24_hour = calendar_config_get_24_hour_format ();
model = e_calendar_table_get_model (cal_table);
- calendar_model_set_use_24_hour_format (model, use_24_hour);
+ e_cal_model_set_use_24_hour_format (model, use_24_hour);
location = calendar_config_get_timezone ();
zone = icaltimezone_get_builtin_timezone (location);
- calendar_model_set_timezone (model, zone);
+ e_cal_model_set_timezone (model, zone);
calendar_config_configure_e_cell_date_edit (cal_table->dates_cell);
-
- /* Reload the event/tasks, since the 'Hide Completed Tasks' option
- may have been changed, so the query needs to be updated. */
- calendar_model_refresh (model);
}
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
deleted file mode 100644
index b5d0738729..0000000000
--- a/calendar/gui/calendar-model.c
+++ /dev/null
@@ -1,2476 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/* Evolution calendar - Data model for ETable
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-
-#include <math.h>
-#include <sys/types.h>
-
-#include <ctype.h>
-
-#include <libgnomeui/gnome-messagebox.h>
-#include <libgnomeui/gnome-stock-icons.h>
-#include <libgnome/gnome-i18n.h>
-#include <gal/widgets/e-unicode.h>
-#include <gal/util/e-util.h>
-#include <e-util/e-time-utils.h>
-#include <cal-util/timeutil.h>
-#include "calendar-commands.h"
-#include "calendar-config.h"
-#include "comp-util.h"
-#include "itip-utils.h"
-#include "calendar-model.h"
-#include "evolution-activity-client.h"
-#include "e-cell-date-edit-text.h"
-#include "misc.h"
-
-/* This specifies how often we refresh the list, so that completed tasks are
- hidden according to the config setting, and overdue tasks change color etc.
- It is in milliseconds, so this is 10 minutes.
- Note that if the user is editing an item in the list, they will probably
- lose their edit, so this isn't ideal. */
-#define CALENDAR_MODEL_REFRESH_TIMEOUT 1000 * 60 * 10
-
-/* These hold the date values of the objects, so we can free the values when
- we no longer need them. */
-typedef struct _CalendarModelObjectData CalendarModelObjectData;
-struct _CalendarModelObjectData {
- ECellDateEditValue *dtstart;
- ECellDateEditValue *dtend;
- ECellDateEditValue *due;
- ECellDateEditValue *completed;
-};
-
-/* We use a pointer to this value to indicate that the property is not set. */
-static ECellDateEditValue unset_date_edit_value;
-
-/* Private part of the ECalendarModel structure */
-struct _CalendarModelPrivate {
- /* Calendar client we are using */
- CalClient *client;
-
- /* Types of objects we are dealing with */
- CalObjType type;
-
- /* S-expression for query and the query object */
- char *sexp;
- CalQuery *query;
-
- /* Array of pointers to calendar objects */
- GArray *objects;
-
- /* Array of CalendarModelObjectData* holding data for each of the
- objects in the objects array above. */
- GArray *objects_data;
-
- /* UID -> array index hash */
- GHashTable *uid_index_hash;
-
- /* Type of components to create when using click-to-add in the table */
- CalComponentVType new_comp_vtype;
-
- /* Whether we display dates in 24-hour format. */
- gboolean use_24_hour_format;
-
- /* The default category to use when creating new tasks, e.g. when the
- filter is set to a certain category we use that category when
- creating a new task. */
- gchar *default_category;
-
- /* Addresses for determining icons */
- EAccountList *accounts;
-
- /* The current timezone. */
- icaltimezone *zone;
-
- /* The id of our timeout function for refreshing the list. */
- gint timeout_id;
-
- /* The activity client used to show messages on the status bar. */
- EvolutionActivityClient *activity;
-};
-
-
-
-static void calendar_model_class_init (CalendarModelClass *class);
-static void calendar_model_init (CalendarModel *model);
-static void calendar_model_finalize (GObject *object);
-
-static int calendar_model_column_count (ETableModel *etm);
-static int calendar_model_row_count (ETableModel *etm);
-static void *calendar_model_value_at (ETableModel *etm, int col, int row);
-static void calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *value);
-static gboolean calendar_model_is_cell_editable (ETableModel *etm, int col, int row);
-static void calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row);
-static void *calendar_model_duplicate_value (ETableModel *etm, int col, const void *value);
-static void calendar_model_free_value (ETableModel *etm, int col, void *value);
-static void *calendar_model_initialize_value (ETableModel *etm, int col);
-static gboolean calendar_model_value_is_empty (ETableModel *etm, int col, const void *value);
-static char * calendar_model_value_to_string (ETableModel *etm, int col, const void *value);
-static int remove_object (CalendarModel *model, const char *uid);
-static void ensure_task_complete (CalComponent *comp,
- time_t completed_date);
-static void ensure_task_not_complete (CalComponent *comp);
-
-static ETableModelClass *parent_class;
-
-
-
-/**
- * calendar_model_get_type:
- * @void:
- *
- * Registers the #CalendarModel class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CalendarModel class.
- **/
-
-E_MAKE_TYPE (calendar_model, "CalendarModel", CalendarModel, calendar_model_class_init,
- calendar_model_init, E_TABLE_MODEL_TYPE);
-
-/* Class initialization function for the calendar table model */
-static void
-calendar_model_class_init (CalendarModelClass *class)
-{
- GObjectClass *object_class;
- ETableModelClass *etm_class;
-
- object_class = (GObjectClass *) class;
- etm_class = (ETableModelClass *) class;
-
- parent_class = g_type_class_peek_parent (class);
-
- object_class->finalize = calendar_model_finalize;
-
- etm_class->column_count = calendar_model_column_count;
- etm_class->row_count = calendar_model_row_count;
- etm_class->value_at = calendar_model_value_at;
- etm_class->set_value_at = calendar_model_set_value_at;
- etm_class->is_cell_editable = calendar_model_is_cell_editable;
- etm_class->append_row = calendar_model_append_row;
- etm_class->duplicate_value = calendar_model_duplicate_value;
- 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;
- etm_class->value_to_string = calendar_model_value_to_string;
-}
-
-
-static gboolean
-calendar_model_timeout_cb (gpointer data)
-{
- CalendarModel *model;
-
- g_return_val_if_fail (IS_CALENDAR_MODEL (data), FALSE);
-
- model = CALENDAR_MODEL (data);
-
- GDK_THREADS_ENTER ();
-
- calendar_model_refresh (model);
-
- GDK_THREADS_LEAVE ();
- return TRUE;
-}
-
-
-/* Object initialization function for the calendar table model */
-static void
-calendar_model_init (CalendarModel *model)
-{
- CalendarModelPrivate *priv;
-
- priv = g_new0 (CalendarModelPrivate, 1);
- model->priv = priv;
-
- priv->sexp = g_strdup ("#t"); /* match all by default */
- priv->query = NULL;
-
- priv->objects = g_array_new (FALSE, TRUE, sizeof (CalComponent *));
- priv->objects_data = g_array_new (FALSE, FALSE, sizeof (CalendarModelObjectData));
- priv->uid_index_hash = g_hash_table_new (g_str_hash, g_str_equal);
- priv->new_comp_vtype = CAL_COMPONENT_EVENT;
- priv->use_24_hour_format = TRUE;
-
- priv->timeout_id = g_timeout_add (CALENDAR_MODEL_REFRESH_TIMEOUT,
- calendar_model_timeout_cb, model);
-
- priv->accounts = itip_addresses_get ();
-
- priv->zone = NULL;
-
- priv->activity = NULL;
-
- /* Preload here, to avoid corba calls later */
- /* Gross hack because gnome-canvas is not re-entrant */
- calendar_config_get_tasks_due_today_color ();
- calendar_config_get_tasks_overdue_color ();
- g_free (calendar_config_get_hide_completed_tasks_sexp ());
-}
-
-static void
-calendar_model_free_object_data (CalendarModel *model,
- CalendarModelObjectData *object_data)
-{
- if (object_data->dtstart != &unset_date_edit_value)
- g_free (object_data->dtstart);
-
- if (object_data->dtend != &unset_date_edit_value)
- g_free (object_data->dtend);
-
- if (object_data->due != &unset_date_edit_value)
- g_free (object_data->due);
-
- if (object_data->completed != &unset_date_edit_value)
- g_free (object_data->completed);
-}
-
-/* Called from g_hash_table_foreach_remove(), frees a stored UID->index
- * mapping.
- */
-static gboolean
-free_uid_index (gpointer key, gpointer value, gpointer data)
-{
- int *idx;
-
- idx = value;
- g_free (idx);
-
- return TRUE;
-}
-
-/* Frees the objects stored in the calendar model */
-static void
-free_objects (CalendarModel *model)
-{
- CalendarModelPrivate *priv;
- int i;
-
- priv = model->priv;
-
- g_hash_table_foreach_remove (priv->uid_index_hash, free_uid_index, NULL);
-
- for (i = 0; i < priv->objects->len; i++) {
- CalComponent *comp;
- CalendarModelObjectData *object_data;
-
- comp = g_array_index (priv->objects, CalComponent *, i);
- g_assert (comp != NULL);
- g_object_unref (comp);
-
- object_data = &g_array_index (priv->objects_data,
- CalendarModelObjectData, i);
- calendar_model_free_object_data (model, object_data);
- }
-
- g_array_set_size (priv->objects, 0);
- g_array_set_size (priv->objects_data, 0);
-}
-
-/* Destroy handler for the calendar table model */
-static void
-calendar_model_finalize (GObject *object)
-{
- CalendarModel *model;
- CalendarModelPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CALENDAR_MODEL (object));
-
- model = CALENDAR_MODEL (object);
- priv = model->priv;
-
- if (priv->timeout_id) {
- g_source_remove (priv->timeout_id);
- priv->timeout_id = 0;
- }
-
- /* Free the calendar client interface object */
-
- if (priv->client) {
- g_signal_handlers_disconnect_matched (priv->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model);
- g_object_unref (priv->client);
- priv->client = NULL;
- }
-
- if (priv->sexp) {
- g_free (priv->sexp);
- priv->sexp = NULL;
- }
-
- if (priv->query) {
- g_signal_handlers_disconnect_matched (priv->query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, model);
- g_object_unref (priv->query);
- priv->query = NULL;
- }
-
- /* Free the uid->index hash data and the array of UIDs */
-
- free_objects (model);
-
- g_hash_table_destroy (priv->uid_index_hash);
- priv->uid_index_hash = NULL;
-
- g_array_free (priv->objects, TRUE);
- priv->objects = NULL;
-
- g_array_free (priv->objects_data, TRUE);
- priv->objects_data = NULL;
-
- g_free (priv->default_category);
-
- if (priv->activity) {
- g_object_unref (priv->activity);
- priv->activity = NULL;
- }
-
- /* Free the private structure */
-
- g_free (priv);
- model->priv = NULL;
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-
-/* ETableModel methods */
-
-/* column_count handler for the calendar table model */
-static int
-calendar_model_column_count (ETableModel *etm)
-{
- return CAL_COMPONENT_FIELD_NUM_FIELDS;
-}
-
-/* row_count handler for the calendar table model */
-static int
-calendar_model_row_count (ETableModel *etm)
-{
- CalendarModel *model;
- CalendarModelPrivate *priv;
-
- model = CALENDAR_MODEL (etm);
- priv = model->priv;
-
- return priv->objects->len;
-}
-
-/* Builds a string based on the list of CATEGORIES properties of a calendar
- * component.
- */
-static char *
-get_categories (CalComponent *comp)
-{
- const char *categories;
-
- cal_component_get_categories (comp, &categories);
-
- return categories ? (char*) categories : "";
-}
-
-/* Returns a string based on the CLASSIFICATION property of a calendar component */
-static char *
-get_classification (CalComponent *comp)
-{
- CalComponentClassification classif;
-
- cal_component_get_classification (comp, &classif);
-
- switch (classif) {
- case CAL_COMPONENT_CLASS_PRIVATE:
- return _("Private");
-
- case CAL_COMPONENT_CLASS_CONFIDENTIAL:
- return _("Confidential");
-
- default:
- return _("Public");
- }
-}
-
-/* Returns an ECellDateEditValue* for a COMPLETED property of a
- calendar component. Note that we cache these in the objects_data array so
- we can free them eventually. */
-static ECellDateEditValue*
-get_completed (CalendarModel *model,
- CalComponent *comp,
- int row)
-{
- CalendarModelPrivate *priv;
- CalendarModelObjectData *object_data;
- struct icaltimetype *completed;
-
- priv = model->priv;
-
- object_data = &g_array_index (priv->objects_data,
- CalendarModelObjectData, row);
-
- if (!object_data->completed) {
- cal_component_get_completed (comp, &completed);
-
- if (completed) {
- object_data->completed = g_new (ECellDateEditValue, 1);
- object_data->completed->tt = *completed;
- object_data->completed->zone = icaltimezone_get_utc_timezone ();
- cal_component_free_icaltimetype (completed);
- } else {
- object_data->completed = &unset_date_edit_value;
- }
- }
-
- return (object_data->completed == &unset_date_edit_value)
- ? NULL : object_data->completed;
-}
-
-/* Returns an ECellDateEditValue* for a DTSTART, DTEND or DUE property of a
- calendar component. Note that we cache these in the objects_data array so
- we can free them eventually. */
-static ECellDateEditValue*
-get_date_edit_value (CalendarModel *model, CalComponent *comp,
- int col, int row)
-{
- CalendarModelPrivate *priv;
- CalComponentDateTime dt;
- CalendarModelObjectData *object_data;
- ECellDateEditValue **value;
-
- priv = model->priv;
-
- object_data = &g_array_index (priv->objects_data,
- CalendarModelObjectData, row);
-
- if (col == CAL_COMPONENT_FIELD_DTSTART)
- value = &object_data->dtstart;
- else if (col == CAL_COMPONENT_FIELD_DTEND)
- value = &object_data->dtend;
- else
- value = &object_data->due;
-
- if (!(*value)) {
- if (col == CAL_COMPONENT_FIELD_DTSTART)
- cal_component_get_dtstart (comp, &dt);
- else if (col == CAL_COMPONENT_FIELD_DTEND)
- cal_component_get_dtend (comp, &dt);
- else
- cal_component_get_due (comp, &dt);
-
- if (dt.value) {
- CalClientGetStatus status;
- icaltimezone *zone;
-
- /* For a DTEND with a DATE value, we subtract 1 from
- the day to display it. */
- if (col == CAL_COMPONENT_FIELD_DTEND
- && dt.value->is_date) {
- icaltime_adjust (dt.value, -1, 0, 0, 0);
- }
-
- *value = g_new (ECellDateEditValue, 1);
- (*value)->tt = *dt.value;
-
- /* FIXME: TIMEZONES: Handle error. */
- status = cal_client_get_timezone (model->priv->client,
- dt.tzid, &zone);
- (*value)->zone = zone;
- } else {
- *value = &unset_date_edit_value;
- }
-
- cal_component_free_datetime (&dt);
- }
-
- return (*value == &unset_date_edit_value) ? NULL : *value;
-}
-
-/* Builds a string for the GEO property of a calendar component */
-static char*
-get_geo (CalComponent *comp)
-{
- struct icalgeotype *geo;
- static gchar buf[32];
-
- cal_component_get_geo (comp, &geo);
-
- if (!geo)
- buf[0] = '\0';
- else {
- g_snprintf (buf, sizeof (buf), "%g %s, %g %s",
- fabs (geo->lat),
- geo->lat >= 0.0 ? _("N") : _("S"),
- fabs (geo->lon),
- geo->lon >= 0.0 ? _("E") : _("W"));
- cal_component_free_geo (geo);
- }
-
- return buf;
-}
-
-/* Builds a string for the PERCENT property of a calendar component */
-static int
-get_percent (CalComponent *comp)
-{
- int *percent, retval;
-
- cal_component_get_percent (comp, &percent);
-
- if (percent) {
- retval = *percent;
- cal_component_free_percent (percent);
- } else {
- retval = -1;
- }
-
- return retval;
-}
-
-/* Builds a string for the PRIORITY property of a calendar component */
-static char *
-get_priority (CalComponent *comp)
-{
- int *priority;
- char *retval = "";
-
- cal_component_get_priority (comp, &priority);
-
- if (priority) {
- retval = cal_util_priority_to_string (*priority);
- cal_component_free_priority (priority);
- }
-
- return retval;
-}
-
-/* Builds a string for the SUMMARY property of a calendar component */
-static char *
-get_summary (CalComponent *comp)
-{
- CalComponentText summary;
-
- cal_component_get_summary (comp, &summary);
-
- if (summary.value)
- return (char *) summary.value;
- else
- return "";
-}
-
-/* Builds a string for the TRANSPARENCY property of a calendar component */
-static char *
-get_transparency (CalComponent *comp)
-{
- CalComponentTransparency transp;
-
- cal_component_get_transparency (comp, &transp);
-
- if (transp == CAL_COMPONENT_TRANSP_TRANSPARENT)
- return _("Free");
- else
- return _("Busy");
-}
-
-/* Builds a string for the URL property of a calendar component */
-static char *
-get_url (CalComponent *comp)
-{
- const char *url;
-
- cal_component_get_url (comp, &url);
-
- if (url)
- return (char *) url;
- else
- return "";
-}
-
-/* Returns whether the completion date has been set on a component */
-static gboolean
-is_complete (CalComponent *comp)
-{
- struct icaltimetype *t;
- gboolean retval;
-
- cal_component_get_completed (comp, &t);
- retval = (t != NULL);
-
- if (retval)
- cal_component_free_icaltimetype (t);
-
- return retval;
-}
-
-typedef enum {
- CALENDAR_MODEL_DUE_NEVER,
- CALENDAR_MODEL_DUE_FUTURE,
- CALENDAR_MODEL_DUE_TODAY,
- CALENDAR_MODEL_DUE_OVERDUE,
- CALENDAR_MODEL_DUE_COMPLETE
-} CalendarModelDueStatus;
-
-
-static CalendarModelDueStatus
-get_due_status (CalendarModel *model, CalComponent *comp)
-{
- CalendarModelPrivate *priv;
- CalComponentDateTime dt;
- CalendarModelDueStatus retval;
-
- priv = model->priv;
-
- cal_component_get_due (comp, &dt);
-
- /* First, do we have a due date? */
-
- if (!dt.value)
- retval = CALENDAR_MODEL_DUE_NEVER;
- else {
- struct icaltimetype now_tt;
- CalClientGetStatus status;
- icaltimezone *zone;
-
- /* Second, is it already completed? */
-
- if (is_complete (comp)) {
- retval = CALENDAR_MODEL_DUE_COMPLETE;
- goto out;
- }
-
- /* Third, are we overdue as of right now? */
-
- if (dt.value->is_date) {
- int cmp;
-
- now_tt = icaltime_current_time_with_zone (priv->zone);
- cmp = icaltime_compare_date_only (*dt.value, now_tt);
-
- if (cmp < 0)
- retval = CALENDAR_MODEL_DUE_OVERDUE;
- else if (cmp == 0)
- retval = CALENDAR_MODEL_DUE_TODAY;
- else
- retval = CALENDAR_MODEL_DUE_FUTURE;
- } else {
- /* Get the current time in the same timezone as the DUE date.*/
- status = cal_client_get_timezone (model->priv->client, dt.tzid,
- &zone);
- if (status != CAL_CLIENT_GET_SUCCESS) {
- retval = CALENDAR_MODEL_DUE_FUTURE;
- goto out;
- }
-
- now_tt = icaltime_current_time_with_zone (zone);
-
- if (icaltime_compare (*dt.value, now_tt) <= 0)
- retval = CALENDAR_MODEL_DUE_OVERDUE;
- else
- if (icaltime_compare_date_only (*dt.value, now_tt) == 0)
- retval = CALENDAR_MODEL_DUE_TODAY;
- else
- retval = CALENDAR_MODEL_DUE_FUTURE;
- }
- }
-
- out:
-
- cal_component_free_datetime (&dt);
-
- return retval;
-}
-
-/* Returns whether a component is overdue. */
-static gboolean
-is_overdue (CalendarModel *model, CalComponent *comp)
-{
- switch (get_due_status (model, comp)) {
- case CALENDAR_MODEL_DUE_NEVER:
- case CALENDAR_MODEL_DUE_FUTURE:
- case CALENDAR_MODEL_DUE_COMPLETE:
- return FALSE;
- case CALENDAR_MODEL_DUE_TODAY:
- case CALENDAR_MODEL_DUE_OVERDUE:
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* Computes the color to be used to display a component */
-static const char *
-get_color (CalendarModel *model, CalComponent *comp)
-{
- switch (get_due_status (model, comp)) {
- case CALENDAR_MODEL_DUE_NEVER:
- case CALENDAR_MODEL_DUE_FUTURE:
- case CALENDAR_MODEL_DUE_COMPLETE:
- return NULL;
- case CALENDAR_MODEL_DUE_TODAY:
- return calendar_config_get_tasks_due_today_color ();
- case CALENDAR_MODEL_DUE_OVERDUE:
- return calendar_config_get_tasks_overdue_color ();
- }
-
- return NULL;
-}
-
-static void *
-get_status (CalComponent *comp)
-{
- icalproperty_status status;
-
- cal_component_get_status (comp, &status);
-
- switch (status) {
- case ICAL_STATUS_NONE:
- return "";
-
- case ICAL_STATUS_NEEDSACTION:
- return _("Not Started");
-
- case ICAL_STATUS_INPROCESS:
- return _("In Progress");
-
- case ICAL_STATUS_COMPLETED:
- return _("Completed");
-
- case ICAL_STATUS_CANCELLED:
- return _("Cancelled");
-
- default:
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-#if 0
-static void *
-get_location (CalComponent *comp)
-{
- const char *location;
-
- cal_component_get_location (comp, &location);
- return (void*) location;
-}
-#endif
-
-/* value_at handler for the calendar table model */
-static void *
-calendar_model_value_at (ETableModel *etm, int col, int row)
-{
- CalendarModel *model;
- CalendarModelPrivate *priv;
- CalComponent *comp;
-
- model = CALENDAR_MODEL (etm);
- priv = model->priv;
-
- g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL);
- g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL);
-
- comp = g_array_index (priv->objects, CalComponent *, row);
- g_assert (comp != NULL);
-
-#if 0
- g_print ("In calendar_model_value_at: %i\n", col);
-#endif
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- return get_categories (comp);
-
- case CAL_COMPONENT_FIELD_CLASSIFICATION:
- return get_classification (comp);
-
- case CAL_COMPONENT_FIELD_COMPLETED:
- return get_completed (model, comp, row);
-
- case CAL_COMPONENT_FIELD_DTEND:
- case CAL_COMPONENT_FIELD_DTSTART:
- case CAL_COMPONENT_FIELD_DUE:
- return get_date_edit_value (model, comp, col, row);
-
- case CAL_COMPONENT_FIELD_GEO:
- return get_geo (comp);
-
- case CAL_COMPONENT_FIELD_PERCENT:
- return GINT_TO_POINTER (get_percent (comp));
-
- case CAL_COMPONENT_FIELD_PRIORITY:
- return get_priority (comp);
-
- case CAL_COMPONENT_FIELD_SUMMARY:
- return get_summary (comp);
-
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- return get_transparency (comp);
-
- case CAL_COMPONENT_FIELD_URL:
- return get_url (comp);
-
- case CAL_COMPONENT_FIELD_HAS_ALARMS:
- return GINT_TO_POINTER (cal_component_has_alarms (comp));
-
- case CAL_COMPONENT_FIELD_ICON:
- {
- GSList *attendees = NULL, *sl;
- gint retval = 0;
-
- if (cal_component_has_recurrences (comp))
- return GINT_TO_POINTER (1);
-
- if (itip_organizer_is_user (comp, priv->client))
- return GINT_TO_POINTER (3);
-
- cal_component_get_attendee_list (comp, &attendees);
- for (sl = attendees; sl != NULL; sl = sl->next) {
- CalComponentAttendee *ca = sl->data;
- const char *text;
-
- text = itip_strip_mailto (ca->value);
- if (e_account_list_find(priv->accounts, E_ACCOUNT_FIND_ID_ADDRESS, text) != NULL) {
- if (ca->delto != NULL)
- retval = 3;
- else
- retval = 2;
- break;
- }
- }
-
- cal_component_free_attendee_list (attendees);
- return GINT_TO_POINTER (retval);
- break;
- }
- case CAL_COMPONENT_FIELD_COMPLETE:
- return GINT_TO_POINTER (is_complete (comp));
-
- case CAL_COMPONENT_FIELD_RECURRING:
- return GINT_TO_POINTER (cal_component_has_recurrences (comp));
-
- case CAL_COMPONENT_FIELD_OVERDUE:
- return GINT_TO_POINTER (is_overdue (model, comp));
-
- case CAL_COMPONENT_FIELD_COLOR:
- return (void *) get_color (model, comp);
-
- case CAL_COMPONENT_FIELD_STATUS:
- return get_status (comp);
-
- case CAL_COMPONENT_FIELD_COMPONENT:
- return comp;
-
-#if 0
- case CAL_COMPONENT_FIELD_LOCATION :
- return get_location (comp);
-#endif
-
- default:
- g_message ("calendar_model_value_at(): Requested invalid column %d", col);
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-/* Builds a list of categories from a comma-delimited string */
-static GSList *
-categories_from_string (const char *value)
-{
- GSList *list;
- const char *categ_start;
- const char *categ_end;
- const char *p;
-
- if (!value)
- return NULL;
-
- list = NULL;
-
- categ_start = categ_end = NULL;
-
- for (p = value; *p; p++) {
- if (categ_start) {
- if (*p == ',') {
- char *c;
-
- c = g_strndup (categ_start, categ_end - categ_start + 1);
- list = g_slist_prepend (list, c);
-
- categ_start = categ_end = NULL;
- } else if (!isspace (*p))
- categ_end = p;
- } else if (!isspace (*p) && *p != ',')
- categ_start = categ_end = p;
- }
-
- if (categ_start) {
- char *c;
-
- c = g_strndup (categ_start, categ_end - categ_start + 1);
- list = g_slist_prepend (list, c);
- }
-
- return g_slist_reverse (list);
-}
-
-/* Sets the list of categories from a comma-delimited string */
-static void
-set_categories (CalComponent *comp, const char *value)
-{
- GSList *list;
- GSList *l;
-
- list = categories_from_string (value);
-
- cal_component_set_categories_list (comp, list);
-
- for (l = list; l; l = l->next) {
- char *s;
-
- s = l->data;
- g_free (s);
- }
-
- g_slist_free (list);
-}
-
-
-static void
-set_classification (CalComponent *comp,
- const char *value)
-{
- CalComponentClassification classif;
-
- if (!g_strcasecmp (value, _("Private")))
- classif = CAL_COMPONENT_CLASS_PRIVATE;
- else if (!g_strcasecmp (value, _("Confidential")))
- classif = CAL_COMPONENT_CLASS_CONFIDENTIAL;
- else
- classif = CAL_COMPONENT_CLASS_PUBLIC;
-
- cal_component_set_classification (comp, classif);
-}
-
-
-/* Called to set the "Date Completed" field. We also need to update the
- Status and Percent fields to make sure they match. */
-static void
-set_completed (CalendarModel *model, CalComponent *comp, const void *value)
-{
- CalendarModelPrivate *priv = model->priv;
- ECellDateEditValue *dv = (ECellDateEditValue*) value;
-
- if (!dv) {
- ensure_task_not_complete (comp);
- } else {
- time_t t;
-
- if (dv->tt.is_date) {
- /* If its a date, it will be floating,
- but completed needs a date time value */
- dv->tt.is_date = FALSE;
- t = icaltime_as_timet_with_zone (dv->tt, priv->zone);
- } else {
- /* We assume that COMPLETED is entered in the current timezone,
- even though it gets stored in UTC. */
- t = icaltime_as_timet_with_zone (dv->tt, dv->zone);
- }
-
- ensure_task_complete (comp, t);
- }
-}
-
-/* Sets a CalComponentDateTime value */
-static void
-set_datetime (CalendarModel *model, CalComponent *comp, const void *value,
- void (* set_func) (CalComponent *comp, CalComponentDateTime *dt),
- gboolean is_dtend)
-{
- ECellDateEditValue *dv = (ECellDateEditValue*) value;
-
- if (!dv) {
- (* set_func) (comp, NULL);
- } else {
- CalComponentDateTime dt;
-
- dt.value = &dv->tt;
- dt.tzid = icaltimezone_get_tzid (dv->zone);
-
- /* For a DTEND with a DATE value, we add 1 day to it. */
- if (is_dtend && dt.value->is_date) {
- icaltime_adjust (dt.value, 1, 0, 0, 0);
- }
-
- (* set_func) (comp, &dt);
- }
-}
-
-/* FIXME: We need to set the "transient_for" property for the dialog, but the
- * model doesn't know anything about the windows.
- */
-static void
-show_geo_warning (void)
-{
- GtkWidget *dialog;
-
- dialog = gnome_message_box_new (_("The geographical position must be entered "
- "in the format: \n\n45.436845,125.862501"),
- GNOME_MESSAGE_BOX_ERROR,
- GNOME_STOCK_BUTTON_OK, NULL);
- gtk_widget_show (dialog);
-}
-
-/* Sets the geographical position value of a component */
-static void
-set_geo (CalComponent *comp, const char *value)
-{
- double latitude, longitude;
- int matched;
- struct icalgeotype geo;
-
- if (string_is_empty (value)) {
- cal_component_set_geo (comp, NULL);
- return;
- }
-
- matched = sscanf (value, "%lg , %lg", &latitude, &longitude);
-
- if (matched != 2) {
- show_geo_warning ();
- return;
- }
-
- geo.lat = latitude;
- geo.lon = longitude;
- cal_component_set_geo (comp, &geo);
-}
-
-/* Sets the percent value of a calendar component */
-static void
-set_percent (CalComponent *comp, const void *value)
-{
- gint percent = GPOINTER_TO_INT (value);
-
- g_return_if_fail (percent >= -1);
- g_return_if_fail (percent <= 100);
-
- /* A value of -1 means it isn't set. */
- if (percent == -1) {
- cal_component_set_percent (comp, NULL);
- ensure_task_not_complete (comp);
- } else {
- cal_component_set_percent (comp, &percent);
-
- if (percent == 100)
- ensure_task_complete (comp, -1);
- else {
- ensure_task_not_complete (comp);
- if (percent > 0)
- cal_component_set_status (comp, ICAL_STATUS_INPROCESS);
- }
- }
-}
-
-/* Sets the priority of a calendar component */
-static void
-set_priority (CalComponent *comp, const char *value)
-{
- int priority;
-
- priority = cal_util_priority_from_string (value);
- /* If the priority is invalid (which should never happen) output a
- warning and set it to undefined. */
- if (priority == -1) {
- g_warning ("Invalid priority");
- priority = 0;
- }
-
- cal_component_set_priority (comp, &priority);
-}
-
-/* Sets the summary of a calendar component */
-static void
-set_summary (CalComponent *comp, const char *value)
-{
- CalComponentText text;
-
- if (string_is_empty (value)) {
- cal_component_set_summary (comp, NULL);
- return;
- }
-
- text.value = value;
- text.altrep = NULL; /* FIXME: should we preserve the old ALTREP? */
-
- cal_component_set_summary (comp, &text);
-}
-
-/* Sets the transparency of a calendar component */
-static void
-set_transparency (CalComponent *comp, const char *value)
-{
- CalComponentTransparency transp;
-
- if (!g_strcasecmp (value, _("Free")))
- transp = CAL_COMPONENT_TRANSP_TRANSPARENT;
- else
- transp = CAL_COMPONENT_TRANSP_OPAQUE;
-
- cal_component_set_transparency (comp, transp);
-}
-
-/* Sets the URI of a calendar component */
-static void
-set_url (CalComponent *comp, const char *value)
-{
- if (string_is_empty (value)) {
- cal_component_set_url (comp, NULL);
- return;
- }
-
- cal_component_set_url (comp, value);
-}
-
-/* Called to set the checkbutton field which indicates whether a task is
- complete. */
-static void
-set_complete (CalComponent *comp, const void *value)
-{
- gint state = GPOINTER_TO_INT (value);
-
- if (state) {
- ensure_task_complete (comp, -1);
- } else {
- ensure_task_not_complete (comp);
- }
-}
-
-/* Sets the status of a calendar component. */
-static void
-set_status (CalComponent *comp, const char *value)
-{
- icalproperty_status status;
- int percent;
-
- /* An empty string is the same as 'None'. */
- if (!value[0] || !g_strcasecmp (value, _("None")))
- status = ICAL_STATUS_NONE;
- else if (!g_strcasecmp (value, _("Not Started")))
- status = ICAL_STATUS_NEEDSACTION;
- else if (!g_strcasecmp (value, _("In Progress")))
- status = ICAL_STATUS_INPROCESS;
- else if (!g_strcasecmp (value, _("Completed")))
- status = ICAL_STATUS_COMPLETED;
- else if (!g_strcasecmp (value, _("Cancelled")))
- status = ICAL_STATUS_CANCELLED;
- else {
- g_warning ("Invalid status: %s\n", value);
- return;
- }
-
- cal_component_set_status (comp, status);
-
- if (status == ICAL_STATUS_NEEDSACTION) {
- percent = 0;
- cal_component_set_percent (comp, &percent);
- cal_component_set_completed (comp, NULL);
- } else if (status == ICAL_STATUS_INPROCESS) {
- ensure_task_not_complete (comp);
- percent = 50;
- cal_component_set_percent (comp, &percent);
- } else if (status == ICAL_STATUS_COMPLETED) {
- ensure_task_complete (comp, -1);
- }
-}
-
-#if 0
-static void
-set_location (CalComponent *comp, const char *value)
-{
- if (string_is_empty (value)) {
- cal_component_set_location (comp, NULL);
- return;
- }
-
- cal_component_set_location (comp, value);
-}
-#endif
-
-/* 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;
- CalComponent *comp;
-
- model = CALENDAR_MODEL (etm);
- priv = model->priv;
-
- g_return_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS);
- g_return_if_fail (row >= 0 && row < priv->objects->len);
-
- comp = g_array_index (priv->objects, CalComponent *, row);
- g_assert (comp != NULL);
-
-#if 0
- g_print ("In calendar_model_set_value_at: %i\n", col);
-#endif
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- set_categories (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_CLASSIFICATION:
- set_classification (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_COMPLETED:
- set_completed (model, comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_DTEND:
- /* FIXME: Need to reset dtstart if dtend happens before it */
- set_datetime (model, comp, value, cal_component_set_dtend,
- TRUE);
- break;
-
- case CAL_COMPONENT_FIELD_DTSTART:
- /* FIXME: Need to reset dtend if dtstart happens after it */
- set_datetime (model, comp, value, cal_component_set_dtstart,
- FALSE);
- break;
-
- case CAL_COMPONENT_FIELD_DUE:
- set_datetime (model, comp, value, cal_component_set_due,
- FALSE);
- break;
-
- case CAL_COMPONENT_FIELD_GEO:
- set_geo (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_PERCENT:
- set_percent (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_PRIORITY:
- set_priority (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_SUMMARY:
- set_summary (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- set_transparency (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_URL:
- set_url (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_COMPLETE:
- set_complete (comp, value);
- break;
-
- case CAL_COMPONENT_FIELD_STATUS:
- set_status (comp, value);
- break;
-
-#if 0
- case CAL_COMPONENT_FIELD_LOCATION :
- set_location (comp, value);
- break;
-#endif
-
- default:
- g_message ("calendar_model_set_value_at(): Requested invalid column %d", col);
- g_assert_not_reached ();
- return;
- }
-
- if (cal_client_update_object (priv->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
- 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 < CAL_COMPONENT_FIELD_NUM_FIELDS, FALSE);
-
- /* FIXME: We can't check this as 'click-to-add' passes row 0. */
- /*g_return_val_if_fail (row >= 0 && row < priv->objects->len, FALSE);*/
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- case CAL_COMPONENT_FIELD_CLASSIFICATION:
- case CAL_COMPONENT_FIELD_COMPLETED:
- case CAL_COMPONENT_FIELD_DTEND:
- case CAL_COMPONENT_FIELD_DTSTART:
- case CAL_COMPONENT_FIELD_DUE:
- case CAL_COMPONENT_FIELD_GEO:
- case CAL_COMPONENT_FIELD_PERCENT:
- case CAL_COMPONENT_FIELD_PRIORITY:
- case CAL_COMPONENT_FIELD_SUMMARY:
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- case CAL_COMPONENT_FIELD_URL:
- case CAL_COMPONENT_FIELD_COMPLETE:
- case CAL_COMPONENT_FIELD_STATUS:
- return TRUE;
-
- default:
- return FALSE;
- }
-}
-
-/* append_row handler for the calendar model */
-static void
-calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row)
-{
- CalendarModel *model;
- CalendarModelPrivate *priv;
- CalComponent *comp;
-
- model = CALENDAR_MODEL (etm);
- priv = model->priv;
-
- /* Guard against saving before the calendar is open */
- if (!(priv->client && cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED))
- return;
-
- /* FIXME: This should also support journal components */
- switch (priv->new_comp_vtype) {
- case CAL_COMPONENT_EVENT:
- comp = cal_comp_event_new_with_defaults (priv->client);
- break;
- case CAL_COMPONENT_TODO:
- comp = cal_comp_task_new_with_defaults (priv->client);
- break;
- default:
- comp = cal_component_new ();
- cal_component_set_new_vtype (comp, priv->new_comp_vtype);
- }
-
- set_categories (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_CATEGORIES, row));
- set_classification (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_CLASSIFICATION, row));
- set_completed (model, comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_COMPLETED, row));
- /* FIXME: Need to reset dtstart if dtend happens before it */
- set_datetime (model, comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_DTEND, row), cal_component_set_dtend, TRUE);
- /* FIXME: Need to reset dtend if dtstart happens after it */
- set_datetime (model, comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_DTSTART, row), cal_component_set_dtstart, FALSE);
- set_datetime (model, comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_DUE, row), cal_component_set_due, FALSE);
- set_geo (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_GEO, row));
- set_percent (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_PERCENT, row));
- set_priority (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_PRIORITY, row));
- set_summary (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_SUMMARY, row));
- set_transparency (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_TRANSPARENCY, row));
- set_url (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_URL, row));
- set_complete (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_COMPLETE, row));
- set_status (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_STATUS, row));
-
- if (cal_client_update_object (priv->client, comp) != CAL_CLIENT_RESULT_SUCCESS) {
- /* FIXME: Show error dialog. */
- g_message ("calendar_model_append_row(): Could not add new object!");
- }
-
- g_object_unref (comp);
-}
-
-/* Duplicates a string value */
-static char *
-dup_string (const char *value)
-{
- return g_strdup (value);
-}
-
-static void*
-dup_date_edit_value (const void *value)
-{
- ECellDateEditValue *dv, *orig_dv;
-
- if (value == NULL)
- return NULL;
-
- orig_dv = (ECellDateEditValue*) value;
-
- dv = g_new (ECellDateEditValue, 1);
- *dv = *orig_dv;
-
- return dv;
-}
-
-/* duplicate_value handler for the calendar table model */
-static void *
-calendar_model_duplicate_value (ETableModel *etm, int col, const void *value)
-{
- g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL);
-
- /* They are almost all dup_string()s for now, but we'll have real fields
- * later.
- */
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- case CAL_COMPONENT_FIELD_CLASSIFICATION:
- case CAL_COMPONENT_FIELD_GEO:
- case CAL_COMPONENT_FIELD_PRIORITY:
- case CAL_COMPONENT_FIELD_SUMMARY:
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- case CAL_COMPONENT_FIELD_URL:
- case CAL_COMPONENT_FIELD_STATUS:
- return dup_string (value);
-
- case CAL_COMPONENT_FIELD_COMPLETED:
- case CAL_COMPONENT_FIELD_DTEND:
- case CAL_COMPONENT_FIELD_DTSTART:
- case CAL_COMPONENT_FIELD_DUE:
- return dup_date_edit_value (value);
-
- case CAL_COMPONENT_FIELD_HAS_ALARMS:
- case CAL_COMPONENT_FIELD_ICON:
- case CAL_COMPONENT_FIELD_COMPLETE:
- case CAL_COMPONENT_FIELD_PERCENT:
- case CAL_COMPONENT_FIELD_RECURRING:
- case CAL_COMPONENT_FIELD_OVERDUE:
- case CAL_COMPONENT_FIELD_COLOR:
- return (void *) value;
-
- case CAL_COMPONENT_FIELD_COMPONENT: {
- CalComponent *comp;
-
- comp = CAL_COMPONENT (value);
- g_object_ref (comp);
- return comp;
- }
-
- default:
- g_message ("calendar_model_duplicate_value(): Requested invalid column %d", col);
- return NULL;
- }
-}
-
-/* free_value handler for the calendar table model */
-static void
-calendar_model_free_value (ETableModel *etm, int col, void *value)
-{
- g_return_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS);
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- if (value)
- g_free (value);
- break;
-
- case CAL_COMPONENT_FIELD_CLASSIFICATION:
- break;
-
- case CAL_COMPONENT_FIELD_COMPLETED:
- case CAL_COMPONENT_FIELD_DTEND:
- case CAL_COMPONENT_FIELD_DTSTART:
- case CAL_COMPONENT_FIELD_DUE:
- case CAL_COMPONENT_FIELD_GEO:
- case CAL_COMPONENT_FIELD_PRIORITY:
- case CAL_COMPONENT_FIELD_SUMMARY:
- case CAL_COMPONENT_FIELD_STATUS:
- if (value)
- g_free (value);
- break;
-
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- break;
-
- case CAL_COMPONENT_FIELD_URL:
- if (value)
- g_free (value);
- break;
-
- case CAL_COMPONENT_FIELD_PERCENT:
- case CAL_COMPONENT_FIELD_HAS_ALARMS:
- case CAL_COMPONENT_FIELD_ICON:
- case CAL_COMPONENT_FIELD_COMPLETE:
- case CAL_COMPONENT_FIELD_RECURRING:
- case CAL_COMPONENT_FIELD_OVERDUE:
- case CAL_COMPONENT_FIELD_COLOR:
- break;
-
- case CAL_COMPONENT_FIELD_COMPONENT:
- if (value)
- g_object_unref (value);
- break;
-
- default:
- g_message ("calendar_model_free_value(): Requested invalid column %d", col);
- }
-}
-
-/* Initializes a string value */
-static char *
-init_string (void)
-{
- return g_strdup ("");
-}
-
-/* initialize_value handler for the calendar table model */
-static void *
-calendar_model_initialize_value (ETableModel *etm, int col)
-{
- CalendarModel *model;
-
- g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL);
-
- model = CALENDAR_MODEL (etm);
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- return g_strdup (model->priv->default_category ? model->priv->default_category : "");
-
- case CAL_COMPONENT_FIELD_CLASSIFICATION:
- case CAL_COMPONENT_FIELD_GEO:
- case CAL_COMPONENT_FIELD_PRIORITY:
- case CAL_COMPONENT_FIELD_SUMMARY:
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- case CAL_COMPONENT_FIELD_URL:
- case CAL_COMPONENT_FIELD_STATUS:
- return init_string ();
-
- case CAL_COMPONENT_FIELD_COMPLETED:
- case CAL_COMPONENT_FIELD_DTEND:
- case CAL_COMPONENT_FIELD_DTSTART:
- case CAL_COMPONENT_FIELD_DUE:
- case CAL_COMPONENT_FIELD_HAS_ALARMS:
- case CAL_COMPONENT_FIELD_ICON:
- case CAL_COMPONENT_FIELD_COMPLETE:
- case CAL_COMPONENT_FIELD_RECURRING:
- case CAL_COMPONENT_FIELD_OVERDUE:
- case CAL_COMPONENT_FIELD_COLOR:
- case CAL_COMPONENT_FIELD_COMPONENT:
- return NULL;
-
- case CAL_COMPONENT_FIELD_PERCENT:
- return GINT_TO_POINTER (-1);
-
- default:
- g_message ("calendar_model_initialize_value(): Requested invalid column %d", col);
- return NULL;
- }
-}
-
-/* value_is_empty handler for the calendar model. This should return TRUE
- unless a significant value has been set. The 'click-to-add' feature
- checks all fields to see if any are not empty and if so it adds a new
- row, so we only want to return FALSE if we have a useful object. */
-static gboolean
-calendar_model_value_is_empty (ETableModel *etm, int col, const void *value)
-{
- CalendarModel *model;
- CalendarModelPrivate *priv;
-
- g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, TRUE);
-
- model = CALENDAR_MODEL (etm);
- priv = model->priv;
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- /* This could be a hack or not. If the categories field only
- * contains the default category, then it possibly means that
- * the user has not entered anything at all in the click-to-add;
- * the category is in the value because we put it there in
- * calendar_model_initialize_value().
- */
- if (priv->default_category && value && strcmp (priv->default_category, value) == 0)
- return TRUE;
- else
- return string_is_empty (value);
-
- case CAL_COMPONENT_FIELD_CLASSIFICATION: /* actually goes here, not by itself */
- case CAL_COMPONENT_FIELD_GEO:
- case CAL_COMPONENT_FIELD_PRIORITY:
- case CAL_COMPONENT_FIELD_SUMMARY:
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- case CAL_COMPONENT_FIELD_URL:
- case CAL_COMPONENT_FIELD_STATUS:
- return string_is_empty (value);
-
- case CAL_COMPONENT_FIELD_COMPLETED:
- case CAL_COMPONENT_FIELD_DTEND:
- case CAL_COMPONENT_FIELD_DTSTART:
- case CAL_COMPONENT_FIELD_DUE:
- return value ? FALSE : TRUE;
-
- case CAL_COMPONENT_FIELD_PERCENT:
- return (GPOINTER_TO_INT (value) < 0) ? TRUE : FALSE;
-
- case CAL_COMPONENT_FIELD_HAS_ALARMS:
- case CAL_COMPONENT_FIELD_ICON:
- case CAL_COMPONENT_FIELD_COMPLETE:
- case CAL_COMPONENT_FIELD_RECURRING:
- case CAL_COMPONENT_FIELD_OVERDUE:
- case CAL_COMPONENT_FIELD_COLOR:
- case CAL_COMPONENT_FIELD_COMPONENT:
- return TRUE;
-
- default:
- g_message ("calendar_model_value_is_empty(): Requested invalid column %d", col);
- return TRUE;
- }
-}
-
-static char*
-date_value_to_string (ETableModel *etm, const void *value)
-{
- CalendarModel *model;
- CalendarModelPrivate *priv;
- ECellDateEditValue *dv = (ECellDateEditValue *) value;
- struct icaltimetype tt;
- struct tm tmp_tm;
- char buffer[64];
-
- model = CALENDAR_MODEL (etm);
- priv = model->priv;
-
- if (!dv)
- return g_strdup ("");
-
- /* We currently convert all the dates to the current timezone. */
- tt = dv->tt;
- icaltimezone_convert_time (&tt, dv->zone, priv->zone);
-
- tmp_tm.tm_year = tt.year - 1900;
- tmp_tm.tm_mon = tt.month - 1;
- tmp_tm.tm_mday = tt.day;
- tmp_tm.tm_hour = tt.hour;
- tmp_tm.tm_min = tt.minute;
- tmp_tm.tm_sec = tt.second;
- tmp_tm.tm_isdst = -1;
-
- tmp_tm.tm_wday = time_day_of_week (tt.day, tt.month - 1, tt.year);
-
- e_time_format_date_and_time (&tmp_tm, priv->use_24_hour_format,
- TRUE, FALSE,
- buffer, sizeof (buffer));
- return g_strdup (buffer);
-}
-
-
-static char *
-calendar_model_value_to_string (ETableModel *etm, int col, const void *value)
-{
- g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL);
-
- switch (col) {
- case CAL_COMPONENT_FIELD_CATEGORIES:
- case CAL_COMPONENT_FIELD_CLASSIFICATION:
- case CAL_COMPONENT_FIELD_GEO:
- case CAL_COMPONENT_FIELD_PRIORITY:
- case CAL_COMPONENT_FIELD_SUMMARY:
- case CAL_COMPONENT_FIELD_TRANSPARENCY:
- case CAL_COMPONENT_FIELD_URL:
- case CAL_COMPONENT_FIELD_STATUS:
- return g_strdup (value);
-
- case CAL_COMPONENT_FIELD_COMPLETED:
- case CAL_COMPONENT_FIELD_DTEND:
- case CAL_COMPONENT_FIELD_DTSTART:
- case CAL_COMPONENT_FIELD_DUE:
- return date_value_to_string (etm, value);
-
- case CAL_COMPONENT_FIELD_ICON:
- if (GPOINTER_TO_INT (value) == 0)
- return _("Normal");
- else if (GPOINTER_TO_INT (value) == 1)
- return _("Recurring");
- else
- return _("Assigned");
-
- case CAL_COMPONENT_FIELD_HAS_ALARMS:
- case CAL_COMPONENT_FIELD_COMPLETE:
- case CAL_COMPONENT_FIELD_RECURRING:
- case CAL_COMPONENT_FIELD_OVERDUE:
- return value ? _("Yes") : _("No");
-
- case CAL_COMPONENT_FIELD_COLOR:
- return NULL;
-
- case CAL_COMPONENT_FIELD_COMPONENT:
- return NULL;
-
- case CAL_COMPONENT_FIELD_PERCENT:
- if (GPOINTER_TO_INT (value) < 0)
- return g_strdup ("N/A");
- else
- return g_strdup_printf ("%i%%", GPOINTER_TO_INT (value));
-
- default:
- g_message ("calendar_model_value_as_string(): Requested invalid column %d", col);
- return NULL;
- }
-}
-
-
-
-/**
- * calendar_model_new:
- *
- * Creates a new calendar model. It must be told about the calendar client
- * interface object it will monitor with calendar_model_set_cal_client().
- *
- * Return value: A newly-created calendar model.
- **/
-CalendarModel *
-calendar_model_new (void)
-{
- return CALENDAR_MODEL (g_object_new (TYPE_CALENDAR_MODEL, NULL));
-}
-
-
-/* Callback used when a component is updated in the live query */
-static void
-query_obj_updated_cb (CalQuery *query, const char *uid,
- gboolean query_in_progress, int n_scanned, int total,
- gpointer data)
-{
- CalendarModel *model;
- CalendarModelPrivate *priv;
- int orig_idx;
- CalComponent *new_comp;
- icalcomponent *icalcomp;
- const char *new_comp_uid;
- int *new_idx;
- CalClientGetStatus status;
- CalendarModelObjectData new_object_data = { NULL, NULL, NULL, NULL };
-
- model = CALENDAR_MODEL (data);
- priv = model->priv;
-
- e_table_model_pre_change (E_TABLE_MODEL (model));
-
- orig_idx = remove_object (model, uid);
-
- status = cal_client_get_object (priv->client, uid, &icalcomp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- new_comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (new_comp, icalcomp)) {
- g_object_unref (new_comp);
- icalcomponent_free (icalcomp);
-
- if (orig_idx != -1)
- e_table_model_row_deleted (E_TABLE_MODEL (model), orig_idx);
- else
- e_table_model_no_change (E_TABLE_MODEL (model));
- break;
- }
-
- /* Insert the object into the model */
-
- cal_component_get_uid (new_comp, &new_comp_uid);
-
- if (orig_idx == -1) {
- /* The object not in the model originally, so we just append it */
-
- g_array_append_val (priv->objects, new_comp);
- g_array_append_val (priv->objects_data, new_object_data);
-
- new_idx = g_new (int, 1);
- *new_idx = priv->objects->len - 1;
-
- g_hash_table_insert (priv->uid_index_hash, (char *) new_comp_uid, new_idx);
- e_table_model_row_inserted (E_TABLE_MODEL (model), *new_idx);
- } else {
- int i;
-
- /* Insert the new version of the object in its old position */
-
- g_array_insert_val (priv->objects, orig_idx, new_comp);
- g_array_insert_val (priv->objects_data, orig_idx,
- new_object_data);
-
- new_idx = g_new (int, 1);
- *new_idx = orig_idx;
- g_hash_table_insert (priv->uid_index_hash, (char *) new_comp_uid, new_idx);
-
- /* Increase the indices of all subsequent objects */
-
- for (i = orig_idx + 1; i < priv->objects->len; i++) {
- CalComponent *comp;
- int *comp_idx;
- const char *comp_uid;
-
- comp = g_array_index (priv->objects, CalComponent *, i);
- g_assert (comp != NULL);
-
- cal_component_get_uid (comp, &comp_uid);
-
- comp_idx = g_hash_table_lookup (priv->uid_index_hash, comp_uid);
- g_assert (comp_idx != NULL);
-
- (*comp_idx)++;
- }
-
- e_table_model_row_changed (E_TABLE_MODEL (model), *new_idx);
- }
-
- break;
-
- case CAL_CLIENT_GET_NOT_FOUND:
- /* Nothing; the object may have been removed from the server. We just
- * notify that the old object was deleted.
- */
- if (orig_idx != -1)
- e_table_model_row_deleted (E_TABLE_MODEL (model), orig_idx);
- else
- e_table_model_no_change (E_TABLE_MODEL (model));
-
- break;
-
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid);
-
- /* Same notification as above */
- if (orig_idx != -1)
- e_table_model_row_deleted (E_TABLE_MODEL (model), orig_idx);
- else
- e_table_model_no_change (E_TABLE_MODEL (model));
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-/* Callback used when a component is removed from the live query */
-static void
-query_obj_removed_cb (CalQuery *query, const char *uid, gpointer data)
-{
- CalendarModel *model;
- int idx;
-
- model = CALENDAR_MODEL (data);
-
- e_table_model_pre_change (E_TABLE_MODEL (model));
-
- idx = remove_object (model, uid);
-
- if (idx != -1)
- e_table_model_row_deleted (E_TABLE_MODEL (model), idx);
- else
- e_table_model_no_change (E_TABLE_MODEL (model));
-}
-
-/* Callback used when a query ends */
-static void
-query_query_done_cb (CalQuery *query, CalQueryDoneStatus status, const char *error_str, gpointer data)
-{
- CalendarModel *model;
-
- model = CALENDAR_MODEL (data);
-
- /* FIXME */
-
- calendar_model_set_status_message (model, NULL);
-
- if (status != CAL_QUERY_DONE_SUCCESS)
- g_warning ("query done: %s\n", error_str);
-}
-
-/* Callback used when an evaluation error occurs when running a query */
-static void
-query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
-{
- CalendarModel *model;
-
- model = CALENDAR_MODEL (data);
-
- /* FIXME */
-
- calendar_model_set_status_message (model, NULL);
-
- g_warning ("eval error: %s\n", error_str);
-}
-
-/* Builds a complete query sexp for the calendar model by adding the predicates
- * to filter only for the type of objects that the model supports, and
- * whether we want completed tasks.
- */
-static char *
-adjust_query_sexp (CalendarModel *model, const char *sexp)
-{
- CalendarModelPrivate *priv;
- CalObjType type;
- char *type_sexp;
- char *completed_sexp;
- char *new_sexp;
-
- priv = model->priv;
-
- type = priv->type;
-
- if (!(type & CALOBJ_TYPE_ANY))
- type_sexp = g_strdup ("#t");
- else
- type_sexp = g_strdup_printf (
- "(or %s %s %s)",
- (type & CALOBJ_TYPE_EVENT) ? "(= (get-vtype) \"VEVENT\")" : "",
- (type & CALOBJ_TYPE_TODO) ? "(= (get-vtype) \"VTODO\")" : "",
- (type & CALOBJ_TYPE_JOURNAL) ? "(= (get-vtype) \"VJOURNAL\")" : "");
-
- /* Create a sub-expression for filtering out completed tasks, based on
- the config settings. */
- completed_sexp = calendar_config_get_hide_completed_tasks_sexp ();
-
- new_sexp = g_strdup_printf ("(and %s %s %s)", type_sexp,
- completed_sexp ? completed_sexp : "",
- sexp);
- g_free (type_sexp);
- g_free (completed_sexp);
-
-#if 0
- g_print ("Calendar model sexp:\n%s\n", new_sexp);
-#endif
-
- return new_sexp;
-}
-
-/* Restarts a query */
-static void
-update_query (CalendarModel *model)
-{
- CalendarModelPrivate *priv;
- CalQuery *old_query;
- char *real_sexp;
-
- priv = model->priv;
-
- e_table_model_pre_change (E_TABLE_MODEL (model));
- free_objects (model);
- e_table_model_changed (E_TABLE_MODEL (model));
-
- if (!(priv->client
- && cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED))
- return;
-
- old_query = priv->query;
- priv->query = NULL;
-
- if (old_query) {
- g_signal_handlers_disconnect_matched (old_query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, model);
- g_object_unref (old_query);
- }
-
- g_assert (priv->sexp != NULL);
- real_sexp = adjust_query_sexp (model, priv->sexp);
-
- calendar_model_set_status_message (model, _("Searching"));
- priv->query = cal_client_get_query (priv->client, real_sexp);
- g_free (real_sexp);
-
- if (!priv->query) {
- g_message ("update_query(): Could not create the query");
- calendar_model_set_status_message (model, NULL);
- return;
- }
-
- g_signal_connect (priv->query, "obj_updated",
- G_CALLBACK (query_obj_updated_cb), model);
- g_signal_connect (priv->query, "obj_removed",
- G_CALLBACK (query_obj_removed_cb), model);
- g_signal_connect (priv->query, "query_done",
- G_CALLBACK (query_query_done_cb), model);
- g_signal_connect (priv->query, "eval_error",
- G_CALLBACK (query_eval_error_cb), model);
-}
-
-/* Callback used when a calendar is opened into the server */
-static void
-cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data)
-{
- CalendarModel *model;
-
- model = CALENDAR_MODEL (data);
-
- if (status != CAL_CLIENT_OPEN_SUCCESS)
- return;
-
- update_query (model);
-}
-
-
-/* Removes an object from the model and updates all the indices that follow.
- * Returns the index of the object that was removed, or -1 if no object with
- * such UID was found.
- */
-static int
-remove_object (CalendarModel *model, const char *uid)
-{
- CalendarModelPrivate *priv;
- int *idx;
- CalComponent *orig_comp;
- int i;
- int n;
- CalendarModelObjectData *object_data;
-
- priv = model->priv;
-
- /* Find the index of the object to be removed */
-
- idx = g_hash_table_lookup (priv->uid_index_hash, uid);
- if (!idx)
- return -1;
-
- orig_comp = g_array_index (priv->objects, CalComponent *, *idx);
- g_assert (orig_comp != NULL);
-
- /* Decrease the indices of all the objects that follow in the array */
-
- for (i = *idx + 1; i < priv->objects->len; i++) {
- CalComponent *comp;
- int *comp_idx;
- const char *comp_uid;
-
- comp = g_array_index (priv->objects, CalComponent *, i);
- g_assert (comp != NULL);
-
- cal_component_get_uid (comp, &comp_uid);
-
- comp_idx = g_hash_table_lookup (priv->uid_index_hash, comp_uid);
- g_assert (comp_idx != NULL);
-
- (*comp_idx)--;
- g_assert (*comp_idx >= 0);
- }
-
- /* Remove this object from the array and hash */
-
- g_hash_table_remove (priv->uid_index_hash, uid);
- g_array_remove_index (priv->objects, *idx);
-
- object_data = &g_array_index (priv->objects_data,
- CalendarModelObjectData, *idx);
- calendar_model_free_object_data (model, object_data);
- g_array_remove_index (priv->objects_data, *idx);
-
- g_object_unref (orig_comp);
-
- n = *idx;
- g_free (idx);
-
- return n;
-}
-
-/* Displays messages on the status bar */
-#define EVOLUTION_TASKS_PROGRESS_IMAGE "evolution-tasks-mini.png"
-static GdkPixbuf *progress_icon[2] = { NULL, NULL };
-
-void
-calendar_model_set_status_message (CalendarModel *model, const char *message)
-{
- extern EvolutionShellClient *global_shell_client; /* ugly */
- CalendarModelPrivate *priv;
-
- g_return_if_fail (IS_CALENDAR_MODEL (model));
-
- priv = model->priv;
-
- if (!message || !*message) {
- if (priv->activity) {
- g_object_unref (priv->activity);
- priv->activity = NULL;
- }
- }
- else if (!priv->activity) {
- int display;
- char *client_id = g_strdup_printf ("%p", model);
-
- if (progress_icon[0] == NULL)
- progress_icon[0] = gdk_pixbuf_new_from_file (EVOLUTION_IMAGESDIR "/" EVOLUTION_TASKS_PROGRESS_IMAGE, NULL);
- priv->activity = evolution_activity_client_new (
- global_shell_client, client_id,
- progress_icon, message, TRUE, &display);
-
- g_free (client_id);
- }
- else
- evolution_activity_client_update (priv->activity, message, -1.0);
-}
-
-/**
- * calendar_model_get_cal_client:
- * @model: A calendar model.
- *
- * Queries the calendar client interface object that a calendar model is using.
- *
- * Return value: A calendar client interface object.
- **/
-CalClient *
-calendar_model_get_cal_client (CalendarModel *model)
-{
- CalendarModelPrivate *priv;
-
- g_return_val_if_fail (model != NULL, NULL);
- g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL);
-
- priv = model->priv;
-
- return priv->client;
-}
-
-
-/**
- * calendar_model_set_cal_client:
- * @model: A calendar model.
- * @client: A calendar client interface object.
- * @type: Type of objects to present.
- *
- * Sets the calendar client interface object that a calendar model will monitor.
- * It also sets the types of objects this model will present to an #ETable.
- **/
-void
-calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjType type)
-{
- CalendarModelPrivate *priv;
-
- g_return_if_fail (model != NULL);
- g_return_if_fail (IS_CALENDAR_MODEL (model));
-
- if (client)
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- priv = model->priv;
-
- if (priv->client == client && priv->type == type)
- return;
-
- if (client)
- g_object_ref (client);
-
- if (priv->client) {
- g_signal_handlers_disconnect_matched (priv->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model);
- g_object_unref (priv->client);
- }
-
- priv->client = client;
- priv->type = type;
-
- if (priv->client) {
- if (cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED)
- update_query (model);
- else
- g_signal_connect (priv->client, "cal_opened", G_CALLBACK (cal_opened_cb), model);
- }
-}
-
-/**
- * calendar_model_set_query:
- * @model: A calendar model.
- * @sexp: Sexp that defines the query.
- *
- * Sets the query sexp that a calendar model will use to filter its contents.
- **/
-void
-calendar_model_set_query (CalendarModel *model, const char *sexp)
-{
- CalendarModelPrivate *priv;
-
- g_return_if_fail (model != NULL);
- g_return_if_fail (IS_CALENDAR_MODEL (model));
- g_return_if_fail (sexp != NULL);
-
- priv = model->priv;
-
- if (priv->sexp)
- g_free (priv->sexp);
-
- priv->sexp = g_strdup (sexp);
-
- update_query (model);
-}
-
-
-/**
- * calendar_model_set_new_comp_vtype:
- * @model: A calendar model.
- * @vtype: Type of calendar components to create.
- *
- * Sets the type of calendar components that will be created by a calendar table
- * model when the click-to-add functionality of the table is used.
- **/
-void
-calendar_model_set_new_comp_vtype (CalendarModel *model, CalComponentVType vtype)
-{
- CalendarModelPrivate *priv;
-
- g_return_if_fail (model != NULL);
- g_return_if_fail (IS_CALENDAR_MODEL (model));
- g_return_if_fail (vtype != CAL_COMPONENT_NO_TYPE);
-
- priv = model->priv;
- priv->new_comp_vtype = vtype;
-}
-
-/**
- * calendar_model_get_new_comp_vtype:
- * @model: A calendar model.
- *
- * Queries the type of calendar components that are created by a calendar table
- * model when using the click-to-add functionality in a table.
- *
- * Return value: Type of components that are created.
- **/
-CalComponentVType
-calendar_model_get_new_comp_vtype (CalendarModel *model)
-{
- CalendarModelPrivate *priv;
-
- g_return_val_if_fail (model != NULL, CAL_COMPONENT_NO_TYPE);
- g_return_val_if_fail (IS_CALENDAR_MODEL (model), CAL_COMPONENT_NO_TYPE);
-
- priv = model->priv;
- return priv->new_comp_vtype;
-}
-
-
-void
-calendar_model_mark_task_complete (CalendarModel *model,
- gint row)
-{
- CalendarModelPrivate *priv;
- CalComponent *comp;
-
- g_return_if_fail (model != NULL);
- g_return_if_fail (IS_CALENDAR_MODEL (model));
-
- priv = model->priv;
-
- g_return_if_fail (row >= 0 && row < priv->objects->len);
-
- comp = g_array_index (priv->objects, CalComponent *, row);
- g_assert (comp != NULL);
-
- ensure_task_complete (comp, -1);
-
- if (cal_client_update_object (priv->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
- g_message ("calendar_model_mark_task_complete(): Could not update the object!");
-}
-
-
-/**
- * calendar_model_get_component:
- * @model: A calendar model.
- * @row: Row number of sought calendar component.
- *
- * Queries a calendar component from a calendar model based on its row number.
- *
- * Return value: The sought calendar component.
- **/
-CalComponent *
-calendar_model_get_component (CalendarModel *model,
- gint row)
-{
- CalendarModelPrivate *priv;
-
- g_return_val_if_fail (model != NULL, NULL);
- g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL);
-
- priv = model->priv;
-
- g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL);
-
- return g_array_index (priv->objects, CalComponent *, row);
-}
-
-
-/* This makes sure a task is marked as complete.
- It makes sure the "Date Completed" property is set. If the completed_date
- is not -1, then that is used, otherwise if the "Date Completed" property
- is not already set it is set to the current time.
- It makes sure the percent is set to 100, and that the status is "Completed".
- Note that this doesn't update the component on the server. */
-static void
-ensure_task_complete (CalComponent *comp,
- time_t completed_date)
-{
- struct icaltimetype *old_completed = NULL;
- int *old_percent, new_percent;
- icalproperty_status status;
- gboolean set_completed = TRUE;
-
- /* Date Completed. */
- if (completed_date == -1) {
- cal_component_get_completed (comp, &old_completed);
-
- if (old_completed) {
- cal_component_free_icaltimetype (old_completed);
- set_completed = FALSE;
- } else {
- completed_date = time (NULL);
- }
- }
-
- if (set_completed) {
- icaltimezone *utc_zone;
- struct icaltimetype new_completed;
-
- /* COMPLETED is stored in UTC. */
- utc_zone = icaltimezone_get_utc_timezone ();
- new_completed = icaltime_from_timet_with_zone (completed_date,
- FALSE,
- utc_zone);
- cal_component_set_completed (comp, &new_completed);
- }
-
- /* Percent. */
- cal_component_get_percent (comp, &old_percent);
- if (!old_percent || *old_percent != 100) {
- new_percent = 100;
- cal_component_set_percent (comp, &new_percent);
- }
- if (old_percent)
- cal_component_free_percent (old_percent);
-
- /* Status. */
- cal_component_get_status (comp, &status);
- if (status != ICAL_STATUS_COMPLETED) {
- cal_component_set_status (comp, ICAL_STATUS_COMPLETED);
- }
-}
-
-
-/* This makes sure a task is marked as incomplete. It clears the
- "Date Completed" property. If the percent is set to 100 it removes it,
- and if the status is "Completed" it sets it to "Needs Action".
- Note that this doesn't update the component on the client. */
-static void
-ensure_task_not_complete (CalComponent *comp)
-{
- icalproperty_status old_status;
- int *old_percent;
-
- /* Date Completed. */
- cal_component_set_completed (comp, NULL);
-
- /* Percent. */
- cal_component_get_percent (comp, &old_percent);
- if (old_percent && *old_percent == 100)
- cal_component_set_percent (comp, NULL);
- if (old_percent)
- cal_component_free_percent (old_percent);
-
- /* Status. */
- cal_component_get_status (comp, &old_status);
- if (old_status == ICAL_STATUS_COMPLETED)
- cal_component_set_status (comp, ICAL_STATUS_NEEDSACTION);
-}
-
-
-/* Whether we use 24 hour format to display the times. */
-gboolean
-calendar_model_get_use_24_hour_format (CalendarModel *model)
-{
- g_return_val_if_fail (IS_CALENDAR_MODEL (model), TRUE);
-
- return model->priv->use_24_hour_format;
-}
-
-
-void
-calendar_model_set_use_24_hour_format (CalendarModel *model,
- gboolean use_24_hour_format)
-{
- g_return_if_fail (IS_CALENDAR_MODEL (model));
-
- if (model->priv->use_24_hour_format != use_24_hour_format) {
- e_table_model_pre_change (E_TABLE_MODEL (model));
- model->priv->use_24_hour_format = use_24_hour_format;
- /* Get the views to redraw themselves. */
- e_table_model_changed (E_TABLE_MODEL (model));
- }
-}
-
-
-void
-calendar_model_set_default_category (CalendarModel *model,
- const char *default_category)
-{
- g_return_if_fail (IS_CALENDAR_MODEL (model));
-
- g_free (model->priv->default_category);
- model->priv->default_category = g_strdup (default_category);
-}
-
-
-
-/* The current timezone. */
-icaltimezone*
-calendar_model_get_timezone (CalendarModel *model)
-{
- g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL);
-
- return model->priv->zone;
-}
-
-
-void
-calendar_model_set_timezone (CalendarModel *model,
- icaltimezone *zone)
-{
- g_return_if_fail (IS_CALENDAR_MODEL (model));
-
- if (model->priv->zone != zone) {
- e_table_model_pre_change (E_TABLE_MODEL (model));
- model->priv->zone = zone;
-
- /* The timezone affects the times shown for COMPLETED and
- maybe other fields, so we need to redisplay everything. */
- e_table_model_changed (E_TABLE_MODEL (model));
- }
-}
-
-
-/**
- * calendar_model_refresh:
- * @model: A calendar model.
- *
- * Refreshes the calendar model, reloading the events/tasks from the server.
- * Be careful about doing this when the user is editing an event/task.
- **/
-void
-calendar_model_refresh (CalendarModel *model)
-{
- g_return_if_fail (model != NULL);
- g_return_if_fail (IS_CALENDAR_MODEL (model));
-
- update_query (model);
-}
diff --git a/calendar/gui/calendar-model.h b/calendar/gui/calendar-model.h
deleted file mode 100644
index 15936367ef..0000000000
--- a/calendar/gui/calendar-model.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Evolution calendar - Data model for ETable
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CALENDAR_MODEL_H
-#define CALENDAR_MODEL_H
-
-#include <gal/e-table/e-table-model.h>
-#include <cal-client/cal-client.h>
-
-G_BEGIN_DECLS
-
-
-
-#define TYPE_CALENDAR_MODEL (calendar_model_get_type ())
-#define CALENDAR_MODEL(obj) (GTK_CHECK_CAST ((obj), TYPE_CALENDAR_MODEL, CalendarModel))
-#define CALENDAR_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_CALENDAR_MODEL, \
- CalendarModelClass))
-#define IS_CALENDAR_MODEL(obj) (GTK_CHECK_TYPE ((obj), TYPE_CALENDAR_MODEL))
-#define IS_CALENDAR_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_CALENDAR_MODEL))
-
-typedef struct _CalendarModel CalendarModel;
-typedef struct _CalendarModelClass CalendarModelClass;
-
-typedef struct _CalendarModelPrivate CalendarModelPrivate;
-
-struct _CalendarModel {
- ETableModel model;
-
- /* Private data */
- CalendarModelPrivate *priv;
-};
-
-struct _CalendarModelClass {
- ETableModelClass parent_class;
-};
-
-GtkType calendar_model_get_type (void);
-
-CalendarModel* calendar_model_new (void);
-
-CalClient* calendar_model_get_cal_client (CalendarModel *model);
-void calendar_model_set_cal_client (CalendarModel *model,
- CalClient *client,
- CalObjType type);
-
-void calendar_model_set_query (CalendarModel *model,
- const char *sexp);
-
-void calendar_model_refresh (CalendarModel *model);
-
-void calendar_model_set_new_comp_vtype (CalendarModel *model,
- CalComponentVType vtype);
-CalComponentVType calendar_model_get_new_comp_vtype (CalendarModel *model);
-
-void calendar_model_mark_task_complete (CalendarModel *model,
- gint row);
-
-CalComponent* calendar_model_get_component (CalendarModel *model,
- gint row);
-
-/* Whether we use 24 hour format to display the times. */
-gboolean calendar_model_get_use_24_hour_format (CalendarModel *model);
-void calendar_model_set_use_24_hour_format (CalendarModel *model,
- gboolean use_24_hour_format);
-
-/* The current timezone. */
-icaltimezone* calendar_model_get_timezone (CalendarModel *model);
-void calendar_model_set_timezone (CalendarModel *model,
- icaltimezone *zone);
-
-void calendar_model_set_default_category (CalendarModel *model,
- const char *default_category);
-
-void calendar_model_set_status_message (CalendarModel *model,
- const char *message);
-
-
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 1b3afd118b..f9c9919338 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -1282,7 +1282,8 @@ save_as_cmd (GtkWidget *widget, gpointer data)
if (filename == NULL)
return;
- ical_string = cal_client_get_component_as_string (priv->client, priv->comp);
+ ical_string = cal_client_get_component_as_string (priv->client,
+ cal_component_get_icalcomponent (priv->comp));
if (ical_string == NULL) {
g_warning ("Couldn't convert item to a string");
return;
diff --git a/calendar/gui/e-cal-view.c b/calendar/gui/e-cal-view.c
index 1895de2e61..24ff9ab570 100644
--- a/calendar/gui/e-cal-view.c
+++ b/calendar/gui/e-cal-view.c
@@ -587,7 +587,7 @@ e_cal_view_copy_clipboard (ECalView *cal_view)
event = (ECalViewEvent *) l->data;
if (event)
- cal_util_add_timezones_from_component (vcal_comp, event->comp);
+ cal_util_add_timezones_from_component (vcal_comp, cal_component_get_icalcomponent (event->comp));
}
for (l = selected; l != NULL; l = l->next) {
@@ -846,7 +846,8 @@ on_save_as (GtkWidget *widget, gpointer user_data)
return;
event = (ECalViewEvent *) selected->data;
- ical_string = cal_client_get_component_as_string (cal_view->priv->client, event->comp);
+ ical_string = cal_client_get_component_as_string (cal_view->priv->client,
+ cal_component_get_icalcomponent (event->comp));
if (ical_string == NULL) {
g_warning ("Couldn't convert item to a string");
return;
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 96cba831d8..09c371b9f9 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -46,7 +46,7 @@
#include "e-calendar-table.h"
#include "e-cell-date-edit-text.h"
#include "calendar-config.h"
-#include "calendar-model.h"
+#include "e-cal-model-tasks.h"
#include "print.h"
#include "dialogs/delete-comp.h"
#include "dialogs/delete-error.h"
@@ -316,9 +316,11 @@ e_calendar_table_init (ECalendarTable *cal_table)
GdkPixbuf *pixbuf;
GList *strings;
+ cal_table->activity = NULL;
+
/* Create the model */
- cal_table->model = calendar_model_new ();
+ cal_table->model = (ECalModel *) e_cal_model_tasks_new ();
/* Create the header columns */
@@ -329,9 +331,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
*/
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
g_object_set (G_OBJECT (cell),
- "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE,
- "bold_column", CAL_COMPONENT_FIELD_OVERDUE,
- "color_column", CAL_COMPONENT_FIELD_COLOR,
+ "strikeout_column", E_CAL_MODEL_TASKS_FIELD_COMPLETE,
+ "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
+ "color_column", E_CAL_MODEL_FIELD_COLOR,
NULL);
e_table_extras_add_cell (extras, "calstring", cell);
@@ -342,9 +344,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
*/
cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT);
g_object_set (G_OBJECT (cell),
- "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE,
- "bold_column", CAL_COMPONENT_FIELD_OVERDUE,
- "color_column", CAL_COMPONENT_FIELD_COLOR,
+ "strikeout_column", E_CAL_MODEL_TASKS_FIELD_COMPLETE,
+ "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
+ "color_column", E_CAL_MODEL_FIELD_COLOR,
NULL);
popup_cell = e_cell_date_edit_new ();
@@ -365,9 +367,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
/* Classification field. */
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
g_object_set (G_OBJECT (cell),
- "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE,
- "bold_column", CAL_COMPONENT_FIELD_OVERDUE,
- "color_column", CAL_COMPONENT_FIELD_COLOR,
+ "strikeout_column", E_CAL_MODEL_TASKS_FIELD_COMPLETE,
+ "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
+ "color_column", E_CAL_MODEL_FIELD_COLOR,
"editable", FALSE,
NULL);
@@ -387,9 +389,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
/* Priority field. */
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
g_object_set (G_OBJECT (cell),
- "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE,
- "bold_column", CAL_COMPONENT_FIELD_OVERDUE,
- "color_column", CAL_COMPONENT_FIELD_COLOR,
+ "strikeout_column", E_CAL_MODEL_TASKS_FIELD_COMPLETE,
+ "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
+ "color_column", E_CAL_MODEL_FIELD_COLOR,
"editable", FALSE,
NULL);
@@ -410,9 +412,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
/* Percent field. */
cell = e_cell_percent_new (NULL, GTK_JUSTIFY_LEFT);
g_object_set (G_OBJECT (cell),
- "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE,
- "bold_column", CAL_COMPONENT_FIELD_OVERDUE,
- "color_column", CAL_COMPONENT_FIELD_COLOR,
+ "strikeout_column", E_CAL_MODEL_TASKS_FIELD_COMPLETE,
+ "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
+ "color_column", E_CAL_MODEL_FIELD_COLOR,
NULL);
popup_cell = e_cell_combo_new ();
@@ -439,9 +441,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
/* Transparency field. */
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
g_object_set (G_OBJECT (cell),
- "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE,
- "bold_column", CAL_COMPONENT_FIELD_OVERDUE,
- "color_column", CAL_COMPONENT_FIELD_COLOR,
+ "strikeout_column", E_CAL_MODEL_TASKS_FIELD_COMPLETE,
+ "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
+ "color_column", E_CAL_MODEL_FIELD_COLOR,
"editable", FALSE,
NULL);
@@ -460,9 +462,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
/* Status field. */
cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT);
g_object_set (G_OBJECT (cell),
- "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE,
- "bold_column", CAL_COMPONENT_FIELD_OVERDUE,
- "color_column", CAL_COMPONENT_FIELD_COLOR,
+ "strikeout_column", E_CAL_MODEL_TASKS_FIELD_COMPLETE,
+ "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
+ "color_column", E_CAL_MODEL_FIELD_COLOR,
"editable", FALSE,
NULL);
@@ -515,7 +517,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
extras,
EVOLUTION_ETSPECDIR "/e-calendar-table.etspec",
NULL);
- g_object_unref (extras);
+ /* FIXME: this causes a message from GLib about 'extras' having only a floating
+ reference */
+ /* g_object_unref (extras); */
cal_table->etable = table;
gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1,
@@ -571,7 +575,7 @@ e_calendar_table_new (void)
*
* Return value: A calendar model.
**/
-CalendarModel *
+ECalModel *
e_calendar_table_get_model (ECalendarTable *cal_table)
{
g_return_val_if_fail (cal_table != NULL, NULL);
@@ -656,7 +660,7 @@ get_selected_row_cb (int model_row, gpointer data)
/* Returns the component that is selected in the table; only works if there is
* one and only one selected row.
*/
-static CalComponent *
+static ECalModelComponent *
get_selected_comp (ECalendarTable *cal_table)
{
ETable *etable;
@@ -672,12 +676,12 @@ get_selected_comp (ECalendarTable *cal_table)
&row);
g_assert (row != -1);
- return calendar_model_get_component (cal_table->model, row);
+ return e_cal_model_get_component_at (cal_table->model, row);
}
struct get_selected_uids_closure {
ECalendarTable *cal_table;
- GSList *uids;
+ GSList *objects;
};
/* Used from e_table_selected_row_foreach(), builds a list of the selected UIDs */
@@ -685,57 +689,51 @@ static void
add_uid_cb (int model_row, gpointer data)
{
struct get_selected_uids_closure *closure;
- CalComponent *comp;
- const char *uid;
+ ECalModelComponent *comp_data;
closure = data;
- comp = calendar_model_get_component (closure->cal_table->model, model_row);
- cal_component_get_uid (comp, &uid);
+ comp_data = e_cal_model_get_component_at (closure->cal_table->model, model_row);
- closure->uids = g_slist_prepend (closure->uids, (char *) uid);
+ closure->objects = g_slist_prepend (closure->objects, comp_data);
}
static GSList *
-get_selected_uids (ECalendarTable *cal_table)
+get_selected_objects (ECalendarTable *cal_table)
{
struct get_selected_uids_closure closure;
ETable *etable;
closure.cal_table = cal_table;
- closure.uids = NULL;
+ closure.objects = NULL;
etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
e_table_selected_row_foreach (etable, add_uid_cb, &closure);
- return closure.uids;
+ return closure.objects;
}
/* Deletes all of the selected components in the table */
static void
delete_selected_components (ECalendarTable *cal_table)
{
- CalClient *client;
- GSList *uids, *l;
+ GSList *objs, *l;
- uids = get_selected_uids (cal_table);
+ objs = get_selected_objects (cal_table);
- client = calendar_model_get_cal_client (cal_table->model);
+ e_calendar_table_set_status_message (cal_table, _("Deleting selected objects"));
- calendar_model_set_status_message (e_calendar_table_get_model (cal_table),
- _("Deleting selected objects"));
-
- for (l = uids; l; l = l->next) {
- const char *uid;
-
- uid = l->data;
+ for (l = objs; l; l = l->next) {
+ ECalModelComponent *comp_data = (ECalModelComponent *) l->data;
- delete_error_dialog (cal_client_remove_object (client, uid), CAL_COMPONENT_TODO);
+ delete_error_dialog (cal_client_remove_object (comp_data->client,
+ icalcomponent_get_uid (comp_data->icalcomp)),
+ CAL_COMPONENT_TODO);
}
- calendar_model_set_status_message (e_calendar_table_get_model (cal_table), NULL);
+ e_calendar_table_set_status_message (cal_table, NULL);
- g_slist_free (uids);
+ g_slist_free (objs);
}
/**
@@ -749,6 +747,7 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table)
{
ETable *etable;
int n_selected;
+ ECalModelComponent *comp_data;
CalComponent *comp;
g_return_if_fail (cal_table != NULL);
@@ -761,15 +760,22 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table)
return;
if (n_selected == 1)
- comp = get_selected_comp (cal_table);
+ comp_data = get_selected_comp (cal_table);
else
- comp = NULL;
+ comp_data = NULL;
/* FIXME: this may be something other than a TODO component */
+ comp = cal_component_new ();
+ if (comp_data)
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
+
if (delete_component_dialog (comp, FALSE, n_selected, CAL_COMPONENT_TODO,
GTK_WIDGET (cal_table)))
delete_selected_components (cal_table);
+
+ /* free memory */
+ g_object_unref (comp);
}
/**
@@ -792,7 +798,7 @@ static void
copy_row_cb (int model_row, gpointer data)
{
ECalendarTable *cal_table;
- CalComponent *comp;
+ ECalModelComponent *comp_data;
gchar *comp_str;
icalcomponent *child;
@@ -800,23 +806,21 @@ copy_row_cb (int model_row, gpointer data)
g_return_if_fail (cal_table->tmp_vcal != NULL);
- comp = calendar_model_get_component (cal_table->model, model_row);
- if (!comp)
+ comp_data = e_cal_model_get_component_at (cal_table->model, model_row);
+ if (!comp_data)
return;
/* add timezones to the VCALENDAR component */
- cal_util_add_timezones_from_component (cal_table->tmp_vcal, comp);
+ cal_util_add_timezones_from_component (cal_table->tmp_vcal, comp_data->icalcomp);
/* add the new component to the VCALENDAR component */
- comp_str = cal_component_get_as_string (comp);
+ comp_str = icalcomponent_as_ical_string (comp_data->icalcomp);
child = icalparser_parse_string (comp_str);
if (child) {
icalcomponent_add_component (cal_table->tmp_vcal,
icalcomponent_new_clone (child));
icalcomponent_free (child);
}
-
- g_free (comp_str);
}
/**
@@ -871,17 +875,21 @@ e_calendar_table_paste_clipboard (ECalendarTable *cal_table)
/* Opens a task in the task editor */
static void
-open_task (ECalendarTable *cal_table, CalComponent *comp, gboolean assign)
+open_task (ECalendarTable *cal_table, ECalModelComponent *comp_data, gboolean assign)
{
CompEditor *tedit;
const char *uid;
- cal_component_get_uid (comp, &uid);
+ uid = icalcomponent_get_uid (comp_data->icalcomp);
tedit = e_comp_editor_registry_find (comp_editor_registry, uid);
if (tedit == NULL) {
- tedit = COMP_EDITOR (task_editor_new (calendar_model_get_cal_client (cal_table->model)));
+ CalComponent *comp;
+
+ tedit = COMP_EDITOR (task_editor_new (comp_data->client));
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
comp_editor_edit_comp (tedit, comp);
if (assign)
task_editor_show_assignment (TASK_EDITOR (tedit));
@@ -896,10 +904,10 @@ open_task (ECalendarTable *cal_table, CalComponent *comp, gboolean assign)
static void
open_task_by_row (ECalendarTable *cal_table, int row)
{
- CalComponent *comp;
+ ECalModelComponent *comp_data;
- comp = calendar_model_get_component (cal_table->model, row);
- open_task (cal_table, comp, FALSE);
+ comp_data = e_cal_model_get_component_at (cal_table->model, row);
+ open_task (cal_table, comp_data, FALSE);
}
static void
@@ -919,7 +927,7 @@ mark_row_complete_cb (int model_row, gpointer data)
ECalendarTable *cal_table;
cal_table = E_CALENDAR_TABLE (data);
- calendar_model_mark_task_complete (cal_table->model, model_row);
+ e_cal_model_tasks_mark_task_complete (E_CAL_MODEL_TASKS (cal_table->model), model_row);
}
/* Callback used for the "mark tasks as complete" menu item */
@@ -940,20 +948,20 @@ static void
open_url_cb (GtkWidget *menuitem, gpointer data)
{
ECalendarTable *cal_table;
- CalComponent *comp;
- const char *url;
+ ECalModelComponent *comp_data;
+ icalproperty *prop;
cal_table = E_CALENDAR_TABLE (data);
- comp = get_selected_comp (cal_table);
- if (!comp)
+ comp_data = get_selected_comp (cal_table);
+ if (!comp_data)
return;
- cal_component_get_url (comp, &url);
- if (!url)
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
+ if (!prop)
return;
- gnome_url_show (url, NULL);
+ gnome_url_show (icalproperty_get_url (prop), NULL);
}
/* Callback for the "delete tasks" menu item */
@@ -1012,33 +1020,31 @@ e_calendar_table_show_popup_menu (ETable *table,
int hide_mask = 0;
int disable_mask = 0;
GtkMenu *gtk_menu;
+ icalproperty *prop;
+ ECalModelComponent *comp_data;
n_selected = e_table_selected_count (table);
if (n_selected <= 0)
return TRUE;
- if (n_selected == 1) {
- CalComponent *comp;
- const char *url;
+ comp_data = get_selected_comp (cal_table);
+ g_assert (comp_data != NULL);
+ if (n_selected == 1) {
hide_mask = MASK_MULTIPLE;
/* See if the task has the URL property set */
- comp = get_selected_comp (cal_table);
- g_assert (comp != NULL);
-
- cal_component_get_url (comp, &url);
- if (!url)
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
+ if (!prop)
disable_mask |= MASK_LACKS_URL;
} else
hide_mask = MASK_SINGLE;
- if (cal_client_is_read_only (calendar_model_get_cal_client (e_calendar_table_get_model (cal_table))))
+ if (cal_client_is_read_only (comp_data->client))
disable_mask |= MASK_EDITABLE;
- if (cal_client_get_static_capability (calendar_model_get_cal_client (e_calendar_table_get_model (cal_table)),
- CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT))
+ if (cal_client_get_static_capability (comp_data->client, CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT))
disable_mask |= MASK_ASSIGNABLE;
gtk_menu = e_popup_menu_create (tasks_popup_menu, disable_mask,
@@ -1074,37 +1080,35 @@ e_calendar_table_on_open_task (GtkWidget *menuitem,
gpointer data)
{
ECalendarTable *cal_table;
- CalComponent *comp;
+ ECalModelComponent *comp_data;
cal_table = E_CALENDAR_TABLE (data);
- comp = get_selected_comp (cal_table);
- if (comp)
- open_task (cal_table, comp, FALSE);
+ comp_data = get_selected_comp (cal_table);
+ if (comp_data)
+ open_task (cal_table, comp_data, FALSE);
}
static void
e_calendar_table_on_save_as (GtkWidget *widget, gpointer data)
{
ECalendarTable *cal_table;
- CalClient *client;
- CalComponent *comp;
+ ECalModelComponent *comp_data;
char *filename;
char *ical_string;
FILE *file;
cal_table = E_CALENDAR_TABLE (data);
- client = calendar_model_get_cal_client (cal_table->model);
- comp = get_selected_comp (cal_table);
- if (comp == NULL)
+ comp_data = get_selected_comp (cal_table);
+ if (comp_data == NULL)
return;
filename = e_file_dialog_save (_("Save as..."));
if (filename == NULL)
return;
- ical_string = cal_client_get_component_as_string (client, comp);
+ ical_string = cal_client_get_component_as_string (comp_data->client, comp_data->icalcomp);
if (ical_string == NULL) {
g_warning ("Couldn't convert item to a string");
return;
@@ -1125,17 +1129,20 @@ static void
e_calendar_table_on_print_task (GtkWidget *widget, gpointer data)
{
ECalendarTable *cal_table;
- CalClient *client;
+ ECalModelComponent *comp_data;
CalComponent *comp;
cal_table = E_CALENDAR_TABLE (data);
- client = calendar_model_get_cal_client (cal_table->model);
- comp = get_selected_comp (cal_table);
- if (comp == NULL)
+ comp_data = get_selected_comp (cal_table);
+ if (comp_data == NULL)
return;
- print_comp (comp, client, FALSE);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
+ print_comp (comp, comp_data->client, FALSE);
+
+ g_object_unref (comp);
}
static void
@@ -1169,29 +1176,33 @@ static void
e_calendar_table_on_assign (GtkWidget *widget, gpointer data)
{
ECalendarTable *cal_table;
- CalComponent *comp;
+ ECalModelComponent *comp_data;
cal_table = E_CALENDAR_TABLE (data);
- comp = get_selected_comp (cal_table);
- if (comp)
- open_task (cal_table, comp, TRUE);
+ comp_data = get_selected_comp (cal_table);
+ if (comp_data)
+ open_task (cal_table, comp_data, TRUE);
}
static void
e_calendar_table_on_forward (GtkWidget *widget, gpointer data)
{
ECalendarTable *cal_table;
- CalClient *client;
- CalComponent *comp;
+ ECalModelComponent *comp_data;
cal_table = E_CALENDAR_TABLE (data);
- client = calendar_model_get_cal_client (cal_table->model);
- comp = get_selected_comp (cal_table);
- if (comp)
- itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp,
- client, NULL);
+ comp_data = get_selected_comp (cal_table);
+ if (comp_data) {
+ CalComponent *comp;
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
+ itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL);
+
+ g_object_unref (comp);
+ }
}
static gint
@@ -1220,7 +1231,7 @@ e_calendar_table_load_state (ECalendarTable *cal_table,
if (stat (filename, &st) == 0 && st.st_size > 0
&& S_ISREG (st.st_mode)) {
- e_table_load_state (e_table_scrolled_get_table(E_TABLE_SCROLLED (cal_table->etable)), filename);
+ e_table_load_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)), filename);
}
}
@@ -1232,7 +1243,7 @@ e_calendar_table_save_state (ECalendarTable *cal_table,
{
g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
- e_table_save_state (e_table_scrolled_get_table(E_TABLE_SCROLLED (cal_table->etable)),
+ e_table_save_state (e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)),
filename);
}
@@ -1296,8 +1307,7 @@ selection_received (GtkWidget *invisible,
return;
}
- calendar_model_set_status_message (e_calendar_table_get_model (cal_table),
- _("Updating objects"));
+ e_calendar_table_set_status_message (cal_table, _("Updating objects"));
if (kind == ICAL_VCALENDAR_COMPONENT) {
icalcomponent_kind child_kind;
@@ -1321,7 +1331,7 @@ selection_received (GtkWidget *invisible,
cal_component_set_uid (tmp_comp, uid);
cal_client_update_object (
- calendar_model_get_cal_client (cal_table->model),
+ e_cal_model_get_default_client (cal_table->model),
tmp_comp);
free (uid);
g_object_unref (tmp_comp);
@@ -1338,12 +1348,12 @@ selection_received (GtkWidget *invisible,
free (uid);
cal_client_update_object (
- calendar_model_get_cal_client (cal_table->model),
+ e_cal_model_get_default_client (cal_table->model),
comp);
g_object_unref (comp);
}
- calendar_model_set_status_message (e_calendar_table_get_model (cal_table), NULL);
+ e_calendar_table_set_status_message (cal_table, NULL);
}
@@ -1384,3 +1394,34 @@ static char *test[] = {
};
#endif
+
+/* Displays messages on the status bar */
+#define EVOLUTION_TASKS_PROGRESS_IMAGE "evolution-tasks-mini.png"
+static GdkPixbuf *progress_icon[2] = { NULL, NULL };
+
+void
+e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *message)
+{
+ extern EvolutionShellClient *global_shell_client; /* ugly */
+
+ g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
+
+ if (!message || !*message) {
+ if (cal_table->activity) {
+ g_object_unref (cal_table->activity);
+ cal_table->activity = NULL;
+ }
+ } else if (!cal_table->activity) {
+ int display;
+ char *client_id = g_strdup_printf ("%p", cal_table);
+
+ if (progress_icon[0] == NULL)
+ progress_icon[0] = gdk_pixbuf_new_from_file (EVOLUTION_IMAGESDIR "/" EVOLUTION_TASKS_PROGRESS_IMAGE, NULL);
+ cal_table->activity = evolution_activity_client_new (
+ global_shell_client, client_id,
+ progress_icon, message, TRUE, &display);
+
+ g_free (client_id);
+ } else
+ evolution_activity_client_update (cal_table->activity, message, -1.0);
+}
diff --git a/calendar/gui/e-calendar-table.etspec b/calendar/gui/e-calendar-table.etspec
index 2e47b817d2..2021ab0037 100644
--- a/calendar/gui/e-calendar-table.etspec
+++ b/calendar/gui/e-calendar-table.etspec
@@ -1,26 +1,27 @@
<ETableSpecification click-to-add="true" _click-to-add-message="Click to add a task" draw-grid="true">
<ETableColumn model_col= "0" _title="Categories" expansion="1.0" minimum_width="10" resizable="true" cell="calstring" compare="string"/>
<ETableColumn model_col= "1" _title="Classification" expansion="1.0" minimum_width="10" resizable="true" cell="classification" compare="string" priority="-1"/>
- <ETableColumn model_col= "2" _title="Completion Date" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
- <ETableColumn model_col= "3" _title="End Date" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2" disabled="true"/>
- <ETableColumn model_col= "4" _title="Start Date" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
- <ETableColumn model_col= "5" _title="Due Date" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
- <ETableColumn model_col= "6" _title="Geographical Position" expansion="1.0" minimum_width="10" resizable="true" cell="calstring" compare="string"/>
- <ETableColumn model_col= "7" _title="% Complete" expansion="1.0" minimum_width="10" resizable="true" cell="percent" compare="percent-compare" priority="-3"/>
- <ETableColumn model_col= "8" _title="Priority" expansion="1.0" minimum_width="10" resizable="true" cell="priority" compare="priority-compare" priority="-3"/>
- <ETableColumn model_col= "9" _title="Summary" expansion="3.0" minimum_width="10" resizable="true" cell="calstring" compare="string" priority="10"/>
- <ETableColumn model_col="10" _title="Show Time As" expansion="1.0" minimum_width="10" resizable="true" cell="transparency" compare="string" priority="-1" disabled="true"/>
- <ETableColumn model_col="11" _title="URL" expansion="2.0" minimum_width="10" resizable="true" cell="calstring" compare="string"/>
- <ETableColumn model_col="12" _title="Alarms" expansion="1.0" minimum_width="10" resizable="true" cell="calstring" compare="string" disabled="true"/>
- <ETableColumn model_col="13" pixbuf="icon" _title="Type" expansion="1.0" minimum_width="16" resizable="false" cell="icon" compare="integer" priority="-4"/>
- <ETableColumn model_col="14" pixbuf="complete" _title="Complete" expansion="1.0" minimum_width="16" resizable="false" cell="checkbox" compare="integer" priority="-4"/>
- <ETableColumn model_col="18" _title="Status" expansion="1.0" minimum_width="10" resizable="true" cell="calstatus" compare="string" priority="-1"/>
+ <ETableColumn model_col="2" _title="color" cell="calcolor" priority="-4"/>
+ <ETableColumn model_col="3" _title="component" cell="calcomp" priority="-4"/>
+ <ETableColumn model_col="4" _title="Description" expansion="2.0" minimum_width="10" resizable="true" cell="calstring" compare="string" priority="-1"/>
+ <ETableColumn model_col= "5" _title="Start Date" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
+ <ETableColumn model_col="6" _title="Alarms" expansion="1.0" minimum_width="10" resizable="true" cell="calstring" compare="string" disabled="true"/>
+ <ETableColumn model_col="7" pixbuf="icon" _title="Type" expansion="1.0" minimum_width="16" resizable="false" cell="icon" compare="integer" priority="-4"/>
+ <ETableColumn model_col= "8" _title="Summary" expansion="3.0" minimum_width="10" resizable="true" cell="calstring" compare="string" priority="10"/>
+ <ETableColumn model_col= "10" _title="Completion Date" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
+ <ETableColumn model_col="11" pixbuf="complete" _title="Complete" expansion="1.0" minimum_width="16" resizable="false" cell="checkbox" compare="integer" priority="-4"/>
+ <ETableColumn model_col= "12" _title="Due Date" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
+ <ETableColumn model_col= "13" _title="Geographical Position" expansion="1.0" minimum_width="10" resizable="true" cell="calstring" compare="string"/>
+ <ETableColumn model_col= "15" _title="% Complete" expansion="1.0" minimum_width="10" resizable="true" cell="percent" compare="percent-compare" priority="-3"/>
+ <ETableColumn model_col= "16" _title="Priority" expansion="1.0" minimum_width="10" resizable="true" cell="priority" compare="priority-compare" priority="-3"/>
+ <ETableColumn model_col="17" _title="Status" expansion="1.0" minimum_width="10" resizable="true" cell="calstatus" compare="string" priority="-1"/>
+ <ETableColumn model_col="18" _title="URL" expansion="2.0" minimum_width="10" resizable="true" cell="calstring" compare="string"/>
<ETableColumn model_col="19" _title="Task sort" cell="task-sort" compare="task-sort" priority="-4"/>
<ETableState>
- <column source="13"/>
- <column source="14"/>
- <column source= "9"/>
+ <column source="7"/>
+ <column source="11"/>
+ <column source= "8"/>
<grouping></grouping>
</ETableState>
</ETableSpecification>
diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h
index fab3afd85d..70dd031174 100644
--- a/calendar/gui/e-calendar-table.h
+++ b/calendar/gui/e-calendar-table.h
@@ -26,12 +26,11 @@
#include <gtk/gtktable.h>
#include <gal/e-table/e-table-scrolled.h>
+#include <shell/evolution-activity-client.h>
#include <widgets/misc/e-cell-date-edit.h>
-#include "calendar-model.h"
+#include "e-cal-model.h"
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
/*
* ECalendarTable - displays the iCalendar objects in a table (an ETable).
@@ -48,12 +47,11 @@ typedef struct _ECalendarTable ECalendarTable;
typedef struct _ECalendarTableClass ECalendarTableClass;
-struct _ECalendarTable
-{
+struct _ECalendarTable {
GtkTable table;
/* The model that we use */
- CalendarModel *model;
+ ECalModel *model;
GtkWidget *etable;
@@ -64,23 +62,25 @@ struct _ECalendarTable
GtkWidget *invisible;
gchar *clipboard_selection;
icalcomponent *tmp_vcal;
+
+ /* The activity client used to show messages on the status bar. */
+ EvolutionActivityClient *activity;
};
-struct _ECalendarTableClass
-{
+struct _ECalendarTableClass {
GtkTableClass parent_class;
};
-GtkType e_calendar_table_get_type (void);
-GtkWidget* e_calendar_table_new (void);
+GtkType e_calendar_table_get_type (void);
+GtkWidget* e_calendar_table_new (void);
-CalendarModel *e_calendar_table_get_model (ECalendarTable *cal_table);
+ECalModel *e_calendar_table_get_model (ECalendarTable *cal_table);
-ETable *e_calendar_table_get_table (ECalendarTable *cal_table);
+ETable *e_calendar_table_get_table (ECalendarTable *cal_table);
-void e_calendar_table_complete_selected (ECalendarTable *cal_table);
-void e_calendar_table_delete_selected (ECalendarTable *cal_table);
+void e_calendar_table_complete_selected (ECalendarTable *cal_table);
+void e_calendar_table_delete_selected (ECalendarTable *cal_table);
/* Clipboard related functions */
void e_calendar_table_cut_clipboard (ECalendarTable *cal_table);
@@ -94,9 +94,9 @@ void e_calendar_table_load_state (ECalendarTable *cal_table,
void e_calendar_table_save_state (ECalendarTable *cal_table,
gchar *filename);
+void e_calendar_table_set_status_message (ECalendarTable *cal_table,
+ const gchar *message);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* _E_CALENDAR_TABLE_H_ */
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 1895de2e61..24ff9ab570 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -587,7 +587,7 @@ e_cal_view_copy_clipboard (ECalView *cal_view)
event = (ECalViewEvent *) l->data;
if (event)
- cal_util_add_timezones_from_component (vcal_comp, event->comp);
+ cal_util_add_timezones_from_component (vcal_comp, cal_component_get_icalcomponent (event->comp));
}
for (l = selected; l != NULL; l = l->next) {
@@ -846,7 +846,8 @@ on_save_as (GtkWidget *widget, gpointer user_data)
return;
event = (ECalViewEvent *) selected->data;
- ical_string = cal_client_get_component_as_string (cal_view->priv->client, event->comp);
+ ical_string = cal_client_get_component_as_string (cal_view->priv->client,
+ cal_component_get_icalcomponent (event->comp));
if (ical_string == NULL) {
g_warning ("Couldn't convert item to a string");
return;
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 1ef6f9c07b..ded89f91f4 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -6794,7 +6794,7 @@ e_day_view_on_drag_data_get (GtkWidget *widget,
icalcomponent *vcal;
vcal = cal_util_new_top_level ();
- cal_util_add_timezones_from_component (vcal, event->comp);
+ cal_util_add_timezones_from_component (vcal, cal_component_get_icalcomponent (event->comp));
icalcomponent_add_component (
vcal,
icalcomponent_new_clone (cal_component_get_icalcomponent (event->comp)));
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index d0a0873195..b441aee09d 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -360,7 +360,8 @@ table_cursor_change_cb (ETable *etable, int row, gpointer data)
/* update the HTML widget */
if (n_selected == 1) {
GtkHTMLStream *stream;
- CalendarModel *model;
+ ECalModel *model;
+ ECalModelComponent *comp_data;
CalComponent *comp;
const char *uid;
@@ -368,7 +369,9 @@ table_cursor_change_cb (ETable *etable, int row, gpointer data)
stream = gtk_html_begin (GTK_HTML (priv->html));
- comp = calendar_model_get_component (model, e_table_get_cursor_row (etable));
+ comp_data = e_cal_model_get_component_at (model, e_table_get_cursor_row (etable));
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
write_html (stream, comp);
gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
@@ -377,6 +380,8 @@ table_cursor_change_cb (ETable *etable, int row, gpointer data)
if (priv->current_uid)
g_free (priv->current_uid);
priv->current_uid = g_strdup (uid);
+
+ g_object_unref (comp);
} else
gtk_html_load_empty (GTK_HTML (priv->html));
}
@@ -401,13 +406,13 @@ search_bar_sexp_changed_cb (CalSearchBar *cal_search, const char *sexp, gpointer
{
ETasks *tasks;
ETasksPrivate *priv;
- CalendarModel *model;
+ ECalModel *model;
tasks = E_TASKS (data);
priv = tasks->priv;
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- calendar_model_set_query (model, sexp);
+ e_cal_model_set_query (model, sexp);
}
/* Callback used when the selected category in the search bar changes */
@@ -416,13 +421,13 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category,
{
ETasks *tasks;
ETasksPrivate *priv;
- CalendarModel *model;
+ ECalModel *model;
tasks = E_TASKS (data);
priv = tasks->priv;
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- calendar_model_set_default_category (model, category);
+ e_cal_model_set_default_category (model, category);
}
/* Callback used when the user selects a URL in the HTML widget */
@@ -472,7 +477,6 @@ setup_widgets (ETasks *tasks)
{
ETasksPrivate *priv;
ETable *etable;
- CalendarModel *model;
GtkWidget *paned, *scroll;
priv = tasks->priv;
@@ -498,8 +502,6 @@ setup_widgets (ETasks *tasks)
/* create the task list */
priv->tasks_view = e_calendar_table_new ();
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- calendar_model_set_new_comp_vtype (model, CAL_COMPONENT_TODO);
etable = e_table_scrolled_get_table (
E_TABLE_SCROLLED (E_CALENDAR_TABLE (priv->tasks_view)->etable));
@@ -570,7 +572,7 @@ GtkWidget *
e_tasks_construct (ETasks *tasks)
{
ETasksPrivate *priv;
- CalendarModel *model;
+ ECalModel *model;
g_return_val_if_fail (tasks != NULL, NULL);
g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
@@ -595,7 +597,7 @@ e_tasks_construct (ETasks *tasks)
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
g_assert (model != NULL);
- calendar_model_set_cal_client (model, priv->client, CALOBJ_TYPE_TODO);
+ e_cal_model_add_client (model, priv->client);
return GTK_WIDGET (tasks);
}
@@ -668,12 +670,10 @@ static void
set_status_message (ETasks *tasks, const char *message)
{
ETasksPrivate *priv;
- CalendarModel *model;
priv = tasks->priv;
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- calendar_model_set_status_message (model, message);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->tasks_view), message);
}
gboolean
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 4dab508ffc..d127f46079 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -653,7 +653,7 @@ void
gnome_calendar_set_query (GnomeCalendar *gcal, const char *sexp)
{
GnomeCalendarPrivate *priv;
- CalendarModel *model;
+ ECalModel *model;
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
@@ -676,7 +676,7 @@ gnome_calendar_set_query (GnomeCalendar *gcal, const char *sexp)
/* Set the query on the task pad */
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- calendar_model_set_query (model, sexp);
+ e_cal_model_set_query (model, sexp);
}
/* Returns the current time, for the ECalendarItem. */
@@ -715,7 +715,7 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category,
{
GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
- CalendarModel *model;
+ ECalModel *model;
gcal = GNOME_CALENDAR (data);
priv = gcal->priv;
@@ -726,7 +726,7 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category,
e_week_view_set_default_category (E_WEEK_VIEW (priv->month_view), category);
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- calendar_model_set_default_category (model, category);
+ e_cal_model_set_default_category (model, category);
}
static void
@@ -812,7 +812,6 @@ setup_widgets (GnomeCalendar *gcal)
GnomeCalendarPrivate *priv;
GtkWidget *w;
gchar *filename;
- CalendarModel *model;
ETable *etable;
priv = gcal->priv;
@@ -872,8 +871,6 @@ setup_widgets (GnomeCalendar *gcal)
/* The ToDo list. */
priv->todo = e_calendar_table_new ();
calendar_config_configure_e_calendar_table (E_CALENDAR_TABLE (priv->todo));
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- calendar_model_set_new_comp_vtype (model, CAL_COMPONENT_TODO);
gtk_paned_pack2 (GTK_PANED (priv->vpane), priv->todo, TRUE, TRUE);
gtk_widget_show (priv->todo);
@@ -1696,8 +1693,7 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), msg);
}
else if (client == priv->task_pad_client) {
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), msg);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), msg);
}
g_free (msg);
@@ -1730,8 +1726,7 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
}
else if (client == priv->task_pad_client) {
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), NULL);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
}
}
@@ -1895,8 +1890,7 @@ backend_died_cb (CalClient *client, gpointer data)
"You will have to restart Evolution in order "
"to use it again"),
uristr);
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), NULL);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
} else {
message = NULL;
g_assert_not_reached ();
@@ -1912,7 +1906,7 @@ gnome_calendar_construct (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
GnomeCalendarViewType view_type;
- CalendarModel *model;
+ ECalModel *model;
g_return_val_if_fail (gcal != NULL, NULL);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
@@ -1959,7 +1953,7 @@ gnome_calendar_construct (GnomeCalendar *gcal)
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
g_assert (model != NULL);
- calendar_model_set_cal_client (model, priv->task_pad_client, CALOBJ_TYPE_TODO);
+ e_cal_model_add_client (model, priv->task_pad_client);
/* Get the default view to show. */
view_type = calendar_config_get_default_view ();
@@ -2137,8 +2131,7 @@ gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri)
if (!uri) {
tasks_uri = g_strdup_printf ("%s/local/Tasks/tasks.ics", evolution_dir);
message = g_strdup_printf (_("Opening tasks at %s"), tasks_uri);
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), message);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), message);
g_free (message);
success = cal_client_open_calendar (priv->task_pad_client, tasks_uri, FALSE);
@@ -2148,17 +2141,15 @@ gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri)
if (!g_strncasecmp (uri->protocol, "file", 4)) {
tasks_uri = g_strdup_printf ("%s/local/Tasks/tasks.ics", evolution_dir);
message = g_strdup_printf (_("Opening tasks at %s"), tasks_uri);
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), message);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), message);
g_free (message);
success = cal_client_open_calendar (priv->task_pad_client, tasks_uri, FALSE);
g_free (tasks_uri);
}
else {
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)),
- _("Opening default tasks folder"));
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo),
+ _("Opening default tasks folder"));
success = cal_client_open_default_tasks (priv->task_pad_client, FALSE);
}
}
@@ -2168,8 +2159,7 @@ gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri)
if (!success) {
g_message ("gnome_calendar_open(): Could not issue the request to open the tasks folder");
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), NULL);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
return FALSE;
}
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index aaf12f548a..f338bc2e36 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -1771,7 +1771,7 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal,
struct icaltimetype *tt;
ECalendarTable *task_pad;
ETable *table;
- CalendarModel *model;
+ ECalModel *model;
gint rows, row;
/* We get the tasks directly from the TaskPad ETable. This means we
@@ -1794,17 +1794,24 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal,
rows = e_table_model_row_count (E_TABLE_MODEL (model));
for (row = 0; row < rows; row++) {
+ ECalModelComponent *comp_data;
CalComponent *comp;
CalComponentText summary;
int model_row;
model_row = e_table_view_to_model_row (table, row);
- comp = calendar_model_get_component (model, model_row);
+ comp_data = e_cal_model_get_component_at (model, model_row);
+ if (!comp_data)
+ continue;
- cal_component_get_summary (comp, &summary);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- if (!summary.value)
+ cal_component_get_summary (comp_data->icalcomp, &summary);
+ if (!summary.value) {
+ g_object_unref (comp);
continue;
+ }
x = left;
xend = right - 2;
@@ -1835,6 +1842,8 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal,
gnome_print_lineto (pc, xend, y);
gnome_print_stroke (pc);
y -= 3;
+
+ g_object_unref (comp);
}
g_object_unref (font_summary);
diff --git a/libical/ChangeLog b/libical/ChangeLog
index a08e9535a8..912cc73a1b 100644
--- a/libical/ChangeLog
+++ b/libical/ChangeLog
@@ -1,3 +1,8 @@
+2003-08-07 Rodrigo Moya <rodrigo@ximian.com>
+
+ * src/libical/icalcomponent.c (icalcomponent_get_uid): added missing
+ implementation.
+
2003-05-14 Rodrigo Moya <rodrigo@ximian.com>
Fixes #41579
diff --git a/libical/src/libical/icalcomponent.c b/libical/src/libical/icalcomponent.c
index ce819ddbd6..c771dc3cf9 100644
--- a/libical/src/libical/icalcomponent.c
+++ b/libical/src/libical/icalcomponent.c
@@ -1459,7 +1459,18 @@ void icalcomponent_set_comment(icalcomponent* comp, const char* v);
const char* icalcomponent_get_comment(icalcomponent* comp);
void icalcomponent_set_uid(icalcomponent* comp, const char* v);
-const char* icalcomponent_get_uid(icalcomponent* comp);
+
+const char* icalcomponent_get_uid(icalcomponent* comp)
+{
+ icalcomponent *inner = icalcomponent_get_inner (comp);
+ icalproperty *prop = icalcomponent_get_first_property (inner, ICAL_UID_PROPERTY);
+
+ if (prop == 0) {
+ return 0;
+ }
+
+ return icalproperty_get_uid (prop);
+}
void icalcomponent_set_recurrenceid(icalcomponent* comp,
struct icaltimetype v);