1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: GTK part
6 * -------------------------------------------------------------------------
16 #include "wx/gsocket.h"
17 #include "wx/unix/gsockunx.h"
20 void _GSocket_GDK_Input(gpointer data
,
22 GdkInputCondition condition
)
24 GSocket
*socket
= (GSocket
*)data
;
26 if (condition
& GDK_INPUT_READ
)
27 _GSocket_Detected_Read(socket
);
28 if (condition
& GDK_INPUT_WRITE
)
29 _GSocket_Detected_Write(socket
);
32 void _GSocket_GUI_Init(GSocket
*socket
)
37 socket
->m_gui_dependent
= (char *)malloc(sizeof(gint
)*2);
38 m_id
= (gint
*)(socket
->m_gui_dependent
);
44 void _GSocket_GUI_Destroy(GSocket
*socket
)
46 free(socket
->m_gui_dependent
);
49 void _GSocket_Install_Callback(GSocket
*socket
, GSocketEvent event
)
51 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
54 if (socket
->m_fd
== -1)
59 case GSOCK_LOST
: /* fall-through */
60 case GSOCK_INPUT
: c
= 0; break;
61 case GSOCK_OUTPUT
: c
= 1; break;
62 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
67 gdk_input_remove(m_id
[c
]);
69 m_id
[c
] = gdk_input_add(socket
->m_fd
,
70 (c
? GDK_INPUT_WRITE
: GDK_INPUT_READ
),
75 void _GSocket_Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
77 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
82 case GSOCK_LOST
: /* fall-through */
83 case GSOCK_INPUT
: c
= 0; break;
84 case GSOCK_OUTPUT
: c
= 1; break;
85 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
90 gdk_input_remove(m_id
[c
]);
95 void _GSocket_Enable_Events(GSocket
*socket
)
97 _GSocket_Install_Callback(socket
, GSOCK_INPUT
);
98 _GSocket_Install_Callback(socket
, GSOCK_OUTPUT
);
101 void _GSocket_Disable_Events(GSocket
*socket
)
103 _GSocket_Uninstall_Callback(socket
, GSOCK_INPUT
);
104 _GSocket_Uninstall_Callback(socket
, GSOCK_OUTPUT
);
107 #endif /* wxUSE_SOCKETS */