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



commit 92c9f7e7ac51b1fafcea0abc4684a552ba170e7e
Author: Thomas Wood <thomas wood intel com>
Date:   Tue Jan 12 12:08:41 2010 +0000

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

 capplets/keyboard/gnome-keyboard-properties.c |   35 +++++++++++++++++++++---
 1 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/capplets/keyboard/gnome-keyboard-properties.c b/capplets/keyboard/gnome-keyboard-properties.c
index d2aef71..20b1fde 100644
--- a/capplets/keyboard/gnome-keyboard-properties.c
+++ b/capplets/keyboard/gnome-keyboard-properties.c
@@ -119,7 +119,8 @@ dialog_response (GtkWidget * widget,
 }
 
 static void
-setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset)
+setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset,
+	      guint32 socket_id)
 {
 	GObject *peditor;
 	gchar *monitor;
@@ -180,8 +181,20 @@ setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset)
 		gtk_notebook_remove_page (nb, tb_page);
 	}
 
-	g_signal_connect (WID ("keyboard_dialog"), "response",
-			  (GCallback) dialog_response, changeset);
+	if (socket_id) {
+		GtkWidget *content, *plug;
+
+		/* re-parent contents */
+		content = WID ("vbox1");
+
+		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);
+	} else {
+		g_signal_connect (WID ("keyboard_dialog"), "response",
+				  (GCallback) dialog_response, changeset);
+	}
 
 	setup_xkb_tabs (dialog, changeset);
 	setup_a11y_tabs (dialog, changeset);
@@ -198,6 +211,7 @@ main (int argc, char **argv)
 	static gboolean apply_only = FALSE;
 	static gboolean switch_to_typing_break_page = FALSE;
 	static gboolean switch_to_a11y_page = FALSE;
+	static guint32 socket_id = 0;
 
 	static GOptionEntry cap_options[] = {
 		{"apply", 0, 0, G_OPTION_ARG_NONE, &apply_only,
@@ -219,6 +233,16 @@ main (int argc, char **argv)
 		 N_
 		 ("Start the page with the accessibility settings showing"),
 		 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") },
+
 		{NULL}
 	};
 
@@ -241,7 +265,7 @@ main (int argc, char **argv)
 
 	changeset = NULL;
 	dialog = create_dialog ();
-	setup_dialog (dialog, changeset);
+	setup_dialog (dialog, changeset, socket_id);
 	if (switch_to_typing_break_page) {
 		gtk_notebook_set_current_page (GTK_NOTEBOOK
 					       (WID
@@ -258,7 +282,8 @@ main (int argc, char **argv)
 
 	capplet_set_icon (WID ("keyboard_dialog"),
 			  "preferences-desktop-keyboard");
-	gtk_widget_show (WID ("keyboard_dialog"));
+	if (!socket_id)
+	  gtk_widget_show (WID ("keyboard_dialog"));
 	gtk_main ();
 
 	return 0;



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