/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: Aaron Bentley
  • Date: 2007-01-17 06:42:55 UTC
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: aaron.bentley@utoronto.ca-20070117064255-x4gznz5e0lyjq3gk
Remove usused span selector

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import sys
18
 
 
19
17
try:
20
18
    import pygtk
21
19
    pygtk.require("2.0")
22
20
except:
23
21
    pass
24
 
try:
25
 
    import gtk
26
 
    import gtk.glade
27
 
    import gobject
28
 
    import pango
29
 
except:
30
 
    sys.exit(1)
31
 
 
32
 
import bzrlib
33
 
import bzrlib.errors as errors
34
 
 
35
 
if bzrlib.version_info < (0, 9):
36
 
    # function deprecated after 0.9
37
 
    from bzrlib.delta import compare_trees
38
 
 
39
 
from bzrlib.status import show_tree_status
40
 
from bzrlib.workingtree import WorkingTree
41
 
 
42
 
from dialog import OliveDialog
 
22
 
 
23
import gtk
 
24
import gtk.glade
 
25
 
 
26
from guifiles import GLADEFILENAME
 
27
 
43
28
 
44
29
class OliveStatus:
45
30
    """ Display Status window and perform the needed actions. """
46
 
    def __init__(self, gladefile, comm, dialog):
 
31
    def __init__(self, wt, wtpath):
47
32
        """ 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
 
33
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_status')
55
34
        
56
35
        # Get the Status window widget
57
36
        self.window = self.glade.get_widget('window_status')
58
37
        
 
38
        self.wt = wt
 
39
        self.wtpath = wtpath
 
40
        
59
41
        # 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)
 
42
        file_id = self.wt.path2id(wtpath)
70
43
 
71
 
        self.notbranch = False
72
 
        if file_id is None:
73
 
            self.notbranch = True
74
 
            return
75
 
        
76
44
        # Set the old working tree
77
45
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
78
46
        
98
66
        column.add_attribute(cell, "text", 0)
99
67
        self.treeview.append_column(column)
100
68
        
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)
 
69
        delta = self.wt.changes_from(self.old_tree)
105
70
 
 
71
        changes = False
 
72
        
106
73
        if len(delta.added):
 
74
            changes = True
107
75
            titer = self.model.append(None, [ _('Added'), None ])
108
76
            for path, id, kind in delta.added:
109
77
                self.model.append(titer, [ path, path ])
110
78
 
111
79
        if len(delta.removed):
 
80
            changes = True
112
81
            titer = self.model.append(None, [ _('Removed'), None ])
113
82
            for path, id, kind in delta.removed:
114
83
                self.model.append(titer, [ path, path ])
115
84
 
116
85
        if len(delta.renamed):
 
86
            changes = True
117
87
            titer = self.model.append(None, [ _('Renamed'), None ])
118
88
            for oldpath, newpath, id, kind, text_modified, meta_modified \
119
89
                    in delta.renamed:
120
90
                self.model.append(titer, [ oldpath, newpath ])
121
91
 
122
92
        if len(delta.modified):
 
93
            changes = True
123
94
            titer = self.model.append(None, [ _('Modified'), None ])
124
95
            for path, id, kind, text_modified, meta_modified in delta.modified:
125
96
                self.model.append(titer, [ path, path ])
126
97
        
127
98
        done_unknown = False
128
99
        for path in self.wt.unknowns():
 
100
            changes = True
129
101
            if not done_unknown:
130
102
                titer = self.model.append(None, [ _('Unknown'), None ])
131
103
                done_unknown = True
132
104
            self.model.append(titer, [ path, path ])
133
105
 
 
106
        if not changes:
 
107
            self.model.append(None, [ _('No changes.'), None ])
 
108
 
134
109
        self.treeview.expand_all()
135
110
    
136
111
    def display(self):
137
112
        """ 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()
 
113
        self.window.show_all()
144
114
 
145
115
    def close(self, widget=None):
146
116
        self.window.destroy()