]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/sockgtk.cpp
Store menus titles in menus themselves in wxOSX.
[wxWidgets.git] / src / gtk / sockgtk.cpp
CommitLineData
2804f77d
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: gtk/gsockgtk.cpp
3// Purpose: implementation of wxGTK-specific socket event handling
4// Author: Guilhem Lavaux, Vadim Zeitlin
5// Created: 1999
6// RCS-ID: $Id$
7// Copyright: (c) 1999, 2007 wxWidgets dev team
6bcc1145 8// (c) 2009 Vadim Zeitlin
2804f77d
VZ
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
9b5f1895
WS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
180f9714
DE
14
15#if wxUSE_SOCKETS
16
2804f77d 17#include "wx/apptrait.h"
6bcc1145 18#include "wx/private/fdiomanager.h"
180f9714 19
65391c8f
PC
20#include <gdk/gdk.h>
21
865bb325
VZ
22extern "C" {
23static
51fe4b60 24void wxSocket_GDK_Input(gpointer data,
e4161a2a 25 gint WXUNUSED(source),
180f9714
DE
26 GdkInputCondition condition)
27{
6bcc1145 28 wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data);
180f9714 29
51fe4b60 30 if ( condition & GDK_INPUT_READ )
ee0995b0 31 {
a9d859df 32 handler->OnReadWaiting();
ee0995b0
VZ
33
34 // we could have lost connection while reading in which case we
35 // shouldn't call OnWriteWaiting() as the socket is now closed and it
36 // would assert
251e98cb 37 if ( !handler->IsOk() )
ee0995b0
VZ
38 return;
39 }
40
51fe4b60 41 if ( condition & GDK_INPUT_WRITE )
a9d859df 42 handler->OnWriteWaiting();
180f9714 43}
865bb325 44}
180f9714 45
6bcc1145 46class GTKFDIOManager : public wxFDIOManager
180f9714 47{
2804f77d 48public:
6bcc1145 49 virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d)
2804f77d
VZ
50 {
51 return gdk_input_add
52 (
a9d859df 53 fd,
6bcc1145 54 d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
51fe4b60 55 wxSocket_GDK_Input,
a9d859df 56 handler
2804f77d
VZ
57 );
58 }
59
6bcc1145
VZ
60 virtual void
61 RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d))
2804f77d
VZ
62 {
63 gdk_input_remove(fd);
64 }
65};
66
6bcc1145 67wxFDIOManager *wxGUIAppTraits::GetFDIOManager()
180f9714 68{
6bcc1145 69 static GTKFDIOManager s_manager;
2804f77d 70 return &s_manager;
180f9714
DE
71}
72
a59bbda1 73#endif // wxUSE_SOCKETS