aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-cell-popup.c25
-rw-r--r--widgets/table/e-table-col.c13
-rw-r--r--widgets/table/e-table-col.h1
-rw-r--r--widgets/table/e-table-column-specification.c4
-rw-r--r--widgets/table/e-table-column-specification.h1
-rw-r--r--widgets/table/e-table-sorting-utils.c14
-rw-r--r--widgets/table/e-table-utils.c4
-rw-r--r--widgets/table/e-table.c15
-rw-r--r--widgets/table/e-table.h3
9 files changed, 50 insertions, 30 deletions
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index b2a0f3bf03..96eebfb6f0 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -264,17 +264,18 @@ ecp_draw (ECellView *ecv, GdkDrawable *drawable,
GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ecv->e_table_item_view)->canvas);
GtkShadowType shadow;
GdkRectangle rect;
- gboolean show_popup_arrow = FALSE;
+ gboolean show_popup_arrow;
/* Display the popup arrow if we are the cursor cell, or the popup
is shown for this cell. */
- if (flags & E_CELL_CURSOR) {
- show_popup_arrow = TRUE;
- ecp->popup_arrow_shown = TRUE;
- } else if (ecp->popup_shown && ecp->popup_view_col == view_col
- && ecp->popup_row == row && ecp->popup_model == ((ECellView *) ecp_view)->e_table_model) {
- show_popup_arrow = TRUE;
- }
+ show_popup_arrow = e_table_model_is_cell_editable (ecv->e_table_model, model_col, row) &&
+ (flags & E_CELL_CURSOR ||
+ (ecp->popup_shown && ecp->popup_view_col == view_col
+ && ecp->popup_row == row
+ && ecp->popup_model == ((ECellView *) ecp_view)->e_table_model));
+
+ if (flags & E_CELL_CURSOR)
+ ecp->popup_arrow_shown = show_popup_arrow;
#if 0
g_print ("In ecp_draw row:%i col: %i %i,%i %i,%i Show Arrow:%i\n",
@@ -329,7 +330,8 @@ ecp_event (ECellView *ecv, GdkEvent *event, int model_col, int view_col,
switch (event->type) {
case GDK_BUTTON_PRESS:
- if (flags & E_CELL_CURSOR
+ if (e_table_model_is_cell_editable (ecv->e_table_model, model_col, row) &&
+ flags & E_CELL_CURSOR
&& ecp->popup_arrow_shown) {
width = e_table_header_col_diff (eti->header, view_col,
view_col + 1);
@@ -344,10 +346,9 @@ ecp_event (ECellView *ecv, GdkEvent *event, int model_col, int view_col,
}
}
break;
- case GDK_BUTTON_RELEASE:
- break;
case GDK_KEY_PRESS:
- if (event->key.state & GDK_MOD1_MASK
+ if (e_table_model_is_cell_editable (ecv->e_table_model, model_col, row) &&
+ event->key.state & GDK_MOD1_MASK
&& event->key.keyval == GDK_Down) {
g_print ("## Alt-Down pressed\n");
return e_cell_popup_do_popup (ecp_view, event, row, view_col);
diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c
index 7d302f4d80..fa53fb0d0c 100644
--- a/widgets/table/e-table-col.c
+++ b/widgets/table/e-table-col.c
@@ -34,7 +34,8 @@ static GtkObjectClass *parent_class;
enum {
ARG_0,
- ARG_SORTABLE
+ ARG_SORTABLE,
+ ARG_COMPARE_COL
};
static void
@@ -62,6 +63,9 @@ etc_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_SORTABLE:
etc->sortable = GTK_VALUE_BOOL(*arg);
break;
+ case ARG_COMPARE_COL:
+ etc->compare_col = GTK_VALUE_INT(*arg);
+ break;
}
}
@@ -74,6 +78,9 @@ etc_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_SORTABLE:
GTK_VALUE_BOOL(*arg) = etc->sortable;
break;
+ case ARG_COMPARE_COL:
+ GTK_VALUE_INT(*arg) = etc->compare_col;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -90,6 +97,8 @@ e_table_col_class_init (GtkObjectClass *object_class)
gtk_object_add_arg_type ("ETableCol::sortable",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SORTABLE);
+ gtk_object_add_arg_type ("ETableCol::compare_col",
+ GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_COMPARE_COL);
}
static void
@@ -148,6 +157,7 @@ e_table_col_new (int col_idx, const char *text, double expansion, int min_width,
etc->is_pixbuf = FALSE;
etc->col_idx = col_idx;
+ etc->compare_col = col_idx;
etc->text = g_strdup (text);
etc->pixbuf = NULL;
etc->expansion = expansion;
@@ -208,6 +218,7 @@ e_table_col_new_with_pixbuf (int col_idx, const char *text, GdkPixbuf *pixbuf, d
etc->is_pixbuf = TRUE;
etc->col_idx = col_idx;
+ etc->compare_col = col_idx;
etc->text = g_strdup(text);
etc->pixbuf = pixbuf;
etc->expansion = expansion;
diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h
index 485bd2d84c..dfeed6707c 100644
--- a/widgets/table/e-table-col.h
+++ b/widgets/table/e-table-col.h
@@ -63,6 +63,7 @@ typedef struct {
unsigned int sortable:1;
unsigned int groupable:1;
int col_idx;
+ int compare_col;
int priority;
GtkJustification justification;
diff --git a/widgets/table/e-table-column-specification.c b/widgets/table/e-table-column-specification.c
index 6ff4a67bd3..bc296e0885 100644
--- a/widgets/table/e-table-column-specification.c
+++ b/widgets/table/e-table-column-specification.c
@@ -66,6 +66,7 @@ static void
etcs_init (ETableColumnSpecification *specification)
{
specification->model_col = 0;
+ specification->compare_col = 0;
specification->title = g_strdup("");
specification->pixbuf = NULL;
@@ -97,6 +98,7 @@ e_table_column_specification_load_from_node (ETableColumnSpecification *etcs,
free_strings(etcs);
etcs->model_col = e_xml_get_integer_prop_by_name (node, "model_col");
+ etcs->compare_col = e_xml_get_integer_prop_by_name_with_default (node, "compare_col", etcs->model_col);
etcs->title = e_xml_get_string_prop_by_name (node, "_title");
etcs->pixbuf = e_xml_get_string_prop_by_name (node, "pixbuf");
@@ -125,6 +127,8 @@ e_table_column_specification_save_to_node (ETableColumnSpecification *specificat
node = xmlNewNode(NULL, "ETableColumn");
e_xml_set_integer_prop_by_name(node, "model_col", specification->model_col);
+ if (specification->compare_col != specification->model_col)
+ e_xml_set_integer_prop_by_name(node, "compare_col", specification->compare_col);
e_xml_set_string_prop_by_name(node, "_title", specification->title);
e_xml_set_string_prop_by_name(node, "pixbuf", specification->pixbuf);
diff --git a/widgets/table/e-table-column-specification.h b/widgets/table/e-table-column-specification.h
index bcd2889dc1..67bf7afb48 100644
--- a/widgets/table/e-table-column-specification.h
+++ b/widgets/table/e-table-column-specification.h
@@ -42,6 +42,7 @@ extern "C" {
typedef struct {
GtkObject base;
int model_col;
+ int compare_col;
char *title;
char *pixbuf;
diff --git a/widgets/table/e-table-sorting-utils.c b/widgets/table/e-table-sorting-utils.c
index fac9666384..80a9564a36 100644
--- a/widgets/table/e-table-sorting-utils.c
+++ b/widgets/table/e-table-sorting-utils.c
@@ -43,8 +43,8 @@ etsu_compare(ETableModel *source, ETableSortInfo *sort_info, ETableHeader *full_
col = e_table_header_get_column_by_col_idx(full_header, column.column);
if (col == NULL)
col = e_table_header_get_column (full_header, e_table_header_count (full_header) - 1);
- comp_val = (*col->compare)(e_table_model_value_at (source, col->col_idx, row1),
- e_table_model_value_at (source, col->col_idx, row2));
+ comp_val = (*col->compare)(e_table_model_value_at (source, col->compare_col, row1),
+ e_table_model_value_at (source, col->compare_col, row2));
ascending = column.ascending;
if (comp_val != 0)
break;
@@ -133,7 +133,7 @@ e_table_sorting_utils_sort(ETableModel *source, ETableSortInfo *sort_info, ETabl
if (col == NULL)
col = e_table_header_get_column (full_header, e_table_header_count (full_header) - 1);
for (i = 0; i < rows; i++) {
- closure.vals[map_table[i] * cols + j] = e_table_model_value_at (source, col->col_idx, map_table[i]);
+ closure.vals[map_table[i] * cols + j] = e_table_model_value_at (source, col->compare_col, map_table[i]);
}
closure.compare[j] = col->compare;
closure.ascending[j] = column.ascending;
@@ -167,7 +167,7 @@ e_table_sorting_utils_affects_sort (ETableSortInfo *sort_info,
tablecol = e_table_header_get_column_by_col_idx(full_header, column.column);
if (tablecol == NULL)
tablecol = e_table_header_get_column (full_header, e_table_header_count (full_header) - 1);
- if (col == tablecol->col_idx)
+ if (col == tablecol->compare_col)
return TRUE;
}
return FALSE;
@@ -229,8 +229,8 @@ etsu_tree_compare(ETreeModel *source, ETableSortInfo *sort_info, ETableHeader *f
col = e_table_header_get_column_by_col_idx(full_header, column.column);
if (col == NULL)
col = e_table_header_get_column (full_header, e_table_header_count (full_header) - 1);
- comp_val = (*col->compare)(e_tree_model_value_at (source, path1, col->col_idx),
- e_tree_model_value_at (source, path2, col->col_idx));
+ comp_val = (*col->compare)(e_tree_model_value_at (source, path1, col->compare_col),
+ e_tree_model_value_at (source, path2, col->compare_col));
ascending = column.ascending;
if (comp_val != 0)
break;
@@ -281,7 +281,7 @@ e_table_sorting_utils_tree_sort(ETreeModel *source, ETableSortInfo *sort_info, E
col = e_table_header_get_column (full_header, e_table_header_count (full_header) - 1);
for (i = 0; i < count; i++) {
- closure.vals[i * cols + j] = e_tree_model_value_at (source, map_table[i], col->col_idx);
+ closure.vals[i * cols + j] = e_tree_model_value_at (source, map_table[i], col->compare_col);
}
closure.ascending[j] = column.ascending;
closure.compare[j] = col->compare;
diff --git a/widgets/table/e-table-utils.c b/widgets/table/e-table-utils.c
index eb36323d70..c0e51e5bec 100644
--- a/widgets/table/e-table-utils.c
+++ b/widgets/table/e-table-utils.c
@@ -112,6 +112,10 @@ et_col_spec_to_col (ETableColumnSpecification *col_spec,
g_free (title);
}
+ if (col && col_spec->compare_col != col_spec->model_col)
+ gtk_object_set (GTK_OBJECT (col),
+ "compare_col", col_spec->compare_col,
+ NULL);
return col;
}
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 903193a755..248f90f873 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -489,8 +489,6 @@ e_table_init (GtkObject *object)
e_table->click_to_add_message = NULL;
e_table->domain = NULL;
- e_table->drag_get_data_row = -1;
- e_table->drag_get_data_col = -1;
e_table->drop_row = -1;
e_table->drop_col = -1;
e_table->site = NULL;
@@ -1519,7 +1517,10 @@ e_table_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete,
g_return_val_if_fail(spec_str != NULL, NULL);
specification = e_table_specification_new();
- e_table_specification_load_from_string(specification, spec_str);
+ if (!e_table_specification_load_from_string(specification, spec_str)) {
+ gtk_object_unref(GTK_OBJECT(specification));
+ return NULL;
+ }
if (state_str) {
state = e_table_state_new();
e_table_state_load_from_string(state, state_str);
@@ -2338,8 +2339,6 @@ e_table_drag_get_data (ETable *table,
g_return_if_fail(table != NULL);
g_return_if_fail(E_IS_TABLE(table));
- table->drag_get_data_row = row;
- table->drag_get_data_col = col;
gtk_drag_get_data(GTK_WIDGET(table),
context,
target,
@@ -2392,8 +2391,10 @@ e_table_drag_highlight (ETable *table,
"y2", (double) y + height - 1,
NULL);
} else {
- gtk_object_destroy (GTK_OBJECT (table->drop_highlight));
- table->drop_highlight = NULL;
+ if (table->drop_highlight) {
+ gtk_object_destroy (GTK_OBJECT (table->drop_highlight));
+ table->drop_highlight = NULL;
+ }
}
}
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index 7f1ec00e75..f67e0078b1 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -140,9 +140,6 @@ typedef struct {
ECursorMode cursor_mode;
- int drag_get_data_row;
- int drag_get_data_col;
-
int drop_row;
int drop_col;
GnomeCanvasItem *drop_highlight;