From 1f07256a92219893d800e08efedba5f25d5434c5 Mon Sep 17 00:00:00 2001 From: Nico Alt <nicoalt@posteo.org> Date: Fri, 27 Mar 2020 12:00:05 +0000 Subject: [PATCH] Use action instead of on_links_next_pressed function --- briar-gtk/briar_gtk/actions/add_contact.py | 25 +++++++++++++++++++ briar-gtk/briar_gtk/actions/prefixes.py | 8 ++++++ briar-gtk/briar_gtk/containers/add_contact.py | 10 ++++++-- briar-gtk/data/ui/add_contact.ui | 2 +- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 briar-gtk/briar_gtk/actions/add_contact.py create mode 100644 briar-gtk/briar_gtk/actions/prefixes.py diff --git a/briar-gtk/briar_gtk/actions/add_contact.py b/briar-gtk/briar_gtk/actions/add_contact.py new file mode 100644 index 0000000..01f965f --- /dev/null +++ b/briar-gtk/briar_gtk/actions/add_contact.py @@ -0,0 +1,25 @@ +# Copyright (c) 2020 Nico Alt +# SPDX-License-Identifier: AGPL-3.0-only +# License-Filename: LICENSE.md + +from briar_gtk.actions.actions import Actions +from briar_gtk.actions.prefixes import ADD_CONTACT_PREFIX + + +# pylint: disable=too-few-public-methods +class AddContactActions(Actions): + + def __init__(self, widget): + super().__init__(widget) + self._setup_simple_action_group(ADD_CONTACT_PREFIX) + self._setup_actions() + + def _setup_actions(self): + self._setup_proceed_from_links_action() + + def _setup_proceed_from_links_action(self): + self._setup_action("proceed-from-links", None, self._proceed_from_links) + + # pylint: disable=unused-argument + def _proceed_from_links(self, action, parameter): + self.widget.proceed_from_links() diff --git a/briar-gtk/briar_gtk/actions/prefixes.py b/briar-gtk/briar_gtk/actions/prefixes.py new file mode 100644 index 0000000..09d5bc7 --- /dev/null +++ b/briar-gtk/briar_gtk/actions/prefixes.py @@ -0,0 +1,8 @@ +# Copyright (c) 2020 Nico Alt +# SPDX-License-Identifier: AGPL-3.0-only +# License-Filename: LICENSE.md + +ADD_CONTACT_PREFIX = "add-contact" +APPLICATION_PREFIX = "app" +LOGIN_PREFIX = "login" +WINDOW_PREFIX = "win" diff --git a/briar-gtk/briar_gtk/containers/add_contact.py b/briar-gtk/briar_gtk/containers/add_contact.py index 94d5875..5f1a03a 100644 --- a/briar-gtk/briar_gtk/containers/add_contact.py +++ b/briar-gtk/briar_gtk/containers/add_contact.py @@ -6,6 +6,8 @@ from gettext import gettext as _ from briar_wrapper.models.contacts import Contacts +from briar_gtk.actions.add_contact import AddContactActions +from briar_gtk.actions.prefixes import ADD_CONTACT_PREFIX from briar_gtk.container import Container from briar_gtk.define import APP @@ -18,6 +20,7 @@ class AddContactContainer(Container): def __init__(self): super().__init__() + AddContactActions(self) self._setup_view() self._load_content() @@ -42,6 +45,9 @@ class AddContactContainer(Container): def _setup_add_contact_flow_headers(self): add_contact_flow_headers = self.builder.get_object(self.HEADERS_NAME) add_contact_flow_headers.show_all() + add_contact_flow_headers.insert_action_group( + ADD_CONTACT_PREFIX, self.get_action_group(ADD_CONTACT_PREFIX) + ) APP().window.set_titlebar(add_contact_flow_headers) def _setup_link_enter_listener(self): @@ -50,10 +56,10 @@ class AddContactContainer(Container): # pylint: disable=unused-argument def _on_link_enter(self, widget): - self.on_links_next_pressed(None) + self.proceed_from_links() # pylint: disable=unused-argument - def on_links_next_pressed(self, button): + def proceed_from_links(self): link_error_label = self.builder.get_object("link_error_label") if self._link_is_empty(): link_error_label.set_label(_("Please enter a link")) diff --git a/briar-gtk/data/ui/add_contact.ui b/briar-gtk/data/ui/add_contact.ui index 639dfcb..c62c14e 100644 --- a/briar-gtk/data/ui/add_contact.ui +++ b/briar-gtk/data/ui/add_contact.ui @@ -205,7 +205,7 @@ <property name="use_underline">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Next</property> - <signal name="clicked" handler="on_links_next_pressed"/> + <property name="action_name">add-contact.proceed-from-links</property> <style> <class name="suggested-action"/> </style> -- GitLab