pref: add preferences for clear after send
This commit is contained in:
parent
399982ea15
commit
211ae80e93
|
@ -1,5 +1,6 @@
|
|||
blueprints = custom_target('blueprints',
|
||||
input: files(
|
||||
'preferences.blp',
|
||||
'window.blp',
|
||||
),
|
||||
output: '.',
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template GradiencePreferencesWindow : Adw.PreferencesWindow {
|
||||
title: _("Preferences");
|
||||
default-height: 400;
|
||||
default-width: 600;
|
||||
modal: true;
|
||||
|
||||
Adw.PreferencesPage general_page {
|
||||
Adw.PreferencesGroup prompt_group {
|
||||
title: _("Prompt");
|
||||
|
||||
Adw.ActionRow {
|
||||
title: _("Clear prompt after send");
|
||||
subtitle: _("The prompt will be cleared after send");
|
||||
activatable-widget: clear_after_send_switch;
|
||||
Gtk.Switch clear_after_send_switch {
|
||||
valign: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
from gi.repository import Gtk, Adw
|
||||
|
||||
|
||||
@Gtk.Template(resource_path="/com/github/Bavarder/Bavarder/ui/preferences.ui")
|
||||
class Preferences(Adw.PreferencesWindow):
|
||||
__gtype_name__ = "GradiencePreferencesWindow"
|
||||
|
||||
clear_after_send_switch = Gtk.Template.Child()
|
||||
|
||||
def __init__(self, application, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.app = application
|
||||
self.settings = application.settings
|
||||
|
||||
self.win = self.app.get_active_window()
|
||||
|
||||
|
||||
self.setup()
|
||||
|
||||
def setup(self):
|
||||
clear_after_send = self.settings.get_boolean("clear-after-send")
|
||||
self.clear_after_send_switch.connect("state-set", self.on_clear_after_send_switch_toggled)
|
||||
|
||||
def on_clear_after_send_switch_toggled(self, *args):
|
||||
state = self.clear_after_send_switch.props.state
|
||||
|
||||
if state:
|
||||
self.settings.set_boolean("clear-after-send", True)
|
||||
else:
|
||||
self.settings.set_boolean("clear-after-send", False)
|
Loading…
Reference in New Issue