]>
Commit | Line | Data |
---|---|---|
a324a7bc GL |
1 | #include <stdlib.h> |
2 | #include <gdk/gdk.h> | |
3 | #include <glib.h> | |
4 | #include <wx/gsocket.h> | |
5 | #include "../unix/gsockunx.h" | |
6 | ||
7 | void _GSocket_GDK_Input(gpointer data, gint source, GdkInputCondition condition) | |
8 | { | |
9 | GSocket *socket = (GSocket *)data; | |
10 | ||
11 | switch (condition) { | |
12 | case GDK_INPUT_READ: | |
13 | _GSocket_Detected_Read(socket); | |
14 | break; | |
15 | case GDK_INPUT_WRITE: | |
16 | _GSocket_Detected_Write(socket); | |
17 | break; | |
18 | default: | |
19 | break; | |
20 | } | |
21 | } | |
22 | ||
23 | void _GSocket_GUI_Init(GSocket *socket) | |
24 | { | |
25 | int i; | |
26 | gint *m_id; | |
27 | ||
28 | socket->m_gui_dependent = (char *)malloc(sizeof(gint)*3); | |
29 | m_id = (gint *)(socket->m_gui_dependent); | |
30 | ||
31 | for (i=0;i<3;i++) | |
32 | m_id[i] = -1; | |
33 | } | |
34 | ||
35 | void _GSocket_GUI_Destroy(GSocket *socket) | |
36 | { | |
37 | int i; | |
38 | gint *m_id; | |
39 | ||
40 | m_id = (gint *)(socket->m_gui_dependent); | |
41 | ||
42 | for (i=0;i<3;i++) | |
43 | if (m_id[i] == -1) | |
44 | gdk_input_remove(m_id[i]); | |
45 | ||
46 | free(socket->m_gui_dependent); | |
47 | } | |
48 | ||
49 | void _GSocket_Install_Fallback(GSocket *socket, GSocketEvent event) | |
50 | { | |
51 | GdkInputCondition flag; | |
52 | int c; | |
53 | gint *m_id; | |
54 | ||
55 | m_id = (gint *)(socket->m_gui_dependent); | |
56 | ||
57 | switch (event) { | |
58 | case GSOCK_CONNECTION: | |
59 | case GSOCK_LOST: | |
60 | case GSOCK_INPUT: c = 0; flag = GDK_INPUT_READ; break; | |
61 | case GSOCK_OUTPUT: c = 1;flag = GDK_INPUT_WRITE; break; | |
62 | default: return; | |
63 | } | |
64 | ||
65 | if (m_id[c] != -1) | |
66 | gdk_input_remove(m_id[c]); | |
67 | ||
68 | m_id[c] = gdk_input_add(socket->m_fd, flag, | |
69 | _GSocket_GDK_Input, (gpointer)socket); | |
70 | } | |
71 | ||
72 | void _GSocket_Uninstall_Fallback(GSocket *socket, GSocketEvent event) | |
73 | { | |
74 | int c; | |
75 | gint *m_id; | |
76 | ||
77 | m_id = (gint *)(socket->m_gui_dependent); | |
78 | ||
79 | switch (event) { | |
80 | case GSOCK_CONNECTION: | |
81 | case GSOCK_LOST: | |
82 | case GSOCK_INPUT: c = 0; break; | |
83 | case GSOCK_OUTPUT: c = 1; break; | |
84 | default: return; | |
85 | } | |
86 | ||
87 | if (m_id[c] != -1) | |
88 | gdk_input_remove(m_id[c]); | |
89 | ||
90 | m_id[c] = -1; | |
91 | } | |
92 | ||
93 | unsigned long GSocket_GetEventID(GSocket *socket) | |
94 | { | |
95 | return 0; | |
96 | } | |
97 | ||
98 | void GSocket_DoEvent(unsigned long evt_id) | |
99 | { | |
100 | } |