diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-08-17 13:22:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-17 13:22:52 -0500 |
commit | ec53136863f20b80caf165d2f15e8a77d614536e (patch) | |
tree | aea6b11eaa16dfcd2b5cc613e6b9678d3fd09253 /python/servo/win32_toast.py | |
parent | b61c45639a264943f8dec61c66b46d40f9d274a1 (diff) | |
parent | dd377164595a91cb5fb6eab5e354cf51814ff7d1 (diff) | |
download | servo-ec53136863f20b80caf165d2f15e8a77d614536e.tar.gz servo-ec53136863f20b80caf165d2f15e8a77d614536e.zip |
Auto merge of #11756 - vvuk:servo-msvc, r=larsbergstrom
MSVC support for Servo, and CMake builds for native code
This is the base PR for MSVC builds of servo and dependent crates. It's got replacements in the Cargo.toml to pull in the right versions, to make sure that crates were properly converted to CMake for all other platforms, not just Windows. (Servo builds with MSVC 2015 with this PR; also with 2013, though a manual change in rust-mozjs to select a different set of bindings is needed.)
This PR isn't quite ready yet, but I want bors-servo to do builds.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11756)
<!-- Reviewable:end -->
Diffstat (limited to 'python/servo/win32_toast.py')
-rw-r--r-- | python/servo/win32_toast.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/python/servo/win32_toast.py b/python/servo/win32_toast.py new file mode 100644 index 00000000000..22a7ccd917f --- /dev/null +++ b/python/servo/win32_toast.py @@ -0,0 +1,45 @@ +# Copyright 2013 The Servo Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +from win32api import GetModuleHandle +from win32gui import WNDCLASS, RegisterClass, CreateWindow, UpdateWindow +from win32gui import DestroyWindow, LoadIcon, NIF_ICON, NIF_MESSAGE, NIF_TIP +from win32gui import Shell_NotifyIcon, NIM_ADD, NIM_MODIFY, NIF_INFO, NIIF_INFO +import win32con + + +class WindowsToast: + def __init__(self): + # Register window class; it's okay to do this multiple times + wc = WNDCLASS() + wc.lpszClassName = 'ServoTaskbarNotification' + wc.lpfnWndProc = {win32con.WM_DESTROY: self.OnDestroy, } + self.classAtom = RegisterClass(wc) + self.hinst = wc.hInstance = GetModuleHandle(None) + + def OnDestroy(self, hwnd, msg, wparam, lparam): + # We don't have to Shell_NotifyIcon to delete it, since + # we destroyed + pass + + def balloon_tip(self, title, msg): + style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU + hwnd = CreateWindow(self.classAtom, "Taskbar", style, 0, 0, + win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, + 0, 0, self.hinst, None) + UpdateWindow(hwnd) + + hicon = LoadIcon(0, win32con.IDI_APPLICATION) + + nid = (hwnd, 0, NIF_ICON | NIF_MESSAGE | NIF_TIP, win32con.WM_USER + 20, hicon, 'Tooltip') + Shell_NotifyIcon(NIM_ADD, nid) + nid = (hwnd, 0, NIF_INFO, win32con.WM_USER + 20, hicon, 'Balloon Tooltip', msg, 200, title, NIIF_INFO) + Shell_NotifyIcon(NIM_MODIFY, nid) + + DestroyWindow(hwnd) |