1 | import os |
---|
2 | from gi.repository import Gtk |
---|
3 | |
---|
4 | def 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 | |
---|
16 | set_theme() |
---|
17 | |
---|
18 | window = Gtk.Window() |
---|
19 | window.connect("delete-event", Gtk.main_quit) |
---|
20 | window.show_all() |
---|
21 | |
---|
22 | vbox = Gtk.VBox() |
---|
23 | window.add(vbox) |
---|
24 | vbox.show() |
---|
25 | |
---|
26 | ok_button = Gtk.Button.new_from_stock(Gtk.STOCK_OK) |
---|
27 | vbox.pack_start(ok_button, True, False, 0) |
---|
28 | ok_button.show() |
---|
29 | |
---|
30 | x_button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL) |
---|
31 | vbox.pack_start(x_button, True, False, 0) |
---|
32 | x_button.show() |
---|
33 | |
---|
34 | icontheme = Gtk.IconTheme.get_default() |
---|
35 | print "IconTheme search path:", icontheme.get_search_path() |
---|
36 | |
---|
37 | needed = icontheme.rescan_if_needed() |
---|
38 | print "IconTheme rescan needed:", needed |
---|
39 | |
---|
40 | ok_icon = icontheme.lookup_icon(Gtk.STOCK_OK, Gtk.IconSize.BUTTON, 0) |
---|
41 | if ok_icon is None: |
---|
42 | print "Gtk.STOCK_OK has no custom icon" |
---|
43 | else: |
---|
44 | print "Icon for Gtk.STOCK_OK:", ok_icon.get_filename() |
---|
45 | |
---|
46 | x_icon = icontheme.lookup_icon(Gtk.STOCK_CANCEL, Gtk.IconSize.BUTTON, 0) |
---|
47 | if x_icon is None: |
---|
48 | print "Gtk.STOCK_CANCEL has no custom icon" |
---|
49 | else: |
---|
50 | print "Icon for Gtk.STOCK_CANCEL:", x_icon.get_filename() |
---|
51 | |
---|
52 | Gtk.main() |
---|