mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
gdesktopappinfo: Do not search Comment field
The Comment field provides a user-visible description of the app, which usually contains generic words ("and", "or", "not", "is", ...) that add noise when used for search. It made some sense to match against the field as a fallback for Keywords, before that key was well established. However that key has been around for years now, so hopefully every app where additional terms are helpful uses it by now. With that, the downside of added noise outweighs the benefit, so it's time to stop matching on comments.
This commit is contained in:
@@ -432,7 +432,6 @@ add_to_table_if_appropriate (GHashTable *apps,
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DESKTOP_KEY_Comment,
|
|
||||||
DESKTOP_KEY_Exec,
|
DESKTOP_KEY_Exec,
|
||||||
DESKTOP_KEY_GenericName,
|
DESKTOP_KEY_GenericName,
|
||||||
DESKTOP_KEY_Keywords,
|
DESKTOP_KEY_Keywords,
|
||||||
@@ -452,8 +451,7 @@ const gchar desktop_key_match_category[N_DESKTOP_KEYS] = {
|
|||||||
[DESKTOP_KEY_Exec] = 2,
|
[DESKTOP_KEY_Exec] = 2,
|
||||||
[DESKTOP_KEY_Keywords] = 3,
|
[DESKTOP_KEY_Keywords] = 3,
|
||||||
[DESKTOP_KEY_GenericName] = 4,
|
[DESKTOP_KEY_GenericName] = 4,
|
||||||
[DESKTOP_KEY_X_GNOME_FullName] = 5,
|
[DESKTOP_KEY_X_GNOME_FullName] = 5
|
||||||
[DESKTOP_KEY_Comment] = 6
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -487,8 +485,6 @@ desktop_key_get_name (guint key_id)
|
|||||||
{
|
{
|
||||||
switch (key_id)
|
switch (key_id)
|
||||||
{
|
{
|
||||||
case DESKTOP_KEY_Comment:
|
|
||||||
return "Comment";
|
|
||||||
case DESKTOP_KEY_Exec:
|
case DESKTOP_KEY_Exec:
|
||||||
return "Exec";
|
return "Exec";
|
||||||
case DESKTOP_KEY_GenericName:
|
case DESKTOP_KEY_GenericName:
|
||||||
|
@@ -881,11 +881,10 @@ test_search (void)
|
|||||||
assert_search ("frobni", "frobnicator.desktop\n", TRUE, FALSE, NULL, NULL);
|
assert_search ("frobni", "frobnicator.desktop\n", TRUE, FALSE, NULL, NULL);
|
||||||
|
|
||||||
/* Obvious multi-word search */
|
/* Obvious multi-word search */
|
||||||
assert_search ("gno hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL);
|
assert_search ("doc hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL);
|
||||||
|
|
||||||
/* Repeated search terms should do nothing... */
|
/* Repeated search terms should do nothing... */
|
||||||
assert_search ("files file fil fi f", "nautilus.desktop\n"
|
assert_search ("files file fil fi f", "nautilus.desktop\n", TRUE, TRUE, NULL, NULL);
|
||||||
"gedit.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
||||||
|
|
||||||
/* "con" will match "connect" and "contacts" on name with prefix match in
|
/* "con" will match "connect" and "contacts" on name with prefix match in
|
||||||
* first group, then second group is a Keyword prefix match for "configuration" in dconf-editor.desktop
|
* first group, then second group is a Keyword prefix match for "configuration" in dconf-editor.desktop
|
||||||
@@ -896,12 +895,10 @@ test_search (void)
|
|||||||
"nautilus-classic.desktop\n", TRUE, TRUE, NULL, NULL);
|
"nautilus-classic.desktop\n", TRUE, TRUE, NULL, NULL);
|
||||||
|
|
||||||
/* "gnome" will match "eye of gnome" from the user's directory, plus
|
/* "gnome" will match "eye of gnome" from the user's directory, plus
|
||||||
* matching "GNOME Clocks" X-GNOME-FullName. It's only a comment on
|
* matching "GNOME Clocks" X-GNOME-FullName.
|
||||||
* yelp and gnome-contacts, though.
|
|
||||||
*/
|
*/
|
||||||
assert_search ("gnome", "eog.desktop\n"
|
assert_search ("gnome", "eog.desktop\n"
|
||||||
"org.gnome.clocks.desktop\n"
|
"org.gnome.clocks.desktop\n", TRUE, TRUE, NULL, NULL);
|
||||||
"yelp.desktop gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
||||||
|
|
||||||
/* eog has exec name 'false' in usr only */
|
/* eog has exec name 'false' in usr only */
|
||||||
assert_search ("false", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
|
assert_search ("false", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
|
||||||
@@ -913,9 +910,9 @@ test_search (void)
|
|||||||
assert_search ("nonsearchable", "", TRUE, FALSE, NULL, NULL);
|
assert_search ("nonsearchable", "", TRUE, FALSE, NULL, NULL);
|
||||||
|
|
||||||
/* "gnome con" will match only gnome contacts; via the name for
|
/* "gnome con" will match only gnome contacts; via the name for
|
||||||
* "contacts" and the comment for "gnome"
|
* "contacts" and keywords for "friend"
|
||||||
*/
|
*/
|
||||||
assert_search ("gnome con", "gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
|
assert_search ("friend con", "gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
|
||||||
|
|
||||||
/* make sure we get the correct kde4- prefix on the application IDs
|
/* make sure we get the correct kde4- prefix on the application IDs
|
||||||
* from subdirectories
|
* from subdirectories
|
||||||
@@ -938,8 +935,7 @@ test_search (void)
|
|||||||
|
|
||||||
/* make sure localised searching works properly */
|
/* make sure localised searching works properly */
|
||||||
assert_search ("foliumi", "nautilus.desktop\n"
|
assert_search ("foliumi", "nautilus.desktop\n"
|
||||||
"kde4-konqbrowser.desktop\n"
|
"kde4-konqbrowser.desktop\n", TRUE, FALSE, "en_US.UTF-8", "eo");
|
||||||
"eog.desktop\n", TRUE, FALSE, "en_US.UTF-8", "eo");
|
|
||||||
/* the user's eog.desktop has no translations... */
|
/* the user's eog.desktop has no translations... */
|
||||||
assert_search ("foliumi", "nautilus.desktop\n"
|
assert_search ("foliumi", "nautilus.desktop\n"
|
||||||
"kde4-konqbrowser.desktop\n", TRUE, TRUE, "en_US.UTF-8", "eo");
|
"kde4-konqbrowser.desktop\n", TRUE, TRUE, "en_US.UTF-8", "eo");
|
||||||
|
Reference in New Issue
Block a user