X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-edit-window.c;h=106295cef3ca0b5d10faa2db708bef3fc7c2d614;hp=fad447096134965ecb05538e661c35358a39306e;hb=e032d937186b378e491002356de885230656ffc3;hpb=da353ac97b24b46e8c693610e1c719f0df23ae3e diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index fad4470..106295c 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -101,6 +101,7 @@ static void reset_modified (ModestMsgEditWindow *editor); static void text_buffer_refresh_attributes (WPTextBuffer *buffer, ModestMsgEditWindow *window); static void text_buffer_delete_range (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, gpointer userdata); static void text_buffer_can_undo (GtkTextBuffer *buffer, gboolean can_undo, ModestMsgEditWindow *window); +static void text_buffer_can_redo (GtkTextBuffer *buffer, gboolean can_redo, ModestMsgEditWindow *window); static void text_buffer_delete_images_by_id (GtkTextBuffer *buffer, const gchar * image_id); static void subject_field_changed (GtkEditable *editable, ModestMsgEditWindow *window); static void modest_msg_edit_window_color_button_change (ModestMsgEditWindow *window, @@ -449,6 +450,8 @@ init_window (ModestMsgEditWindow *obj) G_CALLBACK (text_buffer_delete_range), obj); g_signal_connect (G_OBJECT (priv->text_buffer), "can-undo", G_CALLBACK (text_buffer_can_undo), obj); + g_signal_connect (G_OBJECT (priv->text_buffer), "can-redo", + G_CALLBACK (text_buffer_can_redo), obj); g_signal_connect (G_OBJECT (obj), "window-state-event", G_CALLBACK (modest_msg_edit_window_window_state_event), NULL); @@ -671,6 +674,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg) update_dimmed (self); text_buffer_can_undo (priv->text_buffer, FALSE, self); + text_buffer_can_redo (priv->text_buffer, FALSE, self); priv->draft_msg = g_object_ref(msg); } @@ -1067,13 +1071,33 @@ modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) else data->html_body = NULL; - data->attachments = priv->attachments; /* TODO: copy and free ? */ + /* deep-copy the data */ + GList *cursor = priv->attachments; + data->attachments = NULL; + while (cursor) { + if (!(TNY_IS_MIME_PART(cursor->data))) { + g_warning ("strange data in attachment list"); + continue; + } + data->attachments = g_list_append (data->attachments, + g_object_ref (cursor->data)); + cursor = g_list_next (cursor); + } + data->priority_flags = priv->priority_flags; return data; } -/* TODO: We must duplicate this implementation for GNOME and Maemo, but that is unwise. */ + +static void +unref_gobject (GObject *obj, gpointer data) +{ + if (!G_IS_OBJECT(obj)) + return; + g_object_unref (obj); +} + void modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window, MsgData *data) @@ -1095,12 +1119,10 @@ modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window, g_object_unref (data->draft_msg); data->draft_msg = NULL; } - - g_list_foreach (data->attachments, (GFunc)g_free, NULL); + + g_list_foreach (data->attachments, (GFunc)unref_gobject, NULL); g_list_free (data->attachments); - /* TODO: Free data->attachments? */ - g_slice_free (MsgData, data); } @@ -2318,6 +2340,20 @@ modest_msg_edit_window_undo (ModestMsgEditWindow *window) } +void +modest_msg_edit_window_redo (ModestMsgEditWindow *window) +{ + ModestMsgEditWindowPrivate *priv; + + g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window)); + priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window); + + wp_text_buffer_redo (WP_TEXT_BUFFER (priv->text_buffer)); + + update_dimmed (window); + +} + static void update_dimmed (ModestMsgEditWindow *window) { @@ -2415,6 +2451,16 @@ text_buffer_can_undo (GtkTextBuffer *buffer, gboolean can_undo, ModestMsgEditWin gtk_action_set_sensitive (action, can_undo); } +static void +text_buffer_can_redo (GtkTextBuffer *buffer, gboolean can_redo, ModestMsgEditWindow *window) +{ + ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (window); + GtkAction *action; + + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/RedoMenu"); + gtk_action_set_sensitive (action, can_redo); +} + static void text_buffer_delete_images_by_id (GtkTextBuffer *buffer, const gchar * image_id) {