/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-29 20:59:52 UTC
  • mfrom: (0.8.92 merge)
  • Revision ID: jelmer@samba.org-20060929205952-32ce1f02b7cf334b
MergeĀ OliveĀ code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
try:
25
 
    import gtk
26
 
    import gtk.glade
27
 
    import gobject
28
 
    import pango
29
 
except:
30
 
    sys.exit(1)
 
24
 
 
25
import gtk
 
26
import gtk.glade
 
27
import gobject
 
28
import pango
31
29
 
32
30
import bzrlib
33
31
import bzrlib.errors as errors
34
32
 
35
 
if bzrlib.version_info < (0, 9):
36
 
    # function deprecated after 0.9
37
 
    from bzrlib.delta import compare_trees
38
 
 
39
33
from bzrlib.status import show_tree_status
40
34
from bzrlib.workingtree import WorkingTree
41
35
 
42
 
from dialog import OliveDialog
 
36
from dialog import error_dialog
 
37
 
 
38
from olive import gladefile
43
39
 
44
40
class OliveStatus:
45
41
    """ Display Status window and perform the needed actions. """
46
 
    def __init__(self, gladefile, comm, dialog):
 
42
    def __init__(self, wt, wtpath):
47
43
        """ 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
 
44
        self.glade = gtk.glade.XML(gladefile, 'window_status')
55
45
        
56
46
        # Get the Status window widget
57
47
        self.window = self.glade.get_widget('window_status')
 
48
        self.wt = wt
 
49
        self.wtpath = wtpath
58
50
        
59
51
        # Check if current location is a branch
60
 
        try:
61
 
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
62
 
            branch = self.wt.branch
63
 
        except errors.NotBranchError:
64
 
            self.notbranch = True
65
 
            return
66
 
        except:
67
 
            raise
68
 
        
69
 
        file_id = self.wt.path2id(path)
 
52
        file_id = self.wt.path2id(wtpath)
70
53
 
71
 
        self.notbranch = False
72
 
        if file_id is None:
73
 
            self.notbranch = True
74
 
            return
75
 
        
76
54
        # Set the old working tree
77
55
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
78
56
        
98
76
        column.add_attribute(cell, "text", 0)
99
77
        self.treeview.append_column(column)
100
78
        
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)
 
79
        delta = self.wt.changes_from(self.old_tree)
105
80
 
 
81
        changes = False
 
82
        
106
83
        if len(delta.added):
 
84
            changes = True
107
85
            titer = self.model.append(None, [ _('Added'), None ])
108
86
            for path, id, kind in delta.added:
109
87
                self.model.append(titer, [ path, path ])
110
88
 
111
89
        if len(delta.removed):
 
90
            changes = True
112
91
            titer = self.model.append(None, [ _('Removed'), None ])
113
92
            for path, id, kind in delta.removed:
114
93
                self.model.append(titer, [ path, path ])
115
94
 
116
95
        if len(delta.renamed):
 
96
            changes = True
117
97
            titer = self.model.append(None, [ _('Renamed'), None ])
118
98
            for oldpath, newpath, id, kind, text_modified, meta_modified \
119
99
                    in delta.renamed:
120
100
                self.model.append(titer, [ oldpath, newpath ])
121
101
 
122
102
        if len(delta.modified):
 
103
            changes = True
123
104
            titer = self.model.append(None, [ _('Modified'), None ])
124
105
            for path, id, kind, text_modified, meta_modified in delta.modified:
125
106
                self.model.append(titer, [ path, path ])
126
107
        
127
108
        done_unknown = False
128
109
        for path in self.wt.unknowns():
 
110
            changes = True
129
111
            if not done_unknown:
130
112
                titer = self.model.append(None, [ _('Unknown'), None ])
131
113
                done_unknown = True
132
114
            self.model.append(titer, [ path, path ])
133
115
 
 
116
        if not changes:
 
117
            self.model.append(None, [ _('No changes.'), None ])
 
118
 
134
119
        self.treeview.expand_all()
135
120
    
136
121
    def display(self):
137
122
        """ Display the Diff window. """
138
 
        if self.notbranch:
139
 
            self.dialog.error_dialog(_('Directory is not a branch'),
140
 
                                     _('You can perform this action only in a branch.'))
141
 
            self.close()
142
 
        else:
143
 
            self.window.show_all()
 
123
        self.window.show_all()
144
124
 
145
125
    def close(self, widget=None):
146
126
        self.window.destroy()