Permalink
Browse files

Add a secondary hash table search that checks without regard to

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...
1 parent 93e4776 commit 512d2a31996bffc1c9437faf0c2412b797916b3a @mtwebster committed Nov 7, 2012
Showing with 28 additions and 2 deletions.
  1. +28 −2 src/cinnamon-app-system.c
View
@@ -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:
*
@@ -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;
}
/**
@@ -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;
}
/**

0 comments on commit 512d2a3

Please sign in to comment.