5 assert gtk
.pygtk_version
>= (2, 8)
10 from gazpacho
.loader
.loader
import ObjectBuilder
12 from pysize_widget
import PysizeWidget
13 from core
.compute_size
import size_observable
15 def hover_changed(main_widget
, hover_node
, status_bar
):
18 status_bar
.push(0, hover_node
.get_fullpath())
20 def size_observer(progress_bar
):
22 if now
- size_observer
.last_pulse
> 0.04:
23 size_observer
.last_pulse
= now
24 gobject
.idle_add(lambda: progress_bar
.pulse())
25 size_observer
.last_pulse
= time
.time()
27 def hide_pbar(progress_bar
, visible
):
34 def __init__(self
, options
, args
):
35 create_widget
= lambda **unused_kwargs
: PysizeWidget(options
, args
)
36 glade_filename
= os
.path
.join(os
.path
.dirname(__file__
),
38 builder
= ObjectBuilder(glade_filename
,
39 custom
= {'pysize_widget': create_widget
})
41 main_widget
= builder
.get_widget('main_widget')
42 status_bar
= builder
.get_widget('status_bar')
43 main_widget
.connect('hover_changed', hover_changed
, status_bar
)
45 progress_bar
= builder
.get_widget('progress_bar')
46 size_observable
.add_observer(lambda: size_observer(progress_bar
))
47 pbar_hider
= lambda w
, building
: hide_pbar(progress_bar
, building
)
48 main_widget
.connect('building-tree-state-changed', pbar_hider
)
51 'quit_action': lambda w
: gtk
.main_quit(),
52 'refresh_tree_action': lambda w
: main_widget
.refresh_tree()
54 builder
.signal_autoconnect(callbacks
)
56 window
= builder
.get_widget('main_window')
57 window
.set_title('Pysize - ' + args
[0])