aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-03-13 15:10:22 +0800
committerChris Lahey <clahey@src.gnome.org>2002-03-13 15:10:22 +0800
commitabd6567ea011ed5546aa8b17bea86567ad9fb5f7 (patch)
treeb62808ef22f53beba97f22a50f3f9bd96d74aeda /widgets/table
parente03e086323ba306b53f27f6e9e95d4c627a51717 (diff)
downloadgsoc2013-evolution-abd6567ea011ed5546aa8b17bea86567ad9fb5f7.tar
gsoc2013-evolution-abd6567ea011ed5546aa8b17bea86567ad9fb5f7.tar.gz
gsoc2013-evolution-abd6567ea011ed5546aa8b17bea86567ad9fb5f7.tar.bz2
gsoc2013-evolution-abd6567ea011ed5546aa8b17bea86567ad9fb5f7.tar.lz
gsoc2013-evolution-abd6567ea011ed5546aa8b17bea86567ad9fb5f7.tar.xz
gsoc2013-evolution-abd6567ea011ed5546aa8b17bea86567ad9fb5f7.tar.zst
gsoc2013-evolution-abd6567ea011ed5546aa8b17bea86567ad9fb5f7.zip
Replaced e_marshal_BOOL__STRING with this since the function it was used
2002-03-13 Christopher James Lahey <clahey@ximian.com> * gal/util/e-util.c, gal/util/e-util.h (e_marshal_BOOL__STRING_INT): Replaced e_marshal_BOOL__STRING with this since the function it was used for has been modified. From gal/e-table/ChangeLog: 2002-03-13 Christopher James Lahey <clahey@ximian.com> * e-table-extras.c (e_string_search): Check for a NULL haystack here. * e-table-search.c, e-table-search.h: Added a parameter to the search signal here to pass in flags. Specifically, added the E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST flag. Improved the search behavior here. * e-table.c, e-tree.c: Handle the new signature for the search signal here. svn path=/trunk/; revision=16139
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-table-extras.c6
-rw-r--r--widgets/table/e-table-search.c35
-rw-r--r--widgets/table/e-table-search.h6
-rw-r--r--widgets/table/e-table.c7
-rw-r--r--widgets/table/e-tree.c23
5 files changed, 53 insertions, 24 deletions
diff --git a/widgets/table/e-table-extras.c b/widgets/table/e-table-extras.c
index 9f80557901..e9a18b4f8e 100644
--- a/widgets/table/e-table-extras.c
+++ b/widgets/table/e-table-extras.c
@@ -102,7 +102,11 @@ e_strint_compare(gconstpointer data1, gconstpointer data2)
static gboolean
e_string_search(gconstpointer haystack, const char *needle)
{
- int length = g_utf8_strlen (needle, -1);
+ int length;
+ if (haystack == NULL)
+ return FALSE;
+
+ length = g_utf8_strlen (needle, -1);
if (g_utf8_strncasecmp (haystack, needle, length) == 0)
return TRUE;
else
diff --git a/widgets/table/e-table-search.c b/widgets/table/e-table-search.c
index 88b6673c86..e05210fe65 100644
--- a/widgets/table/e-table-search.c
+++ b/widgets/table/e-table-search.c
@@ -52,14 +52,14 @@ enum {
static guint e_table_search_signals [LAST_SIGNAL] = { 0, };
static gboolean
-e_table_search_search (ETableSearch *e_table_search, char *string)
+e_table_search_search (ETableSearch *e_table_search, char *string, ETableSearchFlags flags)
{
gboolean ret_val;
g_return_val_if_fail (e_table_search != NULL, FALSE);
g_return_val_if_fail (E_IS_TABLE_SEARCH (e_table_search), FALSE);
gtk_signal_emit (GTK_OBJECT (e_table_search),
- e_table_search_signals [SEARCH_SEARCH], string, &ret_val);
+ e_table_search_signals [SEARCH_SEARCH], string, flags, &ret_val);
return ret_val;
}
@@ -124,8 +124,8 @@ e_table_search_class_init (GtkObjectClass *object_class)
GTK_RUN_LAST,
E_OBJECT_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (ETableSearchClass, search),
- e_marshal_BOOL__STRING,
- GTK_TYPE_BOOL, 1, GTK_TYPE_STRING);
+ e_marshal_BOOL__STRING_ENUM,
+ GTK_TYPE_BOOL, 2, GTK_TYPE_STRING, GTK_TYPE_ENUM);
e_table_search_signals [SEARCH_ACCEPT] =
gtk_signal_new ("accept",
@@ -195,25 +195,28 @@ void
e_table_search_input_character (ETableSearch *ets, gunichar character)
{
char character_utf8[7];
+ char *temp_string;
g_return_if_fail (ets != NULL);
g_return_if_fail (E_IS_TABLE_SEARCH (ets));
character_utf8 [g_unichar_to_utf8 (character, character_utf8)] = 0;
- if (character != ets->priv->last_character) {
- char *temp_string;
- temp_string = g_strdup_printf ("%s%s", ets->priv->search_string, character_utf8);
- if (e_table_search_search (ets, temp_string)) {
- g_free (ets->priv->search_string);
- ets->priv->search_string = temp_string;
+ temp_string = g_strdup_printf ("%s%s", ets->priv->search_string, character_utf8);
+ if (e_table_search_search (ets, temp_string,
+ ets->priv->last_character != 0 ? E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST : 0)) {
+ g_free (ets->priv->search_string);
+ ets->priv->search_string = temp_string;
+ add_timeout (ets);
+ ets->priv->last_character = character;
+ return;
+ } else {
+ g_free (temp_string);
+ }
+
+ if (character == ets->priv->last_character) {
+ if (ets->priv->search_string && e_table_search_search (ets, ets->priv->search_string, 0)) {
add_timeout (ets);
- } else {
- g_free (temp_string);
}
- } else {
- e_table_search_search (ets, ets->priv->search_string);
- add_timeout (ets);
}
- ets->priv->last_character = character;
}
diff --git a/widgets/table/e-table-search.h b/widgets/table/e-table-search.h
index a439aafbe5..f90fae19d7 100644
--- a/widgets/table/e-table-search.h
+++ b/widgets/table/e-table-search.h
@@ -38,6 +38,10 @@ BEGIN_GNOME_DECLS
typedef struct _ETableSearchPrivate ETableSearchPrivate;
+typedef enum {
+ E_TABLE_SEARCH_FLAGS_CHECK_CURSOR_FIRST = 1 << 0
+} ETableSearchFlags;
+
typedef struct {
GtkObject base;
@@ -50,7 +54,7 @@ typedef struct {
/*
* Signals
*/
- gboolean (*search) (ETableSearch *ets, char *string /* utf8 */);
+ gboolean (*search) (ETableSearch *ets, char *string /* utf8 */, ETableSearchFlags flags);
void (*accept) (ETableSearch *ets);
void (*cancelled) (ETableSearch *ets);
} ETableSearchClass;
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 110d7a25e5..e730dabbc7 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -342,7 +342,7 @@ check_row (ETable *et, int model_row, int col, ETableSearchFunc search, char *st
}
static gboolean
-et_search_search (ETableSearch *search, char *string, ETable *et)
+et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, ETable *et)
{
int cursor;
int rows;
@@ -362,6 +362,9 @@ et_search_search (ETableSearch *search, char *string, ETable *et)
"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))
+ return TRUE;
+
cursor = e_sorter_model_to_sorted (E_SORTER (et->sorter), cursor);
for (i = cursor + 1; i < rows; i++) {
@@ -383,7 +386,7 @@ et_search_search (ETableSearch *search, char *string, ETable *et)
cursor = e_sorter_sorted_to_model (E_SORTER (et->sorter), cursor);
/* Check if the cursor row is the only matching row. */
- return (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, search_func, string));
}
static void
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c
index 7b1d1cffc7..91f9a500ce 100644
--- a/widgets/table/e-tree.c
+++ b/widgets/table/e-tree.c
@@ -419,7 +419,7 @@ search_search_callback (ETreeModel *model, ETreePath path, gpointer data)
}
static gboolean
-et_search_search (ETableSearch *search, char *string, ETree *et)
+et_search_search (ETableSearch *search, char *string, ETableSearchFlags flags, ETree *et)
{
ETreePath cursor;
ETreePath found;
@@ -436,11 +436,21 @@ et_search_search (ETableSearch *search, char *string, ETree *et)
cursor = e_tree_get_cursor (et);
cursor = e_tree_sorted_model_to_view_path (et->priv->sorted, cursor);
+ 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);
+
+ if (et->priv->current_search (value, string)) {
+ return TRUE;
+ }
+ }
+
found = e_tree_model_node_find (E_TREE_MODEL (et->priv->sorted), cursor, NULL, E_TREE_FIND_NEXT_FORWARD, search_search_callback, &cb_data);
if (found == NULL)
found = e_tree_model_node_find (E_TREE_MODEL (et->priv->sorted), NULL, cursor, E_TREE_FIND_NEXT_FORWARD, search_search_callback, &cb_data);
- if (found) {
+ if (found && found != cursor) {
int model_row;
e_tree_table_adapter_show_node (et->priv->etta, found);
@@ -450,9 +460,14 @@ et_search_search (ETableSearch *search, char *string, ETree *et)
e_selection_model_select_as_key_press(E_SELECTION_MODEL (et->priv->selection), model_row, col, GDK_CONTROL_MASK);
return TRUE;
- } else {
+ } 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);
+
+ return et->priv->current_search (value, string);
+ } else
return FALSE;
- }
}
static void