X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-view-window.c;h=d49fda2e2f1a49da6d8867a4213121ad3e47c9a6;hp=85f1e2acb42ed77eaee353d8c3602d9f7d770988;hb=bc1a77a8a148948d158889be89cb8013883d8756;hpb=175e5926e0194a8211b846a4eec403a5bdb4afd4 diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 85f1e2a..d49fda2 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -140,7 +140,9 @@ static void on_move_focus (ModestMsgViewWindow *window, static void view_msg_cb (ModestMailOperation *mail_op, TnyHeader *header, + gboolean canceled, TnyMsg *msg, + GError *error, gpointer user_data); static void set_toolbar_mode (ModestMsgViewWindow *self, @@ -149,6 +151,7 @@ static void set_toolbar_mode (ModestMsgViewWindow *self, static void update_window_title (ModestMsgViewWindow *window); static gboolean set_toolbar_transfer_mode (ModestMsgViewWindow *self); +static void init_window (ModestMsgViewWindow *obj); /* list my signals */ @@ -159,7 +162,7 @@ enum { static const GtkToggleActionEntry msg_view_toggle_action_entries [] = { { "FindInMessage", MODEST_TOOLBAR_ICON_FIND, N_("qgn_toolb_gene_find"), NULL, NULL, G_CALLBACK (modest_msg_view_window_toggle_find_toolbar), FALSE }, - { "ToolsFindInMessage", NULL, N_("mcen_me_viewer_find"), NULL, NULL, G_CALLBACK (modest_msg_view_window_toggle_find_toolbar), FALSE }, + { "ToolsFindInMessage", NULL, N_("mcen_me_viewer_find"), "F", NULL, G_CALLBACK (modest_msg_view_window_toggle_find_toolbar), FALSE }, }; static const GtkRadioActionEntry msg_view_zoom_action_entries [] = { @@ -324,8 +327,55 @@ static void modest_msg_view_window_init (ModestMsgViewWindow *obj) { ModestMsgViewWindowPrivate *priv; + ModestWindowPrivate *parent_priv = NULL; + GtkActionGroup *action_group = NULL; + GError *error = NULL; + GdkPixbuf *window_icon; + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj); + parent_priv = MODEST_WINDOW_GET_PRIVATE(obj); + parent_priv->ui_manager = gtk_ui_manager_new(); + + action_group = gtk_action_group_new ("ModestMsgViewWindowActions"); + gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); + + /* Add common actions */ + gtk_action_group_add_actions (action_group, + modest_action_entries, + G_N_ELEMENTS (modest_action_entries), + obj); + gtk_action_group_add_toggle_actions (action_group, + modest_toggle_action_entries, + G_N_ELEMENTS (modest_toggle_action_entries), + obj); + gtk_action_group_add_toggle_actions (action_group, + msg_view_toggle_action_entries, + G_N_ELEMENTS (msg_view_toggle_action_entries), + obj); + gtk_action_group_add_radio_actions (action_group, + msg_view_zoom_action_entries, + G_N_ELEMENTS (msg_view_zoom_action_entries), + 100, + G_CALLBACK (modest_ui_actions_on_change_zoom), + obj); + gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0); + g_object_unref (action_group); + + /* Load the UI definition */ + gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-view-window-ui.xml", + &error); + if (error) { + g_printerr ("modest: could not merge modest-msg-view-window-ui.xml: %s\n", error->message); + g_error_free (error); + error = NULL; + } + /* ****** */ + + /* Add accelerators */ + gtk_window_add_accel_group (GTK_WINDOW (obj), + gtk_ui_manager_get_accel_group (parent_priv->ui_manager)); + priv->is_search_result = FALSE; priv->msg_view = NULL; @@ -345,6 +395,19 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj) priv->purge_timeout = 0; priv->remove_attachment_banner = NULL; priv->msg_uid = NULL; + + /* Init window */ + init_window (MODEST_MSG_VIEW_WINDOW(obj)); + /* Set window icon */ + window_icon = modest_platform_get_icon (MODEST_APP_MSG_VIEW_ICON); + if (window_icon) { + gtk_window_set_icon (GTK_WINDOW (obj), window_icon); + g_object_unref (window_icon); + } + + + modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(), + GTK_WINDOW(obj),"applications_email_viewer"); } @@ -533,7 +596,6 @@ init_window (ModestMsgViewWindow *obj) g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_view_window_find_toolbar_close), obj); g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_view_window_find_toolbar_search), obj); - priv->clipboard_change_handler = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change", G_CALLBACK (modest_msg_view_window_clipboard_owner_change), obj); gtk_widget_show_all (GTK_WIDGET(main_vbox)); } @@ -698,9 +760,6 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, 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; obj = G_OBJECT (self); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj); @@ -708,49 +767,12 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, priv->msg_uid = g_strdup (msg_uid); - parent_priv->ui_manager = gtk_ui_manager_new(); parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new(); - action_group = gtk_action_group_new ("ModestMsgViewWindowActions"); - gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); - 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, - modest_action_entries, - G_N_ELEMENTS (modest_action_entries), - obj); - gtk_action_group_add_toggle_actions (action_group, - modest_toggle_action_entries, - G_N_ELEMENTS (modest_toggle_action_entries), - obj); - gtk_action_group_add_toggle_actions (action_group, - msg_view_toggle_action_entries, - G_N_ELEMENTS (msg_view_toggle_action_entries), - obj); - gtk_action_group_add_radio_actions (action_group, - msg_view_zoom_action_entries, - G_N_ELEMENTS (msg_view_zoom_action_entries), - 100, - G_CALLBACK (modest_ui_actions_on_change_zoom), - obj); - - gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0); - g_object_unref (action_group); - - /* Load the UI definition */ - gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-view-window-ui.xml", - &error); - if (error) { - g_printerr ("modest: could not merge modest-msg-view-window-ui.xml: %s\n", error->message); - g_error_free (error); - error = NULL; - } - /* ****** */ - /* Add common dimming rules */ modest_dimming_rules_group_add_rules (menu_rules_group, modest_msg_view_menu_dimming_entries, @@ -773,23 +795,11 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, g_object_unref (toolbar_rules_group); g_object_unref (clipboard_rules_group); - /* Add accelerators */ - gtk_window_add_accel_group (GTK_WINDOW (obj), - gtk_ui_manager_get_accel_group (parent_priv->ui_manager)); - - /* Init window */ - init_window (MODEST_MSG_VIEW_WINDOW(obj)); restore_settings (MODEST_MSG_VIEW_WINDOW(obj)); - /* Set window icon */ - window_icon = modest_platform_get_icon (MODEST_APP_MSG_VIEW_ICON); - if (window_icon) { - gtk_window_set_icon (GTK_WINDOW (obj), window_icon); - g_object_unref (window_icon); - } - /* g_signal_connect (G_OBJECT(obj), "delete-event", G_CALLBACK(on_delete_event), obj); */ + priv->clipboard_change_handler = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change", G_CALLBACK (modest_msg_view_window_clipboard_owner_change), obj); g_signal_connect (G_OBJECT(priv->msg_view), "activate_link", G_CALLBACK (modest_ui_actions_on_msg_link_clicked), obj); g_signal_connect (G_OBJECT(priv->msg_view), "link_hover", @@ -852,8 +862,10 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, TnyFolder *header_folder = NULL; ModestHeaderView *header_view = NULL; ModestWindow *main_window = NULL; - - window = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL); + ModestWindowMgr *mgr = NULL; + + mgr = modest_runtime_get_window_mgr (); + window = MODEST_MSG_VIEW_WINDOW (modest_window_mgr_get_msg_view_window (mgr)); g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL); modest_msg_view_window_construct (window, modest_account_name, msg_uid); @@ -863,8 +875,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, /* Remember the message list's TreeModel so we can detect changes * and change the list selection when necessary: */ - main_window = modest_window_mgr_get_main_window( - modest_runtime_get_window_mgr(), FALSE); /* don't create */ + main_window = modest_window_mgr_get_main_window(mgr, FALSE); /* don't create */ if (!main_window) { g_warning ("%s: BUG: no main window", __FUNCTION__); return NULL; @@ -908,9 +919,9 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, MODEST_HEADER_VIEW_OBSERVER(window)); } - gtk_widget_show_all (GTK_WIDGET (window)); - tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); + update_window_title (MODEST_MSG_VIEW_WINDOW (window)); + gtk_widget_show_all (GTK_WIDGET (window)); modest_msg_view_window_update_priority (window); @@ -927,8 +938,10 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg, { ModestMsgViewWindow *window = NULL; ModestMsgViewWindowPrivate *priv = NULL; + ModestWindowMgr *mgr = NULL; - window = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL); + mgr = modest_runtime_get_window_mgr (); + window = MODEST_MSG_VIEW_WINDOW (modest_window_mgr_get_msg_view_window (mgr)); g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL); modest_msg_view_window_construct (window, modest_account_name, msg_uid); @@ -939,6 +952,7 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg, priv->is_search_result = TRUE; tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); + update_window_title (window); return MODEST_WINDOW(window); } @@ -949,15 +963,18 @@ modest_msg_view_window_new_for_attachment (TnyMsg *msg, const gchar *msg_uid) { GObject *obj = NULL; - ModestMsgViewWindowPrivate *priv; + ModestMsgViewWindowPrivate *priv; + ModestWindowMgr *mgr = NULL; + g_return_val_if_fail (msg, NULL); - - obj = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL); + mgr = modest_runtime_get_window_mgr (); + obj = G_OBJECT (modest_window_mgr_get_msg_view_window (mgr)); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj); modest_msg_view_window_construct (MODEST_MSG_VIEW_WINDOW (obj), modest_account_name, msg_uid); tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); + update_window_title (MODEST_MSG_VIEW_WINDOW (obj)); return MODEST_WINDOW(obj); } @@ -1092,10 +1109,9 @@ void modest_msg_view_window_update_model_replaced( * not care about it's model (msg list). Else if the * header-view shows the folder the msg shown by us is in, we * shall replace our model reference and make some check. */ - if(tny_folder_id == NULL || - !g_str_equal(tny_folder_id, priv->header_folder_id)) + if(tny_folder_id == NULL || !g_str_equal(tny_folder_id, priv->header_folder_id)) return; - + /* Model is changed(replaced), so we should forget the old * one. Because there might be other references and there * might be some change on the model even if we unreferenced @@ -1129,9 +1145,6 @@ void modest_msg_view_window_update_model_replaced( modest_ui_actions_check_toolbar_dimming_rules(MODEST_WINDOW(window)); - if(tny_folder_id == NULL) - return; - g_assert(model != NULL); /* Also we must connect to the new model for row insertions. @@ -1203,15 +1216,12 @@ modest_msg_view_window_get_header (ModestMsgViewWindow *self) TnyMsg* modest_msg_view_window_get_message (ModestMsgViewWindow *self) { - ModestMsgView *msg_view; ModestMsgViewWindowPrivate *priv; - + g_return_val_if_fail (self, NULL); - + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(self); - - msg_view = MODEST_MSG_VIEW (priv->msg_view); - + return tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); } @@ -1773,7 +1783,9 @@ modest_msg_view_window_select_previous_message (ModestMsgViewWindow *window) static void view_msg_cb (ModestMailOperation *mail_op, TnyHeader *header, + gboolean canceled, TnyMsg *msg, + GError *error, gpointer user_data) { ModestMsgViewWindow *self = NULL; @@ -1801,7 +1813,7 @@ view_msg_cb (ModestMailOperation *mail_op, /* Mark header as read */ if (!(tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN)) - tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN); + tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN); /* Set new message */ tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); @@ -2337,7 +2349,7 @@ save_mime_part_to_file (SaveMimePartInfo *info) TnyStream *stream; SaveMimePartPair *pair = (SaveMimePartPair *) info->pairs->data; - result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0777); + result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0444); if (result == GNOME_VFS_OK) { stream = tny_vfs_stream_new (handle); tny_mime_part_decode_to_stream (pair->part, stream); @@ -2505,6 +2517,9 @@ show_remove_attachment_information (gpointer userdata) ModestMsgViewWindow *window = (ModestMsgViewWindow *) userdata; ModestMsgViewWindowPrivate *priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); + /* We're outside the main lock */ + gdk_threads_enter (); + if (priv->remove_attachment_banner != NULL) { gtk_widget_destroy (priv->remove_attachment_banner); g_object_unref (priv->remove_attachment_banner); @@ -2513,6 +2528,8 @@ show_remove_attachment_information (gpointer userdata) priv->remove_attachment_banner = g_object_ref ( hildon_banner_show_animation (NULL, NULL, _("mcen_ib_removing_attachment"))); + gdk_threads_leave (); + return FALSE; } @@ -2620,8 +2637,9 @@ update_window_title (ModestMsgViewWindow *window) TnyMsg *msg = NULL; TnyHeader *header = NULL; const gchar *subject = NULL; - + msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); + if (msg != NULL) { header = tny_msg_get_header (msg); subject = tny_header_get_subject (header); @@ -2634,6 +2652,7 @@ update_window_title (ModestMsgViewWindow *window) gtk_window_set_title (GTK_WINDOW (window), subject); } + static void on_move_focus (ModestMsgViewWindow *window, GtkDirectionType direction, gpointer userdata)