/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: Jelmer Vernooij
  • Date: 2008-06-29 18:12:29 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629181229-1l2m4cf7vvbyh8qg
Simplify progress bar code, use embedded progress bar inside viz window.

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