summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2013-05-19 11:49:47 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-15 05:14:32 (GMT)
commitceaa577a035607569a6ec8cfab09e4fb35363fd0 (patch)
tree1e12901dd1fb716e53b1918c113c05fbe4c6c751 /src/gui
parent789cb3137fe86fc040d53b16b4736188362028cb (diff)
downloadQt-ceaa577a035607569a6ec8cfab09e4fb35363fd0.zip
Qt-ceaa577a035607569a6ec8cfab09e4fb35363fd0.tar.gz
Qt-ceaa577a035607569a6ec8cfab09e4fb35363fd0.tar.bz2
QGtkStyle: add getIconThemeName() helper function
Add QGtkStyle::getIconThemeName() static helper function (which uses GtkSettings to retrieve the theme name) and use it in QGuiPlatformPlugin::systemIconThemeName() when desktop is GNOME. In modern distributions like Debian and Ubuntu, the /desktop/gnome/interface GConf schema is no longer installed, so the old method for retrieving icon theme name no longer works. Qt 5 already uses GtkSettings for this thing, although the code is in a different place. Change-Id: Ib13d4809b55dd55dc1fa0bc2c4b1552f13feb030 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiplatformplugin.cpp6
-rw-r--r--src/gui/styles/qgtkstyle_p.cpp22
-rw-r--r--src/gui/styles/qgtkstyle_p.h1
3 files changed, 27 insertions, 2 deletions
diff --git a/src/gui/kernel/qguiplatformplugin.cpp b/src/gui/kernel/qguiplatformplugin.cpp
index 01fe089..7063e62 100644
--- a/src/gui/kernel/qguiplatformplugin.cpp
+++ b/src/gui/kernel/qguiplatformplugin.cpp
@@ -204,10 +204,12 @@ QString QGuiPlatformPlugin::systemIconThemeName()
QString result;
#ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_GNOME) {
- result = QString::fromLatin1("gnome");
#ifndef QT_NO_STYLE_GTK
- result = QGtkStylePrivate::getGConfString(QLatin1String("/desktop/gnome/interface/icon_theme"), result);
+ result = QGtkStylePrivate::getIconThemeName();
#endif
+ if (result.isEmpty()) {
+ result = QString::fromLatin1("gnome");
+ }
} else if (X11->desktopEnvironment == DE_KDE) {
result = X11->desktopVersion >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");
QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
index 302cf09..67b3245 100644
--- a/src/gui/styles/qgtkstyle_p.cpp
+++ b/src/gui/styles/qgtkstyle_p.cpp
@@ -686,6 +686,28 @@ QString QGtkStylePrivate::getThemeName()
return themeName;
}
+QString QGtkStylePrivate::getIconThemeName() {
+ if (!gtk_settings_get_default) {
+ // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
+ QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
+ libgtk.setLoadHints(QLibrary::ImprovedSearchHeuristics);
+ gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
+ gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
+ }
+ if (!gtk_settings_get_default) {
+ return QString();
+ }
+ x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
+ gtk_init(NULL, NULL);
+ XSetErrorHandler(qt_x_errhandler);
+ GtkSettings *settings = gtk_settings_get_default();
+ gchararray value;
+ g_object_get(settings, "gtk-icon-theme-name", &value, NULL);
+ QString result = QString::fromUtf8(value);
+ g_free(value);
+ return result;
+}
+
// Get size of the arrow controls in a GtkSpinButton
int QGtkStylePrivate::getSpinboxArrowSize() const
{
diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h
index b4ab589..1be5aa4 100644
--- a/src/gui/styles/qgtkstyle_p.h
+++ b/src/gui/styles/qgtkstyle_p.h
@@ -339,6 +339,7 @@ public:
static QString getGConfString(const QString &key, const QString &fallback = QString());
static QString getThemeName();
+ static QString getIconThemeName();
virtual int getSpinboxArrowSize() const;
static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,