]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/sockgtk.cpp
Integrate with GNOME's Recent Documents menu.
[wxWidgets.git] / src / gtk / sockgtk.cpp
... / ...
CommitLineData
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
8// (c) 2009 Vadim Zeitlin
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#if wxUSE_SOCKETS
16
17#include "wx/apptrait.h"
18#include "wx/private/fdiomanager.h"
19
20#include <gdk/gdk.h>
21
22extern "C" {
23static
24void wxSocket_GDK_Input(gpointer data,
25 gint WXUNUSED(source),
26 GdkInputCondition condition)
27{
28 wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data);
29
30 if ( condition & GDK_INPUT_READ )
31 {
32 handler->OnReadWaiting();
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
37 if ( !handler->IsOk() )
38 return;
39 }
40
41 if ( condition & GDK_INPUT_WRITE )
42 handler->OnWriteWaiting();
43}
44}
45
46class GTKFDIOManager : public wxFDIOManager
47{
48public:
49 virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d)
50 {
51 return gdk_input_add
52 (
53 fd,
54 d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
55 wxSocket_GDK_Input,
56 handler
57 );
58 }
59
60 virtual void
61 RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d))
62 {
63 gdk_input_remove(fd);
64 }
65};
66
67wxFDIOManager *wxGUIAppTraits::GetFDIOManager()
68{
69 static GTKFDIOManager s_manager;
70 return &s_manager;
71}
72
73#endif // wxUSE_SOCKETS