aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-table-header.c23
-rw-r--r--widgets/table/e-table-header.h93
-rw-r--r--widgets/table/e-table-utils.c45
-rw-r--r--widgets/table/e-table-utils.h15
-rw-r--r--widgets/table/e-table.c113
-rw-r--r--widgets/table/e-table.h6
-rw-r--r--widgets/table/e-tree.c99
7 files changed, 269 insertions, 125 deletions
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
index aa4b4ffb75..70d9b5583e 100644
--- a/widgets/table/e-table-header.c
+++ b/widgets/table/e-table-header.c
@@ -929,3 +929,26 @@ e_table_header_prioritized_column (ETableHeader *eth)
}
return best_model_col;
}
+
+ETableCol *
+e_table_header_prioritized_column_selected (ETableHeader *eth, ETableColCheckFunc check_func, gpointer user_data)
+{
+ ETableCol *best_col = NULL;
+ int best_priority = G_MININT;
+ int i;
+ int count;
+
+ count = e_table_header_count (eth);
+ if (count == 0)
+ return NULL;
+ 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) && check_func (col, user_data)) {
+ best_priority = col->priority;
+ best_col = col;
+ }
+ }
+ }
+ return best_col;
+}
diff --git a/widgets/table/e-table-header.h b/widgets/table/e-table-header.h
index b30bca47cd..c20fd0be6e 100644
--- a/widgets/table/e-table-header.h
+++ b/widgets/table/e-table-header.h
@@ -29,10 +29,9 @@
#include <gdk/gdk.h>
#include <gal/e-table/e-table-sort-info.h>
#include <gal/e-table/e-table-col.h>
+#include <libgnome/gnome-defs.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+BEGIN_GNOME_DECLS
typedef struct _ETableHeader ETableHeader;
@@ -42,6 +41,8 @@ typedef struct _ETableHeader ETableHeader;
#define E_IS_TABLE_HEADER(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_TYPE))
#define E_IS_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_TYPE))
+typedef gboolean (*ETableColCheckFunc) (ETableCol *col, gpointer user_data);
+
/*
* A Columnar header.
*/
@@ -71,50 +72,50 @@ typedef struct {
int (*request_width) (ETableHeader *eth, int col);
} ETableHeaderClass;
-GtkType e_table_header_get_type (void);
-ETableHeader *e_table_header_new (void);
-
-void e_table_header_add_column (ETableHeader *eth,
- ETableCol *tc,
- int pos);
-ETableCol *e_table_header_get_column (ETableHeader *eth,
- int column);
-ETableCol *e_table_header_get_column_by_col_idx (ETableHeader *eth,
- int col_idx);
-int e_table_header_count (ETableHeader *eth);
-int e_table_header_index (ETableHeader *eth,
- int col);
-int e_table_header_get_index_at (ETableHeader *eth,
- int x_offset);
+GtkType e_table_header_get_type (void);
+ETableHeader *e_table_header_new (void);
+
+void e_table_header_add_column (ETableHeader *eth,
+ ETableCol *tc,
+ int pos);
+ETableCol *e_table_header_get_column (ETableHeader *eth,
+ int column);
+ETableCol *e_table_header_get_column_by_col_idx (ETableHeader *eth,
+ int col_idx);
+int e_table_header_count (ETableHeader *eth);
+int e_table_header_index (ETableHeader *eth,
+ int col);
+int e_table_header_get_index_at (ETableHeader *eth,
+ int x_offset);
ETableCol **e_table_header_get_columns (ETableHeader *eth);
-int e_table_header_get_selected (ETableHeader *eth);
-
-int e_table_header_total_width (ETableHeader *eth);
-int e_table_header_min_width (ETableHeader *eth);
-void e_table_header_move (ETableHeader *eth,
- int source_index,
- int target_index);
-void e_table_header_remove (ETableHeader *eth,
- int idx);
-void e_table_header_set_size (ETableHeader *eth,
- int idx,
- int size);
-void e_table_header_set_selection (ETableHeader *eth,
- gboolean allow_selection);
-int e_table_header_col_diff (ETableHeader *eth,
- int start_col,
- int end_col);
-
-void e_table_header_calc_widths (ETableHeader *eth);
-GList *e_table_header_get_selected_indexes (ETableHeader *eth);
-
-void e_table_header_update_horizontal (ETableHeader *eth);
-int e_table_header_prioritized_column (ETableHeader *eth);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+int e_table_header_get_selected (ETableHeader *eth);
+
+int e_table_header_total_width (ETableHeader *eth);
+int e_table_header_min_width (ETableHeader *eth);
+void e_table_header_move (ETableHeader *eth,
+ int source_index,
+ int target_index);
+void e_table_header_remove (ETableHeader *eth,
+ int idx);
+void e_table_header_set_size (ETableHeader *eth,
+ int idx,
+ int size);
+void e_table_header_set_selection (ETableHeader *eth,
+ gboolean allow_selection);
+int e_table_header_col_diff (ETableHeader *eth,
+ int start_col,
+ int end_col);
+
+void e_table_header_calc_widths (ETableHeader *eth);
+GList *e_table_header_get_selected_indexes (ETableHeader *eth);
+void e_table_header_update_horizontal (ETableHeader *eth);
+int e_table_header_prioritized_column (ETableHeader *eth);
+ETableCol *e_table_header_prioritized_column_selected (ETableHeader *eth,
+ ETableColCheckFunc check_func,
+ gpointer user_data);
+
+
+END_GNOME_DECLS
#endif /* _E_TABLE_HEADER_H_ */
diff --git a/widgets/table/e-table-utils.c b/widgets/table/e-table-utils.c
index 8ae460681f..eb36323d70 100644
--- a/widgets/table/e-table-utils.c
+++ b/widgets/table/e-table-utils.c
@@ -137,3 +137,48 @@ e_table_spec_to_full_header (ETableSpecification *spec,
return nh;
}
+
+static gboolean
+check_col (ETableCol *col, gpointer user_data)
+{
+ return col->search ? TRUE : FALSE;
+}
+
+ETableCol *
+e_table_util_calculate_current_search_col (ETableHeader *header, ETableHeader *full_header, ETableSortInfo *sort_info, gboolean always_search)
+{
+ int i;
+ int count;
+ ETableCol *col = NULL;
+ count = e_table_sort_info_grouping_get_count (sort_info);
+ for (i = 0; i < count; i++) {
+ ETableSortColumn column = e_table_sort_info_grouping_get_nth(sort_info, i);
+
+ col = e_table_header_get_column (full_header, column.column);
+
+ if (col && col->search)
+ break;
+
+ col = NULL;
+ }
+
+ if (col == NULL) {
+ count = e_table_sort_info_sorting_get_count (sort_info);
+ for (i = 0; i < count; i++) {
+ ETableSortColumn column = e_table_sort_info_sorting_get_nth(sort_info, i);
+
+ col = e_table_header_get_column (full_header, column.column);
+
+ if (col && col->search)
+ break;
+
+ col = NULL;
+ }
+ }
+
+ if (col == NULL && always_search) {
+ col = e_table_header_prioritized_column_selected (header, check_col, NULL);
+ }
+
+ return col;
+}
diff --git a/widgets/table/e-table-utils.h b/widgets/table/e-table-utils.h
index 7438a9c759..35277583c0 100644
--- a/widgets/table/e-table-utils.h
+++ b/widgets/table/e-table-utils.h
@@ -32,12 +32,17 @@
BEGIN_GNOME_DECLS
-ETableHeader *e_table_state_to_header (GtkWidget *widget,
- ETableHeader *full_header,
- ETableState *state);
+ETableHeader *e_table_state_to_header (GtkWidget *widget,
+ ETableHeader *full_header,
+ ETableState *state);
-ETableHeader *e_table_spec_to_full_header (ETableSpecification *spec,
- ETableExtras *ete);
+ETableHeader *e_table_spec_to_full_header (ETableSpecification *spec,
+ ETableExtras *ete);
+
+ETableCol *e_table_util_calculate_current_search_col (ETableHeader *header,
+ ETableHeader *full_header,
+ ETableSortInfo *sort_info,
+ gboolean always_search);
END_GNOME_DECLS
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 8b2b6bd4cb..903193a755 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -95,7 +95,8 @@ enum {
ARG_0,
ARG_LENGTH_THRESHOLD,
ARG_MODEL,
- ARG_UNIFORM_ROW_HEIGHT
+ ARG_UNIFORM_ROW_HEIGHT,
+ ARG_ALWAYS_SEARCH
};
enum {
@@ -197,6 +198,27 @@ e_table_state_change (ETable *et)
#define CHECK_HORIZONTAL(et) if ((et)->horizontal_scrolling || (et)->horizontal_resize) e_table_header_update_horizontal (et->header);
static void
+clear_current_search_col (ETable *et)
+{
+ et->search_col_set = FALSE;
+}
+
+static ETableCol *
+current_search_col (ETable *et)
+{
+ if (!et->search_col_set) {
+ et->current_search_col =
+ e_table_util_calculate_current_search_col (et->header,
+ et->full_header,
+ et->sort_info,
+ et->always_search);
+ et->search_col_set = TRUE;
+ }
+
+ return et->current_search_col;
+}
+
+static void
et_size_request (GtkWidget *widget, GtkRequisition *request)
{
ETable *et = E_TABLE (widget);
@@ -220,6 +242,7 @@ structure_changed (ETableHeader *header, ETable *et)
{
e_table_state_change (et);
set_header_width (et);
+ clear_current_search_col (et);
}
static void
@@ -361,38 +384,34 @@ et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, E
int cursor;
int rows;
int i;
- int col;
- ETableSearchFunc search_func;
+ ETableCol *col = current_search_col (et);
- col = et->current_search_col;
- if (col == -1)
+ if (col == NULL)
return FALSE;
rows = e_table_model_row_count (et->model);
- search_func = et->current_search;
-
gtk_object_get(GTK_OBJECT(et->selection),
"cursor_row", &cursor,
NULL);
- if ((flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST) && cursor < rows && cursor >= 0 && check_row (et, cursor, col, search_func, string))
+ if ((flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST) && cursor < rows && cursor >= 0 && check_row (et, cursor, col->col_idx, col->search, string))
return TRUE;
cursor = e_sorter_model_to_sorted (E_SORTER (et->sorter), cursor);
for (i = cursor + 1; i < rows; i++) {
int model_row = e_sorter_sorted_to_model (E_SORTER (et->sorter), i);
- if (check_row (et, model_row, col, search_func, string)) {
- e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->selection), model_row, col, GDK_CONTROL_MASK);
+ if (check_row (et, model_row, col->col_idx, col->search, string)) {
+ e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->selection), model_row, col->col_idx, GDK_CONTROL_MASK);
return TRUE;
}
}
for (i = 0; i < cursor; i++) {
int model_row = e_sorter_sorted_to_model (E_SORTER (et->sorter), i);
- if (check_row (et, model_row, col, search_func, string)) {
- e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->selection), model_row, col, GDK_CONTROL_MASK);
+ if (check_row (et, model_row, col->col_idx, col->search, string)) {
+ e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->selection), model_row, col->col_idx, GDK_CONTROL_MASK);
return TRUE;
}
}
@@ -400,22 +419,38 @@ et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, E
cursor = e_sorter_sorted_to_model (E_SORTER (et->sorter), cursor);
/* 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, search_func, string));
+ return (!(flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST) && cursor < rows && cursor >= 0 && check_row (et, cursor, col->col_idx, col->search, string));
}
static void
et_search_accept (ETableSearch *search, ETable *et)
{
- int col, cursor;
+ int cursor;
+ ETableCol *col = current_search_col (et);
- col = et->current_search_col;
- if (col == -1)
+ if (col == NULL)
return;
gtk_object_get(GTK_OBJECT(et->selection),
"cursor_row", &cursor,
NULL);
- e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->selection), cursor, col, 0);
+ e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->selection), cursor, col->col_idx, 0);
+}
+
+static void
+init_search (ETable *e_table)
+{
+ if (e_table->search != NULL)
+ return;
+
+ e_table->search = e_table_search_new();
+
+ e_table->search_search_id =
+ gtk_signal_connect (GTK_OBJECT (e_table->search), "search",
+ GTK_SIGNAL_FUNC (et_search_search), e_table);
+ e_table->search_accept_id =
+ gtk_signal_connect (GTK_OBJECT (e_table->search), "accept",
+ GTK_SIGNAL_FUNC (et_search_accept), e_table);
}
static void
@@ -467,17 +502,13 @@ e_table_init (GtkObject *object)
e_table->cursor_loc = E_TABLE_CURSOR_LOC_NONE;
e_table->spec = NULL;
- e_table->search = e_table_search_new();
+ e_table->always_search = g_getenv ("GAL_ALWAYS_SEARCH") ? TRUE : FALSE;
- e_table->search_search_id =
- gtk_signal_connect (GTK_OBJECT (e_table->search), "search",
- GTK_SIGNAL_FUNC (et_search_search), e_table);
- e_table->search_accept_id =
- gtk_signal_connect (GTK_OBJECT (e_table->search), "accept",
- GTK_SIGNAL_FUNC (et_search_accept), e_table);
+ e_table->search = NULL;
+ e_table->search_search_id = 0;
+ e_table->search_accept_id = 0;
- e_table->current_search = NULL;
- e_table->current_search_col = -1;
+ e_table->current_search_col = NULL;
e_table->header_width = 0;
}
@@ -550,6 +581,7 @@ static void
group_info_changed (ETableSortInfo *info, ETable *et)
{
gboolean will_be_grouped = e_table_sort_info_grouping_get_count(info) > 0;
+ clear_current_search_col (et);
if (et->is_grouped || will_be_grouped) {
et->need_rebuild = TRUE;
if (!et->rebuild_idle_id) {
@@ -564,6 +596,7 @@ group_info_changed (ETableSortInfo *info, ETable *et)
static void
sort_info_changed (ETableSortInfo *info, ETable *et)
{
+ clear_current_search_col (et);
e_table_state_change (et);
}
@@ -761,16 +794,17 @@ group_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et
return_val = 1;
break;
case GDK_BackSpace:
+ init_search (et);
if (e_table_search_backspace (et->search))
return TRUE;
/* Fall through */
default:
+ init_search (et);
if ((key->state & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK)) == 0
&& ((key->keyval >= GDK_a && key->keyval <= GDK_z) ||
(key->keyval >= GDK_A && key->keyval <= GDK_Z) ||
- (key->keyval >= GDK_0 && key->keyval <= GDK_9))) {
+ (key->keyval >= GDK_0 && key->keyval <= GDK_9)))
e_table_search_input_character (et->search, key->keyval);
- }
gtk_signal_emit (GTK_OBJECT (et),
et_signals [KEY_PRESS],
row, col, event, &return_val);
@@ -1357,7 +1391,6 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete,
ETableSpecification *specification, ETableState *state)
{
int row = 0;
- int col_count, i;
if (ete)
gtk_object_ref(GTK_OBJECT(ete));
@@ -1376,16 +1409,6 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete,
e_table->cursor_mode = specification->cursor_mode;
e_table->full_header = e_table_spec_to_full_header(specification, ete);
- col_count = e_table_header_count (e_table->full_header);
- for (i = 0; i < col_count; i++) {
- ETableCol *col = e_table_header_get_column(e_table->full_header, i);
- if (col && col->search) {
- e_table->current_search_col = col->col_idx;
- e_table->current_search = col->search;
- break;
- }
- }
-
gtk_object_set(GTK_OBJECT(e_table->selection),
"selection_mode", specification->selection_mode,
"cursor_mode", specification->cursor_mode,
@@ -1964,6 +1987,9 @@ et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_UNIFORM_ROW_HEIGHT:
GTK_VALUE_BOOL (*arg) = etable->uniform_row_height;
break;
+ case ARG_ALWAYS_SEARCH:
+ GTK_VALUE_BOOL (*arg) = etable->always_search;
+ break;
default:
break;
}
@@ -1996,6 +2022,13 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
NULL);
}
break;
+ case ARG_ALWAYS_SEARCH:
+ if (etable->always_search == GTK_VALUE_BOOL (*arg))
+ return;
+
+ etable->always_search = GTK_VALUE_BOOL (*arg);
+ clear_current_search_col (etable);
+ break;
}
}
@@ -3134,6 +3167,8 @@ e_table_class_init (ETableClass *class)
GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
gtk_object_add_arg_type ("ETable::uniform_row_height", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_UNIFORM_ROW_HEIGHT);
+ gtk_object_add_arg_type ("ETable::always_search", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_ALWAYS_SEARCH);
gtk_object_add_arg_type ("ETable::model", E_TABLE_MODEL_TYPE,
GTK_ARG_READABLE, ARG_MODEL);
}
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index 58c88d2a0e..7f1ec00e75 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -77,8 +77,7 @@ typedef struct {
ETableSearch *search;
- ETableSearchFunc current_search;
- int current_search_col;
+ ETableCol *current_search_col;
guint search_search_id;
guint search_accept_id;
@@ -131,6 +130,9 @@ typedef struct {
guint uniform_row_height : 1;
guint allow_grouping : 1;
+ guint always_search : 1;
+ guint search_col_set : 1;
+
char *click_to_add_message;
GnomeCanvasItem *click_to_add;
gboolean use_click_to_add;
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c
index 512d833bd8..dce60d441c 100644
--- a/widgets/table/e-tree.c
+++ b/widgets/table/e-tree.c
@@ -99,7 +99,8 @@ enum {
ARG_VERTICAL_DRAW_GRID,
ARG_DRAW_FOCUS,
ARG_ETTA,
- ARG_UNIFORM_ROW_HEIGHT
+ ARG_UNIFORM_ROW_HEIGHT,
+ ARG_ALWAYS_SEARCH
};
enum {
@@ -128,8 +129,7 @@ struct ETreePriv {
ETableSearch *search;
- ETableSearchFunc current_search;
- int current_search_col;
+ ETableCol *current_search_col;
guint search_search_id;
guint search_accept_id;
@@ -170,6 +170,9 @@ struct ETreePriv {
guint uniform_row_height : 1;
+ guint search_col_set : 1;
+ guint always_search : 1;
+
ECursorMode cursor_mode;
int drop_row;
@@ -272,6 +275,27 @@ et_disconnect_from_etta (ETree *et)
}
static void
+clear_current_search_col (ETree *et)
+{
+ et->priv->search_col_set = FALSE;
+}
+
+static ETableCol *
+current_search_col (ETree *et)
+{
+ if (!et->priv->search_col_set) {
+ et->priv->current_search_col =
+ e_table_util_calculate_current_search_col (et->priv->header,
+ et->priv->full_header,
+ et->priv->sort_info,
+ et->priv->always_search);
+ et->priv->search_col_set = TRUE;
+ }
+
+ return et->priv->current_search_col;
+}
+
+static void
e_tree_state_change (ETree *et)
{
gtk_signal_emit (GTK_OBJECT (et),
@@ -285,6 +309,13 @@ change_trigger (GtkObject *object, ETree *et)
}
static void
+search_col_change_trigger (GtkObject *object, ETree *et)
+{
+ clear_current_search_col (et);
+ e_tree_state_change (et);
+}
+
+static void
disconnect_header (ETree *e_tree)
{
if (e_tree->priv->header == NULL)
@@ -321,7 +352,7 @@ connect_header (ETree *e_tree, ETableState *state)
e_tree->priv->structure_change_id =
gtk_signal_connect (GTK_OBJECT (e_tree->priv->header), "structure_change",
- change_trigger, e_tree);
+ search_col_change_trigger, e_tree);
e_tree->priv->expansion_change_id =
gtk_signal_connect (GTK_OBJECT (e_tree->priv->header), "expansion_change",
change_trigger, e_tree);
@@ -331,10 +362,10 @@ connect_header (ETree *e_tree, ETableState *state)
e_table_sort_info_set_can_group (e_tree->priv->sort_info, FALSE);
e_tree->priv->sort_info_change_id =
gtk_signal_connect (GTK_OBJECT (e_tree->priv->sort_info), "sort_info_changed",
- change_trigger, e_tree);
+ search_col_change_trigger, e_tree);
e_tree->priv->group_info_change_id =
gtk_signal_connect (GTK_OBJECT (e_tree->priv->sort_info), "group_info_changed",
- change_trigger, e_tree);
+ search_col_change_trigger, e_tree);
} else
e_tree->priv->sort_info = NULL;
@@ -414,10 +445,11 @@ search_search_callback (ETreeModel *model, ETreePath path, gpointer data)
{
SearchSearchStruct *cb_data = data;
const void *value;
+ ETableCol *col = current_search_col (cb_data->et);
- value = e_tree_model_value_at (model, path, cb_data->et->priv->current_search_col);
+ value = e_tree_model_value_at (model, path, col->col_idx);
- return cb_data->et->priv->current_search (value, cb_data->string);
+ return col->search (value, cb_data->string);
}
static gboolean
@@ -426,10 +458,9 @@ et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, E
ETreePath cursor;
ETreePath found;
SearchSearchStruct cb_data;
- int col;
+ ETableCol *col = current_search_col (et);
- col = et->priv->current_search_col;
- if (col == -1)
+ if (col == NULL)
return FALSE;
cb_data.et = et;
@@ -441,9 +472,9 @@ et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, E
if (flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST) {
const void *value;
- value = e_tree_model_value_at (E_TREE_MODEL (et->priv->sorted), cursor, et->priv->current_search_col);
+ value = e_tree_model_value_at (E_TREE_MODEL (et->priv->sorted), cursor, col->col_idx);
- if (et->priv->current_search (value, string)) {
+ if (col->search (value, string)) {
return TRUE;
}
}
@@ -460,14 +491,14 @@ et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, E
cursor = e_tree_sorted_view_to_model_path (et->priv->sorted, found);
- e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->priv->selection), model_row, col, GDK_CONTROL_MASK);
+ e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->priv->selection), model_row, col->col_idx, GDK_CONTROL_MASK);
return TRUE;
} else if (!(flags & E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST)) {
const void *value;
- value = e_tree_model_value_at (E_TREE_MODEL (et->priv->sorted), cursor, et->priv->current_search_col);
+ value = e_tree_model_value_at (E_TREE_MODEL (et->priv->sorted), cursor, col->col_idx);
- return et->priv->current_search (value, string);
+ return col->search (value, string);
} else
return FALSE;
}
@@ -475,16 +506,16 @@ et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, E
static void
et_search_accept (ETableSearch *search, ETree *et)
{
- int col, cursor;
+ ETableCol *col = current_search_col (et);
+ int cursor;
- col = et->priv->current_search_col;
- if (col == -1)
+ if (col == NULL)
return;
gtk_object_get(GTK_OBJECT(et->priv->selection),
"cursor_row", &cursor,
NULL);
- e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->priv->selection), cursor, col, 0);
+ e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->priv->selection), cursor, col->col_idx, 0);
}
static void
@@ -575,8 +606,9 @@ e_tree_init (GtkObject *object)
gtk_signal_connect (GTK_OBJECT (e_tree->priv->search), "accept",
GTK_SIGNAL_FUNC (et_search_accept), e_tree);
- e_tree->priv->current_search = NULL;
- e_tree->priv->current_search_col = -1;
+ e_tree->priv->current_search_col = NULL;
+ e_tree->priv->search_col_set = FALSE;
+ e_tree->priv->always_search = g_getenv ("GAL_ALWAYS_SEARCH") ? TRUE : FALSE;
}
/* Grab_focus handler for the ETree */
@@ -1301,7 +1333,6 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete,
ETableSpecification *specification, ETableState *state)
{
int row = 0;
- int i, col_count;
if (ete)
gtk_object_ref(GTK_OBJECT(ete));
@@ -1315,16 +1346,6 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete,
e_tree->priv->cursor_mode = specification->cursor_mode;
e_tree->priv->full_header = e_table_spec_to_full_header(specification, ete);
- col_count = e_table_header_count (e_tree->priv->full_header);
- for (i = 0; i < col_count; i++) {
- ETableCol *col = e_table_header_get_column(e_tree->priv->full_header, i);
- if (col && col->search) {
- e_tree->priv->current_search_col = col->col_idx;
- e_tree->priv->current_search = col->search;
- break;
- }
- }
-
connect_header (e_tree, state);
e_tree->priv->horizontal_scrolling = specification->horizontal_scrolling;
@@ -1724,6 +1745,9 @@ et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_UNIFORM_ROW_HEIGHT:
GTK_VALUE_BOOL (*arg) = etree->priv->uniform_row_height;
break;
+ case ARG_ALWAYS_SEARCH:
+ GTK_VALUE_BOOL (*arg) = etree->priv->always_search;
+ break;
default:
break;
@@ -1785,6 +1809,13 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
NULL);
}
break;
+
+ case ARG_ALWAYS_SEARCH:
+ if (etree->priv->always_search == GTK_VALUE_BOOL (*arg))
+ return;
+ etree->priv->always_search = GTK_VALUE_BOOL (*arg);
+ clear_current_search_col (etree);
+ break;
}
}
@@ -3212,6 +3243,8 @@ e_tree_class_init (ETreeClass *class)
GTK_ARG_READABLE, ARG_ETTA);
gtk_object_add_arg_type ("ETree::uniform_row_height", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_UNIFORM_ROW_HEIGHT);
+ gtk_object_add_arg_type ("ETree::always_search", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_ALWAYS_SEARCH);
}
E_MAKE_TYPE(e_tree, "ETree", ETree, e_tree_class_init, e_tree_init, PARENT_TYPE)