Mercurial > pidgin
comparison finch/libgnt/gntmain.c @ 19171:9f7587b86b0d
propagate from branch 'tmpbranch' (head e6743aa2d424749cd40350df703d079ef61fd5ce)
to branch 'im.pidgin.soc.2007.finchfeat' (head a87f346863ddc48e5705c2c555c7ed842325a9a3)
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Sun, 22 Jul 2007 01:28:19 +0000 |
parents | 7a5025b8698c 09db6fec9dce |
children | 33201366bcd4 |
comparison
equal
deleted
inserted
replaced
19170:315fd66bb08f | 19171:9f7587b86b0d |
---|---|
310 | 310 |
311 g_io_channel_unref(channel); /* Apparently this caused crashes for some people. | 311 g_io_channel_unref(channel); /* Apparently this caused crashes for some people. |
312 But irssi does this, so I am going to assume the | 312 But irssi does this, so I am going to assume the |
313 crashes were caused by some other stuff. */ | 313 crashes were caused by some other stuff. */ |
314 | 314 |
315 g_printerr("gntmain: setting up IO\n"); | 315 g_printerr("gntmain: setting up IO (%d)\n", channel_read_callback); |
316 } | 316 } |
317 | 317 |
318 static gboolean | 318 static gboolean |
319 refresh_screen() | 319 refresh_screen() |
320 { | 320 { |
647 { | 647 { |
648 return gnt_clipboard_get_string(clipboard); | 648 return gnt_clipboard_get_string(clipboard); |
649 } | 649 } |
650 | 650 |
651 #if GLIB_CHECK_VERSION(2,4,0) | 651 #if GLIB_CHECK_VERSION(2,4,0) |
652 typedef struct | |
653 { | |
654 void (*callback)(int status, gpointer data); | |
655 gpointer data; | |
656 } ChildProcess; | |
657 | |
652 static void | 658 static void |
653 reap_child(GPid pid, gint status, gpointer data) | 659 reap_child(GPid pid, gint status, gpointer data) |
654 { | 660 { |
661 ChildProcess *cp = data; | |
662 if (cp->callback) { | |
663 cp->callback(status, cp->data); | |
664 } | |
665 g_free(cp); | |
666 clean_pid(); | |
655 wm->mode = GNT_KP_MODE_NORMAL; | 667 wm->mode = GNT_KP_MODE_NORMAL; |
656 clear(); | 668 clear(); |
657 setup_io(); | 669 setup_io(); |
658 refresh_screen(); | 670 refresh_screen(); |
659 } | 671 } |
660 #endif | 672 #endif |
661 | 673 |
662 gboolean gnt_giveup_console(const char *wd, char **argv, char **envp, | 674 gboolean gnt_giveup_console(const char *wd, char **argv, char **envp, |
663 gint *stin, gint *stout, gint *sterr) | 675 gint *stin, gint *stout, gint *sterr, |
676 void (*callback)(int status, gpointer data), gpointer data) | |
664 { | 677 { |
665 #if GLIB_CHECK_VERSION(2,4,0) | 678 #if GLIB_CHECK_VERSION(2,4,0) |
666 GPid pid = 0; | 679 GPid pid = 0; |
680 ChildProcess *cp = NULL; | |
667 | 681 |
668 if (!g_spawn_async_with_pipes(wd, argv, envp, | 682 if (!g_spawn_async_with_pipes(wd, argv, envp, |
669 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, | 683 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, |
670 (GSpawnChildSetupFunc)endwin, NULL, | 684 (GSpawnChildSetupFunc)endwin, NULL, |
671 &pid, stin, stout, sterr, NULL)) | 685 &pid, stin, stout, sterr, NULL)) |
672 return FALSE; | 686 return FALSE; |
673 | 687 |
688 cp = g_new0(ChildProcess, 1); | |
689 cp->callback = callback; | |
690 cp->data = data; | |
674 g_source_remove(channel_read_callback); | 691 g_source_remove(channel_read_callback); |
675 wm->mode = GNT_KP_MODE_WAIT_ON_CHILD; | 692 wm->mode = GNT_KP_MODE_WAIT_ON_CHILD; |
676 g_child_watch_add(pid, reap_child, NULL); | 693 g_child_watch_add(pid, reap_child, cp); |
677 | 694 |
678 return TRUE; | 695 return TRUE; |
679 #else | 696 #else |
680 return FALSE; | 697 return FALSE; |
681 #endif | 698 #endif |