fepitre / rpms / gtk3

Forked from rpms/gtk3 4 years ago
Clone

Blame SOURCES/0002-GtkApplication-Try-to-cope-with-ssh-situations-bette.patch

25dd04
From ac5ffd847b1a7e744d7922359c1639b795c28908 Mon Sep 17 00:00:00 2001
25dd04
From: Matthias Clasen <mclasen@redhat.com>
25dd04
Date: Thu, 18 Dec 2014 23:20:43 -0500
25dd04
Subject: [PATCH 2/2] GtkApplication: Try to cope with ssh situations better
25dd04
25dd04
Override the gtk-shell-shows-app-menu and gtk-shell-shows-menubar
25dd04
settings to FALSE, if we can detect that we are not on the same
25dd04
session bus as the xsettings provider that we got these settings
25dd04
from.
25dd04
25dd04
We determine this by comparing the bus ID of 'our' session
25dd04
bus with the one reported in the Gtk/SessionBusId xsetting.
25dd04
If they are different, then it very likely that we are in an ssh
25dd04
situation where we see the forwarded X display, but not the
25dd04
session bus. The D-Bus based menu exporting will not work
25dd04
in this situation.
25dd04
25dd04
https://bugzilla.gnome.org/show_bug.cgi?id=671802
25dd04
---
25dd04
 gtk/gtkapplication-dbus.c | 59 +++++++++++++++++++++++++++++++++++++++++++----
25dd04
 1 file changed, 54 insertions(+), 5 deletions(-)
25dd04
25dd04
diff --git a/gtk/gtkapplication-dbus.c b/gtk/gtkapplication-dbus.c
25dd04
index 0c45447..2367002 100644
25dd04
--- a/gtk/gtkapplication-dbus.c
25dd04
+++ b/gtk/gtkapplication-dbus.c
25dd04
@@ -111,11 +111,12 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
25dd04
   static gchar *client_id;
25dd04
   GError *error = NULL;
25dd04
   GVariant *res;
25dd04
+  gboolean same_bus;
25dd04
 
25dd04
   dbus->session = g_application_get_dbus_connection (G_APPLICATION (impl->application));
25dd04
 
25dd04
   if (!dbus->session)
25dd04
-    return;
25dd04
+    goto out;
25dd04
 
25dd04
   dbus->application_id = g_application_get_application_id (G_APPLICATION (impl->application));
25dd04
   dbus->object_path = g_application_get_dbus_object_path (G_APPLICATION (impl->application));
25dd04
@@ -149,14 +150,14 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
25dd04
     {
25dd04
       g_warning ("Failed to get a session proxy: %s", error->message);
25dd04
       g_error_free (error);
25dd04
-      return;
25dd04
+      goto out;
25dd04
     }
25dd04
 
25dd04
   /* FIXME: should we reuse the D-Bus application id here ? */
25dd04
   dbus->app_id = g_strdup (g_get_prgname ());
25dd04
 
25dd04
   if (!register_session)
25dd04
-    return;
25dd04
+    goto out;
25dd04
 
25dd04
   g_debug ("Registering client '%s' '%s'", dbus->app_id, client_id);
25dd04
 
25dd04
@@ -173,7 +174,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
25dd04
       g_warning ("Failed to register client: %s", error->message);
25dd04
       g_error_free (error);
25dd04
       g_clear_object (&dbus->sm_proxy);
25dd04
-      return;
25dd04
+      goto out;
25dd04
     }
25dd04
 
25dd04
   g_variant_get (res, "(o)", &dbus->client_path);
25dd04
@@ -195,10 +196,58 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
25dd04
       g_clear_object (&dbus->sm_proxy);
25dd04
       g_free (dbus->client_path);
25dd04
       dbus->client_path = NULL;
25dd04
-      return;
25dd04
+      goto out;
25dd04
     }
25dd04
 
25dd04
   g_signal_connect (dbus->client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), dbus);
25dd04
+
25dd04
+ out:
25dd04
+  same_bus = FALSE;
25dd04
+
25dd04
+  if (dbus->session)
25dd04
+    {
25dd04
+      const gchar *id;
25dd04
+      const gchar *id2;
25dd04
+      GValue value = G_VALUE_INIT;
25dd04
+
25dd04
+      g_value_init (&value, G_TYPE_STRING);
25dd04
+      gdk_screen_get_setting (gdk_screen_get_default (), "gtk-session-bus-id", &value);
25dd04
+      id = g_value_get_string (&value);
25dd04
+
25dd04
+      if (id && id[0])
25dd04
+        {
25dd04
+          res = g_dbus_connection_call_sync (dbus->session,
25dd04
+                                             "org.freedesktop.DBus",
25dd04
+                                             "/org/freedesktop/DBus",
25dd04
+                                             "org.freedesktop.DBus",
25dd04
+                                             "GetId",
25dd04
+                                             NULL,
25dd04
+                                             NULL,
25dd04
+                                             G_DBUS_CALL_FLAGS_NONE,
25dd04
+                                             -1,
25dd04
+                                             NULL,
25dd04
+                                             NULL);
25dd04
+          if (res)
25dd04
+            {
25dd04
+              g_variant_get (res, "(&s)", &id2);
25dd04
+
25dd04
+              if (g_strcmp0 (id, id2) == 0)
25dd04
+                same_bus = TRUE;
25dd04
+
25dd04
+              g_variant_unref (res);
25dd04
+            }
25dd04
+        }
25dd04
+      else
25dd04
+        same_bus = TRUE;
25dd04
+
25dd04
+      g_value_unset (&value);
25dd04
+    }
25dd04
+
25dd04
+  if (!same_bus)
25dd04
+    g_object_set (gtk_settings_get_default (),
25dd04
+                  "gtk-shell-shows-app-menu", FALSE,
25dd04
+                  "gtk-shell-shows-menubar", FALSE,
25dd04
+                  NULL);
25dd04
 }
25dd04
 
25dd04
 static void
25dd04
-- 
25dd04
2.3.6
25dd04