[gnome-control-center/gbsneto/early-exit: 2/3] main: Prevent running outside GNOME



commit c3cff35f9d69c7c106d5d2d1fb2f65f01e8c02af
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Nov 1 12:53:34 2018 -0300

    main: Prevent running outside GNOME
    
    GNOME Settings relies on GNOME-specific services, and we cannot
    guarantee they'll be available on non-GNOME sessions.
    
    Thus, prevent Settings from running when the current desktop is
    not GNOME.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/248

 shell/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/shell/main.c b/shell/main.c
index 332e3c4e5..1e27882c1 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -35,6 +35,12 @@
 
 #include "cc-application.h"
 
+static gboolean
+is_gnome (void)
+{
+  return g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "GNOME") == 0;
+}
+
 int
 main (int    argc,
       char **argv)
@@ -45,6 +51,13 @@ main (int    argc,
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
 
+  /* Prevent running outside GNOME */
+  if (!is_gnome ())
+    {
+      g_critical (_("GNOME Settings cannot run outside the GNOME Desktop Environment, exiting"));
+      return 1;
+    }
+
 #ifdef GDK_WINDOWING_X11
   XInitThreads ();
 #endif


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