/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-07-31 15:52:43 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110731155243-ln8istmxbryhb4pz
Mechanical changes made by pygi.convert.sh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import subprocess
24
24
 
25
 
import gtk
26
 
import gobject
 
25
from gi.repository import Gtk
 
26
from gi.repository import GObject
27
27
 
28
28
from bzrlib.config import GlobalConfig
29
29
from bzrlib.plugins.gtk import _i18n
30
 
 
31
 
from dialog import error_dialog, warning_dialog
32
 
from errors import show_bzr_error
33
 
 
34
 
class ConflictsDialog(gtk.Dialog):
 
30
from bzrlib.plugins.gtk.dialog import (
 
31
    error_dialog,
 
32
    warning_dialog,
 
33
    )
 
34
 
 
35
 
 
36
class ConflictsDialog(Gtk.Dialog):
35
37
    """ This dialog displays the list of conflicts. """
 
38
 
36
39
    def __init__(self, wt, parent=None):
37
40
        """ Initialize the Conflicts dialog. """
38
 
        gtk.Dialog.__init__(self, title="Conflicts - Olive",
 
41
        GObject.GObject.__init__(self, title="Conflicts - Olive",
39
42
                                  parent=parent,
40
43
                                  flags=0,
41
 
                                  buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL))
42
 
        
 
44
                                  buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL))
 
45
 
43
46
        # Get arguments
44
47
        self.wt = wt
45
 
        
 
48
 
46
49
        # Create the widgets
47
 
        self._scrolledwindow = gtk.ScrolledWindow()
48
 
        self._treeview = gtk.TreeView()
49
 
        self._label_diff3 = gtk.Label(_i18n("External utility:"))
50
 
        self._entry_diff3 = gtk.Entry()
51
 
        self._image_diff3 = gtk.Image()
52
 
        self._button_diff3 = gtk.Button()
53
 
        self._hbox_diff3 = gtk.HBox()
54
 
        
 
50
        self._scrolledwindow = Gtk.ScrolledWindow()
 
51
        self._treeview = Gtk.TreeView()
 
52
        self._label_diff3 = Gtk.Label(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()
 
57
 
55
58
        # Set callbacks
56
59
        self._button_diff3.connect('clicked', self._on_diff3_clicked)
57
 
        
 
60
 
58
61
        # Set properties
59
 
        self._scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
60
 
                                        gtk.POLICY_AUTOMATIC)
61
 
        self._image_diff3.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
 
62
        self._scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
 
63
                                        Gtk.PolicyType.AUTOMATIC)
 
64
        self._image_diff3.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON)
62
65
        self._button_diff3.set_image(self._image_diff3)
63
66
        self._entry_diff3.set_text(self._get_diff3())
64
67
        self._hbox_diff3.set_spacing(3)
65
68
        self.vbox.set_spacing(3)
66
69
        self.set_default_size(400, 300)
67
 
        
 
70
 
68
71
        # Construct dialog
69
72
        self._hbox_diff3.pack_start(self._label_diff3, False, False)
70
73
        self._hbox_diff3.pack_start(self._entry_diff3, True, True)
72
75
        self._scrolledwindow.add(self._treeview)
73
76
        self.vbox.pack_start(self._scrolledwindow, True, True)
74
77
        self.vbox.pack_start(self._hbox_diff3, False, False)
75
 
        
 
78
 
76
79
        # Create the conflict list
77
80
        self._create_conflicts()
78
 
        
 
81
 
79
82
        # Show the dialog
80
83
        self.vbox.show_all()
81
 
    
 
84
 
82
85
    def _get_diff3(self):
83
86
        """ Get the specified diff3 utility. Default is meld. """
84
87
        config = GlobalConfig()
86
89
        if diff3 is None:
87
90
            diff3 = 'meld'
88
91
        return diff3
89
 
    
 
92
 
90
93
    def _set_diff3(self, cmd):
91
94
        """ Set the default diff3 utility to cmd. """
92
95
        config = GlobalConfig()
93
96
        config.set_user_option('gconflicts_diff3', cmd)
94
 
    
 
97
 
95
98
    def _create_conflicts(self):
96
99
        """ Construct the list of conflicts. """
97
100
        if len(self.wt.conflicts()) == 0:
98
 
            self.model = gtk.ListStore(gobject.TYPE_STRING)
 
101
            self.model = Gtk.ListStore(GObject.TYPE_STRING)
99
102
            self._treeview.set_model(self.model)
100
 
            self._treeview.append_column(gtk.TreeViewColumn(_i18n('Conflicts'),
101
 
                                         gtk.CellRendererText(), text=0))
102
 
            self._treeview.set_headers_visible(False)            
 
103
            self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Conflicts'),
 
104
                                         Gtk.CellRendererText(), text=0))
 
105
            self._treeview.set_headers_visible(False)
103
106
            self.model.append([ _i18n("No conflicts in working tree.") ])
104
107
            self._button_diff3.set_sensitive(False)
105
108
        else:
106
 
            self.model = gtk.ListStore(gobject.TYPE_STRING,
107
 
                                       gobject.TYPE_STRING,
108
 
                                       gobject.TYPE_STRING)
 
109
            self.model = Gtk.ListStore(GObject.TYPE_STRING,
 
110
                                       GObject.TYPE_STRING,
 
111
                                       GObject.TYPE_STRING)
109
112
            self._treeview.set_model(self.model)
110
 
            self._treeview.append_column(gtk.TreeViewColumn(_i18n('Path'),
111
 
                                         gtk.CellRendererText(), text=0))
112
 
            self._treeview.append_column(gtk.TreeViewColumn(_i18n('Type'),
113
 
                                         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))
114
117
            self._treeview.set_search_column(0)
115
118
            for conflict in self.wt.conflicts():
116
119
                if conflict.typestring == 'path conflict':
133
136
                    t = _i18n("deleting parent")
134
137
                else:
135
138
                    t = _i18n("unknown type of conflict")
136
 
                
137
 
                self.model.append([ conflict.path, t, conflict.typestring ]) 
138
 
    
 
139
 
 
140
                self.model.append([ conflict.path, t, conflict.typestring ])
 
141
 
139
142
    def _get_selected_file(self):
140
143
        """ Return the selected conflict's filename. """
141
144
        treeselection = self._treeview.get_selection()
142
145
        (model, iter) = treeselection.get_selected()
143
 
        
 
146
 
144
147
        if iter is None:
145
148
            return None
146
149
        else:
147
150
            return model.get_value(iter, 0)
148
 
    
 
151
 
149
152
    def _get_selected_type(self):
150
153
        """ Return the type of the selected conflict. """
151
154
        treeselection = self._treeview.get_selection()
152
155
        (model, iter) = treeselection.get_selected()
153
 
        
 
156
 
154
157
        if iter is None:
155
158
            return None
156
159
        else:
157
160
            return model.get_value(iter, 2)
158
 
    
 
161
 
159
162
    def _on_diff3_clicked(self, widget):
160
163
        """ Launch external utility to resolve conflicts. """
161
164
        self._set_diff3(self._entry_diff3.get_text())