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

  • Committer: Adrian Wilkins
  • Date: 2008-04-24 15:26:14 UTC
  • mto: This revision was merged to the branch mainline in revision 470.
  • Revision ID: adrian.wilkins@gmail.com-20080424152614-2rnnljbro6vzqvf7
Detect the reserved null: revision in appropriate places. 

This removes a huge shower of stack traces that get dumped to console when 
you look at the bottom of a log.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pass
22
22
 
23
23
import gtk
24
 
from bzrlib.plugins.gtk import (
25
 
    _i18n,
26
 
    window,
27
 
    )
28
 
 
29
 
 
30
 
class StatusWindow(window.Window):
 
24
 
 
25
class StatusDialog(gtk.Dialog):
31
26
    """ Display Status window and perform the needed actions. """
32
27
    def __init__(self, wt, wtpath, revision=None):
33
28
        """ Initialize the Status window. """
34
 
        super(StatusWindow, self).__init__()
 
29
        super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
35
30
        self.set_title("Working tree changes")
36
31
        self._create()
37
32
        self.wt = wt
38
33
        self.wtpath = wtpath
39
 
 
 
34
        
40
35
        if revision is None:
41
36
            revision = self.wt.branch.last_revision()
42
 
 
 
37
            
43
38
        # Set the old working tree
44
39
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
45
40
        # Generate status output
47
42
 
48
43
    def _create(self):
49
44
        self.set_default_size(400, 300)
50
 
        sw = gtk.ScrolledWindow()
51
 
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
52
 
        sw.set_shadow_type(gtk.SHADOW_IN)
 
45
        scrolledwindow = gtk.ScrolledWindow()
 
46
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
53
47
        self.treeview = gtk.TreeView()
54
 
        sw.add(self.treeview)
55
 
        self.add(sw)
56
 
 
57
 
        # sane border and spacing widths (as recommended by GNOME HIG) 
58
 
        self.set_border_width(5)
59
 
        sw.set_border_width(5)
60
 
        self.show_all()
61
 
 
 
48
        scrolledwindow.add(self.treeview)
 
49
        self.vbox.pack_start(scrolledwindow, True, True)
 
50
        self.vbox.show_all()
62
51
 
63
52
    def row_diff(self, tv, path, tvc):
64
53
        file = self.model[path][1]
66
55
            return
67
56
        from bzrlib.plugins.gtk.diff import DiffWindow
68
57
        window = DiffWindow()
69
 
        window.set_diff("Working tree changes", self.wt, self.old_tree)
 
58
        window.set_diff("Working tree changes", self.old_tree, self.wt)
70
59
        window.set_file(file)
71
60
        window.show()
72
61
 
73
 
 
74
62
    def _generate_status(self):
75
63
        """ Generate 'bzr status' output. """
76
64
        self.model = gtk.TreeStore(str, str)
77
65
        self.treeview.set_headers_visible(False)
78
66
        self.treeview.set_model(self.model)
79
67
        self.treeview.connect("row-activated", self.row_diff)
80
 
 
 
68
        
81
69
        cell = gtk.CellRendererText()
82
70
        cell.set_property("width-chars", 20)
83
71
        column = gtk.TreeViewColumn()
84
72
        column.pack_start(cell, expand=True)
85
73
        column.add_attribute(cell, "text", 0)
86
74
        self.treeview.append_column(column)
87
 
 
 
75
        
88
76
        delta = self.wt.changes_from(self.old_tree)
89
77
 
90
78
        changes = False
91
 
 
 
79
        
92
80
        if len(delta.added):
93
81
            changes = True
94
 
            titer = self.model.append(None, [ _i18n('Added'), None ])
 
82
            titer = self.model.append(None, [ _('Added'), None ])
95
83
            for path, id, kind in delta.added:
96
84
                self.model.append(titer, [ path, path ])
97
85
 
98
86
        if len(delta.removed):
99
87
            changes = True
100
 
            titer = self.model.append(None, [ _i18n('Removed'), None ])
 
88
            titer = self.model.append(None, [ _('Removed'), None ])
101
89
            for path, id, kind in delta.removed:
102
90
                self.model.append(titer, [ path, path ])
103
91
 
104
92
        if len(delta.renamed):
105
93
            changes = True
106
 
            titer = self.model.append(None, [ _i18n('Renamed'), None ])
 
94
            titer = self.model.append(None, [ _('Renamed'), None ])
107
95
            for oldpath, newpath, id, kind, text_modified, meta_modified \
108
96
                    in delta.renamed:
109
97
                self.model.append(titer, [ oldpath, newpath ])
110
98
 
111
99
        if len(delta.modified):
112
100
            changes = True
113
 
            titer = self.model.append(None, [ _i18n('Modified'), None ])
 
101
            titer = self.model.append(None, [ _('Modified'), None ])
114
102
            for path, id, kind, text_modified, meta_modified in delta.modified:
115
103
                self.model.append(titer, [ path, path ])
116
 
 
 
104
        
117
105
        done_unknown = False
118
106
        for path in self.wt.unknowns():
119
107
            changes = True
120
108
            if not done_unknown:
121
 
                titer = self.model.append(None, [ _i18n('Unknown'), None ])
 
109
                titer = self.model.append(None, [ _('Unknown'), None ])
122
110
                done_unknown = True
123
111
            self.model.append(titer, [ path, path ])
124
112
 
125
113
        if not changes:
126
 
            self.model.append(None, [ _i18n('No changes.'), None ])
 
114
            self.model.append(None, [ _('No changes.'), None ])
127
115
 
128
116
        self.treeview.expand_all()
129
 
 
 
117
    
130
118
    def close(self, widget=None):
131
119
        self.window.destroy()