示例#1
0
static int e_player_status(GtkWidget *widget, GdkEventButton *event, void *data)
{
	if(player_toggle() < 0)
	{
		return TRUE;
	}

	ui_update(NULL);

	return TRUE;
}
示例#2
0
文件: frontend.c 项目: jgreco/bnxc
/* the menu logic for the ncurses interface, much simpler than it looks...
 */
void ninterface()
{
	menu_parameters artists_menu, albums_menu, tracks_menu;

	char *sections[] = {"Artists", "Albums", "Tracks" };  /* Section titles, used in the menu */

	artist art;
	album alb;
	track song;
	list np;

	int art_choice, alb_choice, trak_choice;

	/* ---===[ ARTISTS MENU ]===--- */
	artists_menu = (menu_parameters)malloc(sizeof(struct menu_parameters_str));
	artists_menu->list = get_artist_list();
	artists_menu->list_len = num_artists;
	artists_menu->title = "Artists:";
	artists_menu->sections = sections;
	artists_menu->num_sections = 3;
	artists_menu->curr_section = 1;
	artists_menu->commands = COMMANDS;
	artists_menu->select = 0;
	artists_menu->scroll = 0;
	artists_menu->height = LINES;
	artists_menu->width = COLS;

	while(1) {
		art_choice = nmenu(artists_menu);  /* draw artist menu */
		artists_menu->select = art_choice;

		if(artists_menu->entered == QUIT_BACK)  /* exit artist menu (and function) */
			break;
		else if(artists_menu->entered == APPEND_PLAYLIST || artists_menu->entered == REPLACE_PLAYLIST) {  /* play an artist (XMMS2) */
			if(artists_menu->entered == REPLACE_PLAYLIST) {
				player_stop();
				player_clear_playlist();
			}

			art = ((artist)(lookup(artists_menu->list[art_choice])->contents));

			player_add_artist(art);

			player_play();
		} else if(artists_menu->entered == TOGGLE_PLAY_PAUSE) {
			player_toggle();
		} else if(artists_menu->entered == NOWPLAYING) {
			now_playing();
		} else if(artists_menu->entered == NEXT) {
			player_next();
		} else if(artists_menu->entered == PREVIOUS) {
			player_previous();
		}

		/* ---===[ ALBUMS MENU ]===--- */
		else if(artists_menu->entered == '\n') { /* enter this menu */
			art = ((artist)(lookup(artists_menu->list[art_choice])->contents));

			albums_menu = (menu_parameters)malloc(sizeof(struct menu_parameters_str));
			albums_menu->list = get_album_list(art);
			albums_menu->list_len = art->num_albums;
			albums_menu->title = art->name;
			albums_menu->sections = sections;
			albums_menu->num_sections = 3;
			albums_menu->curr_section = 2;
			albums_menu->commands = COMMANDS;
			albums_menu->select = 0;
			albums_menu->scroll = 0;
			albums_menu->height = LINES;
			albums_menu->width = COLS;

			while(1) {
				alb_choice = nmenu(albums_menu);  /* draw album menu */

				if(albums_menu->entered == KEY_LEFT || albums_menu->entered == QUIT_BACK) /* exit albums menu */
					break;
				else if(albums_menu->entered == APPEND_PLAYLIST || albums_menu->entered == REPLACE_PLAYLIST)  {  /* play an album (XMMS2) */
					if(albums_menu->entered == REPLACE_PLAYLIST) {
						player_stop();
						player_clear_playlist();
					}


					for(np = art->albums; np != NULL; np = np->next)
						if(strcmp(albums_menu->list[alb_choice], np->name) == 0)
							break;

					alb = (album)np->contents;


					player_add_album(alb);
					player_play();
				} else if(albums_menu->entered == TOGGLE_PLAY_PAUSE) {
					player_toggle();
				} else if(albums_menu->entered == NOWPLAYING) {
					now_playing();
				} else if(albums_menu->entered == NEXT) {
					player_next();
				} else if(albums_menu->entered == PREVIOUS) {
					player_previous();
				}

				/* ---===[ TRACKS MENU ]===--- */
				else if(albums_menu->entered == '\n') { /* enter this menu */
					for(np = art->albums; np != NULL; np = np->next)
						if(strcmp(albums_menu->list[alb_choice], np->name) == 0)
							break;

					alb = (album)np->contents;

					tracks_menu = (menu_parameters)malloc(sizeof(struct menu_parameters_str));
					tracks_menu->list = get_track_list(alb);
					tracks_menu->list_len = alb->num_songs;
					tracks_menu->title = alb->name;
					tracks_menu->sections = sections;
					tracks_menu->num_sections = 3;
					tracks_menu->curr_section = 3;
					tracks_menu->commands = COMMANDS;
					tracks_menu->select = 0;
					tracks_menu->scroll = 0;
					tracks_menu->height = LINES;
					tracks_menu->width = COLS;

					while(1) {
						trak_choice = nmenu(tracks_menu);  /* draw track menu */

						/* play a track (XMMS2) */
						if(tracks_menu->entered == APPEND_PLAYLIST || tracks_menu->entered == REPLACE_PLAYLIST) {  /* play a track (XMMS2) */
							if(tracks_menu->entered == REPLACE_PLAYLIST) {
								player_stop();
								player_clear_playlist();
							}

							for(song = alb->songs; song != NULL; song = song->next)
								if(strcmp(tracks_menu->list[trak_choice], song->name) == 0)
									break;

							player_add_track(song);
							player_play();
						} else if(tracks_menu->entered == TOGGLE_PLAY_PAUSE) {
							player_toggle();
						} else if(tracks_menu->entered == NOWPLAYING) {
							now_playing();
						} else if(tracks_menu->entered == KEY_LEFT || tracks_menu->entered == QUIT_BACK) { /* exit tracks menu */
							break;
						} else if(tracks_menu->entered == NEXT) {
							player_next();
						} else if(tracks_menu->entered == PREVIOUS) {
							player_previous();
						}
					} /* drop out of tracks here */

					destroy_menu_params(tracks_menu);
				}
			} /* drop out of albums here */

			destroy_menu_params(albums_menu);
		 }
	} /* drop out of artists here */

	destroy_menu_params(artists_menu);

	return;
}