Search code examples
gtkpython-3.xgio

GIO: get_icon() always returns None


According to the GIO Documentation, it is possible to get the Icon of a file through g_file_info_get_icon () http://developer.gnome.org/gio/stable/GFileInfo.html#g-file-info-get-icon

But this doesnt work, take a look at this sample:

print(somefile) # <FileInfo object at 0x17bf820 (GFileInfo at 0x1b15d00)> 
icon = somefile.get_icon()
print(icon) # always None
if icon is Gio.Icon: 
    print("isicon") # never happens

I've testet it with my whole home folder, get_icon() does ALWAYS return None. Did i made any mistakes or is this function simply not working with python / pygobject?


Solution

  • Did you query_info the standard::icon attribute? For example,

    f = File.new_for_commandline_arg('...')
    info = f.query_info('standard::icon')
    print(info.get_icon())