add functions for moving channel groups up and down in list

This commit is contained in:
Andreas Öman 2007-12-02 17:21:12 +00:00
parent f92bfeaf8a
commit 5e499423f8
4 changed files with 60 additions and 13 deletions

View file

@ -100,7 +100,7 @@ avgen_init(void)
if(avcodec_find_encoder(CODEC_ID_MP2) == NULL)
return;
ch = channel_find("Test 1", 1, NULL);
ch = channel_find("Test 1", 1, channel_group_find("Test channels", 1));
t = calloc(1, sizeof(th_transport_t));
t->tht_prio = 100;

View file

@ -356,6 +356,33 @@ channel_group_by_tag(uint32_t tag)
return NULL;
}
void
channel_group_move_next(th_channel_group_t *tcg)
{
th_channel_group_t *n = TAILQ_NEXT(tcg, tcg_global_link);
if(n == NULL)
return;
TAILQ_REMOVE(&all_channel_groups, tcg, tcg_global_link);
TAILQ_INSERT_AFTER(&all_channel_groups, n, tcg, tcg_global_link);
channel_settings_write();
}
void
channel_group_move_prev(th_channel_group_t *tcg)
{
th_channel_group_t *p = TAILQ_PREV(tcg, th_channel_group_queue,
tcg_global_link);
if(p == NULL)
return;
TAILQ_REMOVE(&all_channel_groups, tcg, tcg_global_link);
TAILQ_INSERT_BEFORE(p, tcg, tcg_global_link);
channel_settings_write();
}
/**
*
*/

View file

@ -40,5 +40,10 @@ th_channel_group_t *channel_group_by_tag(uint32_t tag);
void channel_group_destroy(th_channel_group_t *tcg);
void channel_group_move_prev(th_channel_group_t *tcg);
void channel_group_move_next(th_channel_group_t *tcg);
void channel_settings_write(void);
#endif /* CHANNELS_H */

View file

@ -1238,14 +1238,25 @@ page_chgroups(http_connection_t *hc, const char *remain, void *opaque)
channel_group_find(grp, 1);
LIST_FOREACH(ra, &hc->hc_url_args, link) {
if(!strncmp(ra->key, "delgroup", 8))
if(!strncmp(ra->key, "delgroup", 8)) {
tcg = channel_group_by_tag(atoi(ra->key + 8));
if(tcg != NULL)
channel_group_destroy(tcg);
break;
}
}
if(ra != NULL) {
tcg = channel_group_by_tag(atoi(ra->key + 8));
if(tcg != NULL) {
channel_group_destroy(tcg);
if(!strncmp(ra->key, "up", 2)) {
tcg = channel_group_by_tag(atoi(ra->key + 2));
if(tcg != NULL)
channel_group_move_prev(tcg);
break;
}
if(!strncmp(ra->key, "down", 4)) {
tcg = channel_group_by_tag(atoi(ra->key + 4));
if(tcg != NULL)
channel_group_move_next(tcg);
break;
}
}
@ -1266,19 +1277,25 @@ page_chgroups(http_connection_t *hc, const char *remain, void *opaque)
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link)
cnt++;
tcp_qprintf(&tq, "<b>%s</b> (%d channels)<br>", tcg->tcg_name, cnt);
tcp_qprintf(&tq, "<b>%s</b> (%d channels)<br><br>", tcg->tcg_name, cnt);
tcp_qprintf(&tq,
"<input type=\"submit\" name=\"up%d\""
" value=\"Move up\"> ", tcg->tcg_tag);
tcp_qprintf(&tq,
"<input type=\"submit\" name=\"down%d\""
" value=\"Move down\"> ", tcg->tcg_tag);
if(tcg->tcg_cant_delete_me == 0) {
tcp_qprintf(&tq,
"<input type=\"submit\" name=\"delgroup%d\""
" value=\"Delete this group\">"
"</div>", tcg->tcg_tag);
" value=\"Delete this group\">", tcg->tcg_tag);
}
tcp_qprintf(&tq, "</div>");
box_bottom(&tq);
tcp_qprintf(&tq, "</form><br>\r\n");
}
@ -1294,8 +1311,6 @@ page_chgroups(http_connection_t *hc, const char *remain, void *opaque)
box_bottom(&tq);
tcp_qprintf(&tq, "</form><br>\r\n");
http_output_queue(hc, &tq, "text/html; charset=UTF-8");
return 0;
}