[anjal] Make sure, we do the job before we quit. Sync with server etc...



commit 68d7fba9d386d3af2ae72cf13cb907e6bb3d59cc
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Thu Mar 19 17:17:41 2009 +0530

    Make sure, we do the job before we quit. Sync with server etc...
---
 src/mail-component.c |    4 ++--
 src/mail-shell.c     |   26 ++++++++++++++++++++++++--
 src/main.c           |    6 ++++++
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/src/mail-component.c b/src/mail-component.c
index f11a905..31e8373 100644
--- a/src/mail-component.c
+++ b/src/mail-component.c
@@ -658,8 +658,8 @@ mail_component_quit(MailComponent *mc)
 	}
 		/* Falls through */
 	case MC_QUIT_SYNC:
-		if (mc->priv->quit_count > 0 || mc->priv->mail_sync_in_progress > 0)
-			return FALSE;
+		while (mc->priv->quit_count > 0 || mc->priv->mail_sync_in_progress > 0)
+			g_main_context_iteration (NULL, TRUE);
 
 		mail_cancel_all();
 		mc->priv->quit_state = MC_QUIT_THREADS;
diff --git a/src/mail-shell.c b/src/mail-shell.c
index 8d13290..0fb7c50 100644
--- a/src/mail-shell.c
+++ b/src/mail-shell.c
@@ -201,6 +201,28 @@ ms_init_style (GtkStyle *style)
 	 scolor_fg_norm = gdk_color_to_string (pcolor_fg_norm);
 }
 
+static void
+mail_shell_quit (MailShell *shell)
+{
+	/* What other clean ups ?*/
+	gboolean quit = mail_component_can_quit (shell->mail_component);
+	if (quit) {
+		mail_component_quit (shell->mail_component);
+		gtk_main_quit();
+	}
+}
+
+static void
+mail_shell_quit_cb (GtkWidget *w, MailShell *shell)
+{
+	mail_shell_quit (shell);
+}
+static void
+ms_delete_event (MailShell *shell, GdkEvent *event, gpointer data)
+{
+	mail_shell_quit (shell);
+}
+
 void
 mail_shell_construct (MailShell *shell)
 {
@@ -209,7 +231,7 @@ mail_shell_construct (MailShell *shell)
 	GtkStyle *style = gtk_widget_get_default_style ();
 
 	ms_init_style (style);
-	g_signal_connect ((GObject *)shell, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
+	g_signal_connect ((GObject *)shell, "delete-event", G_CALLBACK (ms_delete_event), NULL);
 	gtk_window_set_type_hint ((GtkWindow *)shell, GDK_WINDOW_TYPE_HINT_NORMAL);
 	gtk_window_set_default_size ((GtkWindow *)shell, 1024, 600); /* We officiall should support 800x600 */
 	gtk_container_set_border_width (GTK_CONTAINER (shell), 6);
@@ -274,7 +296,7 @@ mail_shell_construct (MailShell *shell)
 //	gtk_tool_button_set_icon_widget ((GtkButton *)priv->quit, gtk_image_new_from_icon_name("gtk-close", GTK_ICON_SIZE_BUTTON));
 	gtk_box_pack_start ((GtkBox *)priv->option_bar, priv->quit, FALSE, FALSE, 0);
 	gtk_widget_show (priv->quit);
-	g_signal_connect (priv->quit, "clicked", G_CALLBACK(gtk_main_quit), NULL);
+	g_signal_connect (priv->quit, "clicked", G_CALLBACK(mail_shell_quit_cb), shell);
 	
 	gtk_container_add ((GtkContainer *)shell, priv->box);
 
diff --git a/src/main.c b/src/main.c
index 96cf492..be25ec2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,10 +60,16 @@ main (int argc, char *argv[])
 	e_passwords_init();
 	g_thread_init (NULL);
 	mail_msg_init ();
+	gnome_sound_init ("localhost");
 
 	window = (GtkWindow *)mail_shell_new ();
 	gtk_widget_show (window);
 
 	gtk_main ();
+
+	e_icon_factory_shutdown ();
+	gnome_sound_shutdown ();
+	e_cursors_shutdown ();
+	
 	return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]