Merge a branch from Stephen J Boddy that fixes a dragging bug.

This commit is contained in:
Chris Jones 2012-07-10 20:32:37 +01:00
commit 425e2aed6a
2 changed files with 26 additions and 0 deletions

View File

@ -44,6 +44,8 @@ class Paned(Container):
else:
container = HPaned()
self.get_toplevel().set_pos_by_ratio = True
if not sibling:
sibling = self.maker.make('terminal')
sibling.set_cwd(cwd)
@ -61,6 +63,11 @@ class Paned(Container):
self.show_all()
while gtk.events_pending():
gtk.main_iteration_do(False)
self.get_toplevel().set_pos_by_ratio = False
def add(self, widget, metadata=None):
"""Add a widget to the container"""
if len(self.children) == 0:
@ -361,6 +368,12 @@ class Paned(Container):
container.add(child)
def new_size(self, widget, allocation):
if self.get_toplevel().set_pos_by_ratio:
self.set_position_by_ratio()
else:
self.set_position(self.get_position())
def set_position_by_ratio(self):
self.set_pos(int(self.ratio*self.get_length()))
def set_position(self, pos):

View File

@ -37,6 +37,7 @@ class Window(Container, gtk.Window):
losefocus_time = 0
position = None
ignore_startup_show = None
set_pos_by_ratio = None
zoom_data = None
@ -419,6 +420,8 @@ class Window(Container, gtk.Window):
else:
container = maker.make('HPaned')
self.set_pos_by_ratio = True
if not sibling:
sibling = maker.make('Terminal')
sibling.set_cwd(cwd)
@ -434,6 +437,11 @@ class Window(Container, gtk.Window):
container.add(term)
container.show_all()
while gtk.events_pending():
gtk.main_iteration_do(False)
self.set_pos_by_ratio = False
def zoom(self, widget, font_scale=True):
"""Zoom a terminal widget"""
children = self.get_children()
@ -479,6 +487,7 @@ class Window(Container, gtk.Window):
def rotate(self, widget, clockwise):
"""Rotate children in this window"""
self.set_pos_by_ratio = True
maker = Factory()
# collect all paned children in breadth-first order
paned = []
@ -495,6 +504,10 @@ class Window(Container, gtk.Window):
self.show_all()
widget.grab_focus()
while gtk.events_pending():
gtk.main_iteration_do(False)
self.set_pos_by_ratio = False
def get_visible_terminals(self):
"""Walk down the widget tree to find all of the visible terminals.
Mostly using Container::get_visible_terminals()"""