Replaced GtkWindow by ModestWindow in several places and viceversa
[modest] / src / widgets / modest-msg-edit-window.c
index e63e44c..e69fda9 100644 (file)
@@ -71,7 +71,6 @@
 #include <libgnomevfs/gnome-vfs-mime.h>
 #include <modest-utils.h>
 #include <modest-ui-constants.h>
-#include "modest-color-button.h"
 #include <modest-toolkit-utils.h>
 
 #ifdef MODEST_USE_CALENDAR_WIDGETS
 #include <hildon/hildon.h>
 #include "modest-maemo-utils.h"
 #include "modest-hildon-includes.h"
+#include "modest-color-button.h"
 #endif
 
-#define DEFAULT_FONT_SIZE 3
-#define DEFAULT_FONT 2
-#define DEFAULT_SIZE_BUTTON_FONT_FAMILY "Sans"
 #define DEFAULT_MAIN_VBOX_SPACING 0
 #define SUBJECT_MAX_LENGTH 1000
 #define IMAGE_MAX_WIDTH 560
+#ifdef MODEST_TOOLKIT_HILDON2
+#define DEFAULT_SIZE_BUTTON_FONT_FAMILY "Sans"
 #define DEFAULT_FONT_SCALE 1.5
+#define DEFAULT_FONT_SIZE 3
+#define DEFAULT_FONT 2
+#else
+#define DEFAULT_SIZE_BUTTON_FONT_FAMILY "Sans"
+#define DEFAULT_FONT_SCALE 1.0
+#define DEFAULT_FONT_SIZE 2
+#define DEFAULT_FONT 2
+#endif
 #define ATTACHMENT_BUTTON_WIDTH 118
 #define MAX_FROM_VALUE 36
 #define MAX_BODY_LENGTH 128*1024
@@ -363,7 +370,7 @@ modest_msg_edit_window_get_type (void)
 #ifdef MODEST_TOOLKIT_HILDON2
                                                  MODEST_TYPE_HILDON2_WINDOW,
 #else
-                                                 MODEST_TYPE_WINDOW,
+                                                 MODEST_TYPE_SHELL_WINDOW,
 #endif
                                                  "ModestMsgEditWindow",
                                                  &my_info, 0);
@@ -892,10 +899,6 @@ init_window (ModestMsgEditWindow *obj)
                g_clear_error (&error);
        }
 
-       /* Add accelerators */
-       gtk_window_add_accel_group (GTK_WINDOW (obj), 
-                                   gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
-
        parent_priv->menubar = NULL;
 
        title_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
@@ -1275,7 +1278,9 @@ replace_with_images (ModestMsgEditWindow *self, TnyList *attachments)
                        if (pixbuf != NULL) {
                                priv->images_count ++;
                                priv->images_size += stream_size;
+#ifndef MODEST_HAVE_LIBWPEDITOR_PLUS
                                wp_text_buffer_replace_image (WP_TEXT_BUFFER (priv->text_buffer), cid, pixbuf);
+#endif
                                g_object_unref (pixbuf);
                        }
                }
@@ -2013,6 +2018,7 @@ modest_msg_edit_window_set_format (ModestMsgEditWindow *self,
        switch (format) {
        case MODEST_MSG_EDIT_FORMAT_HTML:
                wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), TRUE);
+               update_signature (self, priv->last_from_account, priv->last_from_account);
                if (parent_priv->toolbar) gtk_widget_show (parent_priv->toolbar);
                break;
        case MODEST_MSG_EDIT_FORMAT_TEXT:
@@ -2422,7 +2428,7 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window)
                        if (stream == NULL) {
 
                                modest_platform_information_banner (NULL, NULL, 
-                                                                   _FM("sfil_ib_opening_not_allowed"));
+                                                                   _FM_OPENING_NOT_ALLOWED);
                                g_free (filename);
                                g_object_unref (mime_part);
                                gnome_vfs_file_info_unref (info);
@@ -2644,7 +2650,7 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window,
                
                if (stream == NULL) {
 
-                       modest_platform_information_banner (NULL, NULL, _FM("sfil_ib_opening_not_allowed"));
+                       modest_platform_information_banner (NULL, NULL, _FM_OPENING_NOT_ALLOWED);
 
                        g_object_unref (mime_part);
                        g_free (filename);
@@ -3087,6 +3093,7 @@ modest_msg_edit_window_set_file_format (ModestMsgEditWindow *window,
                case MODEST_FILE_FORMAT_FORMATTED_TEXT:
                        wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), TRUE);
                        remove_tags (WP_TEXT_BUFFER (priv->text_buffer));
+                       update_signature (window, priv->last_from_account, priv->last_from_account);
                        if (parent_priv->toolbar)
                                gtk_widget_show (parent_priv->toolbar);
                        break;
@@ -3704,7 +3711,7 @@ body_insert_text (GtkTextBuffer *buffer,
                if (priv->max_chars_banner == NULL) {
 #ifdef MODEST_TOOLKIT_HILDON2
                        priv->max_chars_banner = hildon_banner_show_information (GTK_WIDGET (window), NULL, 
-                                                                                _CS("ckdg_ib_maximum_characters_reached"));
+                                                                                _CS_MAXIMUM_CHARACTERS_REACHED);
                        g_object_weak_ref (G_OBJECT (priv->max_chars_banner), (GWeakNotify) max_chars_banner_unref, window);
 #endif
                }
