/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:
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
import gtk.glade
 
25
 
 
26
from guifiles import GLADEFILENAME
 
27
 
 
28
 
 
29
class OliveStatus:
31
30
    """ Display Status window and perform the needed actions. """
32
 
    def __init__(self, wt, wtpath, revision=None):
 
31
    def __init__(self, wt, wtpath):
33
32
        """ Initialize the Status window. """
34
 
        super(StatusWindow, self).__init__()
35
 
        self.set_title("Working tree changes")
36
 
        self._create()
 
33
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_status')
 
34
        
 
35
        # Get the Status window widget
 
36
        self.window = self.glade.get_widget('window_status')
 
37
        
37
38
        self.wt = wt
38
39
        self.wtpath = wtpath
39
 
 
40
 
        if revision is None:
41
 
            revision = self.wt.branch.last_revision()
 
40
        
 
41
        # Check if current location is a branch
 
42
        file_id = self.wt.path2id(wtpath)
42
43
 
43
44
        # Set the old working tree
44
 
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
 
45
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
 
46
        
 
47
        # Dictionary for signal_autoconnect
 
48
        dic = { "on_button_status_close_clicked": self.close }
 
49
        
 
50
        # Connect the signals to the handlers
 
51
        self.glade.signal_autoconnect(dic)
 
52
        
45
53
        # Generate status output
46
54
        self._generate_status()
47
55
 
48
 
    def _create(self):
49
 
        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)
53
 
        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
 
 
62
 
 
63
 
    def row_diff(self, tv, path, tvc):
64
 
        file = self.model[path][1]
65
 
        if file is None:
66
 
            return
67
 
        from bzrlib.plugins.gtk.diff import DiffWindow
68
 
        window = DiffWindow()
69
 
        window.set_diff("Working tree changes", self.wt, self.old_tree)
70
 
        window.set_file(file)
71
 
        window.show()
72
 
 
73
 
 
74
56
    def _generate_status(self):
75
57
        """ Generate 'bzr status' output. """
76
58
        self.model = gtk.TreeStore(str, str)
77
 
        self.treeview.set_headers_visible(False)
 
59
        self.treeview = self.glade.get_widget('treeview_status')
78
60
        self.treeview.set_model(self.model)
79
 
        self.treeview.connect("row-activated", self.row_diff)
80
 
 
 
61
        
81
62
        cell = gtk.CellRendererText()
82
63
        cell.set_property("width-chars", 20)
83
64
        column = gtk.TreeViewColumn()
84
65
        column.pack_start(cell, expand=True)
85
66
        column.add_attribute(cell, "text", 0)
86
67
        self.treeview.append_column(column)
87
 
 
 
68
        
88
69
        delta = self.wt.changes_from(self.old_tree)
89
70
 
90
71
        changes = False
91
 
 
 
72
        
92
73
        if len(delta.added):
93
74
            changes = True
94
 
            titer = self.model.append(None, [ _i18n('Added'), None ])
 
75
            titer = self.model.append(None, [ _('Added'), None ])
95
76
            for path, id, kind in delta.added:
96
77
                self.model.append(titer, [ path, path ])
97
78
 
98
79
        if len(delta.removed):
99
80
            changes = True
100
 
            titer = self.model.append(None, [ _i18n('Removed'), None ])
 
81
            titer = self.model.append(None, [ _('Removed'), None ])
101
82
            for path, id, kind in delta.removed:
102
83
                self.model.append(titer, [ path, path ])
103
84
 
104
85
        if len(delta.renamed):
105
86
            changes = True
106
 
            titer = self.model.append(None, [ _i18n('Renamed'), None ])
 
87
            titer = self.model.append(None, [ _('Renamed'), None ])
107
88
            for oldpath, newpath, id, kind, text_modified, meta_modified \
108
89
                    in delta.renamed:
109
90
                self.model.append(titer, [ oldpath, newpath ])
110
91
 
111
92
        if len(delta.modified):
112
93
            changes = True
113
 
            titer = self.model.append(None, [ _i18n('Modified'), None ])
 
94
            titer = self.model.append(None, [ _('Modified'), None ])
114
95
            for path, id, kind, text_modified, meta_modified in delta.modified:
115
96
                self.model.append(titer, [ path, path ])
116
 
 
 
97
        
117
98
        done_unknown = False
118
99
        for path in self.wt.unknowns():
119
100
            changes = True
120
101
            if not done_unknown:
121
 
                titer = self.model.append(None, [ _i18n('Unknown'), None ])
 
102
                titer = self.model.append(None, [ _('Unknown'), None ])
122
103
                done_unknown = True
123
104
            self.model.append(titer, [ path, path ])
124
105
 
125
106
        if not changes:
126
 
            self.model.append(None, [ _i18n('No changes.'), None ])
 
107
            self.model.append(None, [ _('No changes.'), None ])
127
108
 
128
109
        self.treeview.expand_all()
 
110
    
 
111
    def display(self):
 
112
        """ Display the Diff window. """
 
113
        self.window.show_all()
129
114
 
130
115
    def close(self, widget=None):
131
116
        self.window.destroy()