make paneds be splittable, set their initial position properly and don't call reconfigure() all the time
This commit is contained in:
parent
6b4c660cbc
commit
5352731984
|
@ -8,6 +8,7 @@ import gobject
|
|||
import gtk
|
||||
|
||||
from newterminator import Terminator
|
||||
from terminal import Terminal
|
||||
from container import Container
|
||||
|
||||
# pylint: disable-msg=R0921
|
||||
|
@ -24,9 +25,35 @@ class Paned(Container):
|
|||
gobject.type_register(HPaned)
|
||||
self.register_signals(HPaned)
|
||||
|
||||
def set_initial_position(self, widget, event):
|
||||
"""Set the initial position of the widget"""
|
||||
if isinstance(self, gtk.VPaned):
|
||||
position = self.allocation.height / 2
|
||||
else:
|
||||
position = self.allocation.width / 2
|
||||
|
||||
print "Setting position to: %d" % position
|
||||
self.set_position(position)
|
||||
self.disconnect(self.cnxids['init'])
|
||||
del(self.cnxids['init'])
|
||||
|
||||
def split_axis(self, widget, vertical=True):
|
||||
"""Default axis splitter. This should be implemented by subclasses"""
|
||||
raise NotImplementedError('split_axis')
|
||||
self.remove(widget)
|
||||
if vertical:
|
||||
container = VPaned()
|
||||
else:
|
||||
container = HPaned()
|
||||
|
||||
sibling = Terminal()
|
||||
self.terminator.register_terminal(sibling)
|
||||
sibling.spawn_child()
|
||||
|
||||
container.add(widget)
|
||||
container.add(sibling)
|
||||
|
||||
self.add(container)
|
||||
self.show_all()
|
||||
|
||||
def add(self, widget):
|
||||
"""Add a widget to the container"""
|
||||
|
@ -34,12 +61,16 @@ class Paned(Container):
|
|||
self.pack1(widget, True, True)
|
||||
self.children.append(widget)
|
||||
elif len(self.children) == 1:
|
||||
if self.get_child1():
|
||||
self.pack2(widget, True, True)
|
||||
else:
|
||||
self.pack1(widget, True, True)
|
||||
self.children.append(widget)
|
||||
else:
|
||||
raise ValueError('already have two children')
|
||||
|
||||
self.cnxids[widget] = []
|
||||
if isinstance(widget, Terminal):
|
||||
self.cnxids[widget].append(widget.connect('close-term',
|
||||
self.wrapcloseterm))
|
||||
# FIXME: somehow propagate the title-change signal to the Window
|
||||
|
@ -81,6 +112,8 @@ class HPaned(Paned, gtk.HPaned):
|
|||
"""Class initialiser"""
|
||||
Paned.__init__(self)
|
||||
gtk.HPaned.__init__(self)
|
||||
self.cnxids['init'] = self.connect('expose-event',
|
||||
self.set_initial_position)
|
||||
|
||||
class VPaned(Paned, gtk.VPaned):
|
||||
"""Merge gtk.VPaned into our base Paned Container"""
|
||||
|
@ -88,6 +121,8 @@ class VPaned(Paned, gtk.VPaned):
|
|||
"""Class initialiser"""
|
||||
Paned.__init__(self)
|
||||
gtk.VPaned.__init__(self)
|
||||
self.cnxids['init'] = self.connect('expose-event',
|
||||
self.set_initial_position)
|
||||
|
||||
gobject.type_register(HPaned)
|
||||
gobject.type_register(VPaned)
|
||||
|
|
|
@ -72,6 +72,8 @@ class Terminal(gtk.VBox):
|
|||
|
||||
composite_support = None
|
||||
|
||||
cnxid = None
|
||||
|
||||
def __init__(self):
|
||||
"""Class initialiser"""
|
||||
gtk.VBox.__init__(self)
|
||||
|
@ -252,7 +254,7 @@ class Terminal(gtk.VBox):
|
|||
self.vte.connect('enter_notify_event',
|
||||
self.on_vte_notify_enter)
|
||||
|
||||
self.vte.connect_after('realize', self.reconfigure)
|
||||
self.cnxid = self.vte.connect_after('realize', self.reconfigure)
|
||||
|
||||
def create_popup_group_menu(self, widget, event = None):
|
||||
"""Pop up a menu for the group widget"""
|
||||
|
@ -423,6 +425,12 @@ class Terminal(gtk.VBox):
|
|||
|
||||
def reconfigure(self, widget=None):
|
||||
"""Reconfigure our settings"""
|
||||
dbg('Terminal::reconfigure')
|
||||
if self.cnxid:
|
||||
dbg('Terminal::reconfigure: disconnecting')
|
||||
self.vte.disconnect(self.cnxid)
|
||||
self.cnxid = None
|
||||
|
||||
# FIXME: actually reconfigure our settings
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue