ru.po: Corrections from Evgeny Bulgakov <bgav@netvision.net.il>
[midnight-commander.git] / gnome / gkey.c
blobbab48abcb0e4f18bdf9d51282b01575b43732fcd
1 /*
2 * Midnight Commander -- GNOME edition
4 * Copyright 1997 The Free Software Foundation
6 * Author:Miguel de Icaza (miguel@gnu.org)
7 */
9 #include <config.h>
10 #include "global.h"
11 #include "x.h"
12 #include "key.h"
14 /* The tty.h file is included since we try to use as much object code
15 * from the curses distribution as possible so we need to send back
16 * the same constants that the code expects on the non-X version
17 * of the code. The constants may be the ones from curses/ncurses
18 * or our macro definitions for slang
21 struct trampoline {
22 select_fn fn;
23 void *fn_closure;
24 int fd;
25 int tag;
28 void
29 callback_trampoline (gpointer data, gint source, GdkInputCondition condition)
31 struct trampoline *t = data;
33 /* return value is ignored */
34 (*t->fn)(source, t->fn_closure);
38 * We need to keep track of the select callbacks, as we need to release
39 * the trampoline closure.
42 GList *select_list;
44 void
45 add_select_channel (int fd, select_fn callback, void *info)
47 struct trampoline *t;
49 t = g_new (struct trampoline, 1);
50 t->fn = callback;
51 t->fd = fd;
52 t->fn_closure = info;
53 t->tag = gdk_input_add (fd, GDK_INPUT_READ, callback_trampoline, t);
54 g_list_prepend (select_list, t);
57 static struct trampoline *tclosure;
59 static void
60 find_select_closure_callback (gpointer data, gpointer user_data)
62 struct trampoline *t = data;
63 int *pfd = (int *) user_data;
65 if (t->fd == *pfd)
66 tclosure = data;
69 void
70 delete_select_channel (int fd)
72 tclosure = 0;
73 g_list_foreach (select_list, find_select_closure_callback, &fd);
74 if (tclosure){
75 select_list = g_list_remove (select_list, tclosure);
76 gdk_input_remove (tclosure->tag);
77 g_free (tclosure);
78 } else {
79 g_warning ("could not find closure for %d\n", fd);