diff options
Diffstat (limited to 'apps/gui/quickscreen.c')
-rw-r--r-- | apps/gui/quickscreen.c | 116 |
1 files changed, 13 insertions, 103 deletions
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 4c0cddf7ac..3880940ae3 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c | |||
@@ -322,7 +322,7 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) | |||
322 | cond_talk_ids_fq(VOICE_OK); | 322 | cond_talk_ids_fq(VOICE_OK); |
323 | return changed; | 323 | return changed; |
324 | } | 324 | } |
325 | static bool is_setting_quickscreenable(const struct settings_list *setting); | 325 | |
326 | static inline const struct settings_list *get_setting(int gs_value, | 326 | static inline const struct settings_list *get_setting(int gs_value, |
327 | const struct settings_list *defaultval) | 327 | const struct settings_list *defaultval) |
328 | { | 328 | { |
@@ -394,7 +394,7 @@ bool quick_screen_f3(int button_enter) | |||
394 | #endif /* BUTTON_F3 */ | 394 | #endif /* BUTTON_F3 */ |
395 | 395 | ||
396 | /* stuff to make the quickscreen configurable */ | 396 | /* stuff to make the quickscreen configurable */ |
397 | static bool is_setting_quickscreenable(const struct settings_list *setting) | 397 | bool is_setting_quickscreenable(const struct settings_list *setting) |
398 | { | 398 | { |
399 | /* to keep things simple, only settings which have a lang_id set are ok */ | 399 | /* to keep things simple, only settings which have a lang_id set are ok */ |
400 | if (setting->lang_id < 0 || (setting->flags&F_BANFROMQS)) | 400 | if (setting->lang_id < 0 || (setting->flags&F_BANFROMQS)) |
@@ -411,118 +411,28 @@ static bool is_setting_quickscreenable(const struct settings_list *setting) | |||
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | static const struct settings_list *find_setting_from_index(int index) | 414 | void set_as_qs_item(const struct settings_list *setting, |
415 | enum QUICKSCREEN_ITEM item) | ||
415 | { | 416 | { |
416 | int count = -1, i; | 417 | int i; |
417 | const struct settings_list *setting = &settings[0]; | ||
418 | for(i=0;i<nb_settings;i++) | 418 | for(i=0;i<nb_settings;i++) |
419 | { | 419 | { |
420 | setting = &settings[i]; | 420 | if (&settings[i] == setting) |
421 | if (is_setting_quickscreenable(setting)) | 421 | break; |
422 | count++; | ||
423 | if (count == index) | ||
424 | return setting; | ||
425 | } | ||
426 | return NULL; | ||
427 | } | ||
428 | static char* quickscreen_setter_getname(int selected_item, void *data, | ||
429 | char *buffer, size_t buffer_len) | ||
430 | { | ||
431 | (void)data; | ||
432 | const struct settings_list *setting = find_setting_from_index(selected_item); | ||
433 | snprintf(buffer, buffer_len, "%s (%s)", | ||
434 | str(setting->lang_id), setting->cfg_name); | ||
435 | return buffer; | ||
436 | } | ||
437 | static int quickscreen_setter_speak_item(int selected_item, void * data) | ||
438 | { | ||
439 | (void)data; | ||
440 | talk_id(find_setting_from_index(selected_item)->lang_id, true); | ||
441 | return 0; | ||
442 | } | ||
443 | static int quickscreen_setter_action_callback(int action, | ||
444 | struct gui_synclist *lists) | ||
445 | { | ||
446 | const struct settings_list *temp = lists->data; | ||
447 | switch (action) | ||
448 | { | ||
449 | case ACTION_STD_OK: | ||
450 | /* ok, quit */ | ||
451 | return ACTION_STD_CANCEL; | ||
452 | case ACTION_STD_CONTEXT: /* real settings use this to reset to default */ | ||
453 | { | ||
454 | int i=0, count=0; | ||
455 | reset_setting(temp, temp->setting); | ||
456 | for(i=0;i<nb_settings;i++) | ||
457 | { | ||
458 | if (is_setting_quickscreenable(&settings[i])) | ||
459 | count++; | ||
460 | if (*(int*)temp->setting == i) | ||
461 | { | ||
462 | gui_synclist_select_item(lists, count-1); | ||
463 | break; | ||
464 | } | ||
465 | } | ||
466 | return ACTION_REDRAW; | ||
467 | } | ||
468 | } | 422 | } |
469 | return action; | 423 | switch (item) |
470 | } | ||
471 | int quickscreen_set_option(void *data) | ||
472 | { | ||
473 | int valid_settings_count = 0; | ||
474 | int i, newval = 0, oldval, *setting = NULL; | ||
475 | struct simplelist_info info; | ||
476 | switch ((intptr_t)data) | ||
477 | { | 424 | { |
478 | case QUICKSCREEN_LEFT: | 425 | case QUICKSCREEN_LEFT: |
479 | setting = &global_settings.qs_item_left; | 426 | global_settings.qs_item_left = i; |
480 | break; | 427 | break; |
481 | case QUICKSCREEN_RIGHT: | 428 | case QUICKSCREEN_RIGHT: |
482 | setting = &global_settings.qs_item_right; | 429 | global_settings.qs_item_right = i; |
483 | break; | 430 | break; |
484 | case QUICKSCREEN_BOTTOM: | 431 | case QUICKSCREEN_BOTTOM: |
485 | setting = &global_settings.qs_item_bottom; | 432 | global_settings.qs_item_bottom = i; |
433 | break; | ||
434 | default: /* shut the copiler up */ | ||
486 | break; | 435 | break; |
487 | } | 436 | } |
488 | oldval = *setting; | ||
489 | for(i=0;i<nb_settings;i++) | ||
490 | { | ||
491 | if (is_setting_quickscreenable(&settings[i])) | ||
492 | valid_settings_count++; | ||
493 | if (oldval == i) | ||
494 | newval = valid_settings_count - 1; | ||
495 | } | ||
496 | |||
497 | simplelist_info_init(&info, str(LANG_QS_ITEMS), | ||
498 | valid_settings_count, | ||
499 | (void*)find_setting(setting, NULL)); /* find the qs item being changed */ | ||
500 | info.get_name = quickscreen_setter_getname; | ||
501 | if(global_settings.talk_menu) | ||
502 | info.get_talk = quickscreen_setter_speak_item; | ||
503 | info.action_callback = quickscreen_setter_action_callback; | ||
504 | info.selection = newval; | ||
505 | simplelist_show_list(&info); | ||
506 | if (info.selection != oldval) | ||
507 | { | ||
508 | if (info.selection != -1) | ||
509 | { | ||
510 | const struct settings_list *temp = find_setting_from_index(info.selection); | ||
511 | int i = 0; | ||
512 | for(i=0;i<nb_settings;i++) | ||
513 | { | ||
514 | if (&settings[i] == temp) | ||
515 | break; | ||
516 | } | ||
517 | *setting = i; | ||
518 | settings_save(); | ||
519 | } | ||
520 | /* probably should splash LANG_CANCEL here but right now | ||
521 | we cant find out the selection when the cancel button was | ||
522 | pressed, (without hacks)so we cant know if the | ||
523 | selection was changed, or just viewed */ | ||
524 | } | ||
525 | return 0; | ||
526 | } | 437 | } |
527 | 438 | ||
528 | |||