/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-30 13:04:15 UTC
  • mto: (0.14.3 main)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060930130415-aba4100709e11f0a
Loads of fixes. Pyflakes cleanup.

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