+ return TRUE;
+}
+
+static void
+setup_menu (ModestMsgViewWindow *self)
+{
+ g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW(self));
+
+ /* Settings menu buttons */
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_replytoall"), NULL,
+ APP_MENU_CALLBACK (modest_ui_actions_on_reply_all),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_reply_msg));
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_forward"), "<Control>d",
+ APP_MENU_CALLBACK (modest_ui_actions_on_forward),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_reply_msg));
+
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_mark_as_read"), NULL,
+ APP_MENU_CALLBACK (modest_ui_actions_on_mark_as_read),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_mark_as_read_msg_in_view));
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_mark_as_unread"), NULL,
+ APP_MENU_CALLBACK (modest_ui_actions_on_mark_as_unread),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_mark_as_unread_msg_in_view));
+
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_viewer_save_attachments"), NULL,
+ APP_MENU_CALLBACK (modest_ui_actions_save_attachments),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_save_attachments));
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_remove_attachments"), NULL,
+ APP_MENU_CALLBACK (modest_ui_actions_remove_attachments),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_remove_attachments));
+
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_new_message"), "<Control>n",
+ APP_MENU_CALLBACK (modest_ui_actions_on_new_msg),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_new_msg));
+ modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_viewer_addtocontacts"), NULL,
+ APP_MENU_CALLBACK (modest_ui_actions_add_to_contacts),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_add_to_contacts));
+}
+
+void
+modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self)
+{
+ ModestMsgViewWindowPrivate *priv;
+ priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
+ GSList *recipients = NULL;
+ TnyMsg *msg = NULL;
+ gboolean contacts_to_add = FALSE;
+
+ msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
+ if (msg == NULL) {
+ TnyHeader *header;
+
+ header = modest_msg_view_window_get_header (self);
+ if (header == NULL)
+ return;
+ recipients = modest_tny_msg_header_get_all_recipients_list (header);
+ g_object_unref (header);
+ } else {
+ recipients = modest_tny_msg_get_all_recipients_list (msg);
+ g_object_unref (msg);
+ }
+
+ if (recipients != NULL) {
+ GtkWidget *picker_dialog;
+ GtkWidget *selector;
+ GSList *node;
+ gchar *selected = NULL;
+
+ selector = hildon_touch_selector_new_text ();
+ g_object_ref (selector);
+
+ for (node = recipients; node != NULL; node = g_slist_next (node)) {
+ if (!modest_address_book_has_address ((const gchar *) node->data)) {
+ hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
+ (const gchar *) node->data);
+ contacts_to_add = TRUE;
+ }
+ }
+
+ if (contacts_to_add) {
+ gint picker_result;
+
+ picker_dialog = hildon_picker_dialog_new (GTK_WINDOW (self));
+ gtk_window_set_title (GTK_WINDOW (picker_dialog), _("mcen_me_viewer_addtocontacts"));
+
+ hildon_picker_dialog_set_selector (HILDON_PICKER_DIALOG (picker_dialog),
+ HILDON_TOUCH_SELECTOR (selector));
+
+ picker_result = gtk_dialog_run (GTK_DIALOG (picker_dialog));
+
+ if (picker_result == GTK_RESPONSE_OK) {
+ selected = hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector));
+ }
+ gtk_widget_destroy (picker_dialog);
+
+ if (selected)
+ modest_address_book_add_address (selected);
+ g_free (selected);
+
+ } else {
+
+ g_object_unref (selector);
+
+ }
+ }
+
+ if (recipients) {g_slist_foreach (recipients, (GFunc) g_free, NULL); g_slist_free (recipients);}
+}
+
+static gboolean
+_modest_msg_view_window_map_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer userdata)
+{
+ ModestMsgViewWindow *self = (ModestMsgViewWindow *) userdata;
+ ModestMsgViewWindowPrivate *priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
+
+ if (priv->progress_hint) {
+ hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
+ }
+
+ return FALSE;