Look up GNOME system font and focus settings via gconf

This commit is contained in:
Chris Jones 2010-01-21 21:39:05 +00:00
parent c00cf071c7
commit df992c284e
3 changed files with 51 additions and 8 deletions

View File

@ -70,6 +70,11 @@ from configobj.validate import Validator
from borg import Borg
from util import dbg, err, DEBUG, get_config_dir, dict_diff
try:
import gconf
except ImportError:
dbg('Unable to import gconf, GNOME defaults unavailable')
DEFAULTS = {
'global_config': {
'focus' : 'click',
@ -210,6 +215,7 @@ class Config(object):
"""Class to provide a slightly richer config API above ConfigBase"""
base = None
profile = None
gconf = None
def __init__(self, profile='default'):
self.base = ConfigBase()
@ -259,6 +265,28 @@ class Config(object):
"""List all configured profiles"""
return(self.base.profiles.keys())
def get_system_font(self):
"""Look up the system font"""
if 'gconf' not in globals():
return
if self.gconf is None:
self.gconf = gconf.client_get_default()
value = self.gconf.get('/desktop/gnome/interface/monospace_font_name')
return(value.get_string())
def get_system_focus(self):
"""Look up the system focus setting"""
if 'gconf' not in globals():
return
if self.gconf is None:
self.gconf = gconf.client_get_default()
value = self.gconf.get('/apps/metacity/general/focus_mode')
return(value.get_string())
def save(self):
"""Cause ConfigBase to save our config to file"""
return(self.base.save())

View File

@ -277,7 +277,10 @@ class PrefsEditor:
self.on_system_font_checkbutton_toggled(widget)
# Font selector
widget = guiget('font-selector')
widget.set_font_name(self.config['font'])
if self.config['use_system_font'] == True:
widget.set_font_name(self.config.get_system_font())
else:
widget.set_font_name(self.config['font'])
# Allow bold text
widget = guiget('allow-bold-checkbutton')
widget.set_active(self.config['allow_bold'])

View File

@ -524,7 +524,11 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
if not self.custom_font_size:
try:
self.vte.set_font(pango.FontDescription(self.config['font']))
if self.config['use_system_font'] == True:
font = self.config.get_system_font()
else:
font = self.config['font']
self.vte.set_font(pango.FontDescription(font))
except:
pass
self.vte.set_allow_bold(self.config['allow_bold'])
@ -892,10 +896,14 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
def on_vte_notify_enter(self, term, event):
"""Handle the mouse entering this terminal"""
if self.config['focus'] in ['sloppy', 'mouse']:
if self.titlebar.editing() == False:
term.grab_focus()
return(False)
sloppy = False
if self.config['focus'] == 'system':
sloppy = self.config.get_system_focus() == 'sloppy'
elif self.config['focus'] in ['sloppy', 'mouse']:
sloppy = True
if sloppy == True and self.titlebar.editing() == False:
term.grab_focus()
return(False)
def get_zoom_data(self):
"""Return a dict of information for Window"""
@ -1103,8 +1111,12 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
def zoom_orig(self):
"""Restore original font size"""
dbg("Terminal::zoom_orig: restoring font to: %s" % self.config['font'])
self.vte.set_font(pango.FontDescription(self.config['font']))
if self.config['use_system_font'] == True:
font = self.config.get_system_font()
else:
font = self.config['font']
dbg("Terminal::zoom_orig: restoring font to: %s" % font)
self.vte.set_font(pango.FontDescription(font))
self.custom_font_size = None
def get_cursor_position(self):