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
1=== modified file 'lib/synapse-core/desktop-file-service.vala'
2--- lib/synapse-core/desktop-file-service.vala 2014-06-05 14:34:21 +0000
3+++ lib/synapse-core/desktop-file-service.vala 2014-08-31 12:12:32 +0000
4@@ -50,6 +50,7 @@
5
6 public string desktop_id { get; construct set; }
7 public string name { get; construct set; }
8+ public string generic_name { get; construct set; }
9 public string comment { get; set; default = ""; }
10 public string icon_name { get; construct set; default = ""; }
11
12@@ -134,6 +135,7 @@
13 }
14
15 name = app_info.get_name ();
16+ generic_name = app_info.get_generic_name () ?? "";
17 exec = app_info.get_commandline ();
18 if (exec == null)
19 {
20@@ -632,4 +634,3 @@
21 }
22 }
23 }
24-
25
26=== modified file 'lib/synapse-plugins/desktop-file-plugin.vala'
27--- lib/synapse-plugins/desktop-file-plugin.vala 2014-06-04 19:35:44 +0000
28+++ lib/synapse-plugins/desktop-file-plugin.vala 2014-08-31 12:12:32 +0000
29@@ -50,6 +50,9 @@
30 public bool needs_terminal { get; set; default = false; }
31 public string? filename { get; construct set; }
32
33+ // for additional matching
34+ public string generic_name { get; construct set; default = ""; }
35+
36 private string? title_folded = null;
37 public unowned string get_title_folded ()
38 {
39@@ -79,6 +82,7 @@
40 this.title_folded = info.get_name_folded ();
41 this.title_unaccented = Utils.remove_accents (this.title_folded);
42 this.desktop_id = "application://" + info.desktop_id;
43+ this.generic_name = info.generic_name;
44 }
45 }
46
47@@ -112,10 +116,10 @@
48 dfs.reload_done.connect (() => {
49 mimetype_map.clear ();
50 desktop_files.clear ();
51- load_all_desktop_files ();
52+ load_all_desktop_files.begin ();
53 });
54
55- load_all_desktop_files ();
56+ load_all_desktop_files.begin ();
57 }
58
59 public signal void load_complete ();
60@@ -160,6 +164,9 @@
61 {
62 unowned string folded_title = dfm.get_title_folded ();
63 unowned string unaccented_title = dfm.title_unaccented;
64+ unowned string comment = dfm.description;
65+ unowned string generic_name = dfm.generic_name;
66+
67 bool matched = false;
68 // FIXME: we need to do much smarter relevancy computation in fuzzy re
69 // "sysmon" matching "System Monitor" is very good as opposed to
70@@ -177,7 +184,13 @@
71 results.add (dfm, compute_relevancy (dfm, matcher.value - Match.Score.INCREMENT_SMALL));
72 matched = true;
73 break;
74- }
75+ }
76+ }
77+ if (!matched && (comment.down ().contains (q.query_string_folded)
78+ || generic_name.down ().contains (q.query_string_folded)))
79+ {
80+ results.add (dfm, compute_relevancy (dfm, Match.Score.AVERAGE - Match.Score.INCREMENT_MEDIUM));
81+ matched = true;
82 }
83 if (!matched && dfm.exec.has_prefix (q.query_string))
84 {
85@@ -277,7 +290,7 @@
86 var app_info = new DesktopAppInfo.from_filename (desktop_info.filename);
87 List<File> files = new List<File> ();
88 files.prepend (f);
89- app_info.launch (files, new Gdk.AppLaunchContext ());
90+ app_info.launch (files, Gdk.Display.get_default ().get_app_launch_context ());
91 }
92 catch (Error err)
93 {

Subscribers

People subscribed via source and target branches