From aa3ec28ec685e1873ef44ecf012a1b7ef12e66a0 Mon Sep 17 00:00:00 2001 From: einarr Date: Wed, 27 Feb 2008 17:38:01 +0000 Subject: [PATCH] Switched hard-coded 3-s with a variable to determine size of viewport resizing dialog on toolbar. --- fluents/fluents.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/fluents/fluents.py b/fluents/fluents.py index 78465f9..3e10d56 100644 --- a/fluents/fluents.py +++ b/fluents/fluents.py @@ -55,18 +55,19 @@ class IconFactory: icon_factory = IconFactory(ICONDIR) class TableSizeSelection(gtk.Window): - + def __init__(self): + self._SIZE = size = 5 gtk.Window.__init__(self, gtk.WINDOW_POPUP) - self._table = gtk.Table(3, 3, True) + self._table = gtk.Table(size, size, True) self._items = [] ## Create a 3x3 table of EventBox object, doubly stored because ## gtk.Table does not support indexed retrieval. - for y in range(3): + for y in range(size): line = [] - for x in range(3): + for x in range(size): ebox = gtk.EventBox() ebox.add(gtk.Frame()) ebox.set_size_request(20, 20) @@ -80,15 +81,17 @@ class TableSizeSelection(gtk.Window): self.connect_signals() def _get_child_pos(self, child): - for x in range(3): - for y in range(3): + size = self._SIZE + for x in range(size): + for y in range(size): if self._items[y][x] == child: return (x, y) return None def connect_signals(self): - for x in range(3): - for y in range(3): + size = self._SIZE + for x in range(size): + for y in range(size): self._items[y][x].add_events(gtk.gdk.ENTER_NOTIFY_MASK) self._items[y][x].connect("enter-notify-event", self._on_enter_notify) @@ -96,9 +99,10 @@ class TableSizeSelection(gtk.Window): self._on_button_release) def _on_enter_notify(self, widget, event): + size = self._SIZE x, y = self._get_child_pos(widget) - for i in range(3): - for j in range(3): + for i in range(size): + for j in range(size): if i <= x and j <= y: self._items[j][i].set_state(gtk.STATE_SELECTED) else: @@ -107,11 +111,12 @@ class TableSizeSelection(gtk.Window): self.y = y def _on_button_release(self, widget, event): + size = self._SIZE self.emit('table-size-set', self.x+1, self.y+1) self.hide_all() - for x in range(3): - for y in range(3): + for x in range(size): + for y in range(size): self._items[y][x].set_state(gtk.STATE_NORMAL)