-static gboolean
-on_window_destroy (ModestWindow *window,
- GdkEvent *event,
- ModestWindowMgr *self)
-{
- /* Specific stuff first */
- if (MODEST_IS_MAIN_WINDOW (window)) {
- ModestWindowMgrPrivate *priv;
- priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
-
- /* If more than one window already opened */
- if (g_list_length (priv->window_list) > 1) {
-
- /* If the user wants to close all the windows */
- if (modest_main_window_close_all (MODEST_MAIN_WINDOW (window))) {
- GList *iter = priv->window_list;
- do {
- if (iter->data != window) {
- GList *tmp = iter->next;
- on_window_destroy (MODEST_WINDOW (iter->data),
- event,
- self);
- iter = tmp;
- } else {
- iter = g_list_next (iter);
- }
- } while (iter);
- }
- }
- }
- else {
- if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
- gboolean sent = FALSE;
- gint response = GTK_RESPONSE_ACCEPT;
- sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
- /* Save currently edited message to Drafts if it was not sent */
- if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
-
- /* Raise the window if it's minimized */
- if (!gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
- gtk_window_present (GTK_WINDOW (window));
-
- response =
- modest_platform_run_confirmation_dialog (GTK_WINDOW (window),
- _("mcen_nc_no_email_message_modified_save_changes"));
- /* Save to drafts */
- if (response != GTK_RESPONSE_CANCEL)
- modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window));
- }
- }
- }
-
- /* Unregister window */
- modest_window_mgr_unregister_window (self, window);
-
- return FALSE;
-}
-
-static void
-disconnect_msg_changed (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- guint handler_id;
- handler_id = GPOINTER_TO_UINT(value);
-
- if (key && G_IS_OBJECT(key))
- g_signal_handler_disconnect (G_OBJECT (key), handler_id);
-}
-
-
-
-/* interval before retrying to close the application */
-#define CLOSING_RETRY_INTERVAL 3000
-/* interval before cancel whatever is left in the queue, and closing anyway */
-#define MAX_WAIT_FOR_CLOSING 30 * 1000
-
-static gboolean
-on_quit_maybe (ModestWindowMgr *self)
-{
- ModestWindowMgrPrivate *priv;
- guint queue_num;
-
- priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
-
- /* it seems, in the meantime some windows were
- * created. in that case, stop 'on_quit_maybe' */
- if (priv->window_list) {
- priv->closing_time = 0;
- return FALSE;
- }
-
- if (priv->closing_time >= MAX_WAIT_FOR_CLOSING) {
- /* we waited long enough: cancel all remaining operations */
- g_debug ("%s: we waited long enough (%ds), cancelling queue and quiting",
- __FUNCTION__, priv->closing_time/1000);
- /* FIXME: below gives me a lot of:
- * GLIB CRITICAL ** default - modest_mail_operation_cancel:
- * assertion `priv->account' failed
- * which means there is no account for the given operation
- * so, we're not trying to be nice, we're just quiting.
- */
- //modest_mail_operation_queue_cancel_all
- // (modest_runtime_get_mail_operation_queue());
- } else {
-
- /* if there is anything left in our operation queue,
- * wait another round
- */
- queue_num = modest_mail_operation_queue_num_elements
- (modest_runtime_get_mail_operation_queue());
- if (queue_num > 0) {
- g_debug ("%s: waiting, there are still %d operation(s) queued",
- __FUNCTION__, queue_num);
- priv->closing_time += CLOSING_RETRY_INTERVAL;
- return TRUE;
- }
- }
-
- /* so: no windows left, nothing in the queue: quit */
- priv->closing_time = 0;
- gtk_main_quit ();
- return FALSE;
-}
-
-