* Fixes NB#85924, fixes a crash when changing SMTP settings while sending messags
[modest] / src / maemo / modest-platform.c
index d2e97b4..400e273 100644 (file)
@@ -56,6 +56,7 @@
 #include <modest-account-settings-dialog.h>
 #include <easysetup/modest-easysetup-wizard-dialog.h>
 #include <hildon/hildon-sound.h>
+#include <osso-mem.h>
 
 #ifdef MODEST_HAVE_MCE
 #include <mce/dbus-names.h>
@@ -859,21 +860,22 @@ 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), 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);
-
-       /* Some locales like pt_BR need this to get the full window
-          title shown */
-       gtk_widget_set_size_request (GTK_WIDGET (dialog), 300, -1);
+       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)
@@ -1049,8 +1051,9 @@ modest_platform_run_information_dialog (GtkWindow *parent_window,
        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));
        
        if (block) {
                gtk_dialog_run (GTK_DIALOG (note));
@@ -1658,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);
@@ -1675,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);
 }
@@ -1688,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;
@@ -2216,7 +2232,7 @@ 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 ();
 
@@ -2257,3 +2273,27 @@ modest_platform_get_current_connection (void)
 #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;
+}