/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 __init__.py

  • Committer: Dan Loda
  • Date: 2005-10-24 07:32:48 UTC
  • mto: (0.1.4)
  • mto: This revision was merged to the branch mainline in revision 49.
  • Revision ID: danloda@gmail.com-20051024073248-2695df551fd01dbc
First working version of xannotate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 Dan Loda <danloda@gmail.com>
 
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
 
 
17
import pygtk
 
18
pygtk.require("2.0")
 
19
import gtk
 
20
 
 
21
from bzrlib.branch import Branch
 
22
from bzrlib.commands import Command, register_command
 
23
from bzrlib.errors import NotVersionedError
 
24
from bzrlib.option import Option
 
25
 
 
26
 
 
27
class cmd_xannotate(Command):
 
28
    """GTK+ annotate.
 
29
    
 
30
    Browse changes to FILENAME line by line in a GTK+ window.
 
31
    """
 
32
 
 
33
    takes_args = ["filename"]
 
34
    takes_options = [Option("all", help="show annotations on all lines")]
 
35
    aliases = ["xblame", "xpraise"]
 
36
    
 
37
    def run(self, filename, all=False):
 
38
        (branch, path) = Branch.open_containing(filename)
 
39
 
 
40
        file_id = branch.working_tree().path2id(path)
 
41
 
 
42
        if file_id is None:
 
43
            raise NotVersionedError(filename)
 
44
 
 
45
        from xannotate import XAnnotateWindow
 
46
 
 
47
        window = XAnnotateWindow()
 
48
        window.show()
 
49
        window.set_title(path + " - xannotate")
 
50
        window.annotate(branch, file_id, all)
 
51
        window.connect("destroy", lambda w: gtk.main_quit())
 
52
        gtk.main()
 
53
 
 
54
 
 
55
register_command(cmd_xannotate)
 
56