def do_notify(*args): #if GLib is loaded, use it to ensure we use the UI thread: GLib = sys.modules.get("gi.repository.GLib", None) if GLib: GLib.idle_add(notify, *args) else: notify(*args)
def command_callback(hwnd, cid): if cid == 1024: from xpra.platform.win32.win32_balloon import notify notify(hwnd, "hello", "world") elif cid == 1025: print("Goodbye") win32gui.DestroyWindow(hwnd) else: print("OnCommand for ID=%s" % cid)
def show_notify(self, dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, expire_timeout): if tray is None: log.error("no tray - cannot show notification!") return if not hasattr(tray, "getHWND"): log.error("tray class %s does not support getHWND!", type(tray)) return hwnd = tray.getHWND() notify(hwnd, summary, body, expire_timeout)
def close_notify(self, nid): try: self.gtk_notifications.remove(nid) except KeyError: try: hwnd, app_id = self.notification_handles.pop(nid) except KeyError: return log("close_notify(%i) hwnd=%i, app_id=%i", nid, hwnd, app_id) notify(hwnd, app_id, "", "", 0, None) else: self.get_gtk_notifier().close_notify(nid)
def show_notify(self, dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, actions, hints, expire_timeout, icon): getHWND = getattr(tray, "getHWND", None) if GTK_NOTIFIER or tray is None or getHWND is None or actions: log("show_notify(..) using gtk fallback, GTK_NOTIFIER=%s, tray=%s, getHWND=%s, actions=%s", GTK_NOTIFIER, tray, getHWND, actions) gtk_notifier = self.get_gtk_notifier() if gtk_notifier: gtk_notifier.show_notify(dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, actions, hints, expire_timeout, icon) self.gtk_notifications.add(nid) return if tray is None: log.warn("Warning: no system tray - cannot show notification!") return hwnd = getHWND() app_id = tray.app_id log("show_notify%s hwnd=%#x, app_id=%i", (dbus_id, tray, nid, app_name, replaces_nid, app_icon, summary, body, actions, hints, expire_timeout, icon), hwnd, app_id) #FIXME: remove handles when notification is closed self.notification_handles[nid] = (hwnd, app_id) notify(hwnd, app_id, summary, body, expire_timeout, icon)
def command_callback(hwnd, cid): if cid == 1024: from xpra.platform.win32.win32_balloon import notify try: from PIL import Image #@UnresolvedImport from io import BytesIO img = Image.open("icons\\printer.png") buf = BytesIO() img.save(buf, "PNG") data = buf.getvalue() buf.close() icon = (b"png", img.size[0], img.size[1], data) except Exception as e: print("could not find icon: %s" % (e, )) icon = None else: pass notify(hwnd, 0, "hello", "world", timeout=1000, icon=icon) elif cid == 1025: print("Goodbye") DestroyWindow(hwnd) else: print("OnCommand for ID=%s" % cid)