* compile fixes
[modest] / src / gtk / modest-ui-main-view.c
index 631c0cb..b6c21c7 100644 (file)
@@ -1,3 +1,33 @@
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 #include <glib/gi18n.h>
@@ -9,6 +39,7 @@
 
 /* TODO: put in auto* */
 #include <tny-text-buffer-stream.h>
+#include <tny-list.h>
 #include <tny-msg-folder.h>
 
 #include "../modest-ui.h"
@@ -18,9 +49,9 @@
 #include "../modest-identity-mgr.h"
 
 #include "../modest-tny-account-store.h"
-#include "../modest-tny-folder-tree-view.h"
-#include "../modest-tny-header-tree-view.h"
-#include "../modest-tny-msg-view.h"
+#include "../widgets/modest-folder-view.h"
+#include "../widgets/modest-header-view.h"
+#include "../widgets/modest-msg-view.h"
 #include "../modest-tny-transport-actions.h"
 #include "../modest-tny-store-actions.h"
 
@@ -43,11 +74,11 @@ static GtkWidget* modest_main_window_folder_tree (ModestAccountMgr *modest_acc_m
 
 static GtkWidget* modest_main_window_header_tree (TnyMsgFolderIface *folder);
 
-static void on_folder_clicked (ModestTnyFolderTreeView *folder_tree,
+static void on_folder_clicked (ModestFolderView *folder_tree,
                               TnyMsgFolderIface *folder,
                               gpointer data);
 
-static void on_message_clicked (ModestTnyFolderTreeView *folder_tree,
+static void on_message_clicked (ModestFolderView *folder_tree,
                                TnyMsgIface *message,
                                gpointer data);
 
@@ -57,16 +88,12 @@ static void on_forward_clicked (GtkWidget *widget, gpointer user_data);
 
 static void on_delete_clicked (GtkWidget *widget, gpointer user_data);
 
-static void on_view_attachments_toggled(GtkWidget *widget, gpointer user_data);
-
 static void on_sendreceive_button_clicked (GtkWidget *widget, gpointer user_data);
 
 static void on_forward_attached_activated (GtkWidget *widget, gpointer user_data);
 
 static void on_headers_status_update (GtkWidget *header_view, const gchar *msg, gint status,
                          gpointer user_data);
-static void on_status_cleanup (gpointer user_data);
-
 static void register_toolbar_callbacks (ModestUI *modest_ui);
 
 
@@ -85,8 +112,6 @@ modest_ui_main_view_destroy (GtkWidget *win, GdkEvent *event, gpointer data)
        else
                gtk_widget_hide(win);
 }
-
-
 gboolean
 modest_ui_show_main_window (ModestUI *modest_ui)
 {
@@ -96,23 +121,22 @@ modest_ui_show_main_window (ModestUI *modest_ui)
        GtkWidget     *folder_view, *header_view;
        GtkWidget     *message_view;
        GtkWidget     *account_settings_item;
-       GtkWidget     *forward_attached_menu_item;
        GtkWidget     *delete_item;
        GtkWidget     *open_item;
+       GtkWidget     *forward_attached_menu_item;
        GtkWidget     *view_attachments_item;
        GtkWidget     *new_account_item;
        
        GtkWidget  *folder_view_holder,
                *header_view_holder,
                *mail_paned;
-       gboolean show_attachments_inline;
 
        priv = MODEST_UI_GET_PRIVATE(modest_ui);
        
        height = modest_conf_get_int (priv->modest_conf,
-                                     MODEST_CONF_MAIN_WINDOW_HEIGHT,NULL);
+                                     MODEST_MAIN_WINDOW_HEIGHT,NULL);
        width  = modest_conf_get_int (priv->modest_conf,
-                                     MODEST_CONF_MAIN_WINDOW_WIDTH,NULL);
+                                     MODEST_MAIN_WINDOW_WIDTH,NULL);
 
        win = glade_xml_get_widget (priv->glade_xml, "main");
        if (!win) {
@@ -121,7 +145,7 @@ modest_ui_show_main_window (ModestUI *modest_ui)
        }
 
        folder_view = GTK_WIDGET(modest_main_window_folder_tree(priv->modest_acc_mgr,
-                                                         priv->account_store));
+                                                               priv->account_store));
        priv->folder_view = folder_view;
        folder_view_holder = glade_xml_get_widget (priv->glade_xml, "folders");
        if (!folder_view||!folder_view_holder) {
@@ -129,7 +153,7 @@ modest_ui_show_main_window (ModestUI *modest_ui)
                return FALSE;
        }
        gtk_container_add (GTK_CONTAINER(folder_view_holder), folder_view);
