2 from rox
import g
, TRUE
, FALSE
4 from main
import memo_list
5 import pretty_time
, time
8 class ShowAll(g
.Dialog
):
10 g
.Dialog
.__init
__(self
)
11 self
.set_title(_('All memos'))
12 self
.set_has_separator(FALSE
)
14 self
.add_button(g
.STOCK_CLOSE
, g
.RESPONSE_CANCEL
)
17 self
.vbox
.pack_start(frame
, TRUE
, TRUE
, 0)
18 frame
.set_shadow_type(g
.SHADOW_IN
)
20 hbox
= g
.HBox(FALSE
, 0)
23 scroll
= g
.VScrollbar()
24 hbox
.pack_end(scroll
, FALSE
, TRUE
, 0)
26 self
.list = g
.TreeView(memo_list
)
27 hbox
.pack_start(self
.list, TRUE
, TRUE
, 0)
28 self
.list.set_scroll_adjustments(None, scroll
.get_adjustment())
29 self
.list.set_size_request(-1, 12)
30 self
.set_default_size(-1, 300)
32 text
= g
.CellRendererText()
34 toggle
= g
.CellRendererToggle()
35 column
= g
.TreeViewColumn(_('Hide'), toggle
,
36 active
= memos
.HIDDEN
)
37 self
.list.append_column(column
)
38 toggle
.connect('toggled',
39 lambda t
, path
: memo_list
.toggle_hidden(path
))
41 column
= g
.TreeViewColumn(_('Time'), text
, text
= memos
.TIME
)
42 self
.list.append_column(column
)
44 column
= g
.TreeViewColumn(_('Message'), text
, text
= memos
.BRIEF
)
45 self
.list.append_column(column
)
47 self
.list.set_headers_visible(TRUE
)
49 sel
= self
.list.get_selection()
50 sel
.set_mode(g
.SELECTION_MULTIPLE
)
52 def activate(view
, path
, column
):
53 memo
= memo_list
.get_memo_by_path(path
)
54 from EditBox
import EditBox
57 self
.add_events(g
.gdk
.BUTTON_PRESS_MASK
)
58 self
.list.connect('row-activated', activate
)
60 self
.connect('response', self
.response
)
62 self
.set_default_response(g
.RESPONSE_CANCEL
)
64 actions
= g
.HButtonBox()
65 self
.vbox
.pack_start(actions
, FALSE
, TRUE
, 0)
66 actions
.set_layout(g
.BUTTONBOX_END
)
67 actions
.set_border_width(5)
68 actions
.set_spacing(4)
71 from EditBox
import EditBox
73 button
= g
.Button(stock
= g
.STOCK_NEW
)
75 button
.connect('clicked', new
)
78 sel
= self
.list.get_selection()
80 for iter in memo_list
:
81 if sel
.iter_is_selected(iter):
82 m
= memo_list
.get_memo_by_iter(iter)
85 rox
.alert(_('You need to select some memos first!'))
89 message
= _("Really delete memo '%s'?") % memos
[0].brief
91 message
= _('Really delete %d memos?') % l
93 box
= g
.MessageDialog(None, 0, g
.MESSAGE_QUESTION
,
94 g
.BUTTONS_CANCEL
, message
)
96 if rox
.confirm(message
, g
.STOCK_DELETE
):
98 memo_list
.delete(m
, update
= 0)
99 memo_list
.notify_changed()
100 button
= g
.Button(stock
= g
.STOCK_DELETE
)
102 button
.connect('clicked', delete
)
105 sel
= self
.list.get_selection()
107 for iter in memo_list
:
108 if sel
.iter_is_selected(iter):
109 m
= memo_list
.get_memo_by_iter(iter)
112 rox
.alert(_('You need to select exactly one memo first!'))
114 from EditBox
import EditBox
115 EditBox(memos
[0]).show()
116 button
= rox
.ButtonMixed(g
.STOCK_PROPERTIES
, _('_Edit'))
118 button
.connect('clicked', edit
)
122 def response(self
, box
, response
):
123 if response
== int(g
.RESPONSE_CANCEL
):