14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from gi.repository import Gtk
18
from gi.repository import GObject
20
26
from bzrlib.plugins.gtk.diff import DiffWidget
21
27
from bzrlib.plugins.gtk.dialog import question_dialog
26
32
from bzrlib.plugins.gtk.i18n import _i18n
29
class LoomDialog(Gtk.Dialog):
35
class LoomDialog(gtk.Dialog):
30
36
"""Simple Loom browse dialog."""
32
38
def __init__(self, branch, tree=None, parent=None):
33
super(LoomDialog, self).__init__(
34
title="Threads", parent=parent, flags=0,
35
buttons=(Gtk.STOCK_CLOSE,Gtk.ResponseType.OK))
39
gtk.Dialog.__init__(self, title="Threads",
42
buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_OK))
36
43
self.branch = branch
37
44
if tree is not None:
38
45
self.tree = loom_tree.LoomTreeDecorator(tree)
50
57
_i18n("Branch is not a loom branch. Upgrade to Loom format?"),
52
59
# Doesn't set a parent for the dialog..
53
if response == Gtk.ResponseType.NO:
60
if response == gtk.RESPONSE_NO:
55
62
assert self.branch.nick is not None
56
63
loom_branch.loomify(self.branch)
58
65
return super(LoomDialog, self).run()
60
67
def _construct(self):
63
self._threads_scroller = Gtk.ScrolledWindow()
64
self._threads_scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
65
self._threads_view = Gtk.TreeView()
70
self._threads_scroller = gtk.ScrolledWindow()
71
self._threads_scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
72
self._threads_view = gtk.TreeView()
66
73
self._threads_scroller.add(self._threads_view)
67
self._threads_scroller.set_shadow_type(Gtk.ShadowType.IN)
68
hbox.pack_start(self._threads_scroller, True, True, 0)
74
self._threads_scroller.set_shadow_type(gtk.SHADOW_IN)
75
hbox.pack_start(self._threads_scroller)
70
self._threads_store = Gtk.ListStore(
71
GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
77
self._threads_store = gtk.ListStore(
78
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING)
72
79
self._threads_view.set_model(self._threads_store)
73
self._threads_view.append_column(Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0))
80
self._threads_view.append_column(gtk.TreeViewColumn("Name", gtk.CellRendererText(), text=0))
74
81
self._threads_view.connect('cursor-changed', self._on_view_thread)
75
82
if self.tree is not None:
76
83
self._threads_view.connect('row-activated', self._on_switch_thread)
78
85
self._diff = DiffWidget()
80
hbox.pack_end(self._diff, False, False, 0)
87
hbox.pack_end(self._diff)
83
self.get_content_area().pack_start(hbox, True, True, 0)
90
self.vbox.pack_start(hbox)
85
92
# FIXME: Buttons: combine-thread, revert-loom, record
86
93
self.set_default_size(500, 350)