/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: 2011-04-15 01:07:44 UTC
  • mto: This revision was merged to the branch mainline in revision 731.
  • Revision ID: jelmer@samba.org-20110415010744-jf4zxpcll3nvc8k2
Fix signal handling.

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