Bump version numbers for 3.13
[maemo-rb.git] / apps / plugins / clock / clock_menu.c
bloba597664f49752ae2ff9352fe707ce85f71126374
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2003 Zakk Roberts
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "clock.h"
23 #include "clock_bitmaps.h"
24 #include "clock_settings.h"
25 #include "clock_menu.h"
26 #include "lib/playback_control.h"
28 /* Option structs (possible selections per each option) */
29 static const struct opt_items noyes_text[] = {
30 { "No", -1 },
31 { "Yes", -1 }
34 static const struct opt_items backlight_settings_text[] = {
35 { "Always Off", -1 },
36 { "Use Rockbox Setting", -1 },
37 { "Always On", -1 }
40 static const struct opt_items idle_poweroff_text[] = {
41 { "Disabled", -1 },
42 { "Enabled", -1 }
45 static const struct opt_items date_format_text[] = {
46 { "No date", -1 },
47 { "US (M-D-Y)", -1 },
48 { "European (D-M-Y)", -1 },
49 { "Japanese (Y-M-D)", -1 },
52 static const struct opt_items hour_format_text[] = {
53 { "24-Hour", -1 },
54 { "12-Hour", -1 }
57 /***************
58 * Select a mode, returs true when the mode has been selected
59 * (we go back to clock display then)
60 **************/
61 static bool menu_mode_selector(void){
62 MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog",
63 "Digital", "Binary");
64 if(rb->do_menu(&menu, &clock_settings.mode, NULL, false) >=0)
65 return(true);
66 return(false);
69 /**********************
70 * Analog settings menu
71 *********************/
72 static void menu_analog_settings(void)
74 int selection=0, result=0;
76 MENUITEM_STRINGLIST(menu,"Analog Mode Settings",NULL,"Show Date",
77 "Show Second Hand","Show Border");
79 while(result>=0){
80 result=rb->do_menu(&menu, &selection, NULL, false);
81 switch(result){
82 case 0:
83 rb->set_option("Show Date", &clock_settings.analog.show_date,
84 BOOL, noyes_text, 2, NULL);
85 break;
86 case 1:
87 rb->set_option("Show Second Hand",
88 &clock_settings.analog.show_seconds,
89 BOOL, noyes_text, 2, NULL);
90 break;
91 case 2:
92 rb->set_option("Show Border",
93 &clock_settings.analog.show_border,
94 BOOL, noyes_text, 2, NULL);
95 break;
100 /***********************
101 * Digital settings menu
102 **********************/
103 static void menu_digital_settings(void){
104 int selection=0, result=0;
106 MENUITEM_STRINGLIST(menu,"Digital Mode Settings",NULL,"Show Seconds",
107 "Blinking Colon");
109 while(result>=0){
110 result=rb->do_menu(&menu, &selection, NULL, false);
111 switch(result){
112 case 0:
113 rb->set_option("Show Seconds",
114 &clock_settings.digital.show_seconds,
115 BOOL, noyes_text, 2, NULL);
116 break;
117 case 1:
118 rb->set_option("Blinking Colon",
119 &clock_settings.digital.blinkcolon,
120 BOOL, noyes_text, 2, NULL);
121 break;
126 /***********************************************************
127 * Confirm resetting of settings, used in general_settings()
128 **********************************************************/
129 static void confirm_reset(void){
130 int result=0;
132 rb->set_option("Reset all settings?", &result, INT, noyes_text, 2, NULL);
134 if(result == 1){ /* reset! */
135 clock_settings_reset(&clock_settings);
136 rb->splash(HZ, "Settings reset!");
138 else
139 rb->splash(HZ, "Settings NOT reset.");
142 /************************************
143 * General settings. Reset, save, etc
144 ***********************************/
145 static void menu_general_settings(void){
146 int selection=0, result=0;
148 MENUITEM_STRINGLIST(menu,"General Settings",NULL,
149 "Hour Format","Date Format","Show Counter",
150 "Reset Settings","Save Settings Now",
151 "Save On Exit","Backlight Settings",
152 "Idle Poweroff (temporary)");
154 while(result>=0){
155 result=rb->do_menu(&menu, &selection, NULL, false);
156 switch(result){
157 case 0:
158 rb->set_option("Hour format",
159 &clock_settings.general.hour_format,
160 INT, hour_format_text, 2, NULL);
161 break;
162 case 1:
163 rb->set_option("Date format",
164 &clock_settings.general.date_format,
165 INT, date_format_text, 4, NULL);
166 break;
167 case 2:
168 rb->set_option("Show Counter", &clock_settings.general.show_counter,
169 BOOL, noyes_text, 2, NULL);
170 break;
171 case 3:
172 confirm_reset();
173 break;
175 case 4:
176 save_settings_wo_gui();
177 rb->splash(HZ, "Settings saved");
178 break;
180 case 5:
181 rb->set_option("Save On Exit",
182 &clock_settings.general.save_settings,
183 BOOL, noyes_text, 2, NULL);
185 /* if we no longer save on exit,
186 we better save now to remember that */
187 if(!clock_settings.general.save_settings)
188 save_settings_wo_gui();
189 break;
190 case 6:
191 rb->set_option("Backlight Settings",
192 &clock_settings.general.backlight,
193 INT, backlight_settings_text, 3, NULL);
194 apply_backlight_setting(clock_settings.general.backlight);
195 break;
197 case 7:
198 rb->set_option("Idle Poweroff (temporary)",
199 &clock_settings.general.idle_poweroff,
200 BOOL, idle_poweroff_text, 2, NULL);
201 break;
206 /***********
207 * Main menu
208 **********/
209 bool main_menu(void){
210 int selection=0;
211 bool done = false;
212 bool exit_clock=false;
214 MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector",
215 "Mode Settings","General Settings","Playback Control",
216 "Quit");
218 while(!done){
219 switch(rb->do_menu(&menu, &selection, NULL, false)){
220 case 0:
221 done = true;
222 break;
224 case 1:
225 done=menu_mode_selector();
226 break;
228 case 2:
229 switch(clock_settings.mode){
230 case ANALOG: menu_analog_settings();break;
231 case DIGITAL: menu_digital_settings();break;
232 case BINARY: /* no settings */;break;
234 break;
236 case 3:
237 menu_general_settings();
238 break;
240 case 4:
241 playback_control(NULL);
242 break;
244 case 5:
245 exit_clock = true;
246 done = true;
247 break;
249 default:
250 done=true;
251 break;
254 return(exit_clock);