def update(self, buflist: list, bufcurr: int):
"""Updates the widget's buttons.
Increases the internal button cache if needed, then displays the
appropriate amount of buttons, updating their state.
:buflist: list of tuples (buffer-number, buffer-name, buffer-modified).
:bufcurr: the active buffer's number.
"""
self.props.updating = True
self.bids = [id for id, *_ in buflist]
for _ in range(len(buflist) - len(self.btns)):
ico = Gtk.Image(icon_name='document-edit-symbolic')
btn = Gtk.ToggleButton(None, can_focus=False, image=ico)
btn.connect('toggled', self._do_button_toggled)
self.btns.append(btn)
for btn in self.get_children():
self.remove(btn)
for btn, (id, name, modified) in zip(self.btns, buflist):
btn.set_label(name)
btn.set_active(id == bufcurr)
btn.set_always_show_image(modified)
self.add(btn)
self.show_all()
self.props.updating = False
评论列表
文章目录