/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: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

Show diffs side-by-side

added added

removed removed

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