| 218 } |
218 } |
| 219 |
219 |
| 220 static gboolean |
220 static gboolean |
| 221 io_invoke_error(GIOChannel *source, GIOCondition cond, gpointer data) |
221 io_invoke_error(GIOChannel *source, GIOCondition cond, gpointer data) |
| 222 { |
222 { |
| |
223 /* XXX: it throws an error after evey io_invoke, I have no idea why */ |
| |
224 #ifndef _WIN32 |
| 223 int id = GPOINTER_TO_INT(data); |
225 int id = GPOINTER_TO_INT(data); |
| |
226 |
| 224 g_source_remove(id); |
227 g_source_remove(id); |
| 225 g_io_channel_unref(source); |
228 g_io_channel_unref(source); |
| 226 |
229 |
| 227 channel = NULL; |
230 channel = NULL; |
| 228 setup_io(); |
231 setup_io(); |
| |
232 #endif |
| |
233 |
| 229 return TRUE; |
234 return TRUE; |
| 230 } |
235 } |
| 231 |
236 |
| 232 static gboolean |
237 static gboolean |
| 233 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
238 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
| 308 |
313 |
| 309 static void |
314 static void |
| 310 setup_io() |
315 setup_io() |
| 311 { |
316 { |
| 312 int result; |
317 int result; |
| |
318 |
| |
319 #ifdef _WIN32 |
| |
320 channel = g_io_channel_win32_new_fd(STDIN_FILENO); |
| |
321 #else |
| 313 channel = g_io_channel_unix_new(STDIN_FILENO); |
322 channel = g_io_channel_unix_new(STDIN_FILENO); |
| |
323 #endif |
| |
324 |
| |
325 if (channel == NULL) { |
| |
326 gnt_warning("failed creating new channel%s", ""); |
| |
327 return; |
| |
328 } |
| |
329 |
| 314 g_io_channel_set_close_on_unref(channel, TRUE); |
330 g_io_channel_set_close_on_unref(channel, TRUE); |
| 315 |
331 |
| 316 #if 0 |
332 #if 0 |
| 317 g_io_channel_set_encoding(channel, NULL, NULL); |
333 g_io_channel_set_encoding(channel, NULL, NULL); |
| 318 g_io_channel_set_buffered(channel, FALSE); |
334 g_io_channel_set_buffered(channel, FALSE); |
| 325 |
341 |
| 326 channel_error_callback = g_io_add_watch_full(channel, G_PRIORITY_HIGH, |
342 channel_error_callback = g_io_add_watch_full(channel, G_PRIORITY_HIGH, |
| 327 (G_IO_NVAL), |
343 (G_IO_NVAL), |
| 328 io_invoke_error, GINT_TO_POINTER(result), NULL); |
344 io_invoke_error, GINT_TO_POINTER(result), NULL); |
| 329 |
345 |
| 330 g_io_channel_unref(channel); /* Apparently this caused crashes for some people. |
346 g_io_channel_unref(channel); |
| 331 But irssi does this, so I am going to assume the |
|
| 332 crashes were caused by some other stuff. */ |
|
| 333 |
347 |
| 334 gnt_warning("setting up IO (%d)", channel_read_callback); |
348 gnt_warning("setting up IO (%d)", channel_read_callback); |
| 335 } |
349 } |
| 336 |
350 |
| 337 static gboolean |
351 static gboolean |