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