diff options
author | Nils Wallménius <nils@rockbox.org> | 2009-08-20 16:47:44 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2009-08-20 16:47:44 +0000 |
commit | 3200d04d75c5e7556ed8880b155533e881a4d1e1 (patch) | |
tree | 188e2c9525b25cb8922a14766e51ab02bad3f831 /apps/gui | |
parent | 0a1728444882cdbc6a0c815bd88464de25ad94e9 (diff) | |
download | rockbox-3200d04d75c5e7556ed8880b155533e881a4d1e1.tar.gz rockbox-3200d04d75c5e7556ed8880b155533e881a4d1e1.zip |
Make the formatter functions used by the settings return a pointer to avoid usless copying of lang strings, this brought with it a long chain of const correctness and a few random cleanups
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22440 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/bitmap/list.c | 2 | ||||
-rw-r--r-- | apps/gui/charcell/list.c | 2 | ||||
-rw-r--r-- | apps/gui/list.c | 10 | ||||
-rw-r--r-- | apps/gui/list.h | 4 | ||||
-rw-r--r-- | apps/gui/option_select.c | 22 | ||||
-rw-r--r-- | apps/gui/option_select.h | 2 | ||||
-rw-r--r-- | apps/gui/quickscreen.c | 4 |
7 files changed, 24 insertions, 22 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 8e4cd44d21..71c74dbd09 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c | |||
@@ -173,7 +173,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
173 | for (i=start; i<end && i<list->nb_items; i++) | 173 | for (i=start; i<end && i<list->nb_items; i++) |
174 | { | 174 | { |
175 | /* do the text */ | 175 | /* do the text */ |
176 | unsigned char *s; | 176 | unsigned const char *s; |
177 | char entry_buffer[MAX_PATH]; | 177 | char entry_buffer[MAX_PATH]; |
178 | unsigned char *entry_name; | 178 | unsigned char *entry_name; |
179 | int text_pos = 0; | 179 | int text_pos = 0; |
diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c index 8d91c2f6b8..2374156f0b 100644 --- a/apps/gui/charcell/list.c +++ b/apps/gui/charcell/list.c | |||
@@ -69,7 +69,7 @@ void list_draw(struct screen *display, struct gui_synclist *gui_list) | |||
69 | 69 | ||
70 | for (i = start; i < end; i++) | 70 | for (i = start; i < end; i++) |
71 | { | 71 | { |
72 | unsigned char *s; | 72 | unsigned const char *s; |
73 | char entry_buffer[MAX_PATH]; | 73 | char entry_buffer[MAX_PATH]; |
74 | unsigned char *entry_name; | 74 | unsigned char *entry_name; |
75 | int current_item = gui_list->start_item[display->screen_type] + i; | 75 | int current_item = gui_list->start_item[display->screen_type] + i; |
diff --git a/apps/gui/list.c b/apps/gui/list.c index 332459c57f..9b139dd47c 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -827,10 +827,10 @@ void simplelist_addline(int line_number, const char *fmt, ...) | |||
827 | va_end(ap); | 827 | va_end(ap); |
828 | } | 828 | } |
829 | 829 | ||
830 | static char* simplelist_static_getname(int item, | 830 | static const char* simplelist_static_getname(int item, |
831 | void * data, | 831 | void * data, |
832 | char *buffer, | 832 | char *buffer, |
833 | size_t buffer_len) | 833 | size_t buffer_len) |
834 | { | 834 | { |
835 | (void)data; (void)buffer; (void)buffer_len; | 835 | (void)data; (void)buffer; (void)buffer_len; |
836 | return simplelist_text[item]; | 836 | return simplelist_text[item]; |
@@ -841,7 +841,7 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
841 | struct gui_synclist lists; | 841 | struct gui_synclist lists; |
842 | int action, old_line_count = simplelist_line_count; | 842 | int action, old_line_count = simplelist_line_count; |
843 | int oldbars = viewportmanager_set_statusbar(VP_SB_ALLSCREENS); | 843 | int oldbars = viewportmanager_set_statusbar(VP_SB_ALLSCREENS); |
844 | char* (*getname)(int item, void * data, char *buffer, size_t buffer_len); | 844 | const char* (*getname)(int item, void * data, char *buffer, size_t buffer_len); |
845 | int wrap = LIST_WRAP_UNLESS_HELD; | 845 | int wrap = LIST_WRAP_UNLESS_HELD; |
846 | if (info->get_name) | 846 | if (info->get_name) |
847 | getname = info->get_name; | 847 | getname = info->get_name; |
diff --git a/apps/gui/list.h b/apps/gui/list.h index 7148e340cc..8a36acb005 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h | |||
@@ -64,8 +64,8 @@ typedef enum themable_icons list_get_icon(int selected_item, void * data); | |||
64 | * - buffer_len : length of the buffer | 64 | * - buffer_len : length of the buffer |
65 | * Returns a pointer to a string that contains the text to display | 65 | * Returns a pointer to a string that contains the text to display |
66 | */ | 66 | */ |
67 | typedef char * list_get_name(int selected_item, void * data, | 67 | typedef const char * list_get_name(int selected_item, void * data, |
68 | char * buffer, size_t buffer_len); | 68 | char * buffer, size_t buffer_len); |
69 | /* | 69 | /* |
70 | * Voice callback | 70 | * Voice callback |
71 | * - selected_item : an integer that tells the number of the item to speak | 71 | * - selected_item : an integer that tells the number of the item to speak |
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 01259c4136..d806a0aa08 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c | |||
@@ -69,10 +69,11 @@ static const char *unit_strings[] = | |||
69 | /* these two vars are needed so arbitrary values can be added to the | 69 | /* these two vars are needed so arbitrary values can be added to the |
70 | TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */ | 70 | TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */ |
71 | static int table_setting_oldval = 0, table_setting_array_position = 0; | 71 | static int table_setting_oldval = 0, table_setting_array_position = 0; |
72 | char *option_get_valuestring(const struct settings_list *setting, | 72 | const char *option_get_valuestring(const struct settings_list *setting, |
73 | char *buffer, int buf_len, | 73 | char *buffer, int buf_len, |
74 | intptr_t temp_var) | 74 | intptr_t temp_var) |
75 | { | 75 | { |
76 | const char* str = buffer; | ||
76 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | 77 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) |
77 | { | 78 | { |
78 | bool val = (bool)temp_var; | 79 | bool val = (bool)temp_var; |
@@ -93,7 +94,7 @@ char *option_get_valuestring(const struct settings_list *setting, | |||
93 | const struct int_setting *int_info = setting->int_setting; | 94 | const struct int_setting *int_info = setting->int_setting; |
94 | const struct table_setting *tbl_info = setting->table_setting; | 95 | const struct table_setting *tbl_info = setting->table_setting; |
95 | const char *unit; | 96 | const char *unit; |
96 | void (*formatter)(char*, size_t, int, const char*); | 97 | const char* (*formatter)(char*, size_t, int, const char*); |
97 | if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) | 98 | if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) |
98 | { | 99 | { |
99 | formatter = int_info->formatter; | 100 | formatter = int_info->formatter; |
@@ -105,7 +106,7 @@ char *option_get_valuestring(const struct settings_list *setting, | |||
105 | unit = unit_strings[tbl_info->unit]; | 106 | unit = unit_strings[tbl_info->unit]; |
106 | } | 107 | } |
107 | if (formatter) | 108 | if (formatter) |
108 | formatter(buffer, buf_len, (int)temp_var, unit); | 109 | str = formatter(buffer, buf_len, (int)temp_var, unit); |
109 | else | 110 | else |
110 | snprintf(buffer, buf_len, "%d %s", (int)temp_var, unit?unit:""); | 111 | snprintf(buffer, buf_len, "%d %s", (int)temp_var, unit?unit:""); |
111 | } | 112 | } |
@@ -152,7 +153,7 @@ char *option_get_valuestring(const struct settings_list *setting, | |||
152 | strlcpy(buffer, val, buf_len); | 153 | strlcpy(buffer, val, buf_len); |
153 | } | 154 | } |
154 | } | 155 | } |
155 | return buffer; | 156 | return str; |
156 | } | 157 | } |
157 | void option_talk_value(const struct settings_list *setting, int value, bool enqueue) | 158 | void option_talk_value(const struct settings_list *setting, int value, bool enqueue) |
158 | { | 159 | { |
@@ -363,10 +364,11 @@ static int selection_to_val(const struct settings_list *setting, int selection) | |||
363 | } | 364 | } |
364 | return max- (selection * step); | 365 | return max- (selection * step); |
365 | } | 366 | } |
366 | static char * value_setting_get_name_cb(int selected_item, | 367 | |
367 | void * data, | 368 | static const char * value_setting_get_name_cb(int selected_item, |
368 | char *buffer, | 369 | void * data, |
369 | size_t buffer_len) | 370 | char *buffer, |
371 | size_t buffer_len) | ||
370 | { | 372 | { |
371 | selected_item = selection_to_val(data, selected_item); | 373 | selected_item = selection_to_val(data, selected_item); |
372 | return option_get_valuestring(data, buffer, buffer_len, selected_item); | 374 | return option_get_valuestring(data, buffer, buffer_len, selected_item); |
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h index b1a4a86e65..a8661fb8ad 100644 --- a/apps/gui/option_select.h +++ b/apps/gui/option_select.h | |||
@@ -33,7 +33,7 @@ bool option_screen(const struct settings_list *setting, | |||
33 | void option_select_next_val(const struct settings_list *setting, | 33 | void option_select_next_val(const struct settings_list *setting, |
34 | bool previous, bool apply); | 34 | bool previous, bool apply); |
35 | #endif | 35 | #endif |
36 | char *option_get_valuestring(const struct settings_list *setting, | 36 | const char *option_get_valuestring(const struct settings_list *setting, |
37 | char *buffer, int buf_len, | 37 | char *buffer, int buf_len, |
38 | intptr_t temp_var); | 38 | intptr_t temp_var); |
39 | void option_talk_value(const struct settings_list *setting, int value, bool enqueue); | 39 | void option_talk_value(const struct settings_list *setting, int value, bool enqueue); |
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 20d27380d2..d6d662b1f1 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c | |||
@@ -147,7 +147,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, | |||
147 | vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y; | 147 | vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y; |
148 | } | 148 | } |
149 | 149 | ||
150 | static void quickscreen_draw_text(char *s, int item, bool title, | 150 | static void quickscreen_draw_text(const char *s, int item, bool title, |
151 | struct screen *display, struct viewport *vp) | 151 | struct screen *display, struct viewport *vp) |
152 | { | 152 | { |
153 | int nb_lines = viewport_get_nb_lines(vp); | 153 | int nb_lines = viewport_get_nb_lines(vp); |
@@ -186,7 +186,7 @@ static void gui_quickscreen_draw(struct gui_quickscreen *qs, | |||
186 | 186 | ||
187 | int i; | 187 | int i; |
188 | char buf[MAX_PATH]; | 188 | char buf[MAX_PATH]; |
189 | unsigned char *title, *value; | 189 | unsigned const char *title, *value; |
190 | void *setting; | 190 | void *setting; |
191 | int temp; | 191 | int temp; |
192 | display->set_viewport(parent); | 192 | display->set_viewport(parent); |