Merge lp:~gero-bare/slingshot/add_search_for_keyword into lp:~elementary-pantheon/slingshot/trunk

Proposed by Gero.Bare on 2016-05-31
Status: Rejected
Rejected by: Adam Bieńkowski on 2016-07-18
Proposed branch: lp:~gero-bare/slingshot/add_search_for_keyword
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 129 lines (+48/-2)
4 files modified
CMakeLists.txt (+12/-2)
lib/synapse-core/CMakeLists.txt (+3/-0)
lib/synapse-core/desktop-file-service.vala (+8/-0)
lib/synapse-plugins/desktop-file-plugin.vala (+25/-0)
To merge this branch: bzr merge lp:~gero-bare/slingshot/add_search_for_keyword
Reviewer Review Type Date Requested Status
elementary Pantheon team 2016-05-31 Pending
Review via email: mp+296097@code.launchpad.net

Description of the change

Add support for search for keywords.

Due the fact that gio-unix had the definition broken for AppInfo.get_keyword this was blocking me, but apparently this will be fixed soon.

In case of having vala > 0.32.0 or vala > 0.30.1 this should work out of the box, if not we can rely on unity.

To post a comment you must log in.
Adam Bieńkowski (donadigo) wrote :

Marking as rejected as the bug is already fixed.

Unmerged revisions

658. By Gero.Bare on 2016-05-31

Add search for keyword using Appinfo.

It's necesary have vala > 0.32.0, or vala > 0.30.1 to compile using AppInfo.get_keywords
for previus version you can use unity.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-11-25 05:52:20 +0000
3+++ CMakeLists.txt 2016-05-31 11:10:42 +0000
4@@ -63,8 +63,7 @@
5 # Load PkgConfig
6 find_package (PkgConfig)
7
8-# Check for Vala
9-
10+
11 pkg_check_modules(PLANK011 QUIET plank>=0.10.9)
12 if (PLANK011_FOUND)
13 set (PLANK_DEPS plank)
14@@ -82,10 +81,21 @@
15
16 pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)
17
18+# Check for Vala
19 find_package (Vala REQUIRED)
20 include (ValaVersion)
21 ensure_vala_version ("0.26.2" MINIMUM)
22
23+pkg_check_modules(VALA_0_32_1 QUIET vala>=0.32.0)
24+if (VALA_0_32_1_FOUND)
25+ set (DESKTOPINFO_OPTIONS --define=HAS_FIX_DESKTOPINFO)
26+else ()
27+ pkg_check_modules(PLANK QUIET vala>=0.30.0)
28+ if (VALA_0_30_2_FOUND)
29+ set (DESKTOPINFO_OPTIONS --define=HAS_FIX_DESKTOPINFO)
30+ endif ()
31+endif ()
32+
33 # Include vala precompile
34 include (ValaPrecompile)
35
36
37=== modified file 'lib/synapse-core/CMakeLists.txt'
38--- lib/synapse-core/CMakeLists.txt 2015-09-02 16:22:46 +0000
39+++ lib/synapse-core/CMakeLists.txt 2016-05-31 11:10:42 +0000
40@@ -36,10 +36,13 @@
41 ${CORE_SOURCE}
42 PACKAGES
43 ${CORE_PKG}
44+ ${UNITY_DEPS}
45 GENERATE_VAPI
46 ${CORE_LIBRARY_NAME}
47 GENERATE_HEADER
48 ${CORE_LIBRARY_NAME}
49+OPTIONS
50+ ${UNITY_OPTIONS}
51 )
52
53 # Some compiler flags
54
55=== modified file 'lib/synapse-core/desktop-file-service.vala'
56--- lib/synapse-core/desktop-file-service.vala 2016-02-10 10:26:57 +0000
57+++ lib/synapse-core/desktop-file-service.vala 2016-05-31 11:10:42 +0000
58@@ -72,6 +72,8 @@
59 return name_folded;
60 }
61
62+ public string[] keywords = null;
63+
64 public EnvironmentType show_in { get; set; default = EnvironmentType.ALL; }
65
66 private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"};
67@@ -150,6 +152,12 @@
68 throw new DesktopFileError.UNINTERESTING_ENTRY ("Unable to get exec for %s".printf (name));
69 }
70
71+#if HAVE_UNITY
72+ this.keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id);
73+#elif HAS_FIX_DESKTOPINFO
74+ this.keywords = app_info.get_keywords ();
75+#endif
76+
77 // check for hidden desktop files
78 if (keyfile.has_key (GROUP, "Hidden") &&
79 keyfile.get_boolean (GROUP, "Hidden"))
80
81=== modified file 'lib/synapse-plugins/desktop-file-plugin.vala'
82--- lib/synapse-plugins/desktop-file-plugin.vala 2015-12-23 15:10:29 +0000
83+++ lib/synapse-plugins/desktop-file-plugin.vala 2016-05-31 11:10:42 +0000
84@@ -97,6 +97,7 @@
85
86 // for additional matching
87 public string generic_name { get; construct set; default = ""; }
88+ public unowned string[] keywords { get; construct set; default = null; }
89
90 private string? title_folded = null;
91 public unowned string get_title_folded ()
92@@ -129,6 +130,7 @@
93 this.desktop_id = "application://" + info.desktop_id;
94 this.generic_name = info.generic_name;
95 this.gettext_domain = info.gettext_domain;
96+ this.keywords = info.keywords;
97 }
98 }
99
100@@ -275,6 +277,29 @@
101 }
102 }
103
104+ foreach (unowned string keyword in dfm.keywords)
105+ {
106+ foreach (var matcher in matchers)
107+ {
108+ MatchInfo action_info;
109+ if (matcher.key.match (keyword.down (), 0, out action_info)
110+ || keyword.down ().contains (q.query_string_folded)
111+ || keyword.down ().has_prefix (q.query_string))
112+ {
113+ results.add (dfm, compute_relevancy (dfm, Match.Score.INCREMENT_SMALL));
114+ matched = true;
115+ break;
116+ }
117+
118+ else if (action_info.is_partial_match ())
119+ {
120+ results.add (dfm, compute_relevancy (dfm, Match.Score.INCREMENT_SMALL));
121+ matched = true;
122+ break;
123+ }
124+ }
125+ }
126+
127 if (!matched && (comment.down ().contains (q.query_string_folded)
128 || generic_name.down ().contains (q.query_string_folded)))
129 {

Subscribers

People subscribed via source and target branches