* src/widgets/modest-recpt-view.c:
[modest] / src / maemo / modest-msg-view-window.c
index dc67a34..3a59cc7 100644 (file)
@@ -483,7 +483,9 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg)
        GtkWidget *main_vbox;
        ModestMsgViewWindowPrivate *priv;
        ModestWindowPrivate *parent_priv;
-       
+       ModestConf *conf;
+       GtkAction *action = NULL;
+
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj);
        parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
 
@@ -493,8 +495,17 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg)
 
        /* Menubar */
        parent_priv->menubar = menubar_to_menu (parent_priv->ui_manager);
-       gtk_widget_show_all (GTK_WIDGET(parent_priv->menubar));
+       conf = modest_runtime_get_conf ();
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, 
+                                           "/MenuBar/ViewMenu/ViewShowToolbarMenu/ViewShowToolbarNormalScreenMenu");
+       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                                     modest_conf_get_bool (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR, NULL));
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, 
+                                           "/MenuBar/ViewMenu/ViewShowToolbarMenu/ViewShowToolbarFullScreenMenu");
+       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                                     modest_conf_get_bool (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL));
        hildon_window_set_menu    (HILDON_WINDOW(obj), GTK_MENU(parent_priv->menubar));
+       gtk_widget_show (GTK_WIDGET(parent_priv->menubar));
 
        priv->main_scroll = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->main_scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -1840,18 +1851,6 @@ modest_msg_view_window_window_state_event (GtkWidget *widget, GdkEventWindowStat
 
 }
 
-void
-modest_msg_view_window_toggle_fullscreen (ModestMsgViewWindow *window)
-{
-               ModestWindowPrivate *parent_priv;
-               GtkAction *fs_toggle_action;
-               parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
-               
-               fs_toggle_action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewToggleFullscreenMenu");
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (fs_toggle_action),
-                                             !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (fs_toggle_action)));
-}
-
 static void
 set_homogeneous (GtkWidget *widget,
                 gpointer data)
@@ -1871,6 +1870,8 @@ modest_msg_view_window_show_toolbar (ModestWindow *self,
        GtkWidget *reply_button = NULL, *menu = NULL;
        GtkWidget *placeholder = NULL;
        gint insert_index;
+       const gchar *action_name;
+       GtkAction *action;
        
        parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(self);
@@ -1881,6 +1882,7 @@ modest_msg_view_window_show_toolbar (ModestWindow *self,
        if (!parent_priv->toolbar) {
                parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, 
                                                                  "/ToolBar");
+               gtk_widget_set_no_show_all (parent_priv->toolbar, TRUE);
 
                /* Set homogeneous toolbar */
                gtk_container_foreach (GTK_CONTAINER (parent_priv->toolbar), 
@@ -1936,6 +1938,20 @@ modest_msg_view_window_show_toolbar (ModestWindow *self,
                gtk_widget_set_no_show_all (parent_priv->toolbar, TRUE);
                gtk_widget_hide (GTK_WIDGET (parent_priv->toolbar));
        }
+
+       /* Update also the actions (to update the toggles in the
+          menus), we have to do it manually because some other window
+          of the same time could have changed it (remember that the
+          toolbar fullscreen mode is shared by all the windows of the
+          same type */
+       if (modest_window_mgr_get_fullscreen_mode (modest_runtime_get_window_mgr ()))
+               action_name = "/MenuBar/ViewMenu/ViewShowToolbarMenu/ViewShowToolbarFullScreenMenu";
+       else
+               action_name = "/MenuBar/ViewMenu/ViewShowToolbarMenu/ViewShowToolbarNormalScreenMenu";
+
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, action_name);
+       modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+                                                           show_toolbar);
 }
 
 static void 
@@ -2158,17 +2174,10 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart
        if (!TNY_IS_MSG (mime_part)) {
                gchar *filepath = NULL;
                const gchar *att_filename = tny_mime_part_get_filename (mime_part);
-               gchar *extension = NULL;
                TnyFsStream *temp_stream = NULL;
 
-               if (att_filename) {
-                       extension = g_strrstr (att_filename, ".");
-                       if (extension != NULL)
-                               extension++;
-               }
-
-               temp_stream = modest_maemo_utils_create_temp_stream (extension, &filepath);
-
+               temp_stream = modest_maemo_utils_create_temp_stream (att_filename, &filepath);
+               
                if (temp_stream) {
                        const gchar *content_type;
                        content_type = tny_mime_part_get_content_type (mime_part);
@@ -2177,7 +2186,8 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart
                        modest_platform_activate_file (filepath, content_type);
                        g_object_unref (temp_stream);
                        g_free (filepath);
-                       /* TODO: delete temporary file */
+                       /* NOTE: files in the temporary area will be automatically
+                        * cleaned after some time if they are no longer in use */
                }
        } else {
                /* message attachment */