Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar GTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar GTK
Commits
8a7c30b6
Commit
8a7c30b6
authored
5 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Refactor app and window actions
Related to
#27
.
parent
0b38b56b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
briar-gtk/briar_gtk/action.py
+14
-0
14 additions, 0 deletions
briar-gtk/briar_gtk/action.py
briar-gtk/briar_gtk/actions/application.py
+6
-6
6 additions, 6 deletions
briar-gtk/briar_gtk/actions/application.py
briar-gtk/briar_gtk/actions/window.py
+20
-22
20 additions, 22 deletions
briar-gtk/briar_gtk/actions/window.py
with
40 additions
and
28 deletions
briar-gtk/briar_gtk/action.py
0 → 100644
+
14
−
0
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
)
This diff is collapsed.
Click to expand it.
briar-gtk/briar_gtk/actions/application.py
+
6
−
6
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
):
...
...
This diff is collapsed.
Click to expand it.
briar-gtk/briar_gtk/actions/window.py
+
20
−
22
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment