diff options
Diffstat (limited to 'e-util')
28 files changed, 1301 insertions, 1178 deletions
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, |