]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/sockgtk.cpp
Use wxString's empty() when checking if the string is (non-)empty throughout wx.
[wxWidgets.git] / src / gtk1 / 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
180f9714
DE
17#include <gdk/gdk.h>
18#include <glib.h>
19
2804f77d 20#include "wx/apptrait.h"
6bcc1145 21#include "wx/private/fdiomanager.h"
180f9714 22
865bb325
VZ
23extern "C" {
24static
51fe4b60 25void wxSocket_GDK_Input(gpointer data,
89954433 26 gint WXUNUSED(source),
180f9714
DE
27 GdkInputCondition condition)
28{
6bcc1145 29 wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data);
180f9714 30
a9d859df 31 if ( condition & GDK_INPUT_READ )
ee0995b0 32 {
a9d859df 33 handler->OnReadWaiting();
ee0995b0
VZ
34
35 // we could have lost connection while reading in which case we
36 // shouldn't call OnWriteWaiting() as the socket is now closed and it
37 // would assert
251e98cb 38 if ( !handler->IsOk() )
ee0995b0
VZ
39 return;
40 }
41
a9d859df
VZ
42 if ( condition & GDK_INPUT_WRITE )
43 handler->OnWriteWaiting();
180f9714 44}
865bb325 45}
180f9714 46
6bcc1145 47class GTKFDIOManager : public wxFDIOManager
180f9714 48{
2804f77d 49public:
6bcc1145 50 virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d)
2804f77d
VZ
51 {
52 return gdk_input_add
53 (
a9d859df 54 fd,
6bcc1145 55 d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
51fe4b60 56 wxSocket_GDK_Input,
a9d859df 57 handler
2804f77d
VZ
58 );
59 }
60
6bcc1145
VZ
61 virtual void
62 RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d))
2804f77d
VZ
63 {
64 gdk_input_remove(fd);
65 }
66};
67
6bcc1145 68wxFDIOManager *wxGUIAppTraits::GetFDIOManager()
180f9714 69{
6bcc1145 70 static GTKFDIOManager s_manager;
2804f77d 71 return &s_manager;
180f9714
DE
72}
73
2804f77d 74#endif // wxUSE_SOCKETS