예제 #1
0
static menu_st *menu_right_transition(menu_st *menulist, item_st *item)
{
	menu_st *m;
	int i, jump;

	GrCopyArea(menulist->transition, menulist->menu_gc, 0, 0,
			menulist->w, menulist->h, menulist->menu_wid,
			menulist->x, menulist->y, 0);
	m = menu_init(menulist->transition, item->text,
			menulist->w, 0, menulist->w, menulist->h,
			menulist, (item_st *)item->action, menulist->op);
	menu_draw(m);

	m->menu_wid = menulist->menu_wid;
	m->x = menulist->x;
	m->y = menulist->y;

	jump = (ipod_get_setting(SLIDE_TRANSIT)) ?
		menulist->w / TRANSITION_STEPS : 0;
	for (i = 0; i < TRANSITION_STEPS; i++) {
		GrCopyArea(menulist->menu_wid, menulist->menu_gc,
				menulist->x, menulist->y, menulist->w,
				menulist->h, menulist->transition,
				(i + 1) * jump, 0, 0);
	}
	return m;
}
예제 #2
0
static void menu_left_transition(menu_st *menulist)
{
	menu_st *m;
	int i, jump;

	m = menulist->parent;
	GrCopyArea(m->transition, menulist->menu_gc, m->w, 0,
			menulist->w, menulist->h, menulist->menu_wid,
			menulist->x, menulist->y, 0);

	if (m->scheme_no != appearance_get_color_scheme()) {
		m->menu_wid = m->transition;
		m->x = 0;
		m->y = 0;

		menu_draw(m);

		m->menu_wid = menulist->menu_wid;
		m->x = menulist->x;
		m->y = menulist->y;
	}
	
	jump = (ipod_get_setting(SLIDE_TRANSIT)) ?
		m->w / TRANSITION_STEPS : 0;
	for (i = TRANSITION_STEPS; i; i--) {
		GrCopyArea(menulist->menu_wid, menulist->menu_gc,
				menulist->x, menulist->y, menulist->w,
				menulist->h, m->transition,
				i * jump, 0, 0);
	}
}
예제 #3
0
/* this sets up the tables and such.  Eventually this might load in files */
void appearance_init( void )
{
	int reqscheme = ipod_get_setting( COLORSCHEME );

	if( screen_info.bpp < 16 ) {
	   	colorscheme_max = CS_MONO_LAST;
		decorations_max = NDEC_MONO_LAST;
	}

	if( reqscheme > colorscheme_max ) reqscheme = 0;
	appearance_set_color_scheme( reqscheme );
	appearance_set_decorations( ipod_get_setting( DECORATIONS ));

	/* and now some magic twiddling to tweak the menus... */
	menu_adjust_nschemes( colorscheme_max+1 );
	menu_adjust_ndecorations( decorations_max );
}
예제 #4
0
static int menu_get_setting (ttk_menu_item *item, int cdata) 
{
    int ret = ipod_get_setting (cdata);
    if (ret > item->nchoices) {
	fprintf (stderr, "Warning! Setting %d set to %d on a %d scale - using 0\n", cdata, ret, item->nchoices);
	ret = 0;
    }
    return ret;
}
예제 #5
0
static void browser_do_draw()
{
	/* window is focused */
	if(browser_wid == GrGetFocus()) {
		if( ipod_get_setting( BROWSER_PATH ))
			pz_draw_header(browser_shorten_path());
		else
			pz_draw_header(browser_menu->title);
		menu_draw(browser_menu);
	}
}
예제 #6
0
/* the directory to scan */
static void browser_mscandir(char *dira)
{
	DIR *dir = opendir(dira);
	int i, size, op;
	struct stat stat_result;
	struct dirent *subdir;

	if(browser_menu != NULL) {
		menu_destroy(browser_menu);
	}
	browser_menu = menu_init(browser_wid, _("File Browser"), 0, 0,
			screen_info.cols, screen_info.rows -
			(HEADER_TOPLINE + 1), NULL, NULL, ASCII);

	/* not very good for fragmentation... */
	for (i = 0; i < browser_nbEntries; i++) {
		free(browser_entries[i].full_name);
	}
	browser_nbEntries = 0;

	while ((subdir = readdir(dir))) {
		if(strncmp(subdir->d_name, ".", strlen(subdir->d_name)) == 0) {
			continue;
		}
		if(strncmp(subdir->d_name, "..", strlen(subdir->d_name)) == 0) {
			strcpy(browser_entries[browser_nbEntries].name,
				_(".. [Parent Directory]"));
			browser_entries[browser_nbEntries].full_name =
				strdup(browser_entries[browser_nbEntries].name);
			browser_entries[browser_nbEntries].type =
				FILE_TYPE_DIRECTORY;
			browser_entries[browser_nbEntries].op = STUB_MENU;
			browser_nbEntries++;
			continue;
		}
		if(!ipod_get_setting(BROWSER_HIDDEN)) {
			if (subdir->d_name[0] == '.') {
				continue;
			}
		}
		if(browser_nbEntries >= MAX_ENTRIES) {
			pz_error(_("Directory contains too many files."));
			break;
		}
		
		size = strlen(subdir->d_name);
		size = (size > 62 ? 62 : size);
		browser_entries[browser_nbEntries].full_name =
			strdup(subdir->d_name);

		strncpy(browser_entries[browser_nbEntries].name,
				subdir->d_name, size);
		browser_entries[browser_nbEntries].name[size] = '\0';

		stat(subdir->d_name, &stat_result);
		if(S_ISDIR(stat_result.st_mode)) {
			browser_entries[browser_nbEntries].type =
			    FILE_TYPE_DIRECTORY;
			op = ARROW_MENU;
		}
		else if(stat_result.st_mode & S_IXUSR) {
			browser_entries[browser_nbEntries].type =
			    FILE_TYPE_PROGRAM;
			op = EXECUTE_MENU;
		}
		else {
			browser_entries[browser_nbEntries].type =
				FILE_TYPE_OTHER;
			op = STUB_MENU;
		}
		browser_entries[browser_nbEntries].op = op;

		browser_nbEntries++;
	}
	closedir(dir);

	qsort(browser_entries, browser_nbEntries, sizeof(Directory), dir_cmp);
	for (i = 0; i < browser_nbEntries; i++)
		menu_add_item(browser_menu, browser_entries[i].name,
				NULL, 0, browser_entries[i].op);
}
예제 #7
0
ttk_surface iconui_get_icon(char * name)
{
	static int mnt_na = 1; /* 1 - unchecked, 0 - not accessible, 2 - accessible */
	static int hp_na = 1;
	static int share_na = 1;
	static int icons_na = 1;
#ifdef NEVER
	static int cs_na = 1;
	static int epoch = 0;
#endif
	char path[256];
	char * s = iconui_munge(name);
	int iconcache = ipod_get_setting((76));
	ttk_surface iconsrf;
#ifdef NEVER
	if (ttk_epoch > epoch) {
		cs_na = 1;
		epoch = ttk_epoch;
	}
#endif
	if (iconcache && (iconsrf = iconui_cache_get(s))) {
		return iconsrf;
	}
#ifdef NEVER
	if (cs_na) {
		char * p = realpath(COLOR_SCHEME_PATH, path);
		if (!p) {
			cs_na = 0;
		} else {
			path[strlen(path)-3] = 0;
			strcat(path, "-icons/");
			if (cs_na == 1 && access(path, R_OK)) {
				cs_na = 0;
			} else {
				cs_na = 2;
				strcat(path, s);
				strcat(path, ".png");
				if (!access(path, R_OK)) {
					if (iconcache) {
						iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
					} else {
						iconsrf = ttk_load_image((const char *)path);
					}
					free(s);
					return iconsrf;
				}
			}
		}
	}
#endif
	if (mnt_na) {
		strcpy(path, "/mnt/icons/");
		if (mnt_na == 1 && access(path, R_OK)) {
			mnt_na = 0;
		} else {
			mnt_na = 2;
			strcat(path, s);
			strcat(path, ".png");
			if (!access(path, R_OK)) {
				if (iconcache) {
					iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
				} else {
					iconsrf = ttk_load_image((const char *)path);
				}
				free(s);
				return iconsrf;
			}
		}
	}
	if (hp_na) {
		strcpy(path, "/hp/icons/");
		if (hp_na == 1 && access(path, R_OK)) {
			hp_na = 0;
		} else {
			hp_na = 2;
			strcat(path, s);
			strcat(path, ".png");
			if (!access(path, R_OK)) {
				if (iconcache) {
					iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
				} else {
					iconsrf = ttk_load_image((const char *)path);
				}
				free(s);
				return iconsrf;
			}
		}
	}
	if (share_na) {
		strcpy(path, "/usr/share/icons/");
		if (share_na == 1 && access(path, R_OK)) {
			share_na = 0;
		} else {
			share_na = 2;
			strcat(path, s);
			strcat(path, ".png");
			if (!access(path, R_OK)) {
				if (iconcache) {
					iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
				} else {
					iconsrf = ttk_load_image((const char *)path);
				}
				free(s);
				return iconsrf;
			}
		}
	}
	if (icons_na) {
		strcpy(path, "/mnt/aj/icons/");
		if (icons_na == 1 && access(path, R_OK)) {
			icons_na = 0;
		} else {
			icons_na = 2;
			strcat(path, s);
			strcat(path, ".png");
			if (!access(path, R_OK)) {
				if (iconcache) {
					iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
				} else {
					iconsrf = ttk_load_image((const char *)path);
				}
				free(s);
				return iconsrf;
			}
		}
	}
	sprintf(path,"/mnt/aj/icons/%c", s);
	strcat(path, ".png");
	if (!access(path, R_OK)) {
		if (iconcache) {
			iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
		} else {
			iconsrf = ttk_load_image((const char *)path);
		}
		free(s);
		return iconsrf;
	}
#ifdef NEVER
	if (cs_na) {
		char * p = realpath(COLOR_SCHEME_PATH, path);
		if (p) {
			path[strlen(path)-3] = 0;
			strcat(path, "-icons/Default.png");
			if (!access(path, R_OK)) {
				if (iconcache) {
					iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
				} else {
					iconsrf = ttk_load_image((const char *)path);
				}
				free(s);
				return iconsrf;
			}
		}
	}
#endif
	if (mnt_na) {
		strcpy(path, "/mnt/icons/Default.png");
		if (!access(path, R_OK)) {
			if (iconcache) {
				iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
			} else {
				iconsrf = ttk_load_image((const char *)path);
			}
			free(s);
			return iconsrf;
		}
	}
	if (hp_na) {
		strcpy(path, "/hp/icons/Default.png");
		if (!access(path, R_OK)) {
			if (iconcache) {
				iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
			} else {
				iconsrf = ttk_load_image((const char *)path);
			}
			free(s);
			return iconsrf;
		}
	}
	if (share_na) {
		strcpy(path, "/usr/share/icons/Default.png");
		if (!access(path, R_OK)) {
			if (iconcache) {
				iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
			} else {
				iconsrf = ttk_load_image((const char *)path);
			}
			free(s);
			return iconsrf;
		}
	}
	if (icons_na) {
		sprintf(path, "/mnt/aj/icons/Default.png");
		if (!access(path, R_OK)) {
			if (iconcache) {
				iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
			} else {
				iconsrf = ttk_load_image((const char *)path);
			}
			free(s);
			return iconsrf;
		}
	}
	strcpy(path, "/mnt/aj/icons/Default.png");
	if (!access(path, R_OK)) {
		if (iconcache) {
			iconsrf = iconui_cache_set(s, ttk_load_image((const char *)path) );
		} else {
			iconsrf = ttk_load_image((const char *)path);
		}
		free(s);
		return iconsrf;
	}
	free(s);
	return ttk_new_surface(32, 32, ttk_screen->bpp);
}
예제 #8
0
/* simply erases and redoes the text on the pixmap */
void menu_retext_pixmap(menu_st *menulist, int pixmap, item_st *item)
{
	int op;
	char *text;

	if(pixmap < 0 || pixmap > menulist->screen_items - 1) {
		Dprintf("menu_retext_pixmap::No Such Pixmap\n");
		return;
	}
	if(item < 0) {
		Dprintf("menu_retext_pixmap::Item non-existent\n");
		return;
	}

	text = (TRANSLATE & menulist->op) ? gettext(item->text) : item->text;

	/* set the bit for a checked long item */
	if(!(LONG_ITEM & item->op)) {
		GR_SIZE width, height, base;
		GrGetGCTextSize(menulist->menu_gc, text, -1, GR_TFASCII,
				&width, &height, &base);
		item->text_width = width;

		item->op |= LONG_ITEM; 
	}

	menu_clear_pixmap(menulist, pixmap);

	if (UTF8 & menulist->op)
		op = GR_TFUTF8;
	else if (UC16 & menulist->op)
		op = GR_TFUC16;
	else if (ASCII & menulist->op)
		op = GR_TFASCII;
	/* this makes the text draw without outlines */
	GrSetGCUseBackground(menulist->menu_gc, GR_FALSE);
	GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
			menulist->menu_gc, 8, 1, text, strlen(text),
			op | GR_TFTOP);

	
	if(BOOLEAN_MENU & item->op) {
		GR_SIZE width, height, base;
		char option[4];
		/* get setting info */
		if(item->setting != 0)
			item->sel_option = ipod_get_setting(item->setting);
		/* draw boolean text */	
		strcpy(option, (item->sel_option ? _("On") : _("Off")));
		GrGetGCTextSize(menulist->menu_gc, option, -1, GR_TFASCII,
				&width,	&height, &base);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - width) -
				(8 + 2), 1, option, -1, GR_TFASCII| GR_TFTOP);
	}
	else if(OPTION_MENU & item->op) {
		GR_SIZE width, height, base;
		char **option;
		/* get setting info */
		if(item->setting != 0)
			item->sel_option = ipod_get_setting(item->setting);
		/* draw option text */
		option = (char **)item->action;
		text = gettext(option[item->sel_option]);
		GrGetGCTextSize(menulist->menu_gc, text, -1, GR_TFASCII,
				&width,	&height, &base);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - width) -
				(8 + 2), 1, text, -1, GR_TFASCII | GR_TFTOP);
	}
	else if((SUB_MENU_HEADER & item->op || ARROW_MENU & item->op) &&
			(item->text_width < (menulist->w - 8) - 8)) {
		GrSetGCUseBackground(menulist->menu_gc, GR_FALSE);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - 8) - 7,
				2, ">", -1, GR_TFASCII | GR_TFTOP);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - 8) - 6,
				2, ">", -1, GR_TFASCII | GR_TFTOP);
		GrSetGCUseBackground(menulist->menu_gc, GR_TRUE);
	}
	
	menu_draw_item(menulist, pixmap);
}
예제 #9
0
void toggle_backlight(void)
{
        ipod_set_setting(BACKLIGHT, !ipod_get_setting(BACKLIGHT));
}