#include <modest-dnd.h>
#include <modest-tny-folder.h>
#include <modest-debug.h>
-#include <modest-main-window.h>
#include <modest-ui-actions.h>
#include <modest-marshal.h>
#include <modest-text-utils.h>
GdkColor active_color;
GdkColor secondary_color;
+
+ gchar *filter_string;
+ gchar **filter_string_splitted;
};
typedef struct _HeadersCountChangedHelper HeadersCountChangedHelper;
priv->hidding_ids = NULL;
priv->n_selected = 0;
priv->filter = MODEST_HEADER_VIEW_FILTER_NONE;
+ priv->filter_string = NULL;
+ priv->filter_string_splitted = NULL;
priv->selection_changed_handler = 0;
priv->acc_removed_handler = 0;
priv->autoselect_reference = NULL;
}
+ if (priv->filter_string) {
+ g_free (priv->filter_string);
+ }
+
+ if (priv->filter_string_splitted) {
+ g_strfreev (priv->filter_string_splitted);
+ }
+
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
gtk_tree_path_free (tree_iter_path);
}
} else {
- if (priv->autoselect_reference != NULL) {
+ if (priv->autoselect_reference != NULL && gtk_tree_row_reference_valid (priv->autoselect_reference)) {
gboolean moved_selection = FALSE;
GtkTreePath * last_path;
if (gtk_tree_selection_count_selected_rows (sel) != 1) {
}
static void
-modest_header_view_set_folder_intern (ModestHeaderView *self, TnyFolder *folder)
+modest_header_view_set_folder_intern (ModestHeaderView *self,
+ TnyFolder *folder,
+ gboolean refresh)
{
TnyFolderType type;
TnyList *headers;
be added again by tny_gtk_header_list_model_set_folder, so
we'd end up with duplicate headers. sergio */
tny_gtk_header_list_model_set_folder (TNY_GTK_HEADER_LIST_MODEL(headers),
- folder, FALSE,
+ folder, refresh,
set_folder_intern_get_headers_async_cb,
NULL, self);
ModestMailOperation *mail_op = NULL;
/* Set folder in the model */
- modest_header_view_set_folder_intern (self, folder);
+ modest_header_view_set_folder_intern (self, folder, refresh);
/* Pick my reference. Nothing to do with the mail operation */
priv->folder = g_object_ref (folder);
gint t1, t2;
gchar *val1, *val2;
gint cmp;
-/* static int counter = 0; */
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN(user_data), 0);
gtk_tree_model_get (tree_model, iter2, TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN, &val2,
TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN, &t2, -1);
- cmp = modest_text_utils_utf8_strcmp (val1 + modest_text_utils_get_subject_prefix_len(val1),
- val2 + modest_text_utils_get_subject_prefix_len(val2),
+ /* Do not use the prefixes for sorting. Consume all the blank
+ spaces for sorting */
+ cmp = modest_text_utils_utf8_strcmp (g_strchug (val1 + modest_text_utils_get_subject_prefix_len(val1)),
+ g_strchug (val2 + modest_text_utils_get_subject_prefix_len(val2)),
TRUE);
+
+ /* If they're equal based on subject without prefix then just
+ sort them by length. This will show messages like this.
+ * Fw:
+ * Fw:Fw:
+ * Fw:Fw:
+ * Fw:Fw:Fw:
+ * */
+ if (cmp == 0)
+ cmp = (g_utf8_strlen (val1, -1) >= g_utf8_strlen (val2, -1)) ? 1 : -1;
+
g_free (val1);
g_free (val2);
return cmp;
}
static gboolean
+header_match_string (TnyHeader *header, gchar **words)
+{
+ gchar **current_word;
+ gboolean found;
+
+ found = FALSE;
+
+ for (current_word = words; !found && *current_word != NULL; current_word++) {
+ gchar *subject;
+ gchar *cc;
+ gchar *bcc;
+ gchar *to;
+ gchar *from;
+
+ subject = tny_header_dup_subject (header);
+ cc = tny_header_dup_cc (header);
+ bcc = tny_header_dup_bcc (header);
+ to = tny_header_dup_to (header);
+ from = tny_header_dup_from (header);
+
+ if ((subject && g_strstr_len (subject, -1, *current_word))
+ || (cc && g_strstr_len (cc, -1, *current_word))
+ || (bcc && g_strstr_len (bcc, -1, *current_word))
+ || (to && g_strstr_len (to, -1, *current_word))
+ || (from && g_strstr_len (from, -1, *current_word)))
+ found = TRUE;
+ g_free (subject);
+ g_free (cc);
+ g_free (bcc);
+ g_free (to);
+ g_free (from);
+ }
+ return found;
+}
+
+static gboolean
filter_row (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
}
}
+ if (visible && priv->filter_string) {
+ if (!header_match_string (header, priv->filter_string_splitted)) {
+ visible = FALSE;
+ goto frees;
+ }
+ }
+
/* If no data on clipboard, return always TRUE */
if (modest_email_clipboard_cleared(priv->clipboard)) {
visible = TRUE;
/* Set color */
attr_list = pango_attr_list_new ();
- if (!gtk_style_lookup_color (GTK_WIDGET (self)->style, "SecondaryTextColor", &style_color)) {
- gdk_color_parse ("grey", &style_color);
+ if (!gtk_style_lookup_color (gtk_widget_get_style (GTK_WIDGET (self)), "SecondaryTextColor", &style_color)) {
+ gdk_color_parse (MODEST_SECONDARY_COLOR, &style_color);
}
priv->secondary_color = style_color;
attr = pango_attr_foreground_new (style_color.red, style_color.green, style_color.blue);
NULL);
}
- if (gtk_style_lookup_color (GTK_WIDGET (self)->style, "ActiveTextColor", &style_active_color)) {
+ if (gtk_style_lookup_color (gtk_widget_get_style (GTK_WIDGET (self)), "ActiveTextColor", &style_active_color)) {
priv->active_color = style_active_color;
#ifdef MODEST_TOOLKIT_HILDON2
g_object_set_data (G_OBJECT (priv->renderer_subject), BOLD_IS_ACTIVE_COLOR, GINT_TO_POINTER (TRUE));
NULL))
return NULL;
- g_debug ("located path: %s", gtk_tree_path_to_string (path));
-
/* Get model */
tree_model = gtk_tree_view_get_model ((GtkTreeView *) header_view);
if (!gtk_tree_model_get_iter (tree_model, &iter, path))
return header;
}
+
+void
+modest_header_view_set_filter_string (ModestHeaderView *self,
+ const gchar *filter_string)
+{
+ ModestHeaderViewPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_HEADER_VIEW (self));
+ priv = MODEST_HEADER_VIEW_GET_PRIVATE (self);
+
+ if (priv->filter_string)
+ g_free (priv->filter_string);
+
+ priv->filter_string = g_strdup (filter_string);
+
+ if (priv->filter_string_splitted) {
+ g_strfreev (priv->filter_string_splitted);
+ priv->filter_string_splitted = NULL;
+ }
+
+ if (priv->filter_string) {
+ priv->filter_string_splitted = g_strsplit (priv->filter_string, " ", 0);
+ }
+ modest_header_view_refilter (MODEST_HEADER_VIEW (self));
+}