1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-22 18:34:41 +02:00

Merge branch 'master' of projects.qi-hardware.com:openwrt-packages

This commit is contained in:
kyak 2012-04-04 09:03:27 +04:00
commit b5ffbdf667
3 changed files with 60 additions and 16 deletions

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=alfilesel PKG_NAME:=alfilesel
PKG_VERSION:=0.1.0 PKG_VERSION:=0.1.0
PKG_RELEASE:=2 PKG_RELEASE:=3
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz #PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=@SF/forth-brainless #PKG_SOURCE_URL:=@SF/forth-brainless
#PKG_MD5SUM:=ed4a4cbbe23628b17edc5aa01f32f7fb #PKG_MD5SUM:=ed4a4cbbe23628b17edc5aa01f32f7fb
@ -21,7 +21,6 @@ include $(INCLUDE_DIR)/package.mk
define Package/alfilesel define Package/alfilesel
SECTION:=utilities SECTION:=utilities
CATEGORY:=Utilities CATEGORY:=Utilities
CATEGORY:=Games
MAINTAINER:="David Kuehling" <dvdkhlng TA gmx TOD de> MAINTAINER:="David Kuehling" <dvdkhlng TA gmx TOD de>
TITLE:=Graphical file selector app to use in shell scripts TITLE:=Graphical file selector app to use in shell scripts
DEPENDS:=+liballegro +liballegro-jpeg +liballegro-png DEPENDS:=+liballegro +liballegro-jpeg +liballegro-png

View File

