]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/sockgtk.cpp
rename wxDECLARE_LOCAL_EVENT to just wxDECLARE_EVENT
[wxWidgets.git] / src / gtk1 / 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// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#if wxUSE_SOCKETS
15
16#include <stdlib.h>
17#include <stdio.h>
18
19#include <gdk/gdk.h>
20#include <glib.h>
21
22#include "wx/private/socket.h"
23#include "wx/apptrait.h"
24
25extern "C" {
26static
27void wxSocket_GDK_Input(gpointer data,
28 gint WXUNUSED(source),
29 GdkInputCondition condition)
30{
31 wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data);
32
33 if ( condition & GDK_INPUT_READ )
34 handler->OnReadWaiting();
35 if ( condition & GDK_INPUT_WRITE )
36 handler->OnWriteWaiting();
37}
38}
39
40class GTKSocketManager : public wxSocketInputBasedManager
41{
42public:
43 virtual int AddInput(wxFDIOHandler *handler, int fd, SocketDir d)
44 {
45 return gdk_input_add
46 (
47 fd,
48 d == FD_OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
49 wxSocket_GDK_Input,
50 handler
51 );
52 }
53
54 virtual void RemoveInput(int fd)
55 {
56 gdk_input_remove(fd);
57 }
58};
59
60wxSocketManager *wxGUIAppTraits::GetSocketManager()
61{
62 static GTKSocketManager s_manager;
63 return &s_manager;
64}
65
66#endif // wxUSE_SOCKETS