[meld/windows-fixes: 14/15] settings: Handle missing GNOME desktop schemas for font settings
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/windows-fixes: 14/15] settings: Handle missing GNOME desktop schemas for font settings
- Date: Sat, 6 Aug 2022 08:11:26 +0000 (UTC)
commit a94df204104fa7d7fed140aa15fab95e7079f913
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Jul 24 08:11:51 2022 +1000
settings: Handle missing GNOME desktop schemas for font settings
We only use the desktop schemas to get the default font, and even then
we do not currently use this on Windows anyway. Rather than writing
another Windows-specific workaround here, this commit makes us handle
missing desktop schemas with a simple fallback to a monospace font.
meld/settings.py | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/meld/settings.py b/meld/settings.py
index 942269c8..fc2d6c40 100644
--- a/meld/settings.py
+++ b/meld/settings.py
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
+from typing import Optional
from gi.repository import Gio, GObject, Gtk, GtkSource, Pango
@@ -78,9 +79,11 @@ class MeldSettings(GObject.GObject):
if settings.get_boolean('use-system-font'):
if sys.platform == 'win32':
font_string = 'Consolas 11'
- else:
+ elif interface_settings:
font_string = interface_settings.get_string(
'monospace-font-name')
+ else:
+ font_string = 'monospace'
else:
font_string = settings.get_string('custom-font')
return Pango.FontDescription(font_string)
@@ -101,11 +104,23 @@ def load_settings_schema(schema_id):
return settings
+def load_interface_settings() -> Optional[Gio.Settings]:
+
+ # We conditionally load these since they're only used for default
+ # fonts and can sometimes be missing (e.g., in some Windows setups)
+ default_source = Gio.SettingsSchemaSource.get_default()
+ schema = default_source.lookup("org.gnome.desktop.interface", False)
+ if not schema:
+ return None
+
+ return Gio.Settings.new_full(schema=schema, backend=None, path=None)
+
+
def create_settings():
global settings, interface_settings, _meldsettings
settings = load_settings_schema(meld.conf.SETTINGS_SCHEMA_ID)
- interface_settings = Gio.Settings.new('org.gnome.desktop.interface')
+ interface_settings = load_interface_settings()
_meldsettings = MeldSettings()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]