/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:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from gi.repository import Gtk
18
 
from bzrlib.plugins.gtk import window
19
 
from bzrlib.plugins.gtk.i18n import _i18n
20
 
 
21
 
 
22
 
class StatusWindow(window.Window):
 
17
try:
 
18
    import pygtk
 
19
    pygtk.require("2.0")
 
20
except:
 
21
    pass
 
22
 
 
23
import gtk
 
24
from bzrlib.plugins.gtk import _i18n
 
25
 
 
26
 
 
27
class StatusDialog(gtk.Dialog):
23
28
    """ Display Status window and perform the needed actions. """
24
 
 
25
29
    def __init__(self, wt, wtpath, revision=None):
26
30
        """ Initialize the Status window. """
27
 
        super(StatusWindow, self).__init__()
 
31
        super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
28
32
        self.set_title("Working tree changes")
29
33
        self._create()
30
34
        self.wt = wt
31
35
        self.wtpath = wtpath
32
 
 
 
36
        
33
37
        if revision is None:
34
38
            revision = self.wt.branch.last_revision()
35
 
 
 
39
            
36
40
        # Set the old working tree
37
41
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
38
42
        # Generate status output
40
44
 
41
45
    def _create(self):
42
46
        self.set_default_size(400, 300)
43
 
        sw = Gtk.ScrolledWindow()
44
 
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
45
 
        sw.set_shadow_type(Gtk.ShadowType.IN)
46
 
        self.treeview = Gtk.TreeView()
47
 
        sw.add(self.treeview)
48
 
        self.add(sw)
49
 
 
50
 
        # sane border and spacing widths (as recommended by GNOME HIG) 
51
 
        self.set_border_width(5)
52
 
        sw.set_border_width(5)
53
 
        self.show_all()
54
 
 
 
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()
55
53
 
56
54
    def row_diff(self, tv, path, tvc):
57
55
        file = self.model[path][1]
59
57
            return
60
58
        from bzrlib.plugins.gtk.diff import DiffWindow
61
59
        window = DiffWindow()
62
 
        window.set_diff("Working tree changes", self.wt, self.old_tree)
 
60
        window.set_diff("Working tree changes", self.old_tree, self.wt)
63
61
        window.set_file(file)
64
62
        window.show()
65
63
 
66
 
 
67
64
    def _generate_status(self):
68
65
        """ Generate 'bzr status' output. """
69
 
        self.model = Gtk.TreeStore(str, str)
 
66
        self.model = gtk.TreeStore(str, str)
70
67
        self.treeview.set_headers_visible(False)
71
68
        self.treeview.set_model(self.model)
72
69
        self.treeview.connect("row-activated", self.row_diff)
73
 
 
74
 
        cell = Gtk.CellRendererText()
 
70
        
 
71
        cell = gtk.CellRendererText()
75
72
        cell.set_property("width-chars", 20)
76
 
        column = Gtk.TreeViewColumn()
77
 
        column.pack_start(cell, True)
 
73
        column = gtk.TreeViewColumn()
 
74
        column.pack_start(cell, expand=True)
78
75
        column.add_attribute(cell, "text", 0)
79
76
        self.treeview.append_column(column)
80
 
 
 
77
        
81
78
        delta = self.wt.changes_from(self.old_tree)
82
79
 
83
80
        changes = False
84
 
 
 
81
        
85
82
        if len(delta.added):
86
83
            changes = True
87
84
            titer = self.model.append(None, [ _i18n('Added'), None ])
106
103
            titer = self.model.append(None, [ _i18n('Modified'), None ])
107
104
            for path, id, kind, text_modified, meta_modified in delta.modified:
108
105
                self.model.append(titer, [ path, path ])
109
 
 
 
106
        
110
107
        done_unknown = False
111
108
        for path in self.wt.unknowns():
112
109
            changes = True
119
116
            self.model.append(None, [ _i18n('No changes.'), None ])
120
117
 
121
118
        self.treeview.expand_all()
122
 
 
 
119
    
123
120
    def close(self, widget=None):
124
121
        self.window.destroy()