on xenial help sign in
Moved from_gicon function to IconUtil.js.
commitd83cab97d5453c5e977a8f5542a2b1927ad3f95a authorPawel Stolowski <pawel.stolowski@canonical.com> dateTue 11 Jun 2013, 18:26 (13 years ago) parent06b6406
2 files changed+44−26
Components/IconUtil.js+42 Dash/GenericLensView.qml+2−26
Components/IconUtil.jsnew file+42
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+.pragma library
18+
19+// FIXME: a quick hack to get icons out of gicons and fallback to
20+// base icon for annotated icons. Doesn't correctly handle all icons.
21+// Proper global solution needed.
22+function from_gicon(name) {
23+ var icon_name = name;
24+ var annotated_re = /^. UnityProtocolAnnotatedIcon/;
25+ if (annotated_re.test(name)) {
26+ var base_icon_re = /'base-icon':.+?'(.+?)'/;
27+ var base_icon = name.toString().match(base_icon_re);
28+ icon_name = base_icon[1];
29+ }
30+ else {
31+ var themed_re = /^. GThemedIcon\s*([^\s]+)\s*/;
32+ var themed = name.match(themed_re);
33+ if (themed) {
34+ return "image://gicon/" + themed[1];
35+ }
36+ }
37+ var remote_re = /^http/;
38+ if (remote_re.test(icon_name)) {
39+ return icon_name;
40+ }
41+ return "image://gicon/" + icon_name;
42+}
Dash/GenericLensView.qml+2−26
@@ -18,35 +18,11 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import "../Components"
2020import "../Components/ListItems" as ListItems
21+import "../Components/IconUtil.js" as IconUtil
2122
2223LensView {
2324 id: lensView
2425
25− //FIXME: a quick hack to get icons out of gicons and fallback to
26− //base icon for annotated icons. Doesn't correctly handle all icons.
27− //Proper global solution needed.
28− function from_gicon(name) {
29− var icon_name = name;
30− var annotated_re = /^. UnityProtocolAnnotatedIcon/;
31− if (annotated_re.test(name)) {
32− var base_icon_re = /'base-icon':.+?'(.+?)'/;
33− var base_icon = name.toString().match(base_icon_re);
34− icon_name = base_icon[1];
35− }
36− else {
37− var themed_re = /^. GThemedIcon\s*([^\s]+)\s*/;
38− var themed = name.match(themed_re);
39− if (themed) {
40− return "image://gicon/" + themed[1];
41− }
42− }
43− var remote_re = /^http/;
44− if (remote_re.test(icon_name)) {
45− return icon_name;
46− }
47− return "image://gicon/" + icon_name;
48− }
49−
5026 onIsCurrentChanged: {
5127 pageHeader.resetSearch();
5228 }
@@ -99,7 +75,7 @@ LensView {
9975 text: column_5 ? column_5 : "" // FIXME: this shouldn't be necessary
10076 imageWidth: units.gu(11)
10177 imageHeight: units.gu(16)
102− source: column_1 ? from_gicon(column_1) : "" // FIXME: ditto
78+ source: column_1 ? IconUtil.from_gicon(column_1) : "" // FIXME: ditto
10379 }
10480 }
10581 }