Added config option so can force 'bad categories' into Other using freedesktop list
[pandora-libraries.git] / minimenu / mmconf.c
index 0923a34..d0db0ba 100644 (file)
@@ -28,13 +28,15 @@ confitem_t page_general[] = {
   { "Set CPU speed within Minimenu", "Whether the next setting is applied or not",              "0",                "minimenu.use_mm_speed",   ct_boolean },
   { "CPU speed within Minimenu",     "Set low; speed to run Minimenu at",                       "400",              "minimenu.mm_speed",       ct_cpu_speed },
 #endif
-  { "Set CPU speed when leaving",    "Whether the next setting is applied or not",              "0",                "minimenu.use_run_speed",  ct_boolean },
-  { "CPU speed when leaving",        "Before running app, set this speed; app may override.",   "500",              "minimenu.run_speed",      ct_cpu_speed },
   { "Show 'All' tab",                "Whethor an All tab is shown or not",                      "1",                "categories.do_all_cat",   ct_boolean },
   { "Show directory browser tabs",   "Show a tab for each SD card?",                            "0",                "filesystem.do_browser",   ct_boolean },
   { "Detail panel on start?",        "Show or hide the detail panel when menu starts",          "1",                "display.show_detail_pane", ct_boolean },
-  { "Start with app selected",       "Whethor selection is placed by default or not",           "0",                "minimenu.start_selected", ct_boolean },
   { "Sub-categories as folders?",    "If no, uses tabs instead of folders within tabs.",        "1",                "tabs.subcat_as_folders",  ct_boolean },
+  { "Start with app selected",       "Whethor selection is placed by default or not",           "0",                "minimenu.start_selected", ct_boolean },
+  { "Auto discover pnd apps?",       "If no, turn on diectory browser to manually find apps",   "1",                "filesystem.do_pnd_disco", ct_boolean },
+  { "Keep bad categories in Other?", "Lazy dev! Put broken categories into Other to keep clean", "1",               "categories.good_cats_only", ct_boolean },
+  { "Set CPU speed when leaving",    "Whether the next setting is applied or not",              "0",                "minimenu.use_run_speed",  ct_boolean },
+  { "CPU speed when leaving",        "Before running app, set this speed; app may override.",   "500",              "minimenu.run_speed",      ct_cpu_speed },
   { "Wrap tab change",               "Changing tab left or right, does it wrap around?",        "0",                "tabs.wraparound",         ct_boolean },
   { "Grid stop vertical",            "Changing selection up or down, does it stop or wrap?",    "0",                "grid.wrap_vert_stop",     ct_boolean },
   { "Live (not exit) on app run?",   "Normally menu exits (to save ram) on app run",            "0",                "minimenu.live_on_run",    ct_boolean },
@@ -70,10 +72,6 @@ confitem_t pages[] = {
 extern pnd_conf_handle g_conf;
 extern SDL_Surface *sdl_realscreen;
 extern mm_imgcache_t g_imagecache [ IMG_TRUEMAX ];
-extern mm_category_t *g_categories;
-extern unsigned char g_categorycount;
-extern mm_category_t _categories_invis [ MAX_CATS ];
-extern unsigned char _categories_inviscount;
 extern pnd_box_handle g_active_apps;
 
 unsigned char conf_run_menu ( confitem_t *toplevel ) {
@@ -179,21 +177,21 @@ unsigned char conf_run_menu ( confitem_t *toplevel ) {
                if ( v ) {
                  unsigned char n = 0;
                  for ( n = 0; n < g_categorycount; n++ ) {
-                   if ( strcmp ( v, g_categories [ n ].catname ) == 0 ) {
+                   if ( strcmp ( v, g_categories [ n ] -> catname ) == 0 ) {
                      break;
                    }
                  }
                  if ( n < g_categorycount ) {
                    if ( left && n ) {
-                     pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ n - 1 ].catname );
+                     pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ n - 1 ] -> catname );
                    } else if ( ! left && n + 1 < g_categorycount ) {
-                     pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ n + 1 ].catname );
+                     pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ n + 1 ] -> catname );
                    }
                  } else {
-                   pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ 0 ].catname );
+                   pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ 0 ] -> catname );
                  }
                } else {
-                 pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ 0 ].catname );
+                 pnd_conf_set_char ( g_conf, page [ sel ].key, g_categories [ 0 ] -> catname );
                }
              } // if category count
            }