-
+       
        header_view  =  GTK_WIDGET(modest_main_window_header_tree (NULL));
        priv->header_view = header_view;
        header_view_holder = glade_xml_get_widget (priv->glade_xml, "mail_list");
@@ -141,19 +165,15 @@ modest_ui_show_main_window (ModestUI *modest_ui)
 
        g_signal_connect (G_OBJECT(folder_view), "folder_selected",
                          G_CALLBACK(on_folder_clicked), modest_ui);
-
-       show_attachments_inline = modest_conf_get_bool(priv->modest_conf,
-                                            MODEST_CONF_MSG_VIEW_SHOW_ATTACHMENTS_INLINE,
-                                            NULL);
-
-       message_view  = GTK_WIDGET(modest_tny_msg_view_new (NULL, show_attachments_inline));
+       
+       message_view  = GTK_WIDGET(modest_msg_view_new (NULL));
        priv->message_view = message_view;
        if (!message_view) {
                g_warning ("failed to create message view");
                return FALSE;
        }
-       g_signal_connect(G_OBJECT(message_view), "on_mailto_clicked",
-                     G_CALLBACK(ui_on_mailto_clicked), modest_ui);
+       //g_signal_connect(G_OBJECT(message_view), "on_mailto_clicked",
+        //            G_CALLBACK(ui_on_mailto_clicked), modest_ui);
 
        mail_paned = glade_xml_get_widget (priv->glade_xml, "mail_paned");
        gtk_paned_add2 (GTK_PANED(mail_paned), message_view);
@@ -217,14 +237,6 @@ modest_ui_show_main_window (ModestUI *modest_ui)
        g_signal_connect (forward_attached_menu_item, "activate", G_CALLBACK(on_forward_attached_activated),
                          modest_ui);
 
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(view_attachments_item),
-                                       modest_conf_get_bool(priv->modest_conf,
-                                       MODEST_CONF_MSG_VIEW_SHOW_ATTACHMENTS_INLINE,
-                                       NULL));
-
-       g_signal_connect (view_attachments_item, "toggled",
-                               G_CALLBACK(on_view_attachments_toggled), modest_ui);
-
        register_toolbar_callbacks (modest_ui);
 
        modest_window_mgr_register (priv->modest_window_mgr,
@@ -301,14 +313,14 @@ register_toolbar_callbacks (ModestUI *modest_ui)
 
 
 static void
-on_folder_clicked (ModestTnyFolderTreeView *folder_tree,
+on_folder_clicked (ModestFolderView *folder_tree,
                   TnyMsgFolderIface *folder,
                   gpointer data)
 {
        GtkWidget *win;
        GtkWidget *button;
-       ModestTnyHeaderTreeView *tree_view;
-       ModestTnyMsgView *msg_view;
+       ModestHeaderView *tree_view;
+       ModestMsgView *msg_view;
        ModestUIPrivate *priv;
        GtkWidget *scrollview;
 
@@ -318,13 +330,13 @@ on_folder_clicked (ModestTnyFolderTreeView *folder_tree,
        priv = MODEST_UI_GET_PRIVATE(data);
        scrollview = glade_xml_get_widget (priv->glade_xml,"mail_list");
 
-       tree_view = MODEST_TNY_HEADER_TREE_VIEW (priv->header_view);
+       tree_view = MODEST_HEADER_VIEW (priv->header_view);
 
        win = glade_xml_get_widget (priv->glade_xml, "main");
        gtk_window_set_title (GTK_WINDOW(win),
                              tny_msg_folder_iface_get_name(folder));
 
-       modest_tny_header_tree_view_set_folder (tree_view, folder);
+       modest_header_view_set_folder (tree_view, folder);
        priv->current_folder = folder;
 
        button = glade_xml_get_widget (priv->glade_xml, "toolb_reply");
@@ -342,28 +354,28 @@ on_folder_clicked (ModestTnyFolderTreeView *folder_tree,
                gtk_widget_set_sensitive(button, FALSE);
        }
 
-       msg_view = MODEST_TNY_MSG_VIEW (priv->message_view);
+       msg_view = MODEST_MSG_VIEW (priv->message_view);
        g_return_if_fail (msg_view);
 
-       modest_tny_msg_view_set_message  (msg_view, NULL);
+       modest_msg_view_set_message  (msg_view, NULL);
 }
 
 
 static void
-on_message_clicked (ModestTnyFolderTreeView *folder_tree,
-                               TnyMsgIface *message,
-                               gpointer data)
+on_message_clicked (ModestFolderView *folder_tree,
+                   TnyMsgIface *message,
+                   gpointer data)
 {
        GtkWidget *button;
-       ModestTnyMsgView *msg_view;
+       ModestMsgView *msg_view;
        ModestUIPrivate *priv;
 
        g_return_if_fail (data);
 
        priv = MODEST_UI_GET_PRIVATE (data);
-       msg_view = MODEST_TNY_MSG_VIEW (priv->message_view);
+       msg_view = MODEST_MSG_VIEW (priv->message_view);
 
-       modest_tny_msg_view_set_message (msg_view, message);
+       modest_msg_view_set_message (msg_view, message);
        
        button = glade_xml_get_widget (priv->glade_xml, "toolb_reply");
        if (button) {
@@ -386,19 +398,19 @@ modest_main_window_header_tree (TnyMsgFolderIface *folder)
        int i;
        GSList *columns = NULL;
        GtkWidget *header_tree;
-       ModestTnyHeaderTreeViewColumn cols[] = {
-               MODEST_TNY_HEADER_TREE_VIEW_COLUMN_MSGTYPE,
-               MODEST_TNY_HEADER_TREE_VIEW_COLUMN_ATTACH,
-               MODEST_TNY_HEADER_TREE_VIEW_COLUMN_FROM,
-               MODEST_TNY_HEADER_TREE_VIEW_COLUMN_SUBJECT,
-               MODEST_TNY_HEADER_TREE_VIEW_COLUMN_RECEIVED_DATE
+       ModestHeaderViewColumn cols[] = {
+               MODEST_HEADER_VIEW_COLUMN_MSGTYPE,
+               MODEST_HEADER_VIEW_COLUMN_ATTACH,
+               MODEST_HEADER_VIEW_COLUMN_FROM,
+               MODEST_HEADER_VIEW_COLUMN_SUBJECT,
+               MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE
        };
 
-       for (i = 0 ; i != sizeof(cols) / sizeof(ModestTnyHeaderTreeViewColumn); ++i)
+       for (i = 0 ; i != sizeof(cols) / sizeof(ModestHeaderViewColumn); ++i)
                columns = g_slist_append (columns, GINT_TO_POINTER(cols[i]));
 
-       header_tree = GTK_WIDGET(modest_tny_header_tree_view_new(folder, columns,
-                                                                MODEST_TNY_HEADER_TREE_VIEW_STYLE_NORMAL));
+       header_tree = GTK_WIDGET(modest_header_view_new(folder, columns,
+                                                       MODEST_HEADER_VIEW_STYLE_NORMAL));
        g_slist_free (columns);
 
        if (!header_tree) {
@@ -416,7 +428,7 @@ modest_main_window_folder_tree (ModestAccountMgr *modest_acc_mgr,
 {
        GtkWidget *folder_tree;
 
-       folder_tree = GTK_WIDGET (modest_tny_folder_tree_view_new (account_store));
+       folder_tree = GTK_WIDGET (modest_folder_view_new (account_store));
        if (!folder_tree) {
                g_warning ("could not create folder list");
                return NULL;
@@ -445,33 +457,6 @@ on_forward_clicked (GtkWidget *widget, gpointer user_data)
 
 
 static void
-on_view_attachments_toggled(GtkWidget *widget, gpointer user_data)
-{
-       ModestUI *modest_ui = (ModestUI *)user_data;
-       GtkWidget *view_attachments_item;
-       ModestTnyMsgView *msg_view;
-       ModestUIPrivate *priv;
-       gboolean view_attachments_inline;
-
-       priv = MODEST_UI_GET_PRIVATE(modest_ui);
-       view_attachments_item = glade_xml_get_widget (priv->glade_xml, "menu_view_attachments");
-       g_return_if_fail(view_attachments_item);
-
-       msg_view = MODEST_TNY_MSG_VIEW(priv->message_view);
-
-       view_attachments_inline = gtk_check_menu_item_get_active(
-                                       GTK_CHECK_MENU_ITEM(view_attachments_item));
-
-       modest_conf_set_bool(priv->modest_conf,
-                            MODEST_CONF_MSG_VIEW_SHOW_ATTACHMENTS_INLINE,
-                            view_attachments_inline,
-                            NULL);
-
-       modest_tny_msg_view_set_show_attachments_inline_flag(msg_view, view_attachments_inline);
-}
-
-
-static void
 on_delete_clicked (GtkWidget *widget, gpointer user_data)
 {
        ModestUI *modest_ui = (ModestUI *)user_data;
@@ -480,18 +465,18 @@ on_delete_clicked (GtkWidget *widget, gpointer user_data)
        GtkTreeIter iter;
        GtkTreeModel *mymodel;
 
-       ModestTnyHeaderTreeView *header_view;
-       ModestTnyMsgView *msg_view;
+       ModestHeaderView *header_view;
+       ModestMsgView *msg_view;
        ModestUIPrivate *priv;
 
        g_return_if_fail (modest_ui);
 
        priv = MODEST_UI_GET_PRIVATE(modest_ui);
 
-       msg_view = MODEST_TNY_MSG_VIEW(priv->message_view);
+       msg_view = MODEST_MSG_VIEW(priv->message_view);
        g_return_if_fail (msg_view);
 
-       header_view = MODEST_TNY_HEADER_TREE_VIEW(priv->header_view);
+       header_view = MODEST_HEADER_VIEW(priv->header_view);
        g_return_if_fail (header_view);
 
        sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(header_view));
@@ -529,31 +514,47 @@ on_delete_clicked (GtkWidget *widget, gpointer user_data)
 static void
 on_sendreceive_button_clicked (GtkWidget *widget, gpointer user_data)
 {
-       ModestUI *modest_ui = (ModestUI *)user_data;
+       ModestUI *modest_ui;
        ModestUIPrivate *priv;
-       TnyAccountStoreIface *account_store;
-       const GList *store_accounts;
-       const GList *iter;
 
-       g_return_if_fail (modest_ui);
+       TnyListIface *store_accounts;
+       TnyIteratorIface *iter;
+       
+       g_return_if_fail (user_data);
+
+       modest_ui = MODEST_UI(user_data);
        priv = MODEST_UI_GET_PRIVATE(modest_ui);
 
-       account_store = priv->account_store;
-       store_accounts =
-               tny_account_store_iface_get_store_accounts (account_store);
+       store_accounts = tny_list_new (); 
+       tny_account_store_iface_get_accounts (priv->account_store, store_accounts,
+                                             TNY_ACCOUNT_STORE_IFACE_STORE_ACCOUNTS);
+       iter = tny_list_iface_create_iterator (store_accounts);
+       
+       if (tny_iterator_iface_has_first (iter)) {
+               while (1) {
+                       TnyStoreAccountIface *account;
+                       account = TNY_STORE_ACCOUNT_IFACE(tny_iterator_iface_current(iter));
+                       modest_tny_store_actions_update_folders (account);
+                       
+                       if (!tny_iterator_iface_has_next (iter))
+                               break;
+                       
+                       tny_iterator_iface_next (iter); 
+               }
                
-       for (iter = store_accounts; iter; iter = iter->next) {
-               modest_tny_store_actions_update_folders (TNY_STORE_ACCOUNT_IFACE (iter->data));
-
        }
-       
+       g_object_unref (G_OBJECT(iter));
+       g_object_unref (G_OBJECT(store_accounts));
+               
        if (priv->header_view && priv->current_folder) {
-                       
-               modest_tny_header_tree_view_set_folder (MODEST_TNY_HEADER_TREE_VIEW(priv->header_view),
-                                                       priv->current_folder);
+               
+               modest_header_view_set_folder (MODEST_HEADER_VIEW(priv->header_view),
+                                              priv->current_folder);
                gtk_widget_queue_draw (priv->header_view);
        }
 }
+
+
 static void
 on_forward_attached_activated (GtkWidget *widget, gpointer user_data)
 {