/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
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
734.1.1 by Curtis Hovey
Mechanical changes made by pygi.convert.sh.
17
from gi.repository import Gtk
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
18
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
19
from bzrlib.plugins.gtk.branchview.treeview import TreeView
729.1.1 by Jelmer Vernooij
Move i18n support to a separate file, so gettext files aren't loaded unless bzr-gtk is used.
20
from bzrlib.plugins.gtk.i18n import _i18n
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
21
22
734.1.1 by Curtis Hovey
Mechanical changes made by pygi.convert.sh.
23
class RevisionBrowser(Gtk.Dialog):
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
24
    """ Revision Browser main window. """
25
    def __init__(self, branch, parent=None):
734.1.51 by Curtis Hovey
Fix the initializer for many classes.
26
        super(RevisionBrowser, self).__init__(
27
            title="Revision Browser - Olive", parent=parent,
28
            flags=Gtk.DialogFlags.MODAL,
29
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
724 by Jelmer Vernooij
Fix formatting, imports.
30
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
31
        # Get arguments
32
        self.branch = branch
724 by Jelmer Vernooij
Fix formatting, imports.
33
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
34
        # Create the widgets
734.1.1 by Curtis Hovey
Mechanical changes made by pygi.convert.sh.
35
        self._button_select = Gtk.Button(_i18n("_Select"), use_underline=True)
463.2.3 by Javier Derderian
Fixed revbrowser.RevisionBrowser call to TreeView() to pass start revision as list
36
        start_revs = [branch.last_revision(),]
466 by Jelmer Vernooij
Merge Compare With option from Javier.
37
        self.treeview = TreeView(branch, start_revs, None)
724 by Jelmer Vernooij
Fix formatting, imports.
38
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
39
        # Set callbacks
40
        self._button_select.connect('clicked', self._on_select_clicked)
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
41
        self.treeview.connect('revision-activated',
42
                               self._on_treeview_revision_activated)
724 by Jelmer Vernooij
Fix formatting, imports.
43
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
44
        # Set properties
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
45
        self.set_default_size(600, 400)
734.1.51 by Curtis Hovey
Fix the initializer for many classes.
46
        self.get_content_area().set_spacing(3)
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
47
        self.treeview.set_property('graph-column-visible', False)
48
        self.treeview.set_property('date-column-visible', True)
49
        self.treeview.set_property('mainline-only', True)
724 by Jelmer Vernooij
Fix formatting, imports.
50
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
51
        # Construct the dialog
734.1.53 by Curtis Hovey
Fixed packing args.
52
        self.action_area.pack_end(self._button_select, False, False, 0)
724 by Jelmer Vernooij
Fix formatting, imports.
53
734.1.53 by Curtis Hovey
Fixed packing args.
54
        self.get_content_area().pack_start(self.treeview, True, True, 0)
195.1.23 by Szilveszter Farkas (Phanatic)
Make the Revision Browser feel faster.
55
56
        # Show the dialog
57
        self.show_all()
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
58
724 by Jelmer Vernooij
Fix formatting, imports.
59
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
60
    def _on_treeview_revision_activated(self, treeview, path, column):
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
61
        """ Double-click on a row should also select a revision. """
62
        self._on_select_clicked(treeview)
724 by Jelmer Vernooij
Fix formatting, imports.
63
126.1.17 by Szilveszter Farkas (Phanatic)
Forgot to add the Revision Browser.
64
    def _on_select_clicked(self, widget):
65
        """ Select button clicked handler. """
724 by Jelmer Vernooij
Fix formatting, imports.
66
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
67
        self.selected_revno = self.treeview.get_property('revision-number')
68
        self.selected_revid = \
69
                    self.treeview.get_property('revision').revision_id
734.1.1 by Curtis Hovey
Mechanical changes made by pygi.convert.sh.
70
        self.response(Gtk.ResponseType.OK)