If live search is enabled, don't use find toolbar in header window
[modest] / src / hildon2 / modest-header-window.c
index 6c3d6a4..c387674 100644 (file)
 #include <modest-ui-actions.h>
 #include <modest-platform.h>
 #include <modest-text-utils.h>
-#include <hildon/hildon-button.h>
-#include <hildon/hildon-program.h>
-#include <hildon/hildon-banner.h>
-#include <hildon/hildon-find-toolbar.h>
+#include <hildon/hildon.h>
 #include <modest-ui-dimming-rules.h>
 #include <modest-tny-folder.h>
 #include <modest-tny-account.h>
@@ -188,13 +185,15 @@ static gboolean on_key_press(GtkWidget *widget,
                                        gpointer user_data);
 static void modest_header_window_show_more (GtkAction *action, ModestWindow *win);
 
-static void  show_isearch_toolbar   (GtkWidget *obj, gpointer data);
 static void  isearch_toolbar_close  (GtkWidget *widget,
                                     ModestHeaderWindow *obj);
 static void  isearch_toolbar_search (GtkWidget *widget,
                                     ModestHeaderWindow *obj);
+#ifndef MODEST_TOOLKIT_HILDON2
+static void  show_isearch_toolbar   (GtkWidget *obj, gpointer data);
 static void  toggle_isearch_toolbar (GtkWidget *obj,
                                     gpointer data);
+#endif
 
 
 /* globals */
@@ -581,7 +580,11 @@ on_mark_read_csm_activated (GtkMenuItem *item,
                                                       priv->x_coord, priv->y_coord);
 
        if (header) {
+               gchar *uid;
                tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
+               uid = modest_tny_folder_get_header_unique_id (header);
+               modest_platform_emit_msg_read_changed_signal (uid, TRUE);
+               g_free (uid);
                g_object_unref (header);
        }
 }
@@ -601,7 +604,11 @@ on_mark_unread_csm_activated (GtkMenuItem *item,
                                                       priv->x_coord, priv->y_coord);
 
        if (header) {
+               gchar *uid;
                tny_header_unset_flag (header, TNY_HEADER_FLAG_SEEN);
+               uid = modest_tny_folder_get_header_unique_id (header);
+               modest_platform_emit_msg_read_changed_signal (uid, FALSE);
+               g_free (uid);
                g_object_unref (header);
        }
 }
@@ -801,6 +808,9 @@ modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gc
        GdkPixbuf *new_message_pixbuf;
        GtkWidget *alignment;
        gchar *account_display_name = NULL;
+#ifdef MODEST_TOOLKIT_HILDON2
+       GtkWidget *live_search;
+#endif
 
        self  = MODEST_HEADER_WINDOW(g_object_new(MODEST_TYPE_HEADER_WINDOW, NULL));
        priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
@@ -821,6 +831,10 @@ modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gc
                                  self);
 
        priv->header_view  = create_header_view (MODEST_WINDOW (self), folder);
+#ifdef MODEST_TOOLKIT_HILDON2
+       live_search = modest_header_view_setup_live_search (MODEST_HEADER_VIEW (priv->header_view));
+       hildon_live_search_widget_hook (HILDON_LIVE_SEARCH (live_search), GTK_WIDGET (self), priv->header_view);
+#endif
        priv->empty_view = create_empty_view (MODEST_WINDOW (self));
 
        /* Transform the floating reference in a "hard" reference. We
@@ -850,6 +864,9 @@ modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gc
 
         priv->top_vbox = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (alignment), priv->contents_view);
+#ifdef MODEST_TOOLKIT_HILDON2
+       gtk_box_pack_end (GTK_BOX (priv->top_vbox), live_search, FALSE, FALSE, 0);
+#endif
        gtk_box_pack_end (GTK_BOX (priv->top_vbox), alignment, TRUE, TRUE, 0);
 
        gtk_container_add (GTK_CONTAINER (self), priv->top_vbox);
@@ -1004,8 +1021,10 @@ static void setup_menu (ModestHeaderWindow *self)
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
+#ifndef MODEST_TOOLKIT_HILDON2
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _HL("wdgt_bd_search"), NULL,
                                           APP_MENU_CALLBACK (toggle_isearch_toolbar), NULL);
+#endif
 }
 
 static void 
@@ -1636,6 +1655,7 @@ modest_header_window_show_more (GtkAction *action, ModestWindow *win)
        }
 }
 
+#ifndef MODEST_TOOLKIT_HILDON2
 /* Used for the Ctrl+F accelerator */
 static void
 toggle_isearch_toolbar (GtkWidget *obj,
@@ -1662,6 +1682,7 @@ show_isearch_toolbar (GtkWidget *obj,
        gtk_widget_show (priv->isearch_toolbar);
        hildon_find_toolbar_highlight_entry (HILDON_FIND_TOOLBAR (priv->isearch_toolbar), TRUE);
 }
+#endif
 
 /* Handler for click on the "X" close button in isearch toolbar */
 static void