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
19
from gi.repository import Gtk
20
from gi.repository import GObject
22
28
from bzrlib.config import GlobalConfig
23
from bzrlib.plugins.gtk.i18n import _i18n
29
from bzrlib.plugins.gtk import _i18n
24
30
from bzrlib.plugins.gtk.dialog import (
30
class ConflictsDialog(Gtk.Dialog):
36
class ConflictsDialog(gtk.Dialog):
31
37
""" This dialog displays the list of conflicts. """
33
39
def __init__(self, wt, parent=None):
34
40
""" Initialize the Conflicts dialog. """
35
super(ConflictsDialog, self).__init__(
36
title="Conflicts - Olive", parent=parent, flags=0,
37
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL))
41
gtk.Dialog.__init__(self, title="Conflicts - Olive",
44
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL))
42
49
# Create the widgets
43
self._scrolledwindow = Gtk.ScrolledWindow()
44
self._treeview = Gtk.TreeView()
45
self._label_diff3 = Gtk.Label(label=_i18n("External utility:"))
46
self._entry_diff3 = Gtk.Entry()
47
self._image_diff3 = Gtk.Image()
48
self._button_diff3 = Gtk.Button()
49
self._hbox_diff3 = Gtk.HBox()
50
self._scrolledwindow = gtk.ScrolledWindow()
51
self._treeview = gtk.TreeView()
52
self._label_diff3 = gtk.Label(_i18n("External utility:"))
53
self._entry_diff3 = gtk.Entry()
54
self._image_diff3 = gtk.Image()
55
self._button_diff3 = gtk.Button()
56
self._hbox_diff3 = gtk.HBox()
52
59
self._button_diff3.connect('clicked', self._on_diff3_clicked)
55
self._scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
56
Gtk.PolicyType.AUTOMATIC)
57
self._image_diff3.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON)
62
self._scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
64
self._image_diff3.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
58
65
self._button_diff3.set_image(self._image_diff3)
59
66
self._entry_diff3.set_text(self._get_diff3())
60
67
self._hbox_diff3.set_spacing(3)
61
content_area = self.get_content_area()
62
content_area.set_spacing(3)
68
self.vbox.set_spacing(3)
63
69
self.set_default_size(400, 300)
66
self._hbox_diff3.pack_start(self._label_diff3, False, False, 0)
67
self._hbox_diff3.pack_start(self._entry_diff3, True, True, 0)
68
self._hbox_diff3.pack_start(self._button_diff3, False, False, 0)
72
self._hbox_diff3.pack_start(self._label_diff3, False, False)
73
self._hbox_diff3.pack_start(self._entry_diff3, True, True)
74
self._hbox_diff3.pack_start(self._button_diff3, False, False)
69
75
self._scrolledwindow.add(self._treeview)
70
content_area.pack_start(self._scrolledwindow, True, True, 0)
71
content_area.pack_start(self._hbox_diff3, False, False, 0)
76
self.vbox.pack_start(self._scrolledwindow, True, True)
77
self.vbox.pack_start(self._hbox_diff3, False, False)
73
79
# Create the conflict list
74
80
self._create_conflicts()
77
content_area.show_all()
79
85
def _get_diff3(self):
80
86
""" Get the specified diff3 utility. Default is meld. """
92
98
def _create_conflicts(self):
93
99
""" Construct the list of conflicts. """
94
100
if len(self.wt.conflicts()) == 0:
95
self.model = Gtk.ListStore(GObject.TYPE_STRING)
101
self.model = gtk.ListStore(gobject.TYPE_STRING)
96
102
self._treeview.set_model(self.model)
97
self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Conflicts'),
98
Gtk.CellRendererText(), text=0))
103
self._treeview.append_column(gtk.TreeViewColumn(_i18n('Conflicts'),
104
gtk.CellRendererText(), text=0))
99
105
self._treeview.set_headers_visible(False)
100
106
self.model.append([ _i18n("No conflicts in working tree.") ])
101
107
self._button_diff3.set_sensitive(False)
103
self.model = Gtk.ListStore(GObject.TYPE_STRING,
109
self.model = gtk.ListStore(gobject.TYPE_STRING,
106
112
self._treeview.set_model(self.model)
107
self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Path'),
108
Gtk.CellRendererText(), text=0))
109
self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Type'),
110
Gtk.CellRendererText(), text=1))
113
self._treeview.append_column(gtk.TreeViewColumn(_i18n('Path'),
114
gtk.CellRendererText(), text=0))
115
self._treeview.append_column(gtk.TreeViewColumn(_i18n('Type'),
116
gtk.CellRendererText(), text=1))
111
117
self._treeview.set_search_column(0)
112
118
for conflict in self.wt.conflicts():
113
119
if conflict.typestring == 'path conflict':