From 5099a39aef77952446bbcc179013685f8e963b86 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Fri, 21 Aug 2009 21:02:24 +0000 Subject: Getting visible cells in SmoothTable --- (limited to 'src') diff --git a/src/jarabe/journal/browse/smoothtable.py b/src/jarabe/journal/browse/smoothtable.py index c797745..b63cb31 100644 --- a/src/jarabe/journal/browse/smoothtable.py +++ b/src/jarabe/journal/browse/smoothtable.py @@ -40,6 +40,7 @@ class SmoothTable(gtk.Container): self._reordered = None self._last_allocation = None self._fill_in = fill_in + self._visible_rows = {} gtk.Container.__init__(self) @@ -87,6 +88,14 @@ class SmoothTable(gtk.Container): bin_rows = property(get_bin_rows, set_bin_rows) + def get_visible_cell(self, y, x): + if x >= self.columns: + return None + row = self._visible_rows.get(y) + if row is None: + return None + return row[x] + def goto(self, row): if self._adj is None: return @@ -282,6 +291,7 @@ class SmoothTable(gtk.Container): if not visible_rows or len(visible_rows) < self.rows + \ (self._get_head() != visible_rows[0]): self._reordered = self.allocation + self._visible_rows = {} def insert_spare_row(cell_y, end_y): while cell_y < end_y: @@ -290,12 +300,15 @@ class SmoothTable(gtk.Container): return row = spare_rows.pop() self._allocate_row(row, cell_y) + self._visible_rows[cell_y / self._cell_height] = row cell_y = cell_y + self._cell_height cell_y = self._get_head() for i in visible_rows: - insert_spare_row(cell_y, i.row[0].allocation.y) - cell_y = i.row[0].allocation.y + i.row[0].allocation.height + cell = i.row[0].allocation + insert_spare_row(cell_y, cell.y) + self._visible_rows[cell.y / self._cell_height] = i.row + cell_y = cell.y + cell.height insert_spare_row(cell_y, page_end) self._bin_window.move(0, int(-self._adj.value)) diff --git a/src/jarabe/journal/browse/tableview.py b/src/jarabe/journal/browse/tableview.py index 235d3b3..87acdee 100644 --- a/src/jarabe/journal/browse/tableview.py +++ b/src/jarabe/journal/browse/tableview.py @@ -155,16 +155,13 @@ class TableView(SmoothTable): self._selected_cell = None def __row_changed_cb(self, model, path, iter): - range = self.frame - if path[0] < range[0] or path[0] > range[1]: - return - - y = (path[0] - range[0]) / self.columns - x = (path[0] - range[0]) % self.columns + y = path[0] / self.columns + x = path[0] % self.columns - from jarabe.journal.objectmodel import Source + canvas = self.get_visible_cell(y, x) + if canvas is None: + return - canvas = self._rows[y][x] row = self._model.get_row(path) self._fill_in(canvas, y, x, row) -- cgit v0.9.1