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

  • Committer: Jelmer Vernooij
  • Date: 2008-06-29 19:18:34 UTC
  • mto: This revision was merged to the branch mainline in revision 515.
  • Revision ID: jelmer@samba.org-20080629191834-ha2ecpv5szt96nge
Make sure signed testament matches repository data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
 
2
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
try:
 
19
    import pygtk
 
20
    pygtk.require("2.0")
 
21
except:
 
22
    pass
 
23
 
 
24
import gtk
 
25
 
 
26
class RevisionSelectionBox(gtk.HBox):
 
27
    def __init__(self, branch):
 
28
        super(RevisionSelectionBox, self).__init__()
 
29
        self._branch = branch
 
30
        self._entry_revid = gtk.Entry()
 
31
        self._button_revid = gtk.Button('')
 
32
        self._button_revid.set_image(gtk.image_new_from_stock(
 
33
            gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON))
 
34
        self.pack_start(self._entry_revid, True, True)
 
35
        self.pack_start(self._button_revid, False, False) 
 
36
 
 
37
        self._button_revid.connect('clicked', self._on_revid_clicked)
 
38
 
 
39
    def _on_revid_clicked(self, widget):
 
40
        """ Browse for revision button clicked handler. """
 
41
        from revbrowser import RevisionBrowser
 
42
        
 
43
        # FIXME: Should specific parent window here - how to get to it?
 
44
        # JRV 20070715
 
45
        revb = RevisionBrowser(self._branch)
 
46
        response = revb.run()
 
47
        if response != gtk.RESPONSE_NONE:
 
48
            revb.hide()
 
49
        
 
50
            if response == gtk.RESPONSE_OK:
 
51
                if revb.selected_revno is not None:
 
52
                    self._entry_revid.set_text(revb.selected_revid)
 
53
            
 
54
            revb.destroy()
 
55
 
 
56
    def get_revision_id(self):
 
57
        if len(self._entry_revid.get_text()) == 0:
 
58
            return None
 
59
        else:
 
60
            return self._entry_revid.get_text()