/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: Jelmer Vernooij
  • Date: 2011-03-14 20:12:19 UTC
  • Revision ID: jelmer@samba.org-20110314201219-wo692nzwywu6mevh
Fix formatting, imports.

Show diffs side-by-side

added added

removed removed

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