summaryrefslogtreecommitdiff
path: root/python_client.py
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2014-01-27 05:01:34 +0100
committerTreeki <treeki@gmail.com>2014-01-27 05:01:34 +0100
commit1417c14821024bde33552573665973165613fa2a (patch)
treed4ccf63d1f2812813a6fe9119be5230470f5fc9b /python_client.py
parent6248214f5aa6c6f73c248f4239c66fef01cbbbfa (diff)
downloadbounce4-1417c14821024bde33552573665973165613fa2a.tar.gz
bounce4-1417c14821024bde33552573665973165613fa2a.zip
add window closing for queries
Diffstat (limited to '')
-rw-r--r--python_client.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/python_client.py b/python_client.py
index 5a82031..22c31da 100644
--- a/python_client.py
+++ b/python_client.py
@@ -358,6 +358,20 @@ class MainWindow(QtWidgets.QMainWindow):
self.tabs.addTab(tab, wtitle)
self.tabLookup[wid] = tab
tab.pushMessage('\n'.join(msgs))
+ elif ptype == 0x101:
+ # WINDOW CLOSE
+ wndCount = u32.unpack_from(pdata, 0)[0]
+ pos = 4
+
+ for i in range(wndCount):
+ wid = u32.unpack_from(pdata, pos)[0]
+ pos += 4
+
+ if wid in self.tabLookup:
+ tab = self.tabLookup[wid]
+ self.tabs.removeTab(self.tabs.indexOf(tab))
+ del self.tabLookup[wid]
+
elif ptype == 0x102:
# WINDOW MESSAGES
wndID, msglen = struct.unpack_from('<II', pdata, 0)
@@ -427,8 +441,11 @@ class MainWindow(QtWidgets.QMainWindow):
def handleWindowInput(self, text):
wid = self.sender().winID
with packetLock:
- data = str(text).encode('utf-8')
- writePacket(0x102, struct.pack('<II', wid, len(data)) + data)
+ if text == '/close':
+ writePacket(0x101, u32.pack(wid))
+ else:
+ data = str(text).encode('utf-8')
+ writePacket(0x102, struct.pack('<II', wid, len(data)) + data)
app = QtWidgets.QApplication(sys.argv)