/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to conflicts.py

  • Committer: Curtis Hovey
  • Date: 2011-09-03 01:25:04 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110903012504-0jr4diz9033g5df2
Menu fixes.

Show diffs side-by-side

added added

removed removed

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