/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: David Planella
  • Date: 2011-03-06 08:24:07 UTC
  • mfrom: (718 trunk)
  • mto: This revision was merged to the branch mainline in revision 719.
  • Revision ID: david.planella@ubuntu.com-20110306082407-y9zwkjje5oue9egw
Added preliminary internationalization support. Merged from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from gi.repository import GObject
18
 
from gi.repository import Gtk
19
 
 
 
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
20
30
from bzrlib.plugins.gtk.branchview.treeview import TreeView
21
 
from bzrlib.plugins.gtk.i18n import _i18n
22
 
 
23
 
 
24
 
class RevisionBrowser(Gtk.Dialog):
 
31
 
 
32
 
 
33
class RevisionBrowser(gtk.Dialog):
25
34
    """ Revision Browser main window. """
26
35
    def __init__(self, branch, parent=None):
27
 
        GObject.GObject.__init__(self, title="Revision Browser - Olive",
 
36
        gtk.Dialog.__init__(self, title="Revision Browser - Olive",
28
37
                                  parent=parent,
29
 
                                  flags=Gtk.DialogFlags.MODAL,
30
 
                                  buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
31
 
 
 
38
                                  flags=gtk.DIALOG_MODAL,
 
39
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
40
    
32
41
        # Get arguments
33
42
        self.branch = branch
34
 
 
 
43
        
35
44
        # Create the widgets
36
 
        self._button_select = Gtk.Button(_i18n("_Select"), use_underline=True)
 
45
        self._button_select = gtk.Button(_i18n("_Select"), use_underline=True)
37
46
        start_revs = [branch.last_revision(),]
38
47
        self.treeview = TreeView(branch, start_revs, None)
39
 
 
 
48
        
40
49
        # Set callbacks
41
50
        self._button_select.connect('clicked', self._on_select_clicked)
42
51
        self.treeview.connect('revision-activated',
43
52
                               self._on_treeview_revision_activated)
44
 
 
 
53
        
45
54
        # Set properties
46
55
        self.set_default_size(600, 400)
47
56
        self.vbox.set_spacing(3)
48
57
        self.treeview.set_property('graph-column-visible', False)
49
58
        self.treeview.set_property('date-column-visible', True)
50
59
        self.treeview.set_property('mainline-only', True)
51
 
 
 
60
        
52
61
        # Construct the dialog
53
62
        self.action_area.pack_end(self._button_select)
54
 
 
 
63
        
55
64
        self.vbox.pack_start(self.treeview, True, True)
56
65
 
57
66
        # Show the dialog
58
67
        self.show_all()
59
68
 
60
 
 
 
69
    
61
70
    def _on_treeview_revision_activated(self, treeview, path, column):
62
71
        """ Double-click on a row should also select a revision. """
63
72
        self._on_select_clicked(treeview)
64
 
 
 
73
    
65
74
    def _on_select_clicked(self, widget):
66
75
        """ Select button clicked handler. """
67
 
 
 
76
        
68
77
        self.selected_revno = self.treeview.get_property('revision-number')
69
78
        self.selected_revid = \
70
79
                    self.treeview.get_property('revision').revision_id
71
 
        self.response(Gtk.ResponseType.OK)
 
80
        self.response(gtk.RESPONSE_OK)