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

  • Committer: Jelmer Vernooij
  • Date: 2011-04-10 18:44:39 UTC
  • mto: This revision was merged to the branch mainline in revision 730.
  • Revision ID: jelmer@samba.org-20110410184439-g7hqaacexqtviq13
Move i18n support to a separate file, so gettext files aren't loaded unless bzr-gtk is used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@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
try:
 
18
    import pygtk
 
19
    pygtk.require("2.0")
 
20
except:
 
21
    pass
 
22
 
 
23
import gobject
 
24
import gtk
 
25
 
 
26
from bzrlib.plugins.gtk.branchview.treeview import TreeView
 
27
from bzrlib.plugins.gtk.i18n import _i18n
 
28
 
 
29
 
 
30
class RevisionBrowser(gtk.Dialog):
 
31
    """ Revision Browser main window. """
 
32
    def __init__(self, branch, parent=None):
 
33
        gtk.Dialog.__init__(self, title="Revision Browser - Olive",
 
34
                                  parent=parent,
 
35
                                  flags=gtk.DIALOG_MODAL,
 
36
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
37
 
 
38
        # Get arguments
 
39
        self.branch = branch
 
40
 
 
41
        # Create the widgets
 
42
        self._button_select = gtk.Button(_i18n("_Select"), use_underline=True)
 
43
        start_revs = [branch.last_revision(),]
 
44
        self.treeview = TreeView(branch, start_revs, None)
 
45
 
 
46
        # Set callbacks
 
47
        self._button_select.connect('clicked', self._on_select_clicked)
 
48
        self.treeview.connect('revision-activated',
 
49
                               self._on_treeview_revision_activated)
 
50
 
 
51
        # Set properties
 
52
        self.set_default_size(600, 400)
 
53
        self.vbox.set_spacing(3)
 
54
        self.treeview.set_property('graph-column-visible', False)
 
55
        self.treeview.set_property('date-column-visible', True)
 
56
        self.treeview.set_property('mainline-only', True)
 
57
 
 
58
        # Construct the dialog
 
59
        self.action_area.pack_end(self._button_select)
 
60
 
 
61
        self.vbox.pack_start(self.treeview, True, True)
 
62
 
 
63
        # Show the dialog
 
64
        self.show_all()
 
65
 
 
66
 
 
67
    def _on_treeview_revision_activated(self, treeview, path, column):
 
68
        """ Double-click on a row should also select a revision. """
 
69
        self._on_select_clicked(treeview)
 
70
 
 
71
    def _on_select_clicked(self, widget):
 
72
        """ Select button clicked handler. """
 
73
 
 
74
        self.selected_revno = self.treeview.get_property('revision-number')
 
75
        self.selected_revid = \
 
76
                    self.treeview.get_property('revision').revision_id
 
77
        self.response(gtk.RESPONSE_OK)