Merge lp:~sil2100/appmenu-qt5/workaround_1306472_icontheme into lp:appmenu-qt5

Proposed by Łukasz Zemczak
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 17
Merged at revision: 17
Proposed branch: lp:~sil2100/appmenu-qt5/workaround_1306472_icontheme
Merge into: lp:appmenu-qt5
Diff against target: 96 lines (+43/-1)
3 files modified
debian/control (+1/-0)
src/appmenuplatformmenubar.cpp (+41/-0)
src/src.pro (+1/-1)
To merge this branch: bzr merge lp:~sil2100/appmenu-qt5/workaround_1306472_icontheme
Reviewer Review Type Date Requested Status
Timo Jyrinki Approve
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+215688@code.launchpad.net

Commit message

When working with a Gnome/GTK theme, do the same thing as the gtk2 platformtheme plugin does - fetch the SystemIconThemeName (and its fallback) from settings in the system

Description of the change

When working with a Gnome/GTK theme, do the same thing as the gtk2 platformtheme plugin does - fetch the SystemIconThemeName (and its fallback) from settings in the system

This is not a perfect solution, as appmenu should not bother with themeing and be only responsible for exporting the menu, delegating everything else to Qt itself.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Looks fine (the signals trick is needed), builds fine and I can't spot any regressions in my usual test cases of Qt Creator and Transmission. Nice!

I'm unsure though how to the test the actual bug, but nothing seems wrong.

review: Approve
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Right... the appmenu-bug git branch. Seems functional now indeed.

review: Approve
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Hey Łukasz, any reason why you used Gtk+ 2.x here, and not Gtk+ 3.x? There are some reasons why Qt itself didn't yet move to Gtk+ 3, but none of them applies to appmenu-qt5.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-02-03 14:51:17 +0000
3+++ debian/control 2014-04-14 15:06:36 +0000
4@@ -14,6 +14,7 @@
5 qtbase5-dev (>= 5.2.0),
6 qtbase5-private-dev (>= 5.2.0),
7 pkg-config,
8+ libgtk2.0-dev,
9 Standards-Version: 3.9.5
10 Homepage: https://launchpad.net/appmenu-qt5
11 # if you don't have have commit access to this branch but would like to upload
12
13=== modified file 'src/appmenuplatformmenubar.cpp'
14--- src/appmenuplatformmenubar.cpp 2014-01-10 16:14:17 +0000
15+++ src/appmenuplatformmenubar.cpp 2014-04-14 15:06:36 +0000
16@@ -32,6 +32,12 @@
17 #include <QMenu>
18 #include <QDebug>
19 #include <QList>
20+#include <QVariant>
21+
22+#undef signals // Needed to make sure we can include gtk.h
23+#include <gtk/gtk.h>
24+#include <X11/Xlib.h>
25+
26
27 #define LOG qDebug() << "appmenu-qt:" << __FUNCTION__ << __LINE__
28 #define LOG_VAR(x) qDebug() << "appmenu-qt:" << __FUNCTION__ << __LINE__ << #x ":" << x
29@@ -210,6 +216,17 @@
30
31 ///////////////////////////////////////////////////////////
32
33+/* Helper function, as copy-pasted from Qt 5.2.1 gtk2 platformthemeplugin */
34+static QString gtkSetting(const gchar *propertyName)
35+{
36+ GtkSettings *settings = gtk_settings_get_default();
37+ gchararray value;
38+ g_object_get(settings, propertyName, &value, NULL);
39+ QString str = QString::fromUtf8(value);
40+ g_free(value);
41+ return str;
42+}
43+
44 /*
45 * The GnomeAppMenuPlatformTheme is a platform theme providing the platform
46 * menubar functionality with the Qt5 QGnomeTheme look
47@@ -217,12 +234,36 @@
48 class GnomeAppMenuPlatformTheme : public QGnomeTheme
49 {
50 public:
51+ GnomeAppMenuPlatformTheme();
52 virtual QPlatformMenuItem* createPlatformMenuItem() const { return 0; }
53 virtual QPlatformMenu* createPlatformMenu() const { return 0; }
54 virtual QPlatformMenuBar* createPlatformMenuBar() const;
55+
56+ virtual QVariant themeHint(QPlatformTheme::ThemeHint hint) const;
57 };
58
59
60+GnomeAppMenuPlatformTheme::GnomeAppMenuPlatformTheme()
61+ : QGnomeTheme()
62+{
63+ int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL);
64+ gtk_init(0, 0);
65+ XSetErrorHandler(oldErrorHandler);
66+}
67+
68+QVariant GnomeAppMenuPlatformTheme::themeHint(QPlatformTheme::ThemeHint hint) const
69+{
70+ switch (hint) {
71+ case QPlatformTheme::SystemIconThemeName:
72+ return QVariant(gtkSetting("gtk-icon-theme-name"));
73+ case QPlatformTheme::SystemIconFallbackThemeName:
74+ return QVariant(gtkSetting("gtk-fallback-icon-theme"));
75+ default:
76+ return QGnomeTheme::themeHint(hint);
77+ }
78+}
79+
80+
81 QPlatformMenuBar *
82 GnomeAppMenuPlatformTheme::createPlatformMenuBar() const
83 {
84
85=== modified file 'src/src.pro'
86--- src/src.pro 2014-01-13 16:53:07 +0000
87+++ src/src.pro 2014-04-14 15:06:36 +0000
88@@ -8,7 +8,7 @@
89 DBUS_INTERFACES += com.canonical.AppMenu.Registrar.xml
90
91 CONFIG += X11 link_pkgconfig debug
92-PKGCONFIG += dbusmenu-qt5
93+PKGCONFIG += dbusmenu-qt5 gtk+-2.0
94 DESTDIR = ./
95
96 HEADERS += \

Subscribers

People subscribed via source and target branches