/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: 2008-06-29 18:12:29 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629181229-1l2m4cf7vvbyh8qg
Simplify progress bar code, use embedded progress bar inside viz window.

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