window.py 2.04 KB
Newer Older
1 2 3 4 5 6 7 8
# Copyright (c) 2014-2020 Cedric Bellegarde <cedric.bellegarde@adishatz.org>
# Copyright (c) 2020 Nico Alt
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
#
# Initial version based on GNOME Lollypop
# https://gitlab.gnome.org/World/lollypop/blob/1.2.20/lollypop/application_actions.py

Nico Alt's avatar
Nico Alt committed
9
from gi.repository import GLib
10

Nico Alt's avatar
Nico Alt committed
11
from briar_gtk.actions.actions import Actions
12
from briar_gtk.containers.main_window import MainWindowContainer
13 14 15 16
from briar_gtk.define import APP


# pylint: disable=too-few-public-methods
Nico Alt's avatar
Nico Alt committed
17
class WindowActions(Actions):
18 19 20 21 22

    def __init__(self):
        self._setup_actions()

    def _setup_actions(self):
Nico Alt's avatar
Nico Alt committed
23 24 25 26 27 28 29
        self._setup_back_to_sidebar_action()
        self._setup_open_about_page_action()
        self._setup_open_add_contact_action()
        self._setup_open_private_chat_action()

    def _setup_back_to_sidebar_action(self):
        self._setup_action("back-to-sidebar", None, self._back_to_sidebar)
30
        APP().set_accels_for_action("win.back-to-sidebar", ["<Ctrl>w"])
Nico Alt's avatar
Nico Alt committed
31 32 33 34 35 36 37 38 39 40

    def _setup_open_about_page_action(self):
        self._setup_action("open-about-page", None, self._open_about_page)

    def _setup_open_add_contact_action(self):
        self._setup_action("open-add-contact", None, self._open_add_contact)

    def _setup_open_private_chat_action(self):
        self._setup_action("open-private-chat", GLib.VariantType.new("i"),
                           self._open_private_chat)
41 42 43

    # pylint: disable=unused-argument
    def _back_to_sidebar(self, action, parameter):
44
        if isinstance(self.current_container, MainWindowContainer):
45 46
            self.current_container.show_sidebar()

47 48 49 50
    # pylint: disable=unused-argument
    def _open_about_page(self, action, parameter):
        self.current_container.open_about_page()

51 52 53 54 55 56 57
    # pylint: disable=unused-argument
    def _open_add_contact(self, action, parameter):
        self.show_add_contact_container()

    # pylint: disable=unused-argument
    def _open_private_chat(self, action, contact_id):
        self.current_container.open_private_chat(contact_id.get_int32())