Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python-nautilus : add custom emblems (overlay icon)

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 !

like image 428
Slot Avatar asked Oct 20 '22 20:10

Slot


1 Answers

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.

like image 82
Slot Avatar answered Nov 03 '22 06:11

Slot