View difference between Paste ID: z4M19XdH and S2rvz7yB
SHOW: | | - or go back to the newest paste.
1
struct _MarlinIconInfo
2
{
3
    GObject         parent;
4
5
    guint64         last_use_time;
6
    gboolean        is_first_ref;
7
    GdkPixbuf       *pixbuf;
8
    char            *display_name;
9
    char            *icon_name;
10
};
11
12
typedef struct _MarlinIconInfo	MarlinIconInfo;
13
14
MarlinIconInfo *
15
marlin_icon_info_lookup (GIcon *icon, int size)
16
{
17
    MarlinIconInfo *icon_info;
18
    GdkPixbuf *pixbuf = NULL;
19
20
    g_return_val_if_fail (icon && G_IS_ICON (icon), NULL);
21
    if (G_IS_LOADABLE_ICON (icon)) {
22
        LoadableIconKey lookup_key;
23
        LoadableIconKey *key;
24
25
        if (loadable_icon_cache == NULL) {
26
            loadable_icon_cache =
27
                g_hash_table_new_full ((GHashFunc)loadable_icon_key_hash,
28
                                       (GEqualFunc)loadable_icon_key_equal,
29
                                       (GDestroyNotify) loadable_icon_key_free,
30
                                       (GDestroyNotify) destroy_cache_entry);
31
        }
32
33
        lookup_key.icon = icon;
34
        lookup_key.size = size;
35
        icon_info = g_hash_table_lookup (loadable_icon_cache, &lookup_key);
36
        if (icon_info != NULL) {
37
            //g_message ("CACHED %s stream %s\n", G_STRFUNC, g_icon_to_string (icon));
38
            return g_object_ref (icon_info);
39
        }
40
41
        char *str_icon = g_icon_to_string (icon);
42
        pixbuf = gdk_pixbuf_new_from_file_at_size (str_icon, size, size, NULL);
43
        icon_info = marlin_icon_info_new_for_pixbuf (pixbuf);
44
        if (pixbuf != NULL) {
45
            key = loadable_icon_key_new (icon, size);
46
            g_hash_table_insert (loadable_icon_cache, key, g_object_ref (icon_info));
47
            g_free (str_icon);
48
        }
49
50
        return icon_info;
51
//snip
52
}