1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: GTK part
6 * -------------------------------------------------------------------------
15 #include "wx/gsocket.h"
16 #include "../unix/gsockunx.h"
18 void _GSocket_GDK_Input(gpointer data
, gint source
, GdkInputCondition condition
)
20 GSocket
*socket
= (GSocket
*)data
;
22 if (condition
& GDK_INPUT_READ
)
23 _GSocket_Detected_Read(socket
);
24 if (condition
& GDK_INPUT_WRITE
)
25 _GSocket_Detected_Write(socket
);
28 void _GSocket_GUI_Init(GSocket
*socket
)
33 socket
->m_gui_dependent
= (char *)malloc(sizeof(gint
)*3);
34 m_id
= (gint
*)(socket
->m_gui_dependent
);
40 void _GSocket_GUI_Destroy(GSocket
*socket
)
45 m_id
= (gint
*)(socket
->m_gui_dependent
);
49 gdk_input_remove(m_id
[i
]);
51 free(socket
->m_gui_dependent
);
54 void _GSocket_Install_Callback(GSocket
*socket
, GSocketEvent event
)
56 GdkInputCondition flag
;
60 m_id
= (gint
*)(socket
->m_gui_dependent
);
63 case GSOCK_CONNECTION
:
65 case GSOCK_INPUT
: c
= 0; flag
= GDK_INPUT_READ
; break;
66 case GSOCK_OUTPUT
: c
= 1;flag
= GDK_INPUT_WRITE
; break;
71 gdk_input_remove(m_id
[c
]);
73 m_id
[c
] = gdk_input_add(socket
->m_fd
, flag
,
74 _GSocket_GDK_Input
, (gpointer
)socket
);
77 void _GSocket_Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
82 m_id
= (gint
*)(socket
->m_gui_dependent
);
85 case GSOCK_CONNECTION
:
87 case GSOCK_INPUT
: c
= 0; break;
88 case GSOCK_OUTPUT
: c
= 1; break;
93 gdk_input_remove(m_id
[c
]);
98 unsigned long GSocket_GetEventID(GSocket
*socket
)
103 void GSocket_DoEvent(unsigned long evt_id
)
107 #endif /* wxUSE_SOCKETS */