summaryrefslogtreecommitdiff
path: root/src/interface.c
diff options
context:
space:
mode:
authorben <benjaminfranzke@googlemail.com>2010-07-19 20:12:27 +0200
committerben <benjaminfranzke@googlemail.com>2010-07-19 20:14:41 +0200
commit9728688ab9e80ba54bacae0e76c16882c491e3eb (patch)
treeb1ef8e15069065e169f7434e5b8717ac0b2d6ce7 /src/interface.c
parent9e6611b32a566d5319446f3deb78dcf80f417b20 (diff)
downloadpa-sink-ctl-9728688ab9e80ba54bacae0e76c16882c491e3eb.tar.gz
pa-sink-ctl-9728688ab9e80ba54bacae0e76c16882c491e3eb.tar.bz2
pa-sink-ctl-9728688ab9e80ba54bacae0e76c16882c491e3eb.zip
state changes(new input etc) recognized at runtime automatically
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/interface.c b/src/interface.c
index c3c8ba7..d45bff7 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -4,6 +4,7 @@
#include <ncurses.h>
#include <string.h>
#include <stdlib.h>
+#include <stdbool.h>
#include "interface.h"
#include "sink.h"
@@ -38,6 +39,7 @@ void interface_init(void)
startx = (80 - WIDTH) / 2;
starty = (24 - HEIGHT) / 2;
menu_win = newwin(HEIGHT, WIDTH, starty, startx);
+ nodelay(menu_win, TRUE); /* important! make wgetch non-blocking */
keypad(menu_win, TRUE);
curs_set(0); /* hide cursor */
mvprintw(0, 0, "Use arrow keys to go up and down, Press enter to select a choice");
@@ -130,6 +132,10 @@ void get_input(void)
c = wgetch(menu_win);
switch (c) {
+ case ERR:
+ /* nothing typed in */
+ return;
+
case 'k':
case KEY_UP:
if (chooser_input == -1 && chooser_sink > 0) {
@@ -139,6 +145,7 @@ void get_input(void)
else if (chooser_input >= 0)
--chooser_input;
+ print_sink_list();
break;
case 'j':
@@ -149,6 +156,7 @@ void get_input(void)
}
else if (chooser_input < ((gint)sink_list_get(chooser_sink)->input_list->len - 1))
++chooser_input;
+ print_sink_list();
break;
case 'h':
@@ -192,7 +200,7 @@ void get_input(void)
);
pa_operation_unref(tmp.volume_set(context, tmp.index, &tmp.volume, change_callback, NULL));
- return;
+ break;
case 'm':
case 'M': {
struct tmp_t {
@@ -218,7 +226,7 @@ void get_input(void)
break;
pa_operation_unref(tmp.mute_set(context, tmp.index, !tmp.mute, change_callback, NULL));
- return;
+ break;
}
case '\n':
case ' ':
@@ -234,7 +242,7 @@ void get_input(void)
pa_operation_unref(pa_context_move_sink_input_by_index(context, selected_index,
sink_list_get(chooser_sink)->index,
change_callback, NULL));
- return;
+ break;
case 'q':
default:
@@ -242,7 +250,6 @@ void get_input(void)
quit();
break;
}
- collect_all_info();
}
void interface_clear(void)