Fixed remaining reflow() bugs.
This commit is contained in:
parent
9a27fa34f3
commit
5d58acd882
23
crussh.py
23
crussh.py
@ -53,35 +53,40 @@ class CruSSH:
|
|||||||
# empty table and re-size
|
# empty table and re-size
|
||||||
hosts = sorted(self.Terminals.keys(), reverse=True)
|
hosts = sorted(self.Terminals.keys(), reverse=True)
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
self.LayoutTable.remove(self.Terminals[host])
|
if self.Terminals[host].parent == self.LayoutTable:
|
||||||
|
self.LayoutTable.remove(self.Terminals[host])
|
||||||
self.LayoutTable.resize(rows, cols)
|
self.LayoutTable.resize(rows, cols)
|
||||||
# layout terminals
|
# layout terminals
|
||||||
for row in range(rows):
|
for row in range(rows):
|
||||||
for col in range(cols):
|
for col in range(cols):
|
||||||
if len(hosts) > 0:
|
if len(hosts) > 0:
|
||||||
host = hosts.pop()
|
host = hosts.pop()
|
||||||
self.LayoutTable.attach(self.Terminals[host], col, col+1, row, row+1)
|
|
||||||
self.Terminals[host].set_size(80, 24)
|
self.Terminals[host].set_size(80, 24)
|
||||||
|
self.LayoutTable.attach(self.Terminals[host], col, col+1, row, row+1)
|
||||||
|
|
||||||
def reflow(self):
|
def reflow(self, force=False):
|
||||||
num_terms = len(self.Terminals)
|
num_terms = len(self.Terminals)
|
||||||
if num_terms < 1:
|
if num_terms < 1:
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
size = self.MainWin.allocation
|
size = self.MainWin.allocation
|
||||||
cols = int(math.floor((size.width + self.LayoutTable.props.column_spacing) / self.TermMinWidth))
|
cols = int(math.floor((size.width + self.LayoutTable.props.column_spacing) / float(self.TermMinWidth)))
|
||||||
if cols < 1 or num_terms == 1:
|
if cols < 1 or num_terms == 1:
|
||||||
cols = 1
|
cols = 1
|
||||||
rows = int(math.ceil(num_terms/cols))
|
rows = int(math.ceil(num_terms/float(cols)))
|
||||||
if rows < 1:
|
if rows < 1:
|
||||||
rows = 1
|
rows = 1
|
||||||
if (self.LayoutTable.props.n_columns != cols) or (self.LayoutTable.props.n_rows != rows):
|
if (self.LayoutTable.props.n_columns != cols) or (self.LayoutTable.props.n_rows != rows) or force:
|
||||||
self.reflowTable(cols, rows)
|
self.reflowTable(cols, rows)
|
||||||
self.MainWin.show_all()
|
self.MainWin.show_all()
|
||||||
|
|
||||||
def removeTerminal(self, terminal):
|
def removeTerminal(self, terminal):
|
||||||
# TODO: make this work. ;)
|
# brute force search since we don't actually know the hostname from the
|
||||||
# del self.Terminals[terminal.props.window_title]
|
# terminal object. this is an infrequent operation, so it should be fine.
|
||||||
self.reflow()
|
for host in self.Terminals.keys():
|
||||||
|
if terminal == self.Terminals[host]:
|
||||||
|
self.LayoutTable.remove(self.Terminals[host])
|
||||||
|
del self.Terminals[host]
|
||||||
|
self.reflow(force=True)
|
||||||
|
|
||||||
def initGUI(self):
|
def initGUI(self):
|
||||||
self.MainWin.set_title("crussh: " + ' '.join(self.Terminals.keys()))
|
self.MainWin.set_title("crussh: " + ' '.join(self.Terminals.keys()))
|
||||||
|
Loading…
Reference in New Issue
Block a user