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
26
from bzrlib.plugins.gtk import _i18n
17
from gi.repository import Gtk
18
from gi.repository import GObject
27
20
from bzrlib.plugins.gtk.diff import DiffWidget
28
21
from bzrlib.plugins.gtk.dialog import question_dialog
29
from bzrlib.plugins.loom import branch as loom_branch
30
from bzrlib.plugins.loom import tree as loom_tree
32
class LoomDialog(gtk.Dialog):
22
from bzrlib.plugins.loom import (
23
branch as loom_branch,
26
from bzrlib.plugins.gtk.i18n import _i18n
29
class LoomDialog(Gtk.Dialog):
33
30
"""Simple Loom browse dialog."""
35
32
def __init__(self, branch, tree=None, parent=None):
36
gtk.Dialog.__init__(self, title="Threads",
39
buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_OK))
33
super(LoomDialog, self).__init__(
34
title="Threads", parent=parent, flags=0,
35
buttons=(Gtk.STOCK_CLOSE,Gtk.ResponseType.OK))
40
36
self.branch = branch
41
37
if tree is not None:
42
38
self.tree = loom_tree.LoomTreeDecorator(tree)
54
50
_i18n("Branch is not a loom branch. Upgrade to Loom format?"),
56
52
# Doesn't set a parent for the dialog..
57
if response == gtk.RESPONSE_NO:
53
if response == Gtk.ResponseType.NO:
59
55
assert self.branch.nick is not None
60
56
loom_branch.loomify(self.branch)
62
58
return super(LoomDialog, self).run()
64
60
def _construct(self):
67
self._threads_scroller = gtk.ScrolledWindow()
68
self._threads_scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
69
self._threads_view = gtk.TreeView()
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
66
self._threads_scroller.add(self._threads_view)
71
self._threads_scroller.set_shadow_type(gtk.SHADOW_IN)
72
hbox.pack_start(self._threads_scroller)
67
self._threads_scroller.set_shadow_type(Gtk.ShadowType.IN)
68
hbox.pack_start(self._threads_scroller, True, True, 0)
74
self._threads_store = gtk.ListStore(
75
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING)
70
self._threads_store = Gtk.ListStore(
71
GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
76
72
self._threads_view.set_model(self._threads_store)
77
self._threads_view.append_column(gtk.TreeViewColumn("Name", gtk.CellRendererText(), text=0))
73
self._threads_view.append_column(Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0))
78
74
self._threads_view.connect('cursor-changed', self._on_view_thread)
79
75
if self.tree is not None:
80
76
self._threads_view.connect('row-activated', self._on_switch_thread)
82
78
self._diff = DiffWidget()
84
hbox.pack_end(self._diff)
80
hbox.pack_end(self._diff, False, False, 0)
87
self.vbox.pack_start(hbox)
83
self.get_content_area().pack_start(hbox, True, True, 0)
89
85
# FIXME: Buttons: combine-thread, revert-loom, record
90
86
self.set_default_size(500, 350)