Ejemplo n.º 1
0
TWindow * podwrite_mh_quit(ttk_menu_item * item)
{
	if (podwrite_filename) {
		free(podwrite_filename);
		podwrite_filename = 0;
	}
	pz_close_window(podwrite_menu->win);
	pz_close_window(podwrite_win);
	return TTK_MENU_DONOTHING;
}
Ejemplo n.º 2
0
static void start_mp3_playback(char *filename)
{
	FILE *file;
	int ret;

	ret = dsp_open(&dspz, DSP_LINEOUT);
	if (ret < 0) {
		pz_perror("/dev/dsp");
		pz_close_window(mp3_wid);
		return;
	}

	do {
		pz_draw_header(_("Buffering..."));
		total_time = remaining_time = next_song_time;
		mp3_do_draw(0);

		file = fopen(filename, "r");
		if (file == 0) {
			pz_close_window(mp3_wid);
			pz_perror(filename);
			dsp_close(&dspz);
			return;
		}

		fseek(file, 0, SEEK_END);
		audiobuf_len = ftell(file);
		audiobufpos = 0;
		audiobuf = malloc(audiobuf_len);
		if (audiobuf == 0) {
			pz_close_window(mp3_wid);
			dsp_close(&dspz);
			fclose(file);

			new_message_window(_("malloc failed"));
			return;
		}

		fseek(file, 0, SEEK_SET);
		fread(audiobuf, audiobuf_len, 1, file);
		fclose(file);

		pz_draw_header(_("MP3 Playback"));

		decode_mp3();

		free(audiobuf);

		filename = next_song;
	}
	while (next_song_queued);

	dsp_close(&dspz);
	pz_close_window(mp3_wid);
}
Ejemplo n.º 3
0
TWindow * podwrite_mh_return(ttk_menu_item * item)
{
	podwrite_mode = 0;
	pz_close_window(podwrite_menu->win);
	ti_widget_start(podwrite_wid);
	return TTK_MENU_DONOTHING;
}
Ejemplo n.º 4
0
/* exit, release all created stuff */
void lights_exit( void ) 
{
	GrDestroyTimer( lights_timer );
	GrDestroyGC( lights_gc );
	pz_close_window( lights_wid );
	GrDestroyWindow( lights_bufwid );
}
Ejemplo n.º 5
0
void new_itunes_track()
{
	currentml = new_ml();
	currentml->get_next = get_next;
	currentml->get_prev = get_prev;
	currentml->get_text = get_text_track;
	currentml->select = select_track;
	currentml->get_track = get_track;

	if ((db_init((void *) draw_itunes_parse) < 0) || !tracks) {
		pz_close_window(currentml->wid);
		free(currentml);
		return;
	}

	printf("tracks->parent: %p\n ", ((struct btree_head *) tracks)->parent);
	currentml->user = (void *) btree_first((struct btree_head *) tracks);
	printf("currentml->prev: %p\n", ((struct btree_head *) currentml->user)->prev);
	printf("currentml name: %s\n", ((struct track *) currentml->user)->name);
	get_prev(currentml);
	printf("currentml->prev: %p\n", ((struct btree_head *) currentml->user)->prev);
	printf("currentml name: %s\n", ((struct track *) currentml->user)->name);

	itunes_draw(currentml);
}
Ejemplo n.º 6
0
static void credits_exit(void)
{
	credits_free_var();
	GrDestroyGC(credits_gc);
	GrDestroyTimer(credits_timer);
	pz_close_window(credits_wid);
}
Ejemplo n.º 7
0
// clean up & quit
static void mandel_quit() {
	int i;
	rendering=0;
	paused=0;
	
	pz_close_window (mandel_wid);
#ifdef MANDELPOD_STATUS
	pz_close_window (status_wid);
#endif
	for (i=0;i<max_depth+1;i++) 
		GrDestroyWindow(level[i].mandel_buffer);
	for (i=0;i<16;i++) 
		GrDestroyWindow(status_image[i]);
	GrDestroyGC(mandel_gc);
	
}
Ejemplo n.º 8
0
void generator_destruct()
{
	if(lookup_table != NULL) 
		free(lookup_table);
	dsp_close(&dspz);
	pz_close_window( generator_wid );
	GrDestroyGC( generator_gc );
}
Ejemplo n.º 9
0
static void decode_mp3()
{
	while (!decoding_finished) {
		mp3_event_handler();
	}

	pz_close_window(mp3_wid);
}
Ejemplo n.º 10
0
/* When pressing menu - quits*/
void do_menu(void)
{
	int i;
	FILE *writefile;

	readint = 0;

	/* Save last board */
	printf("Save last board \n");
	pz_draw_header("Saving board...");
	if ((writefile = fopen(LASTGAME, "w"))) {
		for (i = 0; i < 64; i++) {
			writeint = piece[i];
			fwrite(&writeint,sizeof(writeint),1,writefile);
		}
		for (i = 0; i < 64; i++) {
			writeint = color[i];
			fwrite(&writeint,sizeof(writeint),1,writefile);
		}
		fwrite(&historic_line1, sizeof(historic_line1), 1, writefile);
		fwrite(&historic_line2, sizeof(historic_line2), 1, writefile);
		fwrite(&historic_line3, sizeof(historic_line3), 1, writefile);
		fwrite(&historic_line4, sizeof(historic_line4), 1, writefile);
		fwrite(&historic_line5, sizeof(historic_line5), 1, writefile);
		fwrite(&historic_line6, sizeof(historic_line6), 1, writefile);
		fclose(writefile);
	}
	else {
		printf("Cant write %s\n", LASTGAME);
	}

	if (end == 2) {
		pz_close_window(end_wid);
	}

	if (is_mini) {
		pz_close_window(message_wid);
	}
	else {
		pz_close_window(historic_wid);
	}

	pz_close_window(tuxchess_wid);

	GrDestroyGC(tuxchess_gc);
}
Ejemplo n.º 11
0
int podwrite_save_callback(TWidget * wid, char * fn)
{
	FILE * f;
	pz_close_window(wid->win);
	if (fn[0]) {
		f = fopen(fn, "wb");
		if (!f) {
			pz_error(_("Could not open file for saving."));
			return 0;
		}
		fwrite(podwrite_buf->text, 1, podwrite_buf->usize, f);
		fclose(f);
	}
	podwrite_mode = 0;
	pz_close_window(podwrite_menu->win);
	ti_widget_start(podwrite_wid);
	return 0;
}
Ejemplo n.º 12
0
//Handles input from ipod
static int handle_event(GR_EVENT *event)
{
    switch (event->type)
    {
		case GR_EVENT_TYPE_KEY_UP:
			switch (event->keystroke.ch)
			{

				case 'h': /* Hold switch */
					draw_window();
				break;
			}
		break;

		case GR_EVENT_TYPE_KEY_DOWN:
			switch (event->keystroke.ch)
			{

				case 'h': /* Hold switch */
					draw_help();
				break;

				case 'm': /* Menu button */
					writePot();
					reset();
					pz_close_window (blackjack_wid);

				break;

				case 'l': /* Wheel left */
					dec_bid();
				break;

				case 'r': /* Wheel right */
					inc_bid();
				break;

				case 'w': /* Prev track */
					dec_bid();
				break;

				case 'f': /* Next track */
					inc_bid();
				break;

				case 'd': /* Play */
					play_stay();
				break;

				case '\r': /* Action */
					hit_me();
				break;
			}
		break;
    }
	return 0;
}
Ejemplo n.º 13
0
int tix_mkdir_callback(TWidget * wid, char * fn)
{
	pz_close_window(wid->win);
	if (fn[0]) {
		if (mkdir(fn, 0755)) {
			new_message_window("mkdir call returned error");
		}
	}
	return 0;
}
Ejemplo n.º 14
0
int tix_run_callback(TWidget * wid, char * fn)
{
	TWindow * w;
	pz_close_window(wid->win);
	if (fn[0]) {
		new_exec_window(fn);
	
	}
	return 0;
}
Ejemplo n.º 15
0
static int handle_event(GR_EVENT *event)
{
	int i;
    switch (event->type)
    {
		case GR_EVENT_TYPE_KEY_DOWN:
			switch (event->keystroke.ch)
			{
				case 'm': /* Menu button */
					pz_close_window (tictactoe_wid);
					break;
					
				case 'l': 
					if (gameRunning == 1) {
						for (i = currSquare - 1; board[i] != '-' && i != currSquare; i--)
							if (i <= -1)
								i = 9;
						if (board[currSquare] == '-')
							drawXO(currSquare, WHITE, 'x');
						drawXO(i, GRAY, 'x');
						currSquare = i;
					}
					break;	
				case 'r': 
					if (gameRunning == 1) {
						for (i = currSquare + 1; board[i] != '-' && i != currSquare; i++)
							if (i >= 9)
								i = -1;
						if (board[currSquare] == '-')
							drawXO(currSquare, WHITE, 'x');
						drawXO(i, GRAY, 'x');
						currSquare = i;
					}
					break;						
				case 'f':
					reset_board();
					break;	
				case 'w':
					if (!gameRunning)
						reset_board();
					break;
				case '\r':
					if (gameRunning)
						playerMadeMove(currSquare);
					else
						reset_board();
					break;
				default:
					break;
			}
			break; 
    }
	return 0;
}
Ejemplo n.º 16
0
static void msg_destroy_msg()
{
	int i;

	pz_close_window(msg_wid);
	GrDestroyGC(msg_gc);
	GrDestroyTimer(msg_timer);
	for(i = linenum; i; i--)
		free(msglines[i-1]);
	free(msglines);
}
Ejemplo n.º 17
0
int tix_rename_callback(TWidget * wid, char * fn)
{
	pz_close_window(wid->win);
	if (fn[0]) {
		if (rename(tix_rename_oldname, fn)) {
			new_message_window("rename call returned error");
		}
	}
	free(tix_rename_oldname);
	return 0;
}
Ejemplo n.º 18
0
int event_remote_ipod_widget (PzEvent *ev) {
    switch (ev->type) {
    	case PZ_EVENT_BUTTON_UP:
			pz_close_window (ev->wid->win);
			break;
    	case PZ_EVENT_DESTROY:
		//	ttk_free_surface (image);
		//	free (text);
			break;
    }
    return 0;
}
Ejemplo n.º 19
0
// Handles timer/key events.
static int handle_event(GR_EVENT *event)
{
    switch (event->type)
    {
		case GR_EVENT_TYPE_TIMER:
			if (running && !hold) 
				advance_and_check();
			break;
		case GR_EVENT_TYPE_KEY_DOWN:
			switch (event->keystroke.ch)
			{
				case 'm': // Menu button.
					GrDestroyTimer( timer_id );
					writeHighScore();
					pz_close_window (tunnel_wid);
					break;
				case 'w': // rewind button
				case 'l': // scroll wheel left
					if (running && ball.radius < ball.x)
						ball.x -= 2;
					break;	
				case 'f': // fast forward button
				case 'r': // scroll wheel right
					if (running && wi.width - 2 - ball.radius  > ball.x)
						ball.x += 2;
					break;						
				case 'd': // play button. Who decided to make it d!
					if (running == 0)
						running = 1;
					else
						reset();
					break;
				case 'h': // Hold button
					hold = 1;
					break;					
				default:
					break;
			}
			break; 
		case GR_EVENT_TYPE_KEY_UP:
			switch( event->keystroke.ch )
			{
				case 'h': // Hold button
					hold = 0;
					break;
			}
			break;
		default:
			break;
    }
	return 0;
}
Ejemplo n.º 20
0
int event_mymodule (PzEvent *ev) 
{
    switch (ev->type) {
    case PZ_EVENT_BUTTON_UP:
	pz_close_window (ev->wid->win);
	break;
    case PZ_EVENT_DESTROY:
	ttk_free_surface (image);
	free (text);
	break;
    }
    return 0;
}
Ejemplo n.º 21
0
static int pz_set_header(TWidget * wid, char * txt)
{
        int reboot = pz_dialog(_("Reboot"), 
              _("Header Name have been saved, Need to reboot to take effect"), 2, 0, _("ok"), _("Reboot"));
        pz_set_string_setting (pz_global_config, HEADERNAME, txt);
        pz_save_config(pz_global_config);

        if (reboot)
            pz_ipod_reboot();
           
        pz_close_window(wid->win);
        return 0;
}
Ejemplo n.º 22
0
static int dialer_do_keystroke(GR_EVENT * event) {
    int ret = 0;

    switch(event->type) {
    case GR_EVENT_TYPE_KEY_DOWN:
        switch (event->keystroke.ch) {
        case IPOD_BUTTON_ACTION:
            dialer_press_button(current_dialer_button);
            draw_dialer();
            ret |= KEY_CLICK;
            break;

        case IPOD_WHEEL_ANTICLOCKWISE:
            last_bouvet_item = current_dialer_button;
            current_dialer_button--;
            draw_dialer();
            ret |= KEY_CLICK;
            break;

        case IPOD_WHEEL_CLOCKWISE:
            last_bouvet_item = current_dialer_button;
            current_dialer_button++;
            draw_dialer();
            ret |= KEY_CLICK;
            break;

        case IPOD_BUTTON_MENU:
        case 'q':
#ifdef __linux__
            dsp_close(&dspz);
#endif
            GrDestroyGC(dialer_gc);
            pz_close_window(dialer_wid);
            ret |= KEY_CLICK;
            break;

        default:
            ret |= KEY_UNUSED;
            break;
        }
        break;

    default:
        ret |= EVENT_UNUSED;
        break;
    }
    return ret;
}
Ejemplo n.º 23
0
static int itunes_do_keystroke(GR_EVENT * event)
{
	int ret = 0;
	struct menulist *oldml;

	switch (event->type) {
	case GR_EVENT_TYPE_TIMER:
		menu_draw_timer(currentml->itunes_menu);
		break;
	case GR_EVENT_TYPE_KEY_DOWN:
		switch (event->keystroke.ch) {
		case '\r':		/* action key */
		case '\n':
			currentml->select(currentml);
			break;

		case 'm':		/* menu key */
			ret = 1;
			pz_close_window(currentml->wid);
			oldml = currentml;
			currentml->itunes_menu = menu_destroy(currentml->itunes_menu);
			currentml = currentml->prevml;
			free(oldml);
			if (currentml) itunes_draw(currentml);
			break;

		case 'r':
			if(currentml->get_next(currentml))
			{
				menu_shift_selected(currentml->itunes_menu, 1);
				itunes_do_draw();
				ret |= KEY_CLICK;
			}
			break;

		case 'l':
			if(currentml->get_prev(currentml))
			{
				menu_shift_selected(currentml->itunes_menu, -1);
				itunes_do_draw();
				ret |= KEY_CLICK;
			}
			break;
		}
		break;
	}
	return ret;
}
Ejemplo n.º 24
0
void new_itunes_artist()
{
	currentml = new_ml();
	currentml->get_next = get_next;
	currentml->get_prev = get_prev;
	currentml->get_text = get_text_artist;
	currentml->select = select_artist;

	if ((db_init((void *) draw_itunes_parse) < 0) || !artists) {
		pz_close_window(currentml->wid);
		free(currentml);
		return;
	}
	currentml->user = (void *) btree_first((struct btree_head *) artists);

	itunes_draw(currentml);
}
Ejemplo n.º 25
0
/* Set up a new game */
void new_game()
{
	end = 0;
	pz_close_window(end_wid);
	init();
	gen_moves();
	max_time = 100000;//1 << 25;
	max_depth = 1;

	init_historic();
	print_board();
	if (!is_mini) {
		draw_historic();
	}
	else {
		draw_message("", "");
	}
}
Ejemplo n.º 26
0
// Resets the game.
static void reset()
{
	if (running == 1)
		GrDestroyTimer( timer_id );
	reset_chasm_queue(&head, &middle, &tail);
	if(new_chasm_queue((wi.width - chasmWidth) / 2, wi.height / 2, &head, &middle, &tail) == -1)
	{
		pz_error("Error making queue.");
		pz_close_window (tunnel_wid);
		return;
	}
	score = 0;
	running = 0;
	ball.radius = ballRadius;
	ball.x = wi.width / 2;
	timer_id = GrCreateTimer(tunnel_wid, timerSpeed); 
	advance_and_check();
}
Ejemplo n.º 27
0
int periodic_handle_event(GR_EVENT * event)
{
	if (event->type == GR_EVENT_TYPE_KEY_DOWN) {
		switch (event->keystroke.ch) {
		case 'l':
			if (periodic_sel > 0) {
				periodic_sel--;
			} else {
				periodic_sel = 117;
			}
			periodic_draw();
			break;
		case 'r':
			if (periodic_sel < 117) {
				periodic_sel++;
			} else {
				periodic_sel = 0;
			}
			periodic_draw();
			break;
		case '\n':
		case '\r':
			periodic_element_info(periodic_sel);
			break;
		case 'm':
		case 'q':
			pz_close_window(periodic_wid);
			GrDestroyWindow(periodic_bufwid);
			GrDestroyGC(periodic_gc);
			break;
		default:
			return 0;
			break;
		}
		return 1;
	} else {
		return 0;
	}
}
Ejemplo n.º 28
0
static int chopHandleEvent (GR_EVENT *event)
{
    switch (event->type)
    {
    case GR_EVENT_TYPE_TIMER:
        chopGameLoop();
        break;
	
	case GR_EVENT_TYPE_KEY_UP:
	if(event->keystroke.ch == '\r')
		bPlayerPressingUp = 0;
		break;

    case GR_EVENT_TYPE_KEY_DOWN:
    	if(bWaitingToStart == 1)
	{
	
	iPlayerSpeedY = 5;
    	bWaitingToStart = 0;
	
	}
        switch (event->keystroke.ch)
        {
        case '\r': /* Wheel button */
            bPlayerPressingUp = 1;
	    break;
         case 'm': /* Menu button */
            pz_close_window (chopWindow);
            GrDestroyTimer (chopTimer);
            GrDestroyGC(chopGC);
            break;
        default:
            break;
        }
        break;   /* key down */
    }
    return 1;
}
Ejemplo n.º 29
0
static int piezomaker_save_callback(TWidget *swid, char *filename)
{
    int i;
    FILE *fp;

    pz_close_window(swid->win);

    fp = fopen(filename, "w");
    if(!fp) {
        pz_error(_("Could not save file."));
        return 0;
    }
    fprintf(fp, "#PZM\n#%.2f seconds\n#generated by piezomaker/podzilla\n", piezomaker_seconds());
    fprintf(fp, "%d\n", size);
    for(i=0; i<size; i++) {
        fprintf(fp, "%d\n%d\n", *(period+i), *(duration+i));
    }
    fclose(fp);

    free(period);
    free(duration);

    return 0;
}
Ejemplo n.º 30
0
static int poddraw_handle_event(GR_EVENT * event)
{
	int ret = 0;
	switch( event->type )
	{
	case( GR_EVENT_TYPE_TIMER ):
		poddraw_cycle_point();
		break;
	    
	case( GR_EVENT_TYPE_KEY_DOWN ):
		switch( event->keystroke.ch )
		{
		    case IPOD_BUTTON_ACTION: /* action */
			    // toggle lr-ud
			    updown = (updown + 1) & 0x01;
			    break;

		    case IPOD_BUTTON_PLAY: /* play/pause */
			    // clear screen
			    poddraw_cls();
			    break;

		    case IPOD_BUTTON_FORWARD: /* >>| */
			    poddraw_color = (poddraw_color +1 ) & 
				(( screen_info.bpp == 16 )?0x0f:0x03);
			    poddraw_draw_box( colors[poddraw_color], 0, 0 );
			    break;

		    case IPOD_BUTTON_REWIND: /* |<< */
			    poddraw_color = (poddraw_color -1 ) & 
				(( screen_info.bpp == 16 )?0x0f:0x03);
			    poddraw_draw_box( colors[poddraw_color], 0, 0 );
			    break;

		    case IPOD_WHEEL_ANTICLOCKWISE: /* CCW spin */
			    poddraw_place_point( poddraw_color );
			    if( updown ) poddraw_x = PDMAX( poddraw_x-2, 0 );
			    else         poddraw_y = PDMAX( poddraw_y-2, 0 );
			    break;

		    case IPOD_WHEEL_CLOCKWISE: /* CW spin */
			    poddraw_place_point( poddraw_color );
			    if( updown )
				poddraw_x = PDMIN( poddraw_x+2, 
						    screen_info.cols-2 );
			    else
				poddraw_y = PDMIN( poddraw_y+2, 
					  (screen_info.rows - 
						(HEADER_TOPLINE + 1))-2);
			break;

		    case IPOD_BUTTON_MENU:
		    case ('q'):
			    poddraw_save();
			    GrDestroyTimer( poddraw_timer );
			    pz_close_window( poddraw_wid );
			    poddraw_free_buffer();
			    ret = 1;
			    break;

		    default:
			    ret |= EVENT_UNUSED;
			    break;
		}
		break;
	}
	return ret;
}