19082N/A--- gnome-control-center-2.30.1.orig/capplets/keyboard/gnome-keyboard-properties-dialog.ui 2010-06-01 13:35:44.209124944 +0200
19082N/A+++ gnome-control-center-2.30.1/capplets/keyboard/gnome-keyboard-properties-dialog.ui 2010-06-01 13:37:25.982521195 +0200
19082N/A@@ -501,7 +501,7 @@
19082N/A </packing>
19082N/A </child>
19082N/A <child>
19082N/A- <object class="GtkVBox" id="vbox33">
19082N/A+ <object class="GtkVBox" id="layout_tab_widget">
19082N/A <property name="visible">True</property>
19082N/A <property name="border_width">12</property>
19082N/A <property name="orientation">vertical</property>
19082N/A
19082N/A--- gnome-control-center-2.30.1.orig/capplets/keyboard/gnome-keyboard-properties.c 2010-06-01 13:35:44.228217173 +0200
19082N/A+++ gnome-control-center-2.30.1/capplets/keyboard/gnome-keyboard-properties.c 2010-06-01 13:42:40.045501900 +0200
19082N/A@@ -38,11 +38,72 @@
19082N/A #include "gnome-keyboard-properties-a11y.h"
19082N/A #include "gnome-keyboard-properties-xkb.h"
19082N/A
19082N/A+#include <fcntl.h>
19082N/A+#include <sys/types.h>
19082N/A+#include <sys/stat.h>
19082N/A+#include <ucred.h>
19082N/A+#include <gdk/gdkx.h>
19082N/A+
19082N/A enum {
19082N/A RESPONSE_APPLY = 1,
19082N/A RESPONSE_CLOSE
19082N/A };
19082N/A
19082N/A+/*
19082N/A+ * Function to determine if a connection is local or not.
19082N/A+ * Returns: FALSE for remote, TRUE for local
19082N/A+ */
19082N/A+static gboolean
19082N/A+is_xclient_local (Display *dpy) {
19082N/A+ int c = ConnectionNumber(dpy);
19082N/A+ struct stat statbuf;
19082N/A+ gboolean rv = FALSE;
19082N/A+ ucred_t *ucred = NULL;
19082N/A+ const char *disp_name;
19082N/A+
19082N/A+ if (c >= 0) {
19082N/A+ /*
19082N/A+ * stat the connection fd. If we succeed and the type of file
19082N/A+ * is a FIFO, then we must be local.
19082N/A+ */
19082N/A+ if ((fstat(c, &statbuf) >= 0) && S_ISFIFO(statbuf.st_mode)) {
19082N/A+ return TRUE;
19082N/A+ }
19082N/A+ /*
19082N/A+ * Then call getpeerucred - if it succeeds, the other end of the
19082N/A+ * connection must be on the same machine (though possibly in a
19082N/A+ * different zone).
19082N/A+ */
19082N/A+ if (getpeerucred(c, &ucred) == 0) {
19082N/A+ if (ucred_getzoneid(ucred) != -1) {
19082N/A+ /* If disp_name starts with ':' then it's local
19082N/A+ * Treats apps running in nested Xservers as remote :( */
19082N/A+ disp_name = g_getenv ("DISPLAY");
19082N/A+
19082N/A+ if (disp_name && disp_name[0] == ':')
19082N/A+ rv = TRUE;
19082N/A+ }
19082N/A+ ucred_free(ucred);
19082N/A+ }
19082N/A+ }
19082N/A+ return rv;
19082N/A+}
19082N/A+
19082N/A+static gboolean
19082N/A+is_xserver_local (void) {
19082N/A+ const char *dt_xserver_loc;
19082N/A+ const char *gdm_xserver_loc;
19082N/A+
19082N/A+ dt_xserver_loc = g_getenv ("DTXSERVERLOCATION");
19082N/A+ gdm_xserver_loc = g_getenv ("GDM_XSERVER_LOCATION");
19082N/A+
19082N/A+ if ((dt_xserver_loc && strcmp (dt_xserver_loc, "remote") == 0) ||
19082N/A+ (gdm_xserver_loc && strcmp (gdm_xserver_loc, "xdmcp") == 0))
19082N/A+ return FALSE;
19082N/A+
19082N/A+ return TRUE;
19082N/A+}
19082N/A+
19082N/A static GtkBuilder *
19082N/A create_dialog (void)
19082N/A {
19082N/A@@ -79,6 +140,18 @@
19082N/A image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON);
19082N/A gtk_button_set_image (GTK_BUTTON (WID ("xkb_reset_to_defaults")), image);
19082N/A
19082N/A+ /* Unless we have both xclient/xserver running in the local */
19082N/A+ /* machine we won't display the keyboard layout tab */
19082N/A+
19082N/A+ Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
19082N/A+
19082N/A+
19082N/A+ if (!is_xclient_local(dpy) || !is_xserver_local()) {
19082N/A+ GtkWidget *layout_tab = WID ("layout_tab_widget");
19082N/A+
19082N/A+ gtk_widget_hide (layout_tab);
19082N/A+ }
19082N/A+
19082N/A return dialog;
19082N/A }
19082N/A