@@ -564,60 +562,52 @@ unsigned char conf_prepare_page ( confitem_t *page ) {
 
       template -> text = ""; // so it won't get repopulated again later
 
-      typedef struct {
-       mm_category_t *cat;
-       unsigned char n;
-      } _foo;
-      _foo cats [ 2 ];
-      cats [ 0 ].cat = g_categories;
-      cats [ 0 ].n = g_categorycount;
-      cats [ 1 ].cat = _categories_invis;
-      cats [ 1 ].n = _categories_inviscount;
+      // switch categories being published
+      category_publish ( CFALL, NULL );
 
       // for each tab
-      unsigned int i, j;
-      for ( j = 0; j < 2; j++ ) {
-       mm_category_t *cc = cats [ j ].cat;
-       unsigned char cn = cats [ j ].n;
-       char catname [ 512 ];
-       char *actual_catname;
-
-       for ( i = 0;  i < cn; i++ ) {
-
-         // if this is an invisi-guy, it has parent-cat prepended; we want the real cat name.
-         strncpy ( catname, cc [ i ].catname, 500 );
-         if ( ( actual_catname = strchr ( catname, '.' ) ) ) {
-           actual_catname++; // skip the period
-         } else {
-           actual_catname = catname;
-         }
-         //fprintf ( stderr, "conf ui; got '%s' but showing '%s'\n", cc [ i ].catname, actual_catname );
+      unsigned int i;
+      char catname [ 512 ];
+      char *actual_catname;
 
-         if ( strncmp ( cc [ i ].catname, "All ", 4 ) == 0 ) {
-           // skip All tab, since it is generated, and managed by another config item
-           continue;
-         }
+      for ( i = 0;  i < g_categorycount; i++ ) {
 
-         p -> text = strndup ( actual_catname, 40 );
-         p -> desc = NULL;
-         p -> def = NULL;
+       // if this is an invisi-guy, it has parent-cat prepended; we want the real cat name.
+       strncpy ( catname, g_categories [ i ] -> catname, 500 );
 
-         sprintf ( buffer, "%s.%s", template -> key, actual_catname );
-         p -> key = strdup ( buffer );
-         p -> type = ct_boolean;
-         p -> newhead = NULL;
+       if ( ( actual_catname = strchr ( catname, '.' ) ) ) {
+         actual_catname++; // skip the period
+       } else {
+         actual_catname = catname;
+       }
+       //fprintf ( stderr, "conf ui; got '%s' but showing '%s'\n", cc [ i ].catname, actual_catname );
 
-         // create to positive if not existant
-         if ( ! pnd_conf_get_as_char ( g_conf, buffer ) ) {
-           pnd_conf_set_char ( g_conf, buffer, "1" );
-         }
+       if ( strncmp ( g_categories [ i ] -> catname, "All ", 4 ) == 0 ) {
+         // skip All tab, since it is generated, and managed by another config item
+         continue;
+       }
 
-         //fprintf ( stderr, "Created tabshow entry '%s'\n", cc [ i ].catname );
+       p -> text = strndup ( actual_catname, 40 );
+       p -> desc = NULL;
+       p -> def = NULL;
+
+       sprintf ( buffer, "%s.%s", template -> key, actual_catname );
+       p -> key = strdup ( buffer );
+       p -> type = ct_boolean;
+       p -> newhead = NULL;
 
-         p++;
+       // create to positive if not existant
+       if ( ! pnd_conf_get_as_char ( g_conf, buffer ) ) {
+         pnd_conf_set_char ( g_conf, buffer, "1" );
        }
 
-      }
+       //fprintf ( stderr, "Created tabshow entry '%s'\n", cc [ i ].catname );
+
+       p++;
+      } // for
+
+      // switch categories being published
+      category_publish ( CFNORMAL, NULL );
 
       break;
     }