[gnome-control-center/single-window-shell] [about-me] add a --socket option



commit 567c780dcce1ac69301b3703a945808a493567ac
Author: Thomas Wood <thomas wood intel com>
Date:   Mon Jan 11 11:06:21 2010 +0000

    [about-me] add a --socket option
    
    Allow embedding in another application by adding a --socket option to
    specify the ID of an window.

 capplets/about-me/gnome-about-me.c |   49 ++++++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 8 deletions(-)
---
diff --git a/capplets/about-me/gnome-about-me.c b/capplets/about-me/gnome-about-me.c
index 9551917..58af30b 100644
--- a/capplets/about-me/gnome-about-me.c
+++ b/capplets/about-me/gnome-about-me.c
@@ -836,7 +836,7 @@ about_me_fingerprint_button_clicked_cb (GtkWidget *button, GnomeAboutMe *me)
 }
 
 static gint
-about_me_setup_dialog (void)
+about_me_setup_dialog (guint32 socket_id)
 {
 	GtkWidget    *widget;
 	GtkWidget    *main_dialog;
@@ -861,10 +861,25 @@ about_me_setup_dialog (void)
 
 	me->dialog = dialog;
 
-	/* Connect the close button signal */
-	main_dialog = WID ("about-me-dialog");
-	g_signal_connect (main_dialog, "response",
-			  G_CALLBACK (about_me_button_clicked_cb), me);
+	if (socket_id) {
+		GtkWidget *content, *plug;
+
+		/* re-parent contents */
+		content = WID ("vbox55");
+
+		plug = gtk_plug_new (socket_id);
+		gtk_widget_reparent (content, plug);
+		g_signal_connect (plug, "destroy", G_CALLBACK (gtk_main_quit),
+				  NULL);
+
+		gtk_widget_show_all (plug);
+		main_dialog = plug;
+	}
+	else {
+		main_dialog = WID ("about-me-dialog");
+		g_signal_connect (main_dialog, "response",
+				  G_CALLBACK (about_me_button_clicked_cb), me);
+	}
 
 	gtk_window_set_resizable (GTK_WINDOW (main_dialog), FALSE);
 	capplet_set_icon (main_dialog, "user-info");
@@ -986,8 +1001,26 @@ int
 main (int argc, char **argv)
 {
 	int rc = 0;
-
-	capplet_init (NULL, &argc, &argv);
+	guint32 socket_id;
+
+	GOptionContext *context;
+	GOptionEntry cap_options[] = {
+		{ "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") },
+		{NULL}
+	};
+
+	context = g_option_context_new (_("- GNOME About Me"));
+	g_option_context_add_main_entries (context, cap_options,
+					   GETTEXT_PACKAGE);
+
+	capplet_init (context, &argc, &argv);
 
 	if (!g_thread_supported ())
 		g_thread_init (NULL);
@@ -995,7 +1028,7 @@ main (int argc, char **argv)
 	dbus_g_object_register_marshaller (fprintd_marshal_VOID__STRING_BOOLEAN,
 					   G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
 
-	rc = about_me_setup_dialog ();
+	rc = about_me_setup_dialog (socket_id);
 
 	if (rc != -1) {
 		gtk_main ();



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