/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: 2008-07-17 11:51:03 UTC
  • Revision ID: jelmer@samba.org-20080717115103-djh5sb0pvpse2zkb
Add note about glade.

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