Skip to content
Snippets Groups Projects
Commit 1f07256a authored by Nico's avatar Nico
Browse files

Use action instead of on_links_next_pressed function

parent 4e9c0b39
No related branches found
No related tags found
No related merge requests found
# 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()
# 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"
...@@ -6,6 +6,8 @@ from gettext import gettext as _ ...@@ -6,6 +6,8 @@ from gettext import gettext as _
from briar_wrapper.models.contacts import Contacts 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.container import Container
from briar_gtk.define import APP from briar_gtk.define import APP
...@@ -18,6 +20,7 @@ class AddContactContainer(Container): ...@@ -18,6 +20,7 @@ class AddContactContainer(Container):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
AddContactActions(self)
self._setup_view() self._setup_view()
self._load_content() self._load_content()
...@@ -42,6 +45,9 @@ class AddContactContainer(Container): ...@@ -42,6 +45,9 @@ class AddContactContainer(Container):
def _setup_add_contact_flow_headers(self): def _setup_add_contact_flow_headers(self):
add_contact_flow_headers = self.builder.get_object(self.HEADERS_NAME) add_contact_flow_headers = self.builder.get_object(self.HEADERS_NAME)
add_contact_flow_headers.show_all() 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) APP().window.set_titlebar(add_contact_flow_headers)
def _setup_link_enter_listener(self): def _setup_link_enter_listener(self):
...@@ -50,10 +56,10 @@ class AddContactContainer(Container): ...@@ -50,10 +56,10 @@ class AddContactContainer(Container):
# pylint: disable=unused-argument # pylint: disable=unused-argument
def _on_link_enter(self, widget): def _on_link_enter(self, widget):
self.on_links_next_pressed(None) self.proceed_from_links()
# pylint: disable=unused-argument # 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") link_error_label = self.builder.get_object("link_error_label")
if self._link_is_empty(): if self._link_is_empty():
link_error_label.set_label(_("Please enter a link")) link_error_label.set_label(_("Please enter a link"))
......
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Next</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> <style>
<class name="suggested-action"/> <class name="suggested-action"/>
</style> </style>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment