X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-platform.c;h=400e273729ae5b044311352b70067ac872ef33d4;hb=97e73afb9a2ed65af4802ff47739694224b95cec;hp=5abe6f34e3fd18daf27cb7b5a3f6913bb4fd1231;hpb=d9dc4e2f6f3fa6148212b17a37a4a555d9514fea;p=modest diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index 5abe6f3..400e273 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -54,8 +54,9 @@ #include #include #include -#include +#include #include +#include #ifdef MODEST_HAVE_MCE #include @@ -350,7 +351,7 @@ modest_platform_activate_file (const gchar *path, const gchar *mime_type) if (result != 1) result = hildon_mime_open_file (con, uri_path); if (result != 1) - modest_platform_run_information_dialog (NULL, _("mcen_ni_noregistered_viewer")); + modest_platform_run_information_dialog (NULL, _("mcen_ni_noregistered_viewer"), FALSE); return result != 1; } @@ -837,6 +838,9 @@ modest_platform_run_folder_name_dialog (GtkWindow *parent_window, 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_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))); gtk_entry_select_region (GTK_ENTRY (entry), 0, -1); /* Connect to the response method to avoid closing the dialog @@ -856,18 +860,23 @@ modest_platform_run_folder_name_dialog (GtkWindow *parent_window, G_CALLBACK (entry_changed), dialog); + + /* Some locales like pt_BR need this to get the full window + title shown */ + gtk_widget_set_size_request (GTK_WIDGET (dialog), 300, -1); + /* Create the hbox */ hbox = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); /* Add hbox to dialog */ gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent_window); - + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), + GTK_WINDOW (dialog)); + gtk_widget_show_all (GTK_WIDGET(dialog)); + result = gtk_dialog_run (GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) *folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); @@ -886,7 +895,7 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window, gchar *suggested_name, gchar **folder_name) { - gchar *real_suggested_name = NULL; + gchar *real_suggested_name = NULL, *tmp = NULL; gint result; if(suggested_name == NULL) @@ -922,12 +931,15 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window, real_suggested_name = suggested_name; } + tmp = g_strconcat (_("mcen_fi_new_folder_name"), ":", NULL); result = modest_platform_run_folder_name_dialog (parent_window, parent_folder, _("mcen_ti_new_folder"), - _("mcen_fi_new_folder_name"), + tmp, real_suggested_name, folder_name); + g_free (tmp); + if (suggested_name == NULL) g_free(real_suggested_name); @@ -1033,23 +1045,32 @@ modest_platform_run_yes_no_dialog (GtkWindow *parent_window, void modest_platform_run_information_dialog (GtkWindow *parent_window, - const gchar *message) + const gchar *message, + gboolean block) { GtkWidget *note; note = hildon_note_new_information (parent_window, message); - modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), - GTK_WINDOW (note)); + if (block) + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), + GTK_WINDOW (note)); - g_signal_connect_swapped (note, - "response", - G_CALLBACK (on_destroy_dialog), - note); - - gtk_widget_show_all (note); -} + if (block) { + gtk_dialog_run (GTK_DIALOG (note)); + + on_destroy_dialog (GTK_DIALOG (note)); + while (gtk_events_pending ()) + gtk_main_iteration (); + } else { + g_signal_connect_swapped (note, + "response", + G_CALLBACK (on_destroy_dialog), + note); + gtk_widget_show_all (note); + } +} typedef struct _ConnectAndWaitData { GMutex *mutex; @@ -1421,21 +1442,26 @@ modest_platform_on_new_headers_received (TnyList *header_list, TnyFolder *folder = tny_header_get_folder (header); gboolean first_notification = TRUE; gint notif_id; + gchar *str; /* constant string, don't free */ display_date = modest_text_utils_get_display_date (tny_header_get_date_received (header)); - display_address = g_strdup(tny_header_get_from (header)); + display_address = tny_header_dup_from (header); modest_text_utils_get_display_address (display_address); /* string is changed in-place */ summary = g_strdup_printf ("%s - %s", display_date, display_address); + str = tny_header_dup_subject (header); notification = hildon_notification_new (summary, - tny_header_get_subject (header), + str, "qgn_list_messagin", "email.arrive"); + g_free (str); /* Create the message URL */ + str = tny_header_dup_uid (header); url = g_strdup_printf ("%s/%s", tny_folder_get_url_string (folder), - tny_header_get_uid (header)); + str); + g_free (str); hildon_notification_add_dbus_action(notification, "default", @@ -1635,9 +1661,11 @@ modest_platform_information_banner (GtkWidget *parent, const gchar *text) { GtkWidget *banner; - ModestWindowMgr *mgr; + ModestWindowMgr *mgr = modest_runtime_get_window_mgr (); + + if (modest_window_mgr_num_windows (mgr) == 0) + return; - mgr = modest_runtime_get_window_mgr (); banner = hildon_banner_show_information (parent, icon_name, text); modest_window_mgr_register_banner (mgr); @@ -1652,6 +1680,10 @@ modest_platform_information_banner_with_timeout (GtkWidget *parent, gint timeout) { GtkWidget *banner; + + if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0) + return; + banner = hildon_banner_show_information (parent, icon_name, text); hildon_banner_set_timeout(HILDON_BANNER(banner), timeout); } @@ -1665,6 +1697,13 @@ modest_platform_animation_banner (GtkWidget *parent, g_return_val_if_fail (text != NULL, NULL); + if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0) + return NULL; + + /* If the parent is not visible then do not show */ + if (parent && !GTK_WIDGET_VISIBLE (parent)) + return NULL; + inf_note = hildon_banner_show_animation (parent, animation_name, text); return inf_note; @@ -1824,6 +1863,10 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name, gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"), server_name); + /* We use GTK_RESPONSE_APPLY because we want the button in the + middle of OK and CANCEL the same as the browser does for + example. With GTK_RESPONSE_HELP the view button is aligned + to the left while the other two to the right */ note = hildon_note_new_confirmation_add_buttons ( GTK_WINDOW(main_win), question, @@ -1879,7 +1922,7 @@ modest_platform_run_alert_dialog (const gchar* prompt, } else { /* Just show the error text and use the default response: */ modest_platform_run_information_dialog (GTK_WINDOW (main_win), - prompt); + prompt, FALSE); } return retval; } @@ -2117,32 +2160,28 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window, } else if (TNY_IS_FOLDER (folder_store)) { /* Get the folder's parent account: */ - account = tny_folder_get_account(TNY_FOLDER (folder_store)); + account = tny_folder_get_account (TNY_FOLDER (folder_store)); } else if (TNY_IS_ACCOUNT (folder_store)) { /* Use the folder store as an account: */ - account = TNY_ACCOUNT (folder_store); + account = TNY_ACCOUNT (g_object_ref (folder_store)); } if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) { if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) && !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) { - - /* This IS a local account like a maildir account, which does not require - * a connection. (original comment had a vague assumption in its language - * usage. There's no assuming needed, this IS what it IS: a local account), */ - /* We promise to instantly perform the callback, so ... */ - if (callback) { + /* No need to connect a local account */ + if (callback) callback (FALSE, NULL, parent_window, account, user_data); - } - - return; + + goto clean; } } + modest_platform_connect_and_perform (parent_window, force, account, callback, user_data); - modest_platform_connect_and_perform (parent_window, force, account, callback, user_data); - - return; + clean: + if (account) + g_object_unref (account); } static void @@ -2193,9 +2232,68 @@ modest_platform_get_account_settings_dialog (ModestAccountSettings *settings) } GtkWidget * -modest_platform_get_account_settings_wizard () +modest_platform_get_account_settings_wizard (void) { ModestEasysetupWizardDialog *dialog = modest_easysetup_wizard_dialog_new (); return GTK_WIDGET (dialog); } + +ModestConnectedVia +modest_platform_get_current_connection (void) +{ + TnyDevice *device = NULL; + ModestConnectedVia retval = MODEST_CONNECTED_VIA_ANY; + + device = modest_runtime_get_device (); + + if (!tny_device_is_online (device)) + return MODEST_CONNECTED_VIA_ANY; + +#ifdef MODEST_HAVE_CONIC + /* Get iap id */ + const gchar *iap_id = tny_maemo_conic_device_get_current_iap_id (TNY_MAEMO_CONIC_DEVICE (device)); + if (iap_id) { + ConIcIap *iap = tny_maemo_conic_device_get_iap ( + TNY_MAEMO_CONIC_DEVICE (device), iap_id); + const gchar *bearer_type = con_ic_iap_get_bearer_type (iap); + if (bearer_type) { + if (!strcmp (bearer_type, CON_IC_BEARER_WLAN_INFRA) || + !strcmp (bearer_type, CON_IC_BEARER_WLAN_ADHOC) || + !strcmp (bearer_type, "WIMAX")) { + retval = MODEST_CONNECTED_VIA_WLAN_OR_WIMAX; + } else { + retval = MODEST_CONNECTED_VIA_ANY; + } + } + g_object_unref (iap); + } +#else + retval = MODEST_CONNECTED_VIA_WLAN_OR_WIMAX; /* assume WLAN (fast) internet */ +#endif /* MODEST_HAVE_CONIC */ + return retval; +} + + + +gboolean +modest_platform_check_memory_low (ModestWindow *win, + gboolean visuals) +{ + gboolean lowmem; + + /* are we in low memory state? */ + lowmem = osso_mem_in_lowmem_state () ? TRUE : FALSE; + + if (win && lowmem && visuals) + modest_platform_run_information_dialog ( + GTK_WINDOW(win), + dgettext("ke-recv","memr_ib_operation_disabled"), + TRUE); + + if (lowmem) + g_debug ("%s: low memory reached. disallowing some operations", + __FUNCTION__); + + return lowmem; +}