mc/gnome/gkey.c
Miguel de Icaza 0559c128f7 1999-03-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdialogs.c: Support ui->ctx to be NULL, as file.c will set this
	to NULL for background operations.


1999-03-10  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* utilunix.c (g_readlink): New function.  Wraps all the nonsense
	of readlink into a nice routine.

	* filegui.c: Support ui->ctx to be NULL, as file.c will set this
	to NULL for background operations.

	* background.c (do_background): Handle EINTR in dup2.
1999-03-11 02:00:12 +00:00

82 lines
1.7 KiB
C

/*
* Midnight Commander -- GNOME edition
*
* Copyright 1997 The Free Software Foundation
*
* Author:Miguel de Icaza (miguel@gnu.org)
*/
#include <config.h>
#include "global.h"
#include "x.h"
#include "key.h"
/* The tty.h file is included since we try to use as much object code
* from the curses distribution as possible so we need to send back
* the same constants that the code expects on the non-X version
* of the code. The constants may be the ones from curses/ncurses
* or our macro definitions for slang
*/
struct trampoline {
select_fn fn;
void *fn_closure;
int fd;
int tag;
};
void
callback_trampoline (gpointer data, gint source, GdkInputCondition condition)
{
struct trampoline *t = data;
/* return value is ignored */
(*t->fn)(source, t->fn_closure);
}
/*
* We need to keep track of the select callbacks, as we need to release
* the trampoline closure.
*/
GList *select_list;
void
add_select_channel (int fd, select_fn callback, void *info)
{
struct trampoline *t;
t = g_new (struct trampoline, 1);
t->fn = callback;
t->fd = fd;
t->fn_closure = info;
t->tag = gdk_input_add (fd, GDK_INPUT_READ, callback_trampoline, t);
g_list_prepend (select_list, t);
}
static struct trampoline *tclosure;
static void
find_select_closure_callback (gpointer data, gpointer user_data)
{
struct trampoline *t = data;
int *pfd = (int *) user_data;
if (t->fd == *pfd)
tclosure = data;
}
void
delete_select_channel (int fd)
{
tclosure = 0;
g_list_foreach (select_list, find_select_closure_callback, &fd);
if (tclosure){
select_list = g_list_remove (select_list, tclosure);
gdk_input_remove (tclosure->tag);
g_free (tclosure);
} else {
g_warning ("could not find closure for %d\n", fd);
}
}