on xenial help sign in
Switch from image://gicon to image://theme
ea43c0bMichael Terry
Components/IconUtil.js+4−4
@@ -25,17 +25,17 @@ function from_gicon(name) {
25 if (annotated_re.test(name)) {
25 if (annotated_re.test(name)) {
26 var base_icon_re = /'base-icon':.+?'(.+?)'/;
26 var base_icon_re = /'base-icon':.+?'(.+?)'/;
27 var base_icon = name.toString().match(base_icon_re);
27 var base_icon = name.toString().match(base_icon_re);
28− icon_name = base_icon[1];
28+ return from_gicon(unescape(base_icon[1]));
29 } else {
29 } else {
30− var themed_re = /^. GThemedIcon\s*([^\s]+)\s*/;
30+ var themed_re = /^. GThemedIcon (.+)/;
31 var themed = name.match(themed_re);
31 var themed = name.match(themed_re);
32 if (themed) {
32 if (themed) {
33− return "image://gicon/" + themed[1];
33+ return "image://theme/" + themed[1].replace(" ", ",");
34 }
34 }
35 }
35 }
36 var name_re = /^[a-z0-9\._-]+$/;
36 var name_re = /^[a-z0-9\._-]+$/;
37 if (name_re.test(icon_name)) {
37 if (name_re.test(icon_name)) {
38− return "image://gicon/" + icon_name;
38+ return "image://theme/" + icon_name;
39 } else {
39 } else {
40 return icon_name;
40 return icon_name;
41 }
41 }
Panel/Indicators/DefaultIndicatorWidget.qml+1−1
@@ -74,7 +74,7 @@ Indicators.IndicatorWidget {
74 }
74 }
75
75
76 label = action.state[Indicators.ActionState.Label];
76 label = action.state[Indicators.ActionState.Label];
77− iconSource = "image://gicon/" + action.state[Indicators.ActionState.IconSource];
77+ iconSource = "image://theme/" + action.state[Indicators.ActionState.IconSource];
78 enabled = action.state[Indicators.ActionState.Visible];
78 enabled = action.state[Indicators.ActionState.Visible];
79 }
79 }
80}
80}
Panel/Indicators/MessagingIndicatorWidget.qml+1−1
@@ -21,5 +21,5 @@ import QtQuick 2.0
21
21
22DefaultIndicatorWidget {
22DefaultIndicatorWidget {
23 // default the icon so we have something to show when we don't have the bus.
23 // default the icon so we have something to show when we don't have the bus.
24− iconSource: "image://gicon/indicator-messages"
24+ iconSource: "image://theme/indicator-messages"
25}
25}
Panel/Indicators/NetworkIndicatorWidget.qml+6−6
@@ -94,16 +94,16 @@ Indicators.IndicatorWidget {
94 function get_icon_for_signal(con_state, value) {
94 function get_icon_for_signal(con_state, value) {
95 if (con_state >= Indicators.NetworkConnection.Activating && con_state <= Indicators.NetworkConnection.Deactivating) {
95 if (con_state >= Indicators.NetworkConnection.Activating && con_state <= Indicators.NetworkConnection.Deactivating) {
96 if (value == 0) {
96 if (value == 0) {
97− return "image://gicon/nm-signal-00";
97+ return "image://theme/nm-signal-00";
98 } else if (value <= 25) {
98 } else if (value <= 25) {
99− return "image://gicon/nm-signal-25";
99+ return "image://theme/nm-signal-25";
100 } else if (value <= 50) {
100 } else if (value <= 50) {
101− return "image://gicon/nm-signal-50";
101+ return "image://theme/nm-signal-50";
102 } else if (value <= 75) {
102 } else if (value <= 75) {
103− return "image://gicon/nm-signal-75";
103+ return "image://theme/nm-signal-75";
104 }
104 }
105− return "image://gicon/nm-signal-100";
105+ return "image://theme/nm-signal-100";
106 }
106 }
107− return "image://gicon/wifi-none";
107+ return "image://theme/wifi-none";
108 }
108 }
109}
109}
Panel/Indicators/SoundIndicatorWidget.qml+1−1
@@ -21,5 +21,5 @@ import QtQuick 2.0
21
21
22DefaultIndicatorWidget {
22DefaultIndicatorWidget {
23 // default the icon so we have something to show when we don't have the bus.
23 // default the icon so we have something to show when we don't have the bus.
24− iconSource: "image://gicon/audio-volume-high"
24+ iconSource: "image://theme/audio-volume-high"
25}
25}
debian/control+2−2
@@ -53,7 +53,7 @@ Vcs-Browser: https://bazaar.launchpad.net/~unity-team/unity8/trunk
53Package: indicators-client
53Package: indicators-client
54Architecture: amd64 armhf i386
54Architecture: amd64 armhf i386
55Depends: qmenumodel-qml (>= 0.2.7),
55Depends: qmenumodel-qml (>= 0.2.7),
56− qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
56+ qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.46+13.10.20130829.1-0ubuntu1),
57 unity8 (= ${binary:Version}),
57 unity8 (= ${binary:Version}),
58 ${misc:Depends},
58 ${misc:Depends},
59 ${shlibs:Depends},
59 ${shlibs:Depends},
@@ -67,7 +67,7 @@ Depends: gsettings-desktop-schemas,
67 qmenumodel-qml (>= 0.2.7),
67 qmenumodel-qml (>= 0.2.7),
68 qtdeclarative5-dee-plugin,
68 qtdeclarative5-dee-plugin,
69 qtdeclarative5-gsettings1.0,
69 qtdeclarative5-gsettings1.0,
70− qtdeclarative5-ubuntu-ui-toolkit-plugin,
70+ qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.46+13.10.20130829.1-0ubuntu1),
71 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
71 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
72 qtdeclarative5-xmllistmodel-plugin,
72 qtdeclarative5-xmllistmodel-plugin,
73 unity-launcher-impl-2,
73 unity-launcher-impl-2,
plugins/Unity/Indicators/Network/qml/AccessPoint.qml+1−1
@@ -55,7 +55,7 @@ Indicators.FramedMenuItem {
55 if (secure) {
55 if (secure) {
56 imageName += "-secure";
56 imageName += "-secure";
57 }
57 }
58− return "image://gicon/" + imageName;
58+ return "image://theme/" + imageName;
59 }
59 }
60
60
61 iconFrame: false
61 iconFrame: false
plugins/Unity/Indicators/rootactionstate.cpp+8−8
@@ -141,15 +141,15 @@ static QString iconUri(GIcon *icon)
141 QString uri;
141 QString uri;
142
142
143 if (G_IS_THEMED_ICON (icon)) {
143 if (G_IS_THEMED_ICON (icon)) {
144−
145 const gchar* const* iconNames = g_themed_icon_get_names (G_THEMED_ICON (icon));
144 const gchar* const* iconNames = g_themed_icon_get_names (G_THEMED_ICON (icon));
146− guint index = 0;
145+
146+ QStringList iconNameList;
147− while(iconNames[index] != NULL) {
147+ for (guint index = 0; iconNames[index] != NULL; index++) {
148− if (QIcon::hasThemeIcon(iconNames[index])) {
148+ iconNameList << iconNames[index];
149+ }
150+
151+ if (!iconNameList.empty()) {
149− uri = QString("image://theme/%1").arg(iconNames[index]);
152+ uri = QString("image://theme/%1").arg(iconNameList.join(","));
150− break;
151− }
152− index++;
153 }
153 }
154 }
154 }
155 else if (G_IS_FILE_ICON (icon)) {
155 else if (G_IS_FILE_ICON (icon)) {
plugins/Unity/IndicatorsLegacy/Messaging/qml/GroupedMessage.qml+1−1
@@ -44,7 +44,7 @@ Indicators.BasicMenuItem {
44 height: units.gu(6)
44 height: units.gu(6)
45 width: units.gu(6)
45 width: units.gu(6)
46 image: Image {
46 image: Image {
47− source: menu && (menu.extra.canonical_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_app.svg"
47+ source: menu && (menu.extra.canonical_icon.length > 0) ? "image://theme/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_app.svg"
48 fillMode: Image.PreserveAspectFit
48 fillMode: Image.PreserveAspectFit
49 }
49 }
50 }
50 }
plugins/Unity/IndicatorsLegacy/Messaging/qml/HeroMessage.qml+2−2
@@ -48,8 +48,8 @@ Indicators.BasicMenuItem {
48 anchors.left: parent.left
48 anchors.left: parent.left
49 anchors.right: parent.right
49 anchors.right: parent.right
50
50
51− avatar: menu && (menu.extra.canonical_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_contact.png"
51+ avatar: menu && (menu.extra.canonical_icon.length > 0) ? "image://theme/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_contact.png"
52− icon: menu && (menu.extra.canonical_app_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_app_icon) : ""
52+ icon: menu && (menu.extra.canonical_app_icon.length > 0) ? "image://theme/" + encodeURI(menu.extra.canonical_app_icon) : ""
53 appIcon: icon
53 appIcon: icon
54
54
55 state: heroMessage.state
55 state: heroMessage.state
plugins/Unity/IndicatorsLegacy/Network/qml/AccessPoint.qml+2−2
@@ -47,10 +47,10 @@ Indicators.MenuItem {
47 imageName += "-secure";
47 imageName += "-secure";
48 }
48 }
49
49
50− return "image://gicon/" + imageName;
50+ return "image://theme/" + imageName;
51 }
51 }
52
52
53− icon: menu && wifiApStrength ? getNetworkIcon(menu) : "image://gicon/wifi-none"
53+ icon: menu && wifiApStrength ? getNetworkIcon(menu) : "image://theme/wifi-none"
54 iconFrame: false
54 iconFrame: false
55 control: CheckBox {
55 control: CheckBox {
56 id: checkBoxActive
56 id: checkBoxActive
plugins/Unity/Launcher/backend/launcherbackend.cpp+1−1
@@ -99,7 +99,7 @@ QString LauncherBackend::icon(const QString &appId) const
99 if (!iconName.isEmpty()) {
99 if (!iconName.isEmpty()) {
100 QFileInfo iconFileInfo(iconName);
100 QFileInfo iconFileInfo(iconName);
101 if (iconFileInfo.isRelative()) {
101 if (iconFileInfo.isRelative()) {
102− iconName = "image://gicon/" + iconName;
102+ iconName = "image://theme/" + iconName;
103 }
103 }
104 }
104 }
105
105
tests/plugins/Unity/Launcher/launcherbackendtest.cpp+2−2
@@ -46,7 +46,7 @@ private Q_SLOTS:
46 LauncherBackend backend(false);
46 LauncherBackend backend(false);
47
47
48 QCOMPARE(backend.displayName(SRCDIR "/rel-icon.desktop"), QString("Relative Icon"));
48 QCOMPARE(backend.displayName(SRCDIR "/rel-icon.desktop"), QString("Relative Icon"));
49− QCOMPARE(backend.icon(SRCDIR "/rel-icon.desktop"), QString("image://gicon/rel-icon"));
49+ QCOMPARE(backend.icon(SRCDIR "/rel-icon.desktop"), QString("image://theme/rel-icon"));
50
50
51 QCOMPARE(backend.displayName(SRCDIR "/abs-icon.desktop"), QString("Absolute Icon"));
51 QCOMPARE(backend.displayName(SRCDIR "/abs-icon.desktop"), QString("Absolute Icon"));
52 QCOMPARE(backend.icon(SRCDIR "/abs-icon.desktop"), QString("/path/to/icon.png"));
52 QCOMPARE(backend.icon(SRCDIR "/abs-icon.desktop"), QString("/path/to/icon.png"));
@@ -55,7 +55,7 @@ private Q_SLOTS:
55 QCOMPARE(backend.icon(SRCDIR "/no-icon.desktop"), QString(""));
55 QCOMPARE(backend.icon(SRCDIR "/no-icon.desktop"), QString(""));
56
56
57 QCOMPARE(backend.displayName(SRCDIR "/no-name.desktop"), QString(""));
57 QCOMPARE(backend.displayName(SRCDIR "/no-name.desktop"), QString(""));
58− QCOMPARE(backend.icon(SRCDIR "/no-name.desktop"), QString("image://gicon/no-name"));
58+ QCOMPARE(backend.icon(SRCDIR "/no-name.desktop"), QString("image://theme/no-name"));
59
59
60 QCOMPARE(backend.displayName(SRCDIR "/no-exist.desktop"), QString(""));
60 QCOMPARE(backend.displayName(SRCDIR "/no-exist.desktop"), QString(""));
61 QCOMPARE(backend.icon(SRCDIR "/no-exist.desktop"), QString(""));
61 QCOMPARE(backend.icon(SRCDIR "/no-exist.desktop"), QString(""));
tests/qmltests/CMakeLists.txt+1
@@ -14,6 +14,7 @@ set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
14add_qml_test(Components AnimationControllerWithSignals)
14add_qml_test(Components AnimationControllerWithSignals)
15add_qml_test(Components Carousel)
15add_qml_test(Components Carousel)
16add_qml_test(Components CrossFadeImage)
16add_qml_test(Components CrossFadeImage)
17+add_qml_test(Components IconUtil)
17add_qml_test(Components MathLocal)
18add_qml_test(Components MathLocal)
18add_qml_test(Components OpenEffect)
19add_qml_test(Components OpenEffect)
19add_qml_test(Components RatingStars)
20add_qml_test(Components RatingStars)
tests/qmltests/Components/tst_IconUtil.qmlnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright 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+import QtQuick 2.0
18+import QtTest 1.0
19+import "../../../Components/IconUtil.js" as IconUtil
20+
21+TestCase {
22+ id: root
23+ name: "IconUtil"
24+
25+ function test_from_gicon_data() {
26+ return [ {in: ". GThemedIcon one", out: "image://theme/one"},
27+ {in: ". GThemedIcon one two", out: "image://theme/one,two"},
28+ {in: ". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'.%20GThemedIcon%20one%20two'%3E%7D", out: "image://theme/one,two"},
29+ {in: "icon.test_0-name", out: "image://theme/icon.test_0-name"},
30+ {in: "?^713]p", out: "?^713]p"},
31+ ]
32+ }
33+
34+ function test_from_gicon(data) {
35+ var out = IconUtil.from_gicon(data.in)
36+ compare(out, data.out)
37+ }
38+}