* Fixes NB#99998, backup email settings along with email messages
[modest] / src / hildon2 / modest-platform.c
index 3ed719f..6483091 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <config.h>
 #include <glib/gi18n.h>
+
 #include <modest-platform.h>
 #include <modest-runtime.h>
 #include <modest-main-window.h>
@@ -57,7 +58,7 @@
 #include <modest-account-settings-dialog.h>
 #include <modest-easysetup-wizard-dialog.h>
 #include "modest-hildon2-sort-dialog.h"
-#include <hildon/hildon-sound.h>
+#include <hildon/hildon.h>
 #include <osso-mem.h>
 #include "hildon2/modest-hildon2-details-dialog.h"
 #include "hildon2/modest-hildon2-window-mgr.h"
@@ -564,6 +565,10 @@ entry_insert_text (GtkEditable *editable,
                        g_free (msg);
                        g_free (tmp);
                } else {
+                       if (length >= 20) {
+                               hildon_banner_show_information  (gtk_widget_get_parent (GTK_WIDGET (data)), NULL,
+                                                                _CS("ckdg_ib_maximum_characters_reached"));
+                       }
                        /* Write the text in the entry if it's valid */
                        g_signal_handlers_block_by_func (editable,
                                                         (gpointer) entry_insert_text, data);
@@ -591,11 +596,11 @@ entry_changed (GtkEditable *editable,
        g_return_if_fail (chars != NULL);
 
 
-       if (g_utf8_strlen (chars,-1) >= 20)
+       if (g_utf8_strlen (chars,-1) >= 20) {
                hildon_banner_show_information  (gtk_widget_get_parent (GTK_WIDGET (user_data)), NULL,
                                                 _CS("ckdg_ib_maximum_characters_reached"));
-       else
-               gtk_widget_set_sensitive (ok_button, modest_text_utils_validate_folder_name(chars));
+       }
+       gtk_widget_set_sensitive (ok_button, modest_text_utils_validate_folder_name(chars));
 
        /* Free */
        g_list_free (buttons);
@@ -756,12 +761,48 @@ folder_picker_set_store (GtkButton *button, TnyFolderStore *store)
        if (store == NULL) {
                g_object_set_data (G_OBJECT (button), FOLDER_PICKER_CURRENT_FOLDER, NULL);
        } else {
+               GdkPixbuf *pixbuf;
+               const gchar *icon_name = NULL;
+
                g_object_ref (store);
                g_object_set_data_full (G_OBJECT (button), FOLDER_PICKER_CURRENT_FOLDER, 
                                        store, (GDestroyNotify) g_object_unref);
                name = folder_store_get_display_name (store);
                hildon_button_set_value (HILDON_BUTTON (button), name);
                g_free (name);
+
+               /* Select icon */
+               if (TNY_IS_ACCOUNT (store)) {
+                       if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (store)))
+                           icon_name = MODEST_FOLDER_ICON_LOCAL_FOLDERS;
+                       else if (modest_tny_account_is_memory_card_account (TNY_ACCOUNT (store)))
+                               icon_name = MODEST_FOLDER_ICON_MMC;
+                       else
+                               icon_name = MODEST_FOLDER_ICON_ACCOUNT;
+               } else {
+                       if (modest_tny_folder_is_remote_folder (TNY_FOLDER (store))) {
+                               TnyFolderType type = modest_tny_folder_guess_folder_type (TNY_FOLDER (store));
+                               switch (type) {
+                               case TNY_FOLDER_TYPE_INBOX:
+                                       icon_name = MODEST_FOLDER_ICON_INBOX;
+                                       break;
+                               default:
+                                       icon_name = MODEST_FOLDER_ICON_ACCOUNT;
+                               }
+                       } else if (modest_tny_folder_is_local_folder (TNY_FOLDER (store)))
+                               icon_name = MODEST_FOLDER_ICON_NORMAL;
+                       else if (modest_tny_folder_is_memory_card_folder (TNY_FOLDER (store)))
+                               icon_name = MODEST_FOLDER_ICON_MMC_FOLDER;
+               }
+
+               /* Set icon */
+               pixbuf = modest_platform_get_icon (icon_name, MODEST_ICON_SIZE_SMALL);
+
+               if (pixbuf) {
+                       hildon_button_set_image (HILDON_BUTTON (button),
+                                                gtk_image_new_from_pixbuf (pixbuf));
+                       g_object_unref (pixbuf);
+               }
        }
 }
 
