[gtk-vnc] gvncviewer.py: add window close handler to terminate the program



commit 1cde6a2f6bb9e3357d1acd517b442e8a15af630c
Author: Dr. Matthias St. Pierre <matthias st pierre ncp-e com>
Date:   Thu Oct 22 22:15:34 2020 +0200

    gvncviewer.py: add window close handler to terminate the program
    
    This fixes the issue that the program hangs when the window is
    closed using the 'X' button.

 examples/gvncviewer.py | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/examples/gvncviewer.py b/examples/gvncviewer.py
index e202b14..5b9be76 100755
--- a/examples/gvncviewer.py
+++ b/examples/gvncviewer.py
@@ -72,6 +72,10 @@ def vnc_screenshot(src, ev, vnc):
 
     return False
 
+def vnc_close(src, window, data = None):
+    print("Window closed by user")
+    Gtk.main_quit()
+
 def vnc_grab(src, window):
     set_title(src, window, True)
 
@@ -245,5 +249,6 @@ vnc.connect("vnc-disconnected", vnc_disconnected)
 vnc.connect("vnc-auth-credential", vnc_auth_cred)
 
 window.connect("key-press-event", vnc_screenshot, vnc)
+window.connect("destroy", vnc_close, window)
 
 Gtk.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]