since the gnome proxy will always be accessible by gconf and anyone else can override with , we don't need to support defaults for all of these proxy related things, and we certainly have no need of watching them in gconf. Just work the string out and do it already

This commit is contained in:
Chris Jones 2008-04-10 00:22:20 +01:00
parent 4bae268709
commit f382c073d4
2 changed files with 24 additions and 32 deletions

View File

@ -130,7 +130,7 @@ class TerminatorTerm:
self._vte.connect ("child-exited", self.spawn_child) self._vte.connect ("child-exited", self.spawn_child)
# We need to support "left" because some buggy versions of gnome-terminal # We need to support "left" because some buggy versions of gnome-terminal
# set it in some situations # set it in some situations
if exit_action in ("close", "left"): elif exit_action in ("close", "left"):
self._vte.connect ("child-exited", lambda close_term: self.terminator.closeterm (self)) self._vte.connect ("child-exited", lambda close_term: self.terminator.closeterm (self))
self._vte.add_events (gtk.gdk.ENTER_NOTIFY_MASK) self._vte.add_events (gtk.gdk.ENTER_NOTIFY_MASK)
@ -152,6 +152,9 @@ class TerminatorTerm:
if self.matches['nntp'] == -1: if self.matches['nntp'] == -1:
self.matches['nntp'] = self._vte.match_add ('''\<news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@[-A-Za-z0-9.]+(:[0-9]+)?\>''') self.matches['nntp'] = self._vte.match_add ('''\<news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@[-A-Za-z0-9.]+(:[0-9]+)?\>''')
env_proxy = os.getenv ('http_proxy')
if not env_proxy:
os.putenv ('http_proxy', self.conf.http_proxy)
self.spawn_child () self.spawn_child ()
def spawn_child (self, event=None): def spawn_child (self, event=None):

View File

@ -108,12 +108,7 @@ class TerminatorConfValuestore:
'custom_command' : '', 'custom_command' : '',
'use_system_font' : True, 'use_system_font' : True,
'use_theme_colors' : True, 'use_theme_colors' : True,
'use_http_proxy' : False, 'http_proxy' : '',
'use_authentication' : False,
'host' : '',
'port' : 0,
'authentication_user' : '',
'authentication_password': '',
'ignore_hosts' : ['localhost','127.0.0.0/8','*.local'], 'ignore_hosts' : ['localhost','127.0.0.0/8','*.local'],
} }
@ -193,8 +188,6 @@ class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
self.client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notify) self.client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notify)
self.client.add_dir ('/desktop/gnome/interface', gconf.CLIENT_PRELOAD_RECURSIVE) self.client.add_dir ('/desktop/gnome/interface', gconf.CLIENT_PRELOAD_RECURSIVE)
self.client.notify_add ('/desktop/gnome/interface/monospace_font_name', self.on_gconf_notify) self.client.notify_add ('/desktop/gnome/interface/monospace_font_name', self.on_gconf_notify)
self.client.add_dir ('/system/http_proxy', gconf.CLIENT_PRELOAD_RECURSIVE)
self.client.notify_add ('/system/http_proxy', self.on_gconf_notify)
# FIXME: Do we need to watch more non-profile stuff here? # FIXME: Do we need to watch more non-profile stuff here?
def set_reconfigure_callback (self, function): def set_reconfigure_callback (self, function):
@ -218,25 +211,28 @@ class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
value = self.client.get ('/desktop/gnome/interface/monospace_font_name') value = self.client.get ('/desktop/gnome/interface/monospace_font_name')
elif key == 'focus': elif key == 'focus':
value = self.client.get ('/apps/metacity/general/focus_mode') value = self.client.get ('/apps/metacity/general/focus_mode')
elif key == 'use_http_proxy': elif key == 'http_proxy':
value = self.client.get ('/system/http_proxy/use_http_proxy') if self.client.get_bool ('/system/http_proxy/use_http_proxy'):
elif key == 'use_authentication': dbg ('HACK: Mangling http_proxy')
value = self.client.get ('/system/http_proxy/use_authentication')
elif key == 'host': if self.client.get_bool ('use_authentication'):
value = self.client.get ('/system/http_proxy/host') dbg ('HACK: Using proxy authentication')
elif key == 'port': value = 'http://%s:%s@%s:%s/'%(
value = self.client.get ('/system/http_proxy/port') self.client.get_string ('/system/http_proxy/authentication_user'),
elif key == 'authentication_user': self.client.get_string ('/system/http_proxy/authentication_password'),
value = self.client.get ('/system/http_proxy/authentication_user') self.client.get_string ('/system/http_proxy/host'),
elif key == 'authentication_password': self.client.get_int ('/system/http_proxy/port'))
value = self.client.get ('/system/http_proxy/authentication_password') else:
elif key == 'ignore_hosts': dbg ('HACK: Not using proxy authentication')
value = self.client.get ('/system/http_proxy/ignore_hosts') value = 'http://%s:%s/'%(
self.client.get_string ('/system/http_proxy/host'),
self.client.get_int ('/system/http_proxy/port'))
else: else:
value = self.client.get ('%s/%s'%(self.profile, key)) value = self.client.get ('%s/%s'%(self.profile, key))
if value: if value:
funcname = "get_" + self.defaults[key].__class__.__name__ funcname = "get_" + self.defaults[key].__class__.__name__
dbg (' GConf: picked function: %s'%funcname)
# Special case for str # Special case for str
if funcname == "get_str": if funcname == "get_str":
funcname = "get_string" funcname = "get_string"
@ -281,12 +277,5 @@ if __name__ == '__main__':
# This should raise AttributeError # This should raise AttributeError
#print foo.blimnle #print foo.blimnle
debug = False # http_proxy is a value that is allowed to not exist
print "use proxy: %d"%foo.use_http_proxy print "final proxy: %s"%foo.http_proxy
print "use proxy auth: %d"%foo.use_authentication
print "proxy host: %s"%foo.host
print "proxy port: %d"%foo.port
print "proxy user: %s"%foo.authentication_user
print "proxy pass: %s"%foo.authentication_password
for host in foo.ignore_hosts:
print "proxy ignore: %s"%host