1 // W32StatusIcon.hh --- Window Notifcation Icon
2 //
3 // Copyright (C) 2010, 2011 Rob Caelers <robc@krandor.nl>
4 // All rights reserved.
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef W32STATUSICON_HH
21 #define W32STATUSICON_HH
22 
23 #include "config.h"
24 
25 #include <string>
26 
27 #include <glibmm.h>
28 #include <gdkmm.h>
29 
30 #include <windows.h>
31 #include <commctrl.h>
32 
33 class W32StatusIcon
34 {
35 public:
36   W32StatusIcon();
37   virtual ~W32StatusIcon();
38 
39   void set(const Glib::RefPtr<Gdk::Pixbuf> &pixbuf);
40   void set_tooltip(const Glib::ustring &text);
41   void show_balloon(std::string id, const Glib::ustring &balloon);
42   void set_visible(bool visible = true);
43   bool get_visible() const;
44   bool is_embedded() const;
45 
46   sigc::signal<void> signal_activate();
47   sigc::signal<void, std::string> signal_balloon_activate();
48   sigc::signal<void, guint, guint32> signal_popup_menu();
49 
50 private:
51   std::string current_id;
52   bool visible;
53 
54   NOTIFYICONDATAW nid;
55 
56   static HWND tray_hwnd;
57   static UINT wm_taskbarcreated;
58 
59   void init();
60   void cleanup();
61   void add_tray_icon();
62 
63   static LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
64 
65   sigc::signal<void> 	activate_signal;
66   sigc::signal<void, std::string> balloon_activate_signal;
67   sigc::signal<void, guint, guint32> popup_menu_signal;
68 
69 };
70 
71 #endif // W32STATUSICON_HH
72