Merge lp:~kamstrup/libunity/now-with-more-keywords into lp:libunity

Proposed by Mikkel Kamstrup Erlandsen
Status: Merged
Approved by: Michal Hruby
Approved revision: 122
Merged at revision: 122
Proposed branch: lp:~kamstrup/libunity/now-with-more-keywords
Merge into: lp:libunity
Diff against target: 85 lines (+22/-3)
3 files modified
src/unity-appinfo-manager.vala (+14/-1)
test/data/applications/ubuntu-about.desktop (+2/-0)
test/vala/test-appinfo-manager.vala (+6/-2)
To merge this branch: bzr merge lp:~kamstrup/libunity/now-with-more-keywords
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+94732@code.launchpad.net

Description of the change

Support the new standard XDG 'Keywords' field in desktop files

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Gio dropped support for the gnome-specific key, shouldn't we as well? (http://mail.gnome.org/archives/commits-list/2011-December/msg06472.html)

review: Needs Information
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

I think we should keep it in for backwards compat. It is more or less free efficiency wise. Also - we still ship a truckload of packages using the X-GNOME-Keywords field.

Revision history for this message
Michal Hruby (mhr3) wrote :

Grepping through my /usr/share/applications shows the key to be mostly gone, but yea, there are still a few non-core-gnome apps using it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-appinfo-manager.vala'
2--- src/unity-appinfo-manager.vala 2011-12-06 11:59:22 +0000
3+++ src/unity-appinfo-manager.vala 2012-02-27 09:12:17 +0000
4@@ -389,6 +389,8 @@
5 {
6 string[] gkeywords;
7 string[] akeywords;
8+ string[] xdgkeywords;
9+
10 try {
11 gkeywords = keyfile.get_locale_string_list ("Desktop Entry",
12 "X-GNOME-Keywords");
13@@ -403,9 +405,16 @@
14 /* Unknown key or group. This app has no X-GNOME-Keywords */
15 akeywords = new string[0];
16 }
17+ try {
18+ xdgkeywords = keyfile.get_locale_string_list ("Desktop Entry",
19+ "Keywords");
20+ } catch (KeyFileError e) {
21+ /* Unknown key or group. This app has no standard Keywords */
22+ xdgkeywords = new string[0];
23+ }
24
25 /* Copy the two keyword types into one 'keyword' array */
26- string[] keywords = new string[gkeywords.length + akeywords.length];
27+ string[] keywords = new string[gkeywords.length + akeywords.length + xdgkeywords.length];
28 for (int i = 0; i < gkeywords.length; i++)
29 {
30 keywords[i] = gkeywords[i];
31@@ -414,6 +423,10 @@
32 {
33 keywords[gkeywords.length + i] = akeywords[i];
34 }
35+ for (int i = 0; i < xdgkeywords.length; i++)
36+ {
37+ keywords[gkeywords.length + akeywords.length + i] = xdgkeywords[i];
38+ }
39
40 var wrapper = new StringArrayWrapper();
41 wrapper.take_strings ((owned) keywords);
42
43=== modified file 'test/data/applications/ubuntu-about.desktop'
44--- test/data/applications/ubuntu-about.desktop 2011-09-27 09:48:39 +0000
45+++ test/data/applications/ubuntu-about.desktop 2012-02-27 09:12:17 +0000
46@@ -11,3 +11,5 @@
47 X-Ubuntu-Gettext-Domain=gnome-panel-2.0
48 X-GNOME-Keywords=about;ubuntu;help
49 X-AppInstall-Keywords=testkeyword
50+Keywords=thisisnotthekeywordsyourelookingfor;neitheristhis
51+
52
53=== modified file 'test/vala/test-appinfo-manager.vala'
54--- test/vala/test-appinfo-manager.vala 2011-12-06 11:59:22 +0000
55+++ test/vala/test-appinfo-manager.vala 2012-02-27 09:12:17 +0000
56@@ -108,11 +108,13 @@
57
58 string[]? keywords = manager.get_keywords ("ubuntu-about.desktop");
59 assert (keywords != null);
60- assert (keywords.length == 4);
61+ assert (keywords.length == 6);
62 assert (keywords[0] == "about");
63 assert (keywords[1] == "ubuntu");
64 assert (keywords[2] == "help");
65 assert (keywords[3] == "testkeyword");
66+ assert (keywords[4] == "thisisnotthekeywordsyourelookingfor");
67+ assert (keywords[5] == "neitheristhis");
68
69 string path = manager.get_path ("ubuntu-about.desktop");
70 string abs_path = File.new_for_path(Config.TESTDIR).resolve_relative_path("data/applications/ubuntu-about.desktop").get_path();
71@@ -147,11 +149,13 @@
72
73 string[]? keywords = manager.get_keywords ("ubuntu-about.desktop");
74 assert (keywords != null);
75+ assert (keywords.length == 6);
76 assert (keywords[0] == "about");
77 assert (keywords[1] == "ubuntu");
78 assert (keywords[2] == "help");
79 assert (keywords[3] == "testkeyword");
80- assert (keywords.length == 4);
81+ assert (keywords[4] == "thisisnotthekeywordsyourelookingfor");
82+ assert (keywords[5] == "neitheristhis");
83
84 string path = manager.get_path ("ubuntu-about.desktop");
85 string abs_path = File.new_for_path(Config.TESTDIR).resolve_relative_path("data/applications/ubuntu-about.desktop").get_path();

Subscribers

People subscribed via source and target branches