/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: Aaron Bentley
  • Date: 2007-03-19 14:04:43 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: abentley@panoramicfeedback.com-20070319140443-nimeomjezt1nzf0h
Better behavior when unable to go back

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 _i18n
25
 
 
26
 
 
27
 
class StatusDialog(gtk.Dialog):
 
24
 
 
25
class StatusDialog(gtk.MessageDialog):
28
26
    """ Display Status window and perform the needed actions. """
29
 
    def __init__(self, wt, wtpath, revision=None):
 
27
    def __init__(self, wt, wtpath):
30
28
        """ Initialize the Status window. """
31
 
        super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
 
29
        super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=gtk.BUTTONS_OK)
32
30
        self.set_title("Working tree changes")
33
 
        self.set_default_response(gtk.RESPONSE_CLOSE)
 
31
        self.set_image(gtk.Label("Working tree status"))
34
32
        self._create()
35
33
        self.wt = wt
36
34
        self.wtpath = wtpath
37
 
 
38
 
        if revision is None:
39
 
            revision = self.wt.branch.last_revision()
40
 
            
41
35
        # Set the old working tree
42
 
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
 
36
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
43
37
        # Generate status output
44
38
        self._generate_status()
45
39
 
46
40
    def _create(self):
47
41
        self.set_default_size(400, 300)
48
 
        self.set_has_separator(False)
49
 
        sw = gtk.ScrolledWindow()
50
 
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
51
 
        sw.set_shadow_type(gtk.SHADOW_IN)
 
42
        scrolledwindow = gtk.ScrolledWindow()
 
43
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
52
44
        self.treeview = gtk.TreeView()
53
 
        sw.add(self.treeview)
54
 
        self.vbox.pack_start(sw, True, True)
 
45
        scrolledwindow.add(self.treeview)
 
46
        self.vbox.pack_start(scrolledwindow, True, True)
55
47
        self.vbox.show_all()
56
48
 
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.vbox.set_spacing(2)
61
 
        self.action_area.set_border_width(5)
62
 
 
63
 
 
64
49
    def row_diff(self, tv, path, tvc):
65
50
        file = self.model[path][1]
66
51
        if file is None:
71
56
        window.set_file(file)
72
57
        window.show()
73
58
 
74
 
 
75
59
    def _generate_status(self):
76
60
        """ Generate 'bzr status' output. """
77
61
        self.model = gtk.TreeStore(str, str)
92
76
        
93
77
        if len(delta.added):
94
78
            changes = True
95
 
            titer = self.model.append(None, [ _i18n('Added'), None ])
 
79
            titer = self.model.append(None, [ _('Added'), None ])
96
80
            for path, id, kind in delta.added:
97
81
                self.model.append(titer, [ path, path ])
98
82
 
99
83
        if len(delta.removed):
100
84
            changes = True
101
 
            titer = self.model.append(None, [ _i18n('Removed'), None ])
 
85
            titer = self.model.append(None, [ _('Removed'), None ])
102
86
            for path, id, kind in delta.removed:
103
87
                self.model.append(titer, [ path, path ])
104
88
 
105
89
        if len(delta.renamed):
106
90
            changes = True
107
 
            titer = self.model.append(None, [ _i18n('Renamed'), None ])
 
91
            titer = self.model.append(None, [ _('Renamed'), None ])
108
92
            for oldpath, newpath, id, kind, text_modified, meta_modified \
109
93
                    in delta.renamed:
110
94
                self.model.append(titer, [ oldpath, newpath ])
111
95
 
112
96
        if len(delta.modified):
113
97
            changes = True
114
 
            titer = self.model.append(None, [ _i18n('Modified'), None ])
 
98
            titer = self.model.append(None, [ _('Modified'), None ])
115
99
            for path, id, kind, text_modified, meta_modified in delta.modified:
116
100
                self.model.append(titer, [ path, path ])
117
101
        
119
103
        for path in self.wt.unknowns():
120
104
            changes = True
121
105
            if not done_unknown:
122
 
                titer = self.model.append(None, [ _i18n('Unknown'), None ])
 
106
                titer = self.model.append(None, [ _('Unknown'), None ])
123
107
                done_unknown = True
124
108
            self.model.append(titer, [ path, path ])
125
109
 
126
110
        if not changes:
127
 
            self.model.append(None, [ _i18n('No changes.'), None ])
 
111
            self.model.append(None, [ _('No changes.'), None ])
128
112
 
129
113
        self.treeview.expand_all()
130
114
    
 
115
    def display(self):
 
116
        """ Display the Diff window. """
 
117
        self.window.show_all()
 
118
 
131
119
    def close(self, widget=None):
132
120
        self.window.destroy()