Adding a bit
[apertium.git] / apertium-tools / apertium-tolk / widget_state.py
blobaaf1d8a2910f01f92ade74487a94bbbf9d79a2f4
1 import gtk
2 from simplegeneric import generic
5 @generic
6 def dump_state(widget):
7 raise NotImplementedError
9 @generic
10 def load_state(widget, dct):
11 raise NotImplementedError
14 @dump_state.when_type(gtk.Widget)
15 def widget_dump_state(widget):
16 return {}
18 @load_state.when_type(gtk.Widget)
19 def widget_load_state(widget, dct):
20 pass
23 @dump_state.when_type(gtk.Window)
24 def window_dump_state(w):
25 return { "x_size": w.get_size()[0],
26 "y_size": w.get_size()[1],
27 "x_pos": w.get_position()[0],
28 "y_pos": w.get_position()[1] }
30 @load_state.when_type(gtk.Window)
31 def window_load_state(w, p):
32 w.move(int(p["x_pos"]), int(p["y_pos"]))
33 w.resize(int(p["x_size"]), int(p["y_size"]))
36 @dump_state.when_type(gtk.Paned)
37 def paned_dump_state(w):
38 return { "position": w.get_position() }
40 @load_state.when_type(gtk.Paned)
41 def paned_load_state(w, p):
42 w.set_position(int(p["position"]))