Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When writing a lens for Unity in python I got stuck at replacing "import gtk" with "from gi.repository import Gtk" because I can't find the equivalence for the funcion: gtk.icon_theme_get_default().

for example:

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()

------- prints ------

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

I have replaced with success the following 2 lines:

 from gi.repository import Gio, Gtk
   iconName = Gio.content_type_get_icon( mimetype )

But I can't find a way to translate:

theme = gtk.icon_theme_get_default()

Any help will be appreciated.

share|improve this question
Thanks for the really quick and accurate answer! – gabdub Jul 19 '12 at 17:35
up vote 4 down vote accepted

It is Gtk.IconTheme.get_default() in the gobject-introspection bindings.

share|improve this answer
@gabdub, if dobey's answer worked for you please click on the check to let others know at a glance. Thanks. – John S Gruber Aug 13 '12 at 0:25
Done, I'm sorry for the delay. – gabdub Aug 17 '12 at 16:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.