Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-08-21 21:02:24 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-08-25 15:47:56 (GMT)
commit5099a39aef77952446bbcc179013685f8e963b86 (patch)
tree488673b487e3441e4cb18b526d91dfc982cfed05 /src
parent8221d89c377b0644f302e9fc463296733a7b536d (diff)
Getting visible cells in SmoothTable
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/journal/browse/smoothtable.py17
-rw-r--r--src/jarabe/journal/browse/tableview.py13
2 files changed, 20 insertions, 10 deletions
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)