feat: add preferences
This commit is contained in:
parent
58a25368d0
commit
4c60b19e98
|
@ -82,7 +82,7 @@ class AccumulateApplication(Adw.Application):
|
|||
except requests.HTTPError:
|
||||
self.win.error.set_title(f"{r.status_code}: An HTTP error occured")
|
||||
self.win.error.set_description(f"Server message: {str(r.text)}")
|
||||
self.win.error_content.set_label(str(r.content))
|
||||
self.win.error_label.set_label(str(r.content))
|
||||
self.win.error_content.set_visible(True)
|
||||
self.win.view_stack.set_visible_child(self.win.error_stack)
|
||||
except requests.ConnectionError:
|
||||
|
@ -213,6 +213,25 @@ class AccumulateApplication(Adw.Application):
|
|||
def on_preferences_action(self, widget, _):
|
||||
"""Callback for the app.preferences action."""
|
||||
print('app.preferences action activated')
|
||||
|
||||
pref = Adw.PreferencesWindow()
|
||||
pref.set_transient_for(self.props.active_window)
|
||||
pref.set_title("Preferences")
|
||||
page = Adw.PreferencesPage()
|
||||
group = Adw.PreferencesGroup(title="Server")
|
||||
self.server_row = Adw.EntryRow()
|
||||
self.server_row.set_title("URL")
|
||||
self.server_row.set_input_purpose(Gtk.InputPurpose.URL)
|
||||
self.server_row.set_text(self.server)
|
||||
self.server_row.connect("changed", self.on_server_entry_changed)
|
||||
group.add(self.server_row)
|
||||
page.add(group)
|
||||
pref.add(page)
|
||||
pref.present()
|
||||
|
||||
def on_server_entry_changed(self, widget):
|
||||
self.server = widget.get_text()
|
||||
self.settings.set_string("server-url", self.server)
|
||||
|
||||
def create_action(self, name, callback, shortcuts=None):
|
||||
"""Add an application action.
|
||||
|
|
|
@ -35,6 +35,7 @@ class AccumulateWindow(Adw.ApplicationWindow):
|
|||
error = Gtk.Template.Child()
|
||||
error_stack = Gtk.Template.Child()
|
||||
error_content = Gtk.Template.Child()
|
||||
error_label = Gtk.Template.Child()
|
||||
content = Gtk.Template.Child()
|
||||
already_submitted = Gtk.Template.Child()
|
||||
|
||||
|
|
|
@ -232,7 +232,8 @@ template AccumulateWindow : Adw.ApplicationWindow {
|
|||
description: _("Please report an issue to the GNOME Team.");
|
||||
icon-name: "error-symbolic";
|
||||
|
||||
Gtk.Box {
|
||||
Gtk.Box error_content {
|
||||
visible: false;
|
||||
margin-end: 50;
|
||||
margin-start: 50;
|
||||
styles ["card"]
|
||||
|
@ -242,10 +243,9 @@ template AccumulateWindow : Adw.ApplicationWindow {
|
|||
margin-end: 12;
|
||||
min-content-height: 200;
|
||||
overflow: hidden;
|
||||
Gtk.Label error_content {
|
||||
Gtk.Label error_label {
|
||||
hexpand: true;
|
||||
vexpand: true;
|
||||
visible: false;
|
||||
selectable: true;
|
||||
wrap: true;
|
||||
xalign: 0;
|
||||
|
|
Loading…
Reference in New Issue