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
|
import gtk
|
||||||
|
|
||||||
from newterminator import Terminator
|
from newterminator import Terminator
|
||||||
|
from terminal import Terminal
|
||||||
from container import Container
|
from container import Container
|
||||||
|
|
||||||
# pylint: disable-msg=R0921
|
# pylint: disable-msg=R0921
|
||||||
|
@ -24,9 +25,35 @@ class Paned(Container):
|
||||||
gobject.type_register(HPaned)
|
gobject.type_register(HPaned)
|
||||||
self.register_signals(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):
|
def split_axis(self, widget, vertical=True):
|
||||||
"""Default axis splitter. This should be implemented by subclasses"""
|
"""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):
|
def add(self, widget):
|
||||||
"""Add a widget to the container"""
|
"""Add a widget to the container"""
|
||||||
|
@ -34,19 +61,23 @@ class Paned(Container):
|
||||||
self.pack1(widget, True, True)
|
self.pack1(widget, True, True)
|
||||||
self.children.append(widget)
|
self.children.append(widget)
|
||||||
elif len(self.children) == 1:
|
elif len(self.children) == 1:
|
||||||
self.pack2(widget, True, True)
|
if self.get_child1():
|
||||||
|
self.pack2(widget, True, True)
|
||||||
|
else:
|
||||||
|
self.pack1(widget, True, True)
|
||||||
self.children.append(widget)
|
self.children.append(widget)
|
||||||
else:
|
else:
|
||||||
raise ValueError('already have two children')
|
raise ValueError('already have two children')
|
||||||
|
|
||||||
self.cnxids[widget] = []
|
self.cnxids[widget] = []
|
||||||
self.cnxids[widget].append(widget.connect('close-term',
|
if isinstance(widget, Terminal):
|
||||||
self.wrapcloseterm))
|
self.cnxids[widget].append(widget.connect('close-term',
|
||||||
# FIXME: somehow propagate the title-change signal to the Window
|
self.wrapcloseterm))
|
||||||
self.cnxids[widget].append(widget.connect('split-horiz',
|
# FIXME: somehow propagate the title-change signal to the Window
|
||||||
self.split_horiz))
|
self.cnxids[widget].append(widget.connect('split-horiz',
|
||||||
self.cnxids[widget].append(widget.connect('split-vert',
|
self.split_horiz))
|
||||||
self.split_vert))
|
self.cnxids[widget].append(widget.connect('split-vert',
|
||||||
|
self.split_vert))
|
||||||
|
|
||||||
def remove(self, widget):
|
def remove(self, widget):
|
||||||
"""Remove a widget from the container"""
|
"""Remove a widget from the container"""
|
||||||
|
@ -81,6 +112,8 @@ class HPaned(Paned, gtk.HPaned):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
Paned.__init__(self)
|
Paned.__init__(self)
|
||||||
gtk.HPaned.__init__(self)
|
gtk.HPaned.__init__(self)
|
||||||
|
self.cnxids['init'] = self.connect('expose-event',
|
||||||
|
self.set_initial_position)
|
||||||
|
|
||||||
class VPaned(Paned, gtk.VPaned):
|
class VPaned(Paned, gtk.VPaned):
|
||||||
"""Merge gtk.VPaned into our base Paned Container"""
|
"""Merge gtk.VPaned into our base Paned Container"""
|
||||||
|
@ -88,6 +121,8 @@ class VPaned(Paned, gtk.VPaned):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
Paned.__init__(self)
|
Paned.__init__(self)
|
||||||
gtk.VPaned.__init__(self)
|
gtk.VPaned.__init__(self)
|
||||||
|
self.cnxids['init'] = self.connect('expose-event',
|
||||||
|
self.set_initial_position)
|
||||||
|
|
||||||
gobject.type_register(HPaned)
|
gobject.type_register(HPaned)
|
||||||
gobject.type_register(VPaned)
|
gobject.type_register(VPaned)
|
||||||
|
|
|
@ -72,6 +72,8 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
composite_support = None
|
composite_support = None
|
||||||
|
|
||||||
|
cnxid = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
gtk.VBox.__init__(self)
|
gtk.VBox.__init__(self)
|
||||||
|
@ -252,7 +254,7 @@ class Terminal(gtk.VBox):
|
||||||
self.vte.connect('enter_notify_event',
|
self.vte.connect('enter_notify_event',
|
||||||
self.on_vte_notify_enter)
|
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):
|
def create_popup_group_menu(self, widget, event = None):
|
||||||
"""Pop up a menu for the group widget"""
|
"""Pop up a menu for the group widget"""
|
||||||
|
@ -423,6 +425,12 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
def reconfigure(self, widget=None):
|
def reconfigure(self, widget=None):
|
||||||
"""Reconfigure our settings"""
|
"""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
|
# FIXME: actually reconfigure our settings
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue