[gnome-control-center] shell: Export our main window XID in an environment variable



commit ac359b1d62d22c716f6d3bf24b51aa23210edc2d
Author: Rui Matos <tiagomatos gmail com>
Date:   Sun Jan 20 15:17:20 2013 +0100

    shell: Export our main window XID in an environment variable
    
    This allows external tools to know that they are being called from
    gnome-control-center and look like attached modal dialogs as per
    design.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691854

 shell/gnome-control-center.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 4db4eb4..8fdc468 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -28,6 +28,7 @@
 #include <gio/gdesktopappinfo.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
+#include <gdk/gdkx.h>
 #include <string.h>
 #include <libgd/gd-styled-text-renderer.h>
 
@@ -1317,6 +1318,27 @@ monitors_changed_cb (GdkScreen *screen,
 }
 
 static void
+gdk_window_set_cb (GObject    *object,
+                   GParamSpec *pspec,
+                   GnomeControlCenter *self)
+{
+  GdkWindow *window;
+  gchar *str;
+
+  if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+    return;
+
+  window = gtk_widget_get_window (GTK_WIDGET (self->priv->window));
+
+  if (!window)
+    return;
+
+  str = g_strdup_printf ("%u", (guint) GDK_WINDOW_XID (window));
+  g_setenv ("GNOME_CONTROL_CENTER_XID", str, TRUE);
+  g_free (str);
+}
+
+static void
 gnome_control_center_init (GnomeControlCenter *self)
 {
   GError *err = NULL;
@@ -1358,6 +1380,7 @@ gnome_control_center_init (GnomeControlCenter *self)
   g_signal_connect_swapped (priv->window, "delete-event", G_CALLBACK (g_object_unref), self);
   g_signal_connect_after (priv->window, "key_press_event",
                           G_CALLBACK (window_key_press_event), self);
+  g_signal_connect (priv->window, "notify::window", G_CALLBACK (gdk_window_set_cb), self);
 
   priv->notebook = W (priv->builder, "notebook");
 



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