[anjal] Add --socket option and let account setup hook into single-shell control center for moblin.



commit e69151db53d9a7f433ae6b96ca0f4f7c741696a0
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Wed Jan 13 22:44:35 2010 +0530

    Add --socket option and let account setup hook into single-shell control
    center for moblin.

 src/anjal-settings-main.c |   16 +++++++--
 src/mail-capplet-shell.c  |   88 +++++++++++++++++++++++++--------------------
 src/mail-capplet-shell.h  |    2 +-
 3 files changed, 63 insertions(+), 43 deletions(-)
---
diff --git a/src/anjal-settings-main.c b/src/anjal-settings-main.c
index 0999f7e..6a9f58f 100644
--- a/src/anjal-settings-main.c
+++ b/src/anjal-settings-main.c
@@ -52,6 +52,7 @@
 gboolean windowed = FALSE;
 gboolean anjal_icon_decoration = FALSE;
 gboolean default_app =  FALSE;
+guint32 socket_id = 0;
 MailShell *main_window;
 static gchar **remaining_args;
 extern char *shell_moduledir;
@@ -162,8 +163,9 @@ idle_cb (MailShell *mshell G_GNUC_UNUSED)
 static void
 create_default_shell (void)
 {
-	main_window = mail_capplet_shell_new();
-	gtk_widget_show (main_window);
+	main_window = mail_capplet_shell_new(socket_id);
+	if (!socket_id)
+		gtk_widget_show (main_window);
 	g_idle_add ((GSourceFunc) idle_cb, remaining_args);
 }
 
@@ -185,6 +187,14 @@ main (int argc, char *argv[])
 	static GOptionEntry entries[] = {
 		{ "windowed", 'w', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &windowed,N_("Run Anjal in a window"), NULL },
 		{ "default-mailer", 'd', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &default_app,N_("Make Anjal the default email client"), NULL },
+		{ "socket",
+		  's',
+		  G_OPTION_FLAG_IN_MAIN,
+		  G_OPTION_ARG_INT,
+		  &socket_id,
+		  /* TRANSLATORS: don't translate the terms in brackets */
+		  N_("ID of the socket to embed in"),
+		  N_("socket") },		
 		{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, NULL },
 		{ NULL, 0, 0, 0, NULL, NULL, NULL }
 	};
@@ -215,7 +225,7 @@ main (int argc, char *argv[])
 	g_object_unref (client);
 	
 	app = unique_app_new ("org.gnome.AnjalSettings", NULL);
-	  if (unique_app_is_running (app))  {
+	  if (unique_app_is_running (app) && !socket_id)  {
 		   gboolean cmd_line =  (remaining_args && remaining_args[0] != NULL);
 		   
 		  if (!cmd_line)
diff --git a/src/mail-capplet-shell.c b/src/mail-capplet-shell.c
index 6541593..15ef90a 100644
--- a/src/mail-capplet-shell.c
+++ b/src/mail-capplet-shell.c
@@ -256,7 +256,7 @@ handle_cmdline (MailView *mv, MailCappletShell *shell)
 }
 
 void
-mail_capplet_shell_construct (MailCappletShell *shell)
+mail_capplet_shell_construct (MailCappletShell *shell, int socket_id)
 {
 	MailCappletShellPrivate *priv = shell->priv;
 	GtkWidget *tmp, *img, *box, *ar1, *ar2, *lbl;
@@ -280,45 +280,55 @@ mail_capplet_shell_construct (MailCappletShell *shell)
 
 	priv->box = (GtkWidget *) gtk_vbox_new (FALSE, 0);
 	gtk_widget_show ((GtkWidget *)priv->box);
-	
-	/* Toolbar */
-	priv->top_bar = gtk_toolbar_new ();
-	gtk_box_pack_start ((GtkBox *)priv->box, priv->top_bar, FALSE, FALSE, 0);
-	gtk_widget_show (priv->top_bar);
-	if (g_getenv("ANJAL_NO_MAX") || windowed) {
-		gtk_container_set_border_width (GTK_CONTAINER (shell), 1);
-		g_signal_connect (priv->top_bar, "expose-event",
-						  G_CALLBACK (color_expose),
-						  shell);
-		/* Leave it to the theme to decide the height */
-		/* gtk_widget_set_size_request (priv->top_bar, -1, 42);	*/
-	}
 
-	/* Label */
-	tmp = gtk_tool_item_new ();
-	gtk_tool_item_set_expand(tmp, FALSE);
-	lbl = gtk_label_new (_("Email Settings"));
-	gtk_container_add (tmp, lbl);
-	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, tmp, 0);
-	gtk_widget_show_all (tmp);
-
-	tmp = gtk_tool_item_new ();
-	gtk_tool_item_set_expand(tmp, TRUE);
-	lbl = gtk_label_new (NULL);
-	gtk_container_add (tmp, lbl);
-	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, tmp, 1);
-	gtk_widget_show_all (tmp);	
-
-	/* Close button */
-	PACK_IN_TOOL(priv->quit, "gtk-close");
-	gtk_widget_set_tooltip_text(priv->quit, _("Quit"));
-	gtk_tool_item_set_expand (priv->quit, FALSE);
-	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->quit, -1);
-	gtk_widget_show_all (priv->quit);
-	g_signal_connect (priv->quit, "clicked", G_CALLBACK(mail_capplet_shell_quit_cb), shell);
+	if (!socket_id) {
+		/* Toolbar */
+		priv->top_bar = gtk_toolbar_new ();
+		gtk_box_pack_start ((GtkBox *)priv->box, priv->top_bar, FALSE, FALSE, 0);
+		gtk_widget_show (priv->top_bar);
+		if (g_getenv("ANJAL_NO_MAX") || windowed) {
+			gtk_container_set_border_width (GTK_CONTAINER (shell), 1);
+			g_signal_connect (priv->top_bar, "expose-event",
+							  G_CALLBACK (color_expose),
+							  shell);
+			/* Leave it to the theme to decide the height */
+			/* gtk_widget_set_size_request (priv->top_bar, -1, 42);	*/
+		}
+	
+		/* Label */
+		tmp = gtk_tool_item_new ();
+		gtk_tool_item_set_expand(tmp, FALSE);
+		lbl = gtk_label_new (_("Email Settings"));
+		gtk_container_add (tmp, lbl);
+		gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, tmp, 0);
+		gtk_widget_show_all (tmp);
 	
