diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2009-09-02 10:56:51 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2009-09-02 10:58:57 (GMT) |
commit | e008ce19585bf607ff652ab95391a890a9523076 (patch) | |
tree | dc7838c85d1ddf3126566b50a672ca16a4faedb2 /src/gui/styles | |
parent | 66fc43343b06575a97b84ad44d70fd3082a6140e (diff) | |
download | Qt-e008ce19585bf607ff652ab95391a890a9523076.zip Qt-e008ce19585bf607ff652ab95391a890a9523076.tar.gz Qt-e008ce19585bf607ff652ab95391a890a9523076.tar.bz2 |
Respect "menus_have_icons" property in GTK+
The default value is planned to be changed in the next minor update to
Gtk+ (2.28), hence we need to read this dynamically now. We also
added a helper-function to easily read a gconf bool.
Note, as a bonus feature I also added support for
"buttons_have_icons".
Task-number: 260684
Reviewed-by: joao
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/gtksymbols.cpp | 19 | ||||
-rw-r--r-- | src/gui/styles/gtksymbols_p.h | 3 | ||||
-rw-r--r-- | src/gui/styles/qgtkstyle.cpp | 5 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index 0d34c77..b61675b 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -194,6 +194,7 @@ Ptr_gdk_x11_drawable_get_xdisplay QGtk::gdk_x11_drawable_get_xdisplay = 0; Ptr_gconf_client_get_default QGtk::gconf_client_get_default = 0; Ptr_gconf_client_get_string QGtk::gconf_client_get_string = 0; +Ptr_gconf_client_get_bool QGtk::gconf_client_get_bool = 0; static QString classPath(GtkWidget *widget) { @@ -336,6 +337,7 @@ static bool resolveGConf() if (!QGtk::gconf_client_get_default) { QGtk::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default"); QGtk::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string"); + QGtk::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool"); } return (QGtk::gconf_client_get_default !=0); } @@ -361,6 +363,23 @@ QString QGtk::getGConfString(const QString &value, const QString &fallback) return retVal; } +bool QGtk::getGConfBool(const QString &key, bool fallback) +{ + bool retVal = fallback; + if (resolveGConf()) { + g_type_init(); + GConfClient* client = QGtk::gconf_client_get_default(); + GError *err = 0; + bool result = QGtk::gconf_client_get_bool(client, qPrintable(key), &err); + g_object_unref(client); + if (!err) + retVal = result; + else + g_error_free (err); + } + return retVal; +} + static QString getThemeName() { QString themeName; diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h index 596a312..fb9d129 100644 --- a/src/gui/styles/gtksymbols_p.h +++ b/src/gui/styles/gtksymbols_p.h @@ -77,6 +77,7 @@ class GConfClient; typedef GConfClient* (*Ptr_gconf_client_get_default)(); typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **); +typedef bool (*Ptr_gconf_client_get_bool)(GConfClient*, const char*, GError **); typedef void (*Ptr_gtk_init)(int *, char ***); typedef GtkWidget* (*Ptr_gtk_window_new) (GtkWindowType); @@ -217,6 +218,7 @@ public: static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); static QString getGConfString(const QString &key, const QString &fallback = QString()); + static bool getGConfBool(const QString &key, bool fallback = 0); static Ptr_gtk_container_forall gtk_container_forall; static Ptr_gtk_init gtk_init; @@ -330,6 +332,7 @@ public: static Ptr_gconf_client_get_default gconf_client_get_default; static Ptr_gconf_client_get_string gconf_client_get_string; + static Ptr_gconf_client_get_bool gconf_client_get_bool; }; // Helper to ensure that we have polished all our gtk widgets diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 87fa322..0ccf219 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -656,6 +656,11 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg return !scrollbars_within_bevel; } + case SH_DialogButtonBox_ButtonsHaveIcons: { + static bool buttonsHaveIcons = QGtk::getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons")); + return buttonsHaveIcons; + } + default: return QCleanlooksStyle::styleHint(hint, option, widget, returnData); } |