]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/taskbar.cpp
osx new layout
[wxWidgets.git] / src / gtk / taskbar.cpp
1 /////////////////////////////////////////////////////////////////////////
2 // File: src/gtk/taskbar.cpp
3 // Purpose: wxTaskBarIcon (src/unix/taskbarx11.cpp) helper for GTK2
4 // Author: Vaclav Slavik
5 // Modified by:
6 // Created: 2004/05/29
7 // RCS-ID: $Id$
8 // Copyright: (c) Vaclav Slavik, 2004
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #if wxUSE_TASKBARICON
16
17 #include "wx/gtk/taskbarpriv.h"
18
19 #ifndef WX_PRECOMP
20 #include "wx/log.h"
21 #include "wx/frame.h"
22 #include "wx/menu.h"
23 #endif
24
25 #include <gtk/gtk.h>
26 #include <gdk/gdkx.h>
27
28 #include "eggtrayicon.h"
29
30 wxTaskBarIconAreaBase::wxTaskBarIconAreaBase()
31 {
32 if (IsProtocolSupported())
33 {
34 m_widget = GTK_WIDGET(egg_tray_icon_new("systray icon"));
35 g_object_ref(m_widget);
36 gtk_window_set_resizable(GTK_WINDOW(m_widget), false);
37
38 wxLogTrace(_T("systray"), _T("using freedesktop.org systray spec"));
39 }
40
41 wxTopLevelWindow::Create(
42 NULL, wxID_ANY, _T("systray icon"),
43 wxDefaultPosition, wxDefaultSize,
44 wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR | wxSIMPLE_BORDER |
45 wxFRAME_SHAPED,
46 wxEmptyString /*eggtray doesn't like setting wmclass*/);
47
48 // WM frame extents are not useful for wxTaskBarIcon
49 m_deferShow = false;
50 gulong handler_id = g_signal_handler_find(
51 m_widget,
52 GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
53 g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET),
54 0, NULL, NULL, this);
55 if (handler_id != 0)
56 g_signal_handler_disconnect(m_widget, handler_id);
57
58 m_invokingWindow = NULL;
59 }
60
61 bool wxTaskBarIconAreaBase::IsProtocolSupported()
62 {
63 static int s_supported = -1;
64 if (s_supported == -1)
65 {
66 Display *display = GDK_DISPLAY();
67 Screen *screen = DefaultScreenOfDisplay(display);
68
69 char name[32];
70 g_snprintf(name, sizeof(name), "_NET_SYSTEM_TRAY_S%d",
71 XScreenNumberOfScreen(screen));
72 Atom atom = XInternAtom(display, name, False);
73
74 Window manager = XGetSelectionOwner(display, atom);
75
76 s_supported = (manager != None);
77 }
78
79 return (bool)s_supported;
80 }
81
82 //-----------------------------------------------------------------------------
83 // Pop-up menu stuff
84 //-----------------------------------------------------------------------------
85
86 #if wxUSE_MENUS_NATIVE
87 void wxTaskBarIconAreaBase::DoPopupMenuUpdateUI(wxMenu* menu)
88 {
89 menu->UpdateUI(m_invokingWindow);
90 }
91 #endif // wxUSE_MENUS_NATIVE
92 #endif // wxUSE_TASKBARICON