diff options
Diffstat (limited to 'apps/gui/option_select.c')
-rw-r--r-- | apps/gui/option_select.c | 46 |
1 files changed, 7 insertions, 39 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 045f5570c4..d4fb225a59 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c | |||
@@ -22,26 +22,6 @@ | |||
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "lang.h" | 23 | #include "lang.h" |
24 | 24 | ||
25 | void option_select_init_numeric(struct option_select * opt, | ||
26 | const char * title, | ||
27 | int init_value, | ||
28 | int min_value, | ||
29 | int max_value, | ||
30 | int step, | ||
31 | const char * unit, | ||
32 | option_formatter *formatter) | ||
33 | { | ||
34 | opt->title=title; | ||
35 | opt->min_value=min_value; | ||
36 | opt->max_value=max_value+1; | ||
37 | opt->option=init_value; | ||
38 | opt->step=step; | ||
39 | opt->extra_string=unit; | ||
40 | opt->formatter=formatter; | ||
41 | opt->items=NULL; | ||
42 | opt->limit_loop=true; | ||
43 | } | ||
44 | |||
45 | void option_select_init_items(struct option_select * opt, | 25 | void option_select_init_items(struct option_select * opt, |
46 | const char * title, | 26 | const char * title, |
47 | int selected, | 27 | int selected, |
@@ -52,31 +32,25 @@ void option_select_init_items(struct option_select * opt, | |||
52 | opt->min_value=0; | 32 | opt->min_value=0; |
53 | opt->max_value=nb_items; | 33 | opt->max_value=nb_items; |
54 | opt->option=selected; | 34 | opt->option=selected; |
55 | opt->step=1; | ||
56 | opt->formatter=NULL; | ||
57 | opt->items=items; | 35 | opt->items=items; |
58 | opt->limit_loop=false; | ||
59 | } | 36 | } |
60 | 37 | ||
61 | void option_select_next(struct option_select * opt) | 38 | void option_select_next(struct option_select * opt) |
62 | { | 39 | { |
63 | if(opt->option + opt->step >= opt->max_value) | 40 | if(opt->option + 1 >= opt->max_value) |
64 | { | 41 | { |
65 | if(!opt->limit_loop) | ||
66 | { | ||
67 | if(opt->option==opt->max_value-1) | 42 | if(opt->option==opt->max_value-1) |
68 | opt->option=opt->min_value; | 43 | opt->option=opt->min_value; |
69 | else | 44 | else |
70 | opt->option=opt->max_value-1; | 45 | opt->option=opt->max_value-1; |
71 | } | ||
72 | } | 46 | } |
73 | else | 47 | else |
74 | opt->option+=opt->step; | 48 | opt->option+=1; |
75 | } | 49 | } |
76 | 50 | ||
77 | void option_select_prev(struct option_select * opt) | 51 | void option_select_prev(struct option_select * opt) |
78 | { | 52 | { |
79 | if(opt->option - opt->step < opt->min_value) | 53 | if(opt->option - 1 < opt->min_value) |
80 | { | 54 | { |
81 | /* the dissimilarity to option_select_next() arises from the | 55 | /* the dissimilarity to option_select_next() arises from the |
82 | * sleep timer problem (bug #5000 and #5001): | 56 | * sleep timer problem (bug #5000 and #5001): |
@@ -85,21 +59,15 @@ void option_select_prev(struct option_select * opt) | |||
85 | * We need to be able to set timer to 0 (= Off) nevertheless. */ | 59 | * We need to be able to set timer to 0 (= Off) nevertheless. */ |
86 | if(opt->option!=opt->min_value) | 60 | if(opt->option!=opt->min_value) |
87 | opt->option=opt->min_value; | 61 | opt->option=opt->min_value; |
88 | else if(!opt->limit_loop) | 62 | else |
89 | opt->option=opt->max_value-1; | 63 | opt->option=opt->max_value-1; |
90 | } | 64 | } |
91 | else | 65 | else |
92 | opt->option-=opt->step; | 66 | opt->option-=1; |
93 | } | 67 | } |
94 | 68 | ||
95 | const char * option_select_get_text(struct option_select * opt, char * buffer, | 69 | const char * option_select_get_text(struct option_select * opt/*, char * buffer, |
96 | int buffersize) | 70 | int buffersize*/) |
97 | { | 71 | { |
98 | if(opt->items) | ||
99 | return(P2STR(opt->items[opt->option].string)); | 72 | return(P2STR(opt->items[opt->option].string)); |
100 | if(!opt->formatter) | ||
101 | snprintf(buffer, buffersize,"%d %s", opt->option, opt->extra_string); | ||
102 | else | ||
103 | opt->formatter(buffer, buffersize, opt->option, opt->extra_string); | ||
104 | return(buffer); | ||
105 | } | 73 | } |