summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/interface.c26
-rw-r--r--src/interface.h1
-rw-r--r--src/pa-sink-ctl.c21
3 files changed, 35 insertions, 13 deletions
diff --git a/src/interface.c b/src/interface.c
index ace0907..3614a21 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -60,15 +60,16 @@ void interface_init(void)
initscr();
clear();
+
noecho();
cbreak(); /* Line buffering disabled. pass on everything */
+ curs_set(0); /* hide cursor */
// 0,0,0,0 means fullscreen
menu_win = newwin(0, 0, 0, 0);
msg_win = newwin(0, 0, 0, 0);
nodelay(menu_win, TRUE); /* important! make wgetch non-blocking */
keypad(menu_win, TRUE);
- curs_set(0); /* hide cursor */
mvwprintw(msg_win, 0, 0, "Use arrow keys to go up and down, Press enter to select a choice");
// resize the windows into the correct form
interface_resize();
@@ -92,6 +93,7 @@ void interface_resize(void)
wresize(msg_win, H_MSG_BOX, width);
mvwin(msg_win, height - H_MSG_BOX, 0);
+ status(NULL);
print_sink_list();
}
@@ -102,11 +104,6 @@ void print_sink_list(void)
gint y = 2;
gint offset = 0;
- werase(msg_win);
- box(msg_win, 0, 0);
- mvwprintw(msg_win, 1, 1, "Test!");
- wrefresh(msg_win);
-
werase(menu_win);
box(menu_win, 0, 0);
@@ -310,7 +307,6 @@ void get_input(void)
case 'q':
default:
- printf("key: %d\n", c);
quit();
break;
}
@@ -318,7 +314,21 @@ void get_input(void)
void interface_clear(void)
{
- clrtoeol();
+ clear();
refresh();
endwin();
}
+
+void status(gchar *msg) {
+ static gchar *save = NULL;
+ if (msg != NULL) {
+ g_free(save);
+ save = g_strdup(msg);
+ }
+ werase(msg_win);
+ box(msg_win, 0, 0);
+ if (save != NULL)
+ mvwprintw(msg_win, 1, 1, save);
+ wrefresh(msg_win);
+ refresh();
+}
diff --git a/src/interface.h b/src/interface.h
index fa368cb..2734c72 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -11,5 +11,6 @@ void get_input(void);
void interface_init(void);
void interface_resize(void);
void interface_clear(void);
+void status(gchar *);
#endif
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c
index d541156..0aed6cd 100644
--- a/src/pa-sink-ctl.c
+++ b/src/pa-sink-ctl.c
@@ -47,7 +47,10 @@ int main(int argc, char** argv)
g_main_loop_run(g_loop);
- printf("main loop quit\n");
+ sink_list_free(sink_list);
+ interface_clear();
+
+ //printf("main loop quit\n");
pa_glib_mainloop_free(m);
g_main_loop_unref(g_loop);
@@ -76,8 +79,13 @@ void context_state_callback(pa_context *c, gpointer userdata)
{
switch (pa_context_get_state(c)) {
case PA_CONTEXT_CONNECTING:
+ status("connecting...");
+ break;
case PA_CONTEXT_AUTHORIZING:
+ status("authorizing...");
+ break;
case PA_CONTEXT_SETTING_NAME:
+ status("setting name...");
break;
case PA_CONTEXT_READY:
@@ -88,14 +96,19 @@ void context_state_callback(pa_context *c, gpointer userdata)
g_assert((o = pa_context_subscribe(c, (pa_subscription_mask_t) (
PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SINK_INPUT
), NULL, NULL)));
+ status("ready to process events.");
+ break;
+ case PA_CONTEXT_FAILED:
+ status("cannot connect!");
break;
case PA_CONTEXT_TERMINATED:
- printf("pulse connection terminated\n");
+ status("connection terminated.");
+ //printf("pulse connection terminated\n");
g_main_loop_quit((GMainLoop *)userdata);
break;
default:
- printf("unknown state\n");
+ status("unknown state");
break;
}
}
@@ -170,8 +183,6 @@ void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info *i, gi
void quit(void)
{
- sink_list_free(sink_list);
- interface_clear();
pa_context_disconnect(context);
}