11#!/usr/bin/env python3
22# -*- coding: utf-8 -*-
33# pylint: disable=wrong-import-position,import-error,superfluous-parens
4- """ A menu listing domains """
4+ """A menu listing domains"""
55
66# Must be imported before creating threads
77from .gtk3_xwayland_menu_dismisser import (
@@ -765,6 +765,9 @@ def register_events(self):
765765 self .dispatcher .add_handler ("domain-pre-shutdown" , self .emit_notification )
766766 self .dispatcher .add_handler ("domain-shutdown" , self .emit_notification )
767767 self .dispatcher .add_handler ("domain-shutdown-failed" , self .emit_notification )
768+ self .dispatcher .add_handler (
769+ "domain-preload-dispvm-used" , self .emit_notification
770+ )
768771
769772 self .dispatcher .add_handler ("domain-start" , self .check_pause_notify )
770773 self .dispatcher .add_handler ("domain-paused" , self .check_pause_notify )
@@ -816,7 +819,11 @@ def show_menu(self, _unused, event):
816819 self .tray_menu .popup_at_pointer (event ) # None means current event
817820
818821 def emit_notification (self , vm , event , ** kwargs ):
819- notification = Gio .Notification .new (_ ("Qube Status: {}" ).format (vm .name ))
822+ if event == "domain-preload-dispvm-used" :
823+ vm_name = kwargs ["dispvm" ]
824+ else :
825+ vm_name = vm .name
826+ notification = Gio .Notification .new (_ ("Qube Status: {}" ).format (vm_name ))
820827 notification .set_priority (Gio .NotificationPriority .NORMAL )
821828
822829 if event == "domain-start-failed" :
@@ -829,6 +836,12 @@ def emit_notification(self, vm, event, **kwargs):
829836 notification .set_body (_ ("Qube {} is starting." ).format (vm .name ))
830837 elif event == "domain-start" :
831838 notification .set_body (_ ("Qube {} has started." ).format (vm .name ))
839+ elif event == "domain-preload-dispvm-used" :
840+ notification .set_body (
841+ _ ("Qube {} was preloaded and is now being used." ).format (
842+ kwargs ["dispvm" ]
843+ )
844+ )
832845 elif event == "domain-pre-shutdown" :
833846 notification .set_body (
834847 _ ("Qube {} is attempting to shut down." ).format (vm .name )
@@ -1106,6 +1119,9 @@ def _disconnect_signals(self, _event):
11061119 self .dispatcher .remove_handler ("domain-pre-shutdown" , self .emit_notification )
11071120 self .dispatcher .remove_handler ("domain-shutdown" , self .emit_notification )
11081121 self .dispatcher .remove_handler ("domain-shutdown-failed" , self .emit_notification )
1122+ self .dispatcher .remove_handler (
1123+ "domain-preload-dispvm-used" , self .emit_notification
1124+ )
11091125
11101126 self .dispatcher .remove_handler ("domain-start" , self .check_pause_notify )
11111127 self .dispatcher .remove_handler ("domain-paused" , self .check_pause_notify )
0 commit comments