Fixed display bug with only one host, and github-3.
This commit is contained in:
parent
5d58acd882
commit
8db6995db9
22
crussh.py
22
crussh.py
@ -37,6 +37,9 @@ args = parser.parse_args()
|
|||||||
|
|
||||||
### CruSSH! ###
|
### CruSSH! ###
|
||||||
class CruSSH:
|
class CruSSH:
|
||||||
|
### Config Vars ###
|
||||||
|
Config = {}
|
||||||
|
|
||||||
### State Vars ###
|
### State Vars ###
|
||||||
Terminals = {}
|
Terminals = {}
|
||||||
TermMinWidth = 1
|
TermMinWidth = 1
|
||||||
@ -65,13 +68,17 @@ class CruSSH:
|
|||||||
self.LayoutTable.attach(self.Terminals[host], col, col+1, row, row+1)
|
self.LayoutTable.attach(self.Terminals[host], col, col+1, row, row+1)
|
||||||
|
|
||||||
def reflow(self, force=False):
|
def reflow(self, force=False):
|
||||||
num_terms = len(self.Terminals)
|
num_terms = len(self.Terminals.keys())
|
||||||
if num_terms < 1:
|
if num_terms < 1:
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
# main_quit desn't happen immediately
|
||||||
|
return False
|
||||||
size = self.MainWin.allocation
|
size = self.MainWin.allocation
|
||||||
cols = int(math.floor((size.width + self.LayoutTable.props.column_spacing) / float(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
|
||||||
|
elif cols > num_terms:
|
||||||
|
cols = num_terms
|
||||||
rows = int(math.ceil(num_terms/float(cols)))
|
rows = int(math.ceil(num_terms/float(cols)))
|
||||||
if rows < 1:
|
if rows < 1:
|
||||||
rows = 1
|
rows = 1
|
||||||
@ -131,7 +138,10 @@ class CruSSH:
|
|||||||
# give EntryBox default focus on init
|
# give EntryBox default focus on init
|
||||||
self.EntryBox.props.has_focus = True
|
self.EntryBox.props.has_focus = True
|
||||||
|
|
||||||
def __init__(self, hosts):
|
def __init__(self, hosts, login=None, port=None):
|
||||||
|
self.Config["login"] = login
|
||||||
|
self.Config["port"] = port
|
||||||
|
|
||||||
# init all terminals
|
# init all terminals
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
terminal = vte.Terminal()
|
terminal = vte.Terminal()
|
||||||
@ -142,9 +152,9 @@ class CruSSH:
|
|||||||
# TODO: disable only this terminal widget on child exit
|
# TODO: disable only this terminal widget on child exit
|
||||||
# v.connect("child-exited", lambda term: gtk.main_quit())
|
# v.connect("child-exited", lambda term: gtk.main_quit())
|
||||||
cmd_str = "/usr/bin/ssh"
|
cmd_str = "/usr/bin/ssh"
|
||||||
if args.login != None:
|
if self.Config["login"] != None:
|
||||||
cmd_str += " -l " + args.login
|
cmd_str += " -l " + args.login
|
||||||
if args.port != None:
|
if self.Config["port"] != None:
|
||||||
cmd_str += " -p " + str(args.port)
|
cmd_str += " -p " + str(args.port)
|
||||||
cmd_str += " " + host
|
cmd_str += " " + host
|
||||||
cmd = cmd_str.split(' ')
|
cmd = cmd_str.split(' ')
|
||||||
@ -155,8 +165,8 @@ class CruSSH:
|
|||||||
self.Terminals[host].connect("child-exited", self.removeTerminal)
|
self.Terminals[host].connect("child-exited", self.removeTerminal)
|
||||||
|
|
||||||
self.initGUI()
|
self.initGUI()
|
||||||
self.reflow()
|
self.reflow(force=True)
|
||||||
|
|
||||||
### Start Execution ###
|
### Start Execution ###
|
||||||
crussh = CruSSH(args.hosts)
|
crussh = CruSSH(args.hosts, args.login, args.port)
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user