Fix system fonts under gtk3
This commit is contained in:
parent
45cb6e05c6
commit
2bc19498ea
|
@ -79,12 +79,7 @@ from configobj.validate import Validator
|
|||
from borg import Borg
|
||||
from util import dbg, err, DEBUG, get_config_dir, dict_diff
|
||||
|
||||
try:
|
||||
import gi
|
||||
gi.require_version('GConf','2.0')
|
||||
from gi.repository import GConf
|
||||
except ImportError:
|
||||
dbg('Unable to import gconf, GNOME defaults unavailable')
|
||||
from gi.repository import Gio
|
||||
|
||||
DEFAULTS = {
|
||||
'global_config': {
|
||||
|
@ -272,7 +267,6 @@ class Config(object):
|
|||
"""Class to provide a slightly richer config API above ConfigBase"""
|
||||
base = None
|
||||
profile = None
|
||||
gconf = None
|
||||
system_mono_font = None
|
||||
system_prop_font = None
|
||||
system_focus = None
|
||||
|
@ -282,6 +276,7 @@ class Config(object):
|
|||
self.base = ConfigBase()
|
||||
self.set_profile(profile)
|
||||
self.inhibited = False
|
||||
self.connect_gsetting_callbacks()
|
||||
|
||||
def __getitem__(self, key, default=None):
|
||||
"""Look up a configuration item"""
|
||||
|
@ -360,70 +355,69 @@ class Config(object):
|
|||
"""List all configured layouts"""
|
||||
return(self.base.layouts.keys())
|
||||
|
||||
def connect_gsetting_callbacks(self):
|
||||
"""Get system settings and create callbacks for changes"""
|
||||
dbg("GSetting connects for system changes")
|
||||
# Have to preserve these to self, or callbacks don't happen
|
||||
self.gsettings_interface=Gio.Settings.new('org.gnome.desktop.interface')
|
||||
self.gsettings_interface.connect("changed::font-name", self.on_gsettings_change_event)
|
||||
self.gsettings_interface.connect("changed::monospace-font-name", self.on_gsettings_change_event)
|
||||
self.gsettings_wm=Gio.Settings.new('org.gnome.desktop.wm.preferences')
|
||||
self.gsettings_wm.connect("changed::focus-mode", self.on_gsettings_change_event)
|
||||
|
||||
def get_system_prop_font(self):
|
||||
"""Look up the system font"""
|
||||
if self.system_prop_font is not None:
|
||||
return(self.system_prop_font)
|
||||
elif 'GConf' not in globals():
|
||||
elif 'org.gnome.desktop.interface' not in Gio.Settings.list_schemas():
|
||||
return
|
||||
else:
|
||||
if self.gconf is None:
|
||||
self.gconf = GConf.Client.get_default()
|
||||
|
||||
value = self.gconf.get(
|
||||
'/desktop/gnome/interface/font_name')
|
||||
gsettings=Gio.Settings.new('org.gnome.desktop.interface')
|
||||
value = gsettings.get_value('font-name')
|
||||
if value:
|
||||
self.system_prop_font = value.get_string()
|
||||
else:
|
||||
self.system_prop_font = "Sans 10"
|
||||
self.gconf.notify_add(
|
||||
'/desktop/gnome/interface/font_name',
|
||||
self.on_gconf_notify)
|
||||
return(self.system_prop_font)
|
||||
|
||||
def get_system_mono_font(self):
|
||||
"""Look up the system font"""
|
||||
if self.system_mono_font is not None:
|
||||
return(self.system_mono_font)
|
||||
elif 'GConf' not in globals():
|
||||
elif 'org.gnome.desktop.interface' not in Gio.Settings.list_schemas():
|
||||
return
|
||||
else:
|
||||
if self.gconf is None:
|
||||
self.gconf = GConf.Client.get_default()
|
||||
|
||||
value = self.gconf.get(
|
||||
'/desktop/gnome/interface/monospace_font_name')
|
||||
gsettings=Gio.Settings.new('org.gnome.desktop.interface')
|
||||
value = gsettings.get_value('monospace-font-name')
|
||||
if value:
|
||||
self.system_mono_font = value.get_string()
|
||||
else:
|
||||
self.system_mono_font = "Mono 10"
|
||||
self.gconf.notify_add(
|
||||
'/desktop/gnome/interface/monospace_font_name',
|
||||
self.on_gconf_notify)
|
||||
return(self.system_mono_font)
|
||||
|
||||
def get_system_focus(self):
|
||||
"""Look up the system focus setting"""
|
||||
if self.system_focus is not None:
|
||||
return(self.system_focus)
|
||||
elif 'GConf' not in globals():
|
||||
elif 'org.gnome.desktop.interface' not in Gio.Settings.list_schemas():
|
||||
return
|
||||
else:
|
||||
if self.gconf is None:
|
||||
self.gconf = GConf.Client.get_default()
|
||||
|
||||
value = self.gconf.get('/apps/metacity/general/focus_mode')
|
||||
gsettings=Gio.Settings.new('org.gnome.desktop.wm.preferences')
|
||||
value = gsettings.get_value('focus-mode')
|
||||
if value:
|
||||
self.system_focus = value.get_string()
|
||||
self.gconf.notify_add('/apps/metacity/general/focus_mode',
|
||||
self.on_gconf_notify)
|
||||
return(self.system_focus)
|
||||
|
||||
def on_gconf_notify(self, _client, _cnxn_id, _entry, _what):
|
||||
"""Handle a gconf watch changing"""
|
||||
dbg('GConf notification received. Invalidating caches')
|
||||
def on_gsettings_change_event(self, settings, key):
|
||||
"""Handle a gsetting change event"""
|
||||
dbg('GSetting change event received. Invalidating caches')
|
||||
self.system_focus = None
|
||||
self.system_font = None
|
||||
self.system_mono_font = None
|
||||
# Need to trigger a reconfigure to change active terminals immediately
|
||||
if "Terminator" not in globals():
|
||||
from terminator import Terminator
|
||||
Terminator().reconfigure()
|
||||
|
||||
def save(self):
|
||||
"""Cause ConfigBase to save our config to file"""
|
||||
|
|
Loading…
Reference in New Issue