summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2013-03-09 17:54:21 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-05 20:04:51 +0200
commitd7e28c1a8d5bc3e30db0802470b3042739afdc6d (patch)
tree8d981075260bc86314e3d196d139453baf2e0f83 /src
parent06d4c0b2e82019798b199cf2f70f184d8a27e456 (diff)
QGtkStyle: Try to get the theme name from GtkSettings
Note that GtkSettings is already used for retrieving the icon theme name. Change-Id: I935d903c703f7d832b0350d3cfd3a638f22d1391 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp38
1 files changed, 6 insertions, 32 deletions
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
index c2f6b99349..a53a961a89 100644
--- a/src/widgets/styles/qgtkstyle_p.cpp
+++ b/src/widgets/styles/qgtkstyle_p.cpp
@@ -676,38 +676,12 @@ bool QGtkStylePrivate::getGConfBool(const QString &key, bool fallback)
QString QGtkStylePrivate::getThemeName()
{
QString themeName;
- // We try to parse the gtkrc file first
- // primarily to avoid resolving Gtk functions if
- // the KDE 3 "Qt" style is currently in use
- QString rcPaths = QString::fromLocal8Bit(qgetenv("GTK2_RC_FILES"));
- if (!rcPaths.isEmpty()) {
- QStringList paths = rcPaths.split(QLS(":"));
- foreach (const QString &rcPath, paths) {
- if (!rcPath.isEmpty()) {
- QFile rcFile(rcPath);
- if (rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&rcFile);
- while(!in.atEnd()) {
- QString line = in.readLine();
- if (line.contains(QLS("gtk-theme-name"))) {
- line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1);
- line.remove(QLatin1Char('\"'));
- line = line.trimmed();
- themeName = line;
- break;
- }
- }
- }
- }
- if (!themeName.isEmpty())
- break;
- }
- }
-
- // Fall back to gconf
- if (themeName.isEmpty() && resolveGConf())
- themeName = getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
-
+ // Read the theme name from GtkSettings
+ GtkSettings *settings = QGtkStylePrivate::gtk_settings_get_default();
+ gchararray value;
+ g_object_get(settings, "gtk-theme-name", &value, NULL);
+ themeName = QString::fromUtf8(value);
+ g_free(value);
return themeName;
}