Skip to content

Commit

Permalink
Add a secondary hash table search that checks without regard to
Browse files Browse the repository at this point in the history
case if the initial (fast) lookup doesn't yield any results.

The benefit of this is we won't have to rename all our .desktop
files for mint programs.

The downside is that unexpected things might happen if for some
reason you have duplicate .desktop files that differ only in
character cases (not likely).
  • Loading branch information
mtwebster committed Nov 7, 2012
1 parent 93e4776 commit 512d2a3
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/cinnamon-app-system.c
Expand Up @@ -490,6 +490,20 @@ cinnamon_app_system_get_default ()
return instance;
}

gboolean
case_insensitive_search (const char *key,
const char *value,
gpointer user_data)
{
char *given_id = (char *) user_data;

if (g_ascii_strcasecmp(key, given_id) == 0) {
return TRUE;
} else {
return FALSE;
}
}

/**
* cinnamon_app_system_lookup_app:
*
Expand All @@ -501,7 +515,13 @@ CinnamonApp *
cinnamon_app_system_lookup_app (CinnamonAppSystem *self,
const char *id)
{
return g_hash_table_lookup (self->priv->id_to_app, id);
CinnamonApp *result;

result = g_hash_table_lookup (self->priv->id_to_app, id);
if (result == NULL) {
result = g_hash_table_find (self->priv->id_to_app, (GHRFunc) case_insensitive_search, id);
}
return result;
}

/**
Expand All @@ -515,7 +535,13 @@ CinnamonApp *
cinnamon_app_system_lookup_settings_app (CinnamonAppSystem *self,
const char *id)
{
return g_hash_table_lookup (self->priv->setting_id_to_app, id);
CinnamonApp *result;

result = g_hash_table_lookup (self->priv->setting_id_to_app, id);
if (result == NULL) {
result = g_hash_table_find (self->priv->setting_id_to_app, (GHRFunc) case_insensitive_search, id);
}
return result;
}

/**
Expand Down

0 comments on commit 512d2a3

Please sign in to comment.