* src/widgets/modest-msg-view.c:
[modest] / src / modest-ui-actions.c
index 24d0376..83f60ff 100644 (file)
@@ -36,6 +36,7 @@
 #include <modest-runtime.h>
 #include <modest-tny-msg.h>
 #include <modest-tny-account.h>
+#include <modest-address-book.h>
 
 #include "modest-ui-actions.h"
 
@@ -190,6 +191,19 @@ modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win)
 }
 
 void
+modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win)
+{
+       GtkClipboard *clipboard = NULL;
+       gchar *selection = NULL;
+
+       clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+       selection = gtk_clipboard_wait_for_text (clipboard);
+
+       modest_address_book_add_address (selection);
+       g_free (selection);
+}
+
+void
 modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
 {
        /* GtkDialog *account_win; */
@@ -506,7 +520,7 @@ modest_ui_actions_on_send_receive (GtkAction *action,  ModestWindow *win)
 {
        gchar *account_name;
        TnyAccount *tny_account;
-       //ModestTnySendQueue *send_queue;
+       ModestTnySendQueue *send_queue;
        ModestMailOperation *mail_op;
        
        account_name =
@@ -517,8 +531,7 @@ modest_ui_actions_on_send_receive (GtkAction *action,  ModestWindow *win)
                g_printerr ("modest: cannot get account\n");
                return;
        }
-       /* FIXME */
-#if 0
+
        tny_account = 
                modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store(),
                                                                     account_name,
@@ -527,18 +540,17 @@ modest_ui_actions_on_send_receive (GtkAction *action,  ModestWindow *win)
                g_printerr ("modest: cannot get tny transport account for %s\n", account_name);
                return;
        }
-
        send_queue = modest_tny_send_queue_new (TNY_CAMEL_TRANSPORT_ACCOUNT(tny_account));
        if (!send_queue) {
                g_object_unref (G_OBJECT(tny_account));
                g_printerr ("modest: cannot get send queue for %s\n", account_name);
                return;
        } 
-       modest_tny_send_queue_flush (send_queue);
+       //modest_tny_send_queue_flush (send_queue);
 
        g_object_unref (G_OBJECT(send_queue));
        g_object_unref (G_OBJECT(tny_account));
-#endif /*  0 */
+
        tny_account = 
                modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store(),
                                                                     account_name,
@@ -760,20 +772,10 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
                                               gboolean selected,
                                               ModestMainWindow *main_window)
 {
-//     GtkLabel *folder_info_label;
-       gchar *txt;     
+       gchar *txt;
        ModestConf *conf;
        GtkWidget *header_view;
        
-/*     folder_info_label =  */
-/*             GTK_LABEL (modest_widget_factory_get_folder_info_label */
-/*                        (modest_runtime_get_widget_factory())); */
-
-/*     if (!folder) { */
-/*             gtk_label_set_label (GTK_LABEL(folder_info_label), ""); */
-/*             return; */
-/*     } */
-       
        g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
 
        header_view = modest_main_window_get_child_widget(main_window,
@@ -967,23 +969,10 @@ modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, int index,
 
 void
 modest_ui_actions_on_msg_recpt_activated (ModestMsgView *msgview,
-                                         ModestRecptView *recpt_view,
+                                         const gchar *address,
                                          ModestWindow *win)
 {
-       gint start, end;
-       gchar *utf_start, *utf_end;
-       gchar *full_string = NULL;
-       gchar *substring;
-
-       gtk_label_get_selection_bounds (GTK_LABEL (recpt_view), &start, &end);
-       full_string = (gchar *) gtk_label_get_text (GTK_LABEL (recpt_view));
-       utf_start = g_utf8_offset_to_pointer (full_string, start);
-       utf_end = g_utf8_offset_to_pointer (full_string, end);
-       substring = g_strndup (utf_start, utf_end - utf_start);
-       g_message ("%s %s", __FUNCTION__, substring);
-
-       g_free (substring);
-       
+       g_message ("%s %s", __FUNCTION__, address);
 }
 
 void
@@ -1186,7 +1175,7 @@ delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
        if (!folder_view)
                return;
 
-       folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
+       folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
        
        mail_op = modest_mail_operation_new ();
        modest_mail_operation_remove_folder (mail_op, folder, move_to_trash);
@@ -1195,7 +1184,8 @@ delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
        if (error)
                g_warning ("%s\n", error->message);
 
-       g_object_unref (mail_op);
+       g_object_unref (G_OBJECT (mail_op));
+       g_object_unref (G_OBJECT (folder));
 }
 
 void