X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-hildon1-window-mgr.c;h=629b7c8c237ea399b2be94ebfeb11d024d0786d0;hb=c847ef9527fe562b850a4f9c0988d0949fe75c72;hp=c7bcac230686015511991ebbc0948325c1b04eaf;hpb=cc379b2109f5c1b1a70419454d1a0e53c26559e6;p=modest diff --git a/src/widgets/modest-hildon1-window-mgr.c b/src/widgets/modest-hildon1-window-mgr.c index c7bcac2..629b7c8 100644 --- a/src/widgets/modest-hildon1-window-mgr.c +++ b/src/widgets/modest-hildon1-window-mgr.c @@ -83,7 +83,13 @@ static void modest_hildon1_window_mgr_set_modal (ModestWindowMgr *self, static gboolean modest_hildon1_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header, ModestWindow **win); +static gboolean modest_hildon1_window_mgr_find_registered_message_uid (ModestWindowMgr *self, + const gchar *msg_uid, + ModestWindow **win); static GList *modest_hildon1_window_mgr_get_window_list (ModestWindowMgr *self); +static gboolean modest_hildon1_window_mgr_close_all_windows (ModestWindowMgr *self); +static ModestWindow *modest_hildon1_window_mgr_get_current_top (ModestWindowMgr *self); +static gboolean modest_hildon1_window_mgr_screen_is_on (ModestWindowMgr *self); typedef struct _ModestHildon1WindowMgrPrivate ModestHildon1WindowMgrPrivate; struct _ModestHildon1WindowMgrPrivate { @@ -152,7 +158,11 @@ modest_hildon1_window_mgr_class_init (ModestHildon1WindowMgrClass *klass) mgr_class->get_modal = modest_hildon1_window_mgr_get_modal; mgr_class->set_modal = modest_hildon1_window_mgr_set_modal; mgr_class->find_registered_header = modest_hildon1_window_mgr_find_registered_header; + mgr_class->find_registered_message_uid = modest_hildon1_window_mgr_find_registered_message_uid; mgr_class->get_window_list = modest_hildon1_window_mgr_get_window_list; + mgr_class->close_all_windows = modest_hildon1_window_mgr_close_all_windows; + mgr_class->get_current_top = modest_hildon1_window_mgr_get_current_top; + mgr_class->screen_is_on = modest_hildon1_window_mgr_screen_is_on; g_type_class_add_private (gobject_class, sizeof(ModestHildon1WindowMgrPrivate)); @@ -237,14 +247,14 @@ modest_hildon1_window_mgr_new (void) return MODEST_WINDOW_MGR(g_object_new(MODEST_TYPE_HILDON1_WINDOW_MGR, NULL)); } -void +static gboolean modest_hildon1_window_mgr_close_all_windows (ModestWindowMgr *self) { ModestHildon1WindowMgrPrivate *priv = NULL; gboolean ret_value = FALSE; ModestWindow *main_window; - g_return_if_fail (MODEST_IS_HILDON1_WINDOW_MGR (self)); + g_return_val_if_fail (MODEST_IS_HILDON1_WINDOW_MGR (self), FALSE); priv = MODEST_HILDON1_WINDOW_MGR_GET_PRIVATE (self); /* If there is a main window then try to close it, and it will @@ -252,6 +262,7 @@ modest_hildon1_window_mgr_close_all_windows (ModestWindowMgr *self) main_window = modest_window_mgr_get_main_window (self, FALSE); if (main_window) { g_signal_emit_by_name (main_window, "delete-event", NULL, &ret_value); + return ret_value; } else { GList *wins = NULL, *next = NULL; @@ -260,9 +271,13 @@ modest_hildon1_window_mgr_close_all_windows (ModestWindowMgr *self) while (wins) { next = g_list_next (wins); g_signal_emit_by_name (G_OBJECT (wins->data), "delete-event", NULL, &ret_value); + if (ret_value) + break; wins = next; } } + + return ret_value; } static gint @@ -325,6 +340,38 @@ modest_hildon1_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHead return has_header || has_window; } +static gboolean +modest_hildon1_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid, + ModestWindow **win) +{ + ModestHildon1WindowMgrPrivate *priv = NULL; + gboolean has_header, has_window = FALSE; + GList *item = NULL; + + g_return_val_if_fail (MODEST_IS_HILDON1_WINDOW_MGR (self), FALSE); + g_return_val_if_fail (msg_uid && msg_uid[0] != '\0', FALSE); + + priv = MODEST_HILDON1_WINDOW_MGR_GET_PRIVATE (self); + + has_header = MODEST_WINDOW_MGR_CLASS (parent_class)->find_registered_message_uid (self, msg_uid, win); + + item = g_list_find_custom (priv->window_list, msg_uid, (GCompareFunc) compare_msguids); + if (item) { + has_window = TRUE; + if (win) { + if ((!MODEST_IS_MSG_VIEW_WINDOW(item->data)) && + (!MODEST_IS_MSG_EDIT_WINDOW (item->data))) + g_debug ("not a valid window!"); + else { + g_debug ("found a window"); + *win = MODEST_WINDOW (item->data); + } + } + } + + return has_header || has_window; +} + static GList * modest_hildon1_window_mgr_get_window_list (ModestWindowMgr *self) { @@ -572,7 +619,7 @@ on_window_destroy (ModestWindow *window, cancel_window_operations (window); /* Fake the window system, make it think that there is no window */ - if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) == 0) + if (modest_window_mgr_get_num_windows (MODEST_WINDOW_MGR (self)) == 0) g_signal_emit_by_name (self, "window-list-empty"); no_propagate = TRUE; @@ -633,7 +680,7 @@ modest_hildon1_window_mgr_unregister_window (ModestWindowMgr *self, win = g_list_find (priv->window_list, window); if (!win) { - g_warning ("Trying to unregister a window that has not being registered yet"); + g_debug ("Trying to unregister a window that has not being registered yet"); return; } @@ -707,7 +754,7 @@ modest_hildon1_window_mgr_unregister_window (ModestWindowMgr *self, MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window); /* If there are no more windows registered emit the signal */ - if (modest_window_mgr_num_windows (self) == 0) + if (modest_window_mgr_get_num_windows (self) == 0) g_signal_emit_by_name (self, "window-list-empty"); } @@ -957,7 +1004,7 @@ remove_modal_from_queue (GtkWidget *widget, g_mutex_lock (priv->queue_lock); item = g_queue_find (priv->modal_windows, widget); if (!item) { - g_warning ("Trying to remove a modal window that is not registered"); + g_debug ("Trying to remove a modal window that is not registered"); g_mutex_unlock (priv->queue_lock); return; } @@ -1018,3 +1065,28 @@ on_modal_dialog_destroy (GtkObject *object, remove_modal_from_queue (GTK_WIDGET (object), self); } +static ModestWindow* +modest_hildon1_window_mgr_get_current_top (ModestWindowMgr *self) +{ + ModestHildon1WindowMgrPrivate *priv; + + priv = MODEST_HILDON1_WINDOW_MGR_GET_PRIVATE (self); + + return priv->current_top; +} + +static gboolean +modest_hildon1_window_mgr_screen_is_on (ModestWindowMgr *self) +{ + ModestHildon1WindowMgrPrivate *priv; + ModestWindow *main_window; + + priv = MODEST_HILDON1_WINDOW_MGR_GET_PRIVATE (self); + + main_window = modest_window_mgr_get_main_window (self, FALSE); + if (main_window && MODEST_IS_MAIN_WINDOW (main_window)) { + return modest_main_window_screen_is_on (MODEST_MAIN_WINDOW (main_window)); + } else { + return TRUE; + } +}