Mercurial > pidgin
changeset 18421:e16d097c5739
Allow executing another application (eg. PAGER) that will use the same
console.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 03 Jul 2007 08:54:34 +0000 |
parents | e2b8b17fc62c |
children | b8cf3002bb99 |
files | finch/libgnt/gnt.h finch/libgnt/gntmain.c finch/libgnt/gntwm.c finch/libgnt/gntwm.h finch/libgnt/gntws.c |
diffstat | 5 files changed, 65 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/libgnt/gnt.h Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gnt.h Tue Jul 03 08:54:34 2007 +0000 @@ -112,7 +112,7 @@ /** * * @param label - * @param callback)() + * @param callback */ void gnt_register_action(const char *label, void (*callback)()); @@ -149,3 +149,11 @@ */ void gnt_set_clipboard_string(gchar *string); +/** + * Spawn a different application that will consume the console. + */ +gboolean gnt_giveup_console(const char *wd, char **argv, char **envp, + gint *stin, gint *stout, gint *sterr); + +gboolean gnt_is_refugee(void); +
--- a/finch/libgnt/gntmain.c Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntmain.c Tue Jul 03 08:54:34 2007 +0000 @@ -220,8 +220,13 @@ io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) { char keys[256]; - int rd = read(STDIN_FILENO, keys + HOLDING_ESCAPE, sizeof(keys) - 1 - HOLDING_ESCAPE); + int rd; char *k; + + if (wm->mode == GNT_KP_MODE_WAIT_ON_CHILD) + return FALSE; + + rd = read(STDIN_FILENO, keys + HOLDING_ESCAPE, sizeof(keys) - 1 - HOLDING_ESCAPE); if (rd < 0) { int ch = getch(); /* This should return ERR, but let's see what it really returns */ @@ -622,7 +627,50 @@ { return clipboard; } + gchar *gnt_get_clipboard_string() { return gnt_clipboard_get_string(clipboard); } + +#if GLIB_CHECK_VERSION(2,4,0) +static void +reap_child(GPid pid, gint status, gpointer data) +{ + wm->mode = GNT_KP_MODE_NORMAL; + clear(); + setup_io(); + refresh_screen(); +} +#endif + +gboolean gnt_giveup_console(const char *wd, char **argv, char **envp, + gint *stin, gint *stout, gint *sterr) +{ +#if GLIB_CHECK_VERSION(2,4,0) + GPid pid = 0; + + if (!g_spawn_async_with_pipes(wd, argv, envp, + G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, + (GSpawnChildSetupFunc)endwin, NULL, + &pid, stin, stout, sterr, NULL)) + return FALSE; + + wm->mode = GNT_KP_MODE_WAIT_ON_CHILD; + g_child_watch_add(pid, reap_child, NULL); + + return TRUE; +#else + return FALSE; +#endif +} + +gboolean gnt_is_refugee() +{ +#if GLIB_CHECK_VERSION(2,4,0) + return (wm && wm->mode == GNT_KP_MODE_WAIT_ON_CHILD); +#else + return FALSE; +#endif +} +
--- a/finch/libgnt/gntwm.c Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntwm.c Tue Jul 03 08:54:34 2007 +0000 @@ -204,6 +204,9 @@ static gboolean update_screen(GntWM *wm) { + if (wm->mode == GNT_KP_MODE_WAIT_ON_CHILD) + return TRUE; + if (wm->menu) { GntMenu *top = wm->menu; while (top) {
--- a/finch/libgnt/gntwm.h Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntwm.h Tue Jul 03 08:54:34 2007 +0000 @@ -46,6 +46,7 @@ GNT_KP_MODE_NORMAL, GNT_KP_MODE_RESIZE, GNT_KP_MODE_MOVE, + GNT_KP_MODE_WAIT_ON_CHILD } GntKeyPressMode; typedef struct
--- a/finch/libgnt/gntws.c Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntws.c Tue Jul 03 08:54:34 2007 +0000 @@ -35,6 +35,9 @@ int n, width = 0; int i; + if (gnt_is_refugee()) + return; + if (taskbar == NULL) { taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); } else if (reposition) {