* Change headers list tree view rows layout (flags, header, date).
[modest] / src / modest-ui-actions.c
index 5a14c75..acf643c 100644 (file)
@@ -34,6 +34,7 @@
 #include <glib/gi18n.h>
 #include <string.h>
 #include <modest-runtime.h>
+#include <modest-tny-folder.h>
 #include <modest-tny-msg.h>
 #include <modest-tny-account.h>
 #include <modest-address-book.h>
@@ -189,16 +190,13 @@ modest_ui_actions_on_delete (GtkAction *action, ModestWindow *win)
 
        if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
                gtk_widget_destroy (GTK_WIDGET(win));
-       }
+       } 
 }
 
 
 void
 modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win)
 {
-       /* FIXME: save size of main window */
-/*     save_sizes (main_window); */
-/*     gtk_widget_destroy (GTK_WIDGET (win)); */
        gtk_main_quit ();
 }
 
@@ -289,12 +287,16 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
        gchar *account_name = NULL;
        gchar *from_str = NULL;
        GError *err = NULL;
-       TnyAccount *account;
+       TnyAccount *account = NULL;
        ModestWindowMgr *mgr;
        
        account_name = g_strdup(modest_window_get_active_account (win));
        if (!account_name)
                account_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
+       if (!account_name) {
+               g_printerr ("modest: no account found\n");
+               goto cleanup;
+       }
        
        account = modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store(),
                                                                       account_name,
@@ -632,6 +634,7 @@ action_receive (const gchar* account_name)
        mail_op = modest_mail_operation_new ();
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
        modest_mail_operation_update_account (mail_op, TNY_STORE_ACCOUNT(tny_account));
+
        g_object_unref (G_OBJECT(tny_account));
        g_object_unref (G_OBJECT (mail_op));
                
@@ -663,7 +666,7 @@ modest_ui_actions_on_send_receive (GtkAction *action,  ModestWindow *win)
 
 
 void
-modest_ui_actions_toggle_view (GtkAction *action, ModestMainWindow *main_window)
+modest_ui_actions_toggle_header_list_view (GtkAction *action, ModestMainWindow *main_window)
 {
        ModestConf *conf;
        GtkWidget *header_view;
@@ -818,7 +821,7 @@ void
 modest_ui_actions_on_header_activated (ModestHeaderView *folder_view, TnyHeader *header,
                                       ModestMainWindow *main_window)
 {
-       ModestWindow *win;
+       ModestWindow *win = NULL;
        TnyFolder *folder = NULL;
        TnyMsg    *msg    = NULL;
        ModestWindowMgr *mgr;
@@ -831,7 +834,7 @@ modest_ui_actions_on_header_activated (ModestHeaderView *folder_view, TnyHeader
        folder = tny_header_get_folder (header);
        if (!folder) {
                g_printerr ("modest: cannot get folder for header\n");
-               goto cleanup;
+               return;
        }
 
        /* FIXME: make async?; check error  */
@@ -858,17 +861,14 @@ modest_ui_actions_on_header_activated (ModestHeaderView *folder_view, TnyHeader
 
                gtk_window_set_transient_for (GTK_WINDOW (win),
                                              GTK_WINDOW (main_window));
-
-               g_free (account);
        }
 
        gtk_widget_show_all (GTK_WIDGET(win));
+
+       g_object_unref (G_OBJECT (msg));
        
 cleanup:
-       if (folder)
-               g_object_unref (G_OBJECT (folder));
-       if (msg)
-               g_object_unref (G_OBJECT (msg));
+       g_object_unref (G_OBJECT (folder));
 }
 
 void 
@@ -1535,7 +1535,7 @@ modest_ui_actions_on_toggle_fullscreen    (GtkToggleAction *toggle,
        mgr = modest_runtime_get_window_mgr ();
 
        active = (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle)))?1:0;
-       fullscreen = (modest_window_mgr_get_fullscreen_mode (mgr))?1:0;
+       fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
 
        if (active != fullscreen) {
                modest_window_mgr_set_fullscreen_mode (mgr, active);
@@ -1629,3 +1629,40 @@ modest_ui_actions_on_toggle_show_bcc (GtkToggleAction *toggle,
 
        modest_msg_edit_window_show_bcc (window, gtk_toggle_action_get_active (toggle));
 }
+
+void
+modest_ui_actions_toggle_folders_view (GtkAction *action, 
+                                      ModestMainWindow *main_window)
+{
+       ModestConf *conf;
+       
+       g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
+
+       conf = modest_runtime_get_conf ();
+       
+       if (modest_main_window_get_style (main_window) == MODEST_MAIN_WINDOW_STYLE_SPLIT)
+               modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SIMPLE);
+       else
+               modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SPLIT);
+}
+
+void 
+modest_ui_actions_on_toggle_toolbar (GtkToggleAction *toggle, 
+                                    ModestWindow *window)
+{
+       gboolean active, fullscreen = FALSE;
+       ModestWindowMgr *mgr;
+
+       active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle));
+
+       /* Check if we want to toggle the toolbar vuew in fullscreen
+          or normal mode */
+       if (!strcmp (gtk_action_get_name (GTK_ACTION (toggle)), 
+                    "ViewShowToolbarFullScreen")) {
+               fullscreen = TRUE;
+       }
+
+       /* Toggle toolbar */
+       mgr = modest_runtime_get_window_mgr ();
+       modest_window_mgr_show_toolbars (mgr, active, fullscreen);
+}