/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: 2007-12-21 20:20:37 UTC
  • mto: This revision was merged to the branch mainline in revision 422.
  • Revision ID: jelmer@samba.org-20071221202037-6zvbwefvrte3e2zy
Fix URL.

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
import time
 
18
 
17
19
try:
18
20
    import pygtk
19
21
    pygtk.require("2.0")
38
40
        self.branch = branch
39
41
        
40
42
        # Create the widgets
41
 
        self._label_select = gtk.Label(_("Please select a revision"))
 
43
        self._hbox = gtk.HBox()
 
44
        self._image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)
 
45
        self._label_loading = gtk.Label(_("Please wait, revisions are being loaded..."))
42
46
        self._scrolledwindow = gtk.ScrolledWindow()
43
47
        self._treeview = gtk.TreeView()
44
48
        self._button_select = gtk.Button(_("_Select"), use_underline=True)
52
56
                                        gtk.POLICY_AUTOMATIC)
53
57
        self.vbox.set_spacing(3)
54
58
        self.set_default_size(600, 400)
 
59
        self._label_loading.set_alignment(0.0, 0.5)
 
60
        self._hbox.set_spacing(5)
 
61
        self._hbox.set_border_width(5)
55
62
        
56
63
        # Construct the TreeView columns
57
64
        self._treeview.append_column(gtk.TreeViewColumn(_('Revno'),
71
78
        
72
79
        self._scrolledwindow.add(self._treeview)
73
80
        
74
 
        self.vbox.pack_start(self._label_select, False, False)
 
81
        self._hbox.pack_start(self._image_loading, False, False)
 
82
        self._hbox.pack_start(self._label_loading, True, True)
 
83
        
 
84
        self.vbox.pack_start(self._hbox, False, False)
75
85
        self.vbox.pack_start(self._scrolledwindow, True, True)
 
86
 
 
87
        # Show the dialog
 
88
        self.show_all()
76
89
        
77
90
        # Fill up with revisions
78
91
        self._fill_revisions()
79
 
        
80
 
        # Show the dialog
81
 
        self.vbox.show_all()
82
92
 
83
93
    def _fill_revisions(self):
84
94
        """ Fill up the treeview with the revisions. """
85
 
        # [ revno, message, committer, timestamp ]
 
95
        # [ revno, message, committer, timestamp, revid ]
86
96
        self.model = gtk.ListStore(gobject.TYPE_STRING,
87
97
                                   gobject.TYPE_STRING,
88
98
                                   gobject.TYPE_STRING,
 
99
                                   gobject.TYPE_STRING,
89
100
                                   gobject.TYPE_STRING)
90
101
        self._treeview.set_model(self.model)
 
102
 
91
103
        repo = self.branch.repository
92
104
        revs = self.branch.revision_history()
93
105
        r = repo.get_revisions(revs)
94
106
        r.reverse()
 
107
 
95
108
        for rev in r:
96
109
            if rev.committer is not None:
97
110
                timestamp = format_date(rev.timestamp, rev.timezone)
100
113
            self.model.append([ self.branch.revision_id_to_revno(rev.revision_id),
101
114
                                rev.get_summary(),
102
115
                                rev.committer,
103
 
                                timestamp ])
 
116
                                timestamp,
 
117
                                rev.revision_id ])
 
118
            while gtk.events_pending():
 
119
                gtk.main_iteration()
 
120
        tend = time.time()
 
121
        
 
122
        # Finished loading
 
123
        self._hbox.hide()
104
124
    
105
125
    def _get_selected_revno(self):
106
126
        """ Return the selected revision's revno. """
112
132
        else:
113
133
            return model.get_value(iter, 0)
114
134
    
 
135
    def _get_selected_revid(self):
 
136
        """ Return the selected revision's revid. """
 
137
        treeselection = self._treeview.get_selection()
 
138
        (model, iter) = treeselection.get_selected()
 
139
        
 
140
        if iter is None:
 
141
            return None
 
142
        else:
 
143
            return model.get_value(iter, 4)
 
144
    
115
145
    def _on_treeview_row_activated(self, treeview, path, column):
116
146
        """ Double-click on a row should also select a revision. """
117
147
        self._on_select_clicked(treeview)
119
149
    def _on_select_clicked(self, widget):
120
150
        """ Select button clicked handler. """
121
151
        self.selected_revno = self._get_selected_revno()
 
152
        self.selected_revid = self._get_selected_revid()
122
153
        self.response(gtk.RESPONSE_OK)