aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-18 21:25:40 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-19 08:31:50 +0800
commitc6ccd45a0ef07b12a0313deb3abee032d89eec0a (patch)
tree41f67ea66ada4bf9a1b109236194386dc1292f7e
parent96acf4fa41260e7917ae1a794bb4b636e6c398cc (diff)
downloadgsoc2013-evolution-c6ccd45a0ef07b12a0313deb3abee032d89eec0a.tar
gsoc2013-evolution-c6ccd45a0ef07b12a0313deb3abee032d89eec0a.tar.gz
gsoc2013-evolution-c6ccd45a0ef07b12a0313deb3abee032d89eec0a.tar.bz2
gsoc2013-evolution-c6ccd45a0ef07b12a0313deb3abee032d89eec0a.tar.lz
gsoc2013-evolution-c6ccd45a0ef07b12a0313deb3abee032d89eec0a.tar.xz
gsoc2013-evolution-c6ccd45a0ef07b12a0313deb3abee032d89eec0a.tar.zst
gsoc2013-evolution-c6ccd45a0ef07b12a0313deb3abee032d89eec0a.zip
ETable-related cleanups.
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.c84
-rw-r--r--calendar/gui/e-cal-model-calendar.c227
-rw-r--r--calendar/gui/e-cal-model-memos.c144
-rw-r--r--calendar/gui/e-cal-model-tasks.c690
-rw-r--r--calendar/gui/e-cal-model.c1808
-rw-r--r--doc/reference/evolution-util/evolution-util-sections.txt1
-rw-r--r--e-util/e-table-click-to-add.c21
-rw-r--r--e-util/e-table-column-specification.c13
-rw-r--r--e-util/e-table-config.c3
-rw-r--r--e-util/e-table-extras.c13
-rw-r--r--e-util/e-table-field-chooser-item.c25
-rw-r--r--e-util/e-table-field-chooser.c5
-rw-r--r--e-util/e-table-group-container.c25
-rw-r--r--e-util/e-table-group-leaf.c105
-rw-r--r--e-util/e-table-group-leaf.h2
-rw-r--r--e-util/e-table-group.c17
-rw-r--r--e-util/e-table-item.c62
-rw-r--r--e-util/e-table-memory-store.c205
-rw-r--r--e-util/e-table-memory.c13
-rw-r--r--e-util/e-table-memory.h6
-rw-r--r--e-util/e-table-model.c470
-rw-r--r--e-util/e-table-model.h110
-rw-r--r--e-util/e-table-one.c149
-rw-r--r--e-util/e-table-sorted-variable.c27
-rw-r--r--e-util/e-table-sorted.c35
-rw-r--r--e-util/e-table-sorter.c10
-rw-r--r--e-util/e-table-specification.c13
-rw-r--r--e-util/e-table-subset-variable.c16
-rw-r--r--e-util/e-table-subset.c748
-rw-r--r--e-util/e-table-subset.h83
-rw-r--r--e-util/e-table-without.c35
-rw-r--r--e-util/e-tree-model.h4
-rw-r--r--e-util/e-tree-table-adapter.c240
-rw-r--r--e-util/gal-define-views-model.c24
34 files changed, 2752 insertions, 2681 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c
index 5bd188ccec..7a7dd4d69b 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c
@@ -49,8 +49,6 @@ struct _EAddressbookTableAdapterPrivate {
GHashTable *emails;
};
-#define COLS (E_CONTACT_FIELD_LAST)
-
G_DEFINE_TYPE (
EAddressbookTableAdapter,
e_addressbook_table_adapter,
@@ -95,7 +93,7 @@ addressbook_finalize (GObject *object)
static gint
addressbook_col_count (ETableModel *etc)
{
- return COLS;
+ return E_CONTACT_FIELD_LAST;
}
/* This function returns the number of rows in our ETableModel. */
@@ -108,6 +106,40 @@ addressbook_row_count (ETableModel *etc)
return e_addressbook_model_contact_count (priv->model);
}
+static void
+addressbook_append_row (ETableModel *etm,
+ ETableModel *source,
+ gint row)
+{
+ EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER (etm);
+ EAddressbookTableAdapterPrivate *priv = adapter->priv;
+ EClientCache *client_cache;
+ ESourceRegistry *registry;
+ EBookClient *book_client;
+ EContact *contact;
+ gint col;
+
+ contact = e_contact_new ();
+
+ for (col = 1; col < E_CONTACT_LAST_SIMPLE_STRING; col++) {
+ gconstpointer val = e_table_model_value_at (source, col, row);
+ e_contact_set (contact, col, (gpointer) val);
+ }
+
+ client_cache =
+ e_addressbook_model_get_client_cache (priv->model);
+ book_client = e_addressbook_model_get_client (priv->model);
+
+ registry = e_client_cache_ref_registry (client_cache);
+
+ eab_merging_book_add_contact (
+ registry, book_client, contact, NULL, NULL);
+
+ g_object_unref (registry);
+
+ g_object_unref (contact);
+}
+
/* This function returns the value at a particular point in our ETableModel. */
static gpointer
addressbook_value_at (ETableModel *etc,
@@ -119,7 +151,10 @@ addressbook_value_at (ETableModel *etc,
EContact *contact;
const gchar *value;
- if (col >= COLS || row >= e_addressbook_model_contact_count (priv->model))
+ if (col >= E_CONTACT_FIELD_LAST)
+ return NULL;
+
+ if (row >= e_addressbook_model_contact_count (priv->model))
return NULL;
contact = e_addressbook_model_contact_at (priv->model, row);
@@ -176,7 +211,10 @@ addressbook_set_value_at (ETableModel *etc,
EBookClient *book_client;
EContact *contact;
- if (col >= COLS || row >= e_addressbook_model_contact_count (priv->model))
+ if (col >= E_CONTACT_FIELD_LAST)
+ return;
+
+ if (row >= e_addressbook_model_contact_count (priv->model))
return;
contact = e_addressbook_model_get_contact (priv->model, row);
@@ -225,40 +263,6 @@ addressbook_is_cell_editable (ETableModel *etc,
return FALSE;
}
-static void
-addressbook_append_row (ETableModel *etm,
- ETableModel *source,
- gint row)
-{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER (etm);
- EAddressbookTableAdapterPrivate *priv = adapter->priv;
- EClientCache *client_cache;
- ESourceRegistry *registry;
- EBookClient *book_client;
- EContact *contact;
- gint col;
-
- contact = e_contact_new ();
-
- for (col = 1; col < E_CONTACT_LAST_SIMPLE_STRING; col++) {
- gconstpointer val = e_table_model_value_at (source, col, row);
- e_contact_set (contact, col, (gpointer) val);
- }
-
- client_cache =
- e_addressbook_model_get_client_cache (priv->model);
- book_client = e_addressbook_model_get_client (priv->model);
-
- registry = e_client_cache_ref_registry (client_cache);
-
- eab_merging_book_add_contact (
- registry, book_client, contact, NULL, NULL);
-
- g_object_unref (registry);
-
- g_object_unref (contact);
-}
-
/* This function duplicates the value passed to it. */
static gpointer
addressbook_duplicate_value (ETableModel *etc,
@@ -315,10 +319,10 @@ e_addressbook_table_adapter_class_init (EAddressbookTableAdapterClass *class)
model_class = E_TABLE_MODEL_CLASS (class);
model_class->column_count = addressbook_col_count;
model_class->row_count = addressbook_row_count;
+ model_class->append_row = addressbook_append_row;
model_class->value_at = addressbook_value_at;
model_class->set_value_at = addressbook_set_value_at;
model_class->is_cell_editable = addressbook_is_cell_editable;
- model_class->append_row = addressbook_append_row;
model_class->duplicate_value = addressbook_duplicate_value;
model_class->free_value = addressbook_free_value;
model_class->initialize_value = addressbook_initialize_value;
diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c
index 5759d3acb1..114ffd4a7e 100644
--- a/calendar/gui/e-cal-model-calendar.c
+++ b/calendar/gui/e-cal-model-calendar.c
@@ -35,52 +35,10 @@
#include "dialogs/recur-comp.h"
#include "dialogs/send-comp.h"
-static gint ecmc_column_count (ETableModel *etm);
-static gpointer ecmc_value_at (ETableModel *etm, gint col, gint row);
-static void ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value);
-static gboolean ecmc_is_cell_editable (ETableModel *etm, gint col, gint row);
-static gpointer ecmc_duplicate_value (ETableModel *etm, gint col, gconstpointer value);
-static void ecmc_free_value (ETableModel *etm, gint col, gpointer value);
-static gpointer ecmc_initialize_value (ETableModel *etm, gint col);
-static gboolean ecmc_value_is_empty (ETableModel *etm, gint col, gconstpointer value);
-static gchar *ecmc_value_to_string (ETableModel *etm, gint col, gconstpointer value);
-
-static void ecmc_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
- ETableModel *source_model, gint row);
-
-G_DEFINE_TYPE (ECalModelCalendar, e_cal_model_calendar, E_TYPE_CAL_MODEL)
-
-static void
-e_cal_model_calendar_class_init (ECalModelCalendarClass *class)
-{
- ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (class);
- ECalModelClass *model_class = E_CAL_MODEL_CLASS (class);
-
- etm_class->column_count = ecmc_column_count;
- etm_class->value_at = ecmc_value_at;
- etm_class->set_value_at = ecmc_set_value_at;
- etm_class->is_cell_editable = ecmc_is_cell_editable;
- etm_class->duplicate_value = ecmc_duplicate_value;
- etm_class->free_value = ecmc_free_value;
- etm_class->initialize_value = ecmc_initialize_value;
- etm_class->value_is_empty = ecmc_value_is_empty;
- etm_class->value_to_string = ecmc_value_to_string;
-
- model_class->fill_component_from_model = ecmc_fill_component_from_model;
-}
-
-static void
-e_cal_model_calendar_init (ECalModelCalendar *model)
-{
- e_cal_model_set_component_kind (E_CAL_MODEL (model), ICAL_VEVENT_COMPONENT);
-}
-
-/* ETableModel methods */
-static gint
-ecmc_column_count (ETableModel *etm)
-{
- return E_CAL_MODEL_CALENDAR_FIELD_LAST;
-}
+G_DEFINE_TYPE (
+ ECalModelCalendar,
+ e_cal_model_calendar,
+ E_TYPE_CAL_MODEL)
static ECellDateEditValue *
get_dtend (ECalModelCalendar *model,
@@ -164,38 +122,6 @@ get_transparency (ECalModelComponent *comp_data)
return NULL;
}
-static gpointer
-ecmc_value_at (ETableModel *etm,
- gint col,
- gint row)
-{
- ECalModelComponent *comp_data;
- ECalModelCalendar *model = (ECalModelCalendar *) etm;
-
- g_return_val_if_fail (E_IS_CAL_MODEL_CALENDAR (model), NULL);
-
- g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL);
- g_return_val_if_fail (row >= 0 && row < e_table_model_row_count (etm), NULL);
-
- if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->value_at (etm, col, row);
-
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
- if (!comp_data)
- return (gpointer) "";
-
- switch (col) {
- case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
- return get_dtend (model, comp_data);
- case E_CAL_MODEL_CALENDAR_FIELD_LOCATION :
- return get_location (comp_data);
- case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY :
- return get_transparency (comp_data);
- }
-
- return (gpointer) "";
-}
-
static void
set_dtend (ECalModel *model,
ECalModelComponent *comp_data,
@@ -266,10 +192,69 @@ set_transparency (ECalModelComponent *comp_data,
}
static void
-ecmc_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer value)
+cal_model_calendar_fill_component_from_model (ECalModel *model,
+ ECalModelComponent *comp_data,
+ ETableModel *source_model,
+ gint row)
+{
+ g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model));
+ g_return_if_fail (comp_data != NULL);
+ g_return_if_fail (E_IS_TABLE_MODEL (source_model));
+
+ set_dtend (
+ model, comp_data,
+ e_table_model_value_at (source_model, E_CAL_MODEL_CALENDAR_FIELD_DTEND, row));
+ set_location (
+ comp_data,
+ e_table_model_value_at (source_model, E_CAL_MODEL_CALENDAR_FIELD_LOCATION, row));
+ set_transparency (
+ comp_data,
+ e_table_model_value_at (source_model, E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY, row));
+}
+
+static gint
+cal_model_calendar_column_count (ETableModel *etm)
+{
+ return E_CAL_MODEL_CALENDAR_FIELD_LAST;
+}
+
+static gpointer
+cal_model_calendar_value_at (ETableModel *etm,
+ gint col,
+ gint row)
+{
+ ECalModelComponent *comp_data;
+ ECalModelCalendar *model = (ECalModelCalendar *) etm;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL_CALENDAR (model), NULL);
+
+ g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL);
+ g_return_val_if_fail (row >= 0 && row < e_table_model_row_count (etm), NULL);
+
+ if (col < E_CAL_MODEL_FIELD_LAST)
+ return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->value_at (etm, col, row);
+
+ comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
+ if (!comp_data)
+ return (gpointer) "";
+
+ switch (col) {
+ case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
+ return get_dtend (model, comp_data);
+ case E_CAL_MODEL_CALENDAR_FIELD_LOCATION :
+ return get_location (comp_data);
+ case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY :
+ return get_transparency (comp_data);
+ }
+
+ return (gpointer) "";
+}
+
+static void
+cal_model_calendar_set_value_at (ETableModel *etm,
+ gint col,
+ gint row,
+ gconstpointer value)
{
ECalModelComponent *comp_data;
CalObjModType mod = CALOBJ_MOD_ALL;
@@ -366,9 +351,9 @@ ecmc_set_value_at (ETableModel *etm,
}
static gboolean
-ecmc_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
+cal_model_calendar_is_cell_editable (ETableModel *etm,
+ gint col,
+ gint row)
{
ECalModelCalendar *model = (ECalModelCalendar *) etm;
@@ -393,9 +378,9 @@ ecmc_is_cell_editable (ETableModel *etm,
}
static gpointer
-ecmc_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_calendar_duplicate_value (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL);
@@ -423,9 +408,9 @@ ecmc_duplicate_value (ETableModel *etm,
}
static void
-ecmc_free_value (ETableModel *etm,
- gint col,
- gpointer value)
+cal_model_calendar_free_value (ETableModel *etm,
+ gint col,
+ gpointer value)
{
g_return_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST);
@@ -445,8 +430,8 @@ ecmc_free_value (ETableModel *etm,
}
static gpointer
-ecmc_initialize_value (ETableModel *etm,
- gint col)
+cal_model_calendar_initialize_value (ETableModel *etm,
+ gint col)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL);
@@ -465,9 +450,9 @@ ecmc_initialize_value (ETableModel *etm,
}
static gboolean
-ecmc_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_calendar_value_is_empty (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, TRUE);
@@ -486,9 +471,9 @@ ecmc_value_is_empty (ETableModel *etm,
}
static gchar *
-ecmc_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_calendar_value_to_string (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, g_strdup (""));
@@ -506,32 +491,34 @@ ecmc_value_to_string (ETableModel *etm,
return g_strdup ("");
}
-/* ECalModel class methods */
-
static void
-ecmc_fill_component_from_model (ECalModel *model,
- ECalModelComponent *comp_data,
- ETableModel *source_model,
- gint row)
+e_cal_model_calendar_class_init (ECalModelCalendarClass *class)
{
- g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model));
- g_return_if_fail (comp_data != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (source_model));
+ ECalModelClass *model_class;
+ ETableModelClass *etm_class;
+
+ model_class = E_CAL_MODEL_CLASS (class);
+ model_class->fill_component_from_model = cal_model_calendar_fill_component_from_model;
+
+ etm_class = E_TABLE_MODEL_CLASS (class);
+ etm_class->column_count = cal_model_calendar_column_count;
+ etm_class->value_at = cal_model_calendar_value_at;
+ etm_class->set_value_at = cal_model_calendar_set_value_at;
+ etm_class->is_cell_editable = cal_model_calendar_is_cell_editable;
+ etm_class->duplicate_value = cal_model_calendar_duplicate_value;
+ etm_class->free_value = cal_model_calendar_free_value;
+ etm_class->initialize_value = cal_model_calendar_initialize_value;
+ etm_class->value_is_empty = cal_model_calendar_value_is_empty;
+ etm_class->value_to_string = cal_model_calendar_value_to_string;
+}
- set_dtend (
- model, comp_data,
- e_table_model_value_at (source_model, E_CAL_MODEL_CALENDAR_FIELD_DTEND, row));
- set_location (
- comp_data,
- e_table_model_value_at (source_model, E_CAL_MODEL_CALENDAR_FIELD_LOCATION, row));
- set_transparency (
- comp_data,
- e_table_model_value_at (source_model, E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY, row));
+static void
+e_cal_model_calendar_init (ECalModelCalendar *model)
+{
+ e_cal_model_set_component_kind (
+ E_CAL_MODEL (model), ICAL_VEVENT_COMPONENT);
}
-/**
- * e_cal_model_calendar_new
- */
ECalModel *
e_cal_model_calendar_new (ESourceRegistry *registry)
{
diff --git a/calendar/gui/e-cal-model-memos.c b/calendar/gui/e-cal-model-memos.c
index a6d3f1d612..dc3440e54d 100644
--- a/calendar/gui/e-cal-model-memos.c
+++ b/calendar/gui/e-cal-model-memos.c
@@ -35,57 +35,39 @@
#define d(x) (x)
-static gint ecmm_column_count (ETableModel *etm);
-static gpointer ecmm_value_at (ETableModel *etm, gint col, gint row);
-static void ecmm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value);
-static gboolean ecmm_is_cell_editable (ETableModel *etm, gint col, gint row);
-static gpointer ecmm_duplicate_value (ETableModel *etm, gint col, gconstpointer value);
-static void ecmm_free_value (ETableModel *etm, gint col, gpointer value);
-static gpointer ecmm_initialize_value (ETableModel *etm, gint col);
-static gboolean ecmm_value_is_empty (ETableModel *etm, gint col, gconstpointer value);
-static gchar *ecmm_value_to_string (ETableModel *etm, gint col, gconstpointer value);
-
-static void ecmm_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
- ETableModel *source_model, gint row);
-
-G_DEFINE_TYPE (ECalModelMemos, e_cal_model_memos, E_TYPE_CAL_MODEL)
+G_DEFINE_TYPE (
+ ECalModelMemos,
+ e_cal_model_memos,
+ E_TYPE_CAL_MODEL)
static void
-e_cal_model_memos_class_init (ECalModelMemosClass *class)
+cal_model_memos_fill_component_from_model (ECalModel *model,
+ ECalModelComponent *comp_data,
+ ETableModel *source_model,
+ gint row)
{
- ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (class);
- ECalModelClass *model_class = E_CAL_MODEL_CLASS (class);
-
- etm_class->column_count = ecmm_column_count;
- etm_class->value_at = ecmm_value_at;
- etm_class->set_value_at = ecmm_set_value_at;
- etm_class->is_cell_editable = ecmm_is_cell_editable;
- etm_class->duplicate_value = ecmm_duplicate_value;
- etm_class->free_value = ecmm_free_value;
- etm_class->initialize_value = ecmm_initialize_value;
- etm_class->value_is_empty = ecmm_value_is_empty;
- etm_class->value_to_string = ecmm_value_to_string;
-
- model_class->fill_component_from_model = ecmm_fill_component_from_model;
-}
+ icaltimetype start;
+ g_return_if_fail (E_IS_CAL_MODEL_MEMOS (model));
+ g_return_if_fail (comp_data != NULL);
+ g_return_if_fail (E_IS_TABLE_MODEL (source_model));
-static void
-e_cal_model_memos_init (ECalModelMemos *model)
-{
- e_cal_model_set_component_kind (E_CAL_MODEL (model), ICAL_VJOURNAL_COMPONENT);
+ start = icalcomponent_get_dtstart (comp_data->icalcomp);
+ if (icaltime_compare_date_only (start, icaltime_null_time ()) == 0) {
+ start = icaltime_today ();
+ icalcomponent_set_dtstart (comp_data->icalcomp, start);
+ }
}
-/* ETableModel methods */
static gint
-ecmm_column_count (ETableModel *etm)
+cal_model_memos_column_count (ETableModel *etm)
{
return E_CAL_MODEL_MEMOS_FIELD_LAST;
}
static gpointer
-ecmm_value_at (ETableModel *etm,
- gint col,
- gint row)
+cal_model_memos_value_at (ETableModel *etm,
+ gint col,
+ gint row)
{
ECalModelComponent *comp_data;
ECalModelMemos *model = (ECalModelMemos *) etm;
@@ -106,10 +88,10 @@ ecmm_value_at (ETableModel *etm,
}
static void
-ecmm_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer value)
+cal_model_memos_set_value_at (ETableModel *etm,
+ gint col,
+ gint row,
+ gconstpointer value)
{
ECalModelComponent *comp_data;
ECalModelMemos *model = (ECalModelMemos *) etm;
@@ -146,9 +128,9 @@ ecmm_set_value_at (ETableModel *etm,
}
static gboolean
-ecmm_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
+cal_model_memos_is_cell_editable (ETableModel *etm,
+ gint col,
+ gint row)
{
ECalModelMemos *model = (ECalModelMemos *) etm;
gboolean retval = FALSE;
@@ -167,9 +149,9 @@ ecmm_is_cell_editable (ETableModel *etm,
}
static gpointer
-ecmm_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_memos_duplicate_value (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, NULL);
@@ -180,9 +162,9 @@ ecmm_duplicate_value (ETableModel *etm,
}
static void
-ecmm_free_value (ETableModel *etm,
- gint col,
- gpointer value)
+cal_model_memos_free_value (ETableModel *etm,
+ gint col,
+ gpointer value)
{
g_return_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST);
@@ -193,8 +175,8 @@ ecmm_free_value (ETableModel *etm,
}
static gpointer
-ecmm_initialize_value (ETableModel *etm,
- gint col)
+cal_model_memos_initialize_value (ETableModel *etm,
+ gint col)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, NULL);
@@ -205,9 +187,9 @@ ecmm_initialize_value (ETableModel *etm,
}
static gboolean
-ecmm_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_memos_value_is_empty (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, TRUE);
@@ -218,9 +200,9 @@ ecmm_value_is_empty (ETableModel *etm,
}
static gchar *
-ecmm_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_memos_value_to_string (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, g_strdup (""));
@@ -230,30 +212,34 @@ ecmm_value_to_string (ETableModel *etm,
return g_strdup ("");
}
-/* ECalModel class methods */
-
static void
-ecmm_fill_component_from_model (ECalModel *model,
- ECalModelComponent *comp_data,
- ETableModel *source_model,
- gint row)
+e_cal_model_memos_class_init (ECalModelMemosClass *class)
{
- icaltimetype start;
- g_return_if_fail (E_IS_CAL_MODEL_MEMOS (model));
- g_return_if_fail (comp_data != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (source_model));
-
- start = icalcomponent_get_dtstart (comp_data->icalcomp);
- if (icaltime_compare_date_only (start, icaltime_null_time ()) == 0) {
- start = icaltime_today ();
- icalcomponent_set_dtstart (comp_data->icalcomp, start);
- }
+ ECalModelClass *model_class;
+ ETableModelClass *etm_class;
+
+ model_class = E_CAL_MODEL_CLASS (class);
+ model_class->fill_component_from_model = cal_model_memos_fill_component_from_model;
+
+ etm_class = E_TABLE_MODEL_CLASS (class);
+ etm_class->column_count = cal_model_memos_column_count;
+ etm_class->value_at = cal_model_memos_value_at;
+ etm_class->set_value_at = cal_model_memos_set_value_at;
+ etm_class->is_cell_editable = cal_model_memos_is_cell_editable;
+ etm_class->duplicate_value = cal_model_memos_duplicate_value;
+ etm_class->free_value = cal_model_memos_free_value;
+ etm_class->initialize_value = cal_model_memos_initialize_value;
+ etm_class->value_is_empty = cal_model_memos_value_is_empty;
+ etm_class->value_to_string = cal_model_memos_value_to_string;
+}
+static void
+e_cal_model_memos_init (ECalModelMemos *model)
+{
+ e_cal_model_set_component_kind (
+ E_CAL_MODEL (model), ICAL_VJOURNAL_COMPONENT);
}
-/**
- * e_cal_model_memos_new
- */
ECalModel *
e_cal_model_memos_new (ESourceRegistry *registry)
{
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index 81c3cb3a45..a3e6cb8107 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -47,23 +47,6 @@ struct _ECalModelTasksPrivate {
gchar *color_overdue;
};
-static gint ecmt_column_count (ETableModel *etm);
-static gpointer ecmt_value_at (ETableModel *etm, gint col, gint row);
-static void ecmt_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value);
-static gboolean ecmt_is_cell_editable (ETableModel *etm, gint col, gint row);
-static gpointer ecmt_duplicate_value (ETableModel *etm, gint col, gconstpointer value);
-static void ecmt_free_value (ETableModel *etm, gint col, gpointer value);
-static gpointer ecmt_initialize_value (ETableModel *etm, gint col);
-static gboolean ecmt_value_is_empty (ETableModel *etm, gint col, gconstpointer value);
-static gchar *ecmt_value_to_string (ETableModel *etm, gint col, gconstpointer value);
-
-static const gchar *ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data);
-static void ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
- ETableModel *source_model, gint row);
-static void commit_component_changes (ECalModelComponent *comp_data);
-
-G_DEFINE_TYPE (ECalModelTasks, e_cal_model_tasks, E_TYPE_CAL_MODEL)
-
enum {
PROP_0,
PROP_HIGHLIGHT_DUE_TODAY,
@@ -72,182 +55,10 @@ enum {
PROP_COLOR_OVERDUE
};
-static void
-cal_model_tasks_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_HIGHLIGHT_DUE_TODAY:
- e_cal_model_tasks_set_highlight_due_today (
- E_CAL_MODEL_TASKS (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_COLOR_DUE_TODAY:
- e_cal_model_tasks_set_color_due_today (
- E_CAL_MODEL_TASKS (object),
- g_value_get_string (value));
- return;
-
- case PROP_HIGHLIGHT_OVERDUE:
- e_cal_model_tasks_set_highlight_overdue (
- E_CAL_MODEL_TASKS (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_COLOR_OVERDUE:
- e_cal_model_tasks_set_color_overdue (
- E_CAL_MODEL_TASKS (object),
- g_value_get_string (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-cal_model_tasks_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_HIGHLIGHT_DUE_TODAY:
- g_value_set_boolean (
- value,
- e_cal_model_tasks_get_highlight_due_today (
- E_CAL_MODEL_TASKS (object)));
- return;
-
- case PROP_COLOR_DUE_TODAY:
- g_value_set_string (
- value,
- e_cal_model_tasks_get_color_due_today (
- E_CAL_MODEL_TASKS (object)));
- return;
-
- case PROP_HIGHLIGHT_OVERDUE:
- g_value_set_boolean (
- value,
- e_cal_model_tasks_get_highlight_overdue (
- E_CAL_MODEL_TASKS (object)));
- return;
-
- case PROP_COLOR_OVERDUE:
- g_value_set_string (
- value,
- e_cal_model_tasks_get_color_overdue (
- E_CAL_MODEL_TASKS (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-cal_model_tasks_finalize (GObject *object)
-{
- ECalModelTasksPrivate *priv;
-
- priv = E_CAL_MODEL_TASKS_GET_PRIVATE (object);
-
- g_free (priv->color_due_today);
- g_free (priv->color_overdue);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize (object);
-}
-
-static void
-e_cal_model_tasks_class_init (ECalModelTasksClass *class)
-{
- GObjectClass *object_class;
- ETableModelClass *table_model_class;
- ECalModelClass *cal_model_class;
-
- g_type_class_add_private (class, sizeof (ECalModelTasksPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->set_property = cal_model_tasks_set_property;
- object_class->get_property = cal_model_tasks_get_property;
- object_class->finalize = cal_model_tasks_finalize;
-
- table_model_class = E_TABLE_MODEL_CLASS (class);
- table_model_class->column_count = ecmt_column_count;
- table_model_class->value_at = ecmt_value_at;
- table_model_class->set_value_at = ecmt_set_value_at;
- table_model_class->is_cell_editable = ecmt_is_cell_editable;
- table_model_class->duplicate_value = ecmt_duplicate_value;
- table_model_class->free_value = ecmt_free_value;
- table_model_class->initialize_value = ecmt_initialize_value;
- table_model_class->value_is_empty = ecmt_value_is_empty;
- table_model_class->value_to_string = ecmt_value_to_string;
-
- cal_model_class = E_CAL_MODEL_CLASS (class);
- cal_model_class->get_color_for_component = ecmt_get_color_for_component;
- cal_model_class->fill_component_from_model = ecmt_fill_component_from_model;
-
- g_object_class_install_property (
- object_class,
- PROP_HIGHLIGHT_DUE_TODAY,
- g_param_spec_boolean (
- "highlight-due-today",
- "Highlight Due Today",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_COLOR_DUE_TODAY,
- g_param_spec_string (
- "color-due-today",
- "Color Due Today",
- NULL,
- "#1e90ff",
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_HIGHLIGHT_OVERDUE,
- g_param_spec_boolean (
- "highlight-overdue",
- "Highlight Overdue",
- NULL,
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_COLOR_OVERDUE,
- g_param_spec_string (
- "color-overdue",
- "Color Overdue",
- NULL,
- "#ff0000",
- G_PARAM_READWRITE));
-}
-
-static void
-e_cal_model_tasks_init (ECalModelTasks *model)
-{
- model->priv = E_CAL_MODEL_TASKS_GET_PRIVATE (model);
-
- model->priv->highlight_due_today = TRUE;
- model->priv->highlight_overdue = TRUE;
-
- e_cal_model_set_component_kind (
- E_CAL_MODEL (model), ICAL_VTODO_COMPONENT);
-}
-
-/* ETableModel methods */
-static gint
-ecmt_column_count (ETableModel *etm)
-{
- return E_CAL_MODEL_TASKS_FIELD_LAST;
-}
+G_DEFINE_TYPE (
+ ECalModelTasks,
+ e_cal_model_tasks,
+ E_TYPE_CAL_MODEL)
/* This makes sure a task is marked as complete.
* It makes sure the "Date Completed" property is set. If the completed_date
@@ -617,52 +428,6 @@ is_overdue (ECalModelTasks *model,
return FALSE;
}
-static gpointer
-ecmt_value_at (ETableModel *etm,
- gint col,
- gint row)
-{
- ECalModelComponent *comp_data;
- ECalModelTasks *model = (ECalModelTasks *) etm;
-
- g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
-
- g_return_val_if_fail (col >= 0 && (col < E_CAL_MODEL_TASKS_FIELD_LAST || col == E_CAL_MODEL_TASKS_FIELD_STRIKEOUT), NULL);
- g_return_val_if_fail (row >= 0 && row < e_table_model_row_count (etm), NULL);
-
- if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->value_at (etm, col, row);
-
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
- if (!comp_data)
- return (gpointer) "";
-
- switch (col) {
- case E_CAL_MODEL_TASKS_FIELD_COMPLETED :
- return get_completed (comp_data);
- case E_CAL_MODEL_TASKS_FIELD_STRIKEOUT :
- return GINT_TO_POINTER (is_status_canceled (comp_data) || is_complete (comp_data));
- case E_CAL_MODEL_TASKS_FIELD_COMPLETE :
- return GINT_TO_POINTER (is_complete (comp_data));
- case E_CAL_MODEL_TASKS_FIELD_DUE :
- return get_due (comp_data);
- case E_CAL_MODEL_TASKS_FIELD_GEO :
- return get_geo (comp_data);
- case E_CAL_MODEL_TASKS_FIELD_OVERDUE :
- return GINT_TO_POINTER (is_overdue (model, comp_data));
- case E_CAL_MODEL_TASKS_FIELD_PERCENT :
- return GINT_TO_POINTER (get_percent (comp_data));
- case E_CAL_MODEL_TASKS_FIELD_PRIORITY :
- return get_priority (comp_data);
- case E_CAL_MODEL_TASKS_FIELD_STATUS :
- return get_status (comp_data);
- case E_CAL_MODEL_TASKS_FIELD_URL :
- return get_url (comp_data);
- }
-
- return (gpointer) "";
-}
-
static void
set_completed (ECalModelTasks *model,
ECalModelComponent *comp_data,
@@ -906,11 +671,250 @@ set_url (ECalModelComponent *comp_data,
}
}
+/**
+ * commit_component_changes
+ * @comp_data: Component of our interest, which has been changed.
+ *
+ * Commits changes to the backend calendar of the component.
+ **/
+static void
+commit_component_changes (ECalModelComponent *comp_data)
+{
+ GError *error = NULL;
+
+ g_return_if_fail (comp_data != NULL);
+
+ /* FIXME ask about mod type */
+ e_cal_client_modify_object_sync (
+ comp_data->client, comp_data->icalcomp,
+ CALOBJ_MOD_ALL, NULL, &error);
+
+ if (error != NULL) {
+ g_warning (
+ G_STRLOC ": Could not modify the object! %s",
+ error->message);
+
+ /* FIXME Show error dialog */
+ g_error_free (error);
+ }
+}
+
+static void
+cal_model_tasks_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_HIGHLIGHT_DUE_TODAY:
+ e_cal_model_tasks_set_highlight_due_today (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_COLOR_DUE_TODAY:
+ e_cal_model_tasks_set_color_due_today (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_HIGHLIGHT_OVERDUE:
+ e_cal_model_tasks_set_highlight_overdue (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_COLOR_OVERDUE:
+ e_cal_model_tasks_set_color_overdue (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_string (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
static void
-ecmt_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer value)
+cal_model_tasks_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_HIGHLIGHT_DUE_TODAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_tasks_get_highlight_due_today (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+
+ case PROP_COLOR_DUE_TODAY:
+ g_value_set_string (
+ value,
+ e_cal_model_tasks_get_color_due_today (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+
+ case PROP_HIGHLIGHT_OVERDUE:
+ g_value_set_boolean (
+ value,
+ e_cal_model_tasks_get_highlight_overdue (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+
+ case PROP_COLOR_OVERDUE:
+ g_value_set_string (
+ value,
+ e_cal_model_tasks_get_color_overdue (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+cal_model_tasks_finalize (GObject *object)
+{
+ ECalModelTasksPrivate *priv;
+
+ priv = E_CAL_MODEL_TASKS_GET_PRIVATE (object);
+
+ g_free (priv->color_due_today);
+ g_free (priv->color_overdue);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize (object);
+}
+
+static const gchar *
+cal_model_tasks_get_color_for_component (ECalModel *model,
+ ECalModelComponent *comp_data)
+{
+ ECalModelTasks *tasks;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
+ g_return_val_if_fail (comp_data != NULL, NULL);
+
+ tasks = E_CAL_MODEL_TASKS (model);
+
+ /* XXX ECalModel's get_color_for_component() method should really
+ * get a GdkColor instead of a color specification string. */
+
+ switch (get_due_status (tasks, comp_data)) {
+ case E_CAL_MODEL_TASKS_DUE_TODAY:
+ if (!e_cal_model_tasks_get_highlight_due_today (tasks))
+ break;
+ return e_cal_model_tasks_get_color_due_today (tasks);
+ case E_CAL_MODEL_TASKS_DUE_OVERDUE:
+ if (!e_cal_model_tasks_get_highlight_overdue (tasks))
+ break;
+ return e_cal_model_tasks_get_color_overdue (tasks);
+ case E_CAL_MODEL_TASKS_DUE_NEVER:
+ case E_CAL_MODEL_TASKS_DUE_FUTURE:
+ case E_CAL_MODEL_TASKS_DUE_COMPLETE:
+ break;
+ }
+
+ return E_CAL_MODEL_CLASS (e_cal_model_tasks_parent_class)->
+ get_color_for_component (model, comp_data);
+}
+
+static void
+cal_model_tasks_fill_component_from_model (ECalModel *model,
+ ECalModelComponent *comp_data,
+ ETableModel *source_model,
+ gint row)
+{
+ gpointer value;
+
+ g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
+ g_return_if_fail (comp_data != NULL);
+ g_return_if_fail (E_IS_TABLE_MODEL (source_model));
+
+ /* This just makes sure if anything indicates completion, all
+ * three fields do or if percent is 0, status is sane */
+
+ value = e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_COMPLETED, row);
+ set_completed ((ECalModelTasks *) model, comp_data, value);
+ if (!value) {
+ value = e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_PERCENT, row);
+ set_percent (comp_data, value);
+ if (GPOINTER_TO_INT (value) != 100 && GPOINTER_TO_INT (value) != 0)
+ set_status (comp_data, e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_STATUS, row));
+ }
+
+ set_due (
+ model, comp_data,
+ e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_DUE, row));
+ set_geo (
+ comp_data,
+ e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_GEO, row));
+ set_priority (
+ comp_data,
+ e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_PRIORITY, row));
+ set_url (
+ comp_data,
+ e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_URL, row));
+}
+
+static gint
+cal_model_tasks_column_count (ETableModel *etm)
+{
+ return E_CAL_MODEL_TASKS_FIELD_LAST;
+}
+
+static gpointer
+cal_model_tasks_value_at (ETableModel *etm,
+ gint col,
+ gint row)
+{
+ ECalModelComponent *comp_data;
+ ECalModelTasks *model = (ECalModelTasks *) etm;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
+
+ g_return_val_if_fail (col >= 0 && (col < E_CAL_MODEL_TASKS_FIELD_LAST || col == E_CAL_MODEL_TASKS_FIELD_STRIKEOUT), NULL);
+ g_return_val_if_fail (row >= 0 && row < e_table_model_row_count (etm), NULL);
+
+ if (col < E_CAL_MODEL_FIELD_LAST)
+ return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->value_at (etm, col, row);
+
+ comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
+ if (!comp_data)
+ return (gpointer) "";
+
+ switch (col) {
+ case E_CAL_MODEL_TASKS_FIELD_COMPLETED :
+ return get_completed (comp_data);
+ case E_CAL_MODEL_TASKS_FIELD_STRIKEOUT :
+ return GINT_TO_POINTER (is_status_canceled (comp_data) || is_complete (comp_data));
+ case E_CAL_MODEL_TASKS_FIELD_COMPLETE :
+ return GINT_TO_POINTER (is_complete (comp_data));
+ case E_CAL_MODEL_TASKS_FIELD_DUE :
+ return get_due (comp_data);
+ case E_CAL_MODEL_TASKS_FIELD_GEO :
+ return get_geo (comp_data);
+ case E_CAL_MODEL_TASKS_FIELD_OVERDUE :
+ return GINT_TO_POINTER (is_overdue (model, comp_data));
+ case E_CAL_MODEL_TASKS_FIELD_PERCENT :
+ return GINT_TO_POINTER (get_percent (comp_data));
+ case E_CAL_MODEL_TASKS_FIELD_PRIORITY :
+ return get_priority (comp_data);
+ case E_CAL_MODEL_TASKS_FIELD_STATUS :
+ return get_status (comp_data);
+ case E_CAL_MODEL_TASKS_FIELD_URL :
+ return get_url (comp_data);
+ }
+
+ return (gpointer) "";
+}
+
+static void
+cal_model_tasks_set_value_at (ETableModel *etm,
+ gint col,
+ gint row,
+ gconstpointer value)
{
ECalModelComponent *comp_data;
ECalModelTasks *model = (ECalModelTasks *) etm;
@@ -960,9 +964,9 @@ ecmt_set_value_at (ETableModel *etm,
}
static gboolean
-ecmt_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
+cal_model_tasks_is_cell_editable (ETableModel *etm,
+ gint col,
+ gint row)
{
ECalModelTasks *model = (ECalModelTasks *) etm;
@@ -993,9 +997,9 @@ ecmt_is_cell_editable (ETableModel *etm,
}
static gpointer
-ecmt_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_tasks_duplicate_value (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, NULL);
@@ -1031,9 +1035,9 @@ ecmt_duplicate_value (ETableModel *etm,
}
static void
-ecmt_free_value (ETableModel *etm,
- gint col,
- gpointer value)
+cal_model_tasks_free_value (ETableModel *etm,
+ gint col,
+ gpointer value)
{
g_return_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST);
@@ -1060,8 +1064,8 @@ ecmt_free_value (ETableModel *etm,
}
static gpointer
-ecmt_initialize_value (ETableModel *etm,
- gint col)
+cal_model_tasks_initialize_value (ETableModel *etm,
+ gint col)
{
ECalModelTasks *model = (ECalModelTasks *) etm;
@@ -1090,9 +1094,9 @@ ecmt_initialize_value (ETableModel *etm,
}
static gboolean
-ecmt_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_tasks_value_is_empty (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ECalModelTasks *model = (ECalModelTasks *) etm;
@@ -1122,9 +1126,9 @@ ecmt_value_is_empty (ETableModel *etm,
}
static gchar *
-ecmt_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
+cal_model_tasks_value_to_string (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ECalModelTasks *model = (ECalModelTasks *) etm;
@@ -1156,77 +1160,86 @@ ecmt_value_to_string (ETableModel *etm,
return g_strdup ("");
}
-/* ECalModel class methods */
-
-static const gchar *
-ecmt_get_color_for_component (ECalModel *model,
- ECalModelComponent *comp_data)
+static void
+e_cal_model_tasks_class_init (ECalModelTasksClass *class)
{
- ECalModelTasks *tasks;
+ GObjectClass *object_class;
+ ECalModelClass *cal_model_class;
+ ETableModelClass *table_model_class;
- g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
- g_return_val_if_fail (comp_data != NULL, NULL);
+ g_type_class_add_private (class, sizeof (ECalModelTasksPrivate));
- tasks = E_CAL_MODEL_TASKS (model);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = cal_model_tasks_set_property;
+ object_class->get_property = cal_model_tasks_get_property;
+ object_class->finalize = cal_model_tasks_finalize;
- /* XXX ECalModel's get_color_for_component() method should really
- * get a GdkColor instead of a color specification string. */
+ cal_model_class = E_CAL_MODEL_CLASS (class);
+ cal_model_class->get_color_for_component = cal_model_tasks_get_color_for_component;
+ cal_model_class->fill_component_from_model = cal_model_tasks_fill_component_from_model;
- switch (get_due_status (tasks, comp_data)) {
- case E_CAL_MODEL_TASKS_DUE_TODAY:
- if (!e_cal_model_tasks_get_highlight_due_today (tasks))
- break;
- return e_cal_model_tasks_get_color_due_today (tasks);
- case E_CAL_MODEL_TASKS_DUE_OVERDUE:
- if (!e_cal_model_tasks_get_highlight_overdue (tasks))
- break;
- return e_cal_model_tasks_get_color_overdue (tasks);
- case E_CAL_MODEL_TASKS_DUE_NEVER:
- case E_CAL_MODEL_TASKS_DUE_FUTURE:
- case E_CAL_MODEL_TASKS_DUE_COMPLETE:
- break;
- }
+ table_model_class = E_TABLE_MODEL_CLASS (class);
+ table_model_class->column_count = cal_model_tasks_column_count;
+ table_model_class->value_at = cal_model_tasks_value_at;
+ table_model_class->set_value_at = cal_model_tasks_set_value_at;
+ table_model_class->is_cell_editable = cal_model_tasks_is_cell_editable;
+ table_model_class->duplicate_value = cal_model_tasks_duplicate_value;
+ table_model_class->free_value = cal_model_tasks_free_value;
+ table_model_class->initialize_value = cal_model_tasks_initialize_value;
+ table_model_class->value_is_empty = cal_model_tasks_value_is_empty;
+ table_model_class->value_to_string = cal_model_tasks_value_to_string;
- return E_CAL_MODEL_CLASS (e_cal_model_tasks_parent_class)->
- get_color_for_component (model, comp_data);
+ g_object_class_install_property (
+ object_class,
+ PROP_HIGHLIGHT_DUE_TODAY,
+ g_param_spec_boolean (
+ "highlight-due-today",
+ "Highlight Due Today",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_COLOR_DUE_TODAY,
+ g_param_spec_string (
+ "color-due-today",
+ "Color Due Today",
+ NULL,
+ "#1e90ff",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_HIGHLIGHT_OVERDUE,
+ g_param_spec_boolean (
+ "highlight-overdue",
+ "Highlight Overdue",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_COLOR_OVERDUE,
+ g_param_spec_string (
+ "color-overdue",
+ "Color Overdue",
+ NULL,
+ "#ff0000",
+ G_PARAM_READWRITE));
}
static void
-ecmt_fill_component_from_model (ECalModel *model,
- ECalModelComponent *comp_data,
- ETableModel *source_model,
- gint row)
+e_cal_model_tasks_init (ECalModelTasks *model)
{
- gpointer value;
-
- g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
- g_return_if_fail (comp_data != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (source_model));
-
- /* This just makes sure if anything indicates completion, all
- * three fields do or if percent is 0, status is sane */
+ model->priv = E_CAL_MODEL_TASKS_GET_PRIVATE (model);
- value = e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_COMPLETED, row);
- set_completed ((ECalModelTasks *) model, comp_data, value);
- if (!value) {
- value = e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_PERCENT, row);
- set_percent (comp_data, value);
- if (GPOINTER_TO_INT (value) != 100 && GPOINTER_TO_INT (value) != 0)
- set_status (comp_data, e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_STATUS, row));
- }
+ model->priv->highlight_due_today = TRUE;
+ model->priv->highlight_overdue = TRUE;
- set_due (
- model, comp_data,
- e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_DUE, row));
- set_geo (
- comp_data,
- e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_GEO, row));
- set_priority (
- comp_data,
- e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_PRIORITY, row));
- set_url (
- comp_data,
- e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_URL, row));
+ e_cal_model_set_component_kind (
+ E_CAL_MODEL (model), ICAL_VTODO_COMPONENT);
}
ECalModel *
@@ -1338,7 +1351,9 @@ e_cal_model_tasks_set_color_overdue (ECalModelTasks *model,
*
* Marks component as complete and commits changes to the calendar backend.
**/
-void e_cal_model_tasks_mark_comp_complete (ECalModelTasks *model, ECalModelComponent *comp_data)
+void
+e_cal_model_tasks_mark_comp_complete (ECalModelTasks *model,
+ ECalModelComponent *comp_data)
{
g_return_if_fail (model != NULL);
g_return_if_fail (comp_data != NULL);
@@ -1360,7 +1375,9 @@ void e_cal_model_tasks_mark_comp_complete (ECalModelTasks *model, ECalModelCompo
*
* Marks component as incomplete and commits changes to the calendar backend.
**/
-void e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model, ECalModelComponent *comp_data)
+void
+e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model,
+ ECalModelComponent *comp_data)
{
icalproperty *prop,*prop1;
@@ -1396,37 +1413,6 @@ void e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model, ECalModelCom
commit_component_changes (comp_data);
}
-/**
- * commit_component_changes
- * @comp_data: Component of our interest, which has been changed.
- *
- * Commits changes to the backend calendar of the component.
- **/
-static void
-commit_component_changes (ECalModelComponent *comp_data)
-{
- GError *error = NULL;
-
- g_return_if_fail (comp_data != NULL);
-
- /* FIXME ask about mod type */
- e_cal_client_modify_object_sync (
- comp_data->client, comp_data->icalcomp,
- CALOBJ_MOD_ALL, NULL, &error);
-
- if (error != NULL) {
- g_warning (
- G_STRLOC ": Could not modify the object! %s",
- error->message);
-
- /* FIXME Show error dialog */
- g_error_free (error);
- }
-}
-
-/**
- * e_cal_model_tasks_update_due_tasks
- */
void
e_cal_model_tasks_update_due_tasks (ECalModelTasks *model)
{
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 16c968d704..288a896f9d 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -145,19 +145,12 @@ struct _ECalModelPrivate {
GCancellable *loading_clients;
};
-static gint ecm_column_count (ETableModel *etm);
-static gint ecm_row_count (ETableModel *etm);
-static gpointer ecm_value_at (ETableModel *etm, gint col, gint row);
-static void ecm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value);
-static gboolean ecm_is_cell_editable (ETableModel *etm, gint col, gint row);
-static void ecm_append_row (ETableModel *etm, ETableModel *source, gint row);
-static gpointer ecm_duplicate_value (ETableModel *etm, gint col, gconstpointer value);
-static void ecm_free_value (ETableModel *etm, gint col, gpointer value);
-static gpointer ecm_initialize_value (ETableModel *etm, gint col);
-static gboolean ecm_value_is_empty (ETableModel *etm, gint col, gconstpointer value);
-static gchar *ecm_value_to_string (ETableModel *etm, gint col, gconstpointer value);
-
-static const gchar *ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data);
+typedef struct {
+ const gchar *color;
+ GList *uids;
+} AssignedColorData;
+
+static const gchar *cal_model_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data);
static gboolean add_new_client (ECalModel *model, ECalClient *client, gboolean do_query);
static void remove_client_objects (ECalModel *model, ClientData *client_data);
@@ -415,6 +408,349 @@ cal_model_clients_remove (ECalModel *model,
return removed;
}
+static gpointer
+get_categories (ECalModelComponent *comp_data)
+{
+ if (!comp_data->priv->categories_str) {
+ icalproperty *prop;
+
+ comp_data->priv->categories_str = g_string_new ("");
+
+ for (prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
+ prop;
+ prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY)) {
+ const gchar *categories = icalproperty_get_categories (prop);
+ if (!categories)
+ continue;
+
+ if (comp_data->priv->categories_str->len)
+ g_string_append_c (comp_data->priv->categories_str, ',');
+ g_string_append (comp_data->priv->categories_str, categories);
+ }
+ }
+
+ return comp_data->priv->categories_str->str;
+}
+
+static gchar *
+get_classification (ECalModelComponent *comp_data)
+{
+ icalproperty *prop;
+ icalproperty_class class;
+
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CLASS_PROPERTY);
+
+ if (!prop)
+ return _("Public");
+
+ class = icalproperty_get_class (prop);
+
+ switch (class)
+ {
+ case ICAL_CLASS_PUBLIC:
+ return _("Public");
+ case ICAL_CLASS_PRIVATE:
+ return _("Private");
+ case ICAL_CLASS_CONFIDENTIAL:
+ return _("Confidential");
+ default:
+ return _("Unknown");
+ }
+}
+
+static const gchar *
+get_color (ECalModel *model,
+ ECalModelComponent *comp_data)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ return e_cal_model_get_color_for_component (model, comp_data);
+}
+
+static gpointer
+get_description (ECalModelComponent *comp_data)
+{
+ icalproperty *prop;
+ static GString *str = NULL;
+
+ if (str) {
+ g_string_free (str, TRUE);
+ str = NULL;
+ }
+
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
+ if (prop) {
+ str = g_string_new (NULL);
+ do {
+ str = g_string_append (str, icalproperty_get_description (prop));
+ } while ((prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY)));
+
+ return str->str;
+ }
+
+ return (gpointer) "";
+}
+
+static ECellDateEditValue *
+get_dtstart (ECalModel *model,
+ ECalModelComponent *comp_data)
+{
+ ECalModelPrivate *priv;
+ struct icaltimetype tt_start;
+
+ priv = model->priv;
+
+ if (!comp_data->dtstart) {
+ icalproperty *prop;
+ icaltimezone *zone;
+ gboolean got_zone = FALSE;
+
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY);
+ if (!prop)
+ return NULL;
+
+ tt_start = icalproperty_get_dtstart (prop);
+
+ if (icaltime_get_tzid (tt_start)
+ && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL, NULL))
+ got_zone = TRUE;
+
+ if (e_cal_model_get_flags (model) & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) {
+ if (got_zone) {
+ tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, tt_start.is_date, zone);
+ if (priv->zone)
+ icaltimezone_convert_time (&tt_start, zone, priv->zone);
+ } else
+ if (priv->zone)
+ tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, tt_start.is_date, priv->zone);
+ }
+
+ if (!icaltime_is_valid_time (tt_start) || icaltime_is_null_time (tt_start))
+ return NULL;
+
+ comp_data->dtstart = g_new0 (ECellDateEditValue, 1);
+ comp_data->dtstart->tt = tt_start;
+
+ if (got_zone)
+ comp_data->dtstart->zone = zone;
+ else
+ comp_data->dtstart->zone = NULL;
+ }
+
+ return comp_data->dtstart;
+}
+
+static ECellDateEditValue *
+get_datetime_from_utc (ECalModel *model,
+ ECalModelComponent *comp_data,
+ icalproperty_kind propkind,
+ struct icaltimetype (*get_value) (const icalproperty *prop),
+ ECellDateEditValue **buffer)
+{
+ ECalModelPrivate *priv;
+ struct icaltimetype tt_value;
+ icalproperty *prop;
+ ECellDateEditValue *res;
+
+ g_return_val_if_fail (buffer!= NULL, NULL);
+
+ if (*buffer)
+ return *buffer;
+
+ priv = model->priv;
+
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, propkind);
+ if (!prop)
+ return NULL;
+
+ tt_value = get_value (prop);
+
+ /* these are always in UTC, thus convert to default zone, if any and done */
+ if (priv->zone)
+ icaltimezone_convert_time (&tt_value, icaltimezone_get_utc_timezone (), priv->zone);
+
+ if (!icaltime_is_valid_time (tt_value) || icaltime_is_null_time (tt_value))
+ return NULL;
+
+ res = g_new0 (ECellDateEditValue, 1);
+ res->tt = tt_value;
+ res->zone = NULL;
+
+ *buffer = res;
+
+ return res;
+}
+
+static gpointer
+get_summary (ECalModelComponent *comp_data)
+{
+ icalproperty *prop;
+
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_SUMMARY_PROPERTY);
+ if (prop)
+ return (gpointer) icalproperty_get_summary (prop);
+
+ return (gpointer) "";
+}
+
+static gchar *
+get_uid (ECalModelComponent *comp_data)
+{
+ return (gchar *) icalcomponent_get_uid (comp_data->icalcomp);
+}
+
+static void
+set_categories (ECalModelComponent *comp_data,
+ const gchar *value)
+{
+ icalproperty *prop;
+
+ /* remove all categories first */
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
+ while (prop) {
+ icalproperty *to_remove = prop;
+ prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
+
+ icalcomponent_remove_property (comp_data->icalcomp, to_remove);
+ icalproperty_free (to_remove);
+ }
+
+ if (comp_data->priv->categories_str)
+ g_string_free (comp_data->priv->categories_str, TRUE);
+ comp_data->priv->categories_str = NULL;
+
+ /* then set a new value; no need to populate categories_str,
+ * it'll be populated on demand (in the get_categories() function)
+ */
+ if (value && *value) {
+ prop = icalproperty_new_categories (value);
+ icalcomponent_add_property (comp_data->icalcomp, prop);
+ }
+}
+
+static void
+set_classification (ECalModelComponent *comp_data,
+ const gchar *value)
+{
+ icalproperty *prop;
+
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CLASS_PROPERTY);
+ if (!value || !(*value)) {
+ if (prop) {
+ icalcomponent_remove_property (comp_data->icalcomp, prop);
+ icalproperty_free (prop);
+ }
+ } else {
+ icalproperty_class ical_class;
+
+ if (!g_ascii_strcasecmp (value, "PUBLIC"))
+ ical_class = ICAL_CLASS_PUBLIC;
+ else if (!g_ascii_strcasecmp (value, "PRIVATE"))
+ ical_class = ICAL_CLASS_PRIVATE;
+ else if (!g_ascii_strcasecmp (value, "CONFIDENTIAL"))
+ ical_class = ICAL_CLASS_CONFIDENTIAL;
+ else
+ ical_class = ICAL_CLASS_NONE;
+
+ if (!prop) {
+ prop = icalproperty_new_class (ical_class);
+ icalcomponent_add_property (comp_data->icalcomp, prop);
+ } else
+ icalproperty_set_class (prop, ical_class);
+ }
+}
+
+static void
+set_description (ECalModelComponent *comp_data,
+ const gchar *value)
+{
+ icalproperty *prop;
+
+ /* remove old description(s) */
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
+ while (prop) {
+ icalproperty *next;
+
+ next = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
+
+ icalcomponent_remove_property (comp_data->icalcomp, prop);
+ icalproperty_free (prop);
+
+ prop = next;
+ }
+
+ /* now add the new description */
+ if (!value || !(*value))
+ return;
+
+ prop = icalproperty_new_description (value);
+ icalcomponent_add_property (comp_data->icalcomp, prop);
+}
+
+static void
+set_dtstart (ECalModel *model,
+ ECalModelComponent *comp_data,
+ gconstpointer value)
+{
+ e_cal_model_update_comp_time (
+ model, comp_data, value,
+ ICAL_DTSTART_PROPERTY,
+ icalproperty_set_dtstart,
+ icalproperty_new_dtstart);
+}
+
+static void
+set_summary (ECalModelComponent *comp_data,
+ const gchar *value)
+{
+ icalproperty *prop;
+
+ prop = icalcomponent_get_first_property (
+ comp_data->icalcomp, ICAL_SUMMARY_PROPERTY);
+
+ if (string_is_empty (value)) {
+ if (prop) {
+ icalcomponent_remove_property (comp_data->icalcomp, prop);
+ icalproperty_free (prop);
+ }
+ } else {
+ if (prop)
+ icalproperty_set_summary (prop, value);
+ else {
+ prop = icalproperty_new_summary (value);
+ icalcomponent_add_property (comp_data->icalcomp, prop);
+ }
+ }
+}
+
+static void
+datetime_to_zone (ECalClient *client,
+ struct icaltimetype *tt,
+ icaltimezone *tt_zone,
+ const gchar *tzid)
+{
+ icaltimezone *from, *to;
+ const gchar *tt_tzid = NULL;
+
+ g_return_if_fail (tt != NULL);
+
+ if (tt_zone)
+ tt_tzid = icaltimezone_get_tzid (tt_zone);
+
+ if (tt_tzid == NULL || tzid == NULL ||
+ tt_tzid == tzid || g_str_equal (tt_tzid, tzid))
+ return;
+
+ from = tt_zone;
+ to = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ if (!to) {
+ /* do not check failure here, maybe the zone is not available there */
+ e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL);
+ }
+
+ icaltimezone_convert_time (tt, from, to);
+}
+
static void
cal_model_set_registry (ECalModel *model,
ESourceRegistry *registry)
@@ -800,6 +1136,538 @@ cal_model_finalize (GObject *object)
G_OBJECT_CLASS (e_cal_model_parent_class)->finalize (object);
}
+static const gchar *
+cal_model_get_color_for_component (ECalModel *model,
+ ECalModelComponent *comp_data)
+{
+ ESource *source;
+ ESourceSelectable *extension;
+ const gchar *color_spec;
+ const gchar *extension_name;
+ const gchar *uid;
+ gint i, first_empty = 0;
+
+ static AssignedColorData assigned_colors[] = {
+ { "#BECEDD", NULL }, /* 190 206 221 Blue */
+ { "#E2F0EF", NULL }, /* 226 240 239 Light Blue */
+ { "#C6E2B7", NULL }, /* 198 226 183 Green */
+ { "#E2F0D3", NULL }, /* 226 240 211 Light Green */
+ { "#E2D4B7", NULL }, /* 226 212 183 Khaki */
+ { "#EAEAC1", NULL }, /* 234 234 193 Light Khaki */
+ { "#F0B8B7", NULL }, /* 240 184 183 Pink */
+ { "#FED4D3", NULL }, /* 254 212 211 Light Pink */
+ { "#E2C6E1", NULL }, /* 226 198 225 Purple */
+ { "#F0E2EF", NULL } /* 240 226 239 Light Purple */
+ };
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ switch (e_cal_client_get_source_type (comp_data->client)) {
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
+ extension_name = E_SOURCE_EXTENSION_CALENDAR;
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
+ extension_name = E_SOURCE_EXTENSION_TASK_LIST;
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
+ extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
+ break;
+ default:
+ g_return_val_if_reached (NULL);
+ }
+
+ source = e_client_get_source (E_CLIENT (comp_data->client));
+ extension = e_source_get_extension (source, extension_name);
+ color_spec = e_source_selectable_get_color (extension);
+
+ if (color_spec != NULL) {
+ g_free (comp_data->color);
+ comp_data->color = g_strdup (color_spec);
+ return comp_data->color;
+ }
+
+ uid = e_source_get_uid (source);
+
+ for (i = 0; i < G_N_ELEMENTS (assigned_colors); i++) {
+ GList *l;
+
+ if (assigned_colors[i].uids == NULL) {
+ first_empty = i;
+ continue;
+ }
+
+ for (l = assigned_colors[i].uids; l != NULL; l = l->next)
+ if (g_strcmp0 (l->data, uid) == 0)
+ return assigned_colors[i].color;
+ }
+
+ /* return the first unused color */
+ assigned_colors[first_empty].uids = g_list_append (
+ assigned_colors[first_empty].uids, g_strdup (uid));
+
+ return assigned_colors[first_empty].color;
+}
+
+static gint
+cal_model_column_count (ETableModel *etm)
+{
+ return E_CAL_MODEL_FIELD_LAST;
+}
+
+static gint
+cal_model_row_count (ETableModel *etm)
+{
+ ECalModelPrivate *priv;
+ ECalModel *model = (ECalModel *) etm;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), -1);
+
+ priv = model->priv;
+
+ return priv->objects->len;
+}
+
+static void
+cal_model_append_row (ETableModel *etm,
+ ETableModel *source,
+ gint row)
+{
+ ECalModelClass *model_class;
+ ECalModelComponent *comp_data;
+ ECalModel *model = (ECalModel *) etm;
+ gchar *uid = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (E_IS_CAL_MODEL (model));
+ g_return_if_fail (E_IS_TABLE_MODEL (source));
+
+ comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL);
+
+ comp_data->client = e_cal_model_ref_default_client (model);
+
+ if (comp_data->client == NULL) {
+ g_object_unref (comp_data);
+ return;
+ }
+
+ comp_data->icalcomp = e_cal_model_create_component_with_defaults (model, FALSE);
+
+ /* set values for our fields */
+ set_categories (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_CATEGORIES, row));
+ set_classification (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_CLASSIFICATION, row));
+ set_description (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_DESCRIPTION, row));
+ set_summary (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_SUMMARY, row));
+
+ if (e_table_model_value_at (source, E_CAL_MODEL_FIELD_DTSTART, row)) {
+ set_dtstart (model, comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_DTSTART, row));
+ } else if (model->priv->get_default_time) {
+ time_t tt = model->priv->get_default_time (model, model->priv->get_default_time_user_data);
+
+ if (tt > 0) {
+ struct icaltimetype itt = icaltime_from_timet_with_zone (tt, FALSE, e_cal_model_get_timezone (model));
+ icalproperty *prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY);
+
+ if (prop) {
+ icalproperty_set_dtstart (prop, itt);
+ } else {
+ prop = icalproperty_new_dtstart (itt);
+ icalcomponent_add_property (comp_data->icalcomp, prop);
+ }
+ }
+ }
+
+ /* call the class' method for filling the component */
+ model_class = (ECalModelClass *) G_OBJECT_GET_CLASS (model);
+ if (model_class->fill_component_from_model != NULL) {
+ model_class->fill_component_from_model (model, comp_data, source, row);
+ }
+
+ e_cal_client_create_object_sync (
+ comp_data->client, comp_data->icalcomp, &uid, NULL, &error);
+
+ if (error != NULL) {
+ g_warning (
+ G_STRLOC ": Could not create the object! %s",
+ error->message);
+
+ /* FIXME: show error dialog */
+ g_error_free (error);
+ } else {
+ if (uid)
+ icalcomponent_set_uid (comp_data->icalcomp, uid);
+
+ g_signal_emit (model, signals[ROW_APPENDED], 0);
+ }
+
+ g_free (uid);
+ g_object_unref (comp_data);
+}
+
+static gpointer
+cal_model_value_at (ETableModel *etm,
+ gint col,
+ gint row)
+{
+ ECalModelPrivate *priv;
+ ECalModelComponent *comp_data;
+ ECalModel *model = (ECalModel *) etm;
+ ESourceRegistry *registry;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ priv = model->priv;
+
+ registry = e_cal_model_get_registry (model);
+
+ g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, NULL);
+ g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL);
+
+ comp_data = g_ptr_array_index (priv->objects, row);
+ g_return_val_if_fail (comp_data != NULL, NULL);
+ g_return_val_if_fail (comp_data->icalcomp != NULL, NULL);
+
+ switch (col) {
+ case E_CAL_MODEL_FIELD_CATEGORIES :
+ return get_categories (comp_data);
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ return get_classification (comp_data);
+ case E_CAL_MODEL_FIELD_COLOR :
+ return (gpointer) get_color (model, comp_data);
+ case E_CAL_MODEL_FIELD_COMPONENT :
+ return comp_data->icalcomp;
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ return get_description (comp_data);
+ case E_CAL_MODEL_FIELD_DTSTART :
+ return (gpointer) get_dtstart (model, comp_data);
+ case E_CAL_MODEL_FIELD_CREATED :
+ return (gpointer) get_datetime_from_utc (
+ model, comp_data, ICAL_CREATED_PROPERTY,
+ icalproperty_get_created, &comp_data->created);
+ case E_CAL_MODEL_FIELD_LASTMODIFIED :
+ return (gpointer) get_datetime_from_utc (
+ model, comp_data, ICAL_LASTMODIFIED_PROPERTY,
+ icalproperty_get_lastmodified, &comp_data->lastmodified);
+ case E_CAL_MODEL_FIELD_HAS_ALARMS :
+ return GINT_TO_POINTER (
+ icalcomponent_get_first_component (
+ comp_data->icalcomp,
+ ICAL_VALARM_COMPONENT) != NULL);
+ case E_CAL_MODEL_FIELD_ICON :
+ {
+ ECalComponent *comp;
+ icalcomponent *icalcomp;
+ gint retval = 0;
+
+ comp = e_cal_component_new ();
+ icalcomp = icalcomponent_new_clone (comp_data->icalcomp);
+ if (e_cal_component_set_icalcomponent (comp, icalcomp)) {
+ if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_JOURNAL) {
+ g_object_unref (comp);
+ return GINT_TO_POINTER (retval);
+ }
+
+ if (e_cal_component_has_recurrences (comp))
+ retval = 1;
+ else if (itip_organizer_is_user (registry, comp, comp_data->client))
+ retval = 3;
+ else {
+ GSList *attendees = NULL, *sl;
+
+ e_cal_component_get_attendee_list (comp, &attendees);
+ for (sl = attendees; sl != NULL; sl = sl->next) {
+ ECalComponentAttendee *ca = sl->data;
+ const gchar *text;
+
+ text = itip_strip_mailto (ca->value);
+ if (itip_address_is_user (registry, text)) {
+ if (ca->delto != NULL)
+ retval = 3;
+ else
+ retval = 2;
+ break;
+ }
+ }
+
+ e_cal_component_free_attendee_list (attendees);
+ }
+ } else
+ icalcomponent_free (icalcomp);
+
+ g_object_unref (comp);
+
+ return GINT_TO_POINTER (retval);
+ }
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ return get_summary (comp_data);
+ case E_CAL_MODEL_FIELD_UID :
+ return get_uid (comp_data);
+ }
+
+ return (gpointer) "";
+}
+
+static void
+cal_model_set_value_at (ETableModel *etm,
+ gint col,
+ gint row,
+ gconstpointer value)
+{
+ ECalModelPrivate *priv;
+ ECalModelComponent *comp_data;
+ ECalModel *model = (ECalModel *) etm;
+ GError *error = NULL;
+
+ g_return_if_fail (E_IS_CAL_MODEL (model));
+
+ priv = model->priv;
+
+ g_return_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST);
+ g_return_if_fail (row >= 0 && row < priv->objects->len);
+
+ comp_data = g_ptr_array_index (priv->objects, row);
+ g_return_if_fail (comp_data != NULL);
+
+ switch (col) {
+ case E_CAL_MODEL_FIELD_CATEGORIES :
+ set_categories (comp_data, value);
+ break;
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ set_classification (comp_data, value);
+ break;
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ set_description (comp_data, value);
+ break;
+ case E_CAL_MODEL_FIELD_DTSTART :
+ set_dtstart (model, comp_data, value);
+ break;
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ set_summary (comp_data, value);
+ break;
+ }
+
+ /* FIXME ask about mod type */
+ e_cal_client_modify_object_sync (
+ comp_data->client, comp_data->icalcomp,
+ CALOBJ_MOD_ALL, NULL, &error);
+
+ if (error != NULL) {
+ g_warning (
+ G_STRLOC ": Could not modify the object! %s",
+ error->message);
+
+ /* FIXME Show error dialog */
+ g_error_free (error);
+ }
+}
+
+static gboolean
+cal_model_is_cell_editable (ETableModel *etm,
+ gint col,
+ gint row)
+{
+ ECalModelPrivate *priv;
+ ECalModel *model = (ECalModel *) etm;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE);
+
+ priv = model->priv;
+
+ g_return_val_if_fail (col >= 0 && col <= E_CAL_MODEL_FIELD_LAST, FALSE);
+ g_return_val_if_fail (row >= -1 || (row >= 0 && row < priv->objects->len), FALSE);
+
+ if (!e_cal_model_test_row_editable (E_CAL_MODEL (etm), row))
+ return FALSE;
+
+ switch (col) {
+ case E_CAL_MODEL_FIELD_CATEGORIES :
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ case E_CAL_MODEL_FIELD_DTSTART :
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gpointer
+cal_model_duplicate_value (ETableModel *etm,
+ gint col,
+ gconstpointer value)
+{
+ g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, NULL);
+
+ switch (col) {
+ case E_CAL_MODEL_FIELD_CATEGORIES :
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ return g_strdup (value);
+ case E_CAL_MODEL_FIELD_HAS_ALARMS :
+ case E_CAL_MODEL_FIELD_ICON :
+ case E_CAL_MODEL_FIELD_COLOR :
+ return (gpointer) value;
+ case E_CAL_MODEL_FIELD_COMPONENT :
+ return icalcomponent_new_clone ((icalcomponent *) value);
+ case E_CAL_MODEL_FIELD_DTSTART :
+ case E_CAL_MODEL_FIELD_CREATED :
+ case E_CAL_MODEL_FIELD_LASTMODIFIED :
+ if (value) {
+ ECellDateEditValue *dv, *orig_dv;
+
+ orig_dv = (ECellDateEditValue *) value;
+ dv = g_new0 (ECellDateEditValue, 1);
+ *dv = *orig_dv;
+
+ return dv;
+ }
+ break;
+ }
+
+ return NULL;
+}
+
+static void
+cal_model_free_value (ETableModel *etm,
+ gint col,
+ gpointer value)
+{
+ g_return_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST);
+
+ switch (col) {
+ case E_CAL_MODEL_FIELD_CATEGORIES :
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ if (value)
+ g_free (value);
+ break;
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ case E_CAL_MODEL_FIELD_HAS_ALARMS :
+ case E_CAL_MODEL_FIELD_ICON :
+ case E_CAL_MODEL_FIELD_COLOR :
+ break;
+ case E_CAL_MODEL_FIELD_DTSTART :
+ case E_CAL_MODEL_FIELD_CREATED :
+ case E_CAL_MODEL_FIELD_LASTMODIFIED :
+ if (value)
+ g_free (value);
+ break;
+ case E_CAL_MODEL_FIELD_COMPONENT :
+ if (value)
+ icalcomponent_free ((icalcomponent *) value);
+ break;
+ }
+}
+
+static gpointer
+cal_model_initialize_value (ETableModel *etm,
+ gint col)
+{
+ ECalModelPrivate *priv;
+ ECalModel *model = (ECalModel *) etm;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+ g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, NULL);
+
+ priv = model->priv;
+
+ switch (col) {
+ case E_CAL_MODEL_FIELD_CATEGORIES :
+ return g_strdup (priv->default_category ? priv->default_category:"");
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ return g_strdup ("");
+ case E_CAL_MODEL_FIELD_DTSTART :
+ case E_CAL_MODEL_FIELD_CREATED :
+ case E_CAL_MODEL_FIELD_LASTMODIFIED :
+ case E_CAL_MODEL_FIELD_HAS_ALARMS :
+ case E_CAL_MODEL_FIELD_ICON :
+ case E_CAL_MODEL_FIELD_COLOR :
+ case E_CAL_MODEL_FIELD_COMPONENT :
+ return NULL;
+ }
+
+ return NULL;
+}
+
+static gboolean
+cal_model_value_is_empty (ETableModel *etm,
+ gint col,
+ gconstpointer value)
+{
+ ECalModelPrivate *priv;
+ ECalModel *model = (ECalModel *) etm;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), TRUE);
+ g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, TRUE);
+
+ priv = model->priv;
+
+ switch (col) {
+ case E_CAL_MODEL_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
+ * ecm_initialize_value().
+ */
+ if (priv->default_category && value && strcmp (priv->default_category, value) == 0)
+ return TRUE;
+ else
+ return string_is_empty (value);
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ return string_is_empty (value);
+ case E_CAL_MODEL_FIELD_DTSTART :
+ case E_CAL_MODEL_FIELD_CREATED :
+ case E_CAL_MODEL_FIELD_LASTMODIFIED :
+ return value ? FALSE : TRUE;
+ case E_CAL_MODEL_FIELD_HAS_ALARMS :
+ case E_CAL_MODEL_FIELD_ICON :
+ case E_CAL_MODEL_FIELD_COLOR :
+ case E_CAL_MODEL_FIELD_COMPONENT :
+ return TRUE;
+ }
+
+ return TRUE;
+}
+
+static gchar *
+cal_model_value_to_string (ETableModel *etm,
+ gint col,
+ gconstpointer value)
+{
+ g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, g_strdup (""));
+
+ switch (col) {
+ case E_CAL_MODEL_FIELD_CATEGORIES :
+ case E_CAL_MODEL_FIELD_CLASSIFICATION :
+ case E_CAL_MODEL_FIELD_DESCRIPTION :
+ case E_CAL_MODEL_FIELD_SUMMARY :
+ return g_strdup (value);
+ case E_CAL_MODEL_FIELD_DTSTART :
+ case E_CAL_MODEL_FIELD_CREATED :
+ case E_CAL_MODEL_FIELD_LASTMODIFIED :
+ return e_cal_model_date_value_to_string (E_CAL_MODEL (etm), value);
+ case E_CAL_MODEL_FIELD_ICON :
+ if (GPOINTER_TO_INT (value) == 0)
+ return g_strdup (_("Normal"));
+ else if (GPOINTER_TO_INT (value) == 1)
+ return g_strdup (_("Recurring"));
+ else
+ return g_strdup (_("Assigned"));
+ case E_CAL_MODEL_FIELD_HAS_ALARMS :
+ return g_strdup (value ? _("Yes") : _("No"));
+ case E_CAL_MODEL_FIELD_COLOR :
+ case E_CAL_MODEL_FIELD_COMPONENT :
+ return g_strdup ("");
+ }
+
+ return g_strdup ("");
+}
+
static void
e_cal_model_class_init (ECalModelClass *class)
{
@@ -815,22 +1683,22 @@ e_cal_model_class_init (ECalModelClass *class)
object_class->dispose = cal_model_dispose;
object_class->finalize = cal_model_finalize;
- etm_class = E_TABLE_MODEL_CLASS (class);
- etm_class->column_count = ecm_column_count;
- etm_class->row_count = ecm_row_count;
- etm_class->value_at = ecm_value_at;
- etm_class->set_value_at = ecm_set_value_at;
- etm_class->is_cell_editable = ecm_is_cell_editable;
- etm_class->append_row = ecm_append_row;
- etm_class->duplicate_value = ecm_duplicate_value;
- etm_class->free_value = ecm_free_value;
- etm_class->initialize_value = ecm_initialize_value;
- etm_class->value_is_empty = ecm_value_is_empty;
- etm_class->value_to_string = ecm_value_to_string;
-
- class->get_color_for_component = ecm_get_color_for_component;
+ class->get_color_for_component = cal_model_get_color_for_component;
class->fill_component_from_model = NULL;
+ etm_class = E_TABLE_MODEL_CLASS (class);
+ etm_class->column_count = cal_model_column_count;
+ etm_class->row_count = cal_model_row_count;
+ etm_class->append_row = cal_model_append_row;
+ etm_class->value_at = cal_model_value_at;
+ etm_class->set_value_at = cal_model_set_value_at;
+ etm_class->is_cell_editable = cal_model_is_cell_editable;
+ etm_class->duplicate_value = cal_model_duplicate_value;
+ etm_class->free_value = cal_model_free_value;
+ etm_class->initialize_value = cal_model_initialize_value;
+ etm_class->value_is_empty = cal_model_value_is_empty;
+ etm_class->value_to_string = cal_model_value_to_string;
+
g_object_class_install_property (
object_class,
PROP_COMPRESS_WEEKEND,
@@ -1174,437 +2042,6 @@ e_cal_model_init (ECalModel *model)
model->priv->loading_clients = g_cancellable_new ();
}
-/* ETableModel methods */
-
-static gint
-ecm_column_count (ETableModel *etm)
-{
- return E_CAL_MODEL_FIELD_LAST;
-}
-
-static gint
-ecm_row_count (ETableModel *etm)
-{
- ECalModelPrivate *priv;
- ECalModel *model = (ECalModel *) etm;
-
- g_return_val_if_fail (E_IS_CAL_MODEL (model), -1);
-
- priv = model->priv;
-
- return priv->objects->len;
-}
-
-static gpointer
-get_categories (ECalModelComponent *comp_data)
-{
- if (!comp_data->priv->categories_str) {
- icalproperty *prop;
-
- comp_data->priv->categories_str = g_string_new ("");
-
- for (prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
- prop;
- prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY)) {
- const gchar *categories = icalproperty_get_categories (prop);
- if (!categories)
- continue;
-
- if (comp_data->priv->categories_str->len)
- g_string_append_c (comp_data->priv->categories_str, ',');
- g_string_append (comp_data->priv->categories_str, categories);
- }
- }
-
- return comp_data->priv->categories_str->str;
-}
-
-static gchar *
-get_classification (ECalModelComponent *comp_data)
-{
- icalproperty *prop;
- icalproperty_class class;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CLASS_PROPERTY);
-
- if (!prop)
- return _("Public");
-
- class = icalproperty_get_class (prop);
-
- switch (class)
- {
- case ICAL_CLASS_PUBLIC:
- return _("Public");
- case ICAL_CLASS_PRIVATE:
- return _("Private");
- case ICAL_CLASS_CONFIDENTIAL:
- return _("Confidential");
- default:
- return _("Unknown");
- }
-}
-
-static const gchar *
-get_color (ECalModel *model,
- ECalModelComponent *comp_data)
-{
- g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
-
- return e_cal_model_get_color_for_component (model, comp_data);
-}
-
-static gpointer
-get_description (ECalModelComponent *comp_data)
-{
- icalproperty *prop;
- static GString *str = NULL;
-
- if (str) {
- g_string_free (str, TRUE);
- str = NULL;
- }
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
- if (prop) {
- str = g_string_new (NULL);
- do {
- str = g_string_append (str, icalproperty_get_description (prop));
- } while ((prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY)));
-
- return str->str;
- }
-
- return (gpointer) "";
-}
-
-static ECellDateEditValue *
-get_dtstart (ECalModel *model,
- ECalModelComponent *comp_data)
-{
- ECalModelPrivate *priv;
- struct icaltimetype tt_start;
-
- priv = model->priv;
-
- if (!comp_data->dtstart) {
- icalproperty *prop;
- icaltimezone *zone;
- gboolean got_zone = FALSE;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY);
- if (!prop)
- return NULL;
-
- tt_start = icalproperty_get_dtstart (prop);
-
- if (icaltime_get_tzid (tt_start)
- && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL, NULL))
- got_zone = TRUE;
-
- if (e_cal_model_get_flags (model) & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) {
- if (got_zone) {
- tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, tt_start.is_date, zone);
- if (priv->zone)
- icaltimezone_convert_time (&tt_start, zone, priv->zone);
- } else
- if (priv->zone)
- tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, tt_start.is_date, priv->zone);
- }
-
- if (!icaltime_is_valid_time (tt_start) || icaltime_is_null_time (tt_start))
- return NULL;
-
- comp_data->dtstart = g_new0 (ECellDateEditValue, 1);
- comp_data->dtstart->tt = tt_start;
-
- if (got_zone)
- comp_data->dtstart->zone = zone;
- else
- comp_data->dtstart->zone = NULL;
- }
-
- return comp_data->dtstart;
-}
-
-static ECellDateEditValue *
-get_datetime_from_utc (ECalModel *model,
- ECalModelComponent *comp_data,
- icalproperty_kind propkind,
- struct icaltimetype (*get_value) (const icalproperty *prop),
- ECellDateEditValue **buffer)
-{
- ECalModelPrivate *priv;
- struct icaltimetype tt_value;
- icalproperty *prop;
- ECellDateEditValue *res;
-
- g_return_val_if_fail (buffer!= NULL, NULL);
-
- if (*buffer)
- return *buffer;
-
- priv = model->priv;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, propkind);
- if (!prop)
- return NULL;
-
- tt_value = get_value (prop);
-
- /* these are always in UTC, thus convert to default zone, if any and done */
- if (priv->zone)
- icaltimezone_convert_time (&tt_value, icaltimezone_get_utc_timezone (), priv->zone);
-
- if (!icaltime_is_valid_time (tt_value) || icaltime_is_null_time (tt_value))
- return NULL;
-
- res = g_new0 (ECellDateEditValue, 1);
- res->tt = tt_value;
- res->zone = NULL;
-
- *buffer = res;
-
- return res;
-}
-
-static gpointer
-get_summary (ECalModelComponent *comp_data)
-{
- icalproperty *prop;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_SUMMARY_PROPERTY);
- if (prop)
- return (gpointer) icalproperty_get_summary (prop);
-
- return (gpointer) "";
-}
-
-static gchar *
-get_uid (ECalModelComponent *comp_data)
-{
- return (gchar *) icalcomponent_get_uid (comp_data->icalcomp);
-}
-
-static gpointer
-ecm_value_at (ETableModel *etm,
- gint col,
- gint row)
-{
- ECalModelPrivate *priv;
- ECalModelComponent *comp_data;
- ECalModel *model = (ECalModel *) etm;
- ESourceRegistry *registry;
-
- g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
-
- priv = model->priv;
-
- registry = e_cal_model_get_registry (model);
-
- g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, NULL);
- g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL);
-
- comp_data = g_ptr_array_index (priv->objects, row);
- g_return_val_if_fail (comp_data != NULL, NULL);
- g_return_val_if_fail (comp_data->icalcomp != NULL, NULL);
-
- switch (col) {
- case E_CAL_MODEL_FIELD_CATEGORIES :
- return get_categories (comp_data);
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- return get_classification (comp_data);
- case E_CAL_MODEL_FIELD_COLOR :
- return (gpointer) get_color (model, comp_data);
- case E_CAL_MODEL_FIELD_COMPONENT :
- return comp_data->icalcomp;
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- return get_description (comp_data);
- case E_CAL_MODEL_FIELD_DTSTART :
- return (gpointer) get_dtstart (model, comp_data);
- case E_CAL_MODEL_FIELD_CREATED :
- return (gpointer) get_datetime_from_utc (
- model, comp_data, ICAL_CREATED_PROPERTY,
- icalproperty_get_created, &comp_data->created);
- case E_CAL_MODEL_FIELD_LASTMODIFIED :
- return (gpointer) get_datetime_from_utc (
- model, comp_data, ICAL_LASTMODIFIED_PROPERTY,
- icalproperty_get_lastmodified, &comp_data->lastmodified);
- case E_CAL_MODEL_FIELD_HAS_ALARMS :
- return GINT_TO_POINTER (
- icalcomponent_get_first_component (
- comp_data->icalcomp,
- ICAL_VALARM_COMPONENT) != NULL);
- case E_CAL_MODEL_FIELD_ICON :
- {
- ECalComponent *comp;
- icalcomponent *icalcomp;
- gint retval = 0;
-
- comp = e_cal_component_new ();
- icalcomp = icalcomponent_new_clone (comp_data->icalcomp);
- if (e_cal_component_set_icalcomponent (comp, icalcomp)) {
- if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_JOURNAL) {
- g_object_unref (comp);
- return GINT_TO_POINTER (retval);
- }
-
- if (e_cal_component_has_recurrences (comp))
- retval = 1;
- else if (itip_organizer_is_user (registry, comp, comp_data->client))
- retval = 3;
- else {
- GSList *attendees = NULL, *sl;
-
- e_cal_component_get_attendee_list (comp, &attendees);
- for (sl = attendees; sl != NULL; sl = sl->next) {
- ECalComponentAttendee *ca = sl->data;
- const gchar *text;
-
- text = itip_strip_mailto (ca->value);
- if (itip_address_is_user (registry, text)) {
- if (ca->delto != NULL)
- retval = 3;
- else
- retval = 2;
- break;
- }
- }
-
- e_cal_component_free_attendee_list (attendees);
- }
- } else
- icalcomponent_free (icalcomp);
-
- g_object_unref (comp);
-
- return GINT_TO_POINTER (retval);
- }
- case E_CAL_MODEL_FIELD_SUMMARY :
- return get_summary (comp_data);
- case E_CAL_MODEL_FIELD_UID :
- return get_uid (comp_data);
- }
-
- return (gpointer) "";
-}
-
-static void
-set_categories (ECalModelComponent *comp_data,
- const gchar *value)
-{
- icalproperty *prop;
-
- /* remove all categories first */
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
- while (prop) {
- icalproperty *to_remove = prop;
- prop = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_CATEGORIES_PROPERTY);
-
- icalcomponent_remove_property (comp_data->icalcomp, to_remove);
- icalproperty_free (to_remove);
- }
-
- if (comp_data->priv->categories_str)
- g_string_free (comp_data->priv->categories_str, TRUE);
- comp_data->priv->categories_str = NULL;
-
- /* then set a new value; no need to populate categories_str,
- * it'll be populated on demand (in the get_categories() function)
- */
- if (value && *value) {
- prop = icalproperty_new_categories (value);
- icalcomponent_add_property (comp_data->icalcomp, prop);
- }
-}
-
-static void
-set_classification (ECalModelComponent *comp_data,
- const gchar *value)
-{
- icalproperty *prop;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_CLASS_PROPERTY);
- if (!value || !(*value)) {
- if (prop) {
- icalcomponent_remove_property (comp_data->icalcomp, prop);
- icalproperty_free (prop);
- }
- } else {
- icalproperty_class ical_class;
-
- if (!g_ascii_strcasecmp (value, "PUBLIC"))
- ical_class = ICAL_CLASS_PUBLIC;
- else if (!g_ascii_strcasecmp (value, "PRIVATE"))
- ical_class = ICAL_CLASS_PRIVATE;
- else if (!g_ascii_strcasecmp (value, "CONFIDENTIAL"))
- ical_class = ICAL_CLASS_CONFIDENTIAL;
- else
- ical_class = ICAL_CLASS_NONE;
-
- if (!prop) {
- prop = icalproperty_new_class (ical_class);
- icalcomponent_add_property (comp_data->icalcomp, prop);
- } else
- icalproperty_set_class (prop, ical_class);
- }
-}
-
-static void
-set_description (ECalModelComponent *comp_data,
- const gchar *value)
-{
- icalproperty *prop;
-
- /* remove old description(s) */
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
- while (prop) {
- icalproperty *next;
-
- next = icalcomponent_get_next_property (comp_data->icalcomp, ICAL_DESCRIPTION_PROPERTY);
-
- icalcomponent_remove_property (comp_data->icalcomp, prop);
- icalproperty_free (prop);
-
- prop = next;
- }
-
- /* now add the new description */
- if (!value || !(*value))
- return;
-
- prop = icalproperty_new_description (value);
- icalcomponent_add_property (comp_data->icalcomp, prop);
-}
-
-static void
-datetime_to_zone (ECalClient *client,
- struct icaltimetype *tt,
- icaltimezone *tt_zone,
- const gchar *tzid)
-{
- icaltimezone *from, *to;
- const gchar *tt_tzid = NULL;
-
- g_return_if_fail (tt != NULL);
-
- if (tt_zone)
- tt_tzid = icaltimezone_get_tzid (tt_zone);
-
- if (tt_tzid == NULL || tzid == NULL ||
- tt_tzid == tzid || g_str_equal (tt_tzid, tzid))
- return;
-
- from = tt_zone;
- to = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!to) {
- /* do not check failure here, maybe the zone is not available there */
- e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL);
- }
-
- icaltimezone_convert_time (tt, from, to);
-}
-
/* updates time in a component, and keeps the timezone used in it, if exists */
void
e_cal_model_update_comp_time (ECalModel *model,
@@ -1669,96 +2106,6 @@ e_cal_model_update_comp_time (ECalModel *model,
}
}
-static void
-set_dtstart (ECalModel *model,
- ECalModelComponent *comp_data,
- gconstpointer value)
-{
- e_cal_model_update_comp_time (
- model, comp_data, value,
- ICAL_DTSTART_PROPERTY,
- icalproperty_set_dtstart,
- icalproperty_new_dtstart);
-}
-
-static void
-set_summary (ECalModelComponent *comp_data,
- const gchar *value)
-{
- icalproperty *prop;
-
- prop = icalcomponent_get_first_property (
- comp_data->icalcomp, ICAL_SUMMARY_PROPERTY);
-
- if (string_is_empty (value)) {
- if (prop) {
- icalcomponent_remove_property (comp_data->icalcomp, prop);
- icalproperty_free (prop);
- }
- } else {
- if (prop)
- icalproperty_set_summary (prop, value);
- else {
- prop = icalproperty_new_summary (value);
- icalcomponent_add_property (comp_data->icalcomp, prop);
- }
- }
-}
-
-static void
-ecm_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer value)
-{
- ECalModelPrivate *priv;
- ECalModelComponent *comp_data;
- ECalModel *model = (ECalModel *) etm;
- GError *error = NULL;
-
- g_return_if_fail (E_IS_CAL_MODEL (model));
-
- priv = model->priv;
-
- g_return_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST);
- g_return_if_fail (row >= 0 && row < priv->objects->len);
-
- comp_data = g_ptr_array_index (priv->objects, row);
- g_return_if_fail (comp_data != NULL);
-
- switch (col) {
- case E_CAL_MODEL_FIELD_CATEGORIES :
- set_categories (comp_data, value);
- break;
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- set_classification (comp_data, value);
- break;
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- set_description (comp_data, value);
- break;
- case E_CAL_MODEL_FIELD_DTSTART :
- set_dtstart (model, comp_data, value);
- break;
- case E_CAL_MODEL_FIELD_SUMMARY :
- set_summary (comp_data, value);
- break;
- }
-
- /* FIXME ask about mod type */
- e_cal_client_modify_object_sync (
- comp_data->client, comp_data->icalcomp,
- CALOBJ_MOD_ALL, NULL, &error);
-
- if (error != NULL) {
- g_warning (
- G_STRLOC ": Could not modify the object! %s",
- error->message);
-
- /* FIXME Show error dialog */
- g_error_free (error);
- }
-}
-
/**
* e_cal_model_test_row_editable
* @model: an #ECalModel
@@ -1799,369 +2146,6 @@ e_cal_model_test_row_editable (ECalModel *model,
return !readonly;
}
-static gboolean
-ecm_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
-{
- ECalModelPrivate *priv;
- ECalModel *model = (ECalModel *) etm;
-
- g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE);
-
- priv = model->priv;
-
- g_return_val_if_fail (col >= 0 && col <= E_CAL_MODEL_FIELD_LAST, FALSE);
- g_return_val_if_fail (row >= -1 || (row >= 0 && row < priv->objects->len), FALSE);
-
- if (!e_cal_model_test_row_editable (E_CAL_MODEL (etm), row))
- return FALSE;
-
- switch (col) {
- case E_CAL_MODEL_FIELD_CATEGORIES :
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- case E_CAL_MODEL_FIELD_DTSTART :
- case E_CAL_MODEL_FIELD_SUMMARY :
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-ecm_append_row (ETableModel *etm,
- ETableModel *source,
- gint row)
-{
- ECalModelClass *model_class;
- ECalModelComponent *comp_data;
- ECalModel *model = (ECalModel *) etm;
- gchar *uid = NULL;
- GError *error = NULL;
-
- g_return_if_fail (E_IS_CAL_MODEL (model));
- g_return_if_fail (E_IS_TABLE_MODEL (source));
-
- comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL);
-
- comp_data->client = e_cal_model_ref_default_client (model);
-
- if (comp_data->client == NULL) {
- g_object_unref (comp_data);
- return;
- }
-
- comp_data->icalcomp = e_cal_model_create_component_with_defaults (model, FALSE);
-
- /* set values for our fields */
- set_categories (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_CATEGORIES, row));
- set_classification (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_CLASSIFICATION, row));
- set_description (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_DESCRIPTION, row));
- set_summary (comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_SUMMARY, row));
-
- if (e_table_model_value_at (source, E_CAL_MODEL_FIELD_DTSTART, row)) {
- set_dtstart (model, comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_DTSTART, row));
- } else if (model->priv->get_default_time) {
- time_t tt = model->priv->get_default_time (model, model->priv->get_default_time_user_data);
-
- if (tt > 0) {
- struct icaltimetype itt = icaltime_from_timet_with_zone (tt, FALSE, e_cal_model_get_timezone (model));
- icalproperty *prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY);
-
- if (prop) {
- icalproperty_set_dtstart (prop, itt);
- } else {
- prop = icalproperty_new_dtstart (itt);
- icalcomponent_add_property (comp_data->icalcomp, prop);
- }
- }
- }
-
- /* call the class' method for filling the component */
- model_class = (ECalModelClass *) G_OBJECT_GET_CLASS (model);
- if (model_class->fill_component_from_model != NULL) {
- model_class->fill_component_from_model (model, comp_data, source, row);
- }
-
- e_cal_client_create_object_sync (
- comp_data->client, comp_data->icalcomp, &uid, NULL, &error);
-
- if (error != NULL) {
- g_warning (
- G_STRLOC ": Could not create the object! %s",
- error->message);
-
- /* FIXME: show error dialog */
- g_error_free (error);
- } else {
- if (uid)
- icalcomponent_set_uid (comp_data->icalcomp, uid);
-
- g_signal_emit (model, signals[ROW_APPENDED], 0);
- }
-
- g_free (uid);
- g_object_unref (comp_data);
-}
-
-static gpointer
-ecm_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
-{
- g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, NULL);
-
- switch (col) {
- case E_CAL_MODEL_FIELD_CATEGORIES :
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- case E_CAL_MODEL_FIELD_SUMMARY :
- return g_strdup (value);
- case E_CAL_MODEL_FIELD_HAS_ALARMS :
- case E_CAL_MODEL_FIELD_ICON :
- case E_CAL_MODEL_FIELD_COLOR :
- return (gpointer) value;
- case E_CAL_MODEL_FIELD_COMPONENT :
- return icalcomponent_new_clone ((icalcomponent *) value);
- case E_CAL_MODEL_FIELD_DTSTART :
- case E_CAL_MODEL_FIELD_CREATED :
- case E_CAL_MODEL_FIELD_LASTMODIFIED :
- if (value) {
- ECellDateEditValue *dv, *orig_dv;
-
- orig_dv = (ECellDateEditValue *) value;
- dv = g_new0 (ECellDateEditValue, 1);
- *dv = *orig_dv;
-
- return dv;
- }
- break;
- }
-
- return NULL;
-}
-
-static void
-ecm_free_value (ETableModel *etm,
- gint col,
- gpointer value)
-{
- g_return_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST);
-
- switch (col) {
- case E_CAL_MODEL_FIELD_CATEGORIES :
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- case E_CAL_MODEL_FIELD_SUMMARY :
- if (value)
- g_free (value);
- break;
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- case E_CAL_MODEL_FIELD_HAS_ALARMS :
- case E_CAL_MODEL_FIELD_ICON :
- case E_CAL_MODEL_FIELD_COLOR :
- break;
- case E_CAL_MODEL_FIELD_DTSTART :
- case E_CAL_MODEL_FIELD_CREATED :
- case E_CAL_MODEL_FIELD_LASTMODIFIED :
- if (value)
- g_free (value);
- break;
- case E_CAL_MODEL_FIELD_COMPONENT :
- if (value)
- icalcomponent_free ((icalcomponent *) value);
- break;
- }
-}
-
-static gpointer
-ecm_initialize_value (ETableModel *etm,
- gint col)
-{
- ECalModelPrivate *priv;
- ECalModel *model = (ECalModel *) etm;
-
- g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, NULL);
-
- priv = model->priv;
-
- switch (col) {
- case E_CAL_MODEL_FIELD_CATEGORIES :
- return g_strdup (priv->default_category ? priv->default_category:"");
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- case E_CAL_MODEL_FIELD_SUMMARY :
- return g_strdup ("");
- case E_CAL_MODEL_FIELD_DTSTART :
- case E_CAL_MODEL_FIELD_CREATED :
- case E_CAL_MODEL_FIELD_LASTMODIFIED :
- case E_CAL_MODEL_FIELD_HAS_ALARMS :
- case E_CAL_MODEL_FIELD_ICON :
- case E_CAL_MODEL_FIELD_COLOR :
- case E_CAL_MODEL_FIELD_COMPONENT :
- return NULL;
- }
-
- return NULL;
-}
-
-static gboolean
-ecm_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
-{
- ECalModelPrivate *priv;
- ECalModel *model = (ECalModel *) etm;
-
- g_return_val_if_fail (E_IS_CAL_MODEL (model), TRUE);
- g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, TRUE);
-
- priv = model->priv;
-
- switch (col) {
- case E_CAL_MODEL_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
- * ecm_initialize_value().
- */
- if (priv->default_category && value && strcmp (priv->default_category, value) == 0)
- return TRUE;
- else
- return string_is_empty (value);
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- case E_CAL_MODEL_FIELD_SUMMARY :
- return string_is_empty (value);
- case E_CAL_MODEL_FIELD_DTSTART :
- case E_CAL_MODEL_FIELD_CREATED :
- case E_CAL_MODEL_FIELD_LASTMODIFIED :
- return value ? FALSE : TRUE;
- case E_CAL_MODEL_FIELD_HAS_ALARMS :
- case E_CAL_MODEL_FIELD_ICON :
- case E_CAL_MODEL_FIELD_COLOR :
- case E_CAL_MODEL_FIELD_COMPONENT :
- return TRUE;
- }
-
- return TRUE;
-}
-
-static gchar *
-ecm_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
-{
- g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_FIELD_LAST, g_strdup (""));
-
- switch (col) {
- case E_CAL_MODEL_FIELD_CATEGORIES :
- case E_CAL_MODEL_FIELD_CLASSIFICATION :
- case E_CAL_MODEL_FIELD_DESCRIPTION :
- case E_CAL_MODEL_FIELD_SUMMARY :
- return g_strdup (value);
- case E_CAL_MODEL_FIELD_DTSTART :
- case E_CAL_MODEL_FIELD_CREATED :
- case E_CAL_MODEL_FIELD_LASTMODIFIED :
- return e_cal_model_date_value_to_string (E_CAL_MODEL (etm), value);
- case E_CAL_MODEL_FIELD_ICON :
- if (GPOINTER_TO_INT (value) == 0)
- return g_strdup (_("Normal"));
- else if (GPOINTER_TO_INT (value) == 1)
- return g_strdup (_("Recurring"));
- else
- return g_strdup (_("Assigned"));
- case E_CAL_MODEL_FIELD_HAS_ALARMS :
- return g_strdup (value ? _("Yes") : _("No"));
- case E_CAL_MODEL_FIELD_COLOR :
- case E_CAL_MODEL_FIELD_COMPONENT :
- return g_strdup ("");
- }
-
- return g_strdup ("");
-}
-
-/* ECalModel class methods */
-
-typedef struct {
- const gchar *color;
- GList *uids;
-} AssignedColorData;
-
-static const gchar *
-ecm_get_color_for_component (ECalModel *model,
- ECalModelComponent *comp_data)
-{
- ESource *source;
- ESourceSelectable *extension;
- const gchar *color_spec;
- const gchar *extension_name;
- const gchar *uid;
- gint i, first_empty = 0;
-
- static AssignedColorData assigned_colors[] = {
- { "#BECEDD", NULL }, /* 190 206 221 Blue */
- { "#E2F0EF", NULL }, /* 226 240 239 Light Blue */
- { "#C6E2B7", NULL }, /* 198 226 183 Green */
- { "#E2F0D3", NULL }, /* 226 240 211 Light Green */
- { "#E2D4B7", NULL }, /* 226 212 183 Khaki */
- { "#EAEAC1", NULL }, /* 234 234 193 Light Khaki */
- { "#F0B8B7", NULL }, /* 240 184 183 Pink */
- { "#FED4D3", NULL }, /* 254 212 211 Light Pink */
- { "#E2C6E1", NULL }, /* 226 198 225 Purple */
- { "#F0E2EF", NULL } /* 240 226 239 Light Purple */
- };
-
- g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
-
- switch (e_cal_client_get_source_type (comp_data->client)) {
- case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- extension_name = E_SOURCE_EXTENSION_CALENDAR;
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- extension_name = E_SOURCE_EXTENSION_TASK_LIST;
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
- break;
- default:
- g_return_val_if_reached (NULL);
- }
-
- source = e_client_get_source (E_CLIENT (comp_data->client));
- extension = e_source_get_extension (source, extension_name);
- color_spec = e_source_selectable_get_color (extension);
-
- if (color_spec != NULL) {
- g_free (comp_data->color);
- comp_data->color = g_strdup (color_spec);
- return comp_data->color;
- }
-
- uid = e_source_get_uid (source);
-
- for (i = 0; i < G_N_ELEMENTS (assigned_colors); i++) {
- GList *l;
-
- if (assigned_colors[i].uids == NULL) {
- first_empty = i;
- continue;
- }
-
- for (l = assigned_colors[i].uids; l != NULL; l = l->next)
- if (g_strcmp0 (l->data, uid) == 0)
- return assigned_colors[i].color;
- }
-
- /* return the first unused color */
- assigned_colors[first_empty].uids = g_list_append (
- assigned_colors[first_empty].uids, g_strdup (uid));
-
- return assigned_colors[first_empty].color;
-}
-
gboolean
e_cal_model_get_confirm_delete (ECalModel *model)
{
@@ -4045,7 +4029,7 @@ e_cal_model_get_color_for_component (ECalModel *model,
color = model_class->get_color_for_component (model, comp_data);
if (!color)
- color = ecm_get_color_for_component (model, comp_data);
+ color = cal_model_get_color_for_component (model, comp_data);
return color;
}
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt b/doc/reference/evolution-util/evolution-util-sections.txt
index 9a0753b55b..f8f0482e8f 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -3973,6 +3973,7 @@ e_table_state_get_type
ETableSubset
e_table_subset_new
e_table_subset_construct
+e_table_subset_get_source_model
e_table_subset_model_to_view_row
e_table_subset_view_to_model_row
e_table_subset_get_toplevel
diff --git a/e-util/e-table-click-to-add.c b/e-util/e-table-click-to-add.c
index 6de00f913b..8d80e197f4 100644
--- a/e-util/e-table-click-to-add.c
+++ b/e-util/e-table-click-to-add.c
@@ -49,9 +49,10 @@ enum {
static guint etcta_signals[LAST_SIGNAL] = { 0 };
-/* workaround for avoiding APi breakage */
-#define etcta_get_type e_table_click_to_add_get_type
-G_DEFINE_TYPE (ETableClickToAdd, etcta, GNOME_TYPE_CANVAS_GROUP)
+G_DEFINE_TYPE (
+ ETableClickToAdd,
+ e_table_click_to_add,
+ GNOME_TYPE_CANVAS_GROUP)
enum {
PROP_0,
@@ -199,7 +200,7 @@ etcta_dispose (GObject *object)
etcta->selection = NULL;
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (etcta_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_click_to_add_parent_class)->dispose (object);
}
static void
@@ -324,8 +325,8 @@ etcta_realize (GnomeCanvasItem *item)
create_rect_and_text (etcta);
e_canvas_item_move_absolute (etcta->text, 2, 2);
- if (GNOME_CANVAS_ITEM_CLASS (etcta_parent_class)->realize)
- (*GNOME_CANVAS_ITEM_CLASS (etcta_parent_class)->realize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_click_to_add_parent_class)->realize)
+ (*GNOME_CANVAS_ITEM_CLASS (e_table_click_to_add_parent_class)->realize)(item);
e_canvas_item_request_reflow (item);
}
@@ -333,8 +334,8 @@ etcta_realize (GnomeCanvasItem *item)
static void
etcta_unrealize (GnomeCanvasItem *item)
{
- if (GNOME_CANVAS_ITEM_CLASS (etcta_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (etcta_parent_class)->unrealize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_click_to_add_parent_class)->unrealize)
+ (*GNOME_CANVAS_ITEM_CLASS (e_table_click_to_add_parent_class)->unrealize)(item);
}
static void finish_editing (ETableClickToAdd *etcta);
@@ -519,7 +520,7 @@ etcta_reflow (GnomeCanvasItem *item,
}
static void
-etcta_class_init (ETableClickToAddClass *class)
+e_table_click_to_add_class_init (ETableClickToAddClass *class)
{
GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -612,7 +613,7 @@ etcta_class_init (ETableClickToAddClass *class)
}
static void
-etcta_init (ETableClickToAdd *etcta)
+e_table_click_to_add_init (ETableClickToAdd *etcta)
{
AtkObject *a11y;
diff --git a/e-util/e-table-column-specification.c b/e-util/e-table-column-specification.c
index d1cf089d2d..32c16a5553 100644
--- a/e-util/e-table-column-specification.c
+++ b/e-util/e-table-column-specification.c
@@ -35,9 +35,10 @@
#include "e-xml-utils.h"
-/* workaround for avoiding API breakage */
-#define etcs_get_type e_table_column_specification_get_type
-G_DEFINE_TYPE (ETableColumnSpecification, etcs, G_TYPE_OBJECT)
+G_DEFINE_TYPE (
+ ETableColumnSpecification,
+ e_table_column_specification,
+ G_TYPE_OBJECT)
static void
free_strings (ETableColumnSpecification *etcs)
@@ -63,11 +64,11 @@ etcs_finalize (GObject *object)
free_strings (etcs);
- G_OBJECT_CLASS (etcs_parent_class)->finalize (object);
+ G_OBJECT_CLASS (e_table_column_specification_parent_class)->finalize (object);
}
static void
-etcs_class_init (ETableColumnSpecificationClass *class)
+e_table_column_specification_class_init (ETableColumnSpecificationClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -75,7 +76,7 @@ etcs_class_init (ETableColumnSpecificationClass *class)
}
static void
-etcs_init (ETableColumnSpecification *specification)
+e_table_column_specification_init (ETableColumnSpecification *specification)
{
specification->model_col = 0;
specification->compare_col = 0;
diff --git a/e-util/e-table-config.c b/e-util/e-table-config.c
index 98f89ffd10..1c7f5563d5 100644
--- a/e-util/e-table-config.c
+++ b/e-util/e-table-config.c
@@ -788,7 +788,8 @@ get_source_model_col_index (ETableConfig *config,
gint visible_index;
ETableModel *src_model;
- src_model = E_TABLE_SUBSET (config->available_model)->source;
+ src_model = e_table_subset_get_source_model (
+ E_TABLE_SUBSET (config->available_model));
visible_index = e_table_subset_view_to_model_row (
E_TABLE_SUBSET (config->available_model), idx);
diff --git a/e-util/e-table-extras.c b/e-util/e-table-extras.c
index 1820f35451..35658fd0cc 100644
--- a/e-util/e-table-extras.c
+++ b/e-util/e-table-extras.c
@@ -52,9 +52,10 @@ struct _ETableExtrasPrivate {
GHashTable *searches;
};
-/* workaround for avoiding API breakage */
-#define ete_get_type e_table_extras_get_type
-G_DEFINE_TYPE (ETableExtras, ete, G_TYPE_OBJECT)
+G_DEFINE_TYPE (
+ ETableExtras,
+ e_table_extras,
+ G_TYPE_OBJECT)
static void
ete_finalize (GObject *object)
@@ -83,11 +84,11 @@ ete_finalize (GObject *object)
priv->icon_names = NULL;
}
- G_OBJECT_CLASS (ete_parent_class)->finalize (object);
+ G_OBJECT_CLASS (e_table_extras_parent_class)->finalize (object);
}
static void
-ete_class_init (ETableExtrasClass *class)
+e_table_extras_class_init (ETableExtrasClass *class)
{
GObjectClass *object_class;
@@ -235,7 +236,7 @@ safe_unref (gpointer object)
}
static void
-ete_init (ETableExtras *extras)
+e_table_extras_init (ETableExtras *extras)
{
ECell *cell, *sub_cell;
diff --git a/e-util/e-table-field-chooser-item.c b/e-util/e-table-field-chooser-item.c
index c7335f8a5c..f4a85d6b83 100644
--- a/e-util/e-table-field-chooser-item.c
+++ b/e-util/e-table-field-chooser-item.c
@@ -50,9 +50,10 @@ enum {
static guint etfci_signals[LAST_SIGNAL] = { 0, };
#endif
-/* workaround for avoiding API breakage */
-#define etfci_get_type e_table_field_chooser_item_get_type
-G_DEFINE_TYPE (ETableFieldChooserItem, etfci, GNOME_TYPE_CANVAS_ITEM)
+G_DEFINE_TYPE (
+ ETableFieldChooserItem,
+ e_table_field_chooser_item,
+ GNOME_TYPE_CANVAS_ITEM)
static void etfci_drop_table_header (ETableFieldChooserItem *etfci);
static void etfci_drop_full_header (ETableFieldChooserItem *etfci);
@@ -83,7 +84,7 @@ etfci_dispose (GObject *object)
etfci->font_desc = NULL;
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (etfci_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_field_chooser_item_parent_class)->dispose (object);
}
static gint
@@ -191,8 +192,8 @@ etfci_update (GnomeCanvasItem *item,
ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
gdouble x1, y1, x2, y2;
- if (GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->update)
- GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->update (
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)->update)
+ GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)->update (
item, i2c, flags);
x1 = y1 = 0;
@@ -450,8 +451,8 @@ etfci_realize (GnomeCanvasItem *item)
{
ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
- if (GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)-> realize)
- (*GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->realize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)-> realize)
+ (*GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)->realize)(item);
if (!etfci->font_desc)
etfci_font_load (etfci);
@@ -479,8 +480,8 @@ etfci_unrealize (GnomeCanvasItem *item)
g_signal_handler_disconnect (item->canvas, etfci->drag_data_get_id);
etfci->drag_data_get_id = 0;
- if (GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->unrealize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)->unrealize)
+ (*GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)->unrealize)(item);
}
static void
@@ -660,7 +661,7 @@ etfci_event (GnomeCanvasItem *item,
}
static void
-etfci_class_init (ETableFieldChooserItemClass *class)
+e_table_field_chooser_item_class_init (ETableFieldChooserItemClass *class)
{
GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -728,7 +729,7 @@ etfci_class_init (ETableFieldChooserItemClass *class)
}
static void
-etfci_init (ETableFieldChooserItem *etfci)
+e_table_field_chooser_item_init (ETableFieldChooserItem *etfci)
{
etfci->full_header = NULL;
etfci->header = NULL;
diff --git a/e-util/e-table-field-chooser.c b/e-util/e-table-field-chooser.c
index dd8a171f9d..85069b6317 100644
--- a/e-util/e-table-field-chooser.c
+++ b/e-util/e-table-field-chooser.c
@@ -45,7 +45,10 @@ enum {
PROP_DND_CODE
};
-G_DEFINE_TYPE (ETableFieldChooser, e_table_field_chooser, GTK_TYPE_VBOX)
+G_DEFINE_TYPE (
+ ETableFieldChooser,
+ e_table_field_chooser,
+ GTK_TYPE_VBOX)
static void
e_table_field_chooser_class_init (ETableFieldChooserClass *class)
diff --git a/e-util/e-table-group-container.c b/e-util/e-table-group-container.c
index 5741cd1093..72fee11c26 100644
--- a/e-util/e-table-group-container.c
+++ b/e-util/e-table-group-container.c
@@ -42,9 +42,10 @@
#define TITLE_HEIGHT 16
-/* workaround for avoiding API breakage */
-#define etgc_get_type e_table_group_container_get_type
-G_DEFINE_TYPE (ETableGroupContainer, etgc, E_TYPE_TABLE_GROUP)
+G_DEFINE_TYPE (
+ ETableGroupContainer,
+ e_table_group_container,
+ E_TYPE_TABLE_GROUP)
enum {
PROP_0,
@@ -124,7 +125,7 @@ etgc_dispose (GObject *object)
g_object_run_dispose (G_OBJECT (etgc->rect));
etgc->rect = NULL;
- G_OBJECT_CLASS (etgc_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_group_container_parent_class)->dispose (object);
}
/**
@@ -315,8 +316,8 @@ etgc_event (GnomeCanvasItem *item,
break;
}
if (return_val == FALSE) {
- if (GNOME_CANVAS_ITEM_CLASS (etgc_parent_class)->event)
- return GNOME_CANVAS_ITEM_CLASS (etgc_parent_class)->event (item, event);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_group_container_parent_class)->event)
+ return GNOME_CANVAS_ITEM_CLASS (e_table_group_container_parent_class)->event (item, event);
}
return return_val;
@@ -328,8 +329,8 @@ etgc_realize (GnomeCanvasItem *item)
{
ETableGroupContainer *etgc;
- if (GNOME_CANVAS_ITEM_CLASS (etgc_parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS (etgc_parent_class)->realize) (item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_group_container_parent_class)->realize)
+ (* GNOME_CANVAS_ITEM_CLASS (e_table_group_container_parent_class)->realize) (item);
etgc = E_TABLE_GROUP_CONTAINER (item);
@@ -340,8 +341,8 @@ etgc_realize (GnomeCanvasItem *item)
static void
etgc_unrealize (GnomeCanvasItem *item)
{
- if (GNOME_CANVAS_ITEM_CLASS (etgc_parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS (etgc_parent_class)->unrealize) (item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_group_container_parent_class)->unrealize)
+ (* GNOME_CANVAS_ITEM_CLASS (e_table_group_container_parent_class)->unrealize) (item);
}
static void
@@ -998,7 +999,7 @@ etgc_get_property (GObject *object,
}
static void
-etgc_class_init (ETableGroupContainerClass *class)
+e_table_group_container_class_init (ETableGroupContainerClass *class)
{
GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -1247,7 +1248,7 @@ etgc_reflow (GnomeCanvasItem *item,
}
static void
-etgc_init (ETableGroupContainer *container)
+e_table_group_container_init (ETableGroupContainer *container)
{
container->children = NULL;
diff --git a/e-util/e-table-group-leaf.c b/e-util/e-table-group-leaf.c
index 8d1a91da69..027ba299ec 100644
--- a/e-util/e-table-group-leaf.c
+++ b/e-util/e-table-group-leaf.c
@@ -37,9 +37,10 @@
#include "e-table-sorted.h"
#include "e-table-sorted-variable.h"
-/* workaround for avoiding APi breakage */
-#define etgl_get_type e_table_group_leaf_get_type
-G_DEFINE_TYPE (ETableGroupLeaf, etgl, E_TYPE_TABLE_GROUP)
+G_DEFINE_TYPE (
+ ETableGroupLeaf,
+ e_table_group_leaf,
+ E_TYPE_TABLE_GROUP)
enum {
PROP_0,
@@ -115,7 +116,7 @@ etgl_dispose (GObject *object)
}
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (etgl_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_group_leaf_parent_class)->dispose (object);
}
static void
@@ -130,13 +131,11 @@ e_table_group_leaf_construct (GnomeCanvasGroup *parent,
(e_table_sort_info_grouping_get_count (sort_info) > 0);
if (etgl->is_grouped)
- etgl->ets = E_TABLE_SUBSET (
- e_table_sorted_variable_new (
- model, full_header, sort_info));
+ etgl->ets = e_table_sorted_variable_new (
+ model, full_header, sort_info);
else
- etgl->ets = E_TABLE_SUBSET (
- e_table_sorted_new (
- model, full_header, sort_info));
+ etgl->ets = e_table_sorted_new (
+ model, full_header, sort_info);
e_table_group_construct (
parent, E_TABLE_GROUP (etgl), full_header, header, model);
@@ -177,13 +176,19 @@ e_table_group_leaf_new (GnomeCanvasGroup *parent,
static void
etgl_cursor_change (GObject *object,
- gint row,
+ gint view_row,
ETableGroupLeaf *etgl)
{
- if (row < E_TABLE_SUBSET (etgl->ets)->n_map)
- e_table_group_cursor_change (
- E_TABLE_GROUP (etgl),
- E_TABLE_SUBSET (etgl->ets)->map_table[row]);
+ ETableSubset *table_subset;
+ gint model_row;
+
+ table_subset = E_TABLE_SUBSET (etgl->ets);
+ model_row = e_table_subset_view_to_model_row (table_subset, view_row);
+
+ if (model_row < 0)
+ return;
+
+ e_table_group_cursor_change (E_TABLE_GROUP (etgl), model_row);
}
static void
@@ -191,10 +196,16 @@ etgl_cursor_activated (GObject *object,
gint view_row,
ETableGroupLeaf *etgl)
{
- if (view_row < E_TABLE_SUBSET (etgl->ets)->n_map)
- e_table_group_cursor_activated (
- E_TABLE_GROUP (etgl),
- E_TABLE_SUBSET (etgl->ets)->map_table[view_row]);
+ ETableSubset *table_subset;
+ gint model_row;
+
+ table_subset = E_TABLE_SUBSET (etgl->ets);
+ model_row = e_table_subset_view_to_model_row (table_subset, view_row);
+
+ if (model_row < 0)
+ return;
+
+ e_table_group_cursor_activated (E_TABLE_GROUP (etgl), model_row);
}
static void
@@ -215,13 +226,17 @@ etgl_key_press (GObject *object,
GdkEvent *event,
ETableGroupLeaf *etgl)
{
- if (row < E_TABLE_SUBSET (etgl->ets)->n_map && row >= 0)
- return e_table_group_key_press (
- E_TABLE_GROUP (etgl),
- E_TABLE_SUBSET (etgl->ets)->map_table[row],
- col, event);
- else
+ ETableSubset *table_subset;
+ gint model_row;
+
+ table_subset = E_TABLE_SUBSET (etgl->ets);
+ model_row = e_table_subset_view_to_model_row (table_subset, row);
+
+ if (model_row < 0)
return FALSE;
+
+ return e_table_group_key_press (
+ E_TABLE_GROUP (etgl), model_row, col, event);
}
static gboolean
@@ -242,13 +257,17 @@ etgl_right_click (GObject *object,
GdkEvent *event,
ETableGroupLeaf *etgl)
{
- if (view_row < E_TABLE_SUBSET (etgl->ets)->n_map)
- return e_table_group_right_click (
- E_TABLE_GROUP (etgl),
- E_TABLE_SUBSET (etgl->ets)->map_table[view_row],
- model_col, event);
- else
+ ETableSubset *table_subset;
+ gint model_row;
+
+ table_subset = E_TABLE_SUBSET (etgl->ets);
+ model_row = e_table_subset_view_to_model_row (table_subset, view_row);
+
+ if (model_row < 0)
return FALSE;
+
+ return e_table_group_right_click (
+ E_TABLE_GROUP (etgl), model_row, model_col, event);
}
static gboolean
@@ -258,13 +277,17 @@ etgl_click (GObject *object,
GdkEvent *event,
ETableGroupLeaf *etgl)
{
- if (row < E_TABLE_SUBSET (etgl->ets)->n_map)
- return e_table_group_click (
- E_TABLE_GROUP (etgl),
- E_TABLE_SUBSET (etgl->ets)->map_table[row],
- col, event);
- else
+ ETableSubset *table_subset;
+ gint model_row;
+
+ table_subset = E_TABLE_SUBSET (etgl->ets);
+ model_row = e_table_subset_view_to_model_row (table_subset, row);
+
+ if (model_row < 0)
return FALSE;
+
+ return e_table_group_click (
+ E_TABLE_GROUP (etgl), model_row, col, event);
}
static void
@@ -284,8 +307,8 @@ etgl_realize (GnomeCanvasItem *item)
{
ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (item);
- if (GNOME_CANVAS_ITEM_CLASS (etgl_parent_class)->realize)
- GNOME_CANVAS_ITEM_CLASS (etgl_parent_class)->realize (item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_group_leaf_parent_class)->realize)
+ GNOME_CANVAS_ITEM_CLASS (e_table_group_leaf_parent_class)->realize (item);
etgl->item = E_TABLE_ITEM (gnome_canvas_item_new (
GNOME_CANVAS_GROUP (etgl),
@@ -634,7 +657,7 @@ etgl_get_property (GObject *object,
}
static void
-etgl_class_init (ETableGroupLeafClass *class)
+e_table_group_leaf_class_init (ETableGroupLeafClass *class)
{
GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class);
ETableGroupClass *e_group_class = E_TABLE_GROUP_CLASS (class);
@@ -784,7 +807,7 @@ etgl_class_init (ETableGroupLeafClass *class)
}
static void
-etgl_init (ETableGroupLeaf *etgl)
+e_table_group_leaf_init (ETableGroupLeaf *etgl)
{
etgl->width = 1;
etgl->height = 1;
diff --git a/e-util/e-table-group-leaf.h b/e-util/e-table-group-leaf.h
index 93aa2bf2da..8c47e2e52e 100644
--- a/e-util/e-table-group-leaf.h
+++ b/e-util/e-table-group-leaf.h
@@ -72,7 +72,7 @@ struct _ETableGroupLeaf {
gint length_threshold;
- ETableSubset *ets;
+ ETableModel *ets;
guint is_grouped : 1;
guint alternating_row_colors : 1;
diff --git a/e-util/e-table-group.c b/e-util/e-table-group.c
index b5671d90f8..a4a23bef67 100644
--- a/e-util/e-table-group.c
+++ b/e-util/e-table-group.c
@@ -32,9 +32,10 @@
#include "e-table-group-leaf.h"
#include "e-table-item.h"
-/* workaround for avoiding API breakage*/
-#define etg_get_type e_table_group_get_type
-G_DEFINE_TYPE (ETableGroup, etg, GNOME_TYPE_CANVAS_GROUP)
+G_DEFINE_TYPE (
+ ETableGroup,
+ e_table_group,
+ GNOME_TYPE_CANVAS_GROUP)
#define ETG_CLASS(e) (E_TABLE_GROUP_CLASS(G_OBJECT_GET_CLASS(e)))
@@ -74,7 +75,7 @@ etg_dispose (GObject *object)
}
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (etg_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_group_parent_class)->dispose (object);
}
/**
@@ -619,8 +620,8 @@ etg_event (GnomeCanvasItem *item,
return_val = FALSE;
}
if (return_val == FALSE) {
- if (GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->event)
- return GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->event (item, event);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_group_parent_class)->event)
+ return GNOME_CANVAS_ITEM_CLASS (e_table_group_parent_class)->event (item, event);
}
return return_val;
@@ -633,7 +634,7 @@ etg_get_focus (ETableGroup *table_group)
}
static void
-etg_class_init (ETableGroupClass *class)
+e_table_group_class_init (ETableGroupClass *class)
{
GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -746,7 +747,7 @@ etg_class_init (ETableGroupClass *class)
}
static void
-etg_init (ETableGroup *table_group)
+e_table_group_init (ETableGroup *table_group)
{
/* nothing to do */
}
diff --git a/e-util/e-table-item.c b/e-util/e-table-item.c
index de749ead68..289d26d973 100644
--- a/e-util/e-table-item.c
+++ b/e-util/e-table-item.c
@@ -49,9 +49,10 @@
#include "gal-a11y-e-table-item-factory.h"
#include "gal-a11y-e-table-item.h"
-/* workaround for avoiding API breakage */
-#define eti_get_type e_table_item_get_type
-G_DEFINE_TYPE (ETableItem, eti, GNOME_TYPE_CANVAS_ITEM)
+G_DEFINE_TYPE (
+ ETableItem,
+ e_table_item,
+ GNOME_TYPE_CANVAS_ITEM)
#define FOCUSED_BORDER 2
@@ -168,21 +169,18 @@ inline static gint
model_to_view_row (ETableItem *eti,
gint row)
{
- gint i;
if (row == -1)
return -1;
if (eti->uses_source_model) {
- ETableSubset *etss = E_TABLE_SUBSET (eti->table_model);
- if (eti->row_guess >= 0 && eti->row_guess < etss->n_map) {
- if (etss->map_table[eti->row_guess] == row) {
- return eti->row_guess;
- }
- }
- for (i = 0; i < etss->n_map; i++) {
- if (etss->map_table[i] == row)
- return i;
- }
- return -1;
+ gint model_row;
+
+ model_row = e_table_subset_view_to_model_row (
+ E_TABLE_SUBSET (eti->table_model), eti->row_guess);
+ if (model_row >= 0 && model_row == row)
+ return eti->row_guess;
+
+ return e_table_subset_model_to_view_row (
+ E_TABLE_SUBSET (eti->table_model), row);
} else
return row;
}
@@ -192,12 +190,15 @@ view_to_model_row (ETableItem *eti,
gint row)
{
if (eti->uses_source_model) {
- ETableSubset *etss = E_TABLE_SUBSET (eti->table_model);
- if (row >= 0 && row < etss->n_map) {
+ gint model_row;
+
+ model_row = e_table_subset_view_to_model_row (
+ E_TABLE_SUBSET (eti->table_model), row);
+
+ if (model_row >= 0)
eti->row_guess = row;
- return etss->map_table[row];
- } else
- return -1;
+
+ return model_row;
} else
return row;
}
@@ -559,8 +560,8 @@ eti_update (GnomeCanvasItem *item,
ETableItem *eti = E_TABLE_ITEM (item);
gdouble x1, x2, y1, y2;
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, i2c, flags);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_item_parent_class)->update)
+ (*GNOME_CANVAS_ITEM_CLASS (e_table_item_parent_class)->update)(item, i2c, flags);
x1 = item->x1;
y1 = item->y1;
@@ -1432,7 +1433,8 @@ eti_add_table_model (ETableItem *eti,
if (E_IS_TABLE_SUBSET (table_model)) {
eti->uses_source_model = 1;
- eti->source_model = E_TABLE_SUBSET (table_model)->source;
+ eti->source_model = e_table_subset_get_source_model (
+ E_TABLE_SUBSET (table_model));
if (eti->source_model)
g_object_ref (eti->source_model);
}
@@ -1576,7 +1578,7 @@ eti_dispose (GObject *object)
eti->height_cache = NULL;
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (eti_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_item_parent_class)->dispose (object);
}
static void
@@ -1704,7 +1706,7 @@ eti_get_property (GObject *object,
}
static void
-eti_init (ETableItem *eti)
+e_table_item_init (ETableItem *eti)
{
eti->motion_row = -1;
eti->motion_col = -1;
@@ -1795,8 +1797,8 @@ eti_realize (GnomeCanvasItem *item)
{
ETableItem *eti = E_TABLE_ITEM (item);
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_item_parent_class)->realize)
+ (*GNOME_CANVAS_ITEM_CLASS (e_table_item_parent_class)->realize)(item);
eti->rows = e_table_model_row_count (eti->table_model);
@@ -1857,8 +1859,8 @@ eti_unrealize (GnomeCanvasItem *item)
eti->height = 0;
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (e_table_item_parent_class)->unrealize)
+ (*GNOME_CANVAS_ITEM_CLASS (e_table_item_parent_class)->unrealize)(item);
}
static void
@@ -3104,7 +3106,7 @@ eti_style_set (ETableItem *eti,
}
static void
-eti_class_init (ETableItemClass *class)
+e_table_item_class_init (ETableItemClass *class)
{
GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
diff --git a/e-util/e-table-memory-store.c b/e-util/e-table-memory-store.c
index 51d8a3c107..6432cc3c5b 100644
--- a/e-util/e-table-memory-store.c
+++ b/e-util/e-table-memory-store.c
@@ -20,10 +20,6 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <string.h>
#include "e-table-memory-store.h"
@@ -40,7 +36,10 @@ struct _ETableMemoryStorePrivate {
gpointer *store;
};
-G_DEFINE_TYPE (ETableMemoryStore, e_table_memory_store, E_TYPE_TABLE_MEMORY)
+G_DEFINE_TYPE (
+ ETableMemoryStore,
+ e_table_memory_store,
+ E_TYPE_TABLE_MEMORY)
static gpointer
duplicate_value (ETableMemoryStore *etms,
@@ -78,18 +77,55 @@ free_value (ETableMemoryStore *etms,
}
}
+static void
+table_memory_store_finalize (GObject *object)
+{
+ ETableMemoryStorePrivate *priv;
+
+ priv = E_TABLE_MEMORY_STORE_GET_PRIVATE (object);
+
+ e_table_memory_store_clear (E_TABLE_MEMORY_STORE (object));
+
+ g_free (priv->columns);
+ g_free (priv->store);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_table_memory_store_parent_class)->finalize (object);
+}
+
static gint
-etms_column_count (ETableModel *etm)
+table_memory_store_column_count (ETableModel *etm)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
return etms->priv->col_count;
}
+static void
+table_memory_store_append_row (ETableModel *etm,
+ ETableModel *source,
+ gint row)
+{
+ ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
+ gpointer *new_data;
+ gint i;
+ gint row_count;
+
+ new_data = g_new (gpointer , etms->priv->col_count);
+
+ for (i = 0; i < etms->priv->col_count; i++) {
+ new_data[i] = e_table_model_value_at (source, i, row);
+ }
+
+ row_count = e_table_model_row_count (E_TABLE_MODEL (etms));
+
+ e_table_memory_store_insert_array (etms, row_count, new_data, NULL);
+}
+
static gpointer
-etms_value_at (ETableModel *etm,
- gint col,
- gint row)
+table_memory_store_value_at (ETableModel *etm,
+ gint col,
+ gint row)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
@@ -97,10 +133,10 @@ etms_value_at (ETableModel *etm,
}
static void
-etms_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer val)
+table_memory_store_set_value_at (ETableModel *etm,
+ gint col,
+ gint row,
+ gconstpointer val)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
@@ -112,20 +148,20 @@ etms_set_value_at (ETableModel *etm,
}
static gboolean
-etms_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
+table_memory_store_is_cell_editable (ETableModel *etm,
+ gint col,
+ gint row)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
return etms->priv->columns[col].editable;
}
-/* The default for etms_duplicate_value is to return the raw value. */
+/* The default for duplicate_value() is to return the raw value. */
static gpointer
-etms_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_memory_store_duplicate_value (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
@@ -133,9 +169,9 @@ etms_duplicate_value (ETableModel *etm,
}
static void
-etms_free_value (ETableModel *etm,
- gint col,
- gpointer value)
+table_memory_store_free_value (ETableModel *etm,
+ gint col,
+ gpointer value)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
@@ -143,102 +179,59 @@ etms_free_value (ETableModel *etm,
}
static gpointer
-etms_initialize_value (ETableModel *etm,
- gint col)
+table_memory_store_initialize_value (ETableModel *etm,
+ gint col)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
switch (etms->priv->columns[col].type) {
- case E_TABLE_MEMORY_STORE_COLUMN_TYPE_STRING:
- return g_strdup ("");
- case E_TABLE_MEMORY_STORE_COLUMN_TYPE_PIXBUF:
- return NULL;
- default:
- break;
+ case E_TABLE_MEMORY_STORE_COLUMN_TYPE_STRING:
+ return g_strdup ("");
+ case E_TABLE_MEMORY_STORE_COLUMN_TYPE_PIXBUF:
+ return NULL;
+ default:
+ break;
}
return NULL;
}
static gboolean
-etms_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_memory_store_value_is_empty (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
switch (etms->priv->columns[col].type) {
- case E_TABLE_MEMORY_STORE_COLUMN_TYPE_STRING:
- return !(value && *(gchar *) value);
- case E_TABLE_MEMORY_STORE_COLUMN_TYPE_PIXBUF:
- return value == NULL;
- default:
- break;
+ case E_TABLE_MEMORY_STORE_COLUMN_TYPE_STRING:
+ return !(value && *(gchar *) value);
+ case E_TABLE_MEMORY_STORE_COLUMN_TYPE_PIXBUF:
+ return value == NULL;
+ default:
+ break;
}
return value == NULL;
}
static gchar *
-etms_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_memory_store_value_to_string (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
switch (etms->priv->columns[col].type) {
- case E_TABLE_MEMORY_STORE_COLUMN_TYPE_STRING:
- return g_strdup (value);
- case E_TABLE_MEMORY_STORE_COLUMN_TYPE_PIXBUF:
- return g_strdup ("");
- default:
- break;
+ case E_TABLE_MEMORY_STORE_COLUMN_TYPE_STRING:
+ return g_strdup (value);
+ case E_TABLE_MEMORY_STORE_COLUMN_TYPE_PIXBUF:
+ return g_strdup ("");
+ default:
+ break;
}
return g_strdup_printf ("%d", GPOINTER_TO_INT (value));
}
static void
-etms_append_row (ETableModel *etm,
- ETableModel *source,
- gint row)
-{
- ETableMemoryStore *etms = E_TABLE_MEMORY_STORE (etm);
- gpointer *new_data;
- gint i;
- gint row_count;
-
- new_data = g_new (gpointer , etms->priv->col_count);
-
- for (i = 0; i < etms->priv->col_count; i++) {
- new_data[i] = e_table_model_value_at (source, i, row);
- }
-
- row_count = e_table_model_row_count (E_TABLE_MODEL (etms));
-
- e_table_memory_store_insert_array (etms, row_count, new_data, NULL);
-}
-
-static void
-etms_finalize (GObject *object)
-{
- ETableMemoryStorePrivate *priv;
-
- priv = E_TABLE_MEMORY_STORE_GET_PRIVATE (object);
-
- e_table_memory_store_clear (E_TABLE_MEMORY_STORE (object));
-
- g_free (priv->columns);
- g_free (priv->store);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_table_memory_store_parent_class)->finalize (object);
-}
-
-static void
-e_table_memory_store_init (ETableMemoryStore *etms)
-{
- etms->priv = E_TABLE_MEMORY_STORE_GET_PRIVATE (etms);
-}
-
-static void
e_table_memory_store_class_init (ETableMemoryStoreClass *class)
{
GObjectClass *object_class;
@@ -247,19 +240,25 @@ e_table_memory_store_class_init (ETableMemoryStoreClass *class)
g_type_class_add_private (class, sizeof (ETableMemoryStorePrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->finalize = etms_finalize;
+ object_class->finalize = table_memory_store_finalize;
model_class = E_TABLE_MODEL_CLASS (class);
- model_class->column_count = etms_column_count;
- model_class->value_at = etms_value_at;
- model_class->set_value_at = etms_set_value_at;
- model_class->is_cell_editable = etms_is_cell_editable;
- model_class->duplicate_value = etms_duplicate_value;
- model_class->free_value = etms_free_value;
- model_class->initialize_value = etms_initialize_value;
- model_class->value_is_empty = etms_value_is_empty;
- model_class->value_to_string = etms_value_to_string;
- model_class->append_row = etms_append_row;
+ model_class->column_count = table_memory_store_column_count;
+ model_class->append_row = table_memory_store_append_row;
+ model_class->value_at = table_memory_store_value_at;
+ model_class->set_value_at = table_memory_store_set_value_at;
+ model_class->is_cell_editable = table_memory_store_is_cell_editable;
+ model_class->duplicate_value = table_memory_store_duplicate_value;
+ model_class->free_value = table_memory_store_free_value;
+ model_class->initialize_value = table_memory_store_initialize_value;
+ model_class->value_is_empty = table_memory_store_value_is_empty;
+ model_class->value_to_string = table_memory_store_value_to_string;
+}
+
+static void
+e_table_memory_store_init (ETableMemoryStore *etms)
+{
+ etms->priv = E_TABLE_MEMORY_STORE_GET_PRIVATE (etms);
}
/**
diff --git a/e-util/e-table-memory.c b/e-util/e-table-memory.c
index e12deb3007..5a0bcd1868 100644
--- a/e-util/e-table-memory.c
+++ b/e-util/e-table-memory.c
@@ -20,10 +20,6 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
@@ -41,7 +37,10 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_TABLE_MEMORY, ETableMemoryPrivate))
-G_DEFINE_TYPE (ETableMemory, e_table_memory, E_TYPE_TABLE_MODEL)
+G_DEFINE_TYPE (
+ ETableMemory,
+ e_table_memory,
+ E_TYPE_TABLE_MODEL)
struct _ETableMemoryPrivate {
gpointer *data;
@@ -63,9 +62,9 @@ table_memory_finalize (GObject *object)
}
static gint
-table_memory_row_count (ETableModel *etm)
+table_memory_row_count (ETableModel *table_model)
{
- ETableMemory *table_memory = E_TABLE_MEMORY (etm);
+ ETableMemory *table_memory = E_TABLE_MEMORY (table_model);
return table_memory->priv->num_rows;
}
diff --git a/e-util/e-table-memory.h b/e-util/e-table-memory.h
index e374fca5ca..db0809daf7 100644
--- a/e-util/e-table-memory.h
+++ b/e-util/e-table-memory.h
@@ -24,8 +24,8 @@
#error "Only <e-util/e-util.h> should be included directly."
#endif
-#ifndef _E_TABLE_MEMORY_H_
-#define _E_TABLE_MEMORY_H_
+#ifndef E_TABLE_MEMORY_H
+#define E_TABLE_MEMORY_H
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -88,4 +88,4 @@ void e_table_memory_set_data (ETableMemory *table_memory,
G_END_DECLS
-#endif /* _E_TABLE_MEMORY_H */
+#endif /* E_TABLE_MEMORY_H */
diff --git a/e-util/e-table-model.c b/e-util/e-table-model.c
index 1ae4d3e81b..7f9477b0f2 100644
--- a/e-util/e-table-model.c
+++ b/e-util/e-table-model.c
@@ -1,4 +1,5 @@
/*
+ * e-table-model.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,25 +14,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "e-table-model.h"
-#include "e-marshal.h"
-
-#define ETM_FROZEN(e) \
- (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (e), "frozen")) != 0)
-
#define d(x)
d (static gint depth = 0;)
@@ -52,74 +38,158 @@ enum {
static guint signals[LAST_SIGNAL] = { 0, };
+static gint
+table_model_is_frozen (ETableModel *table_model)
+{
+ gpointer data;
+
+ data = g_object_get_data (G_OBJECT (table_model), "frozen");
+
+ return (GPOINTER_TO_INT (data) != 0);
+}
+
+static void
+e_table_model_class_init (ETableModelClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ signals[MODEL_NO_CHANGE] = g_signal_new (
+ "model_no_change",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETableModelClass, model_no_change),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+ signals[MODEL_CHANGED] = g_signal_new (
+ "model_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETableModelClass, model_changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+ signals[MODEL_PRE_CHANGE] = g_signal_new (
+ "model_pre_change",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETableModelClass, model_pre_change),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+ signals[MODEL_ROW_CHANGED] = g_signal_new (
+ "model_row_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETableModelClass, model_row_changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+
+ signals[MODEL_CELL_CHANGED] = g_signal_new (
+ "model_cell_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETableModelClass, model_cell_changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ G_TYPE_INT);
+
+ signals[MODEL_ROWS_INSERTED] = g_signal_new (
+ "model_rows_inserted",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETableModelClass, model_rows_inserted),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ G_TYPE_INT);
+
+ signals[MODEL_ROWS_DELETED] = g_signal_new (
+ "model_rows_deleted",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ETableModelClass, model_rows_deleted),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ G_TYPE_INT);
+}
+
+static void
+e_table_model_init (ETableModel *table_model)
+{
+}
+
/**
* e_table_model_column_count:
- * @e_table_model: The e-table-model to operate on
+ * @table_model: The e-table-model to operate on
*
* Returns: the number of columns in the table model.
*/
gint
-e_table_model_column_count (ETableModel *e_table_model)
+e_table_model_column_count (ETableModel *table_model)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), 0);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
g_return_val_if_fail (class->column_count != NULL, 0);
- return class->column_count (e_table_model);
+ return class->column_count (table_model);
}
/**
* e_table_model_row_count:
- * @e_table_model: the e-table-model to operate on
+ * @table_model: the e-table-model to operate on
*
* Returns: the number of rows in the Table model.
*/
gint
-e_table_model_row_count (ETableModel *e_table_model)
+e_table_model_row_count (ETableModel *table_model)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), 0);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
g_return_val_if_fail (class->row_count != NULL, 0);
- return class->row_count (e_table_model);
+ return class->row_count (table_model);
}
/**
* e_table_model_append_row:
- * @e_table_model: the table model to append the a row to.
+ * @table_model: the table model to append the a row to.
* @source:
* @row:
*
*/
void
-e_table_model_append_row (ETableModel *e_table_model,
+e_table_model_append_row (ETableModel *table_model,
ETableModel *source,
gint row)
{
ETableModelClass *class;
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->append_row != NULL)
- class->append_row (e_table_model, source, row);
+ class->append_row (table_model, source, row);
}
/**
* e_table_value_at:
- * @e_table_model: the e-table-model to operate on
+ * @table_model: the e-table-model to operate on
* @col: column in the model to pull data from.
* @row: row in the model to pull data from.
*
* Return value: This function returns the value that is stored
- * by the @e_table_model in column @col and row @row. The data
+ * by the @table_model in column @col and row @row. The data
* returned can be a pointer or any data value that can be stored
* inside a pointer.
*
@@ -132,29 +202,29 @@ e_table_model_append_row (ETableModel *e_table_model,
* rows_inserted and no_change don't affect any data in this way.
**/
gpointer
-e_table_model_value_at (ETableModel *e_table_model,
+e_table_model_value_at (ETableModel *table_model,
gint col,
gint row)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
g_return_val_if_fail (class->value_at != NULL, NULL);
- return class->value_at (e_table_model, col, row);
+ return class->value_at (table_model, col, row);
}
/**
* e_table_model_set_value_at:
- * @e_table_model: the table model to operate on.
+ * @table_model: the table model to operate on.
* @col: the column where the data will be stored in the model.
* @row: the row where the data will be stored in the model.
* @value: the data to be stored.
*
* This function instructs the model to store the value in @data in the
- * the @e_table_model at column @col and row @row. The @data typically
+ * the @table_model at column @col and row @row. The @data typically
* comes from one of the ECell rendering objects.
*
* There should be an agreement between the Table Model and the user
@@ -162,279 +232,171 @@ e_table_model_value_at (ETableModel *e_table_model,
* be a pointer to a set of data, or a datum that fits inside a gpointer .
*/
void
-e_table_model_set_value_at (ETableModel *e_table_model,
+e_table_model_set_value_at (ETableModel *table_model,
gint col,
gint row,
gconstpointer value)
{
ETableModelClass *class;
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
g_return_if_fail (class->set_value_at != NULL);
- class->set_value_at (e_table_model, col, row, value);
+ class->set_value_at (table_model, col, row, value);
}
/**
* e_table_model_is_cell_editable:
- * @e_table_model: the table model to query.
+ * @table_model: the table model to query.
* @col: column to query.
* @row: row to query.
*
- * Returns: %TRUE if the cell in @e_table_model at @col,@row can be
+ * Returns: %TRUE if the cell in @table_model at @col,@row can be
* edited, %FALSE otherwise
*/
gboolean
-e_table_model_is_cell_editable (ETableModel *e_table_model,
+e_table_model_is_cell_editable (ETableModel *table_model,
gint col,
gint row)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
g_return_val_if_fail (class->is_cell_editable != NULL, FALSE);
- return class->is_cell_editable (e_table_model, col, row);
+ return class->is_cell_editable (table_model, col, row);
}
gpointer
-e_table_model_duplicate_value (ETableModel *e_table_model,
+e_table_model_duplicate_value (ETableModel *table_model,
gint col,
gconstpointer value)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->duplicate_value == NULL)
return NULL;
- return class->duplicate_value (e_table_model, col, value);
+ return class->duplicate_value (table_model, col, value);
}
void
-e_table_model_free_value (ETableModel *e_table_model,
+e_table_model_free_value (ETableModel *table_model,
gint col,
gpointer value)
{
ETableModelClass *class;
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->free_value != NULL)
- class->free_value (e_table_model, col, value);
+ class->free_value (table_model, col, value);
}
gboolean
-e_table_model_has_save_id (ETableModel *e_table_model)
+e_table_model_has_save_id (ETableModel *table_model)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->has_save_id == NULL)
return FALSE;
- return class->has_save_id (e_table_model);
+ return class->has_save_id (table_model);
}
gchar *
-e_table_model_get_save_id (ETableModel *e_table_model,
+e_table_model_get_save_id (ETableModel *table_model,
gint row)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->get_save_id == NULL)
return NULL;
- return class->get_save_id (e_table_model, row);
+ return class->get_save_id (table_model, row);
}
gboolean
-e_table_model_has_change_pending (ETableModel *e_table_model)
+e_table_model_has_change_pending (ETableModel *table_model)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->has_change_pending == NULL)
return FALSE;
- return class->has_change_pending (e_table_model);
+ return class->has_change_pending (table_model);
}
gpointer
-e_table_model_initialize_value (ETableModel *e_table_model,
+e_table_model_initialize_value (ETableModel *table_model,
gint col)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->initialize_value == NULL)
return NULL;
- return class->initialize_value (e_table_model, col);
+ return class->initialize_value (table_model, col);
}
gboolean
-e_table_model_value_is_empty (ETableModel *e_table_model,
+e_table_model_value_is_empty (ETableModel *table_model,
gint col,
gconstpointer value)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->value_is_empty == NULL)
return FALSE;
- return class->value_is_empty (e_table_model, col, value);
+ return class->value_is_empty (table_model, col, value);
}
gchar *
-e_table_model_value_to_string (ETableModel *e_table_model,
+e_table_model_value_to_string (ETableModel *table_model,
gint col,
gconstpointer value)
{
ETableModelClass *class;
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL);
- class = E_TABLE_MODEL_GET_CLASS (e_table_model);
+ class = E_TABLE_MODEL_GET_CLASS (table_model);
if (class->value_to_string == NULL)
return g_strdup ("");
- return class->value_to_string (e_table_model, col, value);
-}
-
-static void
-e_table_model_class_init (ETableModelClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- signals[MODEL_NO_CHANGE] = g_signal_new (
- "model_no_change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETableModelClass, model_no_change),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[MODEL_CHANGED] = g_signal_new (
- "model_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETableModelClass, model_changed),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[MODEL_PRE_CHANGE] = g_signal_new (
- "model_pre_change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETableModelClass, model_pre_change),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[MODEL_ROW_CHANGED] = g_signal_new (
- "model_row_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETableModelClass, model_row_changed),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- signals[MODEL_CELL_CHANGED] = g_signal_new (
- "model_cell_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETableModelClass, model_cell_changed),
- (GSignalAccumulator) NULL, NULL,
- e_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals[MODEL_ROWS_INSERTED] = g_signal_new (
- "model_rows_inserted",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETableModelClass, model_rows_inserted),
- (GSignalAccumulator) NULL, NULL,
- e_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals[MODEL_ROWS_DELETED] = g_signal_new (
- "model_rows_deleted",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETableModelClass, model_rows_deleted),
- (GSignalAccumulator) NULL, NULL,
- e_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- class->column_count = NULL;
- class->row_count = NULL;
- class->append_row = NULL;
-
- class->value_at = NULL;
- class->set_value_at = NULL;
- class->is_cell_editable = NULL;
-
- class->has_save_id = NULL;
- class->get_save_id = NULL;
-
- class->has_change_pending = NULL;
-
- class->duplicate_value = NULL;
- class->free_value = NULL;
- class->initialize_value = NULL;
- class->value_is_empty = NULL;
- class->value_to_string = NULL;
-
- class->model_no_change = NULL;
- class->model_changed = NULL;
- class->model_row_changed = NULL;
- class->model_cell_changed = NULL;
- class->model_rows_inserted = NULL;
- class->model_rows_deleted = NULL;
-}
-
-static void
-e_table_model_init (ETableModel *e_table_model)
-{
- /* nothing to do */
+ return class->value_to_string (table_model, col, value);
}
#if d(!)0
@@ -448,26 +410,26 @@ print_tabs (void)
#endif
void
-e_table_model_pre_change (ETableModel *e_table_model)
+e_table_model_pre_change (ETableModel *table_model)
{
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- if (ETM_FROZEN (e_table_model))
+ if (table_model_is_frozen (table_model))
return;
d (print_tabs ());
d (depth++);
- g_signal_emit (e_table_model, signals[MODEL_PRE_CHANGE], 0);
+ g_signal_emit (table_model, signals[MODEL_PRE_CHANGE], 0);
d (depth--);
}
/**
* e_table_model_no_change:
- * @e_table_model: the table model to notify of the lack of a change
+ * @table_model: the table model to notify of the lack of a change
*
* Use this function to notify any views of this table model that
* the contents of the table model have changed. This will emit
- * the signal "model_no_change" on the @e_table_model object.
+ * the signal "model_no_change" on the @table_model object.
*
* It is preferable to use the e_table_model_row_changed() and
* the e_table_model_cell_changed() to notify of smaller changes
@@ -475,26 +437,26 @@ e_table_model_pre_change (ETableModel *e_table_model)
* ways of caching the information they render from the model.
*/
void
-e_table_model_no_change (ETableModel *e_table_model)
+e_table_model_no_change (ETableModel *table_model)
{
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- if (ETM_FROZEN (e_table_model))
+ if (table_model_is_frozen (table_model))
return;
d (print_tabs ());
d (depth++);
- g_signal_emit (e_table_model, signals[MODEL_NO_CHANGE], 0);
+ g_signal_emit (table_model, signals[MODEL_NO_CHANGE], 0);
d (depth--);
}
/**
* e_table_model_changed:
- * @e_table_model: the table model to notify of the change
+ * @table_model: the table model to notify of the change
*
* Use this function to notify any views of this table model that
* the contents of the table model have changed. This will emit
- * the signal "model_changed" on the @e_table_model object.
+ * the signal "model_changed" on the @table_model object.
*
* It is preferable to use the e_table_model_row_changed() and
* the e_table_model_cell_changed() to notify of smaller changes
@@ -502,181 +464,189 @@ e_table_model_no_change (ETableModel *e_table_model)
* ways of caching the information they render from the model.
*/
void
-e_table_model_changed (ETableModel *e_table_model)
+e_table_model_changed (ETableModel *table_model)
{
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- if (ETM_FROZEN (e_table_model))
+ if (table_model_is_frozen (table_model))
return;
d (print_tabs ());
d (depth++);
- g_signal_emit (e_table_model, signals[MODEL_CHANGED], 0);
+ g_signal_emit (table_model, signals[MODEL_CHANGED], 0);
d (depth--);
}
/**
* e_table_model_row_changed:
- * @e_table_model: the table model to notify of the change
+ * @table_model: the table model to notify of the change
* @row: the row that was changed in the model.
*
* Use this function to notify any views of the table model that
* the contents of row @row have changed in model. This function
- * will emit the "model_row_changed" signal on the @e_table_model
+ * will emit the "model_row_changed" signal on the @table_model
* object
*/
void
-e_table_model_row_changed (ETableModel *e_table_model,
+e_table_model_row_changed (ETableModel *table_model,
gint row)
{
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- if (ETM_FROZEN (e_table_model))
+ if (table_model_is_frozen (table_model))
return;
d (print_tabs ());
d (depth++);
- g_signal_emit (e_table_model, signals[MODEL_ROW_CHANGED], 0, row);
+ g_signal_emit (table_model, signals[MODEL_ROW_CHANGED], 0, row);
d (depth--);
}
/**
* e_table_model_cell_changed:
- * @e_table_model: the table model to notify of the change
+ * @table_model: the table model to notify of the change
* @col: the column.
* @row: the row
*
* Use this function to notify any views of the table model that
* contents of the cell at @col,@row has changed. This will emit
- * the "model_cell_changed" signal on the @e_table_model
+ * the "model_cell_changed" signal on the @table_model
* object
*/
void
-e_table_model_cell_changed (ETableModel *e_table_model,
+e_table_model_cell_changed (ETableModel *table_model,
gint col,
gint row)
{
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- if (ETM_FROZEN (e_table_model))
+ if (table_model_is_frozen (table_model))
return;
d (print_tabs ());
d (depth++);
g_signal_emit (
- e_table_model, signals[MODEL_CELL_CHANGED], 0, col, row);
+ table_model, signals[MODEL_CELL_CHANGED], 0, col, row);
d (depth--);
}
/**
* e_table_model_rows_inserted:
- * @e_table_model: the table model to notify of the change
+ * @table_model: the table model to notify of the change
* @row: the row that was inserted into the model.
* @count: The number of rows that were inserted.
*
* Use this function to notify any views of the table model that
* @count rows at row @row have been inserted into the model. This
* function will emit the "model_rows_inserted" signal on the
- * @e_table_model object
+ * @table_model object
*/
void
-e_table_model_rows_inserted (ETableModel *e_table_model,
+e_table_model_rows_inserted (ETableModel *table_model,
gint row,
gint count)
{
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- if (ETM_FROZEN (e_table_model))
+ if (table_model_is_frozen (table_model))
return;
d (print_tabs ());
d (depth++);
g_signal_emit (
- e_table_model, signals[MODEL_ROWS_INSERTED], 0, row, count);
+ table_model, signals[MODEL_ROWS_INSERTED], 0, row, count);
d (depth--);
}
/**
* e_table_model_row_inserted:
- * @e_table_model: the table model to notify of the change
+ * @table_model: the table model to notify of the change
* @row: the row that was inserted into the model.
*
* Use this function to notify any views of the table model that the
* row @row has been inserted into the model. This function will emit
- * the "model_rows_inserted" signal on the @e_table_model object
+ * the "model_rows_inserted" signal on the @table_model object
*/
void
-e_table_model_row_inserted (ETableModel *e_table_model,
+e_table_model_row_inserted (ETableModel *table_model,
gint row)
{
- e_table_model_rows_inserted (e_table_model, row, 1);
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
+
+ e_table_model_rows_inserted (table_model, row, 1);
}
/**
* e_table_model_row_deleted:
- * @e_table_model: the table model to notify of the change
+ * @table_model: the table model to notify of the change
* @row: the row that was deleted
* @count: The number of rows deleted
*
* Use this function to notify any views of the table model that
* @count rows at row @row have been deleted from the model. This
* function will emit the "model_rows_deleted" signal on the
- * @e_table_model object
+ * @table_model object
*/
void
-e_table_model_rows_deleted (ETableModel *e_table_model,
+e_table_model_rows_deleted (ETableModel *table_model,
gint row,
gint count)
{
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
- if (ETM_FROZEN (e_table_model))
+ if (table_model_is_frozen (table_model))
return;
d (print_tabs ());
d (depth++);
g_signal_emit (
- e_table_model, signals[MODEL_ROWS_DELETED], 0, row, count);
+ table_model, signals[MODEL_ROWS_DELETED], 0, row, count);
d (depth--);
}
/**
* e_table_model_row_deleted:
- * @e_table_model: the table model to notify of the change
+ * @table_model: the table model to notify of the change
* @row: the row that was deleted
*
* Use this function to notify any views of the table model that the
* row @row has been deleted from the model. This function will emit
- * the "model_rows_deleted" signal on the @e_table_model object
+ * the "model_rows_deleted" signal on the @table_model object
*/
void
-e_table_model_row_deleted (ETableModel *e_table_model,
+e_table_model_row_deleted (ETableModel *table_model,
gint row)
{
- e_table_model_rows_deleted (e_table_model, row, 1);
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
+
+ e_table_model_rows_deleted (table_model, row, 1);
}
void
-e_table_model_freeze (ETableModel *e_table_model)
+e_table_model_freeze (ETableModel *table_model)
{
- e_table_model_pre_change (e_table_model);
+ gpointer data;
- /* FIXME This expression is awesome! */
- g_object_set_data (
- G_OBJECT (e_table_model), "frozen",
- GINT_TO_POINTER (GPOINTER_TO_INT (
- g_object_get_data (G_OBJECT (e_table_model), "frozen")) + 1));
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
+
+ e_table_model_pre_change (table_model);
+
+ data = g_object_get_data (G_OBJECT (table_model), "frozen");
+ data = GINT_TO_POINTER (GPOINTER_TO_INT (data) + 1);
+ g_object_set_data (G_OBJECT (table_model), "frozen", data);
}
void
-e_table_model_thaw (ETableModel *e_table_model)
+e_table_model_thaw (ETableModel *table_model)
{
- /* FIXME This expression is awesome! */
- g_object_set_data (
- G_OBJECT (e_table_model), "frozen",
- GINT_TO_POINTER (GPOINTER_TO_INT (
- g_object_get_data (G_OBJECT (e_table_model), "frozen")) - 1));
+ gpointer data;
+
+ g_return_if_fail (E_IS_TABLE_MODEL (table_model));
+
+ data = g_object_get_data (G_OBJECT (table_model), "frozen");
+ data = GINT_TO_POINTER (GPOINTER_TO_INT (data) - 1);
+ g_object_set_data (G_OBJECT (table_model), "frozen", data);
- e_table_model_changed (e_table_model);
+ e_table_model_changed (table_model);
}
diff --git a/e-util/e-table-model.h b/e-util/e-table-model.h
index 3ed188e11c..60fc11c53c 100644
--- a/e-util/e-table-model.h
+++ b/e-util/e-table-model.h
@@ -1,4 +1,5 @@
/*
+ * e-table-model.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,20 +14,14 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
#error "Only <e-util/e-util.h> should be included directly."
#endif
-#ifndef _E_TABLE_MODEL_H_
-#define _E_TABLE_MODEL_H_
+#ifndef E_TABLE_MODEL_H
+#define E_TABLE_MODEL_H
#include <glib-object.h>
@@ -61,49 +56,46 @@ struct _ETableModel {
struct _ETableModelClass {
GObjectClass parent_class;
- /*
- * Virtual methods
- */
- gint (*column_count) (ETableModel *etm);
- gint (*row_count) (ETableModel *etm);
- void (*append_row) (ETableModel *etm,
+ gint (*column_count) (ETableModel *table_model);
+ gint (*row_count) (ETableModel *table_model);
+ void (*append_row) (ETableModel *table_model,
ETableModel *source,
gint row);
- gpointer (*value_at) (ETableModel *etm,
+ gpointer (*value_at) (ETableModel *table_model,
gint col,
gint row);
- void (*set_value_at) (ETableModel *etm,
+ void (*set_value_at) (ETableModel *table_model,
gint col,
gint row,
gconstpointer value);
- gboolean (*is_cell_editable) (ETableModel *etm,
+ gboolean (*is_cell_editable) (ETableModel *table_model,
gint col,
gint row);
- gboolean (*has_save_id) (ETableModel *etm);
- gchar * (*get_save_id) (ETableModel *etm,
+ gboolean (*has_save_id) (ETableModel *table_model);
+ gchar * (*get_save_id) (ETableModel *table_model,
gint row);
- gboolean (*has_change_pending) (ETableModel *etm);
+ gboolean (*has_change_pending) (ETableModel *table_model);
/* Allocate a copy of the given value. */
- gpointer (*duplicate_value) (ETableModel *etm,
+ gpointer (*duplicate_value) (ETableModel *table_model,
gint col,
gconstpointer value);
/* Free an allocated value. */
- void (*free_value) (ETableModel *etm,
+ void (*free_value) (ETableModel *table_model,
gint col,
gpointer value);
/* Return an allocated empty value. */
- gpointer (*initialize_value) (ETableModel *etm,
+ gpointer (*initialize_value) (ETableModel *table_model,
gint col);
/* Return TRUE if value is equivalent to an empty cell. */
- gboolean (*value_is_empty) (ETableModel *etm,
+ gboolean (*value_is_empty) (ETableModel *table_model,
gint col,
gconstpointer value);
/* Return an allocated string. */
- gchar * (*value_to_string) (ETableModel *etm,
+ gchar * (*value_to_string) (ETableModel *table_model,
gint col,
gconstpointer value);
@@ -120,19 +112,19 @@ struct _ETableModelClass {
* A row inserted: row_inserted
* A row deleted: row_deleted
*/
- void (*model_pre_change) (ETableModel *etm);
+ void (*model_pre_change) (ETableModel *table_model);
- void (*model_no_change) (ETableModel *etm);
- void (*model_changed) (ETableModel *etm);
- void (*model_row_changed) (ETableModel *etm,
+ void (*model_no_change) (ETableModel *table_model);
+ void (*model_changed) (ETableModel *table_model);
+ void (*model_row_changed) (ETableModel *table_model,
gint row);
- void (*model_cell_changed) (ETableModel *etm,
+ void (*model_cell_changed) (ETableModel *table_model,
gint col,
gint row);
- void (*model_rows_inserted) (ETableModel *etm,
+ void (*model_rows_inserted) (ETableModel *table_model,
gint row,
gint count);
- void (*model_rows_deleted) (ETableModel *etm,
+ void (*model_rows_deleted) (ETableModel *table_model,
gint row,
gint count);
};
@@ -140,78 +132,78 @@ struct _ETableModelClass {
GType e_table_model_get_type (void) G_GNUC_CONST;
/**/
-gint e_table_model_column_count (ETableModel *e_table_model);
-const gchar * e_table_model_column_name (ETableModel *e_table_model,
+gint e_table_model_column_count (ETableModel *table_model);
+const gchar * e_table_model_column_name (ETableModel *table_model,
gint col);
-gint e_table_model_row_count (ETableModel *e_table_model);
-void e_table_model_append_row (ETableModel *e_table_model,
+gint e_table_model_row_count (ETableModel *table_model);
+void e_table_model_append_row (ETableModel *table_model,
ETableModel *source,
gint row);
/**/
-gpointer e_table_model_value_at (ETableModel *e_table_model,
+gpointer e_table_model_value_at (ETableModel *table_model,
gint col,
gint row);
-void e_table_model_set_value_at (ETableModel *e_table_model,
+void e_table_model_set_value_at (ETableModel *table_model,
gint col,
gint row,
gconstpointer value);
-gboolean e_table_model_is_cell_editable (ETableModel *e_table_model,
+gboolean e_table_model_is_cell_editable (ETableModel *table_model,
gint col,
gint row);
/**/
-gboolean e_table_model_has_save_id (ETableModel *etm);
-gchar * e_table_model_get_save_id (ETableModel *etm,
+gboolean e_table_model_has_save_id (ETableModel *table_model);
+gchar * e_table_model_get_save_id (ETableModel *table_model,
gint row);
/**/
gboolean e_table_model_has_change_pending
- (ETableModel *etm);
+ (ETableModel *table_model);
/**/
-gpointer e_table_model_duplicate_value (ETableModel *e_table_model,
+gpointer e_table_model_duplicate_value (ETableModel *table_model,
gint col,
gconstpointer value);
-void e_table_model_free_value (ETableModel *e_table_model,
+void e_table_model_free_value (ETableModel *table_model,
gint col,
gpointer value);
-gpointer e_table_model_initialize_value (ETableModel *e_table_model,
+gpointer e_table_model_initialize_value (ETableModel *table_model,
gint col);
-gboolean e_table_model_value_is_empty (ETableModel *e_table_model,
+gboolean e_table_model_value_is_empty (ETableModel *table_model,
gint col,
gconstpointer value);
-gchar * e_table_model_value_to_string (ETableModel *e_table_model,
+gchar * e_table_model_value_to_string (ETableModel *table_model,
gint col,
gconstpointer value);
/*
* Routines for emitting signals on the e_table
*/
-void e_table_model_pre_change (ETableModel *e_table_model);
-void e_table_model_no_change (ETableModel *e_table_model);
-void e_table_model_changed (ETableModel *e_table_model);
-void e_table_model_row_changed (ETableModel *e_table_model,
+void e_table_model_pre_change (ETableModel *table_model);
+void e_table_model_no_change (ETableModel *table_model);
+void e_table_model_changed (ETableModel *table_model);
+void e_table_model_row_changed (ETableModel *table_model,
gint row);
-void e_table_model_cell_changed (ETableModel *e_table_model,
+void e_table_model_cell_changed (ETableModel *table_model,
gint col,
gint row);
-void e_table_model_rows_inserted (ETableModel *e_table_model,
+void e_table_model_rows_inserted (ETableModel *table_model,
gint row,
gint count);
-void e_table_model_rows_deleted (ETableModel *e_table_model,
+void e_table_model_rows_deleted (ETableModel *table_model,
gint row,
gint count);
/**/
-void e_table_model_row_inserted (ETableModel *e_table_model,
+void e_table_model_row_inserted (ETableModel *table_model,
gint row);
-void e_table_model_row_deleted (ETableModel *e_table_model,
+void e_table_model_row_deleted (ETableModel *table_model,
gint row);
-void e_table_model_freeze (ETableModel *e_table_model);
-void e_table_model_thaw (ETableModel *e_table_model);
+void e_table_model_freeze (ETableModel *table_model);
+void e_table_model_thaw (ETableModel *table_model);
G_END_DECLS
-#endif /* _E_TABLE_MODEL_H_ */
+#endif /* E_TABLE_MODEL_H */
diff --git a/e-util/e-table-one.c b/e-util/e-table-one.c
index db9c27e4d1..242484fdfa 100644
--- a/e-util/e-table-one.c
+++ b/e-util/e-table-one.c
@@ -27,10 +27,39 @@
#include "e-table-one.h"
-G_DEFINE_TYPE (ETableOne, e_table_one, E_TYPE_TABLE_MODEL)
+G_DEFINE_TYPE (
+ ETableOne,
+ e_table_one,
+ E_TYPE_TABLE_MODEL)
+
+static void
+table_one_dispose (GObject *object)
+{
+ ETableOne *one = E_TABLE_ONE (object);
+
+ if (one->data) {
+ gint i;
+ gint col_count;
+
+ if (one->source) {
+ col_count = e_table_model_column_count (one->source);
+
+ for (i = 0; i < col_count; i++)
+ e_table_model_free_value (one->source, i, one->data[i]);
+ }
+
+ g_free (one->data);
+ }
+ one->data = NULL;
+
+ g_clear_object (&one->source);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_table_one_parent_class)->dispose (object);
+}
static gint
-one_column_count (ETableModel *etm)
+table_one_column_count (ETableModel *etm)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -41,15 +70,15 @@ one_column_count (ETableModel *etm)
}
static gint
-one_row_count (ETableModel *etm)
+table_one_row_count (ETableModel *etm)
{
return 1;
}
static gpointer
-one_value_at (ETableModel *etm,
- gint col,
- gint row)
+table_one_value_at (ETableModel *etm,
+ gint col,
+ gint row)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -60,10 +89,10 @@ one_value_at (ETableModel *etm,
}
static void
-one_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer val)
+table_one_set_value_at (ETableModel *etm,
+ gint col,
+ gint row,
+ gconstpointer val)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -74,9 +103,9 @@ one_set_value_at (ETableModel *etm,
}
static gboolean
-one_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
+table_one_is_cell_editable (ETableModel *etm,
+ gint col,
+ gint row)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -88,9 +117,9 @@ one_is_cell_editable (ETableModel *etm,
/* The default for one_duplicate_value is to return the raw value. */
static gpointer
-one_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_one_duplicate_value (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -101,9 +130,9 @@ one_duplicate_value (ETableModel *etm,
}
static void
-one_free_value (ETableModel *etm,
- gint col,
- gpointer value)
+table_one_free_value (ETableModel *etm,
+ gint col,
+ gpointer value)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -112,8 +141,8 @@ one_free_value (ETableModel *etm,
}
static gpointer
-one_initialize_value (ETableModel *etm,
- gint col)
+table_one_initialize_value (ETableModel *etm,
+ gint col)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -124,9 +153,9 @@ one_initialize_value (ETableModel *etm,
}
static gboolean
-one_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_one_value_is_empty (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -137,9 +166,9 @@ one_value_is_empty (ETableModel *etm,
}
static gchar *
-one_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_one_value_to_string (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETableOne *one = E_TABLE_ONE (etm);
@@ -150,64 +179,30 @@ one_value_to_string (ETableModel *etm,
}
static void
-one_finalize (GObject *object)
-{
- G_OBJECT_CLASS (e_table_one_parent_class)->finalize (object);
-}
-
-static void
-one_dispose (GObject *object)
+e_table_one_class_init (ETableOneClass *class)
{
- ETableOne *one = E_TABLE_ONE (object);
-
- if (one->data) {
- gint i;
- gint col_count;
-
- if (one->source) {
- col_count = e_table_model_column_count (one->source);
-
- for (i = 0; i < col_count; i++)
- e_table_model_free_value (one->source, i, one->data[i]);
- }
-
- g_free (one->data);
- }
- one->data = NULL;
-
- if (one->source)
- g_object_unref (one->source);
- one->source = NULL;
+ GObjectClass *object_class;
+ ETableModelClass *model_class;
- G_OBJECT_CLASS (e_table_one_parent_class)->dispose (object);
-}
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = table_one_dispose;
-static void
-e_table_one_class_init (ETableOneClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- ETableModelClass *model_class = E_TABLE_MODEL_CLASS (class);
-
- model_class->column_count = one_column_count;
- model_class->row_count = one_row_count;
- model_class->value_at = one_value_at;
- model_class->set_value_at = one_set_value_at;
- model_class->is_cell_editable = one_is_cell_editable;
- model_class->duplicate_value = one_duplicate_value;
- model_class->free_value = one_free_value;
- model_class->initialize_value = one_initialize_value;
- model_class->value_is_empty = one_value_is_empty;
- model_class->value_to_string = one_value_to_string;
-
- object_class->dispose = one_dispose;
- object_class->finalize = one_finalize;
+ model_class = E_TABLE_MODEL_CLASS (class);
+ model_class->column_count = table_one_column_count;
+ model_class->row_count = table_one_row_count;
+ model_class->value_at = table_one_value_at;
+ model_class->set_value_at = table_one_set_value_at;
+ model_class->is_cell_editable = table_one_is_cell_editable;
+ model_class->duplicate_value = table_one_duplicate_value;
+ model_class->free_value = table_one_free_value;
+ model_class->initialize_value = table_one_initialize_value;
+ model_class->value_is_empty = table_one_value_is_empty;
+ model_class->value_to_string = table_one_value_to_string;
}
static void
e_table_one_init (ETableOne *one)
{
- one->source = NULL;
- one->data = NULL;
}
ETableModel *
diff --git a/e-util/e-table-sorted-variable.c b/e-util/e-table-sorted-variable.c
index 17c10d5328..e01f940b2c 100644
--- a/e-util/e-table-sorted-variable.c
+++ b/e-util/e-table-sorted-variable.c
@@ -37,9 +37,10 @@
/* maximum insertions between an idle event that we will do without scheduling an idle sort */
#define ETSV_INSERT_MAX (4)
-/* workaround for avoiding API breakage */
-#define etsv_get_type e_table_sorted_variable_get_type
-G_DEFINE_TYPE (ETableSortedVariable, etsv, E_TYPE_TABLE_SUBSET_VARIABLE)
+G_DEFINE_TYPE (
+ ETableSortedVariable,
+ e_table_sorted_variable,
+ E_TYPE_TABLE_SUBSET_VARIABLE)
static void etsv_sort_info_changed (ETableSortInfo *info, ETableSortedVariable *etsv);
static void etsv_sort (ETableSortedVariable *etsv);
@@ -74,11 +75,11 @@ etsv_dispose (GObject *object)
g_object_unref (etsv->full_header);
etsv->full_header = NULL;
- G_OBJECT_CLASS (etsv_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_sorted_variable_parent_class)->dispose (object);
}
static void
-etsv_class_init (ETableSortedVariableClass *class)
+e_table_sorted_variable_class_init (ETableSortedVariableClass *class)
{
ETableSubsetVariableClass *etssv_class = E_TABLE_SUBSET_VARIABLE_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -90,7 +91,7 @@ etsv_class_init (ETableSortedVariableClass *class)
}
static void
-etsv_init (ETableSortedVariable *etsv)
+e_table_sorted_variable_init (ETableSortedVariable *etsv)
{
etsv->full_header = NULL;
etsv->sort_info = NULL;
@@ -127,8 +128,11 @@ etsv_add (ETableSubsetVariable *etssv,
ETableModel *etm = E_TABLE_MODEL (etssv);
ETableSubset *etss = E_TABLE_SUBSET (etssv);
ETableSortedVariable *etsv = E_TABLE_SORTED_VARIABLE (etssv);
+ ETableModel *source_model;
gint i;
+ source_model = e_table_subset_get_source_model (etss);
+
e_table_model_pre_change (etm);
if (etss->n_map + 1 > etssv->n_vals_allocated) {
@@ -148,7 +152,7 @@ etsv_add (ETableSubsetVariable *etssv,
if (etsv->insert_idle_id == 0) {
etsv->insert_idle_id = g_idle_add_full (40, (GSourceFunc) etsv_insert_idle, etsv, NULL);
}
- i = e_table_sorting_utils_insert (etss->source, etsv->sort_info, etsv->full_header, etss->map_table, etss->n_map, row);
+ i = e_table_sorting_utils_insert (source_model, etsv->sort_info, etsv->full_header, etss->map_table, etss->n_map, row);
memmove (etss->map_table + i + 1, etss->map_table + i, (etss->n_map - i) * sizeof (gint));
}
}
@@ -164,12 +168,14 @@ etsv_add_all (ETableSubsetVariable *etssv)
ETableModel *etm = E_TABLE_MODEL (etssv);
ETableSubset *etss = E_TABLE_SUBSET (etssv);
ETableSortedVariable *etsv = E_TABLE_SORTED_VARIABLE (etssv);
+ ETableModel *source_model;
gint rows;
gint i;
e_table_model_pre_change (etm);
- rows = e_table_model_row_count (etss->source);
+ source_model = e_table_subset_get_source_model (etss);
+ rows = e_table_model_row_count (source_model);
if (etss->n_map + rows > etssv->n_vals_allocated) {
etssv->n_vals_allocated += MAX (INCREMENT_AMOUNT, rows);
@@ -221,14 +227,17 @@ static void
etsv_sort (ETableSortedVariable *etsv)
{
ETableSubset *etss = E_TABLE_SUBSET (etsv);
+ ETableModel *source_model;
static gint reentering = 0;
+
if (reentering)
return;
reentering = 1;
e_table_model_pre_change (E_TABLE_MODEL (etsv));
- e_table_sorting_utils_sort (etss->source, etsv->sort_info, etsv->full_header, etss->map_table, etss->n_map);
+ source_model = e_table_subset_get_source_model (etss);
+ e_table_sorting_utils_sort (source_model, etsv->sort_info, etsv->full_header, etss->map_table, etss->n_map);
e_table_model_changed (E_TABLE_MODEL (etsv));
reentering = 0;
diff --git a/e-util/e-table-sorted.c b/e-util/e-table-sorted.c
index 3f548d349b..f2b2b617cf 100644
--- a/e-util/e-table-sorted.c
+++ b/e-util/e-table-sorted.c
@@ -34,9 +34,7 @@
#define INCREMENT_AMOUNT 100
-/* workaround for avoding API breakage */
-#define ets_get_type e_table_sorted_get_type
-G_DEFINE_TYPE (ETableSorted, ets, E_TYPE_TABLE_SUBSET)
+G_DEFINE_TYPE (ETableSorted, e_table_sorted, E_TYPE_TABLE_SUBSET)
/* maximum insertions between an idle event that we will do without scheduling an idle sort */
#define ETS_INSERT_MAX (4)
@@ -74,11 +72,11 @@ ets_dispose (GObject *object)
g_object_unref (ets->full_header);
ets->full_header = NULL;
- G_OBJECT_CLASS (ets_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_sorted_parent_class)->dispose (object);
}
static void
-ets_class_init (ETableSortedClass *class)
+e_table_sorted_class_init (ETableSortedClass *class)
{
ETableSubsetClass *etss_class = E_TABLE_SUBSET_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -93,7 +91,7 @@ ets_class_init (ETableSortedClass *class)
}
static void
-ets_init (ETableSorted *ets)
+e_table_sorted_init (ETableSorted *ets)
{
ets->full_header = NULL;
ets->sort_info = NULL;
@@ -131,8 +129,8 @@ e_table_sorted_new (ETableModel *source,
ETableSorted *ets = g_object_new (E_TYPE_TABLE_SORTED, NULL);
ETableSubset *etss = E_TABLE_SUBSET (ets);
- if (E_TABLE_SUBSET_CLASS (ets_parent_class)->proxy_model_pre_change)
- (E_TABLE_SUBSET_CLASS (ets_parent_class)->proxy_model_pre_change) (etss, source);
+ if (E_TABLE_SUBSET_CLASS (e_table_sorted_parent_class)->proxy_model_pre_change)
+ (E_TABLE_SUBSET_CLASS (e_table_sorted_parent_class)->proxy_model_pre_change) (etss, source);
if (e_table_subset_construct (etss, source, 0) == NULL) {
g_object_unref (ets);
@@ -190,8 +188,8 @@ ets_proxy_model_row_changed (ETableSubset *subset,
if (!E_TABLE_SORTED (subset)->sort_idle_id)
E_TABLE_SORTED (subset)->sort_idle_id = g_idle_add_full (50, (GSourceFunc) ets_sort_idle, subset, NULL);
- if (E_TABLE_SUBSET_CLASS (ets_parent_class)->proxy_model_row_changed)
- (E_TABLE_SUBSET_CLASS (ets_parent_class)->proxy_model_row_changed) (subset, source, row);
+ if (E_TABLE_SUBSET_CLASS (e_table_sorted_parent_class)->proxy_model_row_changed)
+ (E_TABLE_SUBSET_CLASS (e_table_sorted_parent_class)->proxy_model_row_changed) (subset, source, row);
}
static void
@@ -203,8 +201,8 @@ ets_proxy_model_cell_changed (ETableSubset *subset,
ETableSorted *ets = E_TABLE_SORTED (subset);
if (e_table_sorting_utils_affects_sort (ets->sort_info, ets->full_header, col))
ets_proxy_model_row_changed (subset, source, row);
- else if (E_TABLE_SUBSET_CLASS (ets_parent_class)->proxy_model_cell_changed)
- (E_TABLE_SUBSET_CLASS (ets_parent_class)->proxy_model_cell_changed) (subset, source, col, row);
+ else if (E_TABLE_SUBSET_CLASS (e_table_sorted_parent_class)->proxy_model_cell_changed)
+ (E_TABLE_SUBSET_CLASS (e_table_sorted_parent_class)->proxy_model_cell_changed) (subset, source, col, row);
}
static void
@@ -215,9 +213,12 @@ ets_proxy_model_rows_inserted (ETableSubset *etss,
{
ETableModel *etm = E_TABLE_MODEL (etss);
ETableSorted *ets = E_TABLE_SORTED (etss);
+ ETableModel *source_model;
gint i;
gboolean full_change = FALSE;
+ source_model = e_table_subset_get_source_model (etss);
+
if (count == 0) {
e_table_model_no_change (etm);
return;
@@ -250,7 +251,7 @@ ets_proxy_model_rows_inserted (ETableSubset *etss,
if (ets->insert_idle_id == 0) {
ets->insert_idle_id = g_idle_add_full (40, (GSourceFunc) ets_insert_idle, ets, NULL);
}
- i = e_table_sorting_utils_insert (etss->source, ets->sort_info, ets->full_header, etss->map_table, etss->n_map, row);
+ i = e_table_sorting_utils_insert (source_model, ets->sort_info, ets->full_header, etss->map_table, etss->n_map, row);
memmove (etss->map_table + i + 1, etss->map_table + i, (etss->n_map - i) * sizeof (gint));
}
}
@@ -314,6 +315,8 @@ static void
ets_sort (ETableSorted *ets)
{
ETableSubset *etss = E_TABLE_SUBSET (ets);
+ ETableModel *source_model;
+
static gint reentering = 0;
if (reentering)
return;
@@ -321,7 +324,11 @@ ets_sort (ETableSorted *ets)
e_table_model_pre_change (E_TABLE_MODEL (ets));
- e_table_sorting_utils_sort (etss->source, ets->sort_info, ets->full_header, etss->map_table, etss->n_map);
+ source_model = e_table_subset_get_source_model (etss);
+
+ e_table_sorting_utils_sort (
+ source_model, ets->sort_info,
+ ets->full_header, etss->map_table, etss->n_map);
e_table_model_changed (E_TABLE_MODEL (ets));
reentering = 0;
diff --git a/e-util/e-table-sorter.c b/e-util/e-table-sorter.c
index f67b635cb8..0ff30db68b 100644
--- a/e-util/e-table-sorter.c
+++ b/e-util/e-table-sorter.c
@@ -39,9 +39,7 @@ enum {
PROP_SORT_INFO
};
-/* workaround for avoiding API breakage */
-#define ets_get_type e_table_sorter_get_type
-G_DEFINE_TYPE (ETableSorter, ets, E_TYPE_SORTER)
+G_DEFINE_TYPE (ETableSorter, e_table_sorter, E_TYPE_SORTER)
#define INCREMENT_AMOUNT 100
@@ -116,7 +114,7 @@ ets_dispose (GObject *object)
g_object_unref (ets->source);
ets->source = NULL;
- G_OBJECT_CLASS (ets_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_sorter_parent_class)->dispose (object);
}
static void
@@ -168,7 +166,7 @@ ets_get_property (GObject *object,
}
static void
-ets_class_init (ETableSorterClass *class)
+e_table_sorter_class_init (ETableSorterClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
ESorterClass *sorter_class = E_SORTER_CLASS (class);
@@ -195,7 +193,7 @@ ets_class_init (ETableSorterClass *class)
}
static void
-ets_init (ETableSorter *ets)
+e_table_sorter_init (ETableSorter *ets)
{
ets->full_header = NULL;
ets->sort_info = NULL;
diff --git a/e-util/e-table-specification.c b/e-util/e-table-specification.c
index b00db491aa..e109a840e5 100644
--- a/e-util/e-table-specification.c
+++ b/e-util/e-table-specification.c
@@ -37,9 +37,10 @@
#include "e-xml-utils.h"
-/* workaround for avoiding API breakage */
-#define etsp_get_type e_table_specification_get_type
-G_DEFINE_TYPE (ETableSpecification, etsp, G_TYPE_OBJECT)
+G_DEFINE_TYPE (
+ ETableSpecification,
+ e_table_specification,
+ G_TYPE_OBJECT)
static void
etsp_finalize (GObject *object)
@@ -65,11 +66,11 @@ etsp_finalize (GObject *object)
g_free (etsp->domain);
etsp->domain = NULL;
- G_OBJECT_CLASS (etsp_parent_class)->finalize (object);
+ G_OBJECT_CLASS (e_table_specification_parent_class)->finalize (object);
}
static void
-etsp_class_init (ETableSpecificationClass *class)
+e_table_specification_class_init (ETableSpecificationClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -77,7 +78,7 @@ etsp_class_init (ETableSpecificationClass *class)
}
static void
-etsp_init (ETableSpecification *etsp)
+e_table_specification_init (ETableSpecification *etsp)
{
etsp->columns = NULL;
etsp->state = NULL;
diff --git a/e-util/e-table-subset-variable.c b/e-util/e-table-subset-variable.c
index 8d9f3d0c8d..4750f168fa 100644
--- a/e-util/e-table-subset-variable.c
+++ b/e-util/e-table-subset-variable.c
@@ -31,9 +31,10 @@
#define ETSSV_CLASS(e) (E_TABLE_SUBSET_VARIABLE_GET_CLASS (e))
-/* workaround for avoiding API breakage */
-#define etssv_get_type e_table_subset_variable_get_type
-G_DEFINE_TYPE (ETableSubsetVariable, etssv, E_TYPE_TABLE_SUBSET)
+G_DEFINE_TYPE (
+ ETableSubsetVariable,
+ e_table_subset_variable,
+ E_TYPE_TABLE_SUBSET)
#define INCREMENT_AMOUNT 10
@@ -86,12 +87,15 @@ etssv_add_all (ETableSubsetVariable *etssv)
{
ETableModel *etm = E_TABLE_MODEL (etssv);
ETableSubset *etss = E_TABLE_SUBSET (etssv);
+ ETableModel *source_model;
gint rows;
gint i;
e_table_model_pre_change (etm);
- rows = e_table_model_row_count (etss->source);
+ source_model = e_table_subset_get_source_model (etss);
+ rows = e_table_model_row_count (source_model);
+
if (etss->n_map + rows > etssv->n_vals_allocated) {
etssv->n_vals_allocated += MAX (INCREMENT_AMOUNT, rows);
etss->map_table = g_realloc (
@@ -129,7 +133,7 @@ etssv_remove (ETableSubsetVariable *etssv,
}
static void
-etssv_class_init (ETableSubsetVariableClass *class)
+e_table_subset_variable_class_init (ETableSubsetVariableClass *class)
{
class->add = etssv_add;
class->add_array = etssv_add_array;
@@ -138,7 +142,7 @@ etssv_class_init (ETableSubsetVariableClass *class)
}
static void
-etssv_init (ETableSubsetVariable *etssv)
+e_table_subset_variable_init (ETableSubsetVariable *etssv)
{
/* nothing to do */
}
diff --git a/e-util/e-table-subset.c b/e-util/e-table-subset.c
index 88532d03bd..92f71cedde 100644
--- a/e-util/e-table-subset.c
+++ b/e-util/e-table-subset.c
@@ -30,76 +30,63 @@
#include "e-table-subset.h"
-static void etss_proxy_model_pre_change_real
- (ETableSubset *etss,
- ETableModel *etm);
-static void etss_proxy_model_no_change_real (ETableSubset *etss,
- ETableModel *etm);
-static void etss_proxy_model_changed_real (ETableSubset *etss,
- ETableModel *etm);
-static void etss_proxy_model_row_changed_real
- (ETableSubset *etss,
- ETableModel *etm,
- gint row);
-static void etss_proxy_model_cell_changed_real
- (ETableSubset *etss,
- ETableModel *etm,
- gint col,
- gint row);
-static void etss_proxy_model_rows_inserted_real
- (ETableSubset *etss,
- ETableModel *etm,
- gint row,
- gint count);
-static void etss_proxy_model_rows_deleted_real
- (ETableSubset *etss,
- ETableModel *etm,
- gint row,
- gint count);
+#define E_TABLE_SUBSET_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_TABLE_SUBSET, ETableSubsetPrivate))
+
+#define VALID_ROW(table_subset, row) \
+ (row >= -1 && row < table_subset->n_map)
+#define MAP_ROW(table_subset, row) \
+ (row == -1 ? -1 : table_subset->map_table[row])
#define d(x)
-/* workaround for avoding API breakage */
-#define etss_get_type e_table_subset_get_type
-G_DEFINE_TYPE (ETableSubset, etss, E_TYPE_TABLE_MODEL)
+struct _ETableSubsetPrivate {
+ ETableModel *source_model;
+ gulong table_model_pre_change_handler_id;
+ gulong table_model_no_change_handler_id;
+ gulong table_model_changed_handler_id;
+ gulong table_model_row_changed_handler_id;
+ gulong table_model_cell_changed_handler_id;
+ gulong table_model_rows_inserted_handler_id;
+ gulong table_model_rows_deleted_handler_id;
-#define ETSS_CLASS(object) (E_TABLE_SUBSET_GET_CLASS(object))
+ gint last_access;
+};
-#define VALID_ROW(etss, row) (row >= -1 && row < etss->n_map)
-#define MAP_ROW(etss, row) (row == -1 ? -1 : etss->map_table[row])
+G_DEFINE_TYPE (ETableSubset, e_table_subset, E_TYPE_TABLE_MODEL)
static gint
-etss_get_view_row (ETableSubset *etss,
- gint row)
+table_subset_get_view_row (ETableSubset *table_subset,
+ gint row)
{
- const gint n = etss->n_map;
- const gint * const map_table = etss->map_table;
+ const gint n = table_subset->n_map;
+ const gint * const map_table = table_subset->map_table;
gint i;
- gint end = MIN (etss->n_map, etss->last_access + 10);
- gint start = MAX (0, etss->last_access - 10);
- gint initial = MAX (MIN (etss->last_access, end), start);
+ gint end = MIN (
+ table_subset->n_map,
+ table_subset->priv->last_access + 10);
+ gint start = MAX (0, table_subset->priv->last_access - 10);
+ gint initial = MAX (MIN (table_subset->priv->last_access, end), start);
for (i = initial; i < end; i++) {
if (map_table[i] == row) {
- d (g_print ("a) Found %d from %d\n", i, etss->last_access));
- etss->last_access = i;
+ table_subset->priv->last_access = i;
return i;
}
}
for (i = initial - 1; i >= start; i--) {
if (map_table[i] == row) {
- d (g_print ("b) Found %d from %d\n", i, etss->last_access));
- etss->last_access = i;
+ table_subset->priv->last_access = i;
return i;
}
}
for (i = 0; i < n; i++) {
if (map_table[i] == row) {
- d (g_print ("c) Found %d from %d\n", i, etss->last_access));
- etss->last_access = i;
+ table_subset->priv->last_access = i;
return i;
}
}
@@ -107,461 +94,572 @@ etss_get_view_row (ETableSubset *etss,
}
static void
-etss_dispose (GObject *object)
+table_subset_dispose (GObject *object)
{
- ETableSubset *etss = E_TABLE_SUBSET (object);
+ ETableSubsetPrivate *priv;
+
+ priv = E_TABLE_SUBSET_GET_PRIVATE (object);
- if (etss->source) {
+ if (priv->table_model_pre_change_handler_id > 0) {
g_signal_handler_disconnect (
- etss->source,
- etss->table_model_pre_change_id);
+ priv->source_model,
+ priv->table_model_pre_change_handler_id);
+ priv->table_model_pre_change_handler_id = 0;
+ }
+
+ if (priv->table_model_no_change_handler_id > 0) {
g_signal_handler_disconnect (
- etss->source,
- etss->table_model_no_change_id);
+ priv->source_model,
+ priv->table_model_no_change_handler_id);
+ priv->table_model_no_change_handler_id = 0;
+ }
+
+ if (priv->table_model_changed_handler_id > 0) {
g_signal_handler_disconnect (
- etss->source,
- etss->table_model_changed_id);
+ priv->source_model,
+ priv->table_model_changed_handler_id);
+ priv->table_model_changed_handler_id = 0;
+ }
+
+ if (priv->table_model_row_changed_handler_id > 0) {
g_signal_handler_disconnect (
- etss->source,
- etss->table_model_row_changed_id);
+ priv->source_model,
+ priv->table_model_row_changed_handler_id);
+ priv->table_model_row_changed_handler_id = 0;
+ }
+
+ if (priv->table_model_cell_changed_handler_id > 0) {
g_signal_handler_disconnect (
- etss->source,
- etss->table_model_cell_changed_id);
+ priv->source_model,
+ priv->table_model_cell_changed_handler_id);
+ priv->table_model_cell_changed_handler_id = 0;
+ }
+
+ if (priv->table_model_rows_inserted_handler_id > 0) {
g_signal_handler_disconnect (
- etss->source,
- etss->table_model_rows_inserted_id);
+ priv->source_model,
+ priv->table_model_rows_inserted_handler_id);
+ priv->table_model_rows_inserted_handler_id = 0;
+ }
+
+ if (priv->table_model_rows_deleted_handler_id > 0) {
g_signal_handler_disconnect (
- etss->source,
- etss->table_model_rows_deleted_id);
+ priv->source_model,
+ priv->table_model_rows_deleted_handler_id);
+ priv->table_model_rows_deleted_handler_id = 0;
+ }
- g_object_unref (etss->source);
- etss->source = NULL;
+ g_clear_object (&priv->source_model);
- etss->table_model_changed_id = 0;
- etss->table_model_row_changed_id = 0;
- etss->table_model_cell_changed_id = 0;
- etss->table_model_rows_inserted_id = 0;
- etss->table_model_rows_deleted_id = 0;
- }
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_table_subset_parent_class)->dispose (object);
+}
+
+static void
+table_subset_finalize (GObject *object)
+{
+ ETableSubset *table_subset;
+
+ table_subset = E_TABLE_SUBSET (object);
+
+ g_free (table_subset->map_table);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_table_subset_parent_class)->finalize (object);
+}
+
+static void
+table_subset_proxy_model_pre_change_real (ETableSubset *table_subset,
+ ETableModel *source_model)
+{
+ e_table_model_pre_change (E_TABLE_MODEL (table_subset));
+}
- G_OBJECT_CLASS (etss_parent_class)->dispose (object);
+static void
+table_subset_proxy_model_no_change_real (ETableSubset *table_subset,
+ ETableModel *source_model)
+{
+ e_table_model_no_change (E_TABLE_MODEL (table_subset));
+}
+
+static void
+table_subset_proxy_model_changed_real (ETableSubset *table_subset,
+ ETableModel *source_model)
+{
+ e_table_model_changed (E_TABLE_MODEL (table_subset));
+}
+
+static void
+table_subset_proxy_model_row_changed_real (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint row)
+{
+ gint view_row = table_subset_get_view_row (table_subset, row);
+
+ if (view_row != -1)
+ e_table_model_row_changed (
+ E_TABLE_MODEL (table_subset), view_row);
+ else
+ e_table_model_no_change (E_TABLE_MODEL (table_subset));
}
static void
-etss_finalize (GObject *object)
+table_subset_proxy_model_cell_changed_real (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint col,
+ gint row)
{
- ETableSubset *etss = E_TABLE_SUBSET (object);
+ gint view_row = table_subset_get_view_row (table_subset, row);
+
+ if (view_row != -1)
+ e_table_model_cell_changed (
+ E_TABLE_MODEL (table_subset), col, view_row);
+ else
+ e_table_model_no_change (E_TABLE_MODEL (table_subset));
+}
- g_free (etss->map_table);
- etss->map_table = NULL;
+static void
+table_subset_proxy_model_rows_inserted_real (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint row,
+ gint count)
+{
+ e_table_model_no_change (E_TABLE_MODEL (table_subset));
+}
- G_OBJECT_CLASS (etss_parent_class)->finalize (object);
+static void
+table_subset_proxy_model_rows_deleted_real (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint row,
+ gint count)
+{
+ e_table_model_no_change (E_TABLE_MODEL (table_subset));
}
static gint
-etss_column_count (ETableModel *etm)
+table_subset_column_count (ETableModel *table_model)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- return e_table_model_column_count (etss->source);
+ return e_table_model_column_count (table_subset->priv->source_model);
}
static gint
-etss_row_count (ETableModel *etm)
+table_subset_row_count (ETableModel *table_model)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- return etss->n_map;
+ return table_subset->n_map;
}
static gpointer
-etss_value_at (ETableModel *etm,
- gint col,
- gint row)
+table_subset_value_at (ETableModel *table_model,
+ gint col,
+ gint row)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
+
+ g_return_val_if_fail (VALID_ROW (table_subset, row), NULL);
- g_return_val_if_fail (VALID_ROW (etss, row), NULL);
+ table_subset->priv->last_access = row;
- etss->last_access = row;
- d (g_print ("g) Setting last_access to %d\n", row));
- return e_table_model_value_at (etss->source, col, MAP_ROW (etss, row));
+ return e_table_model_value_at (
+ table_subset->priv->source_model,
+ col, MAP_ROW (table_subset, row));
}
static void
-etss_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer val)
+table_subset_set_value_at (ETableModel *table_model,
+ gint col,
+ gint row,
+ gconstpointer val)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- g_return_if_fail (VALID_ROW (etss, row));
+ g_return_if_fail (VALID_ROW (table_subset, row));
- etss->last_access = row;
- d (g_print ("h) Setting last_access to %d\n", row));
- e_table_model_set_value_at (etss->source, col, MAP_ROW (etss, row), val);
+ table_subset->priv->last_access = row;
+
+ e_table_model_set_value_at (
+ table_subset->priv->source_model,
+ col, MAP_ROW (table_subset, row), val);
}
static gboolean
-etss_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
+table_subset_is_cell_editable (ETableModel *table_model,
+ gint col,
+ gint row)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- g_return_val_if_fail (VALID_ROW (etss, row), FALSE);
+ g_return_val_if_fail (VALID_ROW (table_subset, row), FALSE);
- return e_table_model_is_cell_editable (etss->source, col, MAP_ROW (etss, row));
+ return e_table_model_is_cell_editable (
+ table_subset->priv->source_model,
+ col, MAP_ROW (table_subset, row));
}
static gboolean
-etss_has_save_id (ETableModel *etm)
+table_subset_has_save_id (ETableModel *table_model)
{
return TRUE;
}
static gchar *
-etss_get_save_id (ETableModel *etm,
- gint row)
+table_subset_get_save_id (ETableModel *table_model,
+ gint row)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- g_return_val_if_fail (VALID_ROW (etss, row), NULL);
+ g_return_val_if_fail (VALID_ROW (table_subset, row), NULL);
- if (e_table_model_has_save_id (etss->source))
- return e_table_model_get_save_id (etss->source, MAP_ROW (etss, row));
+ if (e_table_model_has_save_id (table_subset->priv->source_model))
+ return e_table_model_get_save_id (
+ table_subset->priv->source_model,
+ MAP_ROW (table_subset, row));
else
- return g_strdup_printf ("%d", MAP_ROW (etss, row));
+ return g_strdup_printf ("%d", MAP_ROW (table_subset, row));
}
static void
-etss_append_row (ETableModel *etm,
- ETableModel *source,
- gint row)
+table_subset_append_row (ETableModel *table_model,
+ ETableModel *source,
+ gint row)
{
- ETableSubset *etss = (ETableSubset *) etm;
- e_table_model_append_row (etss->source, source, row);
+ ETableSubset *table_subset = (ETableSubset *) table_model;
+
+ e_table_model_append_row (
+ table_subset->priv->source_model, source, row);
}
static gpointer
-etss_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_subset_duplicate_value (ETableModel *table_model,
+ gint col,
+ gconstpointer value)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- return e_table_model_duplicate_value (etss->source, col, value);
+ return e_table_model_duplicate_value (
+ table_subset->priv->source_model, col, value);
}
static void
-etss_free_value (ETableModel *etm,
- gint col,
- gpointer value)
+table_subset_free_value (ETableModel *table_model,
+ gint col,
+ gpointer value)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- e_table_model_free_value (etss->source, col, value);
+ e_table_model_free_value (
+ table_subset->priv->source_model, col, value);
}
static gpointer
-etss_initialize_value (ETableModel *etm,
- gint col)
+table_subset_initialize_value (ETableModel *table_model,
+ gint col)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- return e_table_model_initialize_value (etss->source, col);
+ return e_table_model_initialize_value (
+ table_subset->priv->source_model, col);
}
static gboolean
-etss_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_subset_value_is_empty (ETableModel *table_model,
+ gint col,
+ gconstpointer value)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- return e_table_model_value_is_empty (etss->source, col, value);
+ return e_table_model_value_is_empty (
+ table_subset->priv->source_model, col, value);
}
static gchar *
-etss_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
+table_subset_value_to_string (ETableModel *table_model,
+ gint col,
+ gconstpointer value)
{
- ETableSubset *etss = (ETableSubset *) etm;
+ ETableSubset *table_subset = (ETableSubset *) table_model;
- return e_table_model_value_to_string (etss->source, col, value);
+ return e_table_model_value_to_string (
+ table_subset->priv->source_model, col, value);
}
static void
-etss_class_init (ETableSubsetClass *class)
-{
- ETableModelClass *table_class = E_TABLE_MODEL_CLASS (class);
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- object_class->dispose = etss_dispose;
- object_class->finalize = etss_finalize;
-
- table_class->column_count = etss_column_count;
- table_class->row_count = etss_row_count;
- table_class->append_row = etss_append_row;
-
- table_class->value_at = etss_value_at;
- table_class->set_value_at = etss_set_value_at;
- table_class->is_cell_editable = etss_is_cell_editable;
-
- table_class->has_save_id = etss_has_save_id;
- table_class->get_save_id = etss_get_save_id;
-
- table_class->duplicate_value = etss_duplicate_value;
- table_class->free_value = etss_free_value;
- table_class->initialize_value = etss_initialize_value;
- table_class->value_is_empty = etss_value_is_empty;
- table_class->value_to_string = etss_value_to_string;
-
- class->proxy_model_pre_change = etss_proxy_model_pre_change_real;
- class->proxy_model_no_change = etss_proxy_model_no_change_real;
- class->proxy_model_changed = etss_proxy_model_changed_real;
- class->proxy_model_row_changed = etss_proxy_model_row_changed_real;
- class->proxy_model_cell_changed = etss_proxy_model_cell_changed_real;
- class->proxy_model_rows_inserted = etss_proxy_model_rows_inserted_real;
- class->proxy_model_rows_deleted = etss_proxy_model_rows_deleted_real;
+e_table_subset_class_init (ETableSubsetClass *class)
+{
+ GObjectClass *object_class;
+ ETableModelClass *table_class;
+
+ g_type_class_add_private (class, sizeof (ETableSubsetPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = table_subset_dispose;
+ object_class->finalize = table_subset_finalize;
+
+ table_class = E_TABLE_MODEL_CLASS (class);
+ table_class->column_count = table_subset_column_count;
+ table_class->row_count = table_subset_row_count;
+ table_class->append_row = table_subset_append_row;
+ table_class->value_at = table_subset_value_at;
+ table_class->set_value_at = table_subset_set_value_at;
+ table_class->is_cell_editable = table_subset_is_cell_editable;
+ table_class->has_save_id = table_subset_has_save_id;
+ table_class->get_save_id = table_subset_get_save_id;
+ table_class->duplicate_value = table_subset_duplicate_value;
+ table_class->free_value = table_subset_free_value;
+ table_class->initialize_value = table_subset_initialize_value;
+ table_class->value_is_empty = table_subset_value_is_empty;
+ table_class->value_to_string = table_subset_value_to_string;
+
+ class->proxy_model_pre_change = table_subset_proxy_model_pre_change_real;
+ class->proxy_model_no_change = table_subset_proxy_model_no_change_real;
+ class->proxy_model_changed = table_subset_proxy_model_changed_real;
+ class->proxy_model_row_changed = table_subset_proxy_model_row_changed_real;
+ class->proxy_model_cell_changed = table_subset_proxy_model_cell_changed_real;
+ class->proxy_model_rows_inserted = table_subset_proxy_model_rows_inserted_real;
+ class->proxy_model_rows_deleted = table_subset_proxy_model_rows_deleted_real;
}
static void
-etss_init (ETableSubset *etss)
+e_table_subset_init (ETableSubset *table_subset)
{
- etss->last_access = 0;
+ table_subset->priv = E_TABLE_SUBSET_GET_PRIVATE (table_subset);
}
static void
-etss_proxy_model_pre_change_real (ETableSubset *etss,
- ETableModel *etm)
+table_subset_proxy_model_pre_change (ETableModel *source_model,
+ ETableSubset *table_subset)
{
- e_table_model_pre_change (E_TABLE_MODEL (etss));
-}
+ ETableSubsetClass *class;
-static void
-etss_proxy_model_no_change_real (ETableSubset *etss,
- ETableModel *etm)
-{
- e_table_model_no_change (E_TABLE_MODEL (etss));
-}
+ class = E_TABLE_SUBSET_GET_CLASS (table_subset);
-static void
-etss_proxy_model_changed_real (ETableSubset *etss,
- ETableModel *etm)
-{
- e_table_model_changed (E_TABLE_MODEL (etss));
+ if (class->proxy_model_pre_change != NULL)
+ class->proxy_model_pre_change (table_subset, source_model);
}
static void
-etss_proxy_model_row_changed_real (ETableSubset *etss,
- ETableModel *etm,
- gint row)
+table_subset_proxy_model_no_change (ETableModel *source_model,
+ ETableSubset *table_subset)
{
- gint view_row = etss_get_view_row (etss, row);
- if (view_row != -1)
- e_table_model_row_changed (E_TABLE_MODEL (etss), view_row);
- else
- e_table_model_no_change (E_TABLE_MODEL (etss));
-}
+ ETableSubsetClass *class;
-static void
-etss_proxy_model_cell_changed_real (ETableSubset *etss,
- ETableModel *etm,
- gint col,
- gint row)
-{
- gint view_row = etss_get_view_row (etss, row);
- if (view_row != -1)
- e_table_model_cell_changed (E_TABLE_MODEL (etss), col, view_row);
- else
- e_table_model_no_change (E_TABLE_MODEL (etss));
-}
+ class = E_TABLE_SUBSET_GET_CLASS (table_subset);
-static void
-etss_proxy_model_rows_inserted_real (ETableSubset *etss,
- ETableModel *etm,
- gint row,
- gint count)
-{
- e_table_model_no_change (E_TABLE_MODEL (etss));
+ if (class->proxy_model_no_change != NULL)
+ class->proxy_model_no_change (table_subset, source_model);
}
static void
-etss_proxy_model_rows_deleted_real (ETableSubset *etss,
- ETableModel *etm,
- gint row,
- gint count)
+table_subset_proxy_model_changed (ETableModel *source_model,
+ ETableSubset *table_subset)
{
- e_table_model_no_change (E_TABLE_MODEL (etss));
-}
+ ETableSubsetClass *class;
-static void
-etss_proxy_model_pre_change (ETableModel *etm,
- ETableSubset *etss)
-{
- if (ETSS_CLASS (etss)->proxy_model_pre_change)
- (ETSS_CLASS (etss)->proxy_model_pre_change) (etss, etm);
-}
+ class = E_TABLE_SUBSET_GET_CLASS (table_subset);
-static void
-etss_proxy_model_no_change (ETableModel *etm,
- ETableSubset *etss)
-{
- if (ETSS_CLASS (etss)->proxy_model_no_change)
- (ETSS_CLASS (etss)->proxy_model_no_change) (etss, etm);
+ if (class->proxy_model_changed != NULL)
+ class->proxy_model_changed (table_subset, source_model);
}
static void
-etss_proxy_model_changed (ETableModel *etm,
- ETableSubset *etss)
+table_subset_proxy_model_row_changed (ETableModel *source_model,
+ gint row,
+ ETableSubset *table_subset)
{
- if (ETSS_CLASS (etss)->proxy_model_changed)
- (ETSS_CLASS (etss)->proxy_model_changed) (etss, etm);
-}
+ ETableSubsetClass *class;
-static void
-etss_proxy_model_row_changed (ETableModel *etm,
- gint row,
- ETableSubset *etss)
-{
- if (ETSS_CLASS (etss)->proxy_model_row_changed)
- (ETSS_CLASS (etss)->proxy_model_row_changed) (etss, etm, row);
+ class = E_TABLE_SUBSET_GET_CLASS (table_subset);
+
+ if (class->proxy_model_row_changed != NULL)
+ class->proxy_model_row_changed (
+ table_subset, source_model, row);
}
static void
-etss_proxy_model_cell_changed (ETableModel *etm,
- gint col,
- gint row,
- ETableSubset *etss)
+table_subset_proxy_model_cell_changed (ETableModel *source_model,
+ gint col,
+ gint row,
+ ETableSubset *table_subset)
{
- if (ETSS_CLASS (etss)->proxy_model_cell_changed)
- (ETSS_CLASS (etss)->proxy_model_cell_changed) (etss, etm, col, row);
+ ETableSubsetClass *class;
+
+ class = E_TABLE_SUBSET_GET_CLASS (table_subset);
+
+ if (class->proxy_model_cell_changed != NULL)
+ class->proxy_model_cell_changed (
+ table_subset, source_model, col, row);
}
static void
-etss_proxy_model_rows_inserted (ETableModel *etm,
- gint row,
- gint col,
- ETableSubset *etss)
+table_subset_proxy_model_rows_inserted (ETableModel *source_model,
+ gint row,
+ gint col,
+ ETableSubset *table_subset)
{
- if (ETSS_CLASS (etss)->proxy_model_rows_inserted)
- (ETSS_CLASS (etss)->proxy_model_rows_inserted) (etss, etm, row, col);
+ ETableSubsetClass *class;
+
+ class = E_TABLE_SUBSET_GET_CLASS (table_subset);
+
+ if (class->proxy_model_rows_inserted != NULL)
+ class->proxy_model_rows_inserted (
+ table_subset, source_model, row, col);
}
static void
-etss_proxy_model_rows_deleted (ETableModel *etm,
- gint row,
- gint col,
- ETableSubset *etss)
+table_subset_proxy_model_rows_deleted (ETableModel *source_model,
+ gint row,
+ gint col,
+ ETableSubset *table_subset)
{
- if (ETSS_CLASS (etss)->proxy_model_rows_deleted)
- (ETSS_CLASS (etss)->proxy_model_rows_deleted) (etss, etm, row, col);
+ ETableSubsetClass *class;
+
+ class = E_TABLE_SUBSET_GET_CLASS (table_subset);
+
+ if (class->proxy_model_rows_deleted != NULL)
+ class->proxy_model_rows_deleted (
+ table_subset, source_model, row, col);
}
ETableModel *
-e_table_subset_construct (ETableSubset *etss,
- ETableModel *source,
+e_table_subset_construct (ETableSubset *table_subset,
+ ETableModel *source_model,
gint nvals)
{
- guint *buffer;
+ gulong handler_id;
+ guint *buffer = NULL;
gint i;
- if (nvals) {
+ if (nvals > 0)
buffer = (guint *) g_malloc (sizeof (guint) * nvals);
- if (buffer == NULL)
- return NULL;
- } else
- buffer = NULL;
- etss->map_table = (gint *) buffer;
- etss->n_map = nvals;
- etss->source = source;
- g_object_ref (source);
+ table_subset->map_table = (gint *) buffer;
+ table_subset->n_map = nvals;
+ table_subset->priv->source_model = g_object_ref (source_model);
/* Init */
for (i = 0; i < nvals; i++)
- etss->map_table[i] = i;
-
- etss->table_model_pre_change_id = g_signal_connect (
- source, "model_pre_change",
- G_CALLBACK (etss_proxy_model_pre_change), etss);
- etss->table_model_no_change_id = g_signal_connect (
- source, "model_no_change",
- G_CALLBACK (etss_proxy_model_no_change), etss);
- etss->table_model_changed_id = g_signal_connect (
- source, "model_changed",
- G_CALLBACK (etss_proxy_model_changed), etss);
- etss->table_model_row_changed_id = g_signal_connect (
- source, "model_row_changed",
- G_CALLBACK (etss_proxy_model_row_changed), etss);
- etss->table_model_cell_changed_id = g_signal_connect (
- source, "model_cell_changed",
- G_CALLBACK (etss_proxy_model_cell_changed), etss);
- etss->table_model_rows_inserted_id = g_signal_connect (
- source, "model_rows_inserted",
- G_CALLBACK (etss_proxy_model_rows_inserted), etss);
- etss->table_model_rows_deleted_id = g_signal_connect (
- source, "model_rows_deleted",
- G_CALLBACK (etss_proxy_model_rows_deleted), etss);
-
- return E_TABLE_MODEL (etss);
+ table_subset->map_table[i] = i;
+
+ handler_id = g_signal_connect (
+ source_model, "model_pre_change",
+ G_CALLBACK (table_subset_proxy_model_pre_change),
+ table_subset);
+ table_subset->priv->table_model_pre_change_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ source_model, "model_no_change",
+ G_CALLBACK (table_subset_proxy_model_no_change),
+ table_subset);
+ table_subset->priv->table_model_no_change_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ source_model, "model_changed",
+ G_CALLBACK (table_subset_proxy_model_changed),
+ table_subset);
+ table_subset->priv->table_model_changed_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ source_model, "model_row_changed",
+ G_CALLBACK (table_subset_proxy_model_row_changed),
+ table_subset);
+ table_subset->priv->table_model_row_changed_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ source_model, "model_cell_changed",
+ G_CALLBACK (table_subset_proxy_model_cell_changed),
+ table_subset);
+ table_subset->priv->table_model_cell_changed_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ source_model, "model_rows_inserted",
+ G_CALLBACK (table_subset_proxy_model_rows_inserted),
+ table_subset);
+ table_subset->priv->table_model_rows_inserted_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ source_model, "model_rows_deleted",
+ G_CALLBACK (table_subset_proxy_model_rows_deleted),
+ table_subset);
+ table_subset->priv->table_model_rows_deleted_handler_id = handler_id;
+
+ return E_TABLE_MODEL (table_subset);
}
ETableModel *
-e_table_subset_new (ETableModel *source,
+e_table_subset_new (ETableModel *source_model,
const gint nvals)
{
- ETableSubset *etss = g_object_new (E_TYPE_TABLE_SUBSET, NULL);
+ ETableSubset *table_subset;
+
+ g_return_val_if_fail (E_IS_TABLE_MODEL (source_model), NULL);
- if (e_table_subset_construct (etss, source, nvals) == NULL) {
- g_object_unref (etss);
+ table_subset = g_object_new (E_TYPE_TABLE_SUBSET, NULL);
+
+ if (e_table_subset_construct (table_subset, source_model, nvals) == NULL) {
+ g_object_unref (table_subset);
return NULL;
}
- return (ETableModel *) etss;
+ return (ETableModel *) table_subset;
+}
+
+ETableModel *
+e_table_subset_get_source_model (ETableSubset *table_subset)
+{
+ g_return_val_if_fail (E_IS_TABLE_SUBSET (table_subset), NULL);
+
+ return table_subset->priv->source_model;
}
gint
-e_table_subset_model_to_view_row (ETableSubset *ets,
+e_table_subset_model_to_view_row (ETableSubset *table_subset,
gint model_row)
{
gint i;
- for (i = 0; i < ets->n_map; i++) {
- if (ets->map_table[i] == model_row)
+
+ g_return_val_if_fail (E_IS_TABLE_SUBSET (table_subset), -1);
+
+ for (i = 0; i < table_subset->n_map; i++) {
+ if (table_subset->map_table[i] == model_row)
return i;
}
return -1;
}
gint
-e_table_subset_view_to_model_row (ETableSubset *ets,
+e_table_subset_view_to_model_row (ETableSubset *table_subset,
gint view_row)
{
- if (view_row >= 0 && view_row < ets->n_map)
- return ets->map_table[view_row];
+ g_return_val_if_fail (E_IS_TABLE_SUBSET (table_subset), -1);
+
+ if (view_row >= 0 && view_row < table_subset->n_map)
+ return table_subset->map_table[view_row];
else
return -1;
}
ETableModel *
-e_table_subset_get_toplevel (ETableSubset *table)
+e_table_subset_get_toplevel (ETableSubset *table_subset)
{
- g_return_val_if_fail (table != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL);
+ g_return_val_if_fail (E_IS_TABLE_SUBSET (table_subset), NULL);
- if (E_IS_TABLE_SUBSET (table->source))
- return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source));
+ if (E_IS_TABLE_SUBSET (table_subset->priv->source_model))
+ return e_table_subset_get_toplevel (
+ E_TABLE_SUBSET (table_subset->priv->source_model));
else
- return table->source;
+ return table_subset->priv->source_model;
}
void
-e_table_subset_print_debugging (ETableSubset *table_model)
+e_table_subset_print_debugging (ETableSubset *table_subset)
{
gint i;
- for (i = 0; i < table_model->n_map; i++) {
- g_print ("%8d\n", table_model->map_table[i]);
+
+ g_return_if_fail (E_IS_TABLE_SUBSET (table_subset));
+
+ for (i = 0; i < table_subset->n_map; i++) {
+ g_print ("%8d\n", table_subset->map_table[i]);
}
}
diff --git a/e-util/e-table-subset.h b/e-util/e-table-subset.h
index 9e8d69496d..fc954f820c 100644
--- a/e-util/e-table-subset.h
+++ b/e-util/e-table-subset.h
@@ -26,8 +26,8 @@
#error "Only <e-util/e-util.h> should be included directly."
#endif
-#ifndef _E_TABLE_SUBSET_H_
-#define _E_TABLE_SUBSET_H_
+#ifndef E_TABLE_SUBSET_H
+#define E_TABLE_SUBSET_H
#include <e-util/e-table-model.h>
@@ -54,67 +54,66 @@ G_BEGIN_DECLS
typedef struct _ETableSubset ETableSubset;
typedef struct _ETableSubsetClass ETableSubsetClass;
+typedef struct _ETableSubsetPrivate ETableSubsetPrivate;
struct _ETableSubset {
ETableModel parent;
+ ETableSubsetPrivate *priv;
- ETableModel *source;
+ /* protected - subclasses modify this directly */
gint n_map;
gint *map_table;
-
- gint last_access;
-
- gint table_model_pre_change_id;
- gint table_model_no_change_id;
- gint table_model_changed_id;
- gint table_model_row_changed_id;
- gint table_model_cell_changed_id;
- gint table_model_rows_inserted_id;
- gint table_model_rows_deleted_id;
};
struct _ETableSubsetClass {
ETableModelClass parent_class;
- void (*proxy_model_pre_change) (ETableSubset *etss,
- ETableModel *etm);
- void (*proxy_model_no_change) (ETableSubset *etss,
- ETableModel *etm);
- void (*proxy_model_changed) (ETableSubset *etss,
- ETableModel *etm);
- void (*proxy_model_row_changed) (ETableSubset *etss,
- ETableModel *etm,
- gint row);
- void (*proxy_model_cell_changed) (ETableSubset *etss,
- ETableModel *etm,
- gint col,
- gint row);
- void (*proxy_model_rows_inserted) (ETableSubset *etss,
- ETableModel *etm,
- gint row,
- gint count);
- void (*proxy_model_rows_deleted) (ETableSubset *etss,
- ETableModel *etm,
- gint row,
- gint count);
+ void (*proxy_model_pre_change)
+ (ETableSubset *table_subset,
+ ETableModel *source_model);
+ void (*proxy_model_no_change)
+ (ETableSubset *table_subset,
+ ETableModel *source_model);
+ void (*proxy_model_changed) (ETableSubset *table_subset,
+ ETableModel *source_model);
+ void (*proxy_model_row_changed)
+ (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint row);
+ void (*proxy_model_cell_changed)
+ (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint col,
+ gint row);
+ void (*proxy_model_rows_inserted)
+ (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint row,
+ gint count);
+ void (*proxy_model_rows_deleted)
+ (ETableSubset *table_subset,
+ ETableModel *source_model,
+ gint row,
+ gint count);
};
GType e_table_subset_get_type (void) G_GNUC_CONST;
-ETableModel * e_table_subset_new (ETableModel *etm,
+ETableModel * e_table_subset_new (ETableModel *source_model,
gint n_vals);
-ETableModel * e_table_subset_construct (ETableSubset *ets,
- ETableModel *source,
+ETableModel * e_table_subset_construct (ETableSubset *table_subset,
+ ETableModel *source_model,
gint nvals);
+ETableModel * e_table_subset_get_source_model (ETableSubset *table_subset);
gint e_table_subset_model_to_view_row
- (ETableSubset *ets,
+ (ETableSubset *table_subset,
gint model_row);
gint e_table_subset_view_to_model_row
- (ETableSubset *ets,
+ (ETableSubset *table_subset,
gint view_row);
-ETableModel * e_table_subset_get_toplevel (ETableSubset *table_model);
-void e_table_subset_print_debugging (ETableSubset *table_model);
+ETableModel * e_table_subset_get_toplevel (ETableSubset *table_subset);
+void e_table_subset_print_debugging (ETableSubset *table_subset);
G_END_DECLS
-#endif /* _E_TABLE_SUBSET_H_ */
+#endif /* E_TABLE_SUBSET_H */
diff --git a/e-util/e-table-without.c b/e-util/e-table-without.c
index 7139ad15df..8e72747759 100644
--- a/e-util/e-table-without.c
+++ b/e-util/e-table-without.c
@@ -34,9 +34,7 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_TABLE_WITHOUT, ETableWithoutPrivate))
-/* workaround for avoiding API breakage */
-#define etw_get_type e_table_without_get_type
-G_DEFINE_TYPE (ETableWithout, etw, E_TYPE_TABLE_SUBSET)
+G_DEFINE_TYPE (ETableWithout, e_table_without, E_TYPE_TABLE_SUBSET)
#define INCREMENT_AMOUNT 10
@@ -61,9 +59,13 @@ check (ETableWithout *etw,
gboolean ret_val;
gpointer key;
ETableSubset *etss = E_TABLE_SUBSET (etw);
+ ETableModel *source_model;
+
+ source_model = e_table_subset_get_source_model (etss);
if (etw->priv->get_key_func)
- key = etw->priv->get_key_func (etss->source, model_row, etw->priv->closure);
+ key = etw->priv->get_key_func (
+ source_model, model_row, etw->priv->closure);
else
key = GINT_TO_POINTER (model_row);
ret_val = (g_hash_table_lookup (etw->priv->hash, key) != NULL);
@@ -80,9 +82,13 @@ check_with_key (ETableWithout *etw,
gboolean ret_val;
gpointer key2;
ETableSubset *etss = E_TABLE_SUBSET (etw);
+ ETableModel *source_model;
+
+ source_model = e_table_subset_get_source_model (etss);
if (etw->priv->get_key_func)
- key2 = etw->priv->get_key_func (etss->source, model_row, etw->priv->closure);
+ key2 = etw->priv->get_key_func (
+ source_model, model_row, etw->priv->closure);
else
key2 = GINT_TO_POINTER (model_row);
if (etw->priv->compare_func)
@@ -156,7 +162,7 @@ etw_dispose (GObject *object)
}
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (etw_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_table_without_parent_class)->dispose (object);
}
static void
@@ -236,12 +242,12 @@ etw_proxy_model_changed (ETableSubset *etss,
}
etss->n_map = j;
- if (E_TABLE_SUBSET_CLASS (etw_parent_class)->proxy_model_changed)
- E_TABLE_SUBSET_CLASS (etw_parent_class)->proxy_model_changed (etss, etm);
+ if (E_TABLE_SUBSET_CLASS (e_table_without_parent_class)->proxy_model_changed)
+ E_TABLE_SUBSET_CLASS (e_table_without_parent_class)->proxy_model_changed (etss, etm);
}
static void
-etw_class_init (ETableWithoutClass *class)
+e_table_without_class_init (ETableWithoutClass *class)
{
GObjectClass *object_class;
ETableSubsetClass *etss_class;
@@ -258,7 +264,7 @@ etw_class_init (ETableWithoutClass *class)
}
static void
-etw_init (ETableWithout *etw)
+e_table_without_init (ETableWithout *etw)
{
etw->priv = E_TABLE_WITHOUT_GET_PRIVATE (etw);
}
@@ -363,10 +369,12 @@ e_table_without_show (ETableWithout *etw,
{
gint i; /* Model row */
ETableSubset *etss = E_TABLE_SUBSET (etw);
+ ETableModel *source_model;
gint count;
gpointer old_key;
- count = e_table_model_row_count (etss->source);
+ source_model = e_table_subset_get_source_model (etss);
+ count = e_table_model_row_count (source_model);
for (i = 0; i < count; i++) {
if (check_with_key (etw, key, i)) {
@@ -388,6 +396,7 @@ e_table_without_show_all (ETableWithout *etw)
gint i; /* Model row */
gint row_count;
ETableSubset *etss = E_TABLE_SUBSET (etw);
+ ETableModel *source_model;
e_table_model_pre_change (E_TABLE_MODEL (etw));
@@ -399,7 +408,9 @@ e_table_without_show_all (ETableWithout *etw)
etw->priv->hash = g_hash_table_new (
etw->priv->hash_func, etw->priv->compare_func);
- row_count = e_table_model_row_count (E_TABLE_MODEL (etss->source));
+ source_model = e_table_subset_get_source_model (etss);
+ row_count = e_table_model_row_count (source_model);
+
g_free (etss->map_table);
etss->map_table = g_new (int, row_count);
diff --git a/e-util/e-tree-model.h b/e-util/e-tree-model.h
index 5162dab0ac..c6ed8c8799 100644
--- a/e-util/e-tree-model.h
+++ b/e-util/e-tree-model.h
@@ -23,7 +23,7 @@
#ifndef E_TREE_MODEL_H
#define E_TREE_MODEL_H
-#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib-object.h>
/* Standard GObject macros */
#define E_TYPE_TREE_MODEL \
@@ -50,7 +50,7 @@ typedef gboolean (*ETreePathFunc) (ETreeModel *tree_model,
gpointer data);
struct _ETreeModelInterface {
- GTypeInterface parent_class;
+ GTypeInterface parent_interface;
ETreePath (*get_root) (ETreeModel *tree_model);
diff --git a/e-util/e-tree-table-adapter.c b/e-util/e-tree-table-adapter.c
index 89110ea5e3..2950d60a33 100644
--- a/e-util/e-tree-table-adapter.c
+++ b/e-util/e-tree-table-adapter.c
@@ -45,20 +45,10 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_TREE_TABLE_ADAPTER, ETreeTableAdapterPrivate))
-/* workaround for avoiding API breakage */
-#define etta_get_type e_tree_table_adapter_get_type
-G_DEFINE_TYPE (ETreeTableAdapter, etta, E_TYPE_TABLE_MODEL)
#define d(x)
#define INCREMENT_AMOUNT 100
-enum {
- SORTING_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0, };
-
typedef struct {
ETreePath path;
guint32 num_visible_children;
@@ -98,7 +88,21 @@ struct _ETreeTableAdapterPrivate {
gint force_expanded_state; /* use this instead of model's default if not 0; <0 ... collapse, >0 ... expand */
};
-static void etta_sort_info_changed (ETableSortInfo *sort_info, ETreeTableAdapter *etta);
+static void tree_table_adapter_sort_info_changed
+ (ETableSortInfo *sort_info,
+ ETreeTableAdapter *etta);
+
+enum {
+ SORTING_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE (
+ ETreeTableAdapter,
+ e_tree_table_adapter,
+ E_TYPE_TABLE_MODEL)
static GNode *
lookup_gnode (ETreeTableAdapter *etta,
@@ -534,32 +538,7 @@ update_node (ETreeTableAdapter *etta,
}
static void
-etta_finalize (GObject *object)
-{
- ETreeTableAdapterPrivate *priv;
-
- priv = E_TREE_TABLE_ADAPTER_GET_PRIVATE (object);
-
- if (priv->resort_idle_id) {
- g_source_remove (priv->resort_idle_id);
- priv->resort_idle_id = 0;
- }
-
- if (priv->root) {
- kill_gnode (priv->root, E_TREE_TABLE_ADAPTER (object));
- priv->root = NULL;
- }
-
- g_hash_table_destroy (priv->nodes);
-
- g_free (priv->map_table);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (etta_parent_class)->finalize (object);
-}
-
-static void
-etta_dispose (GObject *object)
+tree_table_adapter_dispose (GObject *object)
{
ETreeTableAdapterPrivate *priv;
@@ -596,11 +575,36 @@ etta_dispose (GObject *object)
}
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (etta_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_tree_table_adapter_parent_class)->dispose (object);
+}
+
+static void
+tree_table_adapter_finalize (GObject *object)
+{
+ ETreeTableAdapterPrivate *priv;
+
+ priv = E_TREE_TABLE_ADAPTER_GET_PRIVATE (object);
+
+ if (priv->resort_idle_id) {
+ g_source_remove (priv->resort_idle_id);
+ priv->resort_idle_id = 0;
+ }
+
+ if (priv->root) {
+ kill_gnode (priv->root, E_TREE_TABLE_ADAPTER (object));
+ priv->root = NULL;
+ }
+
+ g_hash_table_destroy (priv->nodes);
+
+ g_free (priv->map_table);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_tree_table_adapter_parent_class)->finalize (object);
}
static gint
-etta_column_count (ETableModel *etm)
+tree_table_adapter_column_count (ETableModel *etm)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -608,14 +612,14 @@ etta_column_count (ETableModel *etm)
}
static gboolean
-etta_has_save_id (ETableModel *etm)
+tree_table_adapter_has_save_id (ETableModel *etm)
{
return TRUE;
}
static gchar *
-etta_get_save_id (ETableModel *etm,
- gint row)
+tree_table_adapter_get_save_id (ETableModel *etm,
+ gint row)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -623,7 +627,7 @@ etta_get_save_id (ETableModel *etm,
}
static gint
-etta_row_count (ETableModel *etm)
+tree_table_adapter_row_count (ETableModel *etm)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -631,9 +635,9 @@ etta_row_count (ETableModel *etm)
}
static gpointer
-etta_value_at (ETableModel *etm,
- gint col,
- gint row)
+tree_table_adapter_value_at (ETableModel *etm,
+ gint col,
+ gint row)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -652,33 +656,33 @@ etta_value_at (ETableModel *etm,
}
static void
-etta_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer val)
+tree_table_adapter_set_value_at (ETableModel *etm,
+ gint col,
+ gint row,
+ gconstpointer val)
{
g_warn_if_reached ();
}
static gboolean
-etta_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
+tree_table_adapter_is_cell_editable (ETableModel *etm,
+ gint col,
+ gint row)
{
return FALSE;
}
static void
-etta_append_row (ETableModel *etm,
- ETableModel *source,
- gint row)
+tree_table_adapter_append_row (ETableModel *etm,
+ ETableModel *source,
+ gint row)
{
}
static gpointer
-etta_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
+tree_table_adapter_duplicate_value (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -686,9 +690,9 @@ etta_duplicate_value (ETableModel *etm,
}
static void
-etta_free_value (ETableModel *etm,
- gint col,
- gpointer value)
+tree_table_adapter_free_value (ETableModel *etm,
+ gint col,
+ gpointer value)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -696,8 +700,8 @@ etta_free_value (ETableModel *etm,
}
static gpointer
-etta_initialize_value (ETableModel *etm,
- gint col)
+tree_table_adapter_initialize_value (ETableModel *etm,
+ gint col)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -705,9 +709,9 @@ etta_initialize_value (ETableModel *etm,
}
static gboolean
-etta_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
+tree_table_adapter_value_is_empty (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -715,9 +719,9 @@ etta_value_is_empty (ETableModel *etm,
}
static gchar *
-etta_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
+tree_table_adapter_value_to_string (ETableModel *etm,
+ gint col,
+ gconstpointer value)
{
ETreeTableAdapter *etta = (ETreeTableAdapter *) etm;
@@ -725,7 +729,7 @@ etta_value_to_string (ETableModel *etm,
}
static void
-etta_class_init (ETreeTableAdapterClass *class)
+e_tree_table_adapter_class_init (ETreeTableAdapterClass *class)
{
GObjectClass *object_class;
ETableModelClass *table_model_class;
@@ -733,26 +737,26 @@ etta_class_init (ETreeTableAdapterClass *class)
g_type_class_add_private (class, sizeof (ETreeTableAdapterPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->dispose = etta_dispose;
- object_class->finalize = etta_finalize;
+ object_class->dispose = tree_table_adapter_dispose;
+ object_class->finalize = tree_table_adapter_finalize;
table_model_class = E_TABLE_MODEL_CLASS (class);
- table_model_class->column_count = etta_column_count;
- table_model_class->row_count = etta_row_count;
- table_model_class->append_row = etta_append_row;
+ table_model_class->column_count = tree_table_adapter_column_count;
+ table_model_class->row_count = tree_table_adapter_row_count;
+ table_model_class->append_row = tree_table_adapter_append_row;
- table_model_class->value_at = etta_value_at;
- table_model_class->set_value_at = etta_set_value_at;
- table_model_class->is_cell_editable = etta_is_cell_editable;
+ table_model_class->value_at = tree_table_adapter_value_at;
+ table_model_class->set_value_at = tree_table_adapter_set_value_at;
+ table_model_class->is_cell_editable = tree_table_adapter_is_cell_editable;
- table_model_class->has_save_id = etta_has_save_id;
- table_model_class->get_save_id = etta_get_save_id;
+ table_model_class->has_save_id = tree_table_adapter_has_save_id;
+ table_model_class->get_save_id = tree_table_adapter_get_save_id;
- table_model_class->duplicate_value = etta_duplicate_value;
- table_model_class->free_value = etta_free_value;
- table_model_class->initialize_value = etta_initialize_value;
- table_model_class->value_is_empty = etta_value_is_empty;
- table_model_class->value_to_string = etta_value_to_string;
+ table_model_class->duplicate_value = tree_table_adapter_duplicate_value;
+ table_model_class->free_value = tree_table_adapter_free_value;
+ table_model_class->initialize_value = tree_table_adapter_initialize_value;
+ table_model_class->value_is_empty = tree_table_adapter_value_is_empty;
+ table_model_class->value_to_string = tree_table_adapter_value_to_string;
class->sorting_changed = NULL;
@@ -768,7 +772,7 @@ etta_class_init (ETreeTableAdapterClass *class)
}
static void
-etta_init (ETreeTableAdapter *etta)
+e_tree_table_adapter_init (ETreeTableAdapter *etta)
{
etta->priv = E_TREE_TABLE_ADAPTER_GET_PRIVATE (etta);
@@ -777,15 +781,15 @@ etta_init (ETreeTableAdapter *etta)
}
static void
-etta_proxy_pre_change (ETreeModel *etm,
- ETreeTableAdapter *etta)
+tree_table_adapter_proxy_pre_change (ETreeModel *etm,
+ ETreeTableAdapter *etta)
{
e_table_model_pre_change (E_TABLE_MODEL (etta));
}
static void
-etta_proxy_rebuilt (ETreeModel *etm,
- ETreeTableAdapter *etta)
+tree_table_adapter_proxy_rebuilt (ETreeModel *etm,
+ ETreeTableAdapter *etta)
{
if (!etta->priv->root)
return;
@@ -798,15 +802,15 @@ etta_proxy_rebuilt (ETreeModel *etm,
static gboolean
resort_model (ETreeTableAdapter *etta)
{
- etta_sort_info_changed (NULL, etta);
+ tree_table_adapter_sort_info_changed (NULL, etta);
etta->priv->resort_idle_id = 0;
return FALSE;
}
static void
-etta_proxy_node_changed (ETreeModel *etm,
- ETreePath path,
- ETreeTableAdapter *etta)
+tree_table_adapter_proxy_node_changed (ETreeModel *etm,
+ ETreePath path,
+ ETreeTableAdapter *etta)
{
update_node (etta, path);
e_table_model_changed (E_TABLE_MODEL (etta));
@@ -819,9 +823,9 @@ etta_proxy_node_changed (ETreeModel *etm,
}
static void
-etta_proxy_node_data_changed (ETreeModel *etm,
- ETreePath path,
- ETreeTableAdapter *etta)
+tree_table_adapter_proxy_node_data_changed (ETreeModel *etm,
+ ETreePath path,
+ ETreeTableAdapter *etta)
{
gint row = get_row (etta, path);
@@ -834,10 +838,10 @@ etta_proxy_node_data_changed (ETreeModel *etm,
}
static void
-etta_proxy_node_inserted (ETreeModel *etm,
- ETreePath parent,
- ETreePath child,
- ETreeTableAdapter *etta)
+tree_table_adapter_proxy_node_inserted (ETreeModel *etm,
+ ETreePath parent,
+ ETreePath child,
+ ETreeTableAdapter *etta)
{
if (e_tree_model_node_is_root (etm, child))
generate_tree (etta, child);
@@ -848,19 +852,19 @@ etta_proxy_node_inserted (ETreeModel *etm,
}
static void
-etta_proxy_node_removed (ETreeModel *etm,
- ETreePath parent,
- ETreePath child,
- gint old_position,
- ETreeTableAdapter *etta)
+tree_table_adapter_proxy_node_removed (ETreeModel *etm,
+ ETreePath parent,
+ ETreePath child,
+ gint old_position,
+ ETreeTableAdapter *etta)
{
delete_node (etta, parent, child);
e_table_model_changed (E_TABLE_MODEL (etta));
}
static void
-etta_sort_info_changed (ETableSortInfo *sort_info,
- ETreeTableAdapter *etta)
+tree_table_adapter_sort_info_changed (ETableSortInfo *sort_info,
+ ETreeTableAdapter *etta)
{
if (!etta->priv->root)
return;
@@ -898,7 +902,8 @@ e_tree_table_adapter_construct (ETreeTableAdapter *etta,
g_object_ref (sort_info);
etta->priv->sort_info_changed_id = g_signal_connect (
sort_info, "sort_info_changed",
- G_CALLBACK (etta_sort_info_changed), etta);
+ G_CALLBACK (tree_table_adapter_sort_info_changed),
+ etta);
}
etta->priv->header = header;
@@ -914,22 +919,22 @@ e_tree_table_adapter_construct (ETreeTableAdapter *etta,
etta->priv->pre_change_id = g_signal_connect (
source, "pre_change",
- G_CALLBACK (etta_proxy_pre_change), etta);
+ G_CALLBACK (tree_table_adapter_proxy_pre_change), etta);
etta->priv->rebuilt_id = g_signal_connect (
source, "rebuilt",
- G_CALLBACK (etta_proxy_rebuilt), etta);
+ G_CALLBACK (tree_table_adapter_proxy_rebuilt), etta);
etta->priv->node_changed_id = g_signal_connect (
source, "node_changed",
- G_CALLBACK (etta_proxy_node_changed), etta);
+ G_CALLBACK (tree_table_adapter_proxy_node_changed), etta);
etta->priv->node_data_changed_id = g_signal_connect (
source, "node_data_changed",
- G_CALLBACK (etta_proxy_node_data_changed), etta);
+ G_CALLBACK (tree_table_adapter_proxy_node_data_changed), etta);
etta->priv->node_inserted_id = g_signal_connect (
source, "node_inserted",
- G_CALLBACK (etta_proxy_node_inserted), etta);
+ G_CALLBACK (tree_table_adapter_proxy_node_inserted), etta);
etta->priv->node_removed_id = g_signal_connect (
source, "node_removed",
- G_CALLBACK (etta_proxy_node_removed), etta);
+ G_CALLBACK (tree_table_adapter_proxy_node_removed), etta);
return E_TABLE_MODEL (etta);
}
@@ -1309,7 +1314,8 @@ e_tree_table_adapter_set_sort_info (ETreeTableAdapter *etta,
g_object_ref (sort_info);
etta->priv->sort_info_changed_id = g_signal_connect (
sort_info, "sort_info_changed",
- G_CALLBACK (etta_sort_info_changed), etta);
+ G_CALLBACK (tree_table_adapter_sort_info_changed),
+ etta);
}
if (!etta->priv->root)
diff --git a/e-util/gal-define-views-model.c b/e-util/gal-define-views-model.c
index 8d8dd519a5..14bdac636f 100644
--- a/e-util/gal-define-views-model.c
+++ b/e-util/gal-define-views-model.c
@@ -32,17 +32,17 @@
#include "gal-define-views-model.h"
-G_DEFINE_TYPE (
- GalDefineViewsModel,
- gal_define_views_model,
- E_TYPE_TABLE_MODEL)
-
enum {
PROP_0,
PROP_EDITABLE,
PROP_COLLECTION
};
+G_DEFINE_TYPE (
+ GalDefineViewsModel,
+ gal_define_views_model,
+ E_TYPE_TABLE_MODEL)
+
static void
gal_define_views_model_set_property (GObject *object,
guint property_id,
@@ -126,6 +126,13 @@ gdvm_row_count (ETableModel *etc)
return 0;
}
+static void
+gdvm_append_row (ETableModel *etm,
+ ETableModel *source,
+ gint row)
+{
+}
+
/* This function returns the value at a particular point in our ETableModel. */
static gpointer
gdvm_value_at (ETableModel *etc,
@@ -170,13 +177,6 @@ gdvm_is_cell_editable (ETableModel *etc,
return GAL_DEFINE_VIEWS_MODEL (etc)->editable;
}
-static void
-gdvm_append_row (ETableModel *etm,
- ETableModel *source,
- gint row)
-{
-}
-
/* This function duplicates the value passed to it. */
static gpointer
gdvm_duplicate_value (ETableModel *etc,