GNOME Bugzilla – Bug 655868
gmenu_tree_get_entry_by_id: New API
Last modified: 2011-08-06 14:07:19 UTC
It's useful for gnome-shell if we have an index by desktop file ID to the tree entry. The cost is very small.
Created attachment 193123 [details] [review] gmenu_tree_get_entry_by_id: New API
Review of attachment 193123 [details] [review]: Thanks, it looks good. There are just small details to tweak: ::: libmenu/gmenu-tree.c @@ +834,3 @@ + entry = g_hash_table_lookup (tree->entries_by_id, id); + if (entry != NULL) + gmenu_tree_item_ref (entry); Nitpicking: can you add an empty line here :-) @@ +4455,3 @@ + { + case GMENU_TREE_ITEM_INVALID: + break; We don't need this case, it should never happen because of the loop condition. @@ +4461,3 @@ + + item = gmenu_tree_iter_get_entry (iter); + id = gmenu_tree_entry_get_desktop_file_id (item); There's a mix between tabs and spaces here. @@ +4474,3 @@ + default: + break; + } nitpick: empty line here @@ +4500,3 @@ /* create the menu structure */ + if (tree->entries_by_id == NULL) + tree->entries_by_id = g_hash_table_new (g_str_hash, g_str_equal); Please do this in gmenu_tree_init() since I don't see any reason for lazy-creation here. @@ +4543,3 @@ tree); } + g_hash_table_remove_all (tree->entries_by_id); Should be done inside the if block above this. Also, just for consistency with the call to update_entry_index, do it before removing the entries monitor.
Attachment 193123 [details] pushed as f0e4115 - gmenu_tree_get_entry_by_id: New API