-	gtk_container_add ((GtkContainer *)shell, priv->box);
+		tmp = gtk_tool_item_new ();
+		gtk_tool_item_set_expand(tmp, TRUE);
+		lbl = gtk_label_new (NULL);
+		gtk_container_add (tmp, lbl);
+		gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, tmp, 1);
+		gtk_widget_show_all (tmp);	
 	
+		/* Close button */
+		PACK_IN_TOOL(priv->quit, "gtk-close");
+		gtk_widget_set_tooltip_text(priv->quit, _("Quit"));
+		gtk_tool_item_set_expand (priv->quit, FALSE);
+		gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->quit, -1);
+		gtk_widget_show_all (priv->quit);
+		g_signal_connect (priv->quit, "clicked", G_CALLBACK(mail_capplet_shell_quit_cb), shell);
+
+		gtk_container_add ((GtkContainer *)shell, priv->box);
+	} else {
+		GtkWidget *plug = gtk_plug_new (socket_id);
+		
+		gtk_container_add ((GtkContainer *)plug, priv->box);
+		g_signal_connect (plug, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+		gtk_widget_show (plug);
+		gtk_widget_hide (shell);
+
+	}
+
 	shell->view = mail_view_new ();
 	gtk_widget_show (shell->view);
 	tmp = gtk_vbox_new (FALSE, 0);
@@ -356,10 +366,10 @@ mail_capplet_shell_toolbar_height (MailCappletShell *shell)
 }
 
 MailCappletShell *
-mail_capplet_shell_new ()
+mail_capplet_shell_new (int socket_id)
 {
 	MailCappletShell *shell = g_object_new (MAIL_CAPPLET_SHELL_TYPE, NULL);
-	mail_capplet_shell_construct (shell);
+	mail_capplet_shell_construct (shell, socket_id);
 
 	return shell;
 }
diff --git a/src/mail-capplet-shell.h b/src/mail-capplet-shell.h
index a8750e0..be6ba25 100644
--- a/src/mail-capplet-shell.h
+++ b/src/mail-capplet-shell.h
@@ -50,7 +50,7 @@ typedef struct _MailCappletShellClass {
 	void (* ctrl_q_pressed)    (MailCappletShell *class);	
 } MailCappletShellClass;
 
-MailCappletShell * mail_capplet_shell_new (void);
+MailCappletShell * mail_capplet_shell_new (int socket_id);
 int mail_capplet_shell_toolbar_height (MailCappletShell *shell);
 
 #endif



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