enum
{
DESKTOP_KEY_Comment,
+ DESKTOP_KEY_Exec,
DESKTOP_KEY_GenericName,
DESKTOP_KEY_Keywords,
DESKTOP_KEY_Name,
* use the same number for the two different keys.
*/
[DESKTOP_KEY_Name] = 1,
- [DESKTOP_KEY_Keywords] = 2,
- [DESKTOP_KEY_GenericName] = 3,
- [DESKTOP_KEY_X_GNOME_FullName] = 4,
- [DESKTOP_KEY_Comment] = 5
+ [DESKTOP_KEY_Exec] = 2,
+ [DESKTOP_KEY_Keywords] = 3,
+ [DESKTOP_KEY_GenericName] = 4,
+ [DESKTOP_KEY_X_GNOME_FullName] = 5,
+ [DESKTOP_KEY_Comment] = 6
};
static gchar *
{
case DESKTOP_KEY_Comment:
return "Comment";
+ case DESKTOP_KEY_Exec:
+ return "Exec";
case DESKTOP_KEY_GenericName:
return "GenericName";
case DESKTOP_KEY_Keywords:
for (i = 0; i < G_N_ELEMENTS (desktop_key_match_category); i++)
{
- gchar *value;
+ const gchar *value;
+ gchar *raw;
if (!desktop_key_match_category[i])
continue;
- value = g_key_file_get_locale_string (key_file, "Desktop Entry", desktop_key_get_name (i), NULL, NULL);
+ raw = g_key_file_get_locale_string (key_file, "Desktop Entry", desktop_key_get_name (i), NULL, NULL);
+ value = raw;
+
+ if (i == DESKTOP_KEY_Exec && raw != NULL)
+ {
+ /* Special handling: only match basename of first field */
+ gchar *space;
+ gchar *slash;
+
+ /* Remove extra arguments, if any */
+ space = raw + strcspn (raw, " \t\n"); /* IFS */
+ *space = '\0';
+
+ /* Skip the pathname, if any */
+ if ((slash = strrchr (raw, '/')))
+ value = slash + 1;
+ }
if (value)
memory_index_add_string (dir->memory_index, value, desktop_key_match_category[i], app);
- g_free (value);
+ g_free (raw);
}
}
"gnome-clocks.desktop\n"
"yelp.desktop gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
+ /* eog has exec name 'false' in usr only */
+ assert_search ("false", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
+ assert_search ("false", "", FALSE, TRUE, NULL, NULL);
+ assert_search ("false", "", TRUE, TRUE, NULL, NULL);
+ assert_search ("false", "", FALSE, FALSE, NULL, NULL);
+
+ /* make sure we only search the first component */
+ assert_search ("nonsearchable", "", TRUE, FALSE, NULL, NULL);
+
/* "gnome con" will match only gnome contacts; via the name for
* "contacts" and the comment for "gnome"
*/