* Fixes NB#90818, fixes a potential memory leak
[modest] / src / widgets / modest-window.c
index 2469941..cab203d 100644 (file)
@@ -33,6 +33,9 @@
 #include "modest-tny-platform-factory.h"
 #include "modest-runtime.h"
 #include "modest-window-mgr.h"
+#include "modest-defs.h"
+#include <string.h> /* for strcmp */
+#include <gdk/gdkkeysyms.h>
 
 /* 'private'/'protected' functions */
 static void modest_window_class_init (ModestWindowClass *klass);
@@ -85,8 +88,12 @@ modest_window_get_type (void)
                        (GInstanceInitFunc) modest_window_init,
                        NULL
                };
-#ifdef MODEST_PLATFORM_MAEMO
+#ifndef MODEST_TOOLKIT_GTK
+#ifdef MODEST_TOOLKIT_HILDON2
+               parent_type = HILDON_TYPE_STACKABLE_WINDOW;
+#else
                parent_type = HILDON_TYPE_WINDOW;
+#endif
 #else
                parent_type = GTK_TYPE_WINDOW;
 #endif 
@@ -154,6 +161,10 @@ modest_window_finalize (GObject *obj)
                g_object_unref (G_OBJECT(priv->ui_dimming_manager));
                priv->ui_dimming_manager = NULL;
        }
+       if (priv->dimming_state != NULL) {
+               g_slice_free (DimmedState, priv->dimming_state);
+               priv->dimming_state = NULL;
+       }
 
        g_free (priv->active_account);
        
@@ -166,17 +177,32 @@ const gchar*
 modest_window_get_active_account (ModestWindow *self)
 {
        g_return_val_if_fail (self, NULL);
-
+       //g_warning ("%s: %s", __FUNCTION__, MODEST_WINDOW_GET_PRIVATE(self)->active_account);
        return MODEST_WINDOW_GET_PRIVATE(self)->active_account;
 }
 
 void
 modest_window_set_active_account (ModestWindow *self, const gchar *active_account)
 {
-       ModestWindowPrivate *priv;      
+       ModestWindowPrivate *priv;
 
+       g_return_if_fail (self);        
        priv = MODEST_WINDOW_GET_PRIVATE(self);
 
+       //g_warning ("%s: %s", __FUNCTION__, active_account);
+       
+       /* only 'real' account should be set here; for example the email signature
+        * depends on the current account, so if you reply to a message in your
+        * archive, it should take the signature from the real active account,
+        * not the non-existing one from your mmc-pseudo-account
+        */
+       if (active_account && ((strcmp (active_account, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) == 0) ||
+                              (strcmp (active_account, MODEST_MMC_ACCOUNT_ID) == 0))) {
+                       g_warning ("%s: %s is not a valid active account",
+                                  __FUNCTION__, active_account);
+                       return;
+       }
+       
        if (active_account == priv->active_account)
                return;
        else {
@@ -407,7 +433,7 @@ on_key_pressed (GtkWidget *self,
        case GDK_Escape: 
                if (modest_window_mgr_get_fullscreen_mode (mgr))
                        modest_ui_actions_on_change_fullscreen (NULL, MODEST_WINDOW(self));
-               else if (MODEST_IS_MSG_VIEW_WINDOW (self)||MODEST_IS_MSG_EDIT_WINDOW (self))
+               else if (MODEST_IS_MSG_VIEW_WINDOW (self))
                        modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (self));
                break;
        }