summaryrefslogtreecommitdiff
path: root/apps/plugins/text_viewer/tv_bookmark.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/text_viewer/tv_bookmark.c')
-rw-r--r--apps/plugins/text_viewer/tv_bookmark.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/apps/plugins/text_viewer/tv_bookmark.c b/apps/plugins/text_viewer/tv_bookmark.c
index c6574dbb6f..815e7a1f91 100644
--- a/apps/plugins/text_viewer/tv_bookmark.c
+++ b/apps/plugins/text_viewer/tv_bookmark.c
@@ -166,6 +166,30 @@ void tv_create_system_bookmark(void)
166 } 166 }
167} 167}
168 168
169static const char* get_bookmark_name(int selected, void * data,
170 char * buffer, size_t buffer_len)
171{
172 (void)data;
173 struct tv_bookmark_info *bookmark = &bookmarks[selected];
174 rb->snprintf(buffer, buffer_len,
175#ifdef HAVE_LCD_BITMAP
176 "%cPage: %d Line: %d",
177#else
178 "%cP:%d L:%d",
179#endif
180 (bookmark->flag & TV_BOOKMARK_SYSTEM)? '*' : ' ',
181 bookmark->pos.page + 1, bookmark->pos.line + 1);
182 return buffer;
183}
184
185static int list_action_callback(int action, struct gui_synclist *lists)
186{
187 (void) lists;
188 if (action == ACTION_STD_OK)
189 return ACTION_STD_CANCEL;
190 return action;
191}
192
169void tv_select_bookmark(void) 193void tv_select_bookmark(void)
170{ 194{
171 int i; 195 int i;
@@ -185,32 +209,18 @@ void tv_select_bookmark(void)
185 select_pos = bookmarks[0].pos; 209 select_pos = bookmarks[0].pos;
186 else 210 else
187 { 211 {
188 int selected = -1; 212 struct simplelist_info info;
189 struct opt_items items[bookmark_count];
190 unsigned char names[bookmark_count][24];
191 213
192 rb->qsort(bookmarks, bookmark_count, sizeof(struct tv_bookmark_info), bm_comp); 214 rb->qsort(bookmarks, bookmark_count, sizeof(struct tv_bookmark_info), bm_comp);
193 215
194 for (i = 0; i < bookmark_count; i++) 216 rb->simplelist_info_init(&info, "Select bookmark",
195 { 217 bookmark_count, bookmarks);
196 rb->snprintf(names[i], sizeof(names[0]), 218 info.get_name = get_bookmark_name;
197#if CONFIG_KEYPAD != PLAYER_PAD 219 info.action_callback = list_action_callback;
198 "%cPage: %d Line: %d", 220 rb->simplelist_show_list(&info);
199#else
200 "%cP:%d L:%d",
201#endif
202 (bookmarks[i].flag & TV_BOOKMARK_SYSTEM)? '*' : ' ',
203 bookmarks[i].pos.page + 1,
204 bookmarks[i].pos.line + 1);
205 items[i].string = names[i];
206 items[i].voice_id = -1;
207 }
208
209 rb->set_option("Select bookmark", &selected, INT, items,
210 bookmark_count, NULL);
211 221
212 if (selected >= 0 && selected < bookmark_count) 222 if (info.selection >= 0 && info.selection < bookmark_count)
213 select_pos = bookmarks[selected].pos; 223 select_pos = bookmarks[info.selection].pos;
214 else 224 else
215 { 225 {
216 /* when does not select any bookmarks, move to the current page */ 226 /* when does not select any bookmarks, move to the current page */