Migrated hildon2 to text-utils dgettext macros
[modest] / src / hildon2 / modest-platform.c
index 76df0ae..c0690cf 100644 (file)
@@ -42,6 +42,8 @@
 #include <libosso.h>
 #include <tny-maemo-conic-device.h>
 #include <tny-simple-list.h>
+#include <tny-merge-folder.h>
+#include <tny-error.h>
 #include <tny-folder.h>
 #include <tny-account-store-view.h>
 #include <gtk/gtkicontheme.h>
@@ -562,10 +564,18 @@ entry_insert_text (GtkEditable *editable,
                        g_free (msg);
                        g_free (tmp);
                } else {
+                       gint insert_length;
+
+                       insert_length = g_utf8_strlen (text, -1);
+
+                       if (insert_length + chars_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);
-                       gtk_editable_insert_text (editable, text, length, position);
+                       gtk_editable_insert_text (editable, text, MIN (chars_length + insert_length, 20), position);
                        g_signal_handlers_unblock_by_func (editable,
                                                           (gpointer) entry_insert_text, data);
                }
@@ -589,11 +599,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);
@@ -754,12 +764,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);
+               }
        }
 }
 
@@ -779,15 +825,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) {
@@ -2167,12 +2208,19 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window,
                                               gpointer user_data)
 {
        TnyAccount *account = NULL;
-       
-       if (!folder_store) {
+
+       if (!folder_store ||
+           (TNY_IS_MERGE_FOLDER (folder_store) &&
+            (tny_folder_get_folder_type (TNY_FOLDER(folder_store)) == TNY_FOLDER_TYPE_OUTBOX))) {
+
                /* We promise to instantly perform the callback, so ... */
                if (callback) {
-                       callback (FALSE, NULL, parent_window, NULL, user_data);
-               }
+                       GError *error = NULL;
+                       g_set_error (&error, TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_UNKNOWN,
+                                    "Unable to move or not found folder");
+                       callback (FALSE, error, parent_window, NULL, user_data);
+                       g_error_free (error);
+               }
                return;
 
        } else if (TNY_IS_FOLDER (folder_store)) {
@@ -2294,7 +2342,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)