Ticket #4010: test-stock-icons.py

File test-stock-icons.py, 1.4 KB (added by manuq, 11 years ago)

Testcase script.

Line 
1import os
2from gi.repository import Gtk
3
4def set_theme():
5    settings = Gtk.Settings.get_default()
6    sugar_theme = 'sugar-72'
7    if 'SUGAR_SCALING' in os.environ:
8        if os.environ['SUGAR_SCALING'] == '100':
9            sugar_theme = 'sugar-100'
10    print "Current theme:", sugar_theme
11    settings.set_property('gtk-theme-name', sugar_theme)
12    settings.set_property('gtk-icon-theme-name', 'sugar')
13    settings.set_property('gtk-menu-images', 1)
14    settings.set_property('gtk-button-images', 1)
15
16set_theme()
17
18window = Gtk.Window()
19window.connect("delete-event", Gtk.main_quit)
20window.show_all()
21
22vbox = Gtk.VBox()
23window.add(vbox)
24vbox.show()
25
26ok_button = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
27vbox.pack_start(ok_button, True, False, 0)
28ok_button.show()
29
30x_button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
31vbox.pack_start(x_button, True, False, 0)
32x_button.show()
33
34icontheme = Gtk.IconTheme.get_default()
35print "IconTheme search path:", icontheme.get_search_path()
36
37needed = icontheme.rescan_if_needed()
38print "IconTheme rescan needed:", needed
39
40ok_icon = icontheme.lookup_icon(Gtk.STOCK_OK, Gtk.IconSize.BUTTON, 0)
41if ok_icon is None:
42    print "Gtk.STOCK_OK has no custom icon"
43else:
44    print "Icon for Gtk.STOCK_OK:", ok_icon.get_filename()
45
46x_icon = icontheme.lookup_icon(Gtk.STOCK_CANCEL, Gtk.IconSize.BUTTON, 0)
47if x_icon is None:
48    print "Gtk.STOCK_CANCEL has no custom icon"
49else:
50    print "Icon for Gtk.STOCK_CANCEL:", x_icon.get_filename()
51
52Gtk.main()