X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-view-window.c;h=45cc3f794f59bdf07f09923e415aec59641c677c;hb=58862afe7770c07e425d5f893f552d0342b82fbe;hp=762eb1016722e436b806c988b2915228664338ee;hpb=698950f863e43a6fcd5f9626ab978e750c16db2b;p=modest diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 762eb10..45cc3f7 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -67,8 +67,9 @@ static void modest_msg_view_window_find_toolbar_close (GtkWidget *widget, static void modest_msg_view_window_find_toolbar_search (GtkWidget *widget, ModestMsgViewWindow *obj); -static void modest_msg_view_window_set_zoom (ModestWindow *window, - gdouble zoom); +static void modest_msg_view_window_disconnect_signals (ModestWindow *self); +static void modest_msg_view_window_set_zoom (ModestWindow *window, + gdouble zoom); static gdouble modest_msg_view_window_get_zoom (ModestWindow *window); static gboolean modest_msg_view_window_zoom_minus (ModestWindow *window); static gboolean modest_msg_view_window_zoom_plus (ModestWindow *window); @@ -156,6 +157,10 @@ struct _ModestMsgViewWindowPrivate { /* Optimized view enabled */ gboolean optimized_view; + /* A reference to the @model of the header view + * to allow selecting previous/next messages, + * if the message is currently selected in the header view. + */ GtkTreeModel *header_model; GtkTreeRowReference *row_reference; GtkTreeRowReference *next_row_reference; @@ -235,6 +240,7 @@ modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass) modest_window_class->zoom_minus_func = modest_msg_view_window_zoom_minus; modest_window_class->zoom_plus_func = modest_msg_view_window_zoom_plus; modest_window_class->show_toolbar_func = modest_msg_view_window_show_toolbar; + modest_window_class->disconnect_signals_func = modest_msg_view_window_disconnect_signals; g_type_class_add_private (gobject_class, sizeof(ModestMsgViewWindowPrivate)); @@ -438,31 +444,42 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg) 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)); - -} - +} static void -modest_msg_view_window_finalize (GObject *obj) +modest_msg_view_window_disconnect_signals (ModestWindow *self) { ModestMsgViewWindowPrivate *priv; - priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj); - if (priv->clipboard_change_handler > 0) { + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); + + if (g_signal_handler_is_connected (gtk_clipboard_get (GDK_SELECTION_PRIMARY), + priv->clipboard_change_handler)) g_signal_handler_disconnect (gtk_clipboard_get (GDK_SELECTION_PRIMARY), priv->clipboard_change_handler); - priv->clipboard_change_handler = 0; - } - if (priv->queue_change_handler > 0) { + + if (g_signal_handler_is_connected (G_OBJECT (modest_runtime_get_mail_operation_queue ()), + priv->queue_change_handler)) g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), priv->queue_change_handler); - priv->queue_change_handler = 0; - } - if (priv->account_removed_handler > 0) { + + if (g_signal_handler_is_connected (G_OBJECT (modest_runtime_get_account_store ()), + priv->account_removed_handler)) g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_account_store ()), priv->account_removed_handler); - priv->account_removed_handler = 0; - } +} + +static void +modest_msg_view_window_finalize (GObject *obj) +{ + ModestMsgViewWindowPrivate *priv; + + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj); + + /* Sanity check: shouldn't be needed, the window mgr should + call this function before */ + modest_msg_view_window_disconnect_signals (MODEST_WINDOW (obj)); + if (priv->header_model != NULL) { g_object_unref (priv->header_model); priv->header_model = NULL; @@ -726,7 +743,9 @@ modest_msg_view_window_get_header (ModestMsgViewWindow *self) g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self), NULL); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); - /* Message is not obtained from a treemodel (Attachment ?) */ + /* If the message ws not obtained from a treemodel, + * for instance if it was opened directly by the search UI: + */ if (priv->header_model == NULL) { msg = modest_msg_view_window_get_message (self); header = tny_msg_get_header (msg); @@ -734,7 +753,11 @@ modest_msg_view_window_get_header (ModestMsgViewWindow *self) return header; } - /* Get current message iter */ + /* Get iter of the currently selected message in the header view: */ + /* TODO: Why not just give this window a ref of the TnyHeader or TnyMessage, + * instead of sometimes retrieving it from the header view? + * Then we wouldn't be dependent on the message actually still being selected + * in the header view. murrayc. */ path = gtk_tree_row_reference_get_path (priv->row_reference); g_return_val_if_fail (path != NULL, NULL); gtk_tree_model_get_iter (priv->header_model, @@ -1002,7 +1025,7 @@ modest_msg_view_window_last_message_selected (ModestMsgViewWindow *window) break; gtk_tree_model_get (priv->header_model, &tmp_iter, TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN, &header, -1); - if (!(tny_header_get_flags(header)&TNY_HEADER_FLAG_DELETED)) { + if (!(tny_header_get_flags(header) & TNY_HEADER_FLAG_DELETED)) { has_next = TRUE; break; } @@ -1745,7 +1768,6 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart if (tny_mime_part_is_purged (mime_part)) { g_object_unref (mime_part); - hildon_banner_show_information (NULL, NULL, _("mail_ib_attach_not_local")); return; } @@ -1955,7 +1977,7 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, GList *mim canceled = TRUE; } } else { - save_multiple_str = g_strdup_printf (_("FIXME: %d attachments"), + save_multiple_str = g_strdup_printf (_FM("sfil_va_number_of_objects_attachments"), g_list_length (mime_parts)); }