Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

loadable_icon_key helper functions

By: junrrein on Feb 20th, 2013  |  syntax: C  |  size: 0.84 KB  |  views: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. typedef struct  {
  2.     GIcon *icon;
  3.     int size;
  4. } LoadableIconKey;
  5.  
  6. loadable_icon_key_new (GIcon *icon, int size)
  7. {
  8.     LoadableIconKey *key;
  9.  
  10.     key = g_slice_new (LoadableIconKey);
  11.     key->icon = g_object_ref (icon);
  12.     key->size = size;
  13.  
  14.     return key;
  15. }
  16.  
  17. loadable_icon_key_hash (LoadableIconKey *key)
  18. {
  19.     return g_icon_hash (key->icon) ^ key->size;
  20. }
  21.  
  22. loadable_icon_key_equal (const LoadableIconKey *a,
  23.                          const LoadableIconKey *b)
  24. {
  25.     return a->size == b->size &&
  26.         g_icon_equal (a->icon, b->icon);
  27. }
  28.  
  29. static void
  30. loadable_icon_key_free (LoadableIconKey *key)
  31. {
  32.     g_object_unref (key->icon);
  33.     g_slice_free (LoadableIconKey, key);
  34. }
  35.  
  36. static void destroy_cache_entry (MarlinIconInfo *icon_info)
  37. {
  38.     g_return_if_fail (icon_info != NULL);
  39.     g_clear_object (&icon_info);
  40. }
clone this paste RAW Paste Data