1
# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
from bzrlib.plugins.gtk import _i18n
27
from bzrlib.plugins.gtk.dialog import question_dialog
28
from bzrlib.plugins.loom import branch as loom_branch
30
class LoomDialog(gtk.Dialog):
31
"""Simple Loom browse dialog."""
33
def __init__(self, branch, parent=None):
34
gtk.Dialog.__init__(self, title="Threads",
37
buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_OK))
44
loom_branch.require_loom_branch(self.branch)
45
except loom_branch.NotALoom:
46
response = question_dialog(
47
_i18n("Upgrade to Loom branch?"),
48
_i18n("Branch is not a loom branch. Upgrade to Loom format?"),
50
# Doesn't set a parent for the dialog..
51
if response == gtk.RESPONSE_NO:
53
assert self.branch.nick is not None
54
loom_branch.loomify(self.branch)
55
return super(LoomDialog, self).run()
58
self._threads_scroller = gtk.ScrolledWindow()
59
self._threads_scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
60
self._threads_view = gtk.TreeView()
61
self._threads_view.show()
62
self._threads_scroller.add(self._threads_view)
63
self._threads_scroller.set_shadow_type(gtk.SHADOW_IN)
64
self._threads_scroller.show()
65
self.vbox.pack_start(self._threads_scroller)
67
self._threads_store = gtk.ListStore(
68
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
69
self._threads_view.set_model(self._threads_store)
70
self._threads_view.append_column(gtk.TreeViewColumn("Name", gtk.CellRendererText(), text=0))
72
# Buttons: combine-thread, export-loom, revert-loom, up-thread
73
self.set_default_size(200, 350)
77
def _load_threads(self):
78
self._threads_store.clear()
80
self.branch.lock_read()
82
threads = self.branch.get_loom_state().get_threads()
83
for thread in reversed(threads):
84
self._threads_store.append(thread)