From cd3daab529896b4ace91e34ddd2f576d49c9be77 Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 14 Jul 2010 15:30:08 -0400 Subject: [PATCH] Lots of aesthetics; for apps with searchpaths listed multiple times (like /pandora/apps), don't pull the same pnd in multiple tiles; for conf overrides, also look in /pandora/appdata/mmenu (normalyl just /pandora/mmenu); for sorting, sort upper/lowercase app names together H h I i not H I h i); when using keyboard to jump to app, repeat hitting key to cycle through apps of same starting character --- minimenu/mmcat.c | 2 +- minimenu/mmenu.c | 39 +++++++++++++++++++++++++++++++++++++++ minimenu/mmenu.h | 2 +- minimenu/mmui.c | 31 +++++++++++++++++++++++++------ testdata/conf/desktop | 4 ++-- 5 files changed, 68 insertions(+), 10 deletions(-) diff --git a/minimenu/mmcat.c b/minimenu/mmcat.c index 9d1b1a0..8a32fa3 100644 --- a/minimenu/mmcat.c +++ b/minimenu/mmcat.c @@ -169,7 +169,7 @@ int cat_sort_score ( mm_appref_t *s1, mm_appref_t *s2 ) { } - return ( strcmp ( s1 -> ref -> title_en, s2 -> ref -> title_en ) ); + return ( strcasecmp ( s1 -> ref -> title_en, s2 -> ref -> title_en ) ); } void category_dump ( void ) { diff --git a/minimenu/mmenu.c b/minimenu/mmenu.c index 7e46761..d4b1438 100644 --- a/minimenu/mmenu.c +++ b/minimenu/mmenu.c @@ -494,6 +494,23 @@ void applications_scan ( void ) { // merge lists if ( merge_apps ) { if ( g_active_apps ) { + // the key from pnd_disco_search() is the _path_, so easy to look for duplicates + // this is pretty inefficient, being linked lists; perhaps should switch to hash tables when + // we expect thousands of apps.. or at least an index or something. + void *a = pnd_box_get_head ( merge_apps ); + void *nexta = NULL; + while ( a ) { + nexta = pnd_box_get_next ( a ); + + // if the key for the node is also found in active apps, toss out the merging one + if ( pnd_box_find_by_key ( g_active_apps, pnd_box_get_key ( a ) ) ) { + //fprintf ( stderr, "Merging app id '%s' is duplicate; discarding it.\n", pnd_box_get_key ( a ) ); + pnd_box_delete_node ( merge_apps, a ); + } + + a = nexta; + } + // got menu apps, and got desktop apps, merge pnd_box_append ( g_active_apps, merge_apps ); } else { @@ -514,6 +531,28 @@ void applications_scan ( void ) { // merge aux apps if ( merge_apps ) { if ( g_active_apps ) { + + // LAME: snipped from above; should just catenate the 3 sets of searchpaths into a + // master searchpath, possibly removing duplicate paths _then_, and keep all this much + // more efficient + + // the key from pnd_disco_search() is the _path_, so easy to look for duplicates + // this is pretty inefficient, being linked lists; perhaps should switch to hash tables when + // we expect thousands of apps.. or at least an index or something. + void *a = pnd_box_get_head ( merge_apps ); + void *nexta = NULL; + while ( a ) { + nexta = pnd_box_get_next ( a ); + + // if the key for the node is also found in active apps, toss out the merging one + if ( pnd_box_find_by_key ( g_active_apps, pnd_box_get_key ( a ) ) ) { + fprintf ( stderr, "Merging app id '%s' is duplicate; discarding it.\n", pnd_box_get_key ( a ) ); + pnd_box_delete_node ( merge_apps, a ); + } + + a = nexta; + } + pnd_box_append ( g_active_apps, merge_apps ); } else { g_active_apps = merge_apps; diff --git a/minimenu/mmenu.h b/minimenu/mmenu.h index f7de51e..1c71f6f 100644 --- a/minimenu/mmenu.h +++ b/minimenu/mmenu.h @@ -9,7 +9,7 @@ extern char *g_skinpath; // base searchpath to locate the conf #define MMENU_CONF "mmenu.conf" -#define MMENU_CONF_SEARCHPATH "/media/*/pandora/mmenu:/etc/pandora/conf:./minimenu" +#define MMENU_CONF_SEARCHPATH "/media/*/pandora/mmenu:/media/*/pandora/appdata/mmenu:/etc/pandora/conf:./minimenu" typedef enum { pndn_debug = 0, diff --git a/minimenu/mmui.c b/minimenu/mmui.c index 7a2e21d..670986e 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -1303,13 +1303,28 @@ void ui_process_input ( unsigned char block_p ) { if ( isalpha ( event.key.keysym.sym ) && g_categories [ ui_category ].refcount > 0 ) { mm_appref_t *app = g_categories [ ui_category ].refs; - // walk the category, looking for a first-char match - while ( app ) { - if ( app -> ref -> title_en && toupper ( app -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym ) ) { - break; + //fprintf ( stderr, "sel %s next %s\n", ui_selected -> ref -> title_en, ui_selected -> next -> ref -> title_en ); + + // are we already matching the same char? and next item is also same char? + if ( app && ui_selected && + ui_selected -> ref -> title_en && ui_selected -> next -> ref -> title_en && + toupper ( ui_selected -> ref -> title_en [ 0 ] ) == toupper ( ui_selected -> next -> ref -> title_en [ 0 ] ) && + toupper ( ui_selected -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym ) + ) + { + // just skip down one + app = ui_selected -> next; + } else { + + // walk the category, looking for a first-char match + while ( app ) { + if ( app -> ref -> title_en && toupper ( app -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym ) ) { + break; + } + app = app -> next; } - app = app -> next; - } + + } // same start letter, or new run? // found something, or no? if ( app ) { @@ -1318,6 +1333,10 @@ void ui_process_input ( unsigned char block_p ) { ui_set_selected ( ui_selected ); } + + + + } // SDLK_alphanumeric? } // SDLK_.... diff --git a/testdata/conf/desktop b/testdata/conf/desktop index 0da72c0..b60798d 100644 --- a/testdata/conf/desktop +++ b/testdata/conf/desktop @@ -3,12 +3,12 @@ # Desktop configuration [desktop] -searchpath /mnt/sd?/pandora/desktop:./testdata/app? # path to depth-search for PXMLs and pnd-files +searchpath /media/*/pandora/desktop:./testdata/app? # path to depth-search for PXMLs and pnd-files dotdesktoppath ./testdata/dotdesktop # path for pndnotifyd to spit .desktop files into iconpath ./testdata/doticons # path for pndnotifyd to drop icons into (can be same as dotdesktoppath if WM permits) [menu] -searchpath /mnt/sd?/pandora/menu:./testdata/menuapps # path to depth-search for PXMLs and pnd-files +searchpath /media/*/pandora/menu:./testdata/app?:./testdata/menuapps # path to depth-search for PXMLs and pnd-files dotdesktoppath ./testdata/menu # path for pndnotifyd to spit .desktop files into iconpath ./testdata/menuicons # path for pndnotifyd to drop icons into (can be same as dotdesktoppath if WM permits) -- 2.39.2