shell-app: Remove MATCH_MULTIPLE_{PREFIX,SUFFIX}

We originally OR'ed search terms and favored results which matched
multiple times to get more relevant results. When changing search
to AND search terms, the semantics of "multiple matches" were
changed to refer to a single term matching multiple criteria (name,
executable), which seemed like a good idea at the time.

However in practice this just results in applications whose
user-visible name matches the executable name on disk being
favored over applications using a more generic name, which
isn't too useful (in particular when taking usage frequency
into account).

https://bugzilla.gnome.org/show_bug.cgi?id=623372
This commit is contained in:
Florian Müllner 2011-10-06 01:07:29 +02:00
parent c427bba9f1
commit aee3c6f041
3 changed files with 10 additions and 38 deletions

View File

@ -24,9 +24,7 @@ void _shell_app_remove_window (ShellApp *app, MetaWindow *window);
void _shell_app_do_match (ShellApp *app,
GSList *terms,
GSList **multiple_prefix_results,
GSList **prefix_results,
GSList **multiple_substring_results,
GSList **substring_results);
G_END_DECLS

View File

@ -685,24 +685,16 @@ compare_apps_by_usage (gconstpointer a,
static GSList *
sort_and_concat_results (ShellAppSystem *system,
GSList *multiple_prefix_matches,
GSList *prefix_matches,
GSList *multiple_substring_matches,
GSList *substring_matches)
{
multiple_prefix_matches = g_slist_sort_with_data (multiple_prefix_matches,
compare_apps_by_usage,
system);
prefix_matches = g_slist_sort_with_data (prefix_matches,
compare_apps_by_usage,
system);
multiple_substring_matches = g_slist_sort_with_data (multiple_substring_matches,
compare_apps_by_usage,
system);
substring_matches = g_slist_sort_with_data (substring_matches,
compare_apps_by_usage,
system);
return g_slist_concat (multiple_prefix_matches, g_slist_concat (prefix_matches, g_slist_concat (multiple_substring_matches, substring_matches)));
return g_slist_concat (prefix_matches, substring_matches);
}
/**
@ -729,9 +721,7 @@ search_tree (ShellAppSystem *self,
GSList *terms,
GHashTable *apps)
{
GSList *multiple_prefix_results = NULL;
GSList *prefix_results = NULL;
GSList *multiple_subtring_results = NULL;
GSList *substring_results = NULL;
GSList *normalized_terms;
GHashTableIter iter;
@ -746,14 +736,13 @@ search_tree (ShellAppSystem *self,
ShellApp *app = value;
(void)id;
_shell_app_do_match (app, normalized_terms,
&multiple_prefix_results, &prefix_results,
&multiple_subtring_results, &substring_results);
&prefix_results,
&substring_results);
}
g_slist_foreach (normalized_terms, (GFunc)g_free, NULL);
g_slist_free (normalized_terms);
return sort_and_concat_results (self, multiple_prefix_results, prefix_results,
multiple_subtring_results, substring_results);
return sort_and_concat_results (self, prefix_results, substring_results);
}
@ -792,9 +781,7 @@ shell_app_system_subsearch (ShellAppSystem *system,
GSList *terms)
{
GSList *iter;
GSList *multiple_prefix_results = NULL;
GSList *prefix_results = NULL;
GSList *multiple_substring_results = NULL;
GSList *substring_results = NULL;
GSList *normalized_terms = normalize_terms (terms);
@ -803,8 +790,8 @@ shell_app_system_subsearch (ShellAppSystem *system,
ShellApp *app = iter->data;
_shell_app_do_match (app, normalized_terms,
&multiple_prefix_results, &prefix_results,
&multiple_substring_results, &substring_results);
&prefix_results,
&substring_results);
}
g_slist_foreach (normalized_terms, (GFunc)g_free, NULL);
g_slist_free (normalized_terms);
@ -812,7 +799,7 @@ shell_app_system_subsearch (ShellAppSystem *system,
/* Note that a shorter term might have matched as a prefix, but
when extended only as a substring, so we have to redo the
sort rather than reusing the existing ordering */
return sort_and_concat_results (system, multiple_prefix_results, prefix_results, multiple_substring_results, substring_results);
return sort_and_concat_results (system, prefix_results, substring_results);
}
/**

View File

@ -19,9 +19,7 @@
typedef enum {
MATCH_NONE,
MATCH_SUBSTRING, /* Not prefix, substring */
MATCH_MULTIPLE_SUBSTRING, /* Matches multiple criteria with substrings */
MATCH_PREFIX, /* Strict prefix */
MATCH_MULTIPLE_PREFIX, /* Matches multiple criteria, at least one prefix */
} ShellAppSearchMatch;
/* This is mainly a memory usage optimization - the user is going to
@ -1267,11 +1265,9 @@ _shell_app_match_search_terms (ShellApp *app,
if (p != NULL)
{
if (p == app->casefolded_exec || *(p - 1) == '-')
current_match = (current_match == MATCH_NONE) ? MATCH_PREFIX
: MATCH_MULTIPLE_PREFIX;
current_match = MATCH_PREFIX;
else if (current_match < MATCH_PREFIX)
current_match = (current_match == MATCH_NONE) ? MATCH_SUBSTRING
: MATCH_MULTIPLE_SUBSTRING;
current_match = MATCH_SUBSTRING;
}
if (app->casefolded_description && current_match < MATCH_PREFIX)
@ -1281,8 +1277,7 @@ _shell_app_match_search_terms (ShellApp *app,
*/
p = strstr (app->casefolded_description, term);
if (p != NULL)
current_match = (current_match == MATCH_NONE) ? MATCH_SUBSTRING
: MATCH_MULTIPLE_SUBSTRING;
current_match = MATCH_SUBSTRING;
}
if (current_match == MATCH_NONE)
@ -1297,9 +1292,7 @@ _shell_app_match_search_terms (ShellApp *app,
void
_shell_app_do_match (ShellApp *app,
GSList *terms,
GSList **multiple_prefix_results,
GSList **prefix_results,
GSList **multiple_substring_results,
GSList **substring_results)
{
ShellAppSearchMatch match;
@ -1320,15 +1313,9 @@ _shell_app_do_match (ShellApp *app,
{
case MATCH_NONE:
break;
case MATCH_MULTIPLE_PREFIX:
*multiple_prefix_results = g_slist_prepend (*multiple_prefix_results, app);
break;
case MATCH_PREFIX:
*prefix_results = g_slist_prepend (*prefix_results, app);
break;
case MATCH_MULTIPLE_SUBSTRING:
*multiple_substring_results = g_slist_prepend (*multiple_substring_results, app);
break;
case MATCH_SUBSTRING:
*substring_results = g_slist_prepend (*substring_results, app);
break;