Fix flickering and intermittent failures to rebalance
This commit is contained in:
parent
6b9324e007
commit
785c9a87a4
|
@ -4,6 +4,7 @@
|
||||||
"""paned.py - a base Paned container class and the vertical/horizontal
|
"""paned.py - a base Paned container class and the vertical/horizontal
|
||||||
variants"""
|
variants"""
|
||||||
|
|
||||||
|
import time
|
||||||
import gobject
|
import gobject
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
|
@ -20,6 +21,8 @@ class Paned(Container):
|
||||||
position = None
|
position = None
|
||||||
maker = None
|
maker = None
|
||||||
ratio = 0.5
|
ratio = 0.5
|
||||||
|
last_balance_time = 0
|
||||||
|
last_balance_args = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
|
@ -143,16 +146,21 @@ class Paned(Container):
|
||||||
else:
|
else:
|
||||||
recurse_down=False
|
recurse_down=False
|
||||||
|
|
||||||
# FIXME: These idle events are creating a lot of weird issues
|
self.last_balance_time = time.time()
|
||||||
for i in range(3):
|
self.last_balance_args = (recurse_up, recurse_down)
|
||||||
while gtk.events_pending():
|
|
||||||
gtk.main_iteration_do(False)
|
|
||||||
self.do_redistribute(recurse_up, recurse_down)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def on_button_release(self, widget, event):
|
||||||
|
"""Handle button presses on a Pane"""
|
||||||
|
if event.button == 1:
|
||||||
|
if self.last_balance_time > (time.time() - 1):
|
||||||
|
while gtk.events_pending():
|
||||||
|
gtk.main_iteration_do(False)
|
||||||
|
self.do_redistribute(*self.last_balance_args)
|
||||||
|
return False
|
||||||
|
|
||||||
def do_redistribute(self, recurse_up=False, recurse_down=False):
|
def do_redistribute(self, recurse_up=False, recurse_down=False):
|
||||||
"""Evenly divide available space between sibling panes"""
|
"""Evenly divide available space between sibling panes"""
|
||||||
maker = Factory()
|
maker = Factory()
|
||||||
|
@ -433,6 +441,7 @@ class HPaned(Paned, gtk.HPaned):
|
||||||
gtk.HPaned.__init__(self)
|
gtk.HPaned.__init__(self)
|
||||||
self.register_signals(HPaned)
|
self.register_signals(HPaned)
|
||||||
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
||||||
|
self.cnxids.new(self, 'button-release-event', self.on_button_release)
|
||||||
|
|
||||||
def get_length(self):
|
def get_length(self):
|
||||||
return(self.allocation.width)
|
return(self.allocation.width)
|
||||||
|
@ -448,6 +457,7 @@ class VPaned(Paned, gtk.VPaned):
|
||||||
gtk.VPaned.__init__(self)
|
gtk.VPaned.__init__(self)
|
||||||
self.register_signals(VPaned)
|
self.register_signals(VPaned)
|
||||||
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
||||||
|
self.cnxids.new(self, 'button-release-event', self.on_button_release)
|
||||||
|
|
||||||
def get_length(self):
|
def get_length(self):
|
||||||
return(self.allocation.height)
|
return(self.allocation.height)
|
||||||
|
|
Loading…
Reference in New Issue