* fix a memleak in the msg edit window
[modest] / src / maemo / modest-msg-edit-window.c
index 10f1572..32a4e17 100644 (file)
@@ -148,6 +148,11 @@ static gboolean gtk_text_iter_forward_search_insensitive (const GtkTextIter *ite
                                                          
 
 
+/* static gboolean */
+/* on_key_pressed (GtkWidget *self, */
+/*             GdkEventKey *event, */
+/*             gpointer user_data); */
+
 static void edit_menu_activated (GtkAction *action,
                                 gpointer userdata);
 static void view_menu_activated (GtkAction *action,
@@ -277,10 +282,11 @@ modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass)
        modest_window_class->zoom_plus_func = modest_msg_edit_window_zoom_plus;
        modest_window_class->zoom_minus_func = modest_msg_edit_window_zoom_minus;
        modest_window_class->show_toolbar_func = modest_msg_edit_window_show_toolbar;
+       modest_window_class->save_state_func = save_state;
 
        g_type_class_add_private (gobject_class, sizeof(ModestMsgEditWindowPrivate));
 
-       modest_window_class->save_state_func = save_state;
+
 }
 
 static void
@@ -434,6 +440,8 @@ init_window (ModestMsgEditWindow *obj)
        priv->find_toolbar = hildon_find_toolbar_new (NULL);
        gtk_widget_set_no_show_all (priv->find_toolbar, TRUE);
 
+/*     g_signal_connect (G_OBJECT (obj), "key_pressed", G_CALLBACK (on_key_pressed), NULL) */
+
        g_signal_connect (G_OBJECT (priv->text_buffer), "refresh_attributes",
                          G_CALLBACK (text_buffer_refresh_attributes), obj);
        g_signal_connect (G_OBJECT (priv->text_buffer), "delete-range",
@@ -1082,12 +1090,16 @@ modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window,
        g_free (data->subject);
        g_free (data->plain_body);
        g_free (data->html_body);
+       g_free (data->account_name);
+       
        if (data->draft_msg != NULL) {
                g_object_unref (data->draft_msg);
                data->draft_msg = NULL;
        }
-       g_free (data->account_name);
 
+       g_list_foreach (data->attachments, (GFunc)g_free, NULL);
+       g_list_free (data->attachments);
+       
        /* TODO: Free data->attachments? */
 
        g_slice_free (MsgData, data);
@@ -1197,7 +1209,7 @@ modest_msg_edit_window_set_format_state (ModestMsgEditWindow *self,
                wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FORECOLOR, (gpointer) (&(buffer_format->color)));
        }
        if (buffer_format->cs.font_size) {
-               wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_BOLD, (gpointer) (buffer_format->font_size));
+               wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FONT_SIZE, (gpointer) (buffer_format->font_size));
        }
        if (buffer_format->cs.justification) {
                switch (buffer_format->justification) {
@@ -1216,7 +1228,7 @@ modest_msg_edit_window_set_format_state (ModestMsgEditWindow *self,
                        
        }
        if (buffer_format->cs.font) {
-               wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_BOLD, (gpointer) (buffer_format->font));
+               wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FONT, (gpointer) (buffer_format->font));
        }
        if (buffer_format->cs.bullet) {
                wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_BULLET, (gpointer) ((int)buffer_format->bullet));
@@ -1772,7 +1784,7 @@ modest_msg_edit_window_size_change (GtkCheckMenuItem *menu_item,
                WPTextBufferFormat format;
 
                memset (&format, 0, sizeof (format));
-               wp_text_buffer_get_current_state (WP_TEXT_BUFFER (priv->text_buffer), &format);
+               wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), &format, FALSE);
 
                label = gtk_bin_get_child (GTK_BIN (menu_item));
                
@@ -1781,14 +1793,14 @@ modest_msg_edit_window_size_change (GtkCheckMenuItem *menu_item,
                format.cs.text_position = TRUE;
                format.cs.font = TRUE;
                format.font_size = wp_get_font_size_index (new_size_index, DEFAULT_FONT_SIZE);
-               wp_text_buffer_set_format (WP_TEXT_BUFFER (priv->text_buffer), &format);
+/*             wp_text_buffer_set_format (WP_TEXT_BUFFER (priv->text_buffer), &format); */
 
-/*             if (!wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FONT_SIZE, */
-/*                                                (gpointer) wp_get_font_size_index (new_size_index, 12))) */
-/*                     wp_text_view_reset_and_show_im (WP_TEXT_VIEW (priv->msg_body)); */
+               if (!wp_text_buffer_set_attribute (WP_TEXT_BUFFER (priv->text_buffer), WPT_FONT_SIZE,
+                                                  (gpointer) wp_get_font_size_index (new_size_index, 12)))
+                       wp_text_view_reset_and_show_im (WP_TEXT_VIEW (priv->msg_body));
                
                text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), MODEST_MSG_EDIT_WINDOW (window));
-               markup = g_strconcat ("<span font_family='Serif'>", gtk_label_get_text (GTK_LABEL (label)), "</span>", NULL);
+               markup = g_strconcat ("<span font_family='", DEFAULT_SIZE_BUTTON_FONT_FAMILY, "'>", gtk_label_get_text (GTK_LABEL (label)), "</span>", NULL);
                gtk_label_set_markup (GTK_LABEL (priv->size_tool_button_label), markup);
                g_free (markup);
        }
@@ -2522,7 +2534,8 @@ remove_attachment_insensitive_press (GtkWidget *widget, ModestMsgEditWindow *edi
                hildon_banner_show_information (NULL, NULL, _("mcen_ib_unable_to_display_more"));
        else if (n_att_selected == 0)
                hildon_banner_show_information (NULL, NULL, _("TODO: select one attachment"));
-               
+       else
+               hildon_banner_show_information (NULL, NULL, _("mail_ib_unable_to_purge_attachments"));
 }
 
 static void
@@ -2932,3 +2945,5 @@ modest_msg_edit_window_set_sent (ModestMsgEditWindow *window,
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(window);
        priv->sent = sent;
 }
+
+