c886f2d3cc93ccb06c98f80efa3eb5df711065d4
[pandora-libraries.git] / minimenu / mmcat.h
1
2 #ifndef h_mmcat_h
3 #define h_mmcat_h
4
5 /* code for storing/retrieving/messing with 'categories' (ie: tabs, more or less)
6  */
7
8 // an appreg is a minimenu registered app, that in turn points to the libpnd disco-t entry, but also stores anything
9 // minimenu specific about it.
10 typedef struct _mm_appref_t {
11   pnd_disco_t *ref;
12   pnd_conf_handle ovrh;
13   // anything else?
14   struct _mm_appref_t *next;
15 } mm_appref_t;
16
17 // an actual category reference; points to a list of appref's and supplies a tabname, a filesystem mountpoint, etc.
18 typedef struct _mm_category_t {
19   char *catname;          // name of the category
20   unsigned int catflags;  // flags
21
22   // current applications
23   mm_appref_t *refs;      // apps (from g_active_apps) that are in this category
24   unsigned int refcount;  // how many apps in this category
25
26   // if a directory browser category, additional info is needed
27   char *fspath;           // NULL if a pnd-category (not a filesystem category)
28   pnd_box_handle disco;   // faux-applications generated from filesystem (so that refs can point to here)
29
30 } mm_category_t;
31
32 // the flags available for the above mm_category_t.catflags
33 #define CFNORMAL 1 // catflag
34 #define CFHIDDEN 2 // catflag: 1, 2, 4,...
35 #define CFSUBCAT 4 // catflag
36
37 // how many cats can we handle?
38 #define MAX_CATS 250
39
40 // what do we call the "All" tab, if present
41 #define CATEGORY_ALL "All"
42
43 // try to populate as many cats as necessary
44 void category_init ( void ); // set up; call first!
45 unsigned char category_push ( char *catname, pnd_disco_t *app, pnd_conf_handle ovrh, char *fspath, unsigned char visiblep ); // catname is not pulled from app, so we can make them up on the fly (ie: "All");
46 void category_dump ( void ); // sort the apprefs
47 void category_freeall ( void );
48 int cat_sort_score ( mm_category_t *cat, mm_appref_t *s1, mm_appref_t *s2 ); // like strcmp, but used to sort apps by title
49 void category_sort ( void ); // for sorting categories
50
51 // category mapping hack
52 typedef struct {
53   mm_category_t *target;  // mapping a category _to_ this other category
54   char *from;             // from this category
55 } mm_catmap_t;
56
57 unsigned char category_map_setup ( void ); // set up the mappings
58 mm_category_t *category_map_query ( char *cat );
59 unsigned char category_meta_push ( char *catname, char *parentcatname, pnd_disco_t *app, pnd_conf_handle ovrh, unsigned char visiblep );
60
61 // filesystem browser
62 unsigned char category_fs_restock ( mm_category_t *cat );
63
64 // advertising to rest of the system
65 //
66 extern mm_category_t *g_categories [ MAX_CATS ];
67 extern unsigned char g_categorycount;
68 #define CFALL    0xFF // filter mask
69 #define CFBYNAME 0xFE // filter mask; the name param is used to pick a single category to populate
70 void category_publish ( unsigned int filter_mask, char *param ); // populates g_categories and g_categorycount; pass in CFNORMAL or CFHIDDEN or CFALL or whatever
71 unsigned int category_count ( unsigned int filter_mask );
72 int category_index ( char *catname ); // figure out index in g_categories of named cat
73
74 #endif