Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am working on a program and I want to implement icon denoting keyring state. If you start seahorse you'll see it has the same icon of padlock in two states, locked and unlocked.

I am unable to find unlocked icon name. There are many locked padlocks in /usr/share/icons but I didn't find any unlocked icons.

So, my question is, what's the name of the icon I can use with set_from_icon_name method.

Note: stock_lock-open is not the one am looking for.

share|improve this question
1  
When I start seahorse I see two keys on a keyring, not padlocks. Are you using Ubuntu 12.04 or 12.10, and have you installed any themes? –  Tom Brossman Dec 25 '12 at 19:26
    
Nevermind, I think I see what you mean in the newer version in 12.10. Browsing the package file list online, it appears there are multiple icon files also in /usr/share/seahorse/icons/hicolor/??? Does that help? I'm on 12.04 so unfortunately I can't see the same thing. –  Tom Brossman Dec 25 '12 at 19:41
add comment

1 Answer

up vote 3 down vote accepted

Here you go, taken from the Seahorse source:

from gi.repository import Gtk, Gio

icon_theme = Gtk.IconTheme.get_default()
def get_pixbuf_from_themed_icon(name, size):
    icon = Gio.ThemedIcon.new_with_default_fallbacks(name)
    icon_info = icon_theme.lookup_by_gicon(icon, size, 0)
    return icon_info.load_icon()

pixbuf_lock = get_pixbuf_from_themed_icon("changes-prevent-symbolic", 48)
pixbuf_unlock = get_pixbuf_from_themed_icon("changes-allow-symbolic", 48)

win = Gtk.Window()
win.resize(300, 300)
win.connect('delete-event', Gtk.main_quit)

vbox = Gtk.VBox(False, 4)
img_lock = Gtk.Image.new_from_pixbuf(pixbuf_lock)
vbox.pack_start(img_lock, False, False, 0)
img_unlock = Gtk.Image.new_from_pixbuf(pixbuf_unlock)
vbox.pack_start(img_unlock, False, False, 0)

win.add(vbox)
win.show_all()
Gtk.main()

Only problem is the dark version. I couldn't translate the create_spotlight_pixbuf function to Python.

You might also want to look at the GtkLockButton.

share|improve this answer
    
I've found solution to this problem little earlier but it's the same solution. Thanks, marking as accepted. –  MeanEYE Dec 26 '12 at 20:23
add comment

Your Answer

 
discard

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.