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 int _GSocket_GUI_Init(GSocket
*socket
)
38 socket
->m_gui_dependent
= (char *)malloc(sizeof(gint
)*2);
39 m_id
= (gint
*)(socket
->m_gui_dependent
);
47 void _GSocket_GUI_Destroy(GSocket
*socket
)
49 free(socket
->m_gui_dependent
);
52 void _GSocket_Install_Callback(GSocket
*socket
, GSocketEvent event
)
54 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
57 if (socket
->m_fd
== -1)
62 case GSOCK_LOST
: /* fall-through */
63 case GSOCK_INPUT
: c
= 0; break;
64 case GSOCK_OUTPUT
: c
= 1; break;
65 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
70 gdk_input_remove(m_id
[c
]);
72 m_id
[c
] = gdk_input_add(socket
->m_fd
,
73 (c
? GDK_INPUT_WRITE
: GDK_INPUT_READ
),
78 void _GSocket_Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
80 gint
*m_id
= (gint
*)(socket
->m_gui_dependent
);
85 case GSOCK_LOST
: /* fall-through */
86 case GSOCK_INPUT
: c
= 0; break;
87 case GSOCK_OUTPUT
: c
= 1; break;
88 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
93 gdk_input_remove(m_id
[c
]);
98 void _GSocket_Enable_Events(GSocket
*socket
)
100 _GSocket_Install_Callback(socket
, GSOCK_INPUT
);
101 _GSocket_Install_Callback(socket
, GSOCK_OUTPUT
);
104 void _GSocket_Disable_Events(GSocket
*socket
)
106 _GSocket_Uninstall_Callback(socket
, GSOCK_INPUT
);
107 _GSocket_Uninstall_Callback(socket
, GSOCK_OUTPUT
);
110 #else /* !wxUSE_SOCKETS */
112 /* some compilers don't like having empty source files */
113 static int wxDummyGsockVar
= 0;
115 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */