Switched hard-coded 3-s with a variable to determine size of viewport resizing
dialog on toolbar.
This commit is contained in:
parent
cb6d6b87cc
commit
aa3ec28ec6
|
@ -57,16 +57,17 @@ icon_factory = IconFactory(ICONDIR)
|
||||||
class TableSizeSelection(gtk.Window):
|
class TableSizeSelection(gtk.Window):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self._SIZE = size = 5
|
||||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||||
self._table = gtk.Table(3, 3, True)
|
self._table = gtk.Table(size, size, True)
|
||||||
self._items = []
|
self._items = []
|
||||||
|
|
||||||
## Create a 3x3 table of EventBox object, doubly stored because
|
## Create a 3x3 table of EventBox object, doubly stored because
|
||||||
## gtk.Table does not support indexed retrieval.
|
## gtk.Table does not support indexed retrieval.
|
||||||
|
|
||||||
for y in range(3):
|
for y in range(size):
|
||||||
line = []
|
line = []
|
||||||
for x in range(3):
|
for x in range(size):
|
||||||
ebox = gtk.EventBox()
|
ebox = gtk.EventBox()
|
||||||
ebox.add(gtk.Frame())
|
ebox.add(gtk.Frame())
|
||||||
ebox.set_size_request(20, 20)
|
ebox.set_size_request(20, 20)
|
||||||
|
@ -80,15 +81,17 @@ class TableSizeSelection(gtk.Window):
|
||||||
self.connect_signals()
|
self.connect_signals()
|
||||||
|
|
||||||
def _get_child_pos(self, child):
|
def _get_child_pos(self, child):
|
||||||
for x in range(3):
|
size = self._SIZE
|
||||||
for y in range(3):
|
for x in range(size):
|
||||||
|
for y in range(size):
|
||||||
if self._items[y][x] == child:
|
if self._items[y][x] == child:
|
||||||
return (x, y)
|
return (x, y)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
for x in range(3):
|
size = self._SIZE
|
||||||
for y in range(3):
|
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].add_events(gtk.gdk.ENTER_NOTIFY_MASK)
|
||||||
self._items[y][x].connect("enter-notify-event",
|
self._items[y][x].connect("enter-notify-event",
|
||||||
self._on_enter_notify)
|
self._on_enter_notify)
|
||||||
|
@ -96,9 +99,10 @@ class TableSizeSelection(gtk.Window):
|
||||||
self._on_button_release)
|
self._on_button_release)
|
||||||
|
|
||||||
def _on_enter_notify(self, widget, event):
|
def _on_enter_notify(self, widget, event):
|
||||||
|
size = self._SIZE
|
||||||
x, y = self._get_child_pos(widget)
|
x, y = self._get_child_pos(widget)
|
||||||
for i in range(3):
|
for i in range(size):
|
||||||
for j in range(3):
|
for j in range(size):
|
||||||
if i <= x and j <= y:
|
if i <= x and j <= y:
|
||||||
self._items[j][i].set_state(gtk.STATE_SELECTED)
|
self._items[j][i].set_state(gtk.STATE_SELECTED)
|
||||||
else:
|
else:
|
||||||
|
@ -107,11 +111,12 @@ class TableSizeSelection(gtk.Window):
|
||||||
self.y = y
|
self.y = y
|
||||||
|
|
||||||
def _on_button_release(self, widget, event):
|
def _on_button_release(self, widget, event):
|
||||||
|
size = self._SIZE
|
||||||
self.emit('table-size-set', self.x+1, self.y+1)
|
self.emit('table-size-set', self.x+1, self.y+1)
|
||||||
self.hide_all()
|
self.hide_all()
|
||||||
|
|
||||||
for x in range(3):
|
for x in range(size):
|
||||||
for y in range(3):
|
for y in range(size):
|
||||||
self._items[y][x].set_state(gtk.STATE_NORMAL)
|
self._items[y][x].set_state(gtk.STATE_NORMAL)
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue