]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/gsockgtk.c
fixed (didn't work at all)
[wxWidgets.git] / src / gtk / gsockgtk.c
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockgtk.c
4 * Purpose: GSocket: GTK part
5 * CVSID: $Id$
6 * -------------------------------------------------------------------------
7 */
8 #include "wx/setup.h"
9
10 #if wxUSE_SOCKETS
11
12 #include <stdlib.h>
13 #include "gdk/gdk.h"
14 #include "glib.h"
15 #include "wx/gsocket.h"
16 #include "wx/unix/gsockunx.h"
17
18 void _GSocket_GDK_Input(gpointer data, gint source, GdkInputCondition condition)
19 {
20 GSocket *socket = (GSocket *)data;
21
22 if (condition & GDK_INPUT_READ)
23 _GSocket_Detected_Read(socket);
24 if (condition & GDK_INPUT_WRITE)
25 _GSocket_Detected_Write(socket);
26 }
27
28 void _GSocket_GUI_Init(GSocket *socket)
29 {
30 int i;
31 gint *m_id;
32
33 socket->m_gui_dependent = (char *)malloc(sizeof(gint)*3);
34 m_id = (gint *)(socket->m_gui_dependent);
35
36 for (i=0;i<3;i++)
37 m_id[i] = -1;
38 }
39
40 void _GSocket_GUI_Destroy(GSocket *socket)
41 {
42 int i;
43 gint *m_id;
44
45 m_id = (gint *)(socket->m_gui_dependent);
46
47 for (i=0;i<3;i++)
48 if (m_id[i] == -1)
49 gdk_input_remove(m_id[i]);
50
51 free(socket->m_gui_dependent);
52 }
53
54 void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
55 {
56 GdkInputCondition flag;
57 int c;
58 gint *m_id;
59
60 m_id = (gint *)(socket->m_gui_dependent);
61
62 switch (event) {
63 case GSOCK_CONNECTION:
64 case GSOCK_LOST:
65 case GSOCK_INPUT: c = 0; flag = GDK_INPUT_READ; break;
66 case GSOCK_OUTPUT: c = 1;flag = GDK_INPUT_WRITE; break;
67 default: return;
68 }
69
70 if (m_id[c] != -1)
71 gdk_input_remove(m_id[c]);
72
73 m_id[c] = gdk_input_add(socket->m_fd, flag,
74 _GSocket_GDK_Input, (gpointer)socket);
75 }
76
77 void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
78 {
79 int c;
80 gint *m_id;
81
82 m_id = (gint *)(socket->m_gui_dependent);
83
84 switch (event) {
85 case GSOCK_CONNECTION:
86 case GSOCK_LOST:
87 case GSOCK_INPUT: c = 0; break;
88 case GSOCK_OUTPUT: c = 1; break;
89 default: return;
90 }
91
92 if (m_id[c] != -1)
93 gdk_input_remove(m_id[c]);
94
95 m_id[c] = -1;
96 }
97
98 unsigned long GSocket_GetEventID(GSocket *socket)
99 {
100 return 0;
101 }
102
103 void GSocket_DoEvent(unsigned long evt_id)
104 {
105 }
106
107 #endif /* wxUSE_SOCKETS */