diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-18 23:54:15 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-19 08:32:06 +0800 |
commit | 78c9f356f97f0b40cbd3ad730b8931f75d0649a2 (patch) | |
tree | c2cef75d392b1deae3cfc44c3d6bb7b43c417d70 | |
parent | c6ccd45a0ef07b12a0313deb3abee032d89eec0a (diff) | |
download | gsoc2013-evolution-78c9f356f97f0b40cbd3ad730b8931f75d0649a2.tar gsoc2013-evolution-78c9f356f97f0b40cbd3ad730b8931f75d0649a2.tar.gz gsoc2013-evolution-78c9f356f97f0b40cbd3ad730b8931f75d0649a2.tar.bz2 gsoc2013-evolution-78c9f356f97f0b40cbd3ad730b8931f75d0649a2.tar.lz gsoc2013-evolution-78c9f356f97f0b40cbd3ad730b8931f75d0649a2.tar.xz gsoc2013-evolution-78c9f356f97f0b40cbd3ad730b8931f75d0649a2.tar.zst gsoc2013-evolution-78c9f356f97f0b40cbd3ad730b8931f75d0649a2.zip |
Convert ETableModel to an interface.
Similar to what was recently done to ETreeModel.
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.c | 41 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.h | 4 | ||||
-rw-r--r-- | calendar/gui/e-cal-model-calendar.c | 56 | ||||
-rw-r--r-- | calendar/gui/e-cal-model-memos.c | 58 | ||||
-rw-r--r-- | calendar/gui/e-cal-model-tasks.c | 60 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.c | 46 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.h | 4 | ||||
-rw-r--r-- | e-util/e-table-memory-store.c | 39 | ||||
-rw-r--r-- | e-util/e-table-memory.c | 19 | ||||
-rw-r--r-- | e-util/e-table-memory.h | 4 | ||||
-rw-r--r-- | e-util/e-table-model.c | 151 | ||||
-rw-r--r-- | e-util/e-table-model.h | 22 | ||||
-rw-r--r-- | e-util/e-table-one.c | 39 | ||||
-rw-r--r-- | e-util/e-table-one.h | 4 | ||||
-rw-r--r-- | e-util/e-table-subset.c | 49 | ||||
-rw-r--r-- | e-util/e-table-subset.h | 4 | ||||
-rw-r--r-- | e-util/e-tree-table-adapter.c | 53 | ||||
-rw-r--r-- | e-util/e-tree-table-adapter.h | 4 | ||||
-rw-r--r-- | e-util/gal-define-views-model.c | 49 | ||||
-rw-r--r-- | e-util/gal-define-views-model.h | 4 |
20 files changed, 415 insertions, 295 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index 7a7dd4d69b..ee1ba7c75b 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -49,10 +49,17 @@ struct _EAddressbookTableAdapterPrivate { GHashTable *emails; }; -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_addressbook_table_adapter_table_model_init + (ETableModelInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( EAddressbookTableAdapter, e_addressbook_table_adapter, - E_TYPE_TABLE_MODEL) + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_addressbook_table_adapter_table_model_init)) static void unlink_model (EAddressbookTableAdapter *adapter) @@ -308,26 +315,30 @@ static void e_addressbook_table_adapter_class_init (EAddressbookTableAdapterClass *class) { GObjectClass *object_class; - ETableModelClass *model_class; g_type_class_add_private ( class, sizeof (EAddressbookTableAdapterPrivate)); object_class = G_OBJECT_CLASS (class); object_class->finalize = addressbook_finalize; +} - 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->duplicate_value = addressbook_duplicate_value; - model_class->free_value = addressbook_free_value; - model_class->initialize_value = addressbook_initialize_value; - model_class->value_is_empty = addressbook_value_is_empty; - model_class->value_to_string = addressbook_value_to_string; +static void +e_addressbook_table_adapter_table_model_init (ETableModelInterface *interface) +{ + interface->column_count = addressbook_col_count; + interface->row_count = addressbook_row_count; + interface->append_row = addressbook_append_row; + + interface->value_at = addressbook_value_at; + interface->set_value_at = addressbook_set_value_at; + interface->is_cell_editable = addressbook_is_cell_editable; + + interface->duplicate_value = addressbook_duplicate_value; + interface->free_value = addressbook_free_value; + interface->initialize_value = addressbook_initialize_value; + interface->value_is_empty = addressbook_value_is_empty; + interface->value_to_string = addressbook_value_to_string; } static void diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.h b/addressbook/gui/widgets/e-addressbook-table-adapter.h index 4b089b2d0a..93b7ae9553 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.h +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.h @@ -49,12 +49,12 @@ typedef struct _EAddressbookTableAdapterClass EAddressbookTableAdapterClass; typedef struct _EAddressbookTableAdapterPrivate EAddressbookTableAdapterPrivate; struct _EAddressbookTableAdapter { - ETableModel parent; + GObject parent; EAddressbookTableAdapterPrivate *priv; }; struct _EAddressbookTableAdapterClass { - ETableModelClass parent_class; + GObjectClass parent_class; }; GType e_addressbook_table_adapter_get_type diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c index 114ffd4a7e..cc1e5a46e0 100644 --- a/calendar/gui/e-cal-model-calendar.c +++ b/calendar/gui/e-cal-model-calendar.c @@ -35,10 +35,19 @@ #include "dialogs/recur-comp.h" #include "dialogs/send-comp.h" -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_cal_model_calendar_table_model_init + (ETableModelInterface *interface); + +static ETableModelInterface *table_model_parent_interface; + +G_DEFINE_TYPE_WITH_CODE ( ECalModelCalendar, e_cal_model_calendar, - E_TYPE_CAL_MODEL) + E_TYPE_CAL_MODEL, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_cal_model_calendar_table_model_init)) static ECellDateEditValue * get_dtend (ECalModelCalendar *model, @@ -232,7 +241,7 @@ cal_model_calendar_value_at (ETableModel *etm, 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); + return table_model_parent_interface->value_at (etm, col, row); comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); if (!comp_data) @@ -270,7 +279,7 @@ cal_model_calendar_set_value_at (ETableModel *etm, registry = e_cal_model_get_registry (E_CAL_MODEL (model)); if (col < E_CAL_MODEL_FIELD_LAST) { - E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->set_value_at (etm, col, row, value); + table_model_parent_interface->set_value_at (etm, col, row, value); return; } @@ -362,7 +371,7 @@ cal_model_calendar_is_cell_editable (ETableModel *etm, g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->is_cell_editable (etm, col, row); + return table_model_parent_interface->is_cell_editable (etm, col, row); if (!e_cal_model_test_row_editable (E_CAL_MODEL (etm), row)) return FALSE; @@ -385,7 +394,7 @@ cal_model_calendar_duplicate_value (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->duplicate_value (etm, col, value); + return table_model_parent_interface->duplicate_value (etm, col, value); switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : @@ -415,7 +424,7 @@ cal_model_calendar_free_value (ETableModel *etm, g_return_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST); if (col < E_CAL_MODEL_FIELD_LAST) { - E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->free_value (etm, col, value); + table_model_parent_interface->free_value (etm, col, value); return; } @@ -436,7 +445,7 @@ cal_model_calendar_initialize_value (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->initialize_value (etm, col); + return table_model_parent_interface->initialize_value (etm, col); switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : @@ -457,7 +466,7 @@ cal_model_calendar_value_is_empty (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, TRUE); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->value_is_empty (etm, col, value); + return table_model_parent_interface->value_is_empty (etm, col, value); switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : @@ -478,7 +487,7 @@ cal_model_calendar_value_to_string (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, g_strdup ("")); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->value_to_string (etm, col, value); + return table_model_parent_interface->value_to_string (etm, col, value); switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : @@ -495,21 +504,26 @@ static void e_cal_model_calendar_class_init (ECalModelCalendarClass *class) { 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; +static void +e_cal_model_calendar_table_model_init (ETableModelInterface *interface) +{ + table_model_parent_interface = + g_type_interface_peek_parent (interface); + + interface->column_count = cal_model_calendar_column_count; + interface->value_at = cal_model_calendar_value_at; + interface->set_value_at = cal_model_calendar_set_value_at; + interface->is_cell_editable = cal_model_calendar_is_cell_editable; + interface->duplicate_value = cal_model_calendar_duplicate_value; + interface->free_value = cal_model_calendar_free_value; + interface->initialize_value = cal_model_calendar_initialize_value; + interface->value_is_empty = cal_model_calendar_value_is_empty; + interface->value_to_string = cal_model_calendar_value_to_string; } static void diff --git a/calendar/gui/e-cal-model-memos.c b/calendar/gui/e-cal-model-memos.c index dc3440e54d..c6fecc2e4b 100644 --- a/calendar/gui/e-cal-model-memos.c +++ b/calendar/gui/e-cal-model-memos.c @@ -35,10 +35,19 @@ #define d(x) (x) -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_cal_model_memos_table_model_init + (ETableModelInterface *interface); + +static ETableModelInterface *table_model_parent_interface; + +G_DEFINE_TYPE_WITH_CODE ( ECalModelMemos, e_cal_model_memos, - E_TYPE_CAL_MODEL) + E_TYPE_CAL_MODEL, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_cal_model_memos_table_model_init)) static void cal_model_memos_fill_component_from_model (ECalModel *model, @@ -78,7 +87,7 @@ cal_model_memos_value_at (ETableModel *etm, 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_memos_parent_class)->value_at (etm, col, row); + return table_model_parent_interface->value_at (etm, col, row); comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); if (!comp_data) @@ -102,7 +111,7 @@ cal_model_memos_set_value_at (ETableModel *etm, g_return_if_fail (row >= 0 && row < e_table_model_row_count (etm)); if (col < E_CAL_MODEL_FIELD_LAST) { - E_TABLE_MODEL_CLASS (e_cal_model_memos_parent_class)->set_value_at (etm, col, row, value); + table_model_parent_interface->set_value_at (etm, col, row, value); return; } @@ -143,7 +152,7 @@ cal_model_memos_is_cell_editable (ETableModel *etm, return FALSE; if (col < E_CAL_MODEL_FIELD_LAST) - retval = E_TABLE_MODEL_CLASS (e_cal_model_memos_parent_class)->is_cell_editable (etm, col, row); + retval = table_model_parent_interface->is_cell_editable (etm, col, row); return retval; } @@ -156,7 +165,7 @@ cal_model_memos_duplicate_value (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, NULL); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_memos_parent_class)->duplicate_value (etm, col, value); + return table_model_parent_interface->duplicate_value (etm, col, value); return NULL; } @@ -169,7 +178,7 @@ cal_model_memos_free_value (ETableModel *etm, g_return_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST); if (col < E_CAL_MODEL_FIELD_LAST) { - E_TABLE_MODEL_CLASS (e_cal_model_memos_parent_class)->free_value (etm, col, value); + table_model_parent_interface->free_value (etm, col, value); return; } } @@ -181,7 +190,7 @@ cal_model_memos_initialize_value (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, NULL); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_memos_parent_class)->initialize_value (etm, col); + return table_model_parent_interface->initialize_value (etm, col); return NULL; } @@ -194,7 +203,7 @@ cal_model_memos_value_is_empty (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, TRUE); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_memos_parent_class)->value_is_empty (etm, col, value); + return table_model_parent_interface->value_is_empty (etm, col, value); return TRUE; } @@ -207,7 +216,7 @@ cal_model_memos_value_to_string (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST, g_strdup ("")); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_memos_parent_class)->value_to_string (etm, col, value); + return table_model_parent_interface->value_to_string (etm, col, value); return g_strdup (""); } @@ -216,21 +225,28 @@ static void e_cal_model_memos_class_init (ECalModelMemosClass *class) { 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; +} + +static void +e_cal_model_memos_table_model_init (ETableModelInterface *interface) +{ + table_model_parent_interface = + g_type_interface_peek_parent (interface); + + interface->column_count = cal_model_memos_column_count; + + interface->value_at = cal_model_memos_value_at; + interface->set_value_at = cal_model_memos_set_value_at; + interface->is_cell_editable = cal_model_memos_is_cell_editable; - 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; + interface->duplicate_value = cal_model_memos_duplicate_value; + interface->free_value = cal_model_memos_free_value; + interface->initialize_value = cal_model_memos_initialize_value; + interface->value_is_empty = cal_model_memos_value_is_empty; + interface->value_to_string = cal_model_memos_value_to_string; } static void diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index a3e6cb8107..bb9e8f4bbf 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -55,10 +55,19 @@ enum { PROP_COLOR_OVERDUE }; -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_cal_model_tasks_table_model_init + (ETableModelInterface *interface); + +static ETableModelInterface *table_model_parent_interface; + +G_DEFINE_TYPE_WITH_CODE ( ECalModelTasks, e_cal_model_tasks, - E_TYPE_CAL_MODEL) + E_TYPE_CAL_MODEL, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_cal_model_tasks_table_model_init)) /* This makes sure a task is marked as complete. * It makes sure the "Date Completed" property is set. If the completed_date @@ -878,7 +887,7 @@ cal_model_tasks_value_at (ETableModel *etm, 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); + return table_model_parent_interface->value_at (etm, col, row); comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); if (!comp_data) @@ -925,7 +934,7 @@ cal_model_tasks_set_value_at (ETableModel *etm, g_return_if_fail (row >= 0 && row < e_table_model_row_count (etm)); if (col < E_CAL_MODEL_FIELD_LAST) { - E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->set_value_at (etm, col, row, value); + table_model_parent_interface->set_value_at (etm, col, row, value); return; } @@ -976,7 +985,7 @@ cal_model_tasks_is_cell_editable (ETableModel *etm, g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->is_cell_editable (etm, col, row); + return table_model_parent_interface->is_cell_editable (etm, col, row); if (!e_cal_model_test_row_editable (E_CAL_MODEL (etm), row)) return FALSE; @@ -1004,7 +1013,7 @@ cal_model_tasks_duplicate_value (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, NULL); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->duplicate_value (etm, col, value); + return table_model_parent_interface->duplicate_value (etm, col, value); switch (col) { case E_CAL_MODEL_TASKS_FIELD_GEO : @@ -1042,7 +1051,7 @@ cal_model_tasks_free_value (ETableModel *etm, g_return_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST); if (col < E_CAL_MODEL_FIELD_LAST) { - E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->free_value (etm, col, value); + table_model_parent_interface->free_value (etm, col, value); return; } @@ -1073,7 +1082,7 @@ cal_model_tasks_initialize_value (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, NULL); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->initialize_value (etm, col); + return table_model_parent_interface->initialize_value (etm, col); switch (col) { case E_CAL_MODEL_TASKS_FIELD_GEO : @@ -1104,7 +1113,7 @@ cal_model_tasks_value_is_empty (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, TRUE); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->value_is_empty (etm, col, value); + return table_model_parent_interface->value_is_empty (etm, col, value); switch (col) { case E_CAL_MODEL_TASKS_FIELD_GEO : @@ -1136,7 +1145,7 @@ cal_model_tasks_value_to_string (ETableModel *etm, g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, g_strdup ("")); if (col < E_CAL_MODEL_FIELD_LAST) - return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->value_to_string (etm, col, value); + return table_model_parent_interface->value_to_string (etm, col, value); switch (col) { case E_CAL_MODEL_TASKS_FIELD_GEO : @@ -1165,7 +1174,6 @@ e_cal_model_tasks_class_init (ECalModelTasksClass *class) { GObjectClass *object_class; ECalModelClass *cal_model_class; - ETableModelClass *table_model_class; g_type_class_add_private (class, sizeof (ECalModelTasksPrivate)); @@ -1178,17 +1186,6 @@ e_cal_model_tasks_class_init (ECalModelTasksClass *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; - 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; - g_object_class_install_property ( object_class, PROP_HIGHLIGHT_DUE_TODAY, @@ -1231,6 +1228,25 @@ e_cal_model_tasks_class_init (ECalModelTasksClass *class) } static void +e_cal_model_tasks_table_model_init (ETableModelInterface *interface) +{ + table_model_parent_interface = + g_type_interface_peek_parent (interface); + + interface->column_count = cal_model_tasks_column_count; + + interface->value_at = cal_model_tasks_value_at; + interface->set_value_at = cal_model_tasks_set_value_at; + interface->is_cell_editable = cal_model_tasks_is_cell_editable; + + interface->duplicate_value = cal_model_tasks_duplicate_value; + interface->free_value = cal_model_tasks_free_value; + interface->initialize_value = cal_model_tasks_initialize_value; + interface->value_is_empty = cal_model_tasks_value_is_empty; + interface->value_to_string = cal_model_tasks_value_to_string; +} + +static void e_cal_model_tasks_init (ECalModelTasks *model) { model->priv = E_CAL_MODEL_TASKS_GET_PRIVATE (model); diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 288a896f9d..02020ae2cf 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -193,11 +193,21 @@ enum { LAST_SIGNAL }; +/* Forward Declarations */ +static void e_cal_model_table_model_init + (ETableModelInterface *interface); + static guint signals[LAST_SIGNAL]; G_DEFINE_TYPE_WITH_CODE ( - ECalModel, e_cal_model, E_TYPE_TABLE_MODEL, - G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL)) + ECalModel, + e_cal_model, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + E_TYPE_EXTENSIBLE, NULL) + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_cal_model_table_model_init)) G_DEFINE_TYPE ( ECalModelComponent, @@ -1672,7 +1682,6 @@ static void e_cal_model_class_init (ECalModelClass *class) { GObjectClass *object_class; - ETableModelClass *etm_class; g_type_class_add_private (class, sizeof (ECalModelPrivate)); @@ -1686,19 +1695,6 @@ e_cal_model_class_init (ECalModelClass *class) 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, @@ -2013,6 +2009,24 @@ e_cal_model_class_init (ECalModelClass *class) } static void +e_cal_model_table_model_init (ETableModelInterface *interface) +{ + interface->column_count = cal_model_column_count; + interface->row_count = cal_model_row_count; + interface->append_row = cal_model_append_row; + + interface->value_at = cal_model_value_at; + interface->set_value_at = cal_model_set_value_at; + interface->is_cell_editable = cal_model_is_cell_editable; + + interface->duplicate_value = cal_model_duplicate_value; + interface->free_value = cal_model_free_value; + interface->initialize_value = cal_model_initialize_value; + interface->value_is_empty = cal_model_value_is_empty; + interface->value_to_string = cal_model_value_to_string; +} + +static void e_cal_model_init (ECalModel *model) { model->priv = E_CAL_MODEL_GET_PRIVATE (model); diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index 602db1cae4..cebb09cf76 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -134,12 +134,12 @@ typedef struct { } ECalModelGenerateInstancesData; struct _ECalModel { - ETableModel model; + GObject parent; ECalModelPrivate *priv; }; struct _ECalModelClass { - ETableModelClass parent_class; + GObjectClass parent_class; /* virtual methods */ const gchar * (*get_color_for_component) diff --git a/e-util/e-table-memory-store.c b/e-util/e-table-memory-store.c index 6432cc3c5b..480aacc3ac 100644 --- a/e-util/e-table-memory-store.c +++ b/e-util/e-table-memory-store.c @@ -36,10 +36,17 @@ struct _ETableMemoryStorePrivate { gpointer *store; }; -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_table_memory_store_table_model_init + (ETableModelInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( ETableMemoryStore, e_table_memory_store, - E_TYPE_TABLE_MEMORY) + E_TYPE_TABLE_MEMORY, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_table_memory_store_table_model_init)) static gpointer duplicate_value (ETableMemoryStore *etms, @@ -235,24 +242,28 @@ static void e_table_memory_store_class_init (ETableMemoryStoreClass *class) { GObjectClass *object_class; - ETableModelClass *model_class; g_type_class_add_private (class, sizeof (ETableMemoryStorePrivate)); object_class = G_OBJECT_CLASS (class); object_class->finalize = table_memory_store_finalize; +} - model_class = E_TABLE_MODEL_CLASS (class); - 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_table_model_init (ETableModelInterface *interface) +{ + interface->column_count = table_memory_store_column_count; + interface->append_row = table_memory_store_append_row; + + interface->value_at = table_memory_store_value_at; + interface->set_value_at = table_memory_store_set_value_at; + interface->is_cell_editable = table_memory_store_is_cell_editable; + + interface->duplicate_value = table_memory_store_duplicate_value; + interface->free_value = table_memory_store_free_value; + interface->initialize_value = table_memory_store_initialize_value; + interface->value_is_empty = table_memory_store_value_is_empty; + interface->value_to_string = table_memory_store_value_to_string; } static void diff --git a/e-util/e-table-memory.c b/e-util/e-table-memory.c index 5a0bcd1868..09f13e0b11 100644 --- a/e-util/e-table-memory.c +++ b/e-util/e-table-memory.c @@ -37,10 +37,17 @@ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_TABLE_MEMORY, ETableMemoryPrivate)) -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_table_memory_table_model_init + (ETableModelInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( ETableMemory, e_table_memory, - E_TYPE_TABLE_MODEL) + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_table_memory_table_model_init)) struct _ETableMemoryPrivate { gpointer *data; @@ -73,15 +80,17 @@ static void e_table_memory_class_init (ETableMemoryClass *class) { GObjectClass *object_class; - ETableModelClass *table_model_class; g_type_class_add_private (class, sizeof (ETableMemoryPrivate)); object_class = G_OBJECT_CLASS (class); object_class->finalize = table_memory_finalize; +} - table_model_class = E_TABLE_MODEL_CLASS (class); - table_model_class->row_count = table_memory_row_count; +static void +e_table_memory_table_model_init (ETableModelInterface *interface) +{ + interface->row_count = table_memory_row_count; } static void diff --git a/e-util/e-table-memory.h b/e-util/e-table-memory.h index db0809daf7..86f2b7014a 100644 --- a/e-util/e-table-memory.h +++ b/e-util/e-table-memory.h @@ -57,12 +57,12 @@ typedef struct _ETableMemoryClass ETableMemoryClass; typedef struct _ETableMemoryPrivate ETableMemoryPrivate; struct _ETableMemory { - ETableModel parent; + GObject parent; ETableMemoryPrivate *priv; }; struct _ETableMemoryClass { - ETableModelClass parent_class; + GObjectClass parent_class; }; GType e_table_memory_get_type (void) G_GNUC_CONST; diff --git a/e-util/e-table-model.c b/e-util/e-table-model.c index 7f9477b0f2..78030370f8 100644 --- a/e-util/e-table-model.c +++ b/e-util/e-table-model.c @@ -22,7 +22,7 @@ d (static gint depth = 0;) -G_DEFINE_TYPE (ETableModel, e_table_model, G_TYPE_OBJECT) +G_DEFINE_INTERFACE (ETableModel, e_table_model, G_TYPE_OBJECT) enum { MODEL_NO_CHANGE, @@ -49,48 +49,46 @@ table_model_is_frozen (ETableModel *table_model) } static void -e_table_model_class_init (ETableModelClass *class) +e_table_model_default_init (ETableModelInterface *interface) { - GObjectClass *object_class = G_OBJECT_CLASS (class); - signals[MODEL_NO_CHANGE] = g_signal_new ( "model_no_change", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_INTERFACE (interface), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableModelClass, model_no_change), + G_STRUCT_OFFSET (ETableModelInterface, 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_TYPE_FROM_INTERFACE (interface), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableModelClass, model_changed), + G_STRUCT_OFFSET (ETableModelInterface, 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_TYPE_FROM_INTERFACE (interface), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableModelClass, model_pre_change), + G_STRUCT_OFFSET (ETableModelInterface, 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_TYPE_FROM_INTERFACE (interface), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableModelClass, model_row_changed), + G_STRUCT_OFFSET (ETableModelInterface, 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_TYPE_FROM_INTERFACE (interface), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableModelClass, model_cell_changed), + G_STRUCT_OFFSET (ETableModelInterface, model_cell_changed), NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, @@ -98,9 +96,9 @@ e_table_model_class_init (ETableModelClass *class) signals[MODEL_ROWS_INSERTED] = g_signal_new ( "model_rows_inserted", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_INTERFACE (interface), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableModelClass, model_rows_inserted), + G_STRUCT_OFFSET (ETableModelInterface, model_rows_inserted), NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, @@ -108,20 +106,15 @@ e_table_model_class_init (ETableModelClass *class) signals[MODEL_ROWS_DELETED] = g_signal_new ( "model_rows_deleted", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_INTERFACE (interface), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableModelClass, model_rows_deleted), + G_STRUCT_OFFSET (ETableModelInterface, 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: * @table_model: The e-table-model to operate on @@ -131,14 +124,14 @@ e_table_model_init (ETableModel *table_model) gint e_table_model_column_count (ETableModel *table_model) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), 0); - class = E_TABLE_MODEL_GET_CLASS (table_model); - g_return_val_if_fail (class->column_count != NULL, 0); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); + g_return_val_if_fail (interface->column_count != NULL, 0); - return class->column_count (table_model); + return interface->column_count (table_model); } /** @@ -150,14 +143,14 @@ e_table_model_column_count (ETableModel *table_model) gint e_table_model_row_count (ETableModel *table_model) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), 0); - class = E_TABLE_MODEL_GET_CLASS (table_model); - g_return_val_if_fail (class->row_count != NULL, 0); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); + g_return_val_if_fail (interface->row_count != NULL, 0); - return class->row_count (table_model); + return interface->row_count (table_model); } /** @@ -172,14 +165,14 @@ e_table_model_append_row (ETableModel *table_model, ETableModel *source, gint row) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_if_fail (E_IS_TABLE_MODEL (table_model)); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->append_row != NULL) - class->append_row (table_model, source, row); + if (interface->append_row != NULL) + interface->append_row (table_model, source, row); } /** @@ -206,14 +199,14 @@ e_table_model_value_at (ETableModel *table_model, gint col, gint row) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL); - class = E_TABLE_MODEL_GET_CLASS (table_model); - g_return_val_if_fail (class->value_at != NULL, NULL); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); + g_return_val_if_fail (interface->value_at != NULL, NULL); - return class->value_at (table_model, col, row); + return interface->value_at (table_model, col, row); } /** @@ -237,14 +230,14 @@ e_table_model_set_value_at (ETableModel *table_model, gint row, gconstpointer value) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_if_fail (E_IS_TABLE_MODEL (table_model)); - class = E_TABLE_MODEL_GET_CLASS (table_model); - g_return_if_fail (class->set_value_at != NULL); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); + g_return_if_fail (interface->set_value_at != NULL); - class->set_value_at (table_model, col, row, value); + interface->set_value_at (table_model, col, row, value); } /** @@ -261,14 +254,14 @@ e_table_model_is_cell_editable (ETableModel *table_model, gint col, gint row) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE); - class = E_TABLE_MODEL_GET_CLASS (table_model); - g_return_val_if_fail (class->is_cell_editable != NULL, FALSE); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); + g_return_val_if_fail (interface->is_cell_editable != NULL, FALSE); - return class->is_cell_editable (table_model, col, row); + return interface->is_cell_editable (table_model, col, row); } gpointer @@ -276,16 +269,16 @@ e_table_model_duplicate_value (ETableModel *table_model, gint col, gconstpointer value) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->duplicate_value == NULL) + if (interface->duplicate_value == NULL) return NULL; - return class->duplicate_value (table_model, col, value); + return interface->duplicate_value (table_model, col, value); } void @@ -293,76 +286,76 @@ e_table_model_free_value (ETableModel *table_model, gint col, gpointer value) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_if_fail (E_IS_TABLE_MODEL (table_model)); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->free_value != NULL) - class->free_value (table_model, col, value); + if (interface->free_value != NULL) + interface->free_value (table_model, col, value); } gboolean e_table_model_has_save_id (ETableModel *table_model) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->has_save_id == NULL) + if (interface->has_save_id == NULL) return FALSE; - return class->has_save_id (table_model); + return interface->has_save_id (table_model); } gchar * e_table_model_get_save_id (ETableModel *table_model, gint row) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->get_save_id == NULL) + if (interface->get_save_id == NULL) return NULL; - return class->get_save_id (table_model, row); + return interface->get_save_id (table_model, row); } gboolean e_table_model_has_change_pending (ETableModel *table_model) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->has_change_pending == NULL) + if (interface->has_change_pending == NULL) return FALSE; - return class->has_change_pending (table_model); + return interface->has_change_pending (table_model); } gpointer e_table_model_initialize_value (ETableModel *table_model, gint col) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->initialize_value == NULL) + if (interface->initialize_value == NULL) return NULL; - return class->initialize_value (table_model, col); + return interface->initialize_value (table_model, col); } gboolean @@ -370,16 +363,16 @@ e_table_model_value_is_empty (ETableModel *table_model, gint col, gconstpointer value) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), FALSE); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->value_is_empty == NULL) + if (interface->value_is_empty == NULL) return FALSE; - return class->value_is_empty (table_model, col, value); + return interface->value_is_empty (table_model, col, value); } gchar * @@ -387,16 +380,16 @@ e_table_model_value_to_string (ETableModel *table_model, gint col, gconstpointer value) { - ETableModelClass *class; + ETableModelInterface *interface; g_return_val_if_fail (E_IS_TABLE_MODEL (table_model), NULL); - class = E_TABLE_MODEL_GET_CLASS (table_model); + interface = E_TABLE_MODEL_GET_INTERFACE (table_model); - if (class->value_to_string == NULL) + if (interface->value_to_string == NULL) return g_strdup (""); - return class->value_to_string (table_model, col, value); + return interface->value_to_string (table_model, col, value); } #if d(!)0 diff --git a/e-util/e-table-model.h b/e-util/e-table-model.h index 60fc11c53c..99f53b15c1 100644 --- a/e-util/e-table-model.h +++ b/e-util/e-table-model.h @@ -31,30 +31,20 @@ #define E_TABLE_MODEL(obj) \ (G_TYPE_CHECK_INSTANCE_CAST \ ((obj), E_TYPE_TABLE_MODEL, ETableModel)) -#define E_TABLE_MODEL_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_TABLE_MODEL, ETableModelClass)) #define E_IS_TABLE_MODEL(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE \ ((obj), E_TYPE_TABLE_MODEL)) -#define E_IS_TABLE_MODEL_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_TABLE_MODEL)) -#define E_TABLE_MODEL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_TABLE_MODEL, ETableModelClass)) +#define E_TABLE_MODEL_GET_INTERFACE(obj) \ + (G_TYPE_INSTANCE_GET_INTERFACE \ + ((obj), E_TYPE_TABLE_MODEL, ETableModelInterface)) G_BEGIN_DECLS typedef struct _ETableModel ETableModel; -typedef struct _ETableModelClass ETableModelClass; +typedef struct _ETableModelInterface ETableModelInterface; -struct _ETableModel { - GObject parent; -}; - -struct _ETableModelClass { - GObjectClass parent_class; +struct _ETableModelInterface { + GTypeInterface parent_interface; gint (*column_count) (ETableModel *table_model); gint (*row_count) (ETableModel *table_model); diff --git a/e-util/e-table-one.c b/e-util/e-table-one.c index 242484fdfa..59279c3d59 100644 --- a/e-util/e-table-one.c +++ b/e-util/e-table-one.c @@ -27,10 +27,17 @@ #include "e-table-one.h" -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void e_table_one_table_model_init + (ETableModelInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( ETableOne, e_table_one, - E_TYPE_TABLE_MODEL) + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_table_one_table_model_init)) static void table_one_dispose (GObject *object) @@ -182,22 +189,26 @@ static void e_table_one_class_init (ETableOneClass *class) { GObjectClass *object_class; - ETableModelClass *model_class; object_class = G_OBJECT_CLASS (class); object_class->dispose = table_one_dispose; +} - 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_table_model_init (ETableModelInterface *interface) +{ + interface->column_count = table_one_column_count; + interface->row_count = table_one_row_count; + + interface->value_at = table_one_value_at; + interface->set_value_at = table_one_set_value_at; + interface->is_cell_editable = table_one_is_cell_editable; + + interface->duplicate_value = table_one_duplicate_value; + interface->free_value = table_one_free_value; + interface->initialize_value = table_one_initialize_value; + interface->value_is_empty = table_one_value_is_empty; + interface->value_to_string = table_one_value_to_string; } static void diff --git a/e-util/e-table-one.h b/e-util/e-table-one.h index 86f5538ffb..788bcbe335 100644 --- a/e-util/e-table-one.h +++ b/e-util/e-table-one.h @@ -54,14 +54,14 @@ typedef struct _ETableOne ETableOne; typedef struct _ETableOneClass ETableOneClass; struct _ETableOne { - ETableModel parent; + GObject parent; ETableModel *source; gpointer *data; }; struct _ETableOneClass { - ETableModelClass parent_class; + GObjectClass parent_class; }; GType e_table_one_get_type (void) G_GNUC_CONST; diff --git a/e-util/e-table-subset.c b/e-util/e-table-subset.c index 92f71cedde..741fc8d230 100644 --- a/e-util/e-table-subset.c +++ b/e-util/e-table-subset.c @@ -54,7 +54,17 @@ struct _ETableSubsetPrivate { gint last_access; }; -G_DEFINE_TYPE (ETableSubset, e_table_subset, E_TYPE_TABLE_MODEL) +/* Forward Declarations */ +static void e_table_subset_table_model_init + (ETableModelInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( + ETableSubset, + e_table_subset, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_table_subset_table_model_init)) static gint table_subset_get_view_row (ETableSubset *table_subset, @@ -390,7 +400,6 @@ static void e_table_subset_class_init (ETableSubsetClass *class) { GObjectClass *object_class; - ETableModelClass *table_class; g_type_class_add_private (class, sizeof (ETableSubsetPrivate)); @@ -398,21 +407,6 @@ e_table_subset_class_init (ETableSubsetClass *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; @@ -423,6 +417,27 @@ e_table_subset_class_init (ETableSubsetClass *class) } static void +e_table_subset_table_model_init (ETableModelInterface *interface) +{ + interface->column_count = table_subset_column_count; + interface->row_count = table_subset_row_count; + interface->append_row = table_subset_append_row; + + interface->value_at = table_subset_value_at; + interface->set_value_at = table_subset_set_value_at; + interface->is_cell_editable = table_subset_is_cell_editable; + + interface->has_save_id = table_subset_has_save_id; + interface->get_save_id = table_subset_get_save_id; + + interface->duplicate_value = table_subset_duplicate_value; + interface->free_value = table_subset_free_value; + interface->initialize_value = table_subset_initialize_value; + interface->value_is_empty = table_subset_value_is_empty; + interface->value_to_string = table_subset_value_to_string; +} + +static void e_table_subset_init (ETableSubset *table_subset) { table_subset->priv = E_TABLE_SUBSET_GET_PRIVATE (table_subset); diff --git a/e-util/e-table-subset.h b/e-util/e-table-subset.h index fc954f820c..f56997df0a 100644 --- a/e-util/e-table-subset.h +++ b/e-util/e-table-subset.h @@ -57,7 +57,7 @@ typedef struct _ETableSubsetClass ETableSubsetClass; typedef struct _ETableSubsetPrivate ETableSubsetPrivate; struct _ETableSubset { - ETableModel parent; + GObject parent; ETableSubsetPrivate *priv; /* protected - subclasses modify this directly */ @@ -66,7 +66,7 @@ struct _ETableSubset { }; struct _ETableSubsetClass { - ETableModelClass parent_class; + GObjectClass parent_class; void (*proxy_model_pre_change) (ETableSubset *table_subset, diff --git a/e-util/e-tree-table-adapter.c b/e-util/e-tree-table-adapter.c index 2950d60a33..8c49ec4283 100644 --- a/e-util/e-tree-table-adapter.c +++ b/e-util/e-tree-table-adapter.c @@ -97,12 +97,19 @@ enum { LAST_SIGNAL }; +/* Forward Declarations */ +static void e_tree_table_adapter_table_model_init + (ETableModelInterface *interface); + static guint signals[LAST_SIGNAL]; -G_DEFINE_TYPE ( +G_DEFINE_TYPE_WITH_CODE ( ETreeTableAdapter, e_tree_table_adapter, - E_TYPE_TABLE_MODEL) + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + e_tree_table_adapter_table_model_init)) static GNode * lookup_gnode (ETreeTableAdapter *etta, @@ -732,7 +739,6 @@ static void e_tree_table_adapter_class_init (ETreeTableAdapterClass *class) { GObjectClass *object_class; - ETableModelClass *table_model_class; g_type_class_add_private (class, sizeof (ETreeTableAdapterPrivate)); @@ -740,26 +746,6 @@ e_tree_table_adapter_class_init (ETreeTableAdapterClass *class) 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 = 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 = 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 = tree_table_adapter_has_save_id; - table_model_class->get_save_id = tree_table_adapter_get_save_id; - - 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; - signals[SORTING_CHANGED] = g_signal_new ( "sorting_changed", G_OBJECT_CLASS_TYPE (object_class), @@ -772,6 +758,27 @@ e_tree_table_adapter_class_init (ETreeTableAdapterClass *class) } static void +e_tree_table_adapter_table_model_init (ETableModelInterface *interface) +{ + interface->column_count = tree_table_adapter_column_count; + interface->row_count = tree_table_adapter_row_count; + interface->append_row = tree_table_adapter_append_row; + + interface->value_at = tree_table_adapter_value_at; + interface->set_value_at = tree_table_adapter_set_value_at; + interface->is_cell_editable = tree_table_adapter_is_cell_editable; + + interface->has_save_id = tree_table_adapter_has_save_id; + interface->get_save_id = tree_table_adapter_get_save_id; + + interface->duplicate_value = tree_table_adapter_duplicate_value; + interface->free_value = tree_table_adapter_free_value; + interface->initialize_value = tree_table_adapter_initialize_value; + interface->value_is_empty = tree_table_adapter_value_is_empty; + interface->value_to_string = tree_table_adapter_value_to_string; +} + +static void e_tree_table_adapter_init (ETreeTableAdapter *etta) { etta->priv = E_TREE_TABLE_ADAPTER_GET_PRIVATE (etta); diff --git a/e-util/e-tree-table-adapter.h b/e-util/e-tree-table-adapter.h index 17f3304aa4..29ec1c740e 100644 --- a/e-util/e-tree-table-adapter.h +++ b/e-util/e-tree-table-adapter.h @@ -61,12 +61,12 @@ typedef struct _ETreeTableAdapterClass ETreeTableAdapterClass; typedef struct _ETreeTableAdapterPrivate ETreeTableAdapterPrivate; struct _ETreeTableAdapter { - ETableModel parent; + GObject parent; ETreeTableAdapterPrivate *priv; }; struct _ETreeTableAdapterClass { - ETableModelClass parent_class; + GObjectClass parent_class; /* Signals */ gboolean (*sorting_changed) (ETreeTableAdapter *etta); diff --git a/e-util/gal-define-views-model.c b/e-util/gal-define-views-model.c index 14bdac636f..d05ac53e67 100644 --- a/e-util/gal-define-views-model.c +++ b/e-util/gal-define-views-model.c @@ -38,10 +38,17 @@ enum { PROP_COLLECTION }; -G_DEFINE_TYPE ( +/* Forward Declarations */ +static void gal_define_views_model_table_model_init + (ETableModelInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( GalDefineViewsModel, gal_define_views_model, - E_TYPE_TABLE_MODEL) + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + E_TYPE_TABLE_MODEL, + gal_define_views_model_table_model_init)) static void gal_define_views_model_set_property (GObject *object, @@ -240,12 +247,12 @@ gal_define_views_model_append (GalDefineViewsModel *model, static void gal_define_views_model_class_init (GalDefineViewsModelClass *class) { - ETableModelClass *model_class = E_TABLE_MODEL_CLASS (class); - GObjectClass *object_class = G_OBJECT_CLASS (class); + GObjectClass *object_class; - object_class->dispose = gdvm_dispose; - object_class->set_property = gal_define_views_model_set_property; - object_class->get_property = gal_define_views_model_get_property; + object_class = G_OBJECT_CLASS (class); + object_class->set_property = gal_define_views_model_set_property; + object_class->get_property = gal_define_views_model_get_property; + object_class->dispose = gdvm_dispose; g_object_class_install_property ( object_class, @@ -266,18 +273,24 @@ gal_define_views_model_class_init (GalDefineViewsModelClass *class) NULL, GAL_TYPE_VIEW_COLLECTION, G_PARAM_READWRITE)); +} - model_class->column_count = gdvm_col_count; - model_class->row_count = gdvm_row_count; - model_class->value_at = gdvm_value_at; - model_class->set_value_at = gdvm_set_value_at; - model_class->is_cell_editable = gdvm_is_cell_editable; - model_class->append_row = gdvm_append_row; - model_class->duplicate_value = gdvm_duplicate_value; - model_class->free_value = gdvm_free_value; - model_class->initialize_value = gdvm_initialize_value; - model_class->value_is_empty = gdvm_value_is_empty; - model_class->value_to_string = gdvm_value_to_string; +static void +gal_define_views_model_table_model_init (ETableModelInterface *interface) +{ + interface->column_count = gdvm_col_count; + interface->row_count = gdvm_row_count; + interface->append_row = gdvm_append_row; + + interface->value_at = gdvm_value_at; + interface->set_value_at = gdvm_set_value_at; + interface->is_cell_editable = gdvm_is_cell_editable; + + interface->duplicate_value = gdvm_duplicate_value; + interface->free_value = gdvm_free_value; + interface->initialize_value = gdvm_initialize_value; + interface->value_is_empty = gdvm_value_is_empty; + interface->value_to_string = gdvm_value_to_string; } static void diff --git a/e-util/gal-define-views-model.h b/e-util/gal-define-views-model.h index 8bc243d52c..cd4d44ccf7 100644 --- a/e-util/gal-define-views-model.h +++ b/e-util/gal-define-views-model.h @@ -57,7 +57,7 @@ typedef struct _GalDefineViewsModel GalDefineViewsModel; typedef struct _GalDefineViewsModelClass GalDefineViewsModelClass; struct _GalDefineViewsModel { - ETableModel parent; + GObject parent; /* item specific fields */ GalViewCollection *collection; @@ -66,7 +66,7 @@ struct _GalDefineViewsModel { }; struct _GalDefineViewsModelClass { - ETableModelClass parent_class; + GObjectClass parent_class; }; GType gal_define_views_model_get_type (void) G_GNUC_CONST; |