diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2013-05-19 11:49:47 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-15 05:14:32 (GMT) |
commit | ceaa577a035607569a6ec8cfab09e4fb35363fd0 (patch) | |
tree | 1e12901dd1fb716e53b1918c113c05fbe4c6c751 /src/gui/styles | |
parent | 789cb3137fe86fc040d53b16b4736188362028cb (diff) | |
download | Qt-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/styles')
-rw-r--r-- | src/gui/styles/qgtkstyle_p.cpp | 22 | ||||
-rw-r--r-- | src/gui/styles/qgtkstyle_p.h | 1 |
2 files changed, 23 insertions, 0 deletions
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, |