/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 revisionmenu.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:
 
1
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
"""Simple popup menu for revisions."""
 
17
 
 
18
try:
 
19
    import pygtk
 
20
    pygtk.require("2.0")
 
21
except:
 
22
    pass
 
23
 
 
24
import bzrlib
 
25
import gtk
 
26
import gobject
 
27
from bzrlib import (errors, ui)
 
28
from bzrlib.revision import NULL_REVISION
 
29
 
 
30
class RevisionPopupMenu(gtk.Menu):
 
31
 
 
32
    __gsignals__ = {
 
33
            'tag-added': (
 
34
                gobject.SIGNAL_RUN_FIRST,
 
35
                gobject.TYPE_NONE,
 
36
                (gobject.TYPE_STRING, gobject.TYPE_STRING)
 
37
            )
 
38
    }
 
39
 
 
40
    def __init__(self, repository, revids, branch=None, wt=None):
 
41
        super(RevisionPopupMenu, self).__init__()
 
42
        self.branch = branch
 
43
        self.repository = repository
 
44
        self.wt = wt
 
45
        self.revids = revids
 
46
        self.create_items()
 
47
 
 
48
    def create_items(self):
 
49
        if len(self.revids) == 1:
 
50
            item = gtk.MenuItem("View _Changes")
 
51
            item.connect('activate', self.show_diff)
 
52
            self.append(item)
 
53
            self.show_all()
 
54
 
 
55
            item = gtk.MenuItem("_Push")
 
56
            item.connect('activate', self.show_push)
 
57
            self.append(item)
 
58
            self.show_all()
 
59
 
 
60
            item = gtk.MenuItem("_Tag Revision")
 
61
            item.connect('activate', self.show_tag)
 
62
            self.append(item)
 
63
            self.show_all()
 
64
 
 
65
            item = gtk.MenuItem("_Merge Directive")
 
66
            item.connect('activate', self.store_merge_directive)
 
67
            # FIXME: self.append(item)
 
68
            self.show_all()
 
69
            
 
70
            if self.wt:
 
71
                item = gtk.MenuItem("_Revert to this revision")
 
72
                item.connect('activate', self.revert)
 
73
                self.append(item)
 
74
                self.show_all()
 
75
 
 
76
    def store_merge_directive(self, item):
 
77
        from bzrlib.plugins.gtk.mergedirective import CreateMergeDirectiveDialog
 
78
        window = CreateMergeDirectiveDialog(self.branch, self.revids[0])
 
79
        window.show()
 
80
 
 
81
    def show_diff(self, item):
 
82
        from bzrlib.plugins.gtk.diff import DiffWindow
 
83
        window = DiffWindow(parent=self.parent)
 
84
        parentids = self.repository.revision_parents(self.revids[0])
 
85
 
 
86
        if len(parentids) == 0:
 
87
            parentid = NULL_REVISION
 
88
        else:
 
89
            parentid = parentids[0]
 
90
 
 
91
        rev_tree    = self.repository.revision_tree(self.revids[0])
 
92
        parent_tree = self.repository.revision_tree(parentid)
 
93
        window.set_diff(self.revids[0], rev_tree, parent_tree)
 
94
        window.show()
 
95
 
 
96
    def show_push(self, item):
 
97
        from bzrlib.plugins.gtk.push import PushDialog
 
98
        dialog = PushDialog(self.repository, self.revids[0], self.branch)
 
99
        response = dialog.run()
 
100
 
 
101
        if response != gtk.RESPONSE_NONE:
 
102
            dialog.destroy()
 
103
 
 
104
    def show_tag(self, item):
 
105
        from bzrlib.plugins.gtk.tags import AddTagDialog
 
106
        dialog = AddTagDialog(self.repository, self.revids[0], self.branch)
 
107
        response = dialog.run()
 
108
 
 
109
        if response != gtk.RESPONSE_NONE:
 
110
            dialog.hide()
 
111
        
 
112
            if response == gtk.RESPONSE_OK:
 
113
                self.emit('tag-added', dialog.tagname, dialog._revid)
 
114
            
 
115
            dialog.destroy()
 
116
    
 
117
    def revert(self, item):
 
118
        pb = ui.ui_factory.nested_progress_bar()
 
119
        revision_tree = self.branch.repository.revision_tree(self.revids[0])
 
120
        try:
 
121
            self.wt.revert(old_tree = revision_tree, pb = pb)
 
122
        finally:
 
123
            pb.finished()