From: skeezix Date: Tue, 8 Feb 2011 19:53:17 +0000 (-0500) Subject: libpnd, mmenu: better handling of 'NoSubcategory' pseudo-subcategory in ovr files X-Git-Tag: sz_beta3~80 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-libraries.git;a=commitdiff_plain;h=a3c9bde945629115d1cea9bf807f5e5bec4e2223 libpnd, mmenu: better handling of 'NoSubcategory' pseudo-subcategory in ovr files --- diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index 4c2feba..8afbb38 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -366,8 +366,11 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) { if ( p -> main_category1 ) { free ( p -> main_category1 ); + p -> main_category1 = NULL; + } + if ( strcasecmp ( v, "NoSubcategory" ) != 0 ) { + p -> main_category1 = strdup ( v ); } - p -> main_category1 = strdup ( v ); } } // got ovr conf loaded? diff --git a/minimenu/freedesktop_cats.c b/minimenu/freedesktop_cats.c index 05484ab..087a105 100644 --- a/minimenu/freedesktop_cats.c +++ b/minimenu/freedesktop_cats.c @@ -176,6 +176,15 @@ freedesktop_cat_t freedesktop_complete[] = { freedesktop_cat_t *freedesktop_category_query ( char *name, char *parentcatname ) { freedesktop_cat_t *p = freedesktop_complete; + // if we're supplied "NoSubcategory" virtual name, then we set it to NULL for the search +#if 0 + if ( parentcatname && strcasecmp ( name, freedesktop_complete [ 2 ].cat ) == 0 ) { + name = parentcatname; + parentcatname = NULL; + } +#endif + + // search for the cat/parent combination while ( p -> cat ) { if ( strcasecmp ( p -> cat, name ) == 0 ) { diff --git a/minimenu/mmcat.c b/minimenu/mmcat.c index b9493cb..2bf84e6 100644 --- a/minimenu/mmcat.c +++ b/minimenu/mmcat.c @@ -342,7 +342,7 @@ unsigned char category_meta_push ( char *catname, char *parentcatname, pnd_disco } // check if category came from an ovr-file; if so, we implicitly trust it instead of enforcing rules - if ( app -> object_flags & ( PND_DISCO_CUSTOM1 | PND_DISCO_CUSTOM1 ) ) { + if ( app -> object_flags & ( PND_DISCO_CUSTOM1 | PND_DISCO_CUSTOM2 ) ) { goto category_done_audit; } @@ -539,9 +539,7 @@ unsigned char category_meta_push ( char *catname, char *parentcatname, pnd_disco // so, is the cat we're looking at right now the apps main (or main alt) cat? if ( parentp ) { // and does this app have sub/altsub cats? - if ( app -> main_category1 || app -> main_category2 || - app -> alt_category1 || app -> alt_category2 ) - { + if ( app -> main_category1 || app -> main_category2 || app -> alt_category1 || app -> alt_category2 ) { // and we're only desiring the subcat version of the app? if ( pnd_conf_get_as_int_d ( g_conf, "tabs.subcat_to_parent", 1 ) == 0 ) { // create the parent category, since we need to be able to place a folder here maybe diff --git a/minimenu/mmui.c b/minimenu/mmui.c index 02f9d32..6447ca9 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -3404,6 +3404,8 @@ void ui_menu_context ( mm_appref_t *a ) { if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm categorization", "Do not set category" ) == 1 ) { ovr_replace_or_add ( a, "maincategory", opts [ sel ] ); rescan_apps++; + // when changing main cat, reset subcat, otherwise you go from Game/Emu to Network/Emu and get sent to Other right away + ovr_replace_or_add ( a, "maincategorysub1", freedesktop_complete [ 2 ].cat ); } } @@ -3418,13 +3420,25 @@ void ui_menu_context ( mm_appref_t *a ) { unsigned char i; i = 0; + opts [ optmax++ ] = freedesktop_complete [ 2 ].cat; + while ( 1 ) { if ( ! freedesktop_complete [ i ].cat ) { break; } - if ( freedesktop_complete [ i ].parent_cat ) { + char *whichparentarewe; + if ( g_categories [ ui_category ] -> parent_catname ) { + whichparentarewe = g_categories [ ui_category ] -> parent_catname; + } else { + whichparentarewe = g_categories [ ui_category ] -> catname; + } + + if ( ( freedesktop_complete [ i ].parent_cat ) && + ( strcasecmp ( freedesktop_complete [ i ].parent_cat, whichparentarewe ) == 0 ) + ) + { opts [ optmax++ ] = freedesktop_complete [ i ].cat; }