@@ -3764,7 +3771,7 @@ subject_field_insert_text (GtkEditable *editable,
 
        if (result_len + old_length > 1000) {
                modest_platform_system_banner (GTK_WIDGET (window), NULL, 
-                                               _CS("ckdg_ib_maximum_characters_reached"));
+                                               _CS_MAXIMUM_CHARACTERS_REACHED);
        }
        g_string_free (result, TRUE);
 }
@@ -3871,7 +3878,7 @@ modest_msg_edit_window_isearch_toolbar_search (GtkWidget *widget,
                g_free (priv->last_search);
                priv->last_search = NULL;
                /* Information banner about empty search */
-               modest_platform_system_banner (NULL, NULL, _CS("ecdg_ib_find_rep_enter_text"));
+               modest_platform_system_banner (NULL, NULL, _CS_FIND_REP_ENTER_TEXT);
                return;
        }
 
@@ -3887,14 +3894,14 @@ modest_msg_edit_window_isearch_toolbar_search (GtkWidget *widget,
                result = gtk_text_iter_forward_search_insensitive (&selection_end, current_search, 
                                                                   &match_start, &match_end);
                if (!result)
-                       modest_platform_system_banner (NULL, NULL, _HL("ckct_ib_find_search_complete"));
+                       modest_platform_system_banner (NULL, NULL, _HL_IB_FIND_COMPLETE);
        } else {
                GtkTextIter buffer_start;
                gtk_text_buffer_get_start_iter (priv->text_buffer, &buffer_start);
                result = gtk_text_iter_forward_search_insensitive (&buffer_start, current_search, 
                                                                   &match_start, &match_end);
                if (!result)
-                       modest_platform_system_banner (NULL, NULL, _HL("ckct_ib_find_no_matches"));
+                       modest_platform_system_banner (NULL, NULL, _HL_IB_FIND_NO_MATCHES);
        }
 
        /* Mark as selected the string found in search */
@@ -4113,12 +4120,29 @@ update_signature (ModestMsgEditWindow *self,
        priv->last_from_account = modest_selector_get_active_id (priv->from_field);
        signature = modest_account_mgr_get_signature_from_recipient (mgr, new_account, &has_new_signature);
        if (has_new_signature) {
+               gboolean is_rich;
 
                gchar *full_signature = g_strconcat ((gtk_text_iter_starts_line (&iter)) ? "" : "\n",
                                                     MODEST_TEXT_UTILS_SIGNATURE_MARKER, "\n",
                                                     signature, NULL);
-               gtk_text_buffer_insert (priv->text_buffer, &iter, full_signature, -1);
-               g_free (full_signature);
+               is_rich = wp_text_buffer_is_rich_text (WP_TEXT_BUFFER (priv->text_buffer));
+               if (is_rich) {
+                       WPTextBufferFormat *fmt;
+                       GdkColor style_color;
+                       if (!gtk_style_lookup_color (GTK_WIDGET (self)->style, "SecondaryTextColor", &style_color)) {
+                               gdk_color_parse ("grey", &style_color);
+                       }
+                       fmt = g_new0 (WPTextBufferFormat, 1);
+                       fmt->color = style_color;
+                       fmt->cs.color = 0x1;
+                       wp_text_buffer_insert_with_attribute (WP_TEXT_BUFFER (priv->text_buffer), &iter, 
+                                                             full_signature, -1,
+                                                             fmt, TRUE);
+                       g_free (fmt);
+                       g_free (full_signature);
+               } else {
+                       gtk_text_buffer_insert (priv->text_buffer, &iter, full_signature, -1);
+               }
        }
        g_free (signature);
        gtk_text_buffer_end_user_action (priv->text_buffer);
@@ -4196,6 +4220,7 @@ typedef struct _MessageSettingsHelper {
        GtkToggleButton *current_format;
 } MessageSettingsHelper;
 
+#ifdef MODEST_TOOLKIT_HILDON2
 static void
 on_priority_toggle (GtkToggleButton *button, 
                    MessageSettingsHelper *helper)
@@ -4264,6 +4289,7 @@ on_format_toggle (GtkToggleButton *button,
        }
 
 }
+#endif
 
 static void
 modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window)
@@ -4292,7 +4318,7 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window)
 
        dialog = gtk_dialog_new_with_buttons (_("mcen_me_message_settings"), NULL,
                                              GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             _HL("wdgt_bd_done"), GTK_RESPONSE_ACCEPT, NULL);
+                                             _HL_DONE, GTK_RESPONSE_ACCEPT, NULL);
        vbox = gtk_vbox_new (FALSE, 0);
        align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE, 0);
@@ -4415,6 +4441,7 @@ on_message_settings (GtkAction *action,
        modest_msg_edit_window_show_msg_settings_dialog (window);
 }
 
+#ifdef MODEST_TOOLKIT_HILDON2
 static void
 on_cc_button_toggled (GtkWidget *button,
                      ModestMsgEditWindow *window)
@@ -4434,8 +4461,9 @@ on_bcc_button_toggled (GtkWidget *button,
        modest_msg_edit_window_show_bcc (MODEST_MSG_EDIT_WINDOW (window),
                                        modest_togglable_get_active (button));
 }
+#endif
 
-static void 
+static void
 setup_menu (ModestMsgEditWindow *self)
 {
        ModestMsgEditWindowPrivate *priv = NULL;