Merge lp:~macslow/ubuntu-ui-toolkit/add-search-path-to-giconprovider into lp:ubuntu-ui-toolkit

Proposed by Mirco Müller
Status: Rejected
Rejected by: Zoltan Balogh
Proposed branch: lp:~macslow/ubuntu-ui-toolkit/add-search-path-to-giconprovider
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 148 lines (+75/-2)
4 files modified
debian/control (+1/-0)
examples/ubuntu-ui-toolkit-gallery/Icons.qml (+26/-0)
modules/Ubuntu/Components/plugin/giconprovider.cpp (+47/-1)
modules/Ubuntu/Components/plugin/plugin.pro (+1/-1)
To merge this branch: bzr merge lp:~macslow/ubuntu-ui-toolkit/add-search-path-to-giconprovider
Reviewer Review Type Date Requested Status
Michał Sawicz Disapprove
PS Jenkins bot continuous-integration Approve
Review via email: mp+164197@code.launchpad.net

Commit message

Extended GIconProvider to allow loading notification-specific icons. With this QML's Icon- and Image-elements can load and display the typical symbolic NotifyOSD-icons, if they are installed.

Description of the change

Extended GIconProvider to allow loading notification-specific icons. With this QML's Icon- and Image-elements can load and display the typical symbolic NotifyOSD-icons, if they are installed.

See the extended Icons-tab from the gallery... http://ubuntuone.com/3OVYWD5HRlFxLfWHQLS48d

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) wrote :

A test for this would be useful. Either way, how do you expect to use it from QML?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:495
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~macslow/ubuntu-ui-toolkit/add-search-path-to-giconprovider/+merge/164197/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/64/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-raring-amd64-ci/64/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-raring-armhf-ci/64/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/ubuntu-ui-toolkit-ci/64/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mirco Müller (macslow) wrote :

Doh! I forgot to set it to "Work in progress". More pieces are coming still.

Revision history for this message
Mirco Müller (macslow) wrote :

See for the extended Icons-example of the gallery... http://ubuntuone.com/3OVYWD5HRlFxLfWHQLS48d

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
498. By Mirco Müller

Add gtk+-3.0 build-dependency because of GtkIconTheme calls

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
499. By Mirco Müller

Re-merged with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

My 2¢ here - I'm not liking the fact that we just hardcode the path :/.

I wonder if supporting a "image://gicon/custom/path/to/icons/name" instead would give us more flexibility?

I'm also unsure about the complexity of the scaling code (and does FORCE_SVG mean it will only load SVG icons?). The original provider code does not seem to do as much?

review: Needs Information
Revision history for this message
Cris Dywan (kalikiana) wrote :

Why isn't the icon path in the theme? Hard-coding themed icon paths is an oxymoron in my book.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

guys, AFAIK giconprovider will be replaced by unity-theme-icon-provider:
https://code.launchpad.net/~larsu/ubuntu-ui-toolkit/add-unity-theme-icon-provider/+merge/179011

Let's figure this out some how. AFAIK the only thing we need to add to unity-theme-icon-provider is to add
/usr/share/notify-osd/icons to default search path. notify-OSD icons seem to follow xdg theming already.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :
Revision history for this message
Michał Sawicz (saviq) wrote :

I'm not even sure we need this anymore. Is there any reason why we should support a custom path for themed icons?

review: Disapprove

Unmerged revisions

499. By Mirco Müller

Re-merged with trunk

498. By Mirco Müller

Add gtk+-3.0 build-dependency because of GtkIconTheme calls

497. By Mirco Müller

Correctly load SVG-icon and scale it according to requested-size while preserving initial aspect-ratio of icon/image

496. By Mirco Müller

Trying a different approach to get notify-osd icons to load.

495. By Mirco Müller

