git.openpandora.org
/
pandora-libraries.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1db3cb8
)
mmenu: can now associate custom cats/subcats to an app; special exception -- you...
author
skeezix
<skeezix@flotsam-vm.(none)>
Wed, 9 Feb 2011 21:11:53 +0000
(16:11 -0500)
committer
skeezix
<skeezix@flotsam-vm.(none)>
Wed, 9 Feb 2011 21:11:53 +0000
(16:11 -0500)
minimenu/freedesktop_cats.c
patch
|
blob
|
history
minimenu/freedesktop_cats.h
patch
|
blob
|
history
minimenu/mmcustom_cats.c
patch
|
blob
|
history
minimenu/mmcustom_cats.h
patch
|
blob
|
history
minimenu/mmui.c
patch
|
blob
|
history
minimenu/mmui.h
patch
|
blob
|
history
diff --git
a/minimenu/freedesktop_cats.c
b/minimenu/freedesktop_cats.c
index
087a105
..
f4e7e78
100644
(file)
--- a/
minimenu/freedesktop_cats.c
+++ b/
minimenu/freedesktop_cats.c
@@
-203,6
+203,16
@@
freedesktop_cat_t *freedesktop_category_query ( char *name, char *parentcatname
return ( NULL );
}
return ( NULL );
}
+unsigned int freedesktop_count ( void ) {
+ unsigned int i = 0;
+
+ while ( freedesktop_complete [ i ].cat ) {
+ i++;
+ }
+
+ return ( i );
+}
+
#if 0
int main ( void ) {
#if 0
int main ( void ) {
diff --git
a/minimenu/freedesktop_cats.h
b/minimenu/freedesktop_cats.h
index
362be8a
..
fd4cb2e
100644
(file)
--- a/
minimenu/freedesktop_cats.h
+++ b/
minimenu/freedesktop_cats.h
@@
-12,6
+12,7
@@
extern freedesktop_cat_t freedesktop_complete[];
// return NULL on error, otherwise a category entry
freedesktop_cat_t *freedesktop_category_query ( char *name, char *parentcatname );
// return NULL on error, otherwise a category entry
freedesktop_cat_t *freedesktop_category_query ( char *name, char *parentcatname );
+unsigned int freedesktop_count ( void );
#define BADCATNAME "Other" /* irony: Other is itself not a freedesktop category */
#define BADCATNAME "Other" /* irony: Other is itself not a freedesktop category */
diff --git
a/minimenu/mmcustom_cats.c
b/minimenu/mmcustom_cats.c
index
7cb341a
..
445a81d
100644
(file)
--- a/
minimenu/mmcustom_cats.c
+++ b/
minimenu/mmcustom_cats.c
@@
-79,7
+79,7
@@
unsigned char mmcustom_setup ( void ) {
} // while
} // while
- pnd_log ( pndn_rem, "Found %u custom categories.\n", mmcustom_count );
+
//
pnd_log ( pndn_rem, "Found %u custom categories.\n", mmcustom_count );
} // loaded already?
} // loaded already?
@@
-95,6
+95,10
@@
void mmcustom_shutdown ( void ) {
return;
}
return;
}
+unsigned char mmcustom_is_ready ( void ) {
+ return ( loaded );
+}
+
unsigned char mmcustom_write ( char *fullpath /* if NULL, uses canonical location */ ) {
if ( ! fullpath ) {
unsigned char mmcustom_write ( char *fullpath /* if NULL, uses canonical location */ ) {
if ( ! fullpath ) {
diff --git
a/minimenu/mmcustom_cats.h
b/minimenu/mmcustom_cats.h
index
a003451
..
73738ef
100644
(file)
--- a/
minimenu/mmcustom_cats.h
+++ b/
minimenu/mmcustom_cats.h
@@
-19,6
+19,8
@@
extern unsigned int mmcustom_count;
unsigned char mmcustom_setup ( void ); // load
void mmcustom_shutdown ( void ); // unload
unsigned char mmcustom_setup ( void ); // load
void mmcustom_shutdown ( void ); // unload
+unsigned char mmcustom_is_ready ( void );
+
unsigned char mmcustom_write ( char *fullpath /* if NULL, uses canonical location */ ); // save
char *mmcustom_determine_path ( void );
unsigned char mmcustom_write ( char *fullpath /* if NULL, uses canonical location */ ); // save
char *mmcustom_determine_path ( void );
diff --git
a/minimenu/mmui.c
b/minimenu/mmui.c
index
1770897
..
4dde7b8
100644
(file)
--- a/
minimenu/mmui.c
+++ b/
minimenu/mmui.c
@@
-3385,6
+3385,18
@@
void ui_menu_context ( mm_appref_t *a ) {
unsigned char optmax = 0;
unsigned char i;
unsigned char optmax = 0;
unsigned char i;
+ // show custom categories
+ if ( mmcustom_setup() ) {
+
+ for ( i = 0; i < mmcustom_count; i++ ) {
+ if ( mmcustom_complete [ i ].parent_cat == NULL ) {
+ opts [ optmax++ ] = mmcustom_complete [ i ].cat;
+ }
+ }
+
+ }
+
+ // show FD categories
i = 2; // skip first two - Other and NoParentCategory
while ( 1 ) {
i = 2; // skip first two - Other and NoParentCategory
while ( 1 ) {
@@
-3399,6
+3411,7
@@
void ui_menu_context ( mm_appref_t *a ) {
i++;
} // while
i++;
} // while
+ // picker
char prompt [ 101 ];
snprintf ( prompt, 100, "Pick category [%s]", a -> ref -> main_category ? a -> ref -> main_category : "NoParentCategory" );
char prompt [ 101 ];
snprintf ( prompt, 100, "Pick category [%s]", a -> ref -> main_category ? a -> ref -> main_category : "NoParentCategory" );
@@
-3417,6
+3430,10
@@
void ui_menu_context ( mm_appref_t *a ) {
}
}
+ if ( mmcustom_is_ready() ) {
+ mmcustom_shutdown();
+ }
+
}
break;
}
break;
@@
-3424,24
+3441,36
@@
void ui_menu_context ( mm_appref_t *a ) {
{
char *opts [ 250 ];
unsigned char optmax = 0;
{
char *opts [ 250 ];
unsigned char optmax = 0;
- unsigned char i;
+ unsigned char i
= 0
;
- i = 0;
+ char *whichparentarewe;
+ if ( g_categories [ ui_category ] -> parent_catname ) {
+ whichparentarewe = g_categories [ ui_category ] -> parent_catname;
+ } else {
+ whichparentarewe = g_categories [ ui_category ] -> catname;
+ }
+
+ // add NoSubcategory magic one
opts [ optmax++ ] = freedesktop_complete [ 2 ].cat;
opts [ optmax++ ] = freedesktop_complete [ 2 ].cat;
+ // add custom categories
+ if ( mmcustom_setup() ) {
+
+ for ( i = 0; i < mmcustom_count; i++ ) {
+ if ( mmcustom_complete [ i ].parent_cat && strcmp ( mmcustom_complete [ i ].parent_cat, whichparentarewe ) == 0 ) {
+ opts [ optmax++ ] = mmcustom_complete [ i ].cat;
+ }
+ }
+
+ }
+
+ // add FD categories
while ( 1 ) {
if ( ! freedesktop_complete [ i ].cat ) {
break;
}
while ( 1 ) {
if ( ! freedesktop_complete [ i ].cat ) {
break;
}
- 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 )
)
if ( ( freedesktop_complete [ i ].parent_cat ) &&
( strcasecmp ( freedesktop_complete [ i ].parent_cat, whichparentarewe ) == 0 )
)
@@
-3453,7
+3482,8
@@
void ui_menu_context ( mm_appref_t *a ) {
} // while
char prompt [ 101 ];
} // while
char prompt [ 101 ];
- snprintf ( prompt, 100, "Pick subcategory [%s]", a -> ref -> main_category1 ? a -> ref -> main_category1 : "NoSubcategory" );
+ //snprintf ( prompt, 100, "Currently: %s", a -> ref -> main_category1 ? a -> ref -> main_category1 : "NoSubcategory" );
+ snprintf ( prompt, 100, "%s [%s]", a -> ref -> main_category1 ? a -> ref -> main_category1 : "NoSubcategory", whichparentarewe );
int sel = ui_modal_single_menu ( opts, optmax, prompt /*"Select subcategory"*/, "Enter to select; other to skip." );
int sel = ui_modal_single_menu ( opts, optmax, prompt /*"Select subcategory"*/, "Enter to select; other to skip." );
@@
-3468,6
+3498,10
@@
void ui_menu_context ( mm_appref_t *a ) {
}
}
+ if ( mmcustom_is_ready() ) {
+ mmcustom_shutdown();
+ }
+
}
break;
}
break;
@@
-3771,7
+3805,7
@@
unsigned char ui_menu_get_text_line ( char *title, char *footer, char *initialva
}
unsigned char ovr_replace_or_add ( mm_appref_t *a, char *keybase, char *newvalue ) {
}
unsigned char ovr_replace_or_add ( mm_appref_t *a, char *keybase, char *newvalue ) {
- printf ( "setting %s:%u - '%s' to '%s' - %s/%s\n", a -> ref -> title_en, a -> ref -> subapp_number, keybase, newvalue, a -> ref -> object_path, a -> ref -> object_filename );
+
//
printf ( "setting %s:%u - '%s' to '%s' - %s/%s\n", a -> ref -> title_en, a -> ref -> subapp_number, keybase, newvalue, a -> ref -> object_path, a -> ref -> object_filename );
char fullpath [ PATH_MAX ];
char fullpath [ PATH_MAX ];
@@
-3780,7
+3814,7
@@
unsigned char ovr_replace_or_add ( mm_appref_t *a, char *keybase, char *newvalue
if ( dot ) {
sprintf ( dot, PXML_SAMEPATH_OVERRIDE_FILEEXT );
} else {
if ( dot ) {
sprintf ( dot, PXML_SAMEPATH_OVERRIDE_FILEEXT );
} else {
-
fprintf ( stder
r, "ERROR: Bad pnd-path in disco_t! %s\n", fullpath );
+
pnd_log ( pndn_erro
r, "ERROR: Bad pnd-path in disco_t! %s\n", fullpath );
return ( 0 );
}
return ( 0 );
}
@@
-3846,7
+3880,7
@@
void ui_manage_categories ( void ) {
case 0: // list custom
if ( mmcustom_count ) {
case 0: // list custom
if ( mmcustom_count ) {
- ui_pick_custom_category
(
);
+ ui_pick_custom_category
( 0
);
} else {
ui_menu_oneby ( "Warning", "B/Enter to accept", "There are none registered." );
}
} else {
ui_menu_oneby ( "Warning", "B/Enter to accept", "There are none registered." );
}
@@
-3855,13
+3889,13
@@
void ui_manage_categories ( void ) {
case 1: // list custom sub
if ( mmcustom_count ) {
case 1: // list custom sub
if ( mmcustom_count ) {
-
int maincat = ui_pick_custom_category(
);
+
char *maincat = ui_pick_custom_category ( 0
);
- if ( maincat
>= 0
) {
- unsigned int subcount = mmcustom_count_subcats ( m
mcustom_complete [ maincat ].
cat );
+ if ( maincat ) {
+ unsigned int subcount = mmcustom_count_subcats ( m
ain
cat );
char titlebuf [ 201 ];
char titlebuf [ 201 ];
- snprintf ( titlebuf, 200, "Category: %s", m
mcustom_complete [ maincat ].
cat );
+ snprintf ( titlebuf, 200, "Category: %s", m
ain
cat );
if ( subcount == 0 ) {
ui_menu_oneby ( titlebuf, "B/Enter to accept", "Category has no subcategories." );
if ( subcount == 0 ) {
ui_menu_oneby ( titlebuf, "B/Enter to accept", "Category has no subcategories." );
@@
-3872,7
+3906,7
@@
void ui_manage_categories ( void ) {
unsigned int counter = 0;
for ( i = 0; i < mmcustom_count; i++ ) {
unsigned int counter = 0;
for ( i = 0; i < mmcustom_count; i++ ) {
- if ( mmcustom_complete [ i ].parent_cat && strcasecmp ( mmcustom_complete [ i ].parent_cat, m
mcustom_complete [ maincat ].
cat ) == 0 ) {
+ if ( mmcustom_complete [ i ].parent_cat && strcasecmp ( mmcustom_complete [ i ].parent_cat, m
ain
cat ) == 0 ) {
list [ counter++ ] = mmcustom_complete [ i ].cat;
}
}
list [ counter++ ] = mmcustom_complete [ i ].cat;
}
}
@@
-3929,12
+3963,12
@@
void ui_manage_categories ( void ) {
case 3: // register custom sub
if ( mmcustom_count ) {
case 3: // register custom sub
if ( mmcustom_count ) {
-
int maincat = ui_pick_custom_category(
);
+
char *maincat = ui_pick_custom_category ( 1 /* include FD */
);
- if ( maincat
>= 0
) {
+ if ( maincat ) {
char titlebuf [ 201 ];
char titlebuf [ 201 ];
- snprintf ( titlebuf, 200, "Subcat of: %s", m
mcustom_complete [ maincat ].
cat );
+ snprintf ( titlebuf, 200, "Subcat of: %s", m
ain
cat );
unsigned char changed;
char namebuf [ 101 ] = "";
unsigned char changed;
char namebuf [ 101 ] = "";
@@
-3945,18
+3979,18
@@
void ui_manage_categories ( void ) {
if ( changed ) {
// and if so, is it existant already or not?
if ( changed ) {
// and if so, is it existant already or not?
- if ( mmcustom_query ( namebuf, m
mcustom_complete [ maincat ].
cat ) ) {
+ if ( mmcustom_query ( namebuf, m
ain
cat ) ) {
ui_menu_oneby ( "Warning", "B/Enter to accept", "Already a subcategory." );
ui_menu_oneby ( "Warning", "B/Enter to accept", "Already a subcategory." );
- } else if ( freedesktop_category_query ( namebuf, m
mcustom_complete [ maincat ].
cat ) ) {
+ } else if ( freedesktop_category_query ( namebuf, m
ain
cat ) ) {
ui_menu_oneby ( "Warning", "B/Enter to accept", "Already a Standard subcategory." );
} else {
char confirm [ 1001 ];
ui_menu_oneby ( "Warning", "B/Enter to accept", "Already a Standard subcategory." );
} else {
char confirm [ 1001 ];
- snprintf ( confirm, 1000, "Confirm: %s [%s]", namebuf, m
mcustom_complete [ maincat ].
cat );
+ snprintf ( confirm, 1000, "Confirm: %s [%s]", namebuf, m
ain
cat );
if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm new category", "Do not register" ) == 1 ) {
// register, save, recycle the current list
if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm new category", "Do not register" ) == 1 ) {
// register, save, recycle the current list
- mmcustom_register ( namebuf, m
mcustom_complete [ maincat ].
cat );
+ mmcustom_register ( namebuf, m
ain
cat );
mmcustom_write ( NULL );
mmcustom_shutdown();
mmcustom_setup();
mmcustom_write ( NULL );
mmcustom_shutdown();
mmcustom_setup();
@@
-3975,15
+4009,15
@@
void ui_manage_categories ( void ) {
case 4: // unreg custom
if ( mmcustom_count ) {
case 4: // unreg custom
if ( mmcustom_count ) {
-
int maincat = ui_pick_custom_category(
);
+
char *maincat = ui_pick_custom_category ( 0
);
- if ( maincat
>= 0
) {
+ if ( maincat ) {
char confirm [ 1001 ];
char confirm [ 1001 ];
- snprintf ( confirm, 1000, "Confirm remove: %s", m
mcustom_complete [ maincat ].
cat );
+ snprintf ( confirm, 1000, "Confirm remove: %s", m
ain
cat );
if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm unregister", "Do not unregister" ) == 1 ) {
// register, save, recycle the current list
if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm unregister", "Do not unregister" ) == 1 ) {
// register, save, recycle the current list
- mmcustom_unregister ( m
mcustom_complete [ maincat ].
cat, NULL );
+ mmcustom_unregister ( m
ain
cat, NULL );
mmcustom_write ( NULL );
mmcustom_shutdown();
mmcustom_setup();
mmcustom_write ( NULL );
mmcustom_shutdown();
mmcustom_setup();
@@
-3998,13
+4032,13
@@
void ui_manage_categories ( void ) {
case 5: // unreg custom sub
if ( mmcustom_count ) {
case 5: // unreg custom sub
if ( mmcustom_count ) {
-
int maincat = ui_pick_custom_category(
);
+
char *maincat = ui_pick_custom_category ( 0
);
- if ( maincat
>= 0
) {
- unsigned int subcount = mmcustom_count_subcats ( m
mcustom_complete [ maincat ].
cat );
+ if ( maincat ) {
+ unsigned int subcount = mmcustom_count_subcats ( m
ain
cat );
char titlebuf [ 201 ];
char titlebuf [ 201 ];
- snprintf ( titlebuf, 200, "Category: %s", m
mcustom_complete [ maincat ].
cat );
+ snprintf ( titlebuf, 200, "Category: %s", m
ain
cat );
if ( subcount == 0 ) {
ui_menu_oneby ( titlebuf, "B/Enter to accept", "Category has no subcategories." );
if ( subcount == 0 ) {
ui_menu_oneby ( titlebuf, "B/Enter to accept", "Category has no subcategories." );
@@
-4015,7
+4049,7
@@
void ui_manage_categories ( void ) {
unsigned int counter = 0;
for ( i = 0; i < mmcustom_count; i++ ) {
unsigned int counter = 0;
for ( i = 0; i < mmcustom_count; i++ ) {
- if ( mmcustom_complete [ i ].parent_cat && strcasecmp ( mmcustom_complete [ i ].parent_cat, m
mcustom_complete [ maincat ].
cat ) == 0 ) {
+ if ( mmcustom_complete [ i ].parent_cat && strcasecmp ( mmcustom_complete [ i ].parent_cat, m
ain
cat ) == 0 ) {
list [ counter++ ] = mmcustom_complete [ i ].cat;
}
}
list [ counter++ ] = mmcustom_complete [ i ].cat;
}
}
@@
-4028,7
+4062,7
@@
void ui_manage_categories ( void ) {
if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm unregister", "Do not unregister" ) == 1 ) {
// register, save, recycle the current list
if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm unregister", "Do not unregister" ) == 1 ) {
// register, save, recycle the current list
- mmcustom_unregister ( list [ sel ], m
mcustom_complete [ maincat ].
cat );
+ mmcustom_unregister ( list [ sel ], m
ain
cat );
mmcustom_write ( NULL );
mmcustom_shutdown();
mmcustom_setup();
mmcustom_write ( NULL );
mmcustom_shutdown();
mmcustom_setup();
@@
-4071,31
+4105,50
@@
void ui_manage_categories ( void ) {
return;
}
return;
}
-
int ui_pick_custom_category ( voi
d ) {
- char **list
= malloc ( mmcustom_count * sizeof(char*) )
;
+
char *ui_pick_custom_category ( unsigned char include_f
d ) {
+ char **list;
int i;
unsigned int counter = 0;
int i;
unsigned int counter = 0;
+ if ( include_fd ) {
+ list = malloc ( (mmcustom_count+freedesktop_count()) * sizeof(char*) );
+ } else {
+ list = malloc ( mmcustom_count * sizeof(char*) );
+ }
+
+ // add custom
for ( i = 0; i < mmcustom_count; i++ ) {
if ( mmcustom_complete [ i ].parent_cat == NULL ) {
list [ counter++ ] = mmcustom_complete [ i ].cat;
}
}
for ( i = 0; i < mmcustom_count; i++ ) {
if ( mmcustom_complete [ i ].parent_cat == NULL ) {
list [ counter++ ] = mmcustom_complete [ i ].cat;
}
}
- int sel = ui_modal_single_menu ( list, counter, "Custom Main Categories", "Any button to exit." );
+ // add FD
+ if ( include_fd ) {
+ i = 3;
+ while ( 1 ) {
- counter = 0;
- for ( i = 0; i < mmcustom_count; i++ ) {
- if ( mmcustom_complete [ i ].parent_cat == NULL ) {
- if ( counter == sel ) {
- free ( list );
- return ( i );
+ if ( ! freedesktop_complete [ i ].cat ) {
+ break;
}
}
- counter ++;
- }
+
+ if ( freedesktop_complete [ i ].parent_cat == NULL ) {
+ list [ counter++ ] = freedesktop_complete [ i ].cat;
+ }
+
+ i++;
+ } // while
+ } // if
+
+ int sel = ui_modal_single_menu ( list, counter, "Custom Main Categories", "Any button to exit." );
+
+ if ( sel < 0 ) {
+ free ( list );
+ return ( NULL );
}
}
+ char *foo = list [ sel ];
free ( list );
free ( list );
- return (
-1
);
+ return (
foo
);
}
}
diff --git
a/minimenu/mmui.h
b/minimenu/mmui.h
index
65cdb71
..
464c5f5
100644
(file)
--- a/
minimenu/mmui.h
+++ b/
minimenu/mmui.h
@@
-75,7
+75,7
@@
unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p );
void ui_aboutscreen ( char *textpath );
void ui_revealscreen ( void );
void ui_manage_categories ( void );
void ui_aboutscreen ( char *textpath );
void ui_revealscreen ( void );
void ui_manage_categories ( void );
-
int ui_pick_custom_category ( voi
d );
+
char *ui_pick_custom_category ( unsigned char include_f
d );
/* internal functions follow
*/
/* internal functions follow
*/