(trunk-1679) Fix flickering and intermittent failures to rebalance
This commit is contained in:
parent
fb8c35f259
commit
109e26161a
|
@ -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
|
||||||
from gi.repository import GObject, Gtk, Gdk
|
from gi.repository import GObject, Gtk, Gdk
|
||||||
|
|
||||||
from util import dbg, err
|
from util import dbg, err
|
||||||
|
@ -19,6 +20,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"""
|
||||||
|
@ -141,17 +144,22 @@ class Paned(Container):
|
||||||
recurse_down=True
|
recurse_down=True
|
||||||
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()
|
||||||
|
@ -416,6 +424,7 @@ class HPaned(Paned, Gtk.HPaned):
|
||||||
GObject.GObject.__init__(self)
|
GObject.GObject.__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.get_allocated_width())
|
return(self.get_allocated_width())
|
||||||
|
@ -431,6 +440,7 @@ class VPaned(Paned, Gtk.VPaned):
|
||||||
GObject.GObject.__init__(self)
|
GObject.GObject.__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.get_allocated_height())
|
return(self.get_allocated_height())
|
||||||
|
|
Loading…
Reference in New Issue