Choose type to create from new box, not by key.
[dom-editor.git] / Dome / AppRun
blob2e054de0cee078d3d4be76e0d7ffc232004cff69
1 #! /usr/bin/env python
2 # vi: set syntax=python : */
4 import gc
5 show_leaks = False
7 import findrox
8 import rox
10 #rox.setup_app_options('Dome')
12 from rox.Menu import Menu, set_save_name
14 set_save_name('Dome')
16 no_gui_mode = 0
18 # Ugly hack to stop wierd chars appearing...
19 #import xml.dom.html
20 #xml.dom.html.HTML_CHARACTER_ENTITIES = {}
22 import sys
23 from os.path import dirname
25 app_dir = dirname(sys.argv[0])
27 from rox import g, mime
28 from rox.options import Option
29 from Window import Window
30 rox.setup_app_options('Dome')
32 default_font = Option('default_font', 'sans 12')
34 # All options must be registered by the time we get here
35 rox.app_options.notify()
37 #sys.argv.append('--disable-crash-dialog')
38 #import gnome.ui
39 #sys.argv.pop()
41 mime.install_mime_info('Dome')
43 mono = 0
44 while len(sys.argv) > 1 and sys.argv[1].startswith('--'):
45 option = sys.argv[1][2:]
46 del sys.argv[1]
47 if option == 'mono':
48 mono = 1 # Black & White
49 elif option == '':
50 break
51 else:
52 raise Exception("Unknown option", option)
54 files = sys.argv[1:]
55 del sys.argv[1:] # GnomeCanvas can't cope with -
57 def go():
58 apply(Window, files)
60 if show_leaks:
61 # Run twice, once to make sure everything is initialised, and
62 # again to make sure the memory use doesn't grow further.
63 go()
64 rox.mainloop()
66 log = file('leak-log', 'w')
68 gc.collect()
69 old = {}
70 for x in gc.get_objects():
71 old[id(x)] = None
72 #import profile
73 #profile.run('go()')
74 go()
76 rox.mainloop()
78 if show_leaks:
79 gc.collect()
80 for x in gc.get_objects():
81 if id(x) not in old:
82 print `x`[:80]
83 print>>log, "New %s: %s" % (type(x), `x`)
84 for y in gc.get_referrers(x):
85 if y is not globals() and id(y) in old:
86 if type(y) == dict:
87 print>>log, "\t(dict, key is %s)" % [k for k in y if y[k] is x]
88 print>>log, "\t%s" % `y`