summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-10-19 22:48:50 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-10-19 22:49:32 +0200
commitc8f802659a6954ee0f28297076125442595e7e6b (patch)
tree6ed94e3d23517fb8fb7c76454f3e9a5ba34b1bb9
parentfbfe926fc482a1e48501310c53c95118255da0bc (diff)
downloadpa-sink-ctl-c8f802659a6954ee0f28297076125442595e7e6b.tar.gz
pa-sink-ctl-c8f802659a6954ee0f28297076125442595e7e6b.tar.bz2
pa-sink-ctl-c8f802659a6954ee0f28297076125442595e7e6b.zip
g_curses_input: Fix coding style
-rw-r--r--src/g_curses_input.c17
-rw-r--r--src/g_curses_input.h11
2 files changed, 19 insertions, 9 deletions
diff --git a/src/g_curses_input.c b/src/g_curses_input.c
index 9ab0f71..ece0213 100644
--- a/src/g_curses_input.c
+++ b/src/g_curses_input.c
@@ -12,9 +12,8 @@ static gboolean
check(GSource *source)
{
GCursesInput *curses_input = (GCursesInput*) source;
- static int i = 0;
- i++;
gint ch = wgetch(curses_input->win);
+
if (ch != ERR)
ungetch(ch);
return ch != ERR;
@@ -31,6 +30,7 @@ static gboolean
dispatch(GSource *source, GSourceFunc callback, gpointer user_data)
{
GCursesInput *curses_input = (GCursesInput*) source;
+
return callback((gpointer)curses_input->win) ? TRUE : FALSE;
}
@@ -47,26 +47,33 @@ GSource *
g_curses_input_source_new(WINDOW *win) {
GSource *source = g_source_new(&SourceFuncs, sizeof(GCursesInput));
GCursesInput *curses_input = (GCursesInput*) source;
+
curses_input->win = win;
nodelay(win, TRUE); /* important! make wgetch non-blocking */
+
return source;
}
guint
-g_curses_input_add_full(gint priority, WINDOW *win, GSourceFunc function, gpointer data, GDestroyNotify notify)
+g_curses_input_add_full(gint priority, WINDOW *win, GSourceFunc function,
+ gpointer data, GDestroyNotify notify)
{
g_return_val_if_fail(function != NULL, 0);
GSource *source = g_curses_input_source_new(win);
+ guint id;
+
if (priority != G_PRIORITY_DEFAULT)
g_source_set_priority (source, priority);
g_source_set_callback(source, function, data, notify);
- guint id = g_source_attach(source, NULL);
+ id = g_source_attach(source, NULL);
g_source_unref(source);
+
return id;
}
guint
g_curses_input_add(WINDOW *win, GSourceFunc function, gpointer data)
{
- return g_curses_input_add_full(G_PRIORITY_DEFAULT, win, function, data, NULL);
+ return g_curses_input_add_full(G_PRIORITY_DEFAULT,
+ win, function, data, NULL);
}
diff --git a/src/g_curses_input.h b/src/g_curses_input.h
index 23eb550..b1de86e 100644
--- a/src/g_curses_input.h
+++ b/src/g_curses_input.h
@@ -4,9 +4,12 @@
#include <ncurses.h>
#include <glib.h>
-GSource *g_curses_input_source_new(WINDOW *screen);
-guint g_curses_input_add_full(gint priority, WINDOW *win, GSourceFunc function,
- gpointer data, GDestroyNotify notify);
-guint g_curses_input_add(WINDOW *win, GSourceFunc function, gpointer data);
+GSource *
+g_curses_input_source_new(WINDOW *screen);
+guint
+g_curses_input_add_full(gint priority, WINDOW *win, GSourceFunc function,
+ gpointer data, GDestroyNotify notify);
+guint
+g_curses_input_add(WINDOW *win, GSourceFunc function, gpointer data);
#endif /* G_CURESES_INPUT_H */