Python-nautilus : add custom emblems (overlay icon)

970 views Asked by At

I use the python-nautilus module, and I try to add a custom emblem (an icon overlay), like that: enter image description here

But I didn't found anything about that.

I'm able to add an existing emblem like "multimedia" with this code:

import os.path
from gi.repository import Nautilus, GObject

class OnituIconOverlayExtension(GObject.GObject, Nautilus.InfoProvider):
    def __init__(self):
        pass

    def update_file_info(self, file):
        if os.path.splitext(file.get_name())[1] == "fileWithEmblem":
            file.add_emblem("multimedia")

But I would like to add my own icon.

file.add_emblem("my_super_icon.ico")

Do you have an idea ? How can I do that ?

Thank you in advance !

1

There are 1 answers

0
Slot On BEST ANSWER

Just found the solution:

put your icons in ~/.icons/hicolor/48x48/emblems

named "emblem-icon_name.icon" and "emblem-icon_name.png"

The icon file is just a text file like that:

[Icon Data]
DisplayName=icon_name

And call:

 file.add_emblem("icon_name")

Hoping that it helps someone.