Look up GNOME system font and focus settings via gconf
This commit is contained in:
parent
c00cf071c7
commit
df992c284e
@ -70,6 +70,11 @@ from configobj.validate import Validator
|
|||||||
from borg import Borg
|
from borg import Borg
|
||||||
from util import dbg, err, DEBUG, get_config_dir, dict_diff
|
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 = {
|
DEFAULTS = {
|
||||||
'global_config': {
|
'global_config': {
|
||||||
'focus' : 'click',
|
'focus' : 'click',
|
||||||
@ -210,6 +215,7 @@ class Config(object):
|
|||||||
"""Class to provide a slightly richer config API above ConfigBase"""
|
"""Class to provide a slightly richer config API above ConfigBase"""
|
||||||
base = None
|
base = None
|
||||||
profile = None
|
profile = None
|
||||||
|
gconf = None
|
||||||
|
|
||||||
def __init__(self, profile='default'):
|
def __init__(self, profile='default'):
|
||||||
self.base = ConfigBase()
|
self.base = ConfigBase()
|
||||||
@ -259,6 +265,28 @@ class Config(object):
|
|||||||
"""List all configured profiles"""
|
"""List all configured profiles"""
|
||||||
return(self.base.profiles.keys())
|
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):
|
def save(self):
|
||||||
"""Cause ConfigBase to save our config to file"""
|
"""Cause ConfigBase to save our config to file"""
|
||||||
return(self.base.save())
|
return(self.base.save())
|
||||||
|
@ -277,7 +277,10 @@ class PrefsEditor:
|
|||||||
self.on_system_font_checkbutton_toggled(widget)
|
self.on_system_font_checkbutton_toggled(widget)
|
||||||
# Font selector
|
# Font selector
|
||||||
widget = guiget('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
|
# Allow bold text
|
||||||
widget = guiget('allow-bold-checkbutton')
|
widget = guiget('allow-bold-checkbutton')
|
||||||
widget.set_active(self.config['allow_bold'])
|
widget.set_active(self.config['allow_bold'])
|
||||||
|
@ -524,7 +524,11 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
|
|||||||
|
|
||||||
if not self.custom_font_size:
|
if not self.custom_font_size:
|
||||||
try:
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
self.vte.set_allow_bold(self.config['allow_bold'])
|
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):
|
def on_vte_notify_enter(self, term, event):
|
||||||
"""Handle the mouse entering this terminal"""
|
"""Handle the mouse entering this terminal"""
|
||||||
if self.config['focus'] in ['sloppy', 'mouse']:
|
sloppy = False
|
||||||
if self.titlebar.editing() == False:
|
if self.config['focus'] == 'system':
|
||||||
term.grab_focus()
|
sloppy = self.config.get_system_focus() == 'sloppy'
|
||||||
return(False)
|
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):
|
def get_zoom_data(self):
|
||||||
"""Return a dict of information for Window"""
|
"""Return a dict of information for Window"""
|
||||||
@ -1103,8 +1111,12 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
|
|||||||
|
|
||||||
def zoom_orig(self):
|
def zoom_orig(self):
|
||||||
"""Restore original font size"""
|
"""Restore original font size"""
|
||||||
dbg("Terminal::zoom_orig: restoring font to: %s" % self.config['font'])
|
if self.config['use_system_font'] == True:
|
||||||
self.vte.set_font(pango.FontDescription(self.config['font']))
|
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
|
self.custom_font_size = None
|
||||||
|
|
||||||
def get_cursor_position(self):
|
def get_cursor_position(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user