@ -1,6 +1,6 @@
/* Simple liballegro based file selector helper utility. /* Simple liballegro based file selector helper utility.
* *
* Copyright (C) 2011 David Kühling <dvdkhlng TA gmx TOD de> * Copyright (C) 2012 David Kühling <dvdkhlng TA gmx TOD de>
* *
* License: GPL3 or later, NO WARRANTY * License: GPL3 or later, NO WARRANTY
* *
@ -17,7 +17,6 @@
static int verbose_flag = 0; static int verbose_flag = 0;
static int run_flag = 0;
static int mouse_flag = 0; static int mouse_flag = 0;
static int help_flag = 0; static int help_flag = 0;
@ -25,14 +24,20 @@ char * program_invocation_short_name;
static void print_help() { static void print_help() {
const char *help = const char *help =
"[OPTION]...\n" "[OPTION] [--] [PROGRAM_TO_RUN] [PROGRAM_ARGS]..\n"
"\n"
"If PROGRAM_TO_RUN is specfied, run it with arguments PROGRAM_ARGS and\n"
"the selected file appended as final argument.\n"
"Else just print the selected filename and newline to stdout.\n"
"\n"
"Options:\n" "Options:\n"
"\t-t --title=STRING\n" "\t-t --title=STRING\n"
"\t\tSet file selector dialog's title\n" "\t\tSet file selector dialog's title\n"
"\t-w --wallpaper=FILENAME\n" "\t-w --wallpaper=FILENAME\n"
"\t\tSet file to use as wallpaper (supports jpeg, png, pcx, bmp, tga)\n" "\t\tSet file to use as wallpaper (supports jpeg, png, pcx, bmp, tga)\n"
"\t-p --path=PATH\n" "\t-p --path=PATH\n"
"\t\tSet initial directory and/or filename\n" "\t\tSet initial directory and/or filename. When giving an initial\n"
"\t\tdirectory, make sure that PATH ends in a slash.\n"
"\t-f --filter=STRING\n" "\t-f --filter=STRING\n"
"\t\tFilter files by extension and/or mode bits\n" "\t\tFilter files by extension and/or mode bits\n"
"\t\tUse 'png;jpeg' to show only .png and .jpeg files, use '/+x' to\n" "\t\tUse 'png;jpeg' to show only .png and .jpeg files, use '/+x' to\n"
@ -44,13 +49,12 @@ static void print_help() {
help); help);
} }
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
int c; int c;
const int hborder = 32; const int hborder = 32;
const int vborder = 32; const int vborder = 32;
const int trborder = 6;
const char *title = "Select file"; const char *title = "Select file";
const char *init_path = 0; const char *init_path = 0;
const char *filter = 0; const char *filter = 0;
@ -59,6 +63,7 @@ int main (int argc, char *argv[])
char path[4096]; char path[4096];
char **cmd = NULL; char **cmd = NULL;
int num_cmd = 0; int num_cmd = 0;
int run = 0;
PALETTE pal; PALETTE pal;
BITMAP *backbmp; BITMAP *backbmp;
@ -71,7 +76,6 @@ int main (int argc, char *argv[])
{"verbose", no_argument, &verbose_flag, 1}, {"verbose", no_argument, &verbose_flag, 1},
{"help", no_argument, &help_flag, 1}, {"help", no_argument, &help_flag, 1},
{"mouse", no_argument, &mouse_flag, 1}, {"mouse", no_argument, &mouse_flag, 1},
{"run", no_argument, &run_flag, 1},
/* These options don't set a flag. /* These options don't set a flag.
We distinguish them by their indices. */ We distinguish them by their indices. */
{"title", required_argument, 0, 't'}, {"title", required_argument, 0, 't'},
@ -83,7 +87,7 @@ int main (int argc, char *argv[])
/* `getopt_long' stores the option index here. */ /* `getopt_long' stores the option index here. */
int option_index = 0; int option_index = 0;
c = getopt_long (argc, argv, "t:p:f:w:mrh", c = getopt_long (argc, argv, "t:p:f:w:mh",
long_options, &option_index); long_options, &option_index);
/* Detect the end of the options. */ /* Detect the end of the options. */
@ -98,6 +102,14 @@ int main (int argc, char *argv[])
break; break;
break; break;
case 'h':
help_flag = 1;
break;
case 'm':
mouse_flag = 1;
break;
case 't': case 't':
title = optarg; title = optarg;
break; break;
@ -130,11 +142,10 @@ int main (int argc, char *argv[])
return 0; return 0;
} }
/* Print any remaining command line arguments (not options). */ /* Print any remaining command line arguments (not options). */
if (optind < argc) if (optind < argc)
{ {
run_flag = 1; run = 1;
cmd = &argv[optind]; cmd = &argv[optind];
num_cmd = argc - optind; num_cmd = argc - optind;
printf ("non-option ARGV-elements: "); printf ("non-option ARGV-elements: ");
@ -152,6 +163,7 @@ int main (int argc, char *argv[])
loadpng_init(); loadpng_init();
jpgalleg_init(); jpgalleg_init();
set_color_depth(32);
if (set_gfx_mode(GFX_SAFE, 320, 240, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 320, 240, 0, 0) != 0) {
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
@ -189,9 +201,21 @@ int main (int argc, char *argv[])
set_palette(pal); set_palette(pal);
/* fourth parameter is alpha value (0=fully transparent) */
gui_fg_color = makecol(230,210,140); gui_fg_color = makecol(230,210,140);
gui_bg_color = makecol(30,40,50);
gui_mg_color = makecol(140,150,160); gui_mg_color = makecol(140,150,160);
gui_bg_color = makecol(30,40,50);
/* add some translucent border around file selector dialog. We'd like to
make the whole dialog translucent by using makeacol() above and
set_alpha_blender(), however the dialog can't cope with some of the
changes in drawing function semantics that go along with that */
drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);
set_trans_blender(0,0,0,128);
rectfill(screen, hborder-trborder, vborder-trborder,
SCREEN_W-hborder+trborder, SCREEN_H-vborder+trborder,
gui_bg_color);
drawing_mode(DRAW_MODE_SOLID, 0, 0, 0);
if (!init_path) if (!init_path)
getcwd(path, sizeof(path)); getcwd(path, sizeof(path));
@ -200,8 +224,6 @@ int main (int argc, char *argv[])
path[sizeof(path)-1] = '\0'; path[sizeof(path)-1] = '\0';
int ok = file_select_ex( int ok = file_select_ex(
title, path, filter, sizeof(path), SCREEN_W-2*hborder, SCREEN_H-2*vborder); title, path, filter, sizeof(path), SCREEN_W-2*hborder, SCREEN_H-2*vborder);
path[sizeof(path)-1] = '\0'; path[sizeof(path)-1] = '\0';
@ -210,7 +232,27 @@ int main (int argc, char *argv[])
if (ok) if (ok)
{ {
printf ("%s", path); printf ("%s\n", path);
if (run)
{
char **argv_exec = malloc(sizeof(char*)*(num_cmd+2));
if (!argv_exec)
return 2;
memcpy (argv_exec, cmd, sizeof(char*)*(num_cmd));
argv_exec[num_cmd] = path;
argv_exec[num_cmd+1] = 0;
if (execvp(cmd[0], argv_exec))
{
perror ("Can't exec");
return 3;
}
/* exec shouldn't return! */
return 4;
}
return 0; return 0;
} }

View File

@ -298,6 +298,8 @@ CONFIG_PACKAGE_zlib=y
# liballegro # liballegro
# #
CONFIG_PACKAGE_liballegro=y CONFIG_PACKAGE_liballegro=y
CONFIG_PACKAGE_liballegro-jpeg=y
CONFIG_PACKAGE_liballegro-png=y
CONFIG_PACKAGE_liballegro-data=y CONFIG_PACKAGE_liballegro-data=y
CONFIG_PACKAGE_liballegro-demo=y CONFIG_PACKAGE_liballegro-demo=y
CONFIG_PACKAGE_liballegro-digmid=y CONFIG_PACKAGE_liballegro-digmid=y
@ -341,6 +343,7 @@ CONFIG_PACKAGE_emacs-ja-dic-m=y
CONFIG_KEXEC_TOOLS_TARGET_NAME="mipsel" CONFIG_KEXEC_TOOLS_TARGET_NAME="mipsel"
CONFIG_PACKAGE_abook=y CONFIG_PACKAGE_abook=y
CONFIG_PACKAGE_aewan=y CONFIG_PACKAGE_aewan=y
CONFIG_PACKAGE_alfilesel=y
CONFIG_PACKAGE_alsa-utils=y CONFIG_PACKAGE_alsa-utils=y
CONFIG_PACKAGE_ase=y CONFIG_PACKAGE_ase=y
CONFIG_PACKAGE_at=y CONFIG_PACKAGE_at=y