# vim: ts=4 et sts=4 sw=4 autoindent

import gtk

class CurrentActivitiesTreeView(object):

    def __init__(self, tree_view, model):
        self.view = tree_view
        self.model = model
        self.employee_id = None
        self.filter = self.model.filter_new()
        self.filter.set_visible_func(self.filter_func)
        self.view.set_model(self.filter)
        selection = self.view.get_selection()
        selection.set_mode(gtk.SELECTION_NONE)
        tree_column_1 = gtk.TreeViewColumn("Activity")
        tree_column_1.set_sort_column_id(1)
        self.view.append_column(tree_column_1)

        cell = gtk.CellRendererText()
        tree_column_1.pack_start(cell, True)
        tree_column_1.add_attribute(cell, "text", 3)

    def filter_func(self, model, iter):
        value = model.get_value(iter, 0)
        return value == self.employee_id

    def populate(self, employee_id):
        """
        Filter the model to just the selected employee's records.
        """
        self.employee_id = employee_id
        self.filter.refilter()
        self.view.expand_all()

