App search: Match GenericName too
This is making shell search results more useful in many cases, such as 'web', 'browser', spreadsheet'. https://bugzilla.gnome.org/show_bug.cgi?id=687121
This commit is contained in:
parent
16e22017f2
commit
d1242e9ae7
@ -73,6 +73,7 @@ struct _ShellApp
|
||||
char *window_id_string;
|
||||
|
||||
char *casefolded_name;
|
||||
char *casefolded_generic_name;
|
||||
char *name_collation_key;
|
||||
char *casefolded_exec;
|
||||
char **casefolded_keywords;
|
||||
@ -1310,6 +1311,7 @@ static void
|
||||
shell_app_init_search_data (ShellApp *app)
|
||||
{
|
||||
const char *name;
|
||||
const char *generic_name;
|
||||
const char *exec;
|
||||
const char * const *keywords;
|
||||
char *normalized_exec;
|
||||
@ -1319,6 +1321,12 @@ shell_app_init_search_data (ShellApp *app)
|
||||
name = g_app_info_get_name (G_APP_INFO (appinfo));
|
||||
app->casefolded_name = shell_util_normalize_and_casefold (name);
|
||||
|
||||
generic_name = g_desktop_app_info_get_generic_name (appinfo);
|
||||
if (generic_name)
|
||||
app->casefolded_generic_name = shell_util_normalize_and_casefold (generic_name);
|
||||
else
|
||||
app->casefolded_generic_name = NULL;
|
||||
|
||||
exec = g_app_info_get_executable (G_APP_INFO (appinfo));
|
||||
normalized_exec = shell_util_normalize_and_casefold (exec);
|
||||
app->casefolded_exec = trim_exec_line (normalized_exec);
|
||||
@ -1388,6 +1396,18 @@ _shell_app_match_search_terms (ShellApp *app,
|
||||
current_match = MATCH_SUBSTRING;
|
||||
}
|
||||
|
||||
if (app->casefolded_generic_name)
|
||||
{
|
||||
p = strstr (app->casefolded_generic_name, term);
|
||||
if (p != NULL)
|
||||
{
|
||||
if (p == app->casefolded_generic_name || *(p - 1) == ' ')
|
||||
current_match = MATCH_PREFIX;
|
||||
else if (current_match < MATCH_PREFIX)
|
||||
current_match = MATCH_SUBSTRING;
|
||||
}
|
||||
}
|
||||
|
||||
if (app->casefolded_exec)
|
||||
{
|
||||
p = strstr (app->casefolded_exec, term);
|
||||
@ -1497,6 +1517,7 @@ shell_app_finalize (GObject *object)
|
||||
g_free (app->window_id_string);
|
||||
|
||||
g_free (app->casefolded_name);
|
||||
g_free (app->casefolded_generic_name);
|
||||
g_free (app->name_collation_key);
|
||||
g_free (app->casefolded_exec);
|
||||
g_strfreev (app->casefolded_keywords);
|
||||
|
Loading…
Reference in New Issue
Block a user