/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: Mark Lee
  • Date: 2009-07-11 18:39:14 UTC
  • mto: This revision was merged to the branch mainline in revision 661.
  • Revision ID: bzr@lazymalevolence.com-20090711183914-zuii3et5skiv2njo
Re-ignore credits.pickle.

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