MCPcopy Create free account
hub / github.com/BuddySirJava/SSH-Studio / PreferencesDialog

Class PreferencesDialog

src/ui/preferences_dialog.py:13–209  ·  view source on GitHub ↗

Application preferences dialog using Adwaita components.

Source from the content-addressed store, hash-verified

11 resource_path="/io/github/BuddySirJava/SSH-Studio/ui/preferences_dialog.ui"
12)
13class PreferencesDialog(Adw.PreferencesDialog):
14 """Application preferences dialog using Adwaita components."""
15
16 __gtype_name__ = "SSHStudioPreferencesDialog"
17
18 config_path_entry = Gtk.Template.Child()
19 config_path_button = Gtk.Template.Child()
20 backup_dir_entry = Gtk.Template.Child()
21 backup_dir_button = Gtk.Template.Child()
22 auto_backup_switch = Gtk.Template.Child()
23 editor_font_spin = Gtk.Template.Child()
24 dark_theme_switch = Gtk.Template.Child()
25 raw_wrap_switch = Gtk.Template.Child()
26
27 def __init__(self, parent):
28 super().__init__()
29 self._parent = parent
30 try:
31 self.set_title(_("Preferences"))
32 except Exception:
33 pass
34 try:
35 self.set_default_size(600, 500)
36 except Exception:
37 pass
38 GLib.idle_add(self._connect_signals)
39 GLib.idle_add(self._load_preferences_safely)
40
41 def _connect_signals(self):
42 self.config_path_button.connect("clicked", self._on_config_path_clicked)
43 self.backup_dir_button.connect("clicked", self._on_backup_dir_clicked)
44 self.connect("close-attempt", self._on_close_attempt)
45 self.config_path_entry.connect("changed", self._on_entry_changed)
46 self.backup_dir_entry.connect("changed", self._on_entry_changed)
47 self.auto_backup_switch.connect("notify::active", self._on_switch_toggled)
48 self.dark_theme_switch.connect("notify::active", self._on_switch_toggled)
49 self.raw_wrap_switch.connect("notify::active", self._on_switch_toggled)
50 self.editor_font_spin.connect("notify::value", self._on_spin_changed)
51
52 self.editor_font_spin.get_adjustment().connect(
53 "value-changed", self._on_spin_changed
54 )
55
56 self._setup_keyboard_shortcuts()
57
58 def _setup_keyboard_shortcuts(self):
59 """Setup keyboard shortcuts for the preferences dialog."""
60 key_controller = Gtk.EventControllerKey.new()
61 key_controller.connect("key-pressed", self._on_key_pressed)
62 self.add_controller(key_controller)
63
64 def _on_key_pressed(self, controller, keyval, keycode, state):
65 """Handle key presses in the preferences dialog."""
66 if keyval == Gdk.KEY_Escape:
67 self.close()
68 return True
69 return False
70

Callers 2

_load_preferencesMethod · 0.85
_on_preferencesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected