X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-header-view.c;h=448fdaa4ac8fca8257af2d48aa8ce6933b3a8572;hp=ae24edd6cefd905d5825eac3f1bfdf524674e5ee;hb=c24e7a5bf4a8917400f89c9b06529cbec89e9aac;hpb=4ec80f6ef85bf594ad5c4bd0a7e95c5ca474b08a diff --git a/src/widgets/modest-header-view.c b/src/widgets/modest-header-view.c index ae24edd..448fdaa 100644 --- a/src/widgets/modest-header-view.c +++ b/src/widgets/modest-header-view.c @@ -158,6 +158,7 @@ struct _ModestHeaderViewPrivate { ModestHeaderViewFilter filter; #ifdef MODEST_TOOLKIT_HILDON2 GtkWidget *live_search; + guint live_search_timeout; #endif gint sort_colid[2][TNY_FOLDER_TYPE_NUM]; @@ -644,6 +645,7 @@ modest_header_view_init (ModestHeaderView *obj) priv->filter = MODEST_HEADER_VIEW_FILTER_NONE; #ifdef MODEST_TOOLKIT_HILDON2 priv->live_search = NULL; + priv->live_search_timeout = 0; #endif priv->filter_string = NULL; priv->filter_string_splitted = NULL; @@ -676,6 +678,13 @@ modest_header_view_dispose (GObject *obj) self = MODEST_HEADER_VIEW(obj); priv = MODEST_HEADER_VIEW_GET_PRIVATE(self); +#ifdef MODEST_TOOLKIT_HILDON2 + if (priv->live_search_timeout > 0) { + g_source_remove (priv->live_search_timeout); + priv->live_search_timeout = 0; + } +#endif + if (priv->datetime_formatter) { g_object_unref (priv->datetime_formatter); priv->datetime_formatter = NULL; @@ -2163,15 +2172,15 @@ header_match_string (TnyHeader *header, gchar **words) to = tny_header_dup_to (header); from = tny_header_dup_from (header); - subject_fold = g_utf8_casefold (subject, -1); + subject_fold = subject?g_utf8_casefold (subject, -1):NULL; g_free (subject); - bcc_fold = g_utf8_casefold (bcc, -1); + bcc_fold = bcc?g_utf8_casefold (bcc, -1):NULL; g_free (bcc); - cc_fold = g_utf8_casefold (cc, -1); + cc_fold = cc?g_utf8_casefold (cc, -1):NULL; g_free (cc); - to_fold = g_utf8_casefold (to, -1); + to_fold = to?g_utf8_casefold (to, -1):NULL; g_free (to); - from_fold = g_utf8_casefold (from, -1); + from_fold = from?g_utf8_casefold (from, -1):NULL; g_free (from); found = TRUE; @@ -2798,19 +2807,58 @@ modest_header_view_set_filter_string (ModestHeaderView *self, } #ifdef MODEST_TOOLKIT_HILDON2 + static gboolean -on_live_search_refilter (HildonLiveSearch *livesearch, - ModestHeaderView *self) +on_live_search_timeout (ModestHeaderView *self) { const gchar *needle; + ModestHeaderViewPrivate *priv; + + priv = MODEST_HEADER_VIEW_GET_PRIVATE (self); - needle = hildon_live_search_get_text (livesearch); + needle = hildon_live_search_get_text (HILDON_LIVE_SEARCH (priv->live_search)); if (needle && needle[0] != '\0') { modest_header_view_set_filter_string (MODEST_HEADER_VIEW (self), needle); + if (priv->show_latest > 0) + modest_header_view_set_show_latest (MODEST_HEADER_VIEW (self), 0); } else { modest_header_view_set_filter_string (MODEST_HEADER_VIEW (self), NULL); } - + + priv->live_search_timeout = 0; + + return FALSE; +} + +static gboolean +on_live_search_refilter (HildonLiveSearch *livesearch, + ModestHeaderView *self) +{ + ModestHeaderViewPrivate *priv; + GtkTreeModel *model, *sortable, *filter; + + priv = MODEST_HEADER_VIEW_GET_PRIVATE (self); + + if (priv->live_search_timeout > 0) { + g_source_remove (priv->live_search_timeout); + priv->live_search_timeout = 0; + } + + model = NULL; + sortable = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); + if (GTK_IS_TREE_MODEL_SORT (sortable)) { + filter = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sortable)); + if (GTK_IS_TREE_MODEL_FILTER (filter)) { + model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter)); + } + } + + if (model && tny_list_get_length (TNY_LIST (model)) > 250) { + priv->live_search_timeout = g_timeout_add (1000, (GSourceFunc) on_live_search_timeout, self); + } else { + on_live_search_timeout (self); + } + return TRUE; }