close compose window on escape key

This commit is contained in:
Morgan McMillian 2020-12-15 23:00:45 -08:00
parent 3aaa778194
commit ab947c2fce
2 changed files with 7 additions and 0 deletions

View file

@ -70,6 +70,7 @@ class Application(Gtk.Application):
action = Gio.SimpleAction.new('preferences', None) action = Gio.SimpleAction.new('preferences', None)
action.connect('activate', self.on_preferences) action.connect('activate', self.on_preferences)
self.add_action(action) self.add_action(action)
# TODO: this shortcut might need adjustment
self.set_accels_for_action('app.preferences',["<Ctrl>,"]) self.set_accels_for_action('app.preferences',["<Ctrl>,"])
action = Gio.SimpleAction.new('about', None) action = Gio.SimpleAction.new('about', None)

View file

@ -73,6 +73,12 @@ class ComposeWindow(Handy.Window):
self.show_all() self.show_all()
self.connect('key-release-event', self.on_key_release)
def on_key_release(self, widget, ev, data=None):
if ev.keyval == Gdk.KEY_Escape:
self.close()
def validate(self, widget): def validate(self, widget):
self.counter = self.max_length - self.buffer.get_char_count() self.counter = self.max_length - self.buffer.get_char_count()
self.counter_label.set_text(str(self.counter)) self.counter_label.set_text(str(self.counter))