MCPcopy Create free account
hub / github.com/dialect-app/dialect / __init__

Method __init__

dialect/preferences.py:40–90  ·  view source on GitHub ↗
(self, window: DialectWindow, **kwargs)

Source from the content-addressed store, hash-verified

38 default_font_size: Adw.SpinRow = Gtk.Template.Child() # type: ignore
39
40 def __init__(self, window: DialectWindow, **kwargs):
41 super().__init__(**kwargs)
42
43 self.window = window
44
45 # Bind preferences with GSettings
46 Settings.get().bind(
47 "live-translation", self.live_translation, "enable-expansion", Gio.SettingsBindFlags.DEFAULT
48 )
49 Settings.get().bind("sp-translation", self.search_provider, "active", Gio.SettingsBindFlags.DEFAULT)
50 Settings.get().bind("translate-accel", self.translate_accel, "selected", Gio.SettingsBindFlags.DEFAULT)
51 Settings.get().bind("src-auto", self.src_auto, "active", Gio.SettingsBindFlags.DEFAULT)
52 Settings.get().bind(
53 "custom-default-font-size", self.custom_default_font_size, "enable-expansion", Gio.SettingsBindFlags.DEFAULT
54 )
55 Settings.get().bind("default-font-size", self.default_font_size, "value", Gio.SettingsBindFlags.DEFAULT)
56
57 self.translator_config.props.sensitive = False
58 self.tts_config.props.sensitive = False
59
60 # Setup translator chooser
61 trans_model = ProvidersListModel("translators")
62 with self.translator.freeze_notify():
63 self.translator.set_model(trans_model)
64 self.translator.props.selected = trans_model.get_index_by_name(Settings.get().active_translator)
65 self.translator_config.props.sensitive = self._provider_has_settings(Settings.get().active_translator)
66
67 # Setup TTS chooser
68 if len(TTS) >= 1:
69 tts_model = ProvidersListModel("tts", True)
70 with self.tts.freeze_notify():
71 self.tts.set_model(tts_model)
72 self.tts.props.selected = tts_model.get_index_by_name(Settings.get().active_tts)
73 self.tts_config.props.sensitive = self._provider_has_settings(Settings.get().active_tts)
74 else:
75 self.tts.props.visible = False
76
77 # Providers Settings
78 self.translator_config.connect("clicked", self._open_provider, "trans")
79 self.tts_config.connect("clicked", self._open_provider, "tts")
80
81 # Translator loading
82 self.window.connect("notify::translator-loading", self._on_translator_loading)
83
84 # Search Provider
85 if os.getenv("XDG_CURRENT_DESKTOP") != "GNOME":
86 self.search_provider.props.visible = False
87
88 # Connect font size signals
89 self.custom_default_font_size.connect("notify::enable-expansion", self._custom_default_font_size_switch)
90 self.default_font_size.get_adjustment().connect("value-changed", self._change_default_font_size)
91
92 @Gtk.Template.Callback()
93 def is_not_true(self, _widget: Gtk.Widget, boolean: bool):

Callers

nothing calls this directly

Calls 4

get_index_by_nameMethod · 0.95
ProvidersListModelClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected