Save/restore prefs works, opacity settings don't, so disabled for now.
This commit is contained in:
parent
a48ac22c9b
commit
f71222a9ff
21
crussh.py
21
crussh.py
@ -9,6 +9,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
import json
|
import json
|
||||||
|
import os.path
|
||||||
try:
|
try:
|
||||||
import gtk
|
import gtk
|
||||||
except:
|
except:
|
||||||
@ -28,7 +29,7 @@ class CruSSHConf:
|
|||||||
MainWin = gtk.Window()
|
MainWin = gtk.Window()
|
||||||
|
|
||||||
### Signal Hooks ###
|
### Signal Hooks ###
|
||||||
def destroy_hook(self, discard, save_func):
|
def save_hook(self, discard, save_func):
|
||||||
self.MainWin.destroy()
|
self.MainWin.destroy()
|
||||||
if save_func != None:
|
if save_func != None:
|
||||||
save_func(self.Config)
|
save_func(self.Config)
|
||||||
@ -67,7 +68,8 @@ class CruSSHConf:
|
|||||||
OpacityAdj = gtk.Adjustment(upper=65535, step_incr=1, value=self.Config["opacity"])
|
OpacityAdj = gtk.Adjustment(upper=65535, step_incr=1, value=self.Config["opacity"])
|
||||||
OpacityScale = gtk.HScale(OpacityAdj)
|
OpacityScale = gtk.HScale(OpacityAdj)
|
||||||
OpacityScale.set_draw_value(False)
|
OpacityScale.set_draw_value(False)
|
||||||
OpacityScale.connect("value-changed", self.opacity_hook)
|
# disconnect this until we get it working.
|
||||||
|
# OpacityScale.connect("value-changed", self.opacity_hook)
|
||||||
TermConfTable.attach(OpacityScale, 2, 3, 2, 3)
|
TermConfTable.attach(OpacityScale, 2, 3, 2, 3)
|
||||||
|
|
||||||
ConfirmBox = gtk.HBox(spacing=5)
|
ConfirmBox = gtk.HBox(spacing=5)
|
||||||
@ -79,7 +81,7 @@ class CruSSHConf:
|
|||||||
|
|
||||||
# wire up behaviour
|
# wire up behaviour
|
||||||
CancelButton.connect("clicked", lambda discard: self.MainWin.destroy())
|
CancelButton.connect("clicked", lambda discard: self.MainWin.destroy())
|
||||||
SaveButton.connect("clicked", self.destroy_hook, save_func)
|
SaveButton.connect("clicked", self.save_hook, save_func)
|
||||||
|
|
||||||
self.MainWin.show_all()
|
self.MainWin.show_all()
|
||||||
|
|
||||||
@ -95,8 +97,6 @@ class CruSSH:
|
|||||||
### Config Vars ###
|
### Config Vars ###
|
||||||
# config defaults
|
# config defaults
|
||||||
Config = {
|
Config = {
|
||||||
"login": None,
|
|
||||||
"port": None,
|
|
||||||
"font": "Ubuntu Mono Bold 10",
|
"font": "Ubuntu Mono Bold 10",
|
||||||
"opacity": 65535
|
"opacity": 65535
|
||||||
}
|
}
|
||||||
@ -191,6 +191,14 @@ class CruSSH:
|
|||||||
self.Config = new_config
|
self.Config = new_config
|
||||||
self.configTerminals()
|
self.configTerminals()
|
||||||
self.reflow()
|
self.reflow()
|
||||||
|
# save to file last, so it doesn't hold up other GUI actions
|
||||||
|
conf_json = json.dumps(self.Config, sort_keys=True, indent=4)
|
||||||
|
try:
|
||||||
|
conf_file = open(os.path.expanduser("~/.crusshrc"), 'w')
|
||||||
|
conf_file.write(conf_json)
|
||||||
|
conf_file.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
PrefsItem.connect("activate", lambda discard: CruSSHConf(self.Config, save_func))
|
PrefsItem.connect("activate", lambda discard: CruSSHConf(self.Config, save_func))
|
||||||
EditMenu.append(PrefsItem)
|
EditMenu.append(PrefsItem)
|
||||||
MainMenuBar.append(EditItem)
|
MainMenuBar.append(EditItem)
|
||||||
@ -233,8 +241,9 @@ class CruSSH:
|
|||||||
def __init__(self, hosts, ssh_args=None):
|
def __init__(self, hosts, ssh_args=None):
|
||||||
# load existing config file, if present
|
# load existing config file, if present
|
||||||
try:
|
try:
|
||||||
Config = json.load(open('~/.crusshrc'))
|
self.Config = json.load(open(os.path.expanduser('~/.crusshrc')))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# init all terminals
|
# init all terminals
|
||||||
|
Loading…
Reference in New Issue
Block a user