]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/gsockgtk.cpp
Fixed non-precompiled headers compilation
[wxWidgets.git] / src / gtk1 / gsockgtk.cpp
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/gsocket.h"
23 #include "wx/apptrait.h"
24
25 extern "C" {
26 static
27 void _GSocket_GDK_Input(gpointer data,
28 gint WXUNUSED(source),
29 GdkInputCondition condition)
30 {
31 GSocket *socket = (GSocket *)data;
32
33 if (condition & GDK_INPUT_READ)
34 socket->Detected_Read();
35 if (condition & GDK_INPUT_WRITE)
36 socket->Detected_Write();
37 }
38 }
39
40 class GTKSocketManager : public GSocketInputBasedManager
41 {
42 public:
43 virtual int AddInput(GSocket *socket, SocketDir d)
44 {
45 return gdk_input_add
46 (
47 socket->m_fd,
48 d == FD_OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
49 _GSocket_GDK_Input,
50 socket
51 );
52 }
53
54 virtual void RemoveInput(int fd)
55 {
56 gdk_input_remove(fd);
57 }
58 };
59
60 GSocketManager *wxGUIAppTraits::GetSocketManager()
61 {
62 static GTKSocketManager s_manager;
63 return &s_manager;
64 }
65
66 #endif // wxUSE_SOCKETS