libpnd, mmenu: better handling of 'NoSubcategory' pseudo-subcategory in ovr files
authorskeezix <skeezix@flotsam-vm.(none)>
Tue, 8 Feb 2011 19:53:17 +0000 (14:53 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Tue, 8 Feb 2011 19:53:17 +0000 (14:53 -0500)
lib/pnd_discovery.c
minimenu/freedesktop_cats.c
minimenu/mmcat.c
minimenu/mmui.c

index 4c2feba..8afbb38 100644 (file)
@@ -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?
index 05484ab..087a105 100644 (file)
@@ -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 ) {
index b9493cb..2bf84e6 100644 (file)
@@ -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
index 02f9d32..6447ca9 100644 (file)
@@ -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;
            }