]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/gsockgtk.c
Cured some bugs/typos/spacing in docs
[wxWidgets.git] / src / gtk1 / 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 "../unix/gsockunx.h"
17
18 void _GSocket_GDK_Input(gpointer data, gint source, GdkInputCondition condition)
19 {
20 GSocket *socket = (GSocket *)data;
21
22 switch (condition) {
23 case GDK_INPUT_READ:
24 _GSocket_Detected_Read(socket);
25 break;
26 case GDK_INPUT_WRITE:
27 _GSocket_Detected_Write(socket);
28 break;
29 default:
30 break;
31 }
32 }
33
34 void _GSocket_GUI_Init(GSocket *socket)
35 {
36 int i;
37 gint *m_id;
38
39 socket->m_gui_dependent = (char *)malloc(sizeof(gint)*3);
40 m_id = (gint *)(socket->m_gui_dependent);
41
42 for (i=0;i<3;i++)
43 m_id[i] = -1;
44 }
45
46 void _GSocket_GUI_Destroy(GSocket *socket)
47 {
48 int i;
49 gint *m_id;
50
51 m_id = (gint *)(socket->m_gui_dependent);
52
53 for (i=0;i<3;i++)
54 if (m_id[i] == -1)
55 gdk_input_remove(m_id[i]);
56
57 free(socket->m_gui_dependent);
58 }
59
60 void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
61 {
62 GdkInputCondition flag;
63 int c;
64 gint *m_id;
65
66 m_id = (gint *)(socket->m_gui_dependent);
67
68 switch (event) {
69 case GSOCK_CONNECTION:
70 case GSOCK_LOST:
71 case GSOCK_INPUT: c = 0; flag = GDK_INPUT_READ; break;
72 case GSOCK_OUTPUT: c = 1;flag = GDK_INPUT_WRITE; break;
73 default: return;
74 }
75
76 if (m_id[c] != -1)
77 gdk_input_remove(m_id[c]);
78
79 m_id[c] = gdk_input_add(socket->m_fd, flag,
80 _GSocket_GDK_Input, (gpointer)socket);
81 }
82
83 void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
84 {
85 int c;
86 gint *m_id;
87
88 m_id = (gint *)(socket->m_gui_dependent);
89
90 switch (event) {
91 case GSOCK_CONNECTION:
92 case GSOCK_LOST:
93 case GSOCK_INPUT: c = 0; break;
94 case GSOCK_OUTPUT: c = 1; break;
95 default: return;
96 }
97
98 if (m_id[c] != -1)
99 gdk_input_remove(m_id[c]);
100
101 m_id[c] = -1;
102 }
103
104 unsigned long GSocket_GetEventID(GSocket *socket)
105 {
106 return 0;
107 }
108
109 void GSocket_DoEvent(unsigned long evt_id)
110 {
111 }
112
113 #endif /* wxUSE_SOCKETS */