A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 220 lines 7.0 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2003 Zakk Roberts 11 * 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. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21 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" 27 28/* Option structs (possible selections per each option) */ 29static const struct opt_items noyes_text[] = { 30 { "No", -1 }, 31 { "Yes", -1 } 32}; 33 34static const struct opt_items backlight_settings_text[] = { 35 { "Always Off", -1 }, 36 { "Use System Setting", -1 }, 37 { "Always On", -1 } 38}; 39 40static const struct opt_items idle_poweroff_text[] = { 41 { "Disabled", -1 }, 42 { "Enabled", -1 } 43}; 44 45static 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 }, 50}; 51 52/*************** 53 * Select a mode, returs true when the mode has been selected 54 * (we go back to clock display then) 55 **************/ 56static bool menu_mode_selector(void){ 57 MENUITEM_STRINGLIST(menu,"Mode",NULL, "Analog", 58 "Digital", "Binary"); 59 if(rb->do_menu(&menu, &clock_settings.mode, NULL, false) >=0) 60 return(true); 61 return(false); 62} 63 64/********************** 65 * Analog settings menu 66 *********************/ 67static void menu_analog_settings(void) 68{ 69 int selection=0, result=0; 70 71 MENUITEM_STRINGLIST(menu,"Analog",NULL,"Show Date", 72 "Show Second Hand","Show Border"); 73 74 while(result>=0){ 75 result=rb->do_menu(&menu, &selection, NULL, false); 76 switch(result){ 77 case 0: 78 rb->set_option("Show Date", &clock_settings.analog.show_date, 79 RB_BOOL, noyes_text, 2, NULL); 80 break; 81 case 1: 82 rb->set_option("Show Second Hand", 83 &clock_settings.analog.show_seconds, 84 RB_BOOL, noyes_text, 2, NULL); 85 break; 86 case 2: 87 rb->set_option("Show Border", 88 &clock_settings.analog.show_border, 89 RB_BOOL, noyes_text, 2, NULL); 90 break; 91 } 92 } 93} 94 95/*********************** 96 * Digital settings menu 97 **********************/ 98static void menu_digital_settings(void){ 99 int selection=0, result=0; 100 101 MENUITEM_STRINGLIST(menu,"Digital",NULL,"Show Seconds", 102 "Blinking Colon"); 103 104 while(result>=0){ 105 result=rb->do_menu(&menu, &selection, NULL, false); 106 switch(result){ 107 case 0: 108 rb->set_option("Show Seconds", 109 &clock_settings.digital.show_seconds, 110 RB_BOOL, noyes_text, 2, NULL); 111 break; 112 case 1: 113 rb->set_option("Blinking Colon", 114 &clock_settings.digital.blinkcolon, 115 RB_BOOL, noyes_text, 2, NULL); 116 break; 117 } 118 } 119} 120 121/************************************ 122 * General settings. Reset, save, etc 123 ***********************************/ 124static int menu_general_settings(void){ 125 int selection=0, result=0; 126 127 MENUITEM_STRINGLIST(menu, "Clock Settings", NULL, 128 "Analog", "Digital", 129 "Date Format", "Backlight", "Idle Poweroff", 130 "Save on Exit", "Save", "Reset"); 131 132 while(result>=0){ 133 result=rb->do_menu(&menu, &selection, NULL, false); 134 switch(result){ 135 case 0: 136 menu_analog_settings(); 137 break; 138 case 1: 139 menu_digital_settings(); 140 break; 141 case 2: 142 rb->set_option("Date Format", 143 &clock_settings.general.date_format, 144 RB_INT, date_format_text, 4, NULL); 145 break; 146 case 3: 147 rb->set_option("Backlight", 148 &clock_settings.general.backlight, 149 RB_INT, backlight_settings_text, 3, NULL); 150 apply_backlight_setting(clock_settings.general.backlight); 151 break; 152 153 case 4: 154 rb->set_option("Idle Poweroff", 155 &clock_settings.general.idle_poweroff, 156 RB_BOOL, idle_poweroff_text, 2, NULL); 157 break; 158 case 5: 159 rb->set_option("Save on Exit", 160 &clock_settings.general.save_settings, 161 RB_BOOL, noyes_text, 2, NULL); 162 163 /* if we no longer save on exit, 164 we better save now to remember that */ 165 if(!clock_settings.general.save_settings) 166 save_settings_wo_gui(); 167 break; 168 case 6: 169 save_settings_wo_gui(); 170 rb->splash(HZ, ID2P(LANG_SETTINGS_SAVED)); 171 break; 172 case 7: 173 if (rb->yesno_pop_confirm(ID2P(LANG_RESET))) 174 { 175 clock_settings_reset(&clock_settings); 176 return 1; 177 } 178 break; 179 } 180 } 181 return 0; 182} 183 184/*********** 185 * Main menu 186 **********/ 187bool main_menu(void) 188{ 189 int selection = 0; 190 bool done = false; 191 bool exit_clock=false; 192 193 MENUITEM_STRINGLIST(menu, "Clock", NULL, "Mode", 194 "Settings","Playback Control", 195 "Quit"); 196 while (!done) 197 { 198 switch(rb->do_menu(&menu, &selection, NULL, false)) 199 { 200 case 0: 201 done=menu_mode_selector(); 202 break; 203 case 1: 204 if (menu_general_settings()) 205 done = true; 206 break; 207 case 2: 208 playback_control(NULL); 209 break; 210 case 3: 211 exit_clock = true; 212 done = true; 213 break; 214 default: 215 done=true; 216 break; 217 } 218 } 219 return(exit_clock); 220}