1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: GTK part
6 * -------------------------------------------------------------------------
18 #include "wx/gsocket.h"
19 #include "wx/unix/gsockunx.h"
22 void _GSocket_GDK_Input(gpointer data
,
24 GdkInputCondition condition
)
26 GSocket
*socket
= (GSocket
*)data
;
28 if (condition
& GDK_INPUT_READ
)
29 _GSocket_Detected_Read(socket
);
30 if (condition
& GDK_INPUT_WRITE
)
31 _GSocket_Detected_Write(socket
);
34 void _GSocket_GUI_Init(GSocket
*socket
)
38 socket
->m_gui_dependent
= (char *)malloc(sizeof(gint
)*2);
39 m_id
= (gint
*)(socket
->m_gui_dependent
);
45 void _GSocket_GUI_Destroy(GSocket
*socket
)
47 free(socket
->m_gui_dependent
);
50 void _GSocket_Install_Callback(GSocket
*socket
, GSocketEvent event
)
52 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
55 if (socket
->m_fd
== -1)
60 case GSOCK_LOST
: /* fall-through */
61 case GSOCK_INPUT
: c
= 0; break;
62 case GSOCK_OUTPUT
: c
= 1; break;
63 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
68 gdk_input_remove(m_id
[c
]);
70 m_id
[c
] = gdk_input_add(socket
->m_fd
,
71 (c
? GDK_INPUT_WRITE
: GDK_INPUT_READ
),
76 void _GSocket_Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
78 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
83 case GSOCK_LOST
: /* fall-through */
84 case GSOCK_INPUT
: c
= 0; break;
85 case GSOCK_OUTPUT
: c
= 1; break;
86 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
91 gdk_input_remove(m_id
[c
]);
96 void _GSocket_Enable_Events(GSocket
*socket
)
98 _GSocket_Install_Callback(socket
, GSOCK_INPUT
);
99 _GSocket_Install_Callback(socket
, GSOCK_OUTPUT
);
102 void _GSocket_Disable_Events(GSocket
*socket
)
104 _GSocket_Uninstall_Callback(socket
, GSOCK_INPUT
);
105 _GSocket_Uninstall_Callback(socket
, GSOCK_OUTPUT
);
108 #else /* !wxUSE_SOCKETS */
110 /* some compilers don't like having empty source files */
111 static int wxDummyGsockVar
= 0;
113 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */