guint closing_time;
GSList *modal_handler_uids;
+ GtkWidget *cached_view;
+ GtkWidget *cached_editor;
+ guint idle_load_view_id;
+ guint idle_load_editor_id;
};
#define MODEST_WINDOW_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_WINDOW_MGR, \
G_TYPE_NONE, 0);
}
+static gboolean
+idle_load_view (ModestWindowMgr *mgr)
+{
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (mgr);
+
+ priv->cached_view = g_object_new (MODEST_TYPE_MSG_VIEW_WINDOW, NULL);
+ priv->idle_load_view_id = 0;
+ return FALSE;
+}
+
+static gboolean
+idle_load_editor (ModestWindowMgr *mgr)
+{
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (mgr);
+
+ priv->cached_editor = g_object_new (MODEST_TYPE_MSG_EDIT_WINDOW, NULL);
+ priv->idle_load_editor_id = 0;
+ return FALSE;
+}
+
+static void
+load_new_view (ModestWindowMgr *self)
+{
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+ if ((priv->cached_view == NULL) && (priv->idle_load_view_id == 0))
+ priv->idle_load_view_id = g_idle_add ((GSourceFunc) idle_load_view, self);
+}
+
+static void
+load_new_editor (ModestWindowMgr *self)
+{
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+ if ((priv->cached_editor == NULL) && (priv->idle_load_editor_id == 0))
+ priv->idle_load_editor_id = g_idle_add ((GSourceFunc) idle_load_editor, self);
+}
+
static void
modest_window_mgr_init (ModestWindowMgr *obj)
{
priv->closing_time = 0;
priv->modal_handler_uids = NULL;
+ priv->cached_view = NULL;
+ priv->cached_editor = NULL;
}
static void
{
ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE(obj);
+ if (priv->idle_load_view_id > 0) {
+ g_source_remove (priv->idle_load_view_id);
+ priv->idle_load_view_id = 0;
+ }
+
+ if (priv->idle_load_editor_id > 0) {
+ g_source_remove (priv->idle_load_editor_id);
+ priv->idle_load_editor_id = 0;
+ }
+
+ if (priv->cached_view) {
+ gtk_widget_destroy (priv->cached_view);
+ priv->cached_view = NULL;
+ }
+ if (priv->cached_editor) {
+ gtk_widget_destroy (priv->cached_editor);
+ priv->cached_editor = NULL;
+ }
+
if (priv->window_list) {
GList *iter = priv->window_list;
/* unregister pending windows */
return;
} else {
priv->main_window = window;
+ load_new_view (self);
+ load_new_editor (self);
}
}
return num_windows;
}
+
+GtkWidget *
+modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self)
+{
+ GtkWidget *result;
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE(self);
+
+ if (priv->cached_editor) {
+ result = priv->cached_editor;
+ priv->cached_editor = NULL;
+ load_new_editor (self);
+ } else {
+ result = g_object_new (MODEST_TYPE_MSG_EDIT_WINDOW, NULL);
+ }
+
+ return result;
+}
+
+GtkWidget *
+modest_window_mgr_get_msg_view_window (ModestWindowMgr *self)
+{
+ GtkWidget *result;
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE(self);
+
+ if (priv->cached_view) {
+ result = priv->cached_view;
+ priv->cached_view = NULL;
+ load_new_view (self);
+ } else {
+ result = g_object_new (MODEST_TYPE_MSG_VIEW_WINDOW, NULL);
+ }
+
+ return result;
+}