diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-10-19 21:43:59 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-10-19 21:43:59 +0200 |
commit | 5e110e2a96b33496fac18216eb81e2895d785fdf (patch) | |
tree | 9180116a5aa88cb3e16f35ce06cc914c855b7323 | |
parent | ebc11253078db014895a8321d8d0d23375a878c9 (diff) | |
download | pa-sink-ctl-5e110e2a96b33496fac18216eb81e2895d785fdf.tar.gz pa-sink-ctl-5e110e2a96b33496fac18216eb81e2895d785fdf.tar.bz2 pa-sink-ctl-5e110e2a96b33496fac18216eb81e2895d785fdf.zip |
interface.h: Remove private function prototypes
Therefore reorder function definitions in interface.c.
-rw-r--r-- | src/interface.c | 199 | ||||
-rw-r--r-- | src/interface.h | 5 |
2 files changed, 99 insertions, 105 deletions
diff --git a/src/interface.c b/src/interface.c index 0229204..3e87046 100644 --- a/src/interface.c +++ b/src/interface.c @@ -30,40 +30,7 @@ static guint32 selected_index; guint max_name_len = 0; -void -interface_init(void) -{ - chooser_sink = 0; /* Selected sink-device. 0 is the first device */ - chooser_input = -1; /* Selected input of the current sink-device. */ - /* -1 means the sink-device itself */ - initscr(); - clear(); - - noecho(); - /* Line buffering disabled. pass on everything */ - cbreak(); - /* hide cursor */ - curs_set(0); - - /* 0,0,0,0 := fullscreen */ - menu_win = newwin(0, 0, 0, 0); - msg_win = newwin(0, 0, 0, 0); - - /* multichar keys are mapped to one char */ - keypad(menu_win, TRUE); - - /* "resizing" here is for initial box positioning and layout */ - interface_resize(NULL); - - /* register event handler for resize and input */ - resize_source_id = g_unix_signal_add(SIGWINCH, interface_resize, NULL); - input_source_id = g_curses_input_add(menu_win, interface_get_input, - NULL); - - refresh(); -} - -gboolean +static gboolean interface_resize(gpointer data) { struct winsize wsize; @@ -89,55 +56,28 @@ interface_resize(gpointer data) return TRUE; } -void -print_sink_list(void) +static void +print_volume(pa_volume_t volume, int mute, int y) { - gint i = 0; - gint x = 2; - gint y = 2; - gint offset = 0; - - /* looking for the longest name for right indentation */ - set_max_name_len(); - - werase(menu_win); - box(menu_win, 0, 0); - - /* derive chooser_input from selected_index (this is set when input is moved) */ - if (chooser_input == -2) { - /* if index is will not be found (in the loop), select the sink itself */ - chooser_input = -1; - /* step through inputs for current sink and find the selected */ - for (i = 0; i < sink_list_get(chooser_sink)->input_list->len; ++i) { - if (selected_index == sink_input_get(chooser_sink, i)->index) { - chooser_input = i; - break; - } - } - } - - for (i = 0; i < sink_list->len; ++i) { - if (i == chooser_sink && chooser_input == -1) - wattron(menu_win, A_REVERSE); + gint x = 2 /* left */ + 2 /* index num width */ + 1 /* space */ + + 1 /* space */ + max_name_len + 1 /* space */; - mvwprintw(menu_win, y+i+offset, x, "%2u %-*s", - sink_list_get(i)->index, - max_name_len, - sink_list_get(i)->device != NULL ? sink_list_get(i)->device : sink_list_get(i)->name); - - if (i == chooser_sink && chooser_input == -1) - wattroff(menu_win, A_REVERSE); - print_volume(sink_list_get(i)->vol, sink_list_get(i)->mute, y+i+offset); + //gint vol = (gint) (VOLUME_BAR_LEN * volume / PA_VOLUME_NORM); + int volume_bar_len = getmaxx(menu_win) - x - 6 /* mute button + brackets + space */; + gint vol = (gint) (volume_bar_len * volume / PA_VOLUME_NORM); - print_input_list(i); + mvwprintw(menu_win, y, x - 1, "[%c]", mute ? 'M' : ' '); + x += 3; - offset += sink_list_get(i)->input_list->len; - } - wrefresh(menu_win); + mvwprintw(menu_win, y, x - 1 , "["); + for (gint i = 0; i < vol; ++i) + mvwprintw(menu_win, y, x + i, "="); + for (gint i = vol; i < volume_bar_len; ++i) + mvwprintw(menu_win, y, x + i, " "); + mvwprintw(menu_win, y, x + volume_bar_len, "]"); } - -void +static void print_input_list(gint sink_num) { gint offset = sink_num + 3 /* win border + empty line + 1th sink */; @@ -162,29 +102,8 @@ print_input_list(gint sink_num) } } -void -print_volume(pa_volume_t volume, int mute, int y) -{ - gint x = 2 /* left */ + 2 /* index num width */ + 1 /* space */ + - 1 /* space */ + max_name_len + 1 /* space */; - - //gint vol = (gint) (VOLUME_BAR_LEN * volume / PA_VOLUME_NORM); - int volume_bar_len = getmaxx(menu_win) - x - 6 /* mute button + brackets + space */; - gint vol = (gint) (volume_bar_len * volume / PA_VOLUME_NORM); - - mvwprintw(menu_win, y, x - 1, "[%c]", mute ? 'M' : ' '); - x += 3; - - mvwprintw(menu_win, y, x - 1 , "["); - for (gint i = 0; i < vol; ++i) - mvwprintw(menu_win, y, x + i, "="); - for (gint i = vol; i < volume_bar_len; ++i) - mvwprintw(menu_win, y, x + i, " "); - mvwprintw(menu_win, y, x + volume_bar_len, "]"); -} - /* looking for the longest name length of all SINK's and INPUT's */ -void +static void set_max_name_len(void) { guint len = 0; @@ -212,7 +131,54 @@ set_max_name_len(void) } } -gboolean +void +print_sink_list(void) +{ + gint i = 0; + gint x = 2; + gint y = 2; + gint offset = 0; + + /* looking for the longest name for right indentation */ + set_max_name_len(); + + werase(menu_win); + box(menu_win, 0, 0); + + /* derive chooser_input from selected_index (this is set when input is moved) */ + if (chooser_input == -2) { + /* if index is will not be found (in the loop), select the sink itself */ + chooser_input = -1; + /* step through inputs for current sink and find the selected */ + for (i = 0; i < sink_list_get(chooser_sink)->input_list->len; ++i) { + if (selected_index == sink_input_get(chooser_sink, i)->index) { + chooser_input = i; + break; + } + } + } + + for (i = 0; i < sink_list->len; ++i) { + if (i == chooser_sink && chooser_input == -1) + wattron(menu_win, A_REVERSE); + + mvwprintw(menu_win, y+i+offset, x, "%2u %-*s", + sink_list_get(i)->index, + max_name_len, + sink_list_get(i)->device != NULL ? sink_list_get(i)->device : sink_list_get(i)->name); + + if (i == chooser_sink && chooser_input == -1) + wattroff(menu_win, A_REVERSE); + print_volume(sink_list_get(i)->vol, sink_list_get(i)->mute, y+i+offset); + + print_input_list(i); + + offset += sink_list_get(i)->input_list->len; + } + wrefresh(menu_win); +} + +static gboolean interface_get_input(gpointer data) { gint c; @@ -380,3 +346,36 @@ status(const gchar *msg) wrefresh(msg_win); refresh(); } + +void +interface_init(void) +{ + chooser_sink = 0; /* Selected sink-device. 0 is the first device */ + chooser_input = -1; /* Selected input of the current sink-device. */ + /* -1 means the sink-device itself */ + initscr(); + clear(); + + noecho(); + /* Line buffering disabled. pass on everything */ + cbreak(); + /* hide cursor */ + curs_set(0); + + /* 0,0,0,0 := fullscreen */ + menu_win = newwin(0, 0, 0, 0); + msg_win = newwin(0, 0, 0, 0); + + /* multichar keys are mapped to one char */ + keypad(menu_win, TRUE); + + /* "resizing" here is for initial box positioning and layout */ + interface_resize(NULL); + + /* register event handler for resize and input */ + resize_source_id = g_unix_signal_add(SIGWINCH, interface_resize, NULL); + input_source_id = g_curses_input_add(menu_win, interface_get_input, + NULL); + + refresh(); +} diff --git a/src/interface.h b/src/interface.h index a482f5e..918ccfe 100644 --- a/src/interface.h +++ b/src/interface.h @@ -5,13 +5,8 @@ #include <pulse/pulseaudio.h> void print_sink_list(void); -void print_input_list(gint); -void print_volume(pa_volume_t, gint, gint); -gboolean interface_get_input(gpointer); void interface_init(void); -gboolean interface_resize(gpointer); void interface_clear(void); void status(const gchar *); -void set_max_name_len(void); #endif |