[gnome-shell] Match on executable names as well
- From: Florian Müllner <fmuellner src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] Match on executable names as well
- Date: Fri, 15 Jan 2010 21:56:12 +0000 (UTC)
commit f8acd0f6f67997f3da65f69b6ee8cc50b6e3824f
Author: Florian Müllner <fmuellner src gnome org>
Date: Tue Jan 12 15:12:15 2010 +0100
Match on executable names as well
Include matches on desktop entries' exec property in addition to the
name and comment ones.
https://bugzilla.gnome.org/show_bug.cgi?id=606743
src/shell-app-system.c | 39 +++++++++++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index ab609ec..4b57e8a 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -83,6 +83,7 @@ struct _ShellAppInfo {
char *casefolded_name;
char *name_collation_key;
char *casefolded_description;
+ char *casefolded_exec;
GMenuTreeItem *entry;
@@ -612,11 +613,29 @@ normalize_and_casefold (const char *str)
return result;
}
+static char *
+trim_exec_line (const char *str)
+{
+ const char *start, *end, *pos;
+
+ end = strchr (str, ' ');
+ if (end == NULL)
+ end = str + strlen (str);
+
+ start = str;
+ while ((pos = strchr (start, '/')) && pos < end)
+ start = ++pos;
+
+ return g_strndup (start, end - start);
+}
+
static void
shell_app_info_init_search_data (ShellAppInfo *info)
{
const char *name;
+ const char *exec;
const char *comment;
+ char *normalized_exec;
g_assert (info->type == SHELL_APP_INFO_TYPE_ENTRY);
@@ -625,6 +644,11 @@ shell_app_info_init_search_data (ShellAppInfo *info)
comment = gmenu_tree_entry_get_comment ((GMenuTreeEntry*)info->entry);
info->casefolded_description = normalize_and_casefold (comment);
+
+ exec = gmenu_tree_entry_get_exec ((GMenuTreeEntry*)info->entry);
+ normalized_exec = normalize_and_casefold (exec);
+ info->casefolded_exec = trim_exec_line (normalized_exec);
+ g_free (normalized_exec);
}
static ShellAppInfoSearchMatch
@@ -654,6 +678,17 @@ shell_app_info_match_terms (ShellAppInfo *info,
else if (p != NULL)
match = MATCH_SUBSTRING;
+ p = strstr (info->casefolded_exec, term);
+ if (p == info->casefolded_exec)
+ {
+ if (match != MATCH_NONE)
+ return MATCH_MULTIPLE;
+ else
+ match = MATCH_PREFIX;
+ }
+ else if (p != NULL)
+ match = MATCH_SUBSTRING;
+
if (!info->casefolded_description)
continue;
p = strstr (info->casefolded_description, term);
@@ -770,7 +805,7 @@ shell_app_system_initial_search_internal (ShellAppSystem *self,
/**
* shell_app_system_initial_search:
* @self: A #ShellAppSystem
- * @prefs: %TRUE iff we should search preferences instead of apps
+ * @prefs: %TRUE if we should search preferences instead of apps
* @terms: (element-type utf8): List of terms, logical OR
*
* Search through applications for the given search terms. Note that returned
@@ -790,7 +825,7 @@ shell_app_system_initial_search (ShellAppSystem *self,
/**
* shell_app_system_subsearch:
* @self: A #ShellAppSystem
- * @prefs: %TRUE iff we should search preferences instead of apps
+ * @prefs: %TRUE if we should search preferences instead of apps
* @previous_results: (element-type utf8): List of previous results
* @terms: (element-type utf8): List of terms, logical OR
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]