Merge lp:~mhr3/unity-lens-applications/ascii-fold-app-data into lp:unity-lens-applications

Proposed by Michal Hruby
Status: Merged
Approved by: Gord Allott
Approved revision: 265
Merged at revision: 265
Proposed branch: lp:~mhr3/unity-lens-applications/ascii-fold-app-data
Merge into: lp:unity-lens-applications
Diff against target: 99 lines (+37/-8)
2 files modified
src/unity-package-search.cc (+18/-6)
src/utils.vala (+19/-2)
To merge this branch: bzr merge lp:~mhr3/unity-lens-applications/ascii-fold-app-data
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+93217@code.launchpad.net

Description of the change

Ascii fold application data to make it easier to search.

To post a comment you must log in.
Revision history for this message
Gord Allott (gordallott) wrote :

+1 looks good here

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/unity-package-search.cc'
--- src/unity-package-search.cc 2012-01-24 15:48:18 +0000
+++ src/unity-package-search.cc 2012-02-15 14:56:48 +0000
@@ -54,7 +54,7 @@
5454
55extern "C"55extern "C"
56{56{
57extern gchar* unity_applications_lens_utils_uncamelcase (const gchar* input);57extern gchar* unity_applications_lens_utils_preprocess_string (const gchar* input);
58}58}
5959
60struct _UnityPackageSearcher60struct _UnityPackageSearcher
@@ -175,15 +175,25 @@
175 indexer->set_document(doc);175 indexer->set_document(doc);
176 if (gmenu_tree_entry_get_display_name (entry))176 if (gmenu_tree_entry_get_display_name (entry))
177 {177 {
178 dum1 = unity_applications_lens_utils_uncamelcase (178 dum1 = unity_applications_lens_utils_preprocess_string (
179 gmenu_tree_entry_get_display_name (entry));179 gmenu_tree_entry_get_display_name (entry));
180 indexer->index_text(dum1, 5);180 indexer->index_text(dum1, 5);
181 g_free (dum1);181 g_free (dum1);
182 }182 }
183 if (gmenu_tree_entry_get_name (entry))183 if (gmenu_tree_entry_get_name (entry))
184 indexer->index_text(gmenu_tree_entry_get_name (entry), 5);184 {
185 dum1 = unity_applications_lens_utils_preprocess_string (
186 gmenu_tree_entry_get_name (entry));
187 indexer->index_text(dum1, 5);
188 g_free (dum1);
189 }
185 if (gmenu_tree_entry_get_comment (entry))190 if (gmenu_tree_entry_get_comment (entry))
186 indexer->index_text(gmenu_tree_entry_get_comment (entry), 0);191 {
192 dum1 = unity_applications_lens_utils_preprocess_string (
193 gmenu_tree_entry_get_comment (entry));
194 indexer->index_text (dum1, 0);
195 g_free (dum1);
196 }
187 197
188 /* Index the XDG categories */198 /* Index the XDG categories */
189 appman = unity_app_info_manager_get_default ();199 appman = unity_app_info_manager_get_default ();
@@ -209,8 +219,10 @@
209 &len);219 &len);
210 for (i = 0; i < len; i++)220 for (i = 0; i < len; i++)
211 {221 {
212 indexer->index_text (keywords[i], 3);222 dum1 = unity_applications_lens_utils_preprocess_string (keywords[i]);
213 indexer->index_text (keywords[i], 3, "KW");223 indexer->index_text (dum1, 3);
224 indexer->index_text (dum1, 3, "KW");
225 g_free (dum1);
214 }226 }
215 227
216 228
217229
=== modified file 'src/utils.vala'
--- src/utils.vala 2012-01-24 15:48:18 +0000
+++ src/utils.vala 2012-02-15 14:56:48 +0000
@@ -69,13 +69,30 @@
69 * .desktop file */69 * .desktop file */
70 return actor;70 return actor;
71 }71 }
72 72
73 public bool is_search_empty (Unity.LensSearch search)73 public bool is_search_empty (Unity.LensSearch search)
74 {74 {
75 if (search.search_string == null) return true;75 if (search.search_string == null) return true;
76 return search.search_string == "";76 return search.search_string == "";
77 }77 }
7878
79 private static Dee.ICUTermFilter icu_filter;
80
81 public string preprocess_string (string text)
82 {
83 if (icu_filter == null)
84 {
85 icu_filter = new Dee.ICUTermFilter.ascii_folder ();
86 }
87
88 var uncamelcased = uncamelcase (text);
89 var folded = icu_filter.apply (uncamelcased);
90
91 if (uncamelcased == folded) return uncamelcased;
92
93 return "%s\n%s".printf (uncamelcased, folded);
94 }
95
79 private static Regex camelcase_matcher;96 private static Regex camelcase_matcher;
8097
81 public string uncamelcase (string text)98 public string uncamelcase (string text)
@@ -86,7 +103,7 @@
86 {103 {
87 // 1+ upper characters followed by 1+ non-upper 104 // 1+ upper characters followed by 1+ non-upper
88 // (but preceded by non-upper or start of the string)105 // (but preceded by non-upper or start of the string)
89 camelcase_matcher = new Regex ("(?<=^|[^[:upper:]])[[:upper:]]+[^[:upper:]]+",106 camelcase_matcher = new Regex ("(?<=^|[^[:upper:]\\s])[[:upper:]]+[^[:upper:]]+",
90 RegexCompileFlags.OPTIMIZE);107 RegexCompileFlags.OPTIMIZE);
91 }108 }
92 catch (Error e) { warning ("%s", e.message); }109 catch (Error e) { warning ("%s", e.message); }

Subscribers

People subscribed via source and target branches