-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
window: add basic voice recognition popup
- Loading branch information
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<interface> | ||
<requires lib="adw" version="1.0"/> | ||
<requires lib="gtk" version="4.0"/> | ||
<template class="AssistantPopup" parent="AdwWindow"> | ||
<property name="title" translatable="yes">Speak to the Assistant</property> | ||
<property name="decorated">false</property> | ||
|
||
<style> | ||
<class name="assistant-popup"/> | ||
</style> | ||
|
||
<child> | ||
<object class="AdwFlap" id="flap"> | ||
<property name="vexpand">true</property> | ||
<property name="orientation">vertical</property> | ||
<property name="fold-policy">always</property> | ||
<property name="flap-position">end</property> | ||
<property name="reveal-flap">false</property> | ||
|
||
<child> | ||
<object class="GtkBox"> | ||
<property name="hexpand">true</property> | ||
<property name="vexpand">true</property> | ||
</object> | ||
</child> | ||
|
||
<child type="flap"> | ||
<object class="SpeechView"/> | ||
</child> | ||
</object> | ||
</child> | ||
</template> | ||
</interface> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# coding: utf-8 | ||
""" | ||
Code for the assistant popup. | ||
""" | ||
from gi.repository import Adw, Gtk | ||
from ..daemon import get_daemon | ||
|
||
@Gtk.Template(resource_path='/org/dithernet/lapel/ui/popup.ui') | ||
class AssistantPopup(Adw.Window): | ||
"""Popup window that appears when Mycroft hears its wakeword.""" | ||
__gtype_name__ = 'AssistantPopup' | ||
|
||
flap = Gtk.Template.Child() | ||
|
||
def __init__(self, app): | ||
super().__init__() | ||
self.app = app | ||
self.flap.connect('notify::reveal-progress', self.handle_reveal_progress) | ||
self.daemon = get_daemon() | ||
self.daemon.on('mycroft.mic.listen', self._show) | ||
self.daemon.on('recognizer_loop:record_end', self._hide) | ||
|
||
def _show(self, *args): | ||
active_window = self.app.get_active_window() | ||
if active_window and active_window.get_visible(): | ||
return | ||
|
||
self.set_visible(True) | ||
self.present() | ||
self.fullscreen() | ||
self.flap.set_reveal_flap(True) | ||
|
||
def _hide(self, *args): | ||
self.flap.set_reveal_flap(False) | ||
|
||
def handle_reveal_progress(self, flap, *args): | ||
progress = flap.get_reveal_progress() | ||
if progress == 0: | ||
self.set_visible(False) | ||
self.daemon.stop_record() | ||
|
||
def close(self, *args): | ||
# stub | ||
pass |