Skip to content
Snippets Groups Projects
Verified Commit bef75514 authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Add keyboard shortcuts and simplify about window

parent 6fd38009
No related branches found
No related tags found
No related merge requests found
Pipeline #3546 passed
......@@ -11,6 +11,7 @@ from countdown import config, countdownlabel, digitalclock, timepopover
class ApplicationWindow(Adw.ApplicationWindow):
__gtype_name__ = "ApplicationWindow"
_primary_menu_button = Gtk.Template.Child()
_set_time_button = Gtk.Template.Child()
def __init__(self, app: Gtk.Application) -> None:
......@@ -20,12 +21,20 @@ class ApplicationWindow(Adw.ApplicationWindow):
GObject.type_ensure(digitalclock.DigitalClock.__gtype__)
GObject.type_ensure(timepopover.TimePopover.__gtype__)
set_timer_action = Gio.SimpleAction(name="set-timer")
set_timer_action.connect("activate", self._on_set_timer)
self.add_action(set_timer_action)
self.add_action_entries(
(
("set-timer", self._on_set_timer),
("show-primary-menu", self._on_show_primary_menu),
)
)
if config.DEVELOPMENT:
self.add_css_class("devel")
def _on_set_timer(self, action: Gio.SimpleAction, param: GLib.Variant | None) -> None:
def _on_set_timer(self, action: Gio.SimpleAction, param: None, data: None) -> None:
self._set_time_button.popup()
def _on_show_primary_menu(
self, action: Gio.SimpleAction, param: None, data: None
) -> None:
self._primary_menu_button.popup()
......@@ -2,4 +2,5 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
DEVELOPMENT = @DEVELOPMENT@
\ No newline at end of file
DEVELOPMENT = @DEVELOPMENT@
VERSION = "@VERSION@"
\ No newline at end of file
......@@ -8,7 +8,7 @@ import sys
from gi.repository import Adw, Gio, GLib, Gtk
from countdown import applicationwindow
from countdown import applicationwindow, config
class Application(Adw.Application):
......@@ -30,12 +30,19 @@ class Application(Adw.Application):
self.add_action(about_action)
self.set_accels_for_action("win.set-timer", ("<Ctrl>t", ))
def _on_about(self, action: Gio.SimpleAction, param: GLib.Variant | None) -> None:
builder = Gtk.Builder.new_from_resource("/uk/me/bcowan/Countdown/ui/about.ui")
win = builder.get_object("aboutwindow")
win.props.transient_for = self.props.active_window
win.present()
self.set_accels_for_action("win.show-primary-menu", ("F10", ))
def _on_about(self, action: Gio.SimpleAction, param: None) -> None:
about = Adw.AboutWindow(
application_icon="timer",
application_name="Countdown",
copyright="Copyright 2016–2022 Bruce Cowan",
developer_name="Bruce Cowan",
license_type=Gtk.License.LGPL_3_0,
version=config.VERSION,
)
about.props.transient_for = self.props.active_window
about.present()
def main():
......
......@@ -8,7 +8,6 @@
<gresource prefix="/uk/me/bcowan/Countdown">
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/timer-symbolic.svg</file>
<file preprocess="xml-stripblanks">ui/about.ui</file>
<file preprocess="xml-stripblanks">ui/countdown.ui</file>
<file preprocess="xml-stripblanks">ui/countdown-label.ui</file>
<file preprocess="xml-stripblanks">ui/digital-clock.ui</file>
......
......@@ -16,15 +16,13 @@ blueprints = custom_target('blueprints',
gnome = import('gnome')
subdir('ui')
gnome.compile_resources('countdown',
'countdown.gresource.xml',
gresource_bundle: true,
source_dir: meson.current_build_dir(),
install: true,
install_dir: pkgdatadir,
dependencies: [about_dialogue, blueprints]
dependencies: blueprints
)
install_data('uk.me.bcowan.Countdown.desktop',
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2020-2022 Bruce Cowan <bruce@bcowan.me.uk>
SPDX-License-Identifier: LGPL-3.0-or-later
-->
<interface>
<requires lib="adw" version="1.0"/>
<object class="AdwAboutWindow" id="aboutwindow">
<property name="application-name">Countdown</property>
<property name="copyright" translatable="yes">Copyright 2016–2022 Bruce Cowan</property>
<property name="version">@VERSION@</property>
<property name="comments" translatable="yes">Countdown counts time down to a set time</property>
<property name="developer-name">Bruce Cowan</property>
<property name="application-icon">timer</property>
<property name="license-type">lgpl-3-0</property>
</object>
</interface>
......@@ -21,7 +21,7 @@ template ApplicationWindow : Adw.ApplicationWindow {
}
[end]
MenuButton {
MenuButton _primary_menu_button {
direction: none;
menu-model: app_menu;
tooltip-text: "Main Menu";
......@@ -35,6 +35,7 @@ template ApplicationWindow : Adw.ApplicationWindow {
menu app_menu {
section {
item ("Keyboard Shortcuts", "win.show-help-overlay")
item ("About Countdown", "app.about")
}
}
# SPDX-FileCopyrightText: 2020-2022 Bruce Cowan <bruce@bcowan.me.uk>
#
# SPDX-License-Identifier: LGPL-3.0-or-later
about_dialogue = configure_file(
input: 'about.ui.in',
output: 'about.ui',
configuration: conf
)
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