diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-19 09:00:01 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-19 09:00:01 +0100 |
commit | e9f4a40262232e5687711c6325421cfd4c69065f (patch) | |
tree | 84277ebd27f4c9c7dbb486e970fe461fd79f0874 /src/command.c | |
parent | ce10176ea73bf6a9db11a503102d4fa9363fc587 (diff) | |
download | pa-sink-ctl-e9f4a40262232e5687711c6325421cfd4c69065f.tar.gz pa-sink-ctl-e9f4a40262232e5687711c6325421cfd4c69065f.tar.bz2 pa-sink-ctl-e9f4a40262232e5687711c6325421cfd4c69065f.zip |
Implement "down" for both sink and source list
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/command.c b/src/command.c index eb671ca..a883685 100644 --- a/src/command.c +++ b/src/command.c @@ -25,13 +25,13 @@ #include "command.h" static int -sink_input_len(struct context *ctx, struct sink *sink) +main_ctl_childs_len(struct context *ctx, struct main_ctl *ctl) { - struct sink_input *input; + struct slave_ctl *sctl; int len = 0; - list_foreach(ctx->input_list, input) - if (input->sink == sink->base.index) + list_foreach(*ctl->childs_list, sctl) + if (sctl->parent_index == ctl->base.index) len++; return len; @@ -50,7 +50,7 @@ up(struct context *ctx, int key) ifc->chooser_sink > 0) { sink = g_list_nth_data(ctx->sink_list, --ifc->chooser_sink); /* autoassigment to SELECTED_SINK (=-1) if length = 0 */ - ifc->chooser_input = sink_input_len(ctx, sink) - 1; + ifc->chooser_input = main_ctl_childs_len(ctx, (struct main_ctl *) sink) - 1; } else if (ifc->chooser_input >= 0) --ifc->chooser_input; @@ -61,17 +61,27 @@ static void down(struct context *ctx, int key) { struct interface *ifc = &ctx->interface; - struct sink *sink; + int max_input; + struct vol_ctl *ctl, *parent; + int max_len; if (!ctx->context_ready) return; - sink = g_list_nth_data(ctx->sink_list, ifc->chooser_sink); - if (ifc->chooser_input == (sink_input_len(ctx, sink) - 1) && - ifc->chooser_sink < (gint) g_list_length(ctx->sink_list)-1) { - ++ifc->chooser_sink; - ifc->chooser_input = SELECTED_SINK; - } else if (ifc->chooser_input < (sink_input_len(ctx, sink) - 1)) + max_len = g_list_length(ctx->sink_list) + g_list_length(ctx->source_list); + + ctl = interface_get_current_ctl(&ctx->interface, &parent); + if (parent) + ctl = parent; + + max_input = main_ctl_childs_len(ctx, (struct main_ctl *) ctl) -1; + + if (ifc->chooser_input == max_input) { + if (ifc->chooser_sink < max_len -1) { + ++ifc->chooser_sink; + ifc->chooser_input = SELECTED_SINK; + } + } else if (ifc->chooser_input < max_input) ++ifc->chooser_input; interface_redraw(ifc); |