39
40
def run(self, Theme, IconDB, Store, iconset_data):
40
41
context = iconset_data[2]
41
42
name = iconset_data[1]
44
sizes = list(Theme.get_icon_sizes(name))
43
sizes, msizes = self.get_sizes(Theme, name)
51
45
self.header.set_markup(
52
46
"<b>%s</b>\n<span size=\"small\">%s - %s</span>" % (name, Theme.info[1], context)
54
48
self.header.set_justify(gtk.JUSTIFY_CENTER)
56
51
l_color = self.dialog.get_style().text[gtk.STATE_INSENSITIVE].to_string()
58
53
Icon = self.make_and_append_page(
65
60
if Icon: iconset += Icon,
62
if len(sizes) != len(msizes):
64
note.set_line_wrap(True)
65
note.set_markup("<small><b>Note</b>: There is a mismatch between the reported and discoverable sizes for this icon-set.\nSizes discovered: %s\nSizes reported by Gtk: %s</small>" % (msizes, sizes))
66
self.dialog.vbox.pack_start(note, False, padding=3)
67
68
self.dialog.vbox.show_all()
68
69
response = self.dialog.run()
69
70
self.dialog.destroy()
73
def get_sizes(self, Theme, name):
74
theme_sizes = list(Theme.get_icon_sizes(name))
76
path = Theme.lookup_icon(name, 24, 0).get_filename()
77
if self.is_size_context_fstruct(path):
78
manual_sizes = self.size_context_manually_find_sizes(path, name)
80
manual_sizes = self.context_size_manually_find_sizes(path, name)
84
return theme_sizes, manual_sizes
86
def is_size_context_fstruct(self, path):
87
search_path = '/'+os.path.join(*path.split('/')[:-3])
91
for f in os.listdir(search_path):
92
p = os.path.join(search_path, f)
93
if os.path.isdir(p) and f[0].isdigit():
98
elif os.path.isdir(p):
103
def size_context_manually_find_sizes(self, path, name):
104
search_path = '/'+os.path.join(*path.split('/')[:-3])
105
ctx = path.split('/')[-2]
108
for f in os.listdir(search_path):
109
d = os.path.join(search_path, f, ctx)
111
for fn in os.listdir(d):
112
if os.path.splitext(fn)[0] == name:
113
manual_sizes.append(self.parse_size(f))
116
def context_size_manually_find_sizes(self, path, name):
117
search_path = '/'+os.path.join(*path.split('/')[:-2])
119
for f in os.listdir(search_path):
120
d = os.path.join(search_path, f)
122
for fn in os.listdir(d):
123
if os.path.splitext(fn)[0] == name:
124
manual_sizes.append(self.parse_size(f))
127
def parse_size(self, size):
128
if isinstance(size, int) or size == 'scalable':
136
size = int(size.split('x')[0])
139
print 'Size not parsable:', size
72
142
def make_and_append_page(self, Theme, context, name, size, l_color):
143
if isinstance(size, int):
74
144
path = Theme.lookup_icon(name, size, 0).get_filename()
145
pixbuf = Theme.load_icon(name, size, 0)
75
146
tab_label = "%sx%s" % (size, size)
77
148
path = Theme.lookup_icon(name, 64, gtk.ICON_LOOKUP_FORCE_SVG).get_filename()
149
pixbuf = Theme.load_icon(name, 64, gtk.ICON_LOOKUP_FORCE_SVG)
80
152
Icon = IconInfo(l_color)
188
261
table.attach(r_label, 1, 2, i, j, xpadding=10, ypadding=3)
191
def set_info(self, theme, context, name, size, path):
264
def set_info(self, theme, context, name, size, path, pixbuf):
192
265
self.theme = theme
193
266
self.context = context
197
271
self.target = None
199
self.preview = IconPreview(path, size)
273
self.preview = IconPreview(pixbuf)
200
274
self.update_table(path)