X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-platform.c;h=c0690cf0903ed4bd8674dec0d472a69b4d165763;hp=2f5ea4cf606c88162e85361b20afb1bb44b5fb24;hb=83cfbd96aa351d1ffc91d409cacb26ad1ec7df2d;hpb=8d8805465992be7a76ca01994ae78fc3265c8a95 diff --git a/src/hildon2/modest-platform.c b/src/hildon2/modest-platform.c index 2f5ea4c..c0690cf 100644 --- a/src/hildon2/modest-platform.c +++ b/src/hildon2/modest-platform.c @@ -42,7 +42,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -92,6 +95,7 @@ #define COMMON_FOLDER_DIALOG_ENTRY "entry" #define COMMON_FOLDER_DIALOG_ACCOUNT_PICKER "account-picker" #define FOLDER_PICKER_CURRENT_FOLDER "current-folder" +#define MODEST_ALARMD_APPID PACKAGE_NAME static void _modest_platform_play_email_tone (void); @@ -461,7 +465,7 @@ modest_platform_show_uri_popup (const gchar *uri) GSList *node; popup_info->actions = actions_list; popup_info->uri = g_strdup (uri); - + for (node = actions_list; node != NULL; node = g_slist_next (node)) { GtkWidget *menu_item; const gchar *action_name; @@ -473,7 +477,7 @@ modest_platform_show_uri_popup (const gchar *uri) g_object_set_data (G_OBJECT(menu_item), HILDON_OSSO_URI_ACTION, (gpointer)action_name); /* hack */ g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (activate_uri_popup_item), popup_info); - + if (hildon_uri_is_default_action (action, NULL)) { gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item); } else { @@ -483,25 +487,15 @@ modest_platform_show_uri_popup (const gchar *uri) } } - /* always add the copy item */ - GtkWidget* menu_item = gtk_menu_item_new_with_label (dgettext("osso-uri", - "uri_link_copy_link_location")); - g_object_set_data_full (G_OBJECT(menu_item), HILDON_OSSO_URI_ACTION, - g_strconcat (URI_ACTION_COPY, uri, NULL), - g_free); - g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (activate_uri_popup_item),NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_show (menu_item); - /* and what to do when the link is deleted */ g_signal_connect (G_OBJECT (menu), "delete-event", G_CALLBACK (delete_uri_popup), popup_info); gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time ()); - + } else { hildon_banner_show_information (NULL, NULL, _("mcen_ib_unsupported_link")); } - + return TRUE; } @@ -520,7 +514,7 @@ modest_platform_get_icon (const gchar *name, guint icon_size) */ if (!name || strlen(name) == 0) return NULL; - + current_theme = gtk_icon_theme_get_default (); pixbuf = gtk_icon_theme_load_icon (current_theme, name, icon_size, GTK_ICON_LOOKUP_NO_SVG, @@ -570,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); } @@ -597,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); @@ -694,7 +696,8 @@ folder_chooser_dialog_run (ModestFolderView *original) modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_FILTER_CAN_HAVE_FOLDERS); - modest_folder_view_copy_model (MODEST_FOLDER_VIEW (original), MODEST_FOLDER_VIEW (folder_view)); + modest_folder_view_copy_model (MODEST_FOLDER_VIEW (original), + MODEST_FOLDER_VIEW (folder_view)); visible_id = modest_folder_view_get_account_id_of_visible_server_account (MODEST_FOLDER_VIEW(original)); @@ -761,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); + } } } @@ -786,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) { @@ -1324,7 +1358,7 @@ modest_platform_set_update_interval (guint minutes) /* Delete any existing alarm, * because we will replace it: */ if (alarm_cookie) { - if (alarmd_event_del(alarm_cookie) != 1) + if (alarmd_event_del(alarm_cookie) != 0) g_warning ("%s: alarm %d was not on the queue", __FUNCTION__, (int)alarm_cookie); alarm_cookie = 0; modest_conf_set_int (conf, MODEST_CONF_ALARM_ID, 0, NULL); @@ -1341,6 +1375,7 @@ modest_platform_set_update_interval (guint minutes) alarm_event_t *event = alarm_event_create (); alarm_event_add_actions (event, 1); alarm_action_t *action = alarm_event_get_action (event, 0); + alarm_event_set_alarm_appid (event, MODEST_ALARMD_APPID); event->alarm_time = minutes * 60; /* seconds */ /* Set recurrence every few minutes: */ @@ -1354,7 +1389,7 @@ modest_platform_set_update_interval (guint minutes) action->dbus_interface = g_strdup (MODEST_DBUS_IFACE); action->dbus_service = g_strdup (MODEST_DBUS_SERVICE); action->dbus_name = g_strdup (MODEST_DBUS_METHOD_SEND_RECEIVE); - action->flags = ALARM_ACTION_TYPE_DBUS | ALARM_ACTION_DBUS_USE_ACTIVATION; + action->flags = ALARM_ACTION_WHEN_TRIGGERED | ALARM_ACTION_TYPE_DBUS | ALARM_ACTION_DBUS_USE_ACTIVATION; /* Use ALARM_EVENT_NO_DIALOG: Otherwise, a dialog will be shown if * exec_name or dbus_path is NULL, even though we have specified no dialog text. @@ -2173,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)) { @@ -2300,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) @@ -2434,6 +2476,9 @@ modest_platform_create_move_to_dialog (GtkWindow *parent_window, G_CALLBACK (on_move_to_dialog_folder_activated), dialog); + tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (*folder_view), + (TnyAccountStore *) modest_runtime_get_account_store ()); + /* Create pannable and add it to the dialog */ folder_view_container = hildon_pannable_area_new (); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container);