X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-view-window.c;h=eca30438ed16c0e371e719795962210a2a583c5a;hp=5676299fe9ed6a6ceb2db35d7b6e038a39ba170e;hb=38402a6550ee767271308f42ebfbfc81a1fa736b;hpb=5097300975920f8e18482f2fbfa453a0b96e25b9 diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 5676299..eca3043 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -54,6 +54,7 @@ #include "modest-ui-dimming-manager.h" #include #include +#include #define DEFAULT_FOLDER "MyDocs/.documents" @@ -132,6 +133,10 @@ static void on_account_removed (TnyAccountStore *account_store, TnyAccount *account, gpointer user_data); +static void on_move_focus (ModestMsgViewWindow *window, + GtkDirectionType direction, + gpointer userdata); + static void view_msg_cb (ModestMailOperation *mail_op, TnyHeader *header, TnyMsg *msg, @@ -455,7 +460,7 @@ menubar_to_menu (GtkUIManager *ui_manager) { GtkWidget *main_menu; GtkWidget *menubar; - GList *iter; + GList *iter, *children; /* Create new main menu */ main_menu = gtk_menu_new(); @@ -463,15 +468,17 @@ menubar_to_menu (GtkUIManager *ui_manager) /* Get the menubar from the UI manager */ menubar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar"); - iter = gtk_container_get_children (GTK_CONTAINER (menubar)); + iter = children = gtk_container_get_children (GTK_CONTAINER (menubar)); while (iter) { GtkWidget *menu; menu = GTK_WIDGET (iter->data); gtk_widget_reparent(menu, main_menu); - + iter = g_list_next (iter); } + g_list_free (children); + return main_menu; } @@ -481,7 +488,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); @@ -491,8 +500,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); @@ -569,7 +587,7 @@ modest_msg_view_window_disconnect_signals (ModestWindow *self) header_view = MODEST_HEADER_VIEW( modest_main_window_get_child_widget( - main_window, MODEST_WIDGET_TYPE_HEADER_VIEW)); + main_window, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW)); if (header_view == NULL) return; @@ -675,6 +693,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, ModestWindowPrivate *parent_priv = NULL; ModestDimmingRulesGroup *menu_rules_group = NULL; ModestDimmingRulesGroup *toolbar_rules_group = NULL; + ModestDimmingRulesGroup *clipboard_rules_group = NULL; GtkActionGroup *action_group = NULL; GError *error = NULL; GdkPixbuf *window_icon; @@ -695,6 +714,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, menu_rules_group = modest_dimming_rules_group_new ("ModestMenuDimmingRules", FALSE); toolbar_rules_group = modest_dimming_rules_group_new ("ModestToolbarDimmingRules", TRUE); + clipboard_rules_group = modest_dimming_rules_group_new ("ModestClipboardDimmingRules", FALSE); /* Add common actions */ gtk_action_group_add_actions (action_group, @@ -733,17 +753,23 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, modest_dimming_rules_group_add_rules (menu_rules_group, modest_msg_view_menu_dimming_entries, G_N_ELEMENTS (modest_msg_view_menu_dimming_entries), - self); + MODEST_WINDOW (self)); modest_dimming_rules_group_add_rules (toolbar_rules_group, modest_msg_view_toolbar_dimming_entries, G_N_ELEMENTS (modest_msg_view_toolbar_dimming_entries), - self); + MODEST_WINDOW (self)); + modest_dimming_rules_group_add_rules (clipboard_rules_group, + modest_msg_view_clipboard_dimming_entries, + G_N_ELEMENTS (modest_msg_view_clipboard_dimming_entries), + MODEST_WINDOW (self)); /* Insert dimming rules group for this window */ modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, menu_rules_group); modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, toolbar_rules_group); + modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, clipboard_rules_group); g_object_unref (menu_rules_group); g_object_unref (toolbar_rules_group); + g_object_unref (clipboard_rules_group); /* Add accelerators */ gtk_window_add_accel_group (GTK_WINDOW (obj), @@ -781,6 +807,9 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, G_CALLBACK (modest_msg_view_window_window_state_event), NULL); + g_signal_connect (G_OBJECT (obj), "move-focus", + G_CALLBACK (on_move_focus), obj); + /* Mail Operation Queue */ priv->queue_change_handler = g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), "queue-changed", @@ -804,6 +833,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, /* Check toolbar dimming rules */ modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (obj)); + modest_window_check_dimming_rules_group (MODEST_WINDOW (obj), "ModestClipboardDimmingRules"); } @@ -835,7 +865,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, modest_window_mgr_get_main_window(window_mgr)); g_assert(main_window != NULL); header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget( - main_window, MODEST_WIDGET_TYPE_HEADER_VIEW)); + main_window, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW)); if (header_view != NULL){ header_folder = modest_header_view_get_folder(header_view); g_assert(header_folder != NULL); @@ -1263,11 +1293,20 @@ modest_msg_view_window_set_zoom (ModestWindow *window, gdouble zoom) { ModestMsgViewWindowPrivate *priv; + ModestWindowPrivate *parent_priv; + GtkAction *action = NULL; + gint int_zoom = (gint) rint (zoom*100.0+0.1); g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window)); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); + parent_priv = MODEST_WINDOW_GET_PRIVATE (window); modest_msg_view_set_zoom (MODEST_MSG_VIEW (priv->msg_view), zoom); + + action = gtk_ui_manager_get_action (parent_priv->ui_manager, + "/MenuBar/ViewMenu/ZoomMenu/Zoom50Menu"); + + gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), int_zoom); } static gdouble @@ -1838,18 +1877,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) @@ -1869,6 +1896,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); @@ -1879,6 +1908,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), @@ -1934,6 +1964,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 @@ -1941,34 +1985,10 @@ modest_msg_view_window_clipboard_owner_change (GtkClipboard *clipboard, GdkEvent *event, ModestMsgViewWindow *window) { - ModestWindowPrivate *parent_priv; -/* GtkAction *action; */ - gboolean is_address; - gchar *selection; - GtkWidget *focused; - if (!GTK_WIDGET_VISIBLE (window)) return; - parent_priv = MODEST_WINDOW_GET_PRIVATE (window); - selection = gtk_clipboard_wait_for_text (clipboard); - - is_address = ((selection != NULL) && (modest_text_utils_validate_recipient (selection, NULL))); - -/* action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ToolsMenu/ToolsAddToContactsMenu"); */ -/* gtk_action_set_sensitive (action, is_address); */ - - focused = gtk_window_get_focus (GTK_WINDOW (window)); - -/* action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/EditCopyMenu"); */ -/* gtk_action_set_sensitive (action, (selection != NULL) && (!MODEST_IS_ATTACHMENTS_VIEW (focused))); */ - -/* action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/EditCutMenu"); */ -/* gtk_action_set_sensitive (action, (selection != NULL) && (!MODEST_IS_ATTACHMENTS_VIEW (focused))); */ - - g_free (selection); -/* modest_msg_view_window_update_dimmed (window); */ - + modest_window_check_dimming_rules_group (MODEST_WINDOW (window), "ModestClipboardDimmingRules"); } gboolean @@ -2156,17 +2176,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); @@ -2175,7 +2188,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 */ @@ -2579,3 +2593,17 @@ update_window_title (ModestMsgViewWindow *window) gtk_window_set_title (GTK_WINDOW (window), subject); } + +static void on_move_focus (ModestMsgViewWindow *window, + GtkDirectionType direction, + gpointer userdata) +{ + GtkWidget *current_focus = NULL; + + current_focus = gtk_window_get_focus (GTK_WINDOW (window)); + if ((current_focus != NULL) && + MODEST_IS_ATTACHMENTS_VIEW (current_focus)) { + g_signal_stop_emission_by_name (G_OBJECT (window), "move-focus"); + } +} +