Added support for extending the icon-theme search path of GIconProvider.

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 2013-05-23 07:43:46 +0000
3+++ debian/control 2013-05-31 08:38:24 +0000
4@@ -5,6 +5,7 @@
5 Build-Depends: debhelper (>= 9.0.0),
6 libgles2-mesa-dev,
7 libglib2.0-dev,
8+ libgtk-3-dev,
9 python,
10 libqt5qml-graphicaleffects | libqt5graphicaleffects5,
11 qt5-default,
12
13=== modified file 'examples/ubuntu-ui-toolkit-gallery/Icons.qml'
14--- examples/ubuntu-ui-toolkit-gallery/Icons.qml 2013-04-24 17:09:29 +0000
15+++ examples/ubuntu-ui-toolkit-gallery/Icons.qml 2013-05-31 08:38:24 +0000
16@@ -22,6 +22,32 @@
17 className: "Icon"
18
19 TemplateRow {
20+ title: i18n.tr("NotifyOSD")
21+ spacing: units.gu(2)
22+
23+ Icon {
24+ name: "notification-message-im"
25+ width: 32
26+ height: 32
27+ anchors.verticalCenter: parent.verticalCenter
28+ }
29+
30+ Icon {
31+ name: "notification-message-email"
32+ width: 96
33+ height: 96
34+ anchors.verticalCenter: parent.verticalCenter
35+ }
36+
37+ Icon {
38+ name: "notification-audio-play"
39+ width: 48
40+ height: 48
41+ anchors.verticalCenter: parent.verticalCenter
42+ }
43+ }
44+
45+ TemplateRow {
46 title: i18n.tr("Scaling")
47 spacing: units.gu(2)
48
49
50=== modified file 'modules/Ubuntu/Components/plugin/giconprovider.cpp'
51--- modules/Ubuntu/Components/plugin/giconprovider.cpp 2012-11-28 13:21:48 +0000
52+++ modules/Ubuntu/Components/plugin/giconprovider.cpp 2013-05-31 08:38:24 +0000
53@@ -21,9 +21,11 @@
54 #include <QtCore/QDebug>
55 #include <QtCore/QFile>
56 #include <QtGui/QIcon>
57+#include <QPainter>
58
59 extern "C" {
60 #include <gio/gio.h>
61+#include <gtk/gtk.h>
62 }
63
64 /*
65@@ -55,6 +57,8 @@
66 : QQuickImageProvider(QQuickImageProvider::Image)
67 {
68 g_type_init();
69+ gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
70+ "/usr/share/notify-osd/icons");
71 }
72
73 QImage GIconProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
74@@ -63,6 +67,7 @@
75 QByteArray utf8Name = QUrl::fromPercentEncoding(id.toUtf8()).toUtf8();
76 GError *error = NULL;
77 GIcon *icon = g_icon_new_for_string(utf8Name.data(), &error);
78+
79 if (error) {
80 qWarning() << "Fail to load icon: " << id << error->message;
81 g_error_free(error);
82@@ -78,7 +83,47 @@
83 result = themedIcon.pixmap(themedIcon.availableSizes().last());
84 }
85 } else {
86- qDebug() << "Fail to load themed icon for:" << id;
87+ GtkIconInfo* info = NULL;
88+ info = gtk_icon_theme_lookup_by_gicon(gtk_icon_theme_get_default(),
89+ icon,
90+ requestedSize.width(),
91+ GTK_ICON_LOOKUP_FORCE_SVG);
92+ if (info) {
93+ // obtain filename and clean-up GObject/gtk+ pieces
94+ const gchar* iconName = NULL;
95+ iconName = gtk_icon_info_get_filename(info); // not ref'ed
96+ QImage image = QImage(iconName);
97+ gtk_icon_info_free(info);
98+ g_object_unref(icon);
99+
100+ // create paint-device
101+ QPixmap target = QPixmap(requestedSize);
102+ target.fill(Qt::transparent);
103+ QPainter painter(&target);
104+
105+ // scale original image preserving aspect-ratio
106+ int width = image.width();
107+ int height = image.height();
108+ QImage scaledImage;
109+ if (width > height) {
110+ scaledImage = image.scaledToWidth(requestedSize.width(),
111+ Qt::SmoothTransformation);
112+ } else {
113+ scaledImage = image.scaledToHeight(requestedSize.height(),
114+ Qt::SmoothTransformation);
115+ }
116+
117+ // determine offset and render scaled image
118+ width = scaledImage.width();
119+ height = scaledImage.height();
120+ QPoint offset(abs(width - requestedSize.width()) / 2,
121+ abs(height - requestedSize.height()) / 2);
122+ painter.drawImage(offset, scaledImage);
123+
124+ return target.toImage();
125+ } else {
126+ qDebug() << "Fail to load themed icon for:" << id;
127+ }
128 }
129 } else if (G_IS_FILE_ICON(icon)) {
130 gchar *iconName = g_icon_to_string(icon);
131@@ -100,3 +145,4 @@
132 *size = result.size();
133 return result.toImage();
134 }
135+
136
137=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
138--- modules/Ubuntu/Components/plugin/plugin.pro 2013-05-21 11:06:55 +0000
139+++ modules/Ubuntu/Components/plugin/plugin.pro 2013-05-31 08:38:24 +0000
140@@ -2,7 +2,7 @@
141
142 unix {
143 CONFIG += link_pkgconfig
144- PKGCONFIG += gio-2.0
145+ PKGCONFIG += gio-2.0 gtk+-3.0
146 }
147
148 TEMPLATE = lib

Subscribers

People subscribed via source and target branches

to status/vote changes: