-
Notifications
You must be signed in to change notification settings - Fork 12
/
iconlist.py
54 lines (41 loc) · 1.4 KB
/
iconlist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/local/bin/python3
from gi.repository import Gtk
from gi.repository.GdkPixbuf import Pixbuf
import glob
import os
found = glob.glob('/usr/local/share/icons/mate/24x24/*/*png')
icons = []
for f in found:
base = os.path.basename(f)
icons.append(os.path.splitext(base)[0])
class IconViewWindow(Gtk.Window):
def test(self, widget, path):
model = widget.get_model()
data = model[path][1]
print(data)
def __init__(self):
Gtk.Window.__init__(self)
self.set_title("%d icon%c - %s" % (len(icons), '' if len(icons) < 2 else 's', 'usr/local/share/icons/mate/24x24/'))
self.set_default_size(660, 400)
liststore = Gtk.ListStore(Pixbuf, str, str)
iconview = Gtk.IconView.new()
iconview.set_model(liststore)
iconview.set_pixbuf_column(0)
iconview.set_text_column(1)
iconview.connect("item-activated", self.test)
iconview.set_tooltip_column(2)
bsd = 0
for icon in sorted(icons):
try:
pixbuf = Gtk.IconTheme.get_default().load_icon(icon, 64, 0)
liststore.append([pixbuf, icon, str(bsd)])
except Exception as inst:
print(inst)
bsd += 1
swnd = Gtk.ScrolledWindow()
swnd.add(iconview)
self.add(swnd)
win = IconViewWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()