diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-19 11:21:05 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-19 11:21:48 +0100 |
commit | 8214988ef3d74945b440895615eca06df4cae61c (patch) | |
tree | 65291ea45dca3a28af08f6dc24023145ff4a275c | |
parent | ef40d1a710228fbef322414c1400dfa922d082f5 (diff) | |
download | pa-sink-ctl-8214988ef3d74945b440895615eca06df4cae61c.tar.gz pa-sink-ctl-8214988ef3d74945b440895615eca06df4cae61c.tar.bz2 pa-sink-ctl-8214988ef3d74945b440895615eca06df4cae61c.zip |
command: Put main ctl length logic into interface.c
-rw-r--r-- | src/command.c | 7 | ||||
-rw-r--r-- | src/interface.c | 8 | ||||
-rw-r--r-- | src/interface.h | 3 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/command.c b/src/command.c index 9b9116a..f16e0b0 100644 --- a/src/command.c +++ b/src/command.c @@ -54,21 +54,18 @@ down(struct context *ctx, int key) struct interface *ifc = &ctx->interface; int max_ctl_childs; struct vol_ctl *ctl, *parent; - int max_len; if (!ctx->context_ready) return; - 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_ctl_childs = ctl->childs_len(ctl) -1; - if (ifc->chooser_child == max_ctl_childs) { - if (ifc->chooser_main_ctl < max_len -1) { + if (ifc->chooser_main_ctl < + interface_get_main_ctl_length(ifc) -1) { ++ifc->chooser_main_ctl; ifc->chooser_child = SELECTED_MAIN_CTL; } diff --git a/src/interface.c b/src/interface.c index d4b65e7..8c39e06 100644 --- a/src/interface.c +++ b/src/interface.c @@ -190,6 +190,14 @@ interface_redraw(struct interface *ifc) wrefresh(ifc->menu_win); } +int +interface_get_main_ctl_length(struct interface *ifc) +{ + struct context *ctx = container_of(ifc, struct context, interface); + + return g_list_length(ctx->sink_list) + g_list_length(ctx->source_list); +} + static gboolean interface_get_input(GIOChannel *source, GIOCondition condition, gpointer data) { diff --git a/src/interface.h b/src/interface.h index 5b3ebf8..c177c15 100644 --- a/src/interface.h +++ b/src/interface.h @@ -50,6 +50,9 @@ struct interface { struct vol_ctl * interface_get_current_ctl(struct interface *ifc, struct vol_ctl **parent); +int +interface_get_main_ctl_length(struct interface *ifc); + void interface_redraw(struct interface *ifc); |