Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Gabriele Musco
WhatIP
Commits
7ebb7472
Verified
Commit
7ebb7472
authored
Nov 20, 2020
by
Gabriele Musco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reworked keyboard shortcuts
parent
7a8c92f8
Pipeline
#231981
failed with stage
in 2 minutes and 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
38 deletions
+42
-38
whatip/__main__.py
whatip/__main__.py
+33
-31
whatip/app_window.py
whatip/app_window.py
+9
-7
No files found.
whatip/__main__.py
View file @
7ebb7472
...
...
@@ -39,37 +39,6 @@ class GApplication(Gtk.Application):
def
do_startup
(
self
):
Gtk
.
Application
.
do_startup
(
self
)
Handy
.
init
()
actions
=
[
{
'name'
:
'preferences'
,
'func'
:
self
.
show_settings_window
,
'accel'
:
'<Primary>comma'
},
{
'name'
:
'shortcuts'
,
'func'
:
self
.
show_shortcuts_window
,
'accel'
:
'<Primary>question'
},
{
'name'
:
'about'
,
'func'
:
self
.
show_about_dialog
},
{
'name'
:
'quit'
,
'func'
:
self
.
on_destroy_window
,
'accel'
:
'<Primary>q'
}
]
for
a
in
actions
:
c_action
=
Gio
.
SimpleAction
.
new
(
a
[
'name'
],
None
)
c_action
.
connect
(
'activate'
,
a
[
'func'
])
self
.
add_action
(
c_action
)
if
'accel'
in
a
.
keys
():
self
.
set_accels_for_action
(
f
'app.
{
a
[
"name"
]
}
'
,
[
a
[
'accel'
]]
)
def
show_about_dialog
(
self
,
*
args
):
about_builder
=
Gtk
.
Builder
.
new_from_resource
(
...
...
@@ -116,6 +85,39 @@ class GApplication(Gtk.Application):
self
.
add_window
(
self
.
window
)
self
.
window
.
present
()
self
.
window
.
show
()
actions
=
[
{
'name'
:
'preferences'
,
'func'
:
self
.
show_settings_window
,
'accel'
:
'<Primary>comma'
},
{
'name'
:
'shortcuts'
,
'func'
:
self
.
show_shortcuts_window
,
'accel'
:
'<Primary>question'
},
{
'name'
:
'about'
,
'func'
:
self
.
show_about_dialog
},
{
'name'
:
'quit'
,
'func'
:
self
.
on_destroy_window
,
'accel'
:
'<Primary>q'
}
]
for
a
in
actions
:
c_action
=
Gio
.
SimpleAction
.
new
(
a
[
'name'
],
None
)
c_action
.
connect
(
'activate'
,
a
[
'func'
])
self
.
add_action
(
c_action
)
if
'accel'
in
a
.
keys
():
self
.
set_accels_for_action
(
f
'app.
{
a
[
"name"
]
}
'
,
[
a
[
'accel'
]]
)
if
self
.
confman
.
conf
[
'enable_third_parties'
]
==
'unset'
:
disclaimer_dialog
=
Gtk
.
MessageDialog
(
message_type
=
Gtk
.
MessageType
.
QUESTION
,
...
...
whatip/app_window.py
View file @
7ebb7472
...
...
@@ -40,23 +40,25 @@ class AppWindow(Handy.ApplicationWindow):
self
.
confman
.
conf
[
'windowsize'
][
'height'
]
)
def
toggle_menu
():
popover
=
self
.
headerbar
.
menu_btn
.
get_popover
()
popover
.
popup
()
# TODO: close popover if open
shortcuts_l
=
[
{
'combo'
:
'F10'
,
'cb'
:
lambda
*
args
:
toggle_menu
()
'cb'
:
self
.
toggle_menu
}
]
self
.
shortcut_controller
=
Gtk
.
ShortcutController
()
self
.
shortcut_controller
.
set_scope
(
Gtk
.
ShortcutScope
.
MANAGED
)
self
.
shortcut_controller
.
set_scope
(
Gtk
.
ShortcutScope
.
GLOBAL
)
for
s
in
shortcuts_l
:
self
.
add_accelerator
(
s
[
'combo'
],
s
[
'cb'
])
self
.
add_controller
(
self
.
shortcut_controller
)
def
toggle_menu
(
self
,
*
args
):
popover
=
self
.
headerbar
.
menu_btn
.
get_popover
()
if
popover
.
get_visible
():
popover
.
popdown
()
else
:
popover
.
popup
()
def
on_main_stack_change
(
self
,
*
args
):
self
.
headerbar
.
nobox
.
set_text
(
self
.
main_stack
.
get_visible_child_name
()
...
...
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