* all:
[modest] / src / modest-ui.c
index 1136a92..1216e9e 100644 (file)
@@ -39,6 +39,7 @@
 #include "modest-tny-platform-factory.h"
 #include "modest-account-view-window.h"
 #include "modest-main-window.h"
+#include <modest-widget-memory.h>
 #include <tny-error.h>
 #include <tny-simple-list.h>
 
@@ -183,7 +184,8 @@ modest_ui_new (TnyAccountStore *account_store)
        
        priv->account_store = account_store;
 
-       account_mgr = modest_tny_platform_factory_get_modest_account_mgr_instance (fact);
+       account_mgr = modest_tny_platform_factory_get_account_mgr_instance
+               (MODEST_TNY_PLATFORM_FACTORY(fact));
        if (!account_mgr) {
                g_printerr ("modest: could not create ModestAccountMgr instance\n");
                g_object_unref (obj);
@@ -267,7 +269,6 @@ register_stock_icons ()
        if (!registered) {
                GdkPixbuf *pixbuf;
                GtkIconFactory *factory;
-               gchar *filename;
                gint i;
 
                static GtkStockItem items[] = {
@@ -352,10 +353,7 @@ connect_signals (ModestUI *self)
        /* folder view */
        g_signal_connect (G_OBJECT(folder_view), "folder_selection_changed",
                          G_CALLBACK(_modest_ui_actions_on_folder_selection_changed),
-                         priv->main_window);
-/*     g_signal_connect (G_OBJECT(folder_view), "key-press-event", */
-/*                       G_CALLBACK(on_folder_key_press_event), priv->widget_factory); */
-
+                         priv->main_window);   
        /* header view */
        g_signal_connect (G_OBJECT(header_view), "status_update",
                          G_CALLBACK(_modest_ui_actions_on_header_status_update), 
@@ -366,8 +364,6 @@ connect_signals (ModestUI *self)
        g_signal_connect (G_OBJECT(header_view), "item_not_found",
                          G_CALLBACK(_modest_ui_actions_on_item_not_found), 
                          priv->main_window);
-
-       
        /* msg preview */
        g_signal_connect (G_OBJECT(msg_view), "link_clicked",
                          G_CALLBACK(_modest_ui_actions_on_msg_link_clicked), 
@@ -570,6 +566,8 @@ reply_forward_func (gpointer data, gpointer user_data)
                        modest_mail_operation_create_forward_mail (msg, rf_helper->from, rf_helper->reply_forward_type);
                edit_type = MODEST_EDIT_TYPE_FORWARD;
                break;
+       default:
+               g_return_if_reached ();
        }
 
        /* Set from */
@@ -612,13 +610,13 @@ reply_forward (GtkWidget *widget,
        TnyHeader *header;
        TnyFolder *folder;
        gchar *from, *key;
-       ModestFolderView *folder_view;
        GetMsgAsyncHelper *helper;
        ReplyForwardHelper *rf_helper;
 
        /* Get ModestConf */
        plat_factory = modest_tny_platform_factory_get_instance ();
-       conf = modest_tny_platform_factory_get_modest_conf_instance (plat_factory);
+       conf = modest_tny_platform_factory_get_conf_instance
+               (MODEST_TNY_PLATFORM_FACTORY(plat_factory));
 
        /* Get reply or forward type */
        key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE, 
@@ -700,6 +698,36 @@ _modest_ui_actions_on_next (GtkWidget *widget,
        modest_header_view_select_next (header_view);
 }
 
+void
+_modest_ui_actions_toggle_view (GtkWidget *widget,
+                               ModestMainWindow *main_window)
+{
+       ModestHeaderView *header_view;
+       ModestWidgetFactory *widget_factory;
+       ModestConf *conf;
+       TnyPlatformFactory *plat_factory;
+
+       /* Get ModestConf */
+       plat_factory = modest_tny_platform_factory_get_instance ();
+       conf = modest_tny_platform_factory_get_conf_instance
+               (MODEST_TNY_PLATFORM_FACTORY(plat_factory));
+       widget_factory = modest_main_window_get_widget_factory (main_window);
+       header_view = modest_widget_factory_get_header_view (widget_factory);
+       g_object_unref (G_OBJECT(widget_factory));
+
+       /* what is saved/restored is depending on the style; thus; we save with
+        * old style, then update the style, and restore for this new style*/
+       modest_widget_memory_save (conf, G_OBJECT(header_view), "header-view");
+       
+       if (modest_header_view_get_style (header_view) == MODEST_HEADER_VIEW_STYLE_DETAILS)
+               modest_header_view_set_style (header_view, MODEST_HEADER_VIEW_STYLE_TWOLINES);
+       else
+               modest_header_view_set_style (header_view, MODEST_HEADER_VIEW_STYLE_DETAILS);
+
+       modest_widget_memory_restore (conf, G_OBJECT(header_view), "header-view");
+}
+
+
 
 /*
  * Marks a message as read and passes it to the msg preview widget
@@ -788,10 +816,16 @@ _modest_ui_actions_on_header_selected (ModestHeaderView *folder_view,
        TnyFolder *folder;
        GetMsgAsyncHelper *helper;
        TnyList *list;
-       TnyIterator *iter;
 
-       if (!header)
+       /* when there's no header, clear the msgview */
+       if (!header) {
+               ModestMsgView *msg_view;
+               ModestWidgetFactory *widget_factory;
+               widget_factory = modest_main_window_get_widget_factory (main_window);
+               msg_view       = modest_widget_factory_get_msg_preview (widget_factory);
+               modest_msg_view_set_message (msg_view, NULL);
                return;
+       }
 
        folder = tny_header_get_folder (TNY_HEADER(header));
 
@@ -806,8 +840,7 @@ _modest_ui_actions_on_header_selected (ModestHeaderView *folder_view,
        helper->func = read_msg_func;
 
        tny_folder_get_msg_async (TNY_FOLDER(folder),
-                                 header,
-                                 get_msg_cb,
+                                 header, get_msg_cb,
                                  helper);
 
        /* Frees */
@@ -838,17 +871,27 @@ _modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
 
        factory = modest_tny_platform_factory_get_instance ();
        header_view = modest_widget_factory_get_header_view (widget_factory);
-       conf = modest_tny_platform_factory_get_modest_conf_instance (factory);
+       conf = modest_tny_platform_factory_get_conf_instance
+               (MODEST_TNY_PLATFORM_FACTORY(factory));
        g_object_unref (G_OBJECT (widget_factory));
 
        if (!selected) { /* the folder was unselected; save it's settings  */
                modest_widget_memory_save (conf, G_OBJECT (header_view),
                                           "header-view");
+               gtk_window_set_title (GTK_WINDOW(main_window), "Modest");
+               modest_header_view_set_folder (header_view, NULL);
        } else {  /* the folder was selected */
                guint num, unread;
+               gchar *title;
                num    = tny_folder_get_all_count    (folder);
                unread = tny_folder_get_unread_count (folder);
-                       
+
+               title = g_strdup_printf ("Modest: %s",
+                                        tny_folder_get_name (folder));
+               
+               gtk_window_set_title (GTK_WINDOW(main_window), title);
+               g_free (title);
+
                txt = g_strdup_printf (_("%d %s, %d unread"),
                                       num, num==1 ? _("item") : _("items"), unread);           
                gtk_label_set_label (GTK_LABEL(folder_info_label), txt);
@@ -1081,6 +1124,8 @@ _modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,
        gdk_threads_leave ();
 }
 
+
+
 void
 _modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, 
                                            const gchar *msg,
@@ -1107,6 +1152,7 @@ _modest_ui_actions_on_header_status_update (ModestHeaderView *header_view,
 }
 
 
+
 void
 _modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, 
                                      const gchar* link,