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 #memo_list.watchers.append(self.prime)
61 #def destroyed(widget): memo_list.watchers.remove(self.prime)
62 #self.connect('destroy', destroyed)
64 self
.connect('response', self
.response
)
66 self
.set_default_response(g
.RESPONSE_CANCEL
)
68 actions
= g
.HButtonBox()
69 self
.vbox
.pack_start(actions
, FALSE
, TRUE
, 0)
70 actions
.set_layout(g
.BUTTONBOX_END
)
71 actions
.set_border_width(5)
72 actions
.set_spacing(4)
75 from EditBox
import EditBox
77 button
= g
.Button(stock
= g
.STOCK_NEW
)
79 button
.connect('clicked', new
)
82 sel
= self
.list.get_selection()
84 for iter in memo_list
:
85 if sel
.iter_is_selected(iter):
86 m
= memo_list
.get_memo_by_iter(iter)
89 rox
.alert(_('You need to select some memos first!'))
93 message
= _("Really delete memo '%s'?") % memos
[0].brief
95 message
= _('Really delete %d memos?') % l
97 box
= g
.MessageDialog(None, 0, g
.MESSAGE_QUESTION
,
98 g
.BUTTONS_CANCEL
, message
)
100 if rox
.confirm(message
, g
.STOCK_DELETE
):
102 memo_list
.delete(m
, update
= 0)
103 memo_list
.notify_changed()
104 button
= g
.Button(stock
= g
.STOCK_DELETE
)
106 button
.connect('clicked', delete
)
109 sel
= self
.list.get_selection()
111 for iter in memo_list
:
112 if sel
.iter_is_selected(iter):
113 m
= memo_list
.get_memo_by_iter(iter)
116 rox
.alert(_('You need to select exactly one memo first!'))
118 from EditBox
import EditBox
119 EditBox(memos
[0]).show()
120 button
= rox
.ButtonMixed(g
.STOCK_PROPERTIES
, _('_Edit'))
122 button
.connect('clicked', edit
)
126 def response(self
, box
, response
):
127 if response
== int(g
.RESPONSE_CANCEL
):