From c206bd9d759b78869d92298c547ca35369bcf408 Mon Sep 17 00:00:00 2001 From: skeezix Date: Tue, 16 Mar 2010 13:23:57 -0400 Subject: [PATCH] Fixed a suspected crash that could occur for app scanning Made scanning desktop apps, menu apps and aux-aps optional in conf Added aux-apps, so folks can make a mmenu-only type searchpath for apps Added Y to bering up midori to view documentation in pnd files --- deployment/etc/pandora/conf/mmenu.conf | 5 +- minimenu/mmenu.c | 53 ++++++++++-- minimenu/mmenu.conf | 3 + minimenu/mmui.c | 108 ++++++++++++++++++++++++- minimenu/mmui.h | 1 + 5 files changed, 161 insertions(+), 9 deletions(-) diff --git a/deployment/etc/pandora/conf/mmenu.conf b/deployment/etc/pandora/conf/mmenu.conf index 26d4e07..c0886f5 100644 --- a/deployment/etc/pandora/conf/mmenu.conf +++ b/deployment/etc/pandora/conf/mmenu.conf @@ -10,6 +10,9 @@ load_previews_now 0 # if >0, will try to load preview pics from pnds at boot tim load_previews_later 1 # if >0, will try to load preview pics sometime (see defer_timer_ms as well) loglevel 0 # 0 is debug, lots of crap; 3 is better, means 'errors only'. Output may screw up the wrapper! x11_present_sh /bin/pidof X # command to invoke to determine if X11 is running or not; expects a number on X is present. +desktop_apps 1 # search the pnd standard desktop searchpath for apps +menu_apps 1 # search the pnd standard menu searchpath for apps +aux_searchpath /media/*/pandora/mmenu # if something here, also search this path; can be used for mmenu-only apps? [display] fullscreen 1 # 0 for windowed, >0 for fullscreen @@ -21,7 +24,7 @@ font_rgba_b 220 # RGBA for the display text font_rgba_a 20 # RGBA for the display text battery_x 10 # (x,y) for battery level battery_y 450 # (x,y) for battery level -hintline Push START for shutdown options # shown at bottom of screen +hintline Push SELECT for shutdown options # shown at bottom of screen hint_x 275 # (x,y) for hint line hint_y 450 # (x,y) for hint line clock_x 650 # (x,y) for clock diff --git a/minimenu/mmenu.c b/minimenu/mmenu.c index aadac02..279b57c 100644 --- a/minimenu/mmenu.c +++ b/minimenu/mmenu.c @@ -296,15 +296,54 @@ void applications_scan ( void ) { // determine current app list, cache icons // - ignore overrides for now - pnd_log ( pndn_debug, "Looking for pnd applications here: %s\n", - pnd_conf_get_as_char ( g_desktopconf, "desktop.searchpath" ) ); - g_active_apps = pnd_disco_search ( pnd_conf_get_as_char ( g_desktopconf, "desktop.searchpath" ), NULL ); - pnd_log ( pndn_debug, "Looking for pnd applications here: %s\n", - pnd_conf_get_as_char ( g_desktopconf, "menu.searchpath" ) ); - pnd_box_handle menu_apps = pnd_disco_search ( pnd_conf_get_as_char ( g_desktopconf, "menu.searchpath" ), NULL ); - pnd_box_append ( g_active_apps, menu_apps ); + g_active_apps = 0; + pnd_box_handle merge_apps = 0; + // desktop apps? + if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.desktop_apps", 1 ) ) { + pnd_log ( pndn_debug, "Looking for pnd applications here: %s\n", + pnd_conf_get_as_char ( g_desktopconf, "desktop.searchpath" ) ); + g_active_apps = pnd_disco_search ( pnd_conf_get_as_char ( g_desktopconf, "desktop.searchpath" ), NULL ); + } + + // menu apps? + if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.menu_apps", 1 ) ) { + pnd_log ( pndn_debug, "Looking for pnd applications here: %s\n", + pnd_conf_get_as_char ( g_desktopconf, "menu.searchpath" ) ); + merge_apps = pnd_disco_search ( pnd_conf_get_as_char ( g_desktopconf, "menu.searchpath" ), NULL ); + } + + // merge lists + if ( merge_apps ) { + if ( g_active_apps ) { + // got menu apps, and got desktop apps, merge + pnd_box_append ( g_active_apps, merge_apps ); + } else { + // got menu apps, had no desktop apps, so just assign + g_active_apps = merge_apps; + } + } + + // aux apps? + char *aux_apps = NULL; + merge_apps = 0; + aux_apps = pnd_conf_get_as_char ( g_conf, "minimenu.aux_searchpath" ); + if ( aux_apps && aux_apps [ 0 ] ) { + pnd_log ( pndn_debug, "Looking for pnd applications here: %s\n", aux_apps ); + merge_apps = pnd_disco_search ( aux_apps, NULL ); + } + + // merge aux apps + if ( merge_apps ) { + if ( g_active_apps ) { + pnd_box_append ( g_active_apps, merge_apps ); + } else { + g_active_apps = merge_apps; + } + } + + // do it g_active_appcount = pnd_box_get_size ( g_active_apps ); unsigned char maxwidth, maxheight; diff --git a/minimenu/mmenu.conf b/minimenu/mmenu.conf index 759b578..a48bec0 100644 --- a/minimenu/mmenu.conf +++ b/minimenu/mmenu.conf @@ -10,6 +10,9 @@ load_previews_now 0 # if >0, will try to load preview pics from pnds at boot tim load_previews_later 0 # if >0, will try to load preview pics sometime (see defer_timer_ms as well) loglevel 0 # 0 is debug, lots of crap; 3 is better, means 'errors only'. Output may screw up the wrapper! x11_present_sh /bin/pidof X # command to invoke to determine if X11 is running or not; expects a number on X is present. +desktop_apps 1 # search the pnd standard desktop searchpath for apps +menu_apps 1 # search the pnd standard menu searchpath for apps +aux_searchpath /media/*/pandora/mmenu # if something here, also search this path; can be used for mmenu-only apps? [display] fullscreen 0 # 0 for windowed, >0 for fullscreen diff --git a/minimenu/mmui.c b/minimenu/mmui.c index ad97111..abc4ef4 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "SDL.h" #include "SDL_audio.h" #include "SDL_image.h" @@ -627,6 +628,26 @@ void ui_render ( unsigned int render_mask ) { desty += src.h; } + // info hint + if ( ui_selected -> ref -> clockspeed && ui_selected -> ref -> info_filename ) { + + sprintf ( buffer, "Documentation - hit Y" ); + + SDL_Surface *rtext; + SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a }; + rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, tmpfontcolor ); + src.x = 0; + src.y = 0; + src.w = rtext -> w < cell_width ? rtext -> w : cell_width; + src.h = rtext -> h; + dest -> x = cell_offset_x; + dest -> y = desty; + SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest ); + SDL_FreeSurface ( rtext ); + dest++; + desty += src.h; + } + // preview pic mm_cache_t *ic = cache_query_preview ( ui_selected -> ref -> unique_id ); SDL_Surface *previewpic; @@ -708,7 +729,7 @@ void ui_process_input ( unsigned char block_p ) { SDL_Event event; unsigned char ui_event = 0; // if we get a ui event, flip to 1 and break - static ui_sdl_button_e ui_mask = uisb_none; // current buttons down + //static ui_sdl_button_e ui_mask = uisb_none; // current buttons down while ( ! ui_event && block_p ? SDL_WaitEvent ( &event ) : SDL_PollEvent ( &event ) ) @@ -859,6 +880,12 @@ void ui_process_input ( unsigned char block_p ) { } else if ( event.key.keysym.sym == SDLK_x || event.key.keysym.sym == SDLK_RCTRL ) { ui_push_rtrigger(); ui_event++; + } else if ( event.key.keysym.sym == SDLK_y || event.key.keysym.sym == SDLK_PAGEUP ) { + // info + if ( ui_selected ) { + ui_show_info ( pnd_run_script, ui_selected -> ref ); + ui_event++; + } } else if ( event.key.keysym.sym == SDLK_LALT ) { // start button ui_push_exec(); @@ -1603,3 +1630,82 @@ unsigned char ui_determine_screen_col ( mm_appref_t *a ) { return ( col ); } + +unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p ) { + char *viewer, *searchpath; + pnd_conf_handle desktoph; + + // viewer + searchpath = pnd_conf_query_searchpath(); + + desktoph = pnd_conf_fetch_by_id ( pnd_conf_desktop, searchpath ); + + if ( ! desktoph ) { + return ( 0 ); + } + + viewer = pnd_conf_get_as_char ( desktoph, "info.viewer" ); + + if ( ! viewer ) { + return ( 0 ); // no way to view the file + } + + // etc + if ( ! p -> unique_id ) { + return ( 0 ); + } + + if ( ! p -> info_filename ) { + return ( 0 ); + } + + if ( ! p -> info_name ) { + return ( 0 ); + } + + if ( ! pndrun ) { + return ( 0 ); + } + + // exec line + char args [ 1001 ]; + char *pargs = args; + if ( pnd_conf_get_as_char ( desktoph, "info.viewer_args" ) ) { + snprintf ( pargs, 1001, "%s %s", + pnd_conf_get_as_char ( desktoph, "info.viewer_args" ), p -> info_filename ); + } else { + pargs = NULL; + } + + char pndfile [ 1024 ]; + if ( p -> object_type == pnd_object_type_directory ) { + // for PXML-app-dir, pnd_run.sh doesn't want the PXML.xml.. it just wants the dir-name + strncpy ( pndfile, p -> object_path, 1000 ); + } else if ( p -> object_type == pnd_object_type_pnd ) { + // pnd_run.sh wants the full path and filename for the .pnd file + snprintf ( pndfile, 1020, "%s/%s", p -> object_path, p -> object_filename ); + } + + if ( ! pnd_apps_exec ( pndrun, pndfile, p -> unique_id, viewer, p -> startdir, pargs, + p -> clockspeed ? atoi ( p -> clockspeed ) : 0, PND_EXEC_OPTION_NORUN ) ) + { + return ( 0 ); + } + + pnd_log ( pndn_debug, "Info Exec=%s\n", pnd_apps_exec_runline() ); + + // try running it + int x; + if ( ( x = fork() ) < 0 ) { + pnd_log ( pndn_error, "ERROR: Couldn't fork()\n" ); + return ( 0 ); + } + + if ( x == 0 ) { + execl ( "/bin/sh", "/bin/sh", "-c", pnd_apps_exec_runline(), (char*)NULL ); + pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", pnd_apps_exec_runline() ); + return ( 0 ); + } + + return ( 1 ); +} diff --git a/minimenu/mmui.h b/minimenu/mmui.h index 8beff3b..95e44fc 100644 --- a/minimenu/mmui.h +++ b/minimenu/mmui.h @@ -83,6 +83,7 @@ void ui_push_rtrigger ( void ); unsigned char ui_determine_row ( mm_appref_t *a ); unsigned char ui_determine_screen_row ( mm_appref_t *a ); unsigned char ui_determine_screen_col ( mm_appref_t *a ); +unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p ); // ui_render() can register tappable-areas which touchscreen code can then figure out if we made a hit void ui_register_reset ( void ); -- 2.39.2