/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-10 18:44:39 UTC
  • mto: This revision was merged to the branch mainline in revision 730.
  • Revision ID: jelmer@samba.org-20110410184439-g7hqaacexqtviq13
Move i18n support to a separate file, so gettext files aren't loaded unless bzr-gtk is used.

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