Merge lp:~parnold-x/slingshot/fix-1347956 into lp:~elementary-pantheon/slingshot/trunk

Proposed by Djax
Status: Merged
Approved by: Cody Garver
Approved revision: 445
Merged at revision: 456
Proposed branch: lp:~parnold-x/slingshot/fix-1347956
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 93 lines (+19/-5)
2 files modified
lib/synapse-core/desktop-file-service.vala (+2/-1)
lib/synapse-plugins/desktop-file-plugin.vala (+17/-4)
To merge this branch: bzr merge lp:~parnold-x/slingshot/fix-1347956
Reviewer Review Type Date Requested Status
Tom Beckmann (community) code Approve
Review via email: mp+231742@code.launchpad.net

Commit message

Search generic name (lp:1347956)

Description of the change

To post a comment you must log in.
Revision history for this message
Tom Beckmann (tombeckmann) wrote :

Code looks good, you may want to consider decreasing the score by INCREMENT_MEDIUM though, so that titles score higher than comments. I can't test it today though to see how the decreased score feels.

review: Approve (code)
lp:~parnold-x/slingshot/fix-1347956 updated
445. By Djax

reduce score

Revision history for this message
Djax (parnold-x) wrote :

Reduced the score.
I think it will not make any difference since in all my tested cases the matcher.value gives back 90000 and AVERAGE is 70000.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/synapse-core/desktop-file-service.vala'
--- lib/synapse-core/desktop-file-service.vala 2014-06-05 14:34:21 +0000
+++ lib/synapse-core/desktop-file-service.vala 2014-08-31 12:12:32 +0000
@@ -50,6 +50,7 @@
50 50
51 public string desktop_id { get; construct set; } 51 public string desktop_id { get; construct set; }
52 public string name { get; construct set; }52 public string name { get; construct set; }
53 public string generic_name { get; construct set; }
53 public string comment { get; set; default = ""; }54 public string comment { get; set; default = ""; }
54 public string icon_name { get; construct set; default = ""; }55 public string icon_name { get; construct set; default = ""; }
5556
@@ -134,6 +135,7 @@
134 }135 }
135136
136 name = app_info.get_name ();137 name = app_info.get_name ();
138 generic_name = app_info.get_generic_name () ?? "";
137 exec = app_info.get_commandline ();139 exec = app_info.get_commandline ();
138 if (exec == null)140 if (exec == null)
139 {141 {
@@ -632,4 +634,3 @@
632 }634 }
633 }635 }
634}636}
635
636637
=== modified file 'lib/synapse-plugins/desktop-file-plugin.vala'
--- lib/synapse-plugins/desktop-file-plugin.vala 2014-06-04 19:35:44 +0000
+++ lib/synapse-plugins/desktop-file-plugin.vala 2014-08-31 12:12:32 +0000
@@ -50,6 +50,9 @@
50 public bool needs_terminal { get; set; default = false; }50 public bool needs_terminal { get; set; default = false; }
51 public string? filename { get; construct set; }51 public string? filename { get; construct set; }
5252
53 // for additional matching
54 public string generic_name { get; construct set; default = ""; }
55
53 private string? title_folded = null;56 private string? title_folded = null;
54 public unowned string get_title_folded ()57 public unowned string get_title_folded ()
55 {58 {
@@ -79,6 +82,7 @@
79 this.title_folded = info.get_name_folded ();82 this.title_folded = info.get_name_folded ();
80 this.title_unaccented = Utils.remove_accents (this.title_folded);83 this.title_unaccented = Utils.remove_accents (this.title_folded);
81 this.desktop_id = "application://" + info.desktop_id;84 this.desktop_id = "application://" + info.desktop_id;
85 this.generic_name = info.generic_name;
82 }86 }
83 }87 }
8488
@@ -112,10 +116,10 @@
112 dfs.reload_done.connect (() => {116 dfs.reload_done.connect (() => {
113 mimetype_map.clear ();117 mimetype_map.clear ();
114 desktop_files.clear ();118 desktop_files.clear ();
115 load_all_desktop_files ();119 load_all_desktop_files.begin ();
116 });120 });
117121
118 load_all_desktop_files ();122 load_all_desktop_files.begin ();
119 }123 }
120124
121 public signal void load_complete ();125 public signal void load_complete ();
@@ -160,6 +164,9 @@
160 {164 {
161 unowned string folded_title = dfm.get_title_folded ();165 unowned string folded_title = dfm.get_title_folded ();
162 unowned string unaccented_title = dfm.title_unaccented;166 unowned string unaccented_title = dfm.title_unaccented;
167 unowned string comment = dfm.description;
168 unowned string generic_name = dfm.generic_name;
169
163 bool matched = false;170 bool matched = false;
164 // FIXME: we need to do much smarter relevancy computation in fuzzy re171 // FIXME: we need to do much smarter relevancy computation in fuzzy re
165 // "sysmon" matching "System Monitor" is very good as opposed to172 // "sysmon" matching "System Monitor" is very good as opposed to
@@ -177,7 +184,13 @@
177 results.add (dfm, compute_relevancy (dfm, matcher.value - Match.Score.INCREMENT_SMALL));184 results.add (dfm, compute_relevancy (dfm, matcher.value - Match.Score.INCREMENT_SMALL));
178 matched = true;185 matched = true;
179 break;186 break;
180 }187 }
188 }
189 if (!matched && (comment.down ().contains (q.query_string_folded)
190 || generic_name.down ().contains (q.query_string_folded)))
191 {
192 results.add (dfm, compute_relevancy (dfm, Match.Score.AVERAGE - Match.Score.INCREMENT_MEDIUM));
193 matched = true;
181 }194 }
182 if (!matched && dfm.exec.has_prefix (q.query_string))195 if (!matched && dfm.exec.has_prefix (q.query_string))
183 {196 {
@@ -277,7 +290,7 @@
277 var app_info = new DesktopAppInfo.from_filename (desktop_info.filename);290 var app_info = new DesktopAppInfo.from_filename (desktop_info.filename);
278 List<File> files = new List<File> ();291 List<File> files = new List<File> ();
279 files.prepend (f);292 files.prepend (f);
280 app_info.launch (files, new Gdk.AppLaunchContext ());293 app_info.launch (files, Gdk.Display.get_default ().get_app_launch_context ());
281 }294 }
282 catch (Error err)295 catch (Error err)
283 {296 {

Subscribers

People subscribed via source and target branches