Search code examples
pythonpluginsiconspygtkgedit

How to define an icon for a Gedit plugin written in Python


I am writing a Gedit plugin and created an icon for it as SVG (which of course can be exported to any format). How could I configure this plugin to show this icon in the plugin listing in Edit > Preferences > Plugins dialog?


Solution

  • The .plugin file accepts an Icon field -- as in this example:

    [Gedit Plugin]
    Loader=python
    Module=TextWrap
    IAge=2
    Icon=gtk-ok
    [... and so on ...]
    

    Taken from the TextWrap plugin source.

    To add a custom icon to an existing icon theme, place it in the appropriate folder -- i.e.

    $prefix/share/icons/hicolor/scalable/apps
    

    as ptomato suggests, (where $prefix is probably /usr if you use linux) and then run

    $ gtk-update-icon-cache $prefix/share/icons/hicolor
    

    If the icon filename is gedit-plug.svg, it should now be available as gedit-plug. Note that I actually tested this on the gnome theme, rather than the hicolor theme.