summaryrefslogtreecommitdiffstats
path: root/main/qt/qt-gtk-theme-fix.patch
blob: 5939b1fd1a071715a567e24271d24a81768edfa0 (plain)
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
Author: Timo Teräs <timo.teras@iki.fi>

Fix QT GTK style to use GTK API to get the active theme name. This fixes
things for non-GNOME setups, as well as realtime theme change detection.

It still tries to detect if GTK-Qt is in use and refuse to run with that
as it would cause obvious recursion, however that might be not always
possible.

--- qt-everywhere-opensource-src-4.8.0/src/gui/styles/qgtkstyle_p.h.orig
+++ qt-everywhere-opensource-src-4.8.0/src/gui/styles/qgtkstyle_p.h
@@ -338,6 +338,7 @@
     static bool getGConfBool(const QString &key, bool fallback = 0);
     static QString getGConfString(const QString &key, const QString &fallback = QString());
 
+    static QString getThemeNameGuess();
     static QString getThemeName();
     virtual int getSpinboxArrowSize() const;
 
--- qt-everywhere-opensource-src-4.8.0/src/gui/styles/qgtkstyle_p.cpp.orig
+++ qt-everywhere-opensource-src-4.8.0/src/gui/styles/qgtkstyle_p.cpp
@@ -504,12 +504,9 @@
 
     static QString themeName;
     if (!gtkWidgetMap()->contains("GtkWindow") && themeName.isEmpty()) {
-        themeName = getThemeName();
+        themeName = getThemeNameGuess();
 
-        if (themeName.isEmpty()) {
-            qWarning("QGtkStyle was unable to detect the current GTK+ theme.");
-            return;
-        } else if (themeName == QLS("Qt") || themeName == QLS("Qt4")) {
+        if (themeName == QLS("Qt") || themeName == QLS("Qt4")) {
             // Due to namespace conflicts with Qt3 and obvious recursion with Qt4,
             // we cannot support the GTK_Qt Gtk engine
             qWarning("QGtkStyle cannot be used together with the GTK_Qt engine.");
@@ -650,7 +647,7 @@
     return retVal;
 }
 
-QString QGtkStylePrivate::getThemeName()
+QString QGtkStylePrivate::getThemeNameGuess()
 {
     QString themeName;
     // We try to parse the gtkrc file first
@@ -684,6 +681,19 @@
     // Fall back to gconf
     if (themeName.isEmpty() && resolveGConf())
         themeName = getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
+
+    return themeName;
+}
+
+QString QGtkStylePrivate::getThemeName()
+{
+    QString themeName;
+    gchar *theme_name;
+
+    GtkSettings *settings = gtk_settings_get_default();
+    g_object_get(settings, "gtk-theme-name", &theme_name, NULL);
+    themeName = QString::fromUtf8(theme_name);
+    g_free(theme_name);
 
     return themeName;
 }