aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-27 07:02:43 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-02 22:34:09 +0800
commit96b07a2ff024c6e852344f4614735132219d2104 (patch)
tree95c9bdb74cde0769a31399cc6d2b92415b37ba32 /e-util
parentd40e5a8ba1e7d362415be17d0ccde4477243839d (diff)
downloadgsoc2013-evolution-96b07a2ff024c6e852344f4614735132219d2104.tar
gsoc2013-evolution-96b07a2ff024c6e852344f4614735132219d2104.tar.gz
gsoc2013-evolution-96b07a2ff024c6e852344f4614735132219d2104.tar.bz2
gsoc2013-evolution-96b07a2ff024c6e852344f4614735132219d2104.tar.lz
gsoc2013-evolution-96b07a2ff024c6e852344f4614735132219d2104.tar.xz
gsoc2013-evolution-96b07a2ff024c6e852344f4614735132219d2104.tar.zst
gsoc2013-evolution-96b07a2ff024c6e852344f4614735132219d2104.zip
ETableCol: Embed an ETableColumnSpecification.
Eliminates a few redundant fields.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-cell-combo.c6
-rw-r--r--e-util/e-cell-date-edit.c8
-rw-r--r--e-util/e-table-col.c89
-rw-r--r--e-util/e-table-col.h30
-rw-r--r--e-util/e-table-field-chooser-item.c19
-rw-r--r--e-util/e-table-group-container.c13
-rw-r--r--e-util/e-table-header-item.c58
-rw-r--r--e-util/e-table-header.c30
-rw-r--r--e-util/e-table-item.c28
-rw-r--r--e-util/e-table-sorter.c2
-rw-r--r--e-util/e-table-sorting-utils.c14
-rw-r--r--e-util/e-table-utils.c30
-rw-r--r--e-util/e-table.c19
-rw-r--r--e-util/e-tree.c16
-rw-r--r--e-util/gal-a11y-e-table-item.c15
15 files changed, 139 insertions, 238 deletions
diff --git a/e-util/e-cell-combo.c b/e-util/e-cell-combo.c
index dba6b53c50..0252b3a2db 100644
--- a/e-util/e-cell-combo.c
+++ b/e-util/e-cell-combo.c
@@ -377,7 +377,7 @@ e_cell_combo_select_matching_item (ECellCombo *ecc)
ecol = e_table_header_get_column (eti->header, ecp->popup_view_col);
cell_text = e_cell_text_get_text (
ecell_text, ecv->e_table_model,
- ecol->col_idx, ecp->popup_row);
+ ecol->spec->model_col, ecp->popup_row);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (ecc->popup_tree_view));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ecc->popup_tree_view));
@@ -811,13 +811,13 @@ e_cell_combo_update_cell (ECellCombo *ecc)
old_text = e_cell_text_get_text (
ecell_text, ecv->e_table_model,
- ecol->col_idx, ecp->popup_row);
+ ecol->spec->model_col, ecp->popup_row);
/* If they are different, update the cell contents. */
if (old_text && strcmp (old_text, text)) {
e_cell_text_set_value (
ecell_text, ecv->e_table_model,
- ecol->col_idx, ecp->popup_row, text);
+ ecol->spec->model_col, ecp->popup_row, text);
}
e_cell_text_free_text (ecell_text, old_text);
diff --git a/e-util/e-cell-date-edit.c b/e-util/e-cell-date-edit.c
index 8b43bc9745..1e7642eb3d 100644
--- a/e-util/e-cell-date-edit.c
+++ b/e-util/e-cell-date-edit.c
@@ -518,7 +518,7 @@ e_cell_date_edit_set_popup_values (ECellDateEdit *ecde)
cell_text = e_cell_text_get_text (
ecell_text, ecv->e_table_model,
- ecol->col_idx, ecp->popup_row);
+ ecol->spec->model_col, ecp->popup_row);
/* Try to parse just a date first. If the value is only a date, we
* use a DATE value. */
@@ -952,16 +952,16 @@ e_cell_date_edit_update_cell (ECellDateEdit *ecde,
old_text = e_cell_text_get_text (
ecell_text, ecv->e_table_model,
- ecol->col_idx, ecp->popup_row);
+ ecol->spec->model_col, ecp->popup_row);
/* If they are different, update the cell contents. */
if (strcmp (old_text, text)) {
e_cell_text_set_value (
ecell_text, ecv->e_table_model,
- ecol->col_idx, ecp->popup_row, text);
+ ecol->spec->model_col, ecp->popup_row, text);
e_cell_leave_edit (
ecv, ecp->popup_view_col,
- ecol->col_idx, ecp->popup_row, NULL);
+ ecol->spec->model_col, ecp->popup_row, NULL);
}
e_cell_text_free_text (ecell_text, old_text);
diff --git a/e-util/e-table-col.c b/e-util/e-table-col.c
index 4e5e18a5b6..8762e2c913 100644
--- a/e-util/e-table-col.c
+++ b/e-util/e-table-col.c
@@ -30,11 +30,6 @@
G_DEFINE_TYPE (ETableCol, e_table_col, G_TYPE_OBJECT)
-enum {
- PROP_0,
- PROP_COMPARE_COL
-};
-
static void
etc_load_icon (ETableCol *etc)
{
@@ -61,6 +56,8 @@ etc_dispose (GObject *object)
{
ETableCol *etc = E_TABLE_COL (object);
+ g_clear_object (&etc->spec);
+
if (etc->ecell)
g_object_unref (etc->ecell);
etc->ecell = NULL;
@@ -80,81 +77,27 @@ etc_dispose (GObject *object)
}
static void
-etc_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- ETableCol *etc = E_TABLE_COL (object);
-
- switch (property_id) {
- case PROP_COMPARE_COL:
- etc->compare_col = g_value_get_int (value);
- break;
- default:
- break;
- }
-}
-
-static void
-etc_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ETableCol *etc = E_TABLE_COL (object);
-
- switch (property_id) {
- case PROP_COMPARE_COL:
- g_value_set_int (value, etc->compare_col);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
e_table_col_class_init (ETableColClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = etc_dispose;
- object_class->set_property = etc_set_property;
- object_class->get_property = etc_get_property;
-
- g_object_class_install_property (
- object_class,
- PROP_COMPARE_COL,
- g_param_spec_int (
- "compare_col",
- "Width",
- "Width",
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
}
static void
e_table_col_init (ETableCol *etc)
{
etc->width = 0;
- etc->sortable = 1;
- etc->groupable = 1;
etc->justification = GTK_JUSTIFY_LEFT;
- etc->priority = 0;
}
/**
* e_table_col_new:
- * @col_idx: the column we represent in the model
+ * @spec: an #ETableColumnSpecification
* @text: a title for this column
* @icon_name: name of the icon to be used for the header, or %NULL
- * @expansion: FIXME
- * @min_width: minimum width in pixels for this column
* @ecell: the renderer to be used for this column
* @compare: comparision function for the elements stored in this column
- * @resizable: whether the column can be resized interactively by the user
- * @priority: FIXME
*
* The ETableCol represents a column to be used inside an ETable. The
* ETableCol objects are inserted inside an ETableHeader (which is just a
@@ -177,43 +120,31 @@ e_table_col_init (ETableCol *etc)
* Returns: the newly created ETableCol object.
*/
ETableCol *
-e_table_col_new (gint col_idx,
+e_table_col_new (ETableColumnSpecification *spec,
const gchar *text,
const gchar *icon_name,
- gdouble expansion,
- gint min_width,
ECell *ecell,
- GCompareDataFunc compare,
- gboolean resizable,
- gboolean disabled,
- gint priority)
+ GCompareDataFunc compare)
{
ETableCol *etc;
- g_return_val_if_fail (expansion >= 0, NULL);
- g_return_val_if_fail (min_width >= 0, NULL);
+ g_return_val_if_fail (E_IS_TABLE_COLUMN_SPECIFICATION (spec), NULL);
g_return_val_if_fail (ecell != NULL, NULL);
g_return_val_if_fail (compare != NULL, NULL);
g_return_val_if_fail (text != NULL, NULL);
etc = g_object_new (E_TYPE_TABLE_COL, NULL);
- etc->col_idx = col_idx;
- etc->compare_col = col_idx;
+ etc->spec = g_object_ref (spec);
etc->text = g_strdup (text);
etc->icon_name = g_strdup (icon_name);
etc->pixbuf = NULL;
- etc->expansion = expansion;
- etc->min_width = min_width;
- etc->ecell = ecell;
+ etc->min_width = spec->minimum_width;
+ etc->expansion = spec->expansion;
+ etc->ecell = g_object_ref (ecell);
etc->compare = compare;
- etc->disabled = disabled;
- etc->priority = priority;
etc->selected = 0;
- etc->resizable = resizable;
-
- g_object_ref (etc->ecell);
if (etc->icon_name != NULL)
etc_load_icon (etc);
diff --git a/e-util/e-table-col.h b/e-util/e-table-col.h
index 243aa04e7a..1f8d4b158b 100644
--- a/e-util/e-table-col.h
+++ b/e-util/e-table-col.h
@@ -31,6 +31,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <e-util/e-cell.h>
+#include <e-util/e-table-column-specification.h>
/* Standard GObject macros */
#define E_TYPE_TABLE_COL \
@@ -68,6 +69,8 @@ typedef struct _ETableColClass ETableColClass;
struct _ETableCol {
GObject parent;
+ ETableColumnSpecification *spec;
+
gchar *text;
gchar *icon_name;
GdkPixbuf *pixbuf;
@@ -78,15 +81,7 @@ struct _ETableCol {
GCompareDataFunc compare;
ETableSearchFunc search;
- guint selected : 1;
- guint resizable : 1;
- guint disabled : 1;
- guint sortable : 1;
- guint groupable : 1;
-
- gint col_idx;
- gint compare_col;
- gint priority;
+ gboolean selected;
GtkJustification justification;
@@ -97,17 +92,12 @@ struct _ETableColClass {
GObjectClass parent_class;
};
-GType e_table_col_get_type (void) G_GNUC_CONST;
-ETableCol * e_table_col_new (gint col_idx,
- const gchar *text,
- const gchar *icon_name,
- gdouble expansion,
- gint min_width,
- ECell *ecell,
- GCompareDataFunc compare,
- gboolean resizable,
- gboolean disabled,
- gint priority);
+GType e_table_col_get_type (void) G_GNUC_CONST;
+ETableCol * e_table_col_new (ETableColumnSpecification *spec,
+ const gchar *text,
+ const gchar *icon_name,
+ ECell *ecell,
+ GCompareDataFunc compare);
G_END_DECLS
diff --git a/e-util/e-table-field-chooser-item.c b/e-util/e-table-field-chooser-item.c
index f4a85d6b83..592349ae57 100644
--- a/e-util/e-table-field-chooser-item.c
+++ b/e-util/e-table-field-chooser-item.c
@@ -100,7 +100,7 @@ etfci_find_button (ETableFieldChooserItem *etfci,
ETableCol *ecol;
ecol = e_table_header_get_column (etfci->combined_header, i);
- if (ecol->disabled)
+ if (ecol->spec->disabled)
continue;
height += e_table_header_compute_height (
ecol, GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas));
@@ -127,9 +127,10 @@ etfci_rebuild_combined (ETableFieldChooserItem *etfci)
count = e_table_header_count (etfci->header);
for (i = 0; i < count; i++) {
ETableCol *ecol = e_table_header_get_column (etfci->header, i);
- if (ecol->disabled)
+ if (ecol->spec->disabled)
continue;
- g_hash_table_add (hash, GINT_TO_POINTER (ecol->col_idx));
+ g_hash_table_add (
+ hash, GINT_TO_POINTER (ecol->spec->model_col));
}
count = e_table_header_count (etfci->full_header);
@@ -138,9 +139,9 @@ etfci_rebuild_combined (ETableFieldChooserItem *etfci)
gpointer key;
ecol = e_table_header_get_column (etfci->full_header, i);
- key = GINT_TO_POINTER (ecol->col_idx);
+ key = GINT_TO_POINTER (ecol->spec->model_col);
- if (ecol->disabled)
+ if (ecol->spec->disabled)
continue;
if (!g_hash_table_contains (hash, key))
@@ -170,7 +171,7 @@ etfci_reflow (GnomeCanvasItem *item,
ETableCol *ecol;
ecol = e_table_header_get_column (etfci->combined_header, i);
- if (ecol->disabled)
+ if (ecol->spec->disabled)
continue;
height += e_table_header_compute_height (
ecol, GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas));
@@ -509,7 +510,7 @@ etfci_draw (GnomeCanvasItem *item,
ecol = e_table_header_get_column (etfci->combined_header, row);
- if (ecol->disabled)
+ if (ecol->spec->disabled)
continue;
y2 += e_table_header_compute_height (ecol, GTK_WIDGET (canvas));
@@ -588,10 +589,10 @@ etfci_start_drag (ETableFieldChooserItem *etfci,
ecol = e_table_header_get_column (etfci->combined_header, drag_col);
- if (ecol->disabled)
+ if (ecol->spec->disabled)
return;
- etfci->drag_col = ecol->col_idx;
+ etfci->drag_col = ecol->spec->model_col;
etfci_drag_types[0].target = g_strdup_printf (
"%s-%s", etfci_drag_types[0].target, etfci->dnd_code);
diff --git a/e-util/e-table-group-container.c b/e-util/e-table-group-container.c
index 6fe5898f9a..68239b123f 100644
--- a/e-util/e-table-group-container.c
+++ b/e-util/e-table-group-container.c
@@ -76,7 +76,7 @@ e_table_group_container_child_node_free (ETableGroupContainer *etgc,
g_object_run_dispose (G_OBJECT (child));
e_table_model_free_value (
- etg->model, etgc->ecol->col_idx,
+ etg->model, etgc->ecol->spec->model_col,
child_node->key);
g_free (child_node->string);
g_object_run_dispose (G_OBJECT (child_node->text));
@@ -515,9 +515,9 @@ create_child_node (ETableGroupContainer *etgc,
G_CALLBACK (child_start_drag), etgc);
child_node->child = child;
child_node->key = e_table_model_duplicate_value (
- etg->model, etgc->ecol->col_idx, val);
+ etg->model, etgc->ecol->spec->model_col, val);
child_node->string = e_table_model_value_to_string (
- etg->model, etgc->ecol->col_idx, val);
+ etg->model, etgc->ecol->spec->model_col, val);
child_node->count = 0;
return child_node;
@@ -536,7 +536,8 @@ etgc_add (ETableGroup *etg,
gpointer val;
gint i = 0;
- val = e_table_model_value_at (etg->model, etgc->ecol->col_idx, row);
+ val = e_table_model_value_at (
+ etg->model, etgc->ecol->spec->model_col, row);
for (; list; list = g_list_next (list), i++) {
gint comp_val;
@@ -592,14 +593,14 @@ etgc_add_array (ETableGroup *etg,
cmp_cache = e_table_sorting_utils_create_cmp_cache ();
lastval = e_table_model_value_at (
- etg->model, etgc->ecol->col_idx, array[0]);
+ etg->model, etgc->ecol->spec->model_col, array[0]);
for (i = 1; i < count; i++) {
gpointer val;
gint comp_val;
val = e_table_model_value_at (
- etg->model, etgc->ecol->col_idx, array[i]);
+ etg->model, etgc->ecol->spec->model_col, array[i]);
comp_val = (*comp)(lastval, val, cmp_cache);
if (comp_val != 0) {
diff --git a/e-util/e-table-header-item.c b/e-util/e-table-header-item.c
index 103ed3a807..ddbe7c8cfd 100644
--- a/e-util/e-table-header-item.c
+++ b/e-util/e-table-header-item.c
@@ -561,26 +561,6 @@ ethi_remove_destroy_marker (ETableHeaderItem *ethi)
ethi->remove_item = NULL;
}
-#if 0
-static gboolean
-moved (ETableHeaderItem *ethi,
- guint col,
- guint model_col)
-{
- if (col == -1)
- return TRUE;
- ecol = e_table_header_get_column (ethi->eth, col);
- if (ecol->col_idx == model_col)
- return FALSE;
- if (col > 0) {
- ecol = e_table_header_get_column (ethi->eth, col - 1);
- if (ecol->col_idx == model_col)
- return FALSE;
- }
- return TRUE;
-}
-#endif
-
static void
do_drag_motion (ETableHeaderItem *ethi,
GdkDragContext *context,
@@ -823,7 +803,7 @@ ethi_drag_data_received (GtkWidget *canvas,
if (column >= 0) {
for (i = 0; i < count; i++) {
ETableCol *ecol = e_table_header_get_column (ethi->eth, i);
- if (ecol->col_idx == column) {
+ if (ecol->spec->model_col == column) {
e_table_header_move (ethi->eth, i, drop_col);
found = TRUE;
break;
@@ -837,7 +817,7 @@ ethi_drag_data_received (GtkWidget *canvas,
ecol = e_table_header_get_column (
ethi->full_header, i);
- if (ecol->col_idx == column) {
+ if (ecol->spec->model_col == column) {
e_table_header_add_column (
ethi->eth, ecol,
drop_col);
@@ -862,7 +842,7 @@ ethi_drag_data_get (GtkWidget *canvas,
if (ethi->drag_col != -1) {
ETableCol *ecol = e_table_header_get_column (ethi->eth, ethi->drag_col);
- gchar *string = g_strdup_printf ("%d", ecol->col_idx);
+ gchar *string = g_strdup_printf ("%d", ecol->spec->model_col);
gtk_selection_data_set (
selection_data,
GDK_SELECTION_TYPE_STRING,
@@ -1092,7 +1072,7 @@ ethi_draw (GnomeCanvasItem *item,
x1 - x, -y, width, height,
x2 - x1, ethi->height,
(ETableColArrow) g_hash_table_lookup (
- arrows, GINT_TO_POINTER (ecol->col_idx)));
+ arrows, GINT_TO_POINTER (ecol->spec->model_col)));
gtk_style_context_restore (context);
}
@@ -1176,7 +1156,7 @@ set_cursor (ETableHeaderItem *ethi,
ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
/* Last column is not resizable */
- if (ecol->resizable && col != last_col) {
+ if (ecol->spec->resizable && col != last_col) {
gint c = col + 1;
/* Column is not resizable if all columns after it
@@ -1185,7 +1165,7 @@ set_cursor (ETableHeaderItem *ethi,
ETableCol *ecol2;
ecol2 = e_table_header_get_column (ethi->eth, c);
- if (ecol2->resizable) {
+ if (ecol2->spec->resizable) {
resizable = TRUE;
break;
}
@@ -1307,7 +1287,7 @@ ethi_start_drag (ETableHeaderItem *ethi,
col_width, ethi->height,
col_width, ethi->height,
(ETableColArrow) g_hash_table_lookup (
- arrows, GINT_TO_POINTER (ecol->col_idx)));
+ arrows, GINT_TO_POINTER (ecol->spec->model_col)));
gtk_drag_set_icon_surface (context, s);
cairo_surface_destroy (s);
@@ -1332,8 +1312,8 @@ ethi_popup_sort_ascending (GtkWidget *widget,
ETableHeaderItem *ethi = info->ethi;
col = e_table_header_get_column (ethi->eth, info->col);
- if (col->sortable)
- model_col = col->col_idx;
+ if (col->spec->sortable)
+ model_col = col->spec->model_col;
length = e_table_sort_info_grouping_get_count (ethi->sort_info);
for (i = 0; i < length; i++) {
@@ -1388,8 +1368,8 @@ ethi_popup_sort_descending (GtkWidget *widget,
ETableHeaderItem *ethi = info->ethi;
col = e_table_header_get_column (ethi->eth, info->col);
- if (col->sortable)
- model_col = col->col_idx;
+ if (col->spec->sortable)
+ model_col = col->spec->model_col;
length = e_table_sort_info_grouping_get_count (ethi->sort_info);
for (i = 0; i < length; i++) {
@@ -1452,7 +1432,7 @@ ethi_popup_group_field (GtkWidget *widget,
ETableSortColumn column;
col = e_table_header_get_column (ethi->eth, info->col);
- model_col = col->col_idx;
+ model_col = col->spec->model_col;
column.column = model_col;
column.ascending = 1;
@@ -1655,7 +1635,7 @@ sort_by_id (GtkWidget *menu_item,
ETableSortColumn column;
column = e_table_sort_info_sorting_get_nth (ethi->sort_info, 0);
- clearfirst = ecol->sortable && ecol->col_idx != column.column;
+ clearfirst = ecol->spec->sortable && ecol->spec->model_col != column.column;
}
if (clearfirst)
@@ -1740,8 +1720,8 @@ ethi_header_context_menu (ETableHeaderItem *ethi,
{
gchar *text = NULL;
- if (!ethi->full_header->columns[ncol]->sortable ||
- ethi->full_header->columns[ncol]->disabled)
+ if (!ethi->full_header->columns[ncol]->spec->sortable ||
+ ethi->full_header->columns[ncol]->spec->disabled)
continue;
if (ncol == sort_col) {
@@ -1801,8 +1781,8 @@ ethi_change_sort_state (ETableHeaderItem *ethi,
if (col == NULL)
return;
- if (col->sortable)
- model_col = col->col_idx;
+ if (col->spec->sortable)
+ model_col = col->spec->model_col;
length = e_table_sort_info_grouping_get_count (ethi->sort_info);
for (i = 0; i < length; i++) {
@@ -1965,7 +1945,7 @@ ethi_event (GnomeCanvasItem *item,
*/
ecol = e_table_header_get_column (ethi->eth, col);
- if (!ecol->resizable)
+ if (!ecol->spec->resizable)
break;
ethi->resize_col = col;
ethi->resize_start_pos = start - ecol->width;
@@ -2047,7 +2027,7 @@ ethi_event (GnomeCanvasItem *item,
popup = e_popup_menu_create_with_domain (
ethi_context_menu,
1 +
- (ecol->sortable ? 0 : 2) +
+ (ecol->spec->sortable ? 0 : 2) +
((ethi->table || ethi->tree) ? 0 : 4) +
((e_table_header_count (ethi->eth) > 1) ? 0 : 8),
((e_table_sort_info_get_can_group (
diff --git a/e-util/e-table-header.c b/e-util/e-table-header.c
index d06b26e147..546c8d1d3b 100644
--- a/e-util/e-table-header.c
+++ b/e-util/e-table-header.c
@@ -483,7 +483,7 @@ e_table_header_get_column_by_col_idx (ETableHeader *eth,
g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL);
for (i = 0; i < eth->col_count; i++) {
- if (eth->columns[i]->col_idx == col_idx) {
+ if (eth->columns[i]->spec->model_col == col_idx) {
return eth->columns[i];
}
}
@@ -526,7 +526,7 @@ e_table_header_index (ETableHeader *eth,
g_return_val_if_fail (E_IS_TABLE_HEADER (eth), -1);
g_return_val_if_fail (col >= 0 && col < eth->col_count, -1);
- return eth->columns[col]->col_idx;
+ return eth->columns[col]->spec->model_col;
}
/**
@@ -746,7 +746,7 @@ eth_set_size (ETableHeader *eth,
g_return_if_fail (idx < eth->col_count);
/* If this column is not resizable, don't do anything. */
- if (!eth->columns[idx]->resizable)
+ if (!eth->columns[idx]->spec->resizable)
return;
expansion = 0;
@@ -770,7 +770,7 @@ eth_set_size (ETableHeader *eth,
*/
for (; i < eth->col_count; i++) {
min_width += eth->columns[i]->min_width + eth->width_extras;
- if (eth->columns[i]->resizable) {
+ if (eth->columns[i]->spec->resizable) {
expansion += eth->columns[i]->expansion;
expandable_count++;
}
@@ -837,7 +837,7 @@ eth_set_size (ETableHeader *eth,
*/
if (old_expansion == 0) {
for (i = idx + 1; i < eth->col_count; i++) {
- if (eth->columns[idx]->resizable) {
+ if (eth->columns[idx]->spec->resizable) {
/* expandable_count != 0 by (1) */
eth->columns[i]->expansion = expansion / expandable_count;
}
@@ -847,7 +847,7 @@ eth_set_size (ETableHeader *eth,
}
for (i = idx + 1; i < eth->col_count; i++) {
- if (eth->columns[idx]->resizable) {
+ if (eth->columns[idx]->spec->resizable) {
/* old_expansion != 0 by (2) */
eth->columns[i]->expansion *= expansion / old_expansion;
}
@@ -910,9 +910,9 @@ eth_calc_widths (ETableHeader *eth)
expansion = 0;
for (i = 0; i < eth->col_count; i++) {
extra -= eth->columns[i]->min_width + eth->width_extras;
- if (eth->columns[i]->resizable && eth->columns[i]->expansion > 0)
+ if (eth->columns[i]->spec->resizable && eth->columns[i]->expansion > 0)
last_resizable = i;
- expansion += eth->columns[i]->resizable ? eth->columns[i]->expansion : 0;
+ expansion += eth->columns[i]->spec->resizable ? eth->columns[i]->expansion : 0;
widths[i] = eth->columns[i]->min_width + eth->width_extras;
}
if (eth->sort_info)
@@ -921,7 +921,7 @@ eth_calc_widths (ETableHeader *eth)
if (expansion != 0 && extra > 0) {
for (i = 0; i < last_resizable; i++) {
next_position +=
- extra * (eth->columns[i]->resizable ?
+ extra * (eth->columns[i]->spec->resizable ?
eth->columns[i]->expansion : 0) / expansion;
widths[i] += next_position - last_position;
last_position = next_position;
@@ -974,13 +974,13 @@ e_table_header_prioritized_column (ETableHeader *eth)
count = e_table_header_count (eth);
if (count == 0)
return -1;
- best_priority = e_table_header_get_column (eth, 0)->priority;
- best_model_col = e_table_header_get_column (eth, 0)->col_idx;
+ best_priority = e_table_header_get_column (eth, 0)->spec->priority;
+ best_model_col = e_table_header_get_column (eth, 0)->spec->model_col;
for (i = 1; i < count; i++) {
- gint priority = e_table_header_get_column (eth, i)->priority;
+ gint priority = e_table_header_get_column (eth, i)->spec->priority;
if (priority > best_priority) {
best_priority = priority;
- best_model_col = e_table_header_get_column (eth, i)->col_idx;
+ best_model_col = e_table_header_get_column (eth, i)->spec->model_col;
}
}
return best_model_col;
@@ -1002,9 +1002,9 @@ e_table_header_prioritized_column_selected (ETableHeader *eth,
for (i = 1; i < count; i++) {
ETableCol *col = e_table_header_get_column (eth, i);
if (col) {
- if ((best_col == NULL || col->priority > best_priority)
+ if ((best_col == NULL || col->spec->priority > best_priority)
&& check_func (col, user_data)) {
- best_priority = col->priority;
+ best_priority = col->spec->priority;
best_col = col;
}
}
diff --git a/e-util/e-table-item.c b/e-util/e-table-item.c
index 66477f5cba..c552922a34 100644
--- a/e-util/e-table-item.c
+++ b/e-util/e-table-item.c
@@ -206,14 +206,14 @@ view_to_model_row (ETableItem *eti,
inline static gint
model_to_view_col (ETableItem *eti,
- gint col)
+ gint model_col)
{
gint i;
- if (col == -1)
+ if (model_col == -1)
return -1;
for (i = 0; i < eti->cols; i++) {
ETableCol *ecol = e_table_header_get_column (eti->header, i);
- if (ecol->col_idx == col)
+ if (ecol->spec->model_col == model_col)
return i;
}
return -1;
@@ -221,10 +221,11 @@ model_to_view_col (ETableItem *eti,
inline static gint
view_to_model_col (ETableItem *eti,
- gint col)
+ gint view_col)
{
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
- return ecol ? ecol->col_idx : -1;
+ ETableCol *ecol = e_table_header_get_column (eti->header, view_col);
+
+ return (ecol != NULL) ? ecol->spec->model_col : -1;
}
static void
@@ -2038,7 +2039,7 @@ eti_draw (GnomeCanvasItem *item,
switch (eti->cursor_mode) {
case E_CURSOR_SIMPLE:
case E_CURSOR_SPREADSHEET:
- if (cursor_col == ecol->col_idx && cursor_row == view_to_model_row (eti, row)) {
+ if (cursor_col == ecol->spec->model_col && cursor_row == view_to_model_row (eti, row)) {
col_selected = !col_selected;
cursor = TRUE;
}
@@ -2122,8 +2123,11 @@ eti_draw (GnomeCanvasItem *item,
}
e_cell_draw (
- ecell_view, cr, ecol->col_idx, col, row, flags,
- xd, yd, xd + ecol->width, yd + height);
+ ecell_view, cr,
+ ecol->spec->model_col,
+ col, row, flags,
+ xd, yd,
+ xd + ecol->width, yd + height);
if (!f_found && !selected) {
switch (eti->cursor_mode) {
@@ -3747,13 +3751,13 @@ e_table_item_calculate_print_widths (ETableHeader *eth,
expansion = 0;
for (i = 0; i < eth->col_count; i++) {
extra -= eth->columns[i]->min_width * scale;
- if (eth->columns[i]->resizable && eth->columns[i]->expansion > 0)
+ if (eth->columns[i]->spec->resizable && eth->columns[i]->expansion > 0)
last_resizable = i;
- expansion += eth->columns[i]->resizable ? eth->columns[i]->expansion : 0;
+ expansion += eth->columns[i]->spec->resizable ? eth->columns[i]->expansion : 0;
widths[i] = eth->columns[i]->min_width * scale;
}
for (i = 0; i <= last_resizable; i++) {
- widths[i] += extra * (eth->columns[i]->resizable ? eth->columns[i]->expansion : 0) / expansion;
+ widths[i] += extra * (eth->columns[i]->spec->resizable ? eth->columns[i]->expansion : 0) / expansion;
}
return widths;
diff --git a/e-util/e-table-sorter.c b/e-util/e-table-sorter.c
index e570042217..1342326c8f 100644
--- a/e-util/e-table-sorter.c
+++ b/e-util/e-table-sorter.c
@@ -149,7 +149,7 @@ table_sorter_sort (ETableSorter *table_sorter)
col = e_table_header_get_column (table_sorter->full_header, e_table_header_count (table_sorter->full_header) - 1);
for (i = 0; i < rows; i++) {
- qd.vals[i * cols + j] = e_table_model_value_at (table_sorter->source, col->col_idx, i);
+ qd.vals[i * cols + j] = e_table_model_value_at (table_sorter->source, col->spec->model_col, i);
}
qd.compare[j] = col->compare;
diff --git a/e-util/e-table-sorting-utils.c b/e-util/e-table-sorting-utils.c
index b5e7930462..a8c5bcdf5e 100644
--- a/e-util/e-table-sorting-utils.c
+++ b/e-util/e-table-sorting-utils.c
@@ -59,9 +59,9 @@ etsu_compare (ETableModel *source,
comp_val = (*col->compare) (
e_table_model_value_at (
- source, col->compare_col, row1),
+ source, col->spec->compare_col, row1),
e_table_model_value_at (
- source, col->compare_col, row2),
+ source, col->spec->compare_col, row2),
cmp_cache);
if (column.ascending)
sort_type = GTK_SORT_ASCENDING;
@@ -173,7 +173,7 @@ e_table_sorting_utils_sort (ETableModel *source,
}
for (i = 0; i < rows; i++) {
- closure.vals[map_table[i] * cols + j] = e_table_model_value_at (source, col->compare_col, map_table[i]);
+ closure.vals[map_table[i] * cols + j] = e_table_model_value_at (source, col->spec->compare_col, map_table[i]);
}
closure.compare[j] = col->compare;
if (column.ascending)
@@ -214,7 +214,7 @@ e_table_sorting_utils_affects_sort (ETableSortInfo *sort_info,
col = e_table_header_get_column (full_header, last);
}
- if (compare_col == col->compare_col)
+ if (compare_col == col->spec->compare_col)
return TRUE;
}
@@ -302,9 +302,9 @@ etsu_tree_compare (ETreeModel *source,
comp_val = (*col->compare) (
e_tree_model_value_at (
- source, path1, col->compare_col),
+ source, path1, col->spec->compare_col),
e_tree_model_value_at (
- source, path2, col->compare_col),
+ source, path2, col->spec->compare_col),
cmp_cache);
if (column.ascending)
sort_type = GTK_SORT_ASCENDING;
@@ -368,7 +368,7 @@ e_table_sorting_utils_tree_sort (ETreeModel *source,
}
for (i = 0; i < count; i++) {
- closure.vals[i * cols + j] = e_tree_model_sort_value_at (source, map_table[i], col->compare_col);
+ closure.vals[i * cols + j] = e_tree_model_sort_value_at (source, map_table[i], col->spec->compare_col);
}
closure.compare[j] = col->compare;
if (column.ascending)
diff --git a/e-util/e-table-utils.c b/e-util/e-table-utils.c
index 207da0c04c..3c598e38a9 100644
--- a/e-util/e-table-utils.c
+++ b/e-util/e-table-utils.c
@@ -104,39 +104,25 @@ et_col_spec_to_col (ETableColumnSpecification *col_spec,
ete, col_spec->pixbuf);
if (icon_name != NULL) {
col = e_table_col_new (
- col_spec->model_col,
+ col_spec,
title, icon_name,
- col_spec->expansion,
- col_spec->minimum_width,
- cell, compare,
- col_spec->resizable,
- col_spec->disabled,
- col_spec->priority);
+ cell, compare);
}
}
if (col == NULL && col_spec->title && *col_spec->title) {
col = e_table_col_new (
- col_spec->model_col, title, NULL,
- col_spec->expansion,
- col_spec->minimum_width,
- cell, compare,
- col_spec->resizable,
- col_spec->disabled,
- col_spec->priority);
+ col_spec,
+ title, NULL,
+ cell, compare);
}
- if (col) {
+ if (col != NULL)
col->search = search;
- col->sortable = col_spec->sortable;
- }
+
g_free (title);
}
- if (col && col_spec->compare_col != col_spec->model_col)
- g_object_set (
- col,
- "compare_col", col_spec->compare_col,
- NULL);
+
return col;
}
diff --git a/e-util/e-table.c b/e-util/e-table.c
index 24ee13f38c..0aae2032b6 100644
--- a/e-util/e-table.c
+++ b/e-util/e-table.c
@@ -480,27 +480,29 @@ et_search_search (ETableSearch *search,
if ((flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST) &&
cursor < rows && cursor >= 0 &&
- check_row (et, cursor, col->col_idx, col->search, string))
+ check_row (et, cursor, col->spec->model_col, col->search, string))
return TRUE;
cursor = e_sorter_model_to_sorted (E_SORTER (et->sorter), cursor);
for (i = cursor + 1; i < rows; i++) {
gint model_row = e_sorter_sorted_to_model (E_SORTER (et->sorter), i);
- if (check_row (et, model_row, col->col_idx, col->search, string)) {
+ if (check_row (et, model_row, col->spec->model_col, col->search, string)) {
e_selection_model_select_as_key_press (
E_SELECTION_MODEL (et->selection),
- model_row, col->col_idx, GDK_CONTROL_MASK);
+ model_row, col->spec->model_col,
+ GDK_CONTROL_MASK);
return TRUE;
}
}
for (i = 0; i < cursor; i++) {
gint model_row = e_sorter_sorted_to_model (E_SORTER (et->sorter), i);
- if (check_row (et, model_row, col->col_idx, col->search, string)) {
+ if (check_row (et, model_row, col->spec->model_col, col->search, string)) {
e_selection_model_select_as_key_press (
E_SELECTION_MODEL (et->selection),
- model_row, col->col_idx, GDK_CONTROL_MASK);
+ model_row, col->spec->model_col,
+ GDK_CONTROL_MASK);
return TRUE;
}
}
@@ -510,7 +512,7 @@ et_search_search (ETableSearch *search,
/* Check if the cursor row is the only matching row. */
return (!(flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST) &&
cursor < rows && cursor >= 0 &&
- check_row (et, cursor, col->col_idx, col->search, string));
+ check_row (et, cursor, col->spec->model_col, col->search, string));
}
static void
@@ -526,7 +528,8 @@ et_search_accept (ETableSearch *search,
g_object_get (et->selection, "cursor_row", &cursor, NULL);
e_selection_model_select_as_key_press (
- E_SELECTION_MODEL (et->selection), cursor, col->col_idx, 0);
+ E_SELECTION_MODEL (et->selection),
+ cursor, col->spec->model_col, 0);
}
static void
@@ -1691,7 +1694,7 @@ e_table_get_state_object (ETable *e_table)
ETableCol *col = e_table_header_get_column (e_table->header, i);
state->columns[i] = -1;
for (j = 0; j < full_col_count; j++) {
- if (col->col_idx == e_table_header_index (e_table->full_header, j)) {
+ if (col->spec->model_col == e_table_header_index (e_table->full_header, j)) {
state->columns[i] = j;
break;
}
diff --git a/e-util/e-tree.c b/e-util/e-tree.c
index 91caea7c43..a8ccefcb5d 100644
--- a/e-util/e-tree.c
+++ b/e-util/e-tree.c
@@ -527,7 +527,8 @@ search_search_callback (ETreeModel *model,
ETableCol *col = current_search_col (cb_data->tree);
value = e_tree_model_value_at (
- model, path, cb_data->tree->priv->current_search_col->col_idx);
+ model, path,
+ cb_data->tree->priv->current_search_col->spec->model_col);
return col->search (value, cb_data->string);
}
@@ -554,7 +555,8 @@ et_search_search (ETableSearch *search,
if (cursor && (flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST)) {
gconstpointer value;
- value = e_tree_model_value_at (tree->priv->model, cursor, col->col_idx);
+ value = e_tree_model_value_at (
+ tree->priv->model, cursor, col->spec->model_col);
if (col->search (value, string)) {
return TRUE;
@@ -577,12 +579,14 @@ et_search_search (ETableSearch *search,
e_selection_model_select_as_key_press (
E_SELECTION_MODEL (tree->priv->selection),
- model_row, col->col_idx, GDK_CONTROL_MASK);
+ model_row, col->spec->model_col,
+ GDK_CONTROL_MASK);
return TRUE;
} else if (cursor && !(flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST)) {
gconstpointer value;
- value = e_tree_model_value_at (tree->priv->model, cursor, col->col_idx);
+ value = e_tree_model_value_at (
+ tree->priv->model, cursor, col->spec->model_col);
return col->search (value, string);
} else
@@ -603,7 +607,7 @@ et_search_accept (ETableSearch *search,
e_selection_model_select_as_key_press (
E_SELECTION_MODEL (tree->priv->selection),
- cursor, col->col_idx, 0);
+ cursor, col->spec->model_col, 0);
}
static void
@@ -1394,7 +1398,7 @@ e_tree_get_state_object (ETree *tree)
ETableCol *col = e_table_header_get_column (tree->priv->header, i);
state->columns[i] = -1;
for (j = 0; j < full_col_count; j++) {
- if (col->col_idx == e_table_header_index (tree->priv->full_header, j)) {
+ if (col->spec->model_col == e_table_header_index (tree->priv->full_header, j)) {
state->columns[i] = j;
break;
}
diff --git a/e-util/gal-a11y-e-table-item.c b/e-util/gal-a11y-e-table-item.c
index 9f5c407507..51bce1725b 100644
--- a/e-util/gal-a11y-e-table-item.c
+++ b/e-util/gal-a11y-e-table-item.c
@@ -134,10 +134,11 @@ view_to_model_row (ETableItem *eti,
inline static gint
view_to_model_col (ETableItem *eti,
- gint col)
+ gint view_col)
{
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
- return ecol ? ecol->col_idx : -1;
+ ETableCol *ecol = e_table_header_get_column (eti->header, view_col);
+
+ return (ecol != NULL) ? ecol->spec->model_col : -1;
}
inline static gint
@@ -165,14 +166,14 @@ model_to_view_row (ETableItem *eti,
inline static gint
model_to_view_col (ETableItem *eti,
- gint col)
+ gint model_col)
{
gint i;
- if (col == -1)
+ if (model_col == -1)
return -1;
for (i = 0; i < eti->cols; i++) {
ETableCol *ecol = e_table_header_get_column (eti->header, i);
- if (ecol->col_idx == col)
+ if (ecol->spec->model_col == model_col)
return i;
}
return -1;
@@ -405,7 +406,7 @@ eti_ref_at (AtkTable *table,
item,
cell_view,
ATK_OBJECT (table),
- ecol->col_idx,
+ ecol->spec->model_col,
column,
row);
if (ATK_IS_OBJECT (ret)) {