From 88cf5f12dd15ac810858bf93debfe28a472000e5 Mon Sep 17 00:00:00 2001 From: skeezix Date: Fri, 4 Jun 2010 09:41:41 -0400 Subject: [PATCH] Added option to set starting category to minimenu (default is still leftmost (usually All)) --- deployment/etc/pandora/conf/mmenu.conf | 1 + minimenu/mmenu.conf | 1 + minimenu/mmui.c | 39 ++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/deployment/etc/pandora/conf/mmenu.conf b/deployment/etc/pandora/conf/mmenu.conf index f638c4f..edfc683 100644 --- a/deployment/etc/pandora/conf/mmenu.conf +++ b/deployment/etc/pandora/conf/mmenu.conf @@ -61,6 +61,7 @@ cache_findpath /media/mmcblk?p?/pandora/appdata/mmenu.pvwcache # where to catmap_searchpath /media/*/pandora/mmenu:/etc/pandora/mmenu:./minimenu catmap_confname mmcatmap.conf do_all_cat 1 # if >0, will show an All category; if 0, skip it, just your cats. +#default_cat Game # if specified, will attempt to use the named category when mmenu starts, instead of 'leftmost' (usually All) [filesystem] do_browser 1 # if >0, will allow filesystem browsing somehow diff --git a/minimenu/mmenu.conf b/minimenu/mmenu.conf index df6e06e..6028084 100644 --- a/minimenu/mmenu.conf +++ b/minimenu/mmenu.conf @@ -61,6 +61,7 @@ cache_findpath /media/mmcblk[12]p?/pandora/appdata/mmenu.pvwcache # where catmap_searchpath /media/*/pandora/mmenu:/etc/pandora/mmenu:./minimenu catmap_confname mmcatmap.conf do_all_cat 1 # if >0, will show an All category; if 0, skip it, just your cats. +#default_cat Game [filesystem] do_browser 1 # if >0, will allow filesystem browsing somehow diff --git a/minimenu/mmui.c b/minimenu/mmui.c index 39c2a64..58ee9f9 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -1240,12 +1240,6 @@ void ui_process_input ( unsigned char block_p ) { applications_free(); pnd_log ( pndn_debug, "Rescanning applications\n" ); applications_scan(); - // reset view - ui_selected = NULL; - ui_rows_scrolled_down = 0; - // set back to first tab, to be safe - ui_category = 0; - ui_catshift = 0; } else if ( sel == 3 ) { // cache preview to SD now extern pnd_box_handle g_active_apps; @@ -2336,6 +2330,39 @@ void ui_post_scan ( void ) { } // deferred icon load + // reset view + ui_selected = NULL; + ui_rows_scrolled_down = 0; + // set back to first tab, to be safe + ui_category = 0; + ui_catshift = 0; + + // do we have a preferred category to jump to? + char *dc = pnd_conf_get_as_char ( g_conf, "categories.default_cat" ); + if ( dc ) { + + // attempt to find default cat; if we do find it, select it; otherwise + // default behaviour will pick first cat (ie: usually All) + unsigned int i; + for ( i = 0; i < g_categorycount; i++ ) { + if ( strcasecmp ( g_categories [ i ].catname, dc ) == 0 ) { + ui_category = i; + // ensure visibility + unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 ); + unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" ); + if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) { + ui_catshift = ui_category - ( screen_width / tab_width ) + 1; + } + break; + } + } + + if ( i == g_categorycount ) { + pnd_log ( pndn_warning, " User defined default category '%s' but not found, so using default behaviour\n", dc ); + } + + } // default cat + return; } -- 2.39.2