Merge branch 'master' of ssh://skeezixgit@git.openpandora.org/srv/git/pandora-libraries
[pandora-libraries.git] / minimenu / mmenu.c
index 83743bc..f8ba263 100644 (file)
@@ -359,7 +359,7 @@ int main ( int argc, char *argv[] ) {
 
   // create all cat
   if ( pnd_conf_get_as_int_d ( g_conf, "categories.do_all_cat", 1 ) ) {
-    category_push ( g_x11_present ? CATEGORY_ALL "    (X11)" : CATEGORY_ALL "   (No X11)", NULL /*app*/, 0, NULL /* fspath */, 1 /* visible */ );
+    category_push ( g_x11_present ? CATEGORY_ALL "    (X11)" : CATEGORY_ALL "   (No X11)", NULL /* parent cat */, NULL /*app*/, 0, NULL /* fspath */, 1 /* visible */ );
   }
 
   // set up category mappings
@@ -373,16 +373,16 @@ int main ( int argc, char *argv[] ) {
 
   /* actual work now
    */
-  unsigned char block = 1;
-
   if ( g_autorescan ) {
-    block = 0;
 
     // set up notifications
     dbh = pnd_dbusnotify_init();
     pnd_log ( pndn_debug, "Setting up dbusnotify\n" );
     //setup_notifications();
 
+    // create a timer thread, that will trigger us to check for SD insert notifications every once in awhile
+    ui_threaded_timer_create();
+
   } // set up rescan
 
   /* set speed to minimenu run-speed, now that we're all set up
@@ -405,33 +405,8 @@ int main ( int argc, char *argv[] ) {
     // show the menu, or changes thereof
     ui_render();
 
-    // wait for input or time-based events (like animations)
-    // deal with inputs
-    ui_process_input ( block /* block */ );
-
-    // did a rescan event trigger?
-    if ( g_autorescan ) {
-      unsigned char watch_dbus = 0;
-      unsigned char watch_inotify = 0;
-
-      if ( dbh ) {
-       watch_dbus = pnd_dbusnotify_rediscover_p ( dbh );
-      }
-
-      if ( nh ) {
-       watch_inotify = pnd_notify_rediscover_p ( nh );
-      }
-
-      if ( watch_dbus || watch_inotify ) {
-       pnd_log ( pndn_debug, "dbusnotify detected SD event\n" );
-       applications_free();
-       applications_scan();
-      }
-
-    } // rescan?
-
-    // sleep? block?
-    usleep ( 100000 /*5000*/ );
+    // wait for input or time-based events (like animations) and deal with inputs
+    ui_process_input ( dbh, nh );
 
   } // while
 
@@ -642,6 +617,25 @@ void applications_scan ( void ) {
       }
 #endif
 
+      if ( ovrh ) {
+       // lets also check to see if this ovr is specifying category overrides; if so, we can trust those
+       // more than categories specified by pnd-packager.
+       char ovrkey [ 41 ];
+
+       snprintf ( ovrkey, 40, "Application-%u.maincategory", iter -> subapp_number );
+       if ( pnd_conf_get_as_char ( ovrh, ovrkey ) ) {
+         iter -> object_flags |= PND_DISCO_CUSTOM1;
+         //printf ( "App '%s' has main cat ovr %s\n", iter -> title_en, pnd_conf_get_as_char ( ovrh, ovrkey ) );
+       }
+
+       snprintf ( ovrkey, 40, "Application-%u.maincategorysub1", iter -> subapp_number );
+       if ( pnd_conf_get_as_char ( ovrh, ovrkey ) ) {
+         iter -> object_flags |= PND_DISCO_CUSTOM2;
+         //printf ( "App '%s' has sub cat ovr %s\n", iter -> title_en, pnd_conf_get_as_char ( ovrh, ovrkey ) );
+       }
+
+      } // got ovr loaded/
+
     } // ovr
 
     // cache the icon, unless deferred
@@ -677,20 +671,20 @@ void applications_scan ( void ) {
        // push to All category
        // we do this first, so first category is always All
        if ( pnd_conf_get_as_int_d ( g_conf, "categories.do_all_cat", 1 ) ) {
-         category_push ( g_x11_present ? CATEGORY_ALL "    (X11)" : CATEGORY_ALL "   (No X11)", iter, ovrh, NULL /* fspath */, 1 /* visible */ );
+         category_push ( g_x11_present ? CATEGORY_ALL "    (X11)" : CATEGORY_ALL "   (No X11)", NULL /* parent cat */, iter, ovrh, NULL /* fspath */, 1 /* visible */ );
        } // all?
 
        // is this app suppressed? if not, show it in whatever categories the user is allowing
        if ( iter -> unique_id && app_is_visible ( g_conf, iter -> unique_id ) ) {
 
          // main categories
-         category_meta_push ( iter -> main_category, NULL /* no parent cat */, iter, ovrh, cat_is_visible ( g_conf, iter -> main_category ) ); //pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat", 1 ) );
-         category_meta_push ( iter -> main_category1, iter -> main_category, iter, ovrh, cat_is_visible ( g_conf, iter -> main_category1 ) ); //pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat1", 0 ) );
-         category_meta_push ( iter -> main_category2, iter -> main_category, iter, ovrh, cat_is_visible ( g_conf, iter -> main_category2 ) ); //pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat2", 0 ) );
+         category_meta_push ( iter -> main_category, NULL /* no parent cat */, iter, ovrh, cat_is_visible ( g_conf, iter -> main_category ), 1);
+         category_meta_push ( iter -> main_category1, iter -> main_category, iter, ovrh, cat_is_visible ( g_conf, iter -> main_category1 ), 0 );
+         category_meta_push ( iter -> main_category2, iter -> main_category, iter, ovrh, cat_is_visible ( g_conf, iter -> main_category2 ), 0 );
          // alt categories
-         category_meta_push ( iter -> alt_category, NULL /* no parent cat */, iter, ovrh, cat_is_visible ( g_conf, iter -> alt_category ) ); //pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat", 0 ) );
-         category_meta_push ( iter -> alt_category1, iter -> alt_category, iter, ovrh, cat_is_visible ( g_conf, iter -> alt_category1 ) ); //pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat1", 0 ) );
-         category_meta_push ( iter -> alt_category2, iter -> alt_category, iter, ovrh, cat_is_visible ( g_conf, iter -> alt_category2 ) ); //pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat2", 0 ) );
+         category_meta_push ( iter -> alt_category, NULL /* no parent cat */, iter, ovrh, cat_is_visible ( g_conf, iter -> alt_category ), 1 );
+         category_meta_push ( iter -> alt_category1, iter -> alt_category, iter, ovrh, cat_is_visible ( g_conf, iter -> alt_category1 ), 0 );
+         category_meta_push ( iter -> alt_category2, iter -> alt_category, iter, ovrh, cat_is_visible ( g_conf, iter -> alt_category2 ), 0 );
 
        } // app is visible?
 
@@ -721,7 +715,7 @@ void applications_scan ( void ) {
 
       // check if dir is empty; if so, skip it.
       if ( ! is_dir_empty ( buffer ) ) {
-       category_push ( tabname /* tab name */, NULL /* app */, 0 /* override */, buffer /* fspath */, 1 /* visible */ );
+       category_push ( tabname /* tab name */, NULL /* parent cat */, NULL /* app */, 0 /* override */, buffer /* fspath */, 1 /* visible */ );
       }
 
     }