Const police raid, making a lot of pointers to lang strings const and removing some ugly casting
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17251 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e1bc2d5b71
commit
33c44461e1
15 changed files with 58 additions and 56 deletions
|
@ -187,12 +187,12 @@ bool bookmark_autobookmark(void)
|
|||
return write_bookmark(false);
|
||||
}
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
unsigned char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY)};
|
||||
struct text_message message={(char **)lines, 1};
|
||||
const char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY)};
|
||||
const struct text_message message={lines, 1};
|
||||
#else
|
||||
unsigned char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY),
|
||||
const char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY),
|
||||
str(LANG_CONFIRM_WITH_BUTTON)};
|
||||
struct text_message message={(char **)lines, 2};
|
||||
const struct text_message message={lines, 2};
|
||||
#endif
|
||||
#if LCD_DEPTH > 1
|
||||
show_main_backdrop(); /* switch to main backdrop as we may come from wps */
|
||||
|
|
|
@ -104,7 +104,7 @@ bool ft_play_playlist(char* pathname, char* dirname, char* filename)
|
|||
if (global_settings.warnon_erase_dynplaylist &&
|
||||
playlist_modified(NULL))
|
||||
{
|
||||
char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
const char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
struct text_message message = {lines, 1};
|
||||
|
||||
if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
||||
|
@ -408,8 +408,8 @@ int ft_enter(struct tree_context* c)
|
|||
!global_settings.party_mode &&
|
||||
playlist_modified(NULL))
|
||||
{
|
||||
char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
struct text_message message={lines, 1};
|
||||
static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
static const struct text_message message={lines, 1};
|
||||
|
||||
if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
||||
break;
|
||||
|
|
|
@ -47,7 +47,7 @@ void gui_textarea_update(struct screen * display)
|
|||
}
|
||||
|
||||
int gui_textarea_put_message(struct screen * display,
|
||||
struct text_message * message,
|
||||
const struct text_message * message,
|
||||
int ystart)
|
||||
{
|
||||
int i;
|
||||
|
@ -78,7 +78,7 @@ void gui_textarea_update_nblines(struct screen * display)
|
|||
display->nb_lines = height / display->char_height;
|
||||
}
|
||||
|
||||
void talk_text_message(struct text_message * message, bool enqueue)
|
||||
void talk_text_message(const struct text_message * message, bool enqueue)
|
||||
{
|
||||
int line;
|
||||
if(message)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
struct text_message
|
||||
{
|
||||
char **message_lines;
|
||||
const char **message_lines;
|
||||
int nb_lines;
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,7 @@ extern void gui_textarea_update(struct screen * display);
|
|||
* returns : the number of lines effectively displayed
|
||||
*/
|
||||
extern int gui_textarea_put_message(struct screen * display,
|
||||
struct text_message * message,
|
||||
const struct text_message * message,
|
||||
int ystart);
|
||||
/*
|
||||
* Compute the number of text lines the display can draw with the current font
|
||||
|
@ -63,7 +63,7 @@ extern void gui_textarea_update_nblines(struct screen * display);
|
|||
* Speak a text_message. The message's lines may be virtual pointers
|
||||
* representing language / voicefont IDs (see settings.h).
|
||||
*/
|
||||
extern void talk_text_message(struct text_message * message, bool enqueue);
|
||||
extern void talk_text_message(const struct text_message * message, bool enqueue);
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
/*
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
* - no_message : message displayed if answer is 'no'
|
||||
*/
|
||||
static void gui_yesno_init(struct gui_yesno * yn,
|
||||
struct text_message * main_message,
|
||||
struct text_message * yes_message,
|
||||
struct text_message * no_message)
|
||||
const struct text_message * main_message,
|
||||
const struct text_message * yes_message,
|
||||
const struct text_message * no_message)
|
||||
{
|
||||
yn->main_message=main_message;
|
||||
yn->result_message[YESNO_YES]=yes_message;
|
||||
|
@ -92,7 +92,7 @@ static void gui_yesno_draw(struct gui_yesno * yn)
|
|||
*/
|
||||
static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
|
||||
{
|
||||
struct text_message * message=yn->result_message[result];
|
||||
const struct text_message * message=yn->result_message[result];
|
||||
if(message==NULL)
|
||||
return false;
|
||||
gui_textarea_put_message(yn->display, message, 0);
|
||||
|
@ -101,9 +101,9 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
|
|||
|
||||
#include "debug.h"
|
||||
|
||||
enum yesno_res gui_syncyesno_run(struct text_message * main_message,
|
||||
struct text_message * yes_message,
|
||||
struct text_message * no_message)
|
||||
enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
|
||||
const struct text_message * yes_message,
|
||||
const struct text_message * no_message)
|
||||
{
|
||||
int i;
|
||||
unsigned button;
|
||||
|
|
|
@ -32,8 +32,8 @@ enum yesno_res
|
|||
|
||||
struct gui_yesno
|
||||
{
|
||||
struct text_message * main_message;
|
||||
struct text_message * result_message[2];
|
||||
const struct text_message * main_message;
|
||||
const struct text_message * result_message[2];
|
||||
|
||||
struct screen * display;
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ struct gui_yesno
|
|||
* - no_message : message displayed if answer is 'no'
|
||||
*/
|
||||
extern enum yesno_res gui_syncyesno_run(
|
||||
struct text_message * main_message,
|
||||
struct text_message * yes_message,
|
||||
struct text_message * no_message);
|
||||
const struct text_message * main_message,
|
||||
const struct text_message * yes_message,
|
||||
const struct text_message * no_message);
|
||||
#endif /* _GUI_YESNO_H_ */
|
||||
|
|
|
@ -55,15 +55,18 @@ static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG};
|
|||
|
||||
static int reset_settings(void)
|
||||
{
|
||||
const unsigned char *lines[]={ID2P(LANG_RESET_ASK)};
|
||||
const unsigned char *yes_lines[]={
|
||||
str(LANG_SETTINGS),
|
||||
static const char *lines[]={ID2P(LANG_RESET_ASK)};
|
||||
static const char *yes_lines[]={
|
||||
ID2P(LANG_SETTINGS),
|
||||
ID2P(LANG_RESET_DONE_CLEAR)
|
||||
};
|
||||
const unsigned char *no_lines[]={yes_lines[0], ID2P(LANG_CANCEL)};
|
||||
struct text_message message={(char **)lines, 1};
|
||||
struct text_message yes_message={(char **)yes_lines, 2};
|
||||
struct text_message no_message={(char **)no_lines, 2};
|
||||
static const char *no_lines[]={
|
||||
ID2P(LANG_SETTINGS),
|
||||
ID2P(LANG_CANCEL)
|
||||
};
|
||||
static const struct text_message message={lines, 1};
|
||||
static const struct text_message yes_message={yes_lines, 2};
|
||||
static const struct text_message no_message={no_lines, 2};
|
||||
|
||||
switch(gui_syncyesno_run(&message, &yes_message, &no_message))
|
||||
{
|
||||
|
|
|
@ -1050,9 +1050,9 @@ void check_bootfile(bool do_rolo)
|
|||
if((entry->wrtdate != wrtdate) ||
|
||||
(entry->wrttime != wrttime))
|
||||
{
|
||||
char *lines[] = { ID2P(LANG_BOOT_CHANGED),
|
||||
ID2P(LANG_REBOOT_NOW) };
|
||||
struct text_message message={ lines, 2 };
|
||||
static const char *lines[] = { ID2P(LANG_BOOT_CHANGED),
|
||||
ID2P(LANG_REBOOT_NOW) };
|
||||
static const struct text_message message={ lines, 2 };
|
||||
button_clear_queue(); /* Empty the keyboard buffer */
|
||||
if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES)
|
||||
rolo_load(BOOTDIR "/" BOOTFILE);
|
||||
|
|
|
@ -160,11 +160,11 @@ static bool save_playlist(void)
|
|||
static bool add_to_playlist(int position, bool queue)
|
||||
{
|
||||
bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY);
|
||||
char *lines[] = {
|
||||
const char *lines[] = {
|
||||
ID2P(LANG_RECURSE_DIRECTORY_QUESTION),
|
||||
selected_file
|
||||
};
|
||||
struct text_message message={lines, 2};
|
||||
const struct text_message message={lines, 2};
|
||||
|
||||
gui_syncsplash(0, ID2P(LANG_WAIT));
|
||||
|
||||
|
@ -523,11 +523,11 @@ static int remove_dir(char* dirname, int len)
|
|||
/* share code for file and directory deletion, saves space */
|
||||
static bool delete_handler(bool is_dir)
|
||||
{
|
||||
char *lines[]={
|
||||
const char *lines[]={
|
||||
ID2P(LANG_REALLY_DELETE),
|
||||
selected_file
|
||||
};
|
||||
char *yes_lines[]={
|
||||
const char *yes_lines[]={
|
||||
ID2P(LANG_DELETED),
|
||||
selected_file
|
||||
};
|
||||
|
@ -867,8 +867,8 @@ static bool clipboard_paste(void)
|
|||
char *cwd, *nameptr;
|
||||
bool success;
|
||||
|
||||
unsigned char *lines[]={ID2P(LANG_REALLY_OVERWRITE)};
|
||||
struct text_message message={(char **)lines, 1};
|
||||
static const char *lines[]={ID2P(LANG_REALLY_OVERWRITE)};
|
||||
static const struct text_message message={lines, 1};
|
||||
|
||||
/* Get the name of the current directory */
|
||||
cwd = getcwd(NULL, 0);
|
||||
|
|
|
@ -378,11 +378,9 @@ static int add_to_playlist(const char* playlist, char* sel, int sel_attr)
|
|||
{
|
||||
/* search directory for tracks and append to playlist */
|
||||
bool recurse = false;
|
||||
char *lines[] = {
|
||||
(char *)str(LANG_RECURSE_DIRECTORY_QUESTION),
|
||||
sel
|
||||
};
|
||||
struct text_message message={lines, 2};
|
||||
const char *lines[] = {
|
||||
str(LANG_RECURSE_DIRECTORY_QUESTION), sel};
|
||||
const struct text_message message={lines, 2};
|
||||
struct add_track_context context;
|
||||
|
||||
if (global_settings.recursive_dir_insert != RECURSE_ASK)
|
||||
|
|
|
@ -136,11 +136,11 @@ static int scan_presets(void);
|
|||
|
||||
/* Function to manipulate all yesno dialogues.
|
||||
This function needs the output text as an argument. */
|
||||
static bool yesno_pop(char* text)
|
||||
static bool yesno_pop(const char* text)
|
||||
{
|
||||
int i;
|
||||
char *lines[]={text};
|
||||
struct text_message message={lines, 1};
|
||||
const char *lines[]={text};
|
||||
const struct text_message message={lines, 1};
|
||||
bool ret = (gui_syncyesno_run(&message,NULL,NULL)== YESNO_YES);
|
||||
FOR_NB_SCREENS(i)
|
||||
gui_textarea_clear(&screens[i]);
|
||||
|
|
|
@ -143,8 +143,9 @@ static int browser(void* param)
|
|||
{
|
||||
/* Prompt the user */
|
||||
reinit_attempted = true;
|
||||
char *lines[]={ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)};
|
||||
struct text_message message={lines, 2};
|
||||
static const char *lines[]={
|
||||
ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)};
|
||||
static const struct text_message message={lines, 2};
|
||||
if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO)
|
||||
break;
|
||||
int i;
|
||||
|
|
|
@ -1270,8 +1270,8 @@ static int runtime_speak_data(int selected_item, void* data)
|
|||
|
||||
bool view_runtime(void)
|
||||
{
|
||||
unsigned char *lines[]={ID2P(LANG_CLEAR_TIME)};
|
||||
struct text_message message={(char **)lines, 1};
|
||||
static const char *lines[]={ID2P(LANG_CLEAR_TIME)};
|
||||
static const struct text_message message={lines, 1};
|
||||
|
||||
struct gui_synclist lists;
|
||||
int action;
|
||||
|
|
|
@ -1501,8 +1501,8 @@ int tagtree_enter(struct tree_context* c)
|
|||
!global_settings.party_mode &&
|
||||
playlist_modified(NULL))
|
||||
{
|
||||
char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
struct text_message message={lines, 1};
|
||||
static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
static const struct text_message message={lines, 1};
|
||||
|
||||
if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
||||
break;
|
||||
|
|
|
@ -645,8 +645,8 @@ static int dirbrowse()
|
|||
tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
|
||||
#ifdef BOOTFILE
|
||||
if (boot_changed) {
|
||||
char *lines[]={ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW)};
|
||||
struct text_message message={lines, 2};
|
||||
static const char *lines[]={ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW)};
|
||||
static const struct text_message message={lines, 2};
|
||||
if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
|
||||
rolo_load("/" BOOTFILE);
|
||||
restore = true;
|
||||
|
|
Loading…
Reference in a new issue