gtk2-use-adwaita-theme.patch 2.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index 186a8f5cb2..f5c39b5afe 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -3000,6 +3000,50 @@ check_transform (const gchar *xsettings_name,
     return TRUE;
 }

+static gchar *
+gtk_rc_get_theme_dir (void)
+{
+  const gchar *var;
+  gchar *path;
+
+  var = g_getenv ("GTK_DATA_PREFIX");
+
+  if (var)
+    path = g_build_filename (var, "share", "themes", NULL);
+  else
+    path = g_build_filename ("/usr", "share", "themes", NULL);
+
+  return path;
+}
+
+static gboolean
+theme_name_valid (XSettingsSetting *setting)
+{
+  gboolean res = FALSE;
+
+  if (setting->type == XSETTINGS_TYPE_STRING)
+    {
+      char *theme_name = setting->data.v_string;
+      gchar *theme_dir = gtk_rc_get_theme_dir ();
+      gchar *path = g_build_filename (theme_dir, theme_name, "gtk-2.0", "gtkrc", NULL);
+
+      if (g_file_test (path, G_FILE_TEST_EXISTS))
+        res = TRUE;
+      else if (g_str_has_suffix (theme_name, "-Dark") ||
+               g_str_has_suffix (theme_name, "-dark"))
+        {
+          setting->data.v_string = g_strdup ("Adwaita-dark");
+          g_free (theme_name);
+          res = TRUE;
+        }
+
+      g_free (theme_dir);
+      g_free (path);
+    }
+
+  return res;
+}
+
 /**
  * gdk_screen_get_setting:
  * @screen: the #GdkScreen where the setting is located
@@ -3050,6 +3094,11 @@ gdk_screen_get_setting (GdkScreen   *screen,
   if (result != XSETTINGS_SUCCESS)
     goto out;

+  if (strcmp (name, "gtk-theme-name") == 0 &&
+      (setting->type != XSETTINGS_TYPE_STRING ||
+       !theme_name_valid (setting)))
+    goto out;
+
   switch (setting->type)
     {
     case XSETTINGS_TYPE_INT:
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 3fbbf00548..5c0a4b33d2 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -312,7 +312,7 @@ gtk_settings_class_init (GtkSettingsClass *class)
 #ifdef G_OS_WIN32
 								  "MS-Windows",
 #else
-								  "Raleigh",
+								  "Adwaita",
 #endif
 								  GTK_PARAM_READWRITE),
                                              NULL);