/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 olive/status.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-27 19:52:46 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927195246-9354d7ccf56127f5
Don't pass around gladefile all the time. 
Fix bug in status information when files have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import bzrlib
33
33
import bzrlib.errors as errors
34
34
 
35
 
if bzrlib.version_info < (0, 9):
36
 
    # function deprecated after 0.9
37
 
    from bzrlib.delta import compare_trees
38
 
 
39
35
from bzrlib.status import show_tree_status
40
36
from bzrlib.workingtree import WorkingTree
41
37
 
42
38
from dialog import OliveDialog
43
39
 
 
40
from olive import gladefile
 
41
 
44
42
class OliveStatus:
45
43
    """ Display Status window and perform the needed actions. """
46
 
    def __init__(self, gladefile, comm, dialog):
 
44
    def __init__(self, gladefile, wt, wtpath):
47
45
        """ Initialize the Status window. """
48
 
        self.gladefile = gladefile
49
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_status')
50
 
        
51
 
        # Communication object
52
 
        self.comm = comm
53
 
        # Dialog object
54
 
        self.dialog = dialog
 
46
        self.glade = gtk.glade.XML(gladefile, 'window_status')
55
47
        
56
48
        # Get the Status window widget
57
49
        self.window = self.glade.get_widget('window_status')
 
50
        self.wt = wt
 
51
        self.wtpath = wtpath
58
52
        
59
53
        # Check if current location is a branch
60
54
        try:
61
 
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
62
 
            branch = self.wt.branch
 
55
            branch = wt.branch
63
56
        except errors.NotBranchError:
64
57
            self.notbranch = True
65
58
            return
66
59
        except:
67
60
            raise
68
61
        
69
 
        file_id = self.wt.path2id(path)
 
62
        file_id = self.wt.path2id(wtpath)
70
63
 
71
64
        self.notbranch = False
72
65
        if file_id is None:
98
91
        column.add_attribute(cell, "text", 0)
99
92
        self.treeview.append_column(column)
100
93
        
101
 
        if bzrlib.version_info < (0, 9):
102
 
            delta = compare_trees(self.old_tree, self.wt)
103
 
        else:
104
 
            delta = self.wt.changes_from(self.old_tree)
 
94
        delta = self.wt.changes_from(self.old_tree)
105
95
 
 
96
        changes = False
 
97
        
106
98
        if len(delta.added):
 
99
            changes = True
107
100
            titer = self.model.append(None, [ _('Added'), None ])
108
101
            for path, id, kind in delta.added:
109
102
                self.model.append(titer, [ path, path ])
110
103
 
111
104
        if len(delta.removed):
 
105
            changes = True
112
106
            titer = self.model.append(None, [ _('Removed'), None ])
113
107
            for path, id, kind in delta.removed:
114
108
                self.model.append(titer, [ path, path ])
115
109
 
116
110
        if len(delta.renamed):
 
111
            changes = True
117
112
            titer = self.model.append(None, [ _('Renamed'), None ])
118
113
            for oldpath, newpath, id, kind, text_modified, meta_modified \
119
114
                    in delta.renamed:
120
115
                self.model.append(titer, [ oldpath, newpath ])
121
116
 
122
117
        if len(delta.modified):
 
118
            changes = True
123
119
            titer = self.model.append(None, [ _('Modified'), None ])
124
120
            for path, id, kind, text_modified, meta_modified in delta.modified:
125
121
                self.model.append(titer, [ path, path ])
126
122
        
127
123
        done_unknown = False
128
124
        for path in self.wt.unknowns():
 
125
            changes = True
129
126
            if not done_unknown:
130
127
                titer = self.model.append(None, [ _('Unknown'), None ])
131
128
                done_unknown = True
132
129
            self.model.append(titer, [ path, path ])
133
130
 
 
131
        if not changes:
 
132
            self.model.append(None, [ _('No changes.'), None ])
 
133
 
134
134
        self.treeview.expand_all()
135
135
    
136
136
    def display(self):
137
137
        """ Display the Diff window. """
138
138
        if self.notbranch:
139
 
            self.dialog.error_dialog(_('Directory is not a branch'),
 
139
            error_dialog(_('Directory is not a branch'),
140
140
                                     _('You can perform this action only in a branch.'))
141
141
            self.close()
142
142
        else: