fix: make clear after send working (#19)

This commit is contained in:
0xMRTT 2023-05-07 22:49:02 +02:00
parent f15696e470
commit 142eefa310
Signed by: 0xMRTT
GPG Key ID: 19C1449A774028BD
2 changed files with 8 additions and 9 deletions

View File

@ -289,9 +289,9 @@ Providers: {self.enabled_providers}
self.win.ask_button.set_visible(True)
self.win.wait_button.set_visible(False)
GLib.idle_add(self.update_response, response)
if self.clear_after_send:
GLib.idle_add(self.update_response, "")
self.t.join()
if self.clear_after_send:
self.win.prompt_text_view.get_buffer().set_text("")
self.t = threading.Thread(target=thread_run)
self.t.start()

View File

@ -15,22 +15,21 @@ class Preferences(Adw.PreferencesWindow):
self.app = application
self.settings = application.settings
clear_after_send = self.settings.get_boolean("clear-after-send")
self.clear_after_send_switch.props.state = clear_after_send
self.clear_after_send_switch.set_active(self.app.clear_after_send)
self.clear_after_send_switch.connect(
"state-set", self.on_clear_after_send_switch_toggled
"notify::active", self.on_clear_after_send_switch_toggled
)
self.setup_providers()
def on_clear_after_send_switch_toggled(self, *args):
def on_clear_after_send_switch_toggled(self, widget, *args):
"""Callback for the clear_after_send_switch toggled event."""
state = self.clear_after_send_switch.props.state
if state:
if widget.get_active():
self.settings.set_boolean("clear-after-send", True)
self.app.clear_after_send = True
else:
self.settings.set_boolean("clear-after-send", False)
self.app.clear_after_send = False
def setup_providers(self):
# for provider in self.app.providers.values():