Update the task list on add/remove rather than

rebuilding every time. Note that this is _not_
the real UI. It's just some stuff I put there
because we need the functionality while we
finalize the real design and we figure out
how to implement it.
This commit is contained in:
Marco Pesenti Gritti 2006-07-13 11:10:27 +02:00
parent cc66d7d4df
commit e079d76380

View File

@ -42,27 +42,34 @@ class ActivityGrid(gtk.VBox):
gtk.VBox.__init__(self) gtk.VBox.__init__(self)
self._home = home self._home = home
self.update() self._buttons = {}
def _add_all(self):
screen = wnck.screen_get_default() screen = wnck.screen_get_default()
for window in screen.get_windows(): for window in screen.get_windows():
if not window.is_skip_tasklist(): if not window.is_skip_tasklist():
self.add(window) self._add(window)
screen.connect('window_opened', self.__window_opened_cb)
screen.connect('window_closed', self.__window_closed_cb)
def _remove_all(self): def __window_opened_cb(self, screen, window):
for child in self.get_children(): if not window.is_skip_tasklist():
self.remove(child) self._add(window)
def add(self, window): def __window_closed_cb(self, screen, window):
if not window.is_skip_tasklist():
self._remove(window)
def _remove(self, window):
button = self._buttons[window.get_xid()]
self.remove(button)
def _add(self, window):
button = gtk.Button(window.get_name()) button = gtk.Button(window.get_name())
button.connect('clicked', self.__button_clicked_cb, window) button.connect('clicked', self.__button_clicked_cb, window)
self.pack_start(button, False) self.pack_start(button, False)
button.show() button.show()
def update(self): self._buttons[window.get_xid()] = button
self._remove_all()
self._add_all()
def __button_clicked_cb(self, button, window): def __button_clicked_cb(self, button, window):
self._home.activate(window) self._home.activate(window)
@ -73,16 +80,29 @@ class HomeWindow(gtk.Window):
self._shell = shell self._shell = shell
vbox = gtk.VBox() self.set_skip_taskbar_hint(True)
vbox = gtk.VBox(False, 6)
vbox.set_border_width(24)
toolbar = Toolbar(self) toolbar = Toolbar(self)
vbox.pack_start(toolbar, False) vbox.pack_start(toolbar, False)
toolbar.show() toolbar.show()
label = gtk.Label('Open activities:')
label.set_alignment(0.0, 0.5)
vbox.pack_start(label, False)
label.show()
self._grid = ActivityGrid(self) self._grid = ActivityGrid(self)
vbox.pack_start(self._grid) vbox.pack_start(self._grid)
self._grid.show() self._grid.show()
label = gtk.Label('Shared activities:')
label.set_alignment(0.0, 0.5)
vbox.pack_start(label, False)
label.show()
self.add(vbox) self.add(vbox)
vbox.show() vbox.show()
@ -96,7 +116,3 @@ class HomeWindow(gtk.Window):
def activate(self, activity_window): def activate(self, activity_window):
activity_window.activate(gtk.get_current_event_time()) activity_window.activate(gtk.get_current_event_time())
self.hide() self.hide()
def show(self):
self._grid.update()
gtk.Window.show(self)