]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/taskbar.cpp
remove also wxT(); it's confusing, too; do load wxstd.mo catalog after calling wxLoca...
[wxWidgets.git] / src / gtk / taskbar.cpp
CommitLineData
33d4eef0 1/////////////////////////////////////////////////////////////////////////
e4db172a 2// File: src/gtk/taskbar.cpp
33d4eef0
VS
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
33d4eef0
VS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
4f167b46
VZ
15#if wxUSE_TASKBARICON
16
e1bf3ad3 17#include "wx/gtk/taskbarpriv.h"
e4db172a
WS
18
19#ifndef WX_PRECOMP
20 #include "wx/log.h"
76b49cf4 21 #include "wx/frame.h"
3b3dc801 22 #include "wx/menu.h"
e4db172a
WS
23#endif
24
290cd301 25#include <gtk/gtk.h>
5dc22463 26#include <gdk/gdkx.h>
5dc22463 27
33d4eef0
VS
28#include "eggtrayicon.h"
29
30wxTaskBarIconAreaBase::wxTaskBarIconAreaBase()
31{
32 if (IsProtocolSupported())
33 {
34 m_widget = GTK_WIDGET(egg_tray_icon_new("systray icon"));
9ff9d30c 35 g_object_ref(m_widget);
33d4eef0 36 gtk_window_set_resizable(GTK_WINDOW(m_widget), false);
3d257b8d 37
33d4eef0
VS
38 wxLogTrace(_T("systray"), _T("using freedesktop.org systray spec"));
39 }
3d257b8d 40
33d4eef0
VS
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*/);
3d257b8d 47
53e3cd04
PC
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
0bd3b8ec 58 m_invokingWindow = NULL;
33d4eef0
VS
59}
60
61bool wxTaskBarIconAreaBase::IsProtocolSupported()
62{
61f6ba07
VS
63 Display *display = GDK_DISPLAY();
64 Screen *screen = DefaultScreenOfDisplay(display);
3d257b8d 65
61f6ba07
VS
66 char name[32];
67 g_snprintf(name, sizeof(name), "_NET_SYSTEM_TRAY_S%d",
68 XScreenNumberOfScreen(screen));
69 Atom atom = XInternAtom(display, name, False);
3d257b8d 70
61f6ba07 71 Window manager = XGetSelectionOwner(display, atom);
3d257b8d 72
61f6ba07 73 return (manager != None);
33d4eef0
VS
74}
75
0bd3b8ec
RR
76//-----------------------------------------------------------------------------
77// Pop-up menu stuff
78//-----------------------------------------------------------------------------
79
065f010f 80#if wxUSE_MENUS_NATIVE
edd6813c 81void wxTaskBarIconAreaBase::DoPopupMenuUpdateUI(wxMenu* menu)
0bd3b8ec 82{
edd6813c 83 menu->UpdateUI(m_invokingWindow);
0bd3b8ec 84}
290cd301 85#endif // wxUSE_MENUS_NATIVE
4f167b46 86#endif // wxUSE_TASKBARICON