* don't set the window icon explicitly; maemo seems to
[modest] / src / maemo / modest-msg-edit-window.c
index 1365ded..9599e6c 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",
@@ -530,6 +538,11 @@ modest_msg_edit_window_finalize (GObject *obj)
                priv->system_clipboard_change_handler_id = 0;
        }
        
+       if (priv->draft_msg != NULL) {
+               g_object_unref (priv->draft_msg);
+               priv->draft_msg = NULL;
+       }
+
        /* This had to stay alive for as long as the combobox that used it: */
        modest_pair_list_free (priv->from_field_protos);
        
@@ -658,7 +671,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg)
        update_dimmed (self);
        text_buffer_can_undo (priv->text_buffer, FALSE, self);
 
-       priv->draft_msg = msg;
+       priv->draft_msg = g_object_ref(msg);
 }
 
 static void
@@ -928,8 +941,6 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name)
 
        restore_settings (MODEST_MSG_EDIT_WINDOW(obj));
                
-       gtk_window_set_icon_from_file (GTK_WINDOW(obj), MODEST_APP_ICON, NULL);
-
        modest_window_set_active_account (MODEST_WINDOW(obj), account_name);
 
        modest_msg_edit_window_setup_toolbar (MODEST_MSG_EDIT_WINDOW (obj));
@@ -1077,12 +1088,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);
@@ -1192,7 +1207,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) {
@@ -1211,7 +1226,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));
@@ -1611,7 +1626,7 @@ modest_msg_edit_window_attach_file_noninteractive (
        
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
 
-       if (file_uri) {
+       if (file_uri && strlen(file_uri)) {
                gint file_id = 0;
                
                /* TODO: We should probably try to use only the URI,
@@ -1619,7 +1634,7 @@ modest_msg_edit_window_attach_file_noninteractive (
                 */
                gchar* filename = g_filename_from_uri (file_uri, NULL, NULL);
                if (!filename) {
-                       g_warning("%s: g_filename_from_uri(%s) failed.\n", __FUNCTION__, file_uri);
+                       g_warning("%s: g_filename_from_uri('%s') failed.\n", __FUNCTION__, file_uri);
                }
 
                file_id = g_open (filename, O_RDONLY, 0);
@@ -1767,7 +1782,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));
                
@@ -1776,14 +1791,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);
        }
@@ -2517,7 +2532,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
@@ -2927,3 +2943,5 @@ modest_msg_edit_window_set_sent (ModestMsgEditWindow *window,
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(window);
        priv->sent = sent;
 }
+
+