Как получить тему по умолчанию, используя python "Gtk" (не "gtk")?
При написании линзы для Unity в python я застрял при замене "import gtk" на "из gi.repository import Gtk", потому что не могу найти эквивалент для функции: gtk.icon_theme_get_default().
например:
import gtk, gio
if __name__ == "__main__":
mimetype= "text/x-c"
print "MIME=", mimetype
iconName = gio.content_type_get_icon( mimetype )
theme = gtk.icon_theme_get_default()
print "ICO names=", iconName.get_names()
icon = theme.choose_icon(iconName.get_names(), 48, 0)
print "ICO=", icon.get_filename()
------- печатает ------
MIME= text/x-c
ICO names= ['text-x-c', 'gnome-mime-text-x-c', 'text-x-generic']
ICO= /usr/share/icons/Humanity/mimes/48/text-x-c.svg
Я с успехом заменил следующие 2 строки:
from gi.repository import Gio, Gtk
iconName = Gio.content_type_get_icon( mimetype )
Но я не могу найти способ перевести:
theme = gtk.icon_theme_get_default()
Любая помощь будет оценена.
1 ответ
Решение
Это Gtk.IconTheme.get_default() в привязках gobject-introspection.