57
59
icon_generate(themePath, outImage)
58
60
elif sys.argv[1] == "gtk":
59
outImage = os.path.abspath(os.path.expanduser(sys.argv[2]))
63
gtk_generate(outImage, iconDir)
61
raise(Exception("GTK disable in this revision"))
64
62
elif sys.argv[1] == "multiple":
65
63
outImage = os.path.abspath(os.path.expanduser(sys.argv[2]))
202
def gtk_generate(outImage, iconDir=None):
203
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
204
window.connect("destroy", lambda widget: sys.exit(1))
205
window.resize(100, 35)
206
window.set_property("skip-pager-hint", True)
207
window.set_property("skip-taskbar-hint", True)
211
button = gtk.Button()
212
button.set_label("_Abc")
213
hbox.pack_start(button)
214
chkbox = gtk.CheckButton()
215
chkbox.set_active(True)
216
hbox.pack_end(chkbox, False)
217
radiobox = gtk.RadioButton()
218
hbox.pack_end(radiobox, False)
222
take_screenshot(hbox, outImage)
200
def gtk_generate(themePath, outImage):
201
# This code was ported from GNOME Control Center version 2.32.1,
202
# released under the GPLv2, from theme-thumbnail.c
203
# Modifications were made.
205
themePath = os.path.normpath(os.path.abspath(themePath))
206
split = os.path.split(themePath)
208
with _ThemeNameCollisionResolver(themePath, "gtk") as theme:
209
load_gtk_theme(theme.theme_path, os.path.join(theme.theme_path, "gtk-2.0/gtkrc"))
211
window = gtk.OffscreenWindow()
213
vbox = gtk.VBox(False, 0)
215
box = gtk.HBox(False, 0)
216
box.set_border_width(6)
217
vbox.pack_start(box, False, False, 0)
218
stock_button = gtk.Button(stock=gtk.STOCK_OPEN)
219
box.pack_start(stock_button, False, False, 0)
220
checkbox = gtk.CheckButton()
221
checkbox.set_active(True)
222
box.pack_start(checkbox, False, False, 0)
223
radio = gtk.RadioButton()
224
box.pack_start(radio, False, False, 0)
228
size = window.size_request()
229
allocation = gtk.gdk.Rectangle(0, 0, size[0], size[1])
230
window.size_allocate(allocation)
231
window.size_request()
233
size = window.get_size()
236
window.window.process_updates(True)
238
pb = window.get_pixbuf()
240
pb = pb.scale_simple(GTK_THUMBNAIL_SIZE, int(GTK_THUMBNAIL_SIZE * (size[1] / float(size[0]))), gtk.gdk.INTERP_BILINEAR)
241
pb.save(outImage, outImage.split(".")[-1].lower())
227
244
def icon_generate(themePath, outImage=None):
228
245
"""Return Pixbuf if outImage is None.