如何使用python“Gtk”(不是“gtk”)获取默认主题?

gab*_*dub 3 python gtk lenses

在 python 中为 Unity 编写镜头时,我遇到了用“from gi.repository import Gtk”替换“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()
Run Code Online (Sandbox Code Playgroud)

- - - - 印刷 - - -

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
Run Code Online (Sandbox Code Playgroud)

我已经成功替换了以下两行:

 from gi.repository import Gio, Gtk
   iconName = Gio.content_type_get_icon( mimetype )
Run Code Online (Sandbox Code Playgroud)

但我找不到翻译的方法:

theme = gtk.icon_theme_get_default()
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激。

dob*_*bey 8

Gtk.IconTheme.get_default()在 gobject-introspection 绑定中。