Merge lp:~alecu/unity-scope-click/non-click-icons into lp:unity-scope-click

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 138
Merged at revision: 150
Proposed branch: lp:~alecu/unity-scope-click/non-click-icons
Merge into: lp:unity-scope-click
Prerequisite: lp:~diegosarmentero/unity-scope-click/allthe-previews
Diff against target: 115 lines (+48/-7)
3 files modified
scope/click/interface.cpp (+29/-4)
scope/click/interface.h (+2/-0)
scope/tests/test_interface.cpp (+17/-3)
To merge this branch: bzr merge lp:~alecu/unity-scope-click/non-click-icons
Reviewer Review Type Date Requested Status
Thomas Voß (community) Needs Fixing
PS Jenkins bot continuous-integration Approve
dobey (community) Approve
Roberto Alsina (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+206804@code.launchpad.net

This proposal supersedes a proposal from 2014-02-13.

Commit message

Add the icon://theme/ prefix when the icon does not specify a path

To post a comment you must log in.
Revision history for this message
dobey (dobey) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Thomas Voß (thomas-voss) wrote : Posted in a previous version of this proposal

While the code looks fine in general, I'm concerned with click::Interface becoming a kitchen sink here. As far as I understand it, is_icon_identifier and add_theme_scheme could be free functions living in a namespace click::util.

What do you think?

review: Needs Information
Revision history for this message
dobey (dobey) wrote : Posted in a previous version of this proposal

> While the code looks fine in general, I'm concerned with click::Interface
> becoming a kitchen sink here. As far as I understand it, is_icon_identifier
> and add_theme_scheme could be free functions living in a namespace
> click::util.
>
> What do you think?

Unless there is a significant performance improvement that would result from this, I don't think we should block the branch on this. It's not public API (we're not a shared library that others can/should use), and we can refactor it later. I don't foresee any other code in the scope needing these calls though, so I don't think there would be any benefit to utility or style by moving it, either.

Revision history for this message
Thomas Voß (thomas-voss) wrote : Posted in a previous version of this proposal

> > While the code looks fine in general, I'm concerned with click::Interface
> > becoming a kitchen sink here. As far as I understand it, is_icon_identifier
> > and add_theme_scheme could be free functions living in a namespace
> > click::util.
> >
> > What do you think?
>
> Unless there is a significant performance improvement that would result from
> this, I don't think we should block the branch on this. It's not public API
> (we're not a shared library that others can/should use), and we can refactor
> it later. I don't foresee any other code in the scope needing these calls
> though, so I don't think there would be any benefit to utility or style by
> moving it, either.

I disagree and I was not referring to performance improvements here. However, for the sake of landing this, I abstain.

review: Abstain
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomas Voß (thomas-voss) wrote :

l. 88/89: The signature of EXPECT_EQ reads EXPECT_EQ(expected, actual). Please change the parameter ordering accordingly.

review: Needs Fixing
139. By Alejandro J. Cura

Fix EXPECTED_EQ order

Revision history for this message
Alejandro J. Cura (alecu) wrote :

> l. 88/89: The signature of EXPECT_EQ reads EXPECT_EQ(expected, actual). Please
> change the parameter ordering accordingly.

done

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scope/click/interface.cpp'
2--- scope/click/interface.cpp 2014-02-18 07:06:13 +0000
3+++ scope/click/interface.cpp 2014-02-18 07:06:13 +0000
4@@ -108,8 +108,9 @@
5 QString app_url = "application:///" + QString::fromStdString(filename);
6 app.url = app_url.toUtf8().data();
7 app.title = name.toUtf8().data();
8- app.icon_url = keyFile.get_string(DESKTOP_FILE_GROUP,
9- DESKTOP_FILE_KEY_ICON);
10+ app.icon_url = Interface::add_theme_scheme(
11+ keyFile.get_string(DESKTOP_FILE_GROUP,
12+ DESKTOP_FILE_KEY_ICON));
13 if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_APP_ID)) {
14 QString app_id = QString::fromStdString(keyFile.get_string(
15 DESKTOP_FILE_GROUP,
16@@ -152,6 +153,29 @@
17 return click::nonClickDesktopFiles().count(filename.toUtf8().data()) > 0;
18 }
19
20+/*
21+ * is_icon_identifier()
22+ *
23+ * Checks if @filename has no / in it
24+ */
25+bool Interface::is_icon_identifier(const std::string &icon_id)
26+{
27+ return icon_id.find("/") == std::string::npos;
28+}
29+
30+/*
31+ * add_theme_scheme()
32+ *
33+ * Adds the theme prefix if the filename is not an icon identifier
34+ */
35+std::string Interface::add_theme_scheme(const std::string& icon_id)
36+{
37+ if (is_icon_identifier(icon_id)) {
38+ return "image://theme/" + icon_id;
39+ }
40+ return icon_id;
41+}
42+
43 /* find_apps_in_dir()
44 *
45 * Finds all the apps in the specified @dir_path, which also match
46@@ -181,8 +205,9 @@
47 QString app_url = "application:///" + filename;
48 app.url = app_url.toUtf8().data();
49 app.title = name.toUtf8().data();
50- app.icon_url = keyfile.get_string(DESKTOP_FILE_GROUP,
51- DESKTOP_FILE_KEY_ICON);
52+ app.icon_url = Interface::add_theme_scheme(
53+ keyfile.get_string(DESKTOP_FILE_GROUP,
54+ DESKTOP_FILE_KEY_ICON));
55 if (keyfile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_UBUNTU_TOUCH)) {
56 app.description = keyfile.get_string(DESKTOP_FILE_GROUP,
57 DESKTOP_FILE_COMMENT);
58
59=== modified file 'scope/click/interface.h'
60--- scope/click/interface.h 2014-02-11 13:54:39 +0000
61+++ scope/click/interface.h 2014-02-18 07:06:13 +0000
62@@ -59,6 +59,8 @@
63 const QString& search_query,
64 std::vector<Application>& result_list);
65
66+ static bool is_icon_identifier(const std::string &icon_id);
67+ static std::string add_theme_scheme(const std::string &filename);
68 private:
69 QSharedPointer<KeyFileLocator> keyFileLocator;
70 };
71
72=== modified file 'scope/tests/test_interface.cpp'
73--- scope/tests/test_interface.cpp 2014-02-18 07:06:13 +0000
74+++ scope/tests/test_interface.cpp 2014-02-18 07:06:13 +0000
75@@ -111,6 +111,20 @@
76 EXPECT_TRUE(results.empty());
77 }
78
79+TEST(ClickInterface, testIsIconIdentifier)
80+{
81+ EXPECT_TRUE(Interface::is_icon_identifier("contacts-app"));
82+ EXPECT_FALSE(Interface::is_icon_identifier(
83+ "/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png"));
84+}
85+
86+TEST(ClickInterface, testAddThemeScheme)
87+{
88+ EXPECT_EQ("image://theme/contacts-app", Interface::add_theme_scheme("contacts-app"));
89+ EXPECT_EQ("/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png",
90+ Interface::add_theme_scheme("/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png"));
91+}
92+
93 // TODO: Get rid of file-based testing and instead make unity::util::IniParser mockable
94 // Maintaining this list here will become tedious over time.
95 TEST(ClickInterface, findInstalledAppsReturnsCorrectListOfResults)
96@@ -127,7 +141,7 @@
97 {"com.ubuntu.developer.webapps.webapp-gmail", "Gmail", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-gmail/./gmail.png", "application:///com.ubuntu.developer.webapps.webapp-gmail_webapp-gmail_1.0.8.desktop", "", ""},
98 {"com.ubuntu.terminal", "Terminal", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.terminal/./terminal64.png", "application:///com.ubuntu.terminal_terminal_0.5.29.desktop", "", ""},
99 {"com.ubuntu.calendar", "Calendar", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calendar/./calendar64.png", "application:///com.ubuntu.calendar_calendar_0.4.182.desktop", "", ""},
100- {"com.ubuntu.notes", "Notes", "", "notepad", "application:///com.ubuntu.notes_notes_1.4.242.desktop", "", ""},
101+ {"com.ubuntu.notes", "Notes", "", "image://theme/notepad", "application:///com.ubuntu.notes_notes_1.4.242.desktop", "", ""},
102 {"com.ubuntu.developer.webapps.webapp-amazon", "Amazon", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-amazon/./amazon.png", "application:///com.ubuntu.developer.webapps.webapp-amazon_webapp-amazon_1.0.6.desktop", "", ""},
103 {"com.ubuntu.shorts", "Shorts", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.shorts/./rssreader64.png", "application:///com.ubuntu.shorts_shorts_0.2.162.desktop", "", ""},
104 {"com.ubuntu.filemanager", "File Manager", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager/./filemanager64.png", "application:///com.ubuntu.filemanager_filemanager_0.1.1.97.desktop", "", ""},
105@@ -135,8 +149,8 @@
106 {"com.ubuntu.sudoku", "Sudoku", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.sudoku/SudokuGameIcon.png", "application:///com.ubuntu.sudoku_sudoku_1.0.142.desktop", "", ""},
107 {"com.ubuntu.developer.webapps.webapp-ebay", "eBay", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-ebay/./ebay.png", "application:///com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay_1.0.8.desktop", "", ""},
108 {"com.ubuntu.developer.webapps.webapp-facebook", "Facebook", "", "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-facebook/./facebook.png", "application:///com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook_1.0.5.desktop", "", ""},
109- {"", "Messaging", "", "messages-app", "application:///messaging-app.desktop", "", ""},
110- {"", "Contacts", "", "contacts-app", "application:///address-book-app.desktop", "", ""}
111+ {"", "Messaging", "", "image://theme/messages-app", "application:///messaging-app.desktop", "", ""},
112+ {"", "Contacts", "", "image://theme/contacts-app", "application:///address-book-app.desktop", "", ""}
113 };
114
115 click::Application mustNotBePartOfResult

Subscribers

People subscribed via source and target branches