Ejemplo n.º 1
0
    def __init__(self):
        Gtk.ListStore.__init__(self, GObject.TYPE_PYOBJECT, str, str, int, str, int)

        self._recstore = DVBRecordingsStoreClient()
        self._recstore.connect("changed", self._on_changed)

        self._fill()
Ejemplo n.º 2
0
class RecordingsStore(Gtk.ListStore):

    (COL_START,
    COL_CHANNEL,
    COL_NAME,
    COL_DURATION,
    COL_LOCATION,
    COL_ID,) = list(range(6))

    def __init__(self):
        Gtk.ListStore.__init__(self, GObject.TYPE_PYOBJECT, str, str, int, str, int)

        self._recstore = DVBRecordingsStoreClient()
        self._recstore.connect("changed", self._on_changed)

        self._fill()

    def get_recordings_store_client(self):
        return self._recstore

    def _append_recording(self, rec_id):
        info, success = self._recstore.get_all_informations (rec_id)

        if success:
            channame = info[5]
            name = escape(info[1])
            start = datetime.datetime.fromtimestamp(info[4])
            duration = info[3]
            location = info[6]

            self.append([start, channame, name, duration, location, rec_id])

    def _fill(self):
        def append_rec(proxy, rids, user_data):
            for rid in rids:
                self._append_recording(rid)

        self._recstore.get_recordings(result_handler=append_rec, error_handler=global_error_handler)

    def _on_changed(self, recstore, rec_id, change_type):
        if change_type == 0:
            # Added
            self._append_recording(rec_id)
        elif change_type == 1:
            # Deleted
            for row in self:
                if row[self.COL_ID] == rec_id:
                    self.remove(row.iter)
                    return
        elif change_type == 2:
            # Updated
            pass