@@ -781,15 +822,10 @@ static GtkWidget *
 folder_picker_new (ModestFolderView *folder_view, TnyFolderStore *suggested)
 {
        GtkWidget *button;
-       GdkPixbuf *pixbuf;
 
        button = hildon_button_new (MODEST_EDITABLE_SIZE,
                                    HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
-       pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_NORMAL,
-                                          MODEST_ICON_SIZE_SMALL);
 
-       hildon_button_set_image (HILDON_BUTTON (button), 
-                                gtk_image_new_from_pixbuf (pixbuf));
        hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 1.0);
 
        if (suggested) {
@@ -854,10 +890,10 @@ modest_platform_run_folder_common_dialog (GtkWindow *parent_window,
                if (suggested_name)
                        gtk_entry_set_text (GTK_ENTRY (entry), suggested_name);
                else
-                       gtk_entry_set_text (GTK_ENTRY (entry), _("mcen_ia_default_folder_name"));
+                       gtk_entry_set_text (GTK_ENTRY (entry), _CS("ckdg_va_new_folder_name_stub"));
                gtk_entry_set_width_chars (GTK_ENTRY (entry),
                                           MAX (g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (entry)), -1),
-                                               g_utf8_strlen (_("mcen_ia_default_folder_name"), -1)));
+                                               g_utf8_strlen (_CS("ckdg_va_new_folder_name_stub"), -1)));
                gtk_entry_select_region (GTK_ENTRY (entry), 0, -1);
        }
 
@@ -956,20 +992,18 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
 
        if(suggested_name == NULL)
        {
-               const gchar *default_name = _("mcen_ia_default_folder_name");
+               const gchar *default_name = _CS("ckdg_va_new_folder_name_stub");
                unsigned int i;
-               gchar num_str[3];
 
                for(i = 0; i < 100; ++ i) {
                        gboolean exists = FALSE;
 
-                       sprintf(num_str, "%.2u", i);
-
                        if (i == 0)
                                real_suggested_name = g_strdup (default_name);
                        else
-                               real_suggested_name = g_strdup_printf (_("mcen_ia_default_folder_name_s"),
-                                                                      num_str);
+                               real_suggested_name = g_strdup_printf ("%s(%d)",
+                                                                      _CS("ckdg_va_new_folder_name_stub"),
+                                                                      i);
                        exists = modest_tny_folder_has_subfolder_with_name (suggested_folder,
                                                                            real_suggested_name,
                                                                            TRUE);
@@ -1003,10 +1037,10 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
                suggested_folder = (TnyFolderStore *)
                        modest_tny_account_store_get_local_folders_account (acc_store);
 
-       tmp = g_strconcat (_("mcen_fi_new_folder_name"), ":", NULL);
+       tmp = g_strconcat (_CS("ckdg_fi_new_folder_name"), ":", NULL);
        result = modest_platform_run_folder_common_dialog (parent_window, 
                                                           suggested_folder,
-                                                          _("mcen_ti_new_folder"),
+                                                          _CS("ckdg_fi_new_folder_name"),
                                                           tmp,
                                                           real_suggested_name,
                                                           TRUE,
@@ -1440,28 +1474,19 @@ modest_platform_on_new_headers_received (TnyList *header_list,
 
        iter = tny_list_create_iterator (header_list);
        while (!tny_iterator_is_done (iter)) {
-               gchar *url = NULL, *display_address = NULL,  *summary = NULL;
-               const gchar *display_date;
+               gchar *url = NULL, *display_address = NULL;
                TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
                TnyFolder *folder = tny_header_get_folder (header);
                gboolean first_notification = TRUE;
                gint notif_id;
                gchar *str;
-               ModestDatetimeFormatter *datetime_formatter;
-
-               /* constant string, don't free */
-               datetime_formatter = modest_datetime_formatter_new ();
-               display_date = modest_datetime_formatter_display_datetime (datetime_formatter,
-                                                                          tny_header_get_date_received (header));
-               g_object_unref (datetime_formatter);
 
                display_address = tny_header_dup_from (header);
                /* string is changed in-place */
                modest_text_utils_get_display_address (display_address);
 
-               summary = g_strdup_printf ("%s - %s", display_date, display_address);
                str = tny_header_dup_subject (header);
-               notification = hildon_notification_new (summary,
+               notification = hildon_notification_new (display_address,
                                                        str,
                                                        "qgn_list_messagin",
                                                        "email-message");
@@ -1526,7 +1551,6 @@ modest_platform_on_new_headers_received (TnyList *header_list,
        
                /* Free & carry on */
                g_free (display_address);
-               g_free (summary);
                g_free (url);
                g_object_unref (folder);
                g_object_unref (header);
@@ -2303,7 +2327,7 @@ modest_platform_check_memory_low (ModestWindow *win,
        if (win && lowmem && visuals)
                modest_platform_run_information_dialog (
                        GTK_WINDOW(win),
-                       dgettext("ke-recv","memr_ib_operation_disabled"),
+                       _KR("memr_ib_operation_disabled"),
                        TRUE);
 
        if (lowmem)
@@ -2425,7 +2449,7 @@ modest_platform_create_move_to_dialog (GtkWindow *parent_window,
                                              GTK_WINDOW (parent_window),
                                              GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR |
                                              GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             _("mcen_bd_new"), MODEST_GTK_RESPONSE_NEW_FOLDER,
+                                             _HL("wdgt_bd_new"), MODEST_GTK_RESPONSE_NEW_FOLDER,
                                              NULL);
 
        /* Create folder view */