Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
briar
Briar GTK
Commits
8a7c30b6
Commit
8a7c30b6
authored
Mar 23, 2020
by
Nico Alt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor app and window actions
Related to
#27
.
parent
0b38b56b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
28 deletions
+40
-28
briar-gtk/briar_gtk/action.py
briar-gtk/briar_gtk/action.py
+14
-0
briar-gtk/briar_gtk/actions/application.py
briar-gtk/briar_gtk/actions/application.py
+6
-6
briar-gtk/briar_gtk/actions/window.py
briar-gtk/briar_gtk/actions/window.py
+20
-22
No files found.
briar-gtk/briar_gtk/action.py
0 → 100644
View file @
8a7c30b6
# Copyright (c) 2020 Nico Alt
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
from
gi.repository
import
Gio
class
Actions
:
# pylint: disable=no-member
def
_setup_action
(
self
,
key
,
parameter
,
callback
):
action
=
Gio
.
SimpleAction
.
new
(
key
,
parameter
)
action
.
connect
(
"activate"
,
callback
)
self
.
add_action
(
action
)
briar-gtk/briar_gtk/actions/application.py
View file @
8a7c30b6
...
...
@@ -6,22 +6,22 @@
# Initial version based on GNOME Lollypop
# https://gitlab.gnome.org/World/lollypop/blob/1.2.20/lollypop/application_actions.py
from
gi.repository
import
Gio
from
briar_gtk.action
import
Actions
# pylint: disable=too-few-public-methods
class
ApplicationActions
:
class
ApplicationActions
(
Actions
)
:
def
__init__
(
self
):
self
.
_setup_actions
()
# pylint: disable=no-member
def
_setup_actions
(
self
):
self
.
_setup_quit_action
()
quit_action
=
Gio
.
SimpleAction
.
new
(
"quit"
,
None
)
quit_action
.
connect
(
"activate"
,
self
.
_quit
)
# pylint: disable=no-member
def
_setup_quit_action
(
self
):
self
.
_setup_action
(
"quit"
,
None
,
self
.
_quit
)
self
.
set_accels_for_action
(
"app.quit"
,
[
"<Ctrl>q"
])
self
.
add_action
(
quit_action
)
# pylint: disable=unused-argument
def
_quit
(
self
,
action
,
parameter
):
...
...
briar-gtk/briar_gtk/actions/window.py
View file @
8a7c30b6
...
...
@@ -6,40 +6,38 @@
# Initial version based on GNOME Lollypop
# https://gitlab.gnome.org/World/lollypop/blob/1.2.20/lollypop/application_actions.py
from
gi.repository
import
Gio
,
GLib
from
gi.repository
import
GLib
from
briar_gtk.action
import
Actions
from
briar_gtk.containers.main_window
import
MainWindowContainer
from
briar_gtk.define
import
APP
# pylint: disable=too-few-public-methods
class
WindowActions
:
class
WindowActions
(
Actions
)
:
def
__init__
(
self
):
self
.
_setup_actions
()
# pylint: disable=no-member
def
_setup_actions
(
self
):
back_to_sidebar_action
=
Gio
.
SimpleAction
.
new
(
"back-to-sidebar"
,
None
)
back_to_sidebar_action
.
connect
(
"activate"
,
self
.
_back_to_sidebar
)
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
)
APP
().
set_accels_for_action
(
"win.back-to-sidebar"
,
[
"<Ctrl>w"
])
self
.
add_action
(
back_to_sidebar_action
)
open_add_contact_action
=
Gio
.
SimpleAction
.
new
(
"open-add-contact"
,
None
)
open_add_contact_action
.
connect
(
"activate"
,
self
.
_open_add_contact
)
self
.
add_action
(
open_add_contact_action
)
open_about_page_action
=
Gio
.
SimpleAction
.
new
(
"open-about-page"
,
None
)
open_about_page_action
.
connect
(
"activate"
,
self
.
_open_about_page
)
self
.
add_action
(
open_about_page_action
)
open_private_chat_action
=
Gio
.
SimpleAction
.
new
(
"open-private-chat"
,
GLib
.
VariantType
.
new
(
"i"
))
open_private_chat_action
.
connect
(
"activate"
,
self
.
_open_private_chat
)
self
.
add_action
(
open_private_chat_action
)
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
)
# pylint: disable=unused-argument
def
_back_to_sidebar
(
self
,
action
,
parameter
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment