diff options
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 179 |
1 files changed, 111 insertions, 68 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.43 2000/11/05 18:41:09 kls Exp $ + * $Id: menu.c 1.44 2000/11/11 09:58:12 kls Exp $ */ #include "menu.h" @@ -14,6 +14,7 @@ #include <string.h> #include "config.h" #include "eit.h" +#include "i18n.h" #define MENUTIMEOUT 120 // seconds @@ -131,7 +132,7 @@ cMenuEditBoolItem::cMenuEditBoolItem(const char *Name, int *Value) void cMenuEditBoolItem::Set(void) { char buf[16]; - snprintf(buf, sizeof(buf), "%s", *value ? "yes" : "no"); + snprintf(buf, sizeof(buf), "%s", *value ? tr("yes") : tr("no")); SetValue(buf); } @@ -493,6 +494,29 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key) return osContinue; } +// --- cMenuEditStraItem ----------------------------------------------------- + +class cMenuEditStraItem : public cMenuEditIntItem { +private: + const char * const *strings; +protected: + virtual void Set(void); +public: + cMenuEditStraItem(const char *Name, int *Value, int NumStrings, const char * const *Strings); + }; + +cMenuEditStraItem::cMenuEditStraItem(const char *Name, int *Value, int NumStrings, const char * const *Strings) +:cMenuEditIntItem(Name, Value, 0, NumStrings - 1) +{ + strings = Strings; + Set(); +} + +void cMenuEditStraItem::Set(void) +{ + SetValue(strings[*value]); +} + // --- cMenuEditChannel ------------------------------------------------------ class cMenuEditChannel : public cOsdMenu { @@ -505,20 +529,20 @@ public: }; cMenuEditChannel::cMenuEditChannel(int Index) -:cOsdMenu("Edit Channel", 14) +:cOsdMenu(tr("Edit Channel"), 14) { channel = Channels.Get(Index); if (channel) { data = *channel; - Add(new cMenuEditStrItem( "Name", data.name, sizeof(data.name), FileNameChars)); - Add(new cMenuEditIntItem( "Frequency", &data.frequency, 10000, 13000)); //TODO exact limits??? - Add(new cMenuEditChrItem( "Polarization", &data.polarization, "hv")); - Add(new cMenuEditIntItem( "Diseqc", &data.diseqc, 0, 10)); //TODO exact limits??? - Add(new cMenuEditIntItem( "Srate", &data.srate, 22000, 27500)); //TODO exact limits - toggle??? - Add(new cMenuEditIntItem( "Vpid", &data.vpid, 0, 10000)); //TODO exact limits??? - Add(new cMenuEditIntItem( "Apid", &data.apid, 0, 10000)); //TODO exact limits??? - Add(new cMenuEditIntItem( "CA", &data.ca, 0, cDvbApi::NumDvbApis)); - Add(new cMenuEditIntItem( "Pnr", &data.pnr, 0)); + Add(new cMenuEditStrItem( tr("Name"), data.name, sizeof(data.name), FileNameChars)); + Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency, 10000, 13000)); //TODO exact limits??? + Add(new cMenuEditChrItem( tr("Polarization"), &data.polarization, "hv")); + Add(new cMenuEditIntItem( tr("Diseqc"), &data.diseqc, 0, 10)); //TODO exact limits??? + Add(new cMenuEditIntItem( tr("Srate"), &data.srate, 22000, 27500)); //TODO exact limits - toggle??? + Add(new cMenuEditIntItem( tr("Vpid"), &data.vpid, 0, 10000)); //TODO exact limits??? + Add(new cMenuEditIntItem( tr("Apid"), &data.apid, 0, 10000)); //TODO exact limits??? + Add(new cMenuEditIntItem( tr("CA"), &data.ca, 0, cDvbApi::NumDvbApis)); + Add(new cMenuEditIntItem( tr("Pnr"), &data.pnr, 0)); } } @@ -589,7 +613,7 @@ public: }; cMenuChannels::cMenuChannels(void) -:cOsdMenu("Channels", 4) +:cOsdMenu(tr("Channels"), 4) { //TODO int i = 0; @@ -600,7 +624,7 @@ cMenuChannels::cMenuChannels(void) Add(new cMenuChannelItem(i, channel), i == curr); i++; } - SetHelp("Edit", "New", "Delete", "Mark"); + SetHelp(tr("Edit"), tr("New"), tr("Delete"), tr("Mark")); } eOSState cMenuChannels::Switch(void) @@ -641,11 +665,11 @@ eOSState cMenuChannels::Del(void) // Check if there is a timer using this channel: for (cTimer *ti = Timers.First(); ti; ti = (cTimer *)ti->Next()) { if (ti->channel == DeletedChannel) { - Interface->Error("Channel is being used by a timer!"); + Interface->Error(tr("Channel is being used by a timer!")); return osContinue; } } - if (Interface->Confirm("Delete Channel?")) { + if (Interface->Confirm(tr("Delete Channel?"))) { // Move and renumber the channels: Channels.Del(channel); Channels.ReNumber(); @@ -835,7 +859,7 @@ public: }; cMenuSummary::cMenuSummary(const char *Text) -:cOsdMenu("Summary") +:cOsdMenu(tr("Summary")) { Add(new cMenuTextItem(Text, 1, 2, MenuColumns - 2, MAXOSDITEMS)); } @@ -861,22 +885,22 @@ public: }; cMenuEditTimer::cMenuEditTimer(int Index, bool New) -:cOsdMenu("Edit Timer", 10) +:cOsdMenu(tr("Edit Timer"), 12) { timer = Timers.Get(Index); if (timer) { data = *timer; if (New) data.active = 1; - Add(new cMenuEditBoolItem("Active", &data.active)); - Add(new cMenuEditChanItem("Channel", &data.channel)); - Add(new cMenuEditDayItem( "Day", &data.day)); - Add(new cMenuEditTimeItem("Start", &data.start)); - Add(new cMenuEditTimeItem("Stop", &data.stop)); + Add(new cMenuEditBoolItem(tr("Active"), &data.active)); + Add(new cMenuEditChanItem(tr("Channel"), &data.channel)); + Add(new cMenuEditDayItem( tr("Day"), &data.day)); + Add(new cMenuEditTimeItem(tr("Start"), &data.start)); + Add(new cMenuEditTimeItem(tr("Stop"), &data.stop)); //TODO VPS??? - Add(new cMenuEditIntItem( "Priority", &data.priority, 0, 99)); - Add(new cMenuEditIntItem( "Lifetime", &data.lifetime, 0, 99)); - Add(new cMenuEditStrItem( "File", data.file, sizeof(data.file), FileNameChars)); + Add(new cMenuEditIntItem( tr("Priority"), &data.priority, 0, 99)); + Add(new cMenuEditIntItem( tr("Lifetime"), &data.lifetime, 0, 99)); + Add(new cMenuEditStrItem( tr("File"), data.file, sizeof(data.file), FileNameChars)); } } @@ -948,7 +972,7 @@ public: }; cMenuTimers::cMenuTimers(void) -:cOsdMenu("Timer", 2, 4, 10, 6, 6) +:cOsdMenu(tr("Timers"), 2, 4, 10, 6, 6) { int i = 0; cTimer *timer; @@ -957,7 +981,7 @@ cMenuTimers::cMenuTimers(void) Add(new cMenuTimerItem(i, timer)); i++; } - SetHelp("Edit", "New", "Delete", "Mark"); + SetHelp(tr("Edit"), tr("New"), tr("Delete"), tr("Mark")); } eOSState cMenuTimers::Activate(bool On) @@ -1000,7 +1024,7 @@ eOSState cMenuTimers::Del(void) cTimer *ti = Timers.Get(Index); if (ti) { if (!ti->recording) { - if (Interface->Confirm("Delete Timer?")) { + if (Interface->Confirm(tr("Delete Timer?"))) { Timers.Del(Timers.Get(Index)); cOsdMenu::Del(Index); Timers.Save(); @@ -1009,7 +1033,7 @@ eOSState cMenuTimers::Del(void) } } else - Interface->Error("Timer is recording!"); + Interface->Error(tr("Timer is recording!")); } return osContinue; } @@ -1064,7 +1088,7 @@ public: }; cMenuEvent::cMenuEvent(const cEventInfo *EventInfo, bool CanSwitch) -:cOsdMenu("Event") +:cOsdMenu(tr("Event")) { eventInfo = EventInfo; if (eventInfo) { @@ -1086,7 +1110,7 @@ cMenuEvent::cMenuEvent(const cEventInfo *EventInfo, bool CanSwitch) } if (!isempty(p = eventInfo->GetExtendedDescription())) Add(new cMenuTextItem(p, 1, Line, MenuColumns - 2, Height() - Line - 2, clrCyan), true); - SetHelp("Record", NULL, NULL, CanSwitch ? "Switch" : NULL); + SetHelp(tr("Record"), NULL, NULL, CanSwitch ? tr("Switch") : NULL); } } } @@ -1138,7 +1162,7 @@ static int CompareEventChannel(const void *p1, const void *p2) } cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now) -:cOsdMenu(Now ? "What's on now?" : "What's on next?", 4, 7, 6) +:cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), 4, 7, 6) { const cSchedule *Schedule = Schedules->First(); const cEventInfo **pArray = NULL; @@ -1164,7 +1188,7 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now) Add(new cMenuWhatsOnItem(pArray[a])); delete pArray; - SetHelp("Record", Now ? "Next" : "Now", "Schedule", "Switch"); + SetHelp(tr("Record"), Now ? tr("Next") : tr("Now"), tr("Schedule"), tr("Switch")); } eOSState cMenuWhatsOn::Switch(void) @@ -1175,7 +1199,7 @@ eOSState cMenuWhatsOn::Switch(void) if (channel && channel->Switch()) return osEnd; } - Interface->Error("Can't switch channel!"); + Interface->Error(tr("Can't switch channel!")); return osContinue; } @@ -1242,17 +1266,17 @@ public: }; cMenuSchedule::cMenuSchedule(void) -:cOsdMenu("Schedule", 6, 6) +:cOsdMenu("", 6, 6) { now = next = false; cChannel *channel = Channels.GetByNumber(cDvbApi::CurrentChannel()); if (channel) { char *buffer = NULL; - asprintf(&buffer, "Schedule - %s", channel->name); + asprintf(&buffer, tr("Schedule - %s"), channel->name); SetTitle(buffer, false); + PrepareSchedule(); + SetHelp(tr("Record"), tr("Now"), tr("Next")); } - PrepareSchedule(); - SetHelp("Record", "Now", "Next"); } static int CompareEventTime(const void *p1, const void *p2) @@ -1347,7 +1371,7 @@ void cMenuRecordingItem::Set(void) // --- cMenuRecordings ------------------------------------------------------- cMenuRecordings::cMenuRecordings(void) -:cOsdMenu("Recordings", 6, 6) +:cOsdMenu(tr("Recordings"), 6, 6) { if (Recordings.Load()) { const char *lastReplayed = cReplayControl::LastReplayed(); @@ -1357,7 +1381,7 @@ cMenuRecordings::cMenuRecordings(void) recording = Recordings.Next(recording); } } - SetHelp("Play", NULL, "Delete", "Summary"); + SetHelp(tr("Play"), NULL, tr("Delete"), tr("Summary")); Display(); } @@ -1377,18 +1401,18 @@ eOSState cMenuRecordings::Del(void) if (ri) { //XXX what if this recording's file is currently in use??? //XXX if (!ti->recording) { - if (Interface->Confirm("Delete Recording?")) { + if (Interface->Confirm(tr("Delete Recording?"))) { if (ri->recording->Delete()) { cReplayControl::ClearLastReplayed(ri->recording->FileName()); cOsdMenu::Del(Current()); Display(); } else - Interface->Error("Error while deleting recording!"); + Interface->Error(tr("Error while deleting recording!")); } //XXX } //XXX else -//XXX Interface->Error("Timer is recording!"); +//XXX Interface->Error(tr("Timer is recording!")); } return osContinue; } @@ -1425,24 +1449,35 @@ eOSState cMenuRecordings::ProcessKey(eKeys Key) class cMenuSetup : public cOsdMenu { private: cSetup data; + int osdLanguage; + void Set(void); public: cMenuSetup(void); virtual eOSState ProcessKey(eKeys Key); }; cMenuSetup::cMenuSetup(void) -:cOsdMenu("Setup", 20) +:cOsdMenu("", 25) { data = Setup; - Add(new cMenuEditIntItem( "PrimaryDVB", &data.PrimaryDVB, 1, cDvbApi::NumDvbApis)); - Add(new cMenuEditBoolItem("ShowInfoOnChSwitch", &data.ShowInfoOnChSwitch)); - Add(new cMenuEditBoolItem("MenuScrollPage", &data.MenuScrollPage)); - Add(new cMenuEditBoolItem("MarkInstantRecord", &data.MarkInstantRecord)); - Add(new cMenuEditIntItem( "LnbFrequLo", &data.LnbFrequLo)); - Add(new cMenuEditIntItem( "LnbFrequHi", &data.LnbFrequHi)); - Add(new cMenuEditBoolItem("SetSystemTime", &data.SetSystemTime)); - Add(new cMenuEditIntItem( "MarginStart", &data.MarginStart)); - Add(new cMenuEditIntItem( "MarginStop", &data.MarginStop)); + osdLanguage = Setup.OSDLanguage; + Set(); +} + +void cMenuSetup::Set(void) +{ + Clear(); + SetTitle(tr("Setup")); + Add(new cMenuEditStraItem(tr("OSD-Language"), &data.OSDLanguage, NumLanguages, Languages())); + Add(new cMenuEditIntItem( tr("PrimaryDVB"), &data.PrimaryDVB, 1, cDvbApi::NumDvbApis)); + Add(new cMenuEditBoolItem(tr("ShowInfoOnChSwitch"), &data.ShowInfoOnChSwitch)); + Add(new cMenuEditBoolItem(tr("MenuScrollPage"), &data.MenuScrollPage)); + Add(new cMenuEditBoolItem(tr("MarkInstantRecord"), &data.MarkInstantRecord)); + Add(new cMenuEditIntItem( tr("LnbFrequLo"), &data.LnbFrequLo)); + Add(new cMenuEditIntItem( tr("LnbFrequHi"), &data.LnbFrequHi)); + Add(new cMenuEditBoolItem(tr("SetSystemTime"), &data.SetSystemTime)); + Add(new cMenuEditIntItem( tr("MarginStart"), &data.MarginStart)); + Add(new cMenuEditIntItem( tr("MarginStop"), &data.MarginStop)); } eOSState cMenuSetup::ProcessKey(eKeys Key) @@ -1451,7 +1486,7 @@ eOSState cMenuSetup::ProcessKey(eKeys Key) if (state == osUnknown) { switch (Key) { - case kOk: state = (Setup.PrimaryDVB != data.PrimaryDVB) ? osSwitchDvb : osBack; + case kOk: state = (Setup.PrimaryDVB != data.PrimaryDVB) ? osSwitchDvb : osEnd; cDvbApi::PrimaryDvbApi->SetUseTSTime(data.SetSystemTime); Setup = data; Setup.Save(); @@ -1459,23 +1494,31 @@ eOSState cMenuSetup::ProcessKey(eKeys Key) default: break; } } + if (data.OSDLanguage != osdLanguage) { + int OriginalOSDLanguage = Setup.OSDLanguage; + Setup.OSDLanguage = data.OSDLanguage; + Set(); + Display(); + osdLanguage = data.OSDLanguage; + Setup.OSDLanguage = OriginalOSDLanguage; + } return state; } // --- cMenuMain ------------------------------------------------------------- -#define STOP_RECORDING "Stop recording " +#define STOP_RECORDING tr("Stop recording ") cMenuMain::cMenuMain(bool Replaying) -:cOsdMenu("Main") +:cOsdMenu(tr("Main")) { - Add(new cOsdItem("Schedule", osSchedule)); - Add(new cOsdItem("Channels", osChannels)); - Add(new cOsdItem("Timer", osTimer)); - Add(new cOsdItem("Recordings", osRecordings)); - Add(new cOsdItem("Setup", osSetup)); + Add(new cOsdItem(tr("Schedule"), osSchedule)); + Add(new cOsdItem(tr("Channels"), osChannels)); + Add(new cOsdItem(tr("Timers"), osTimers)); + Add(new cOsdItem(tr("Recordings"), osRecordings)); + Add(new cOsdItem(tr("Setup"), osSetup)); if (Replaying) - Add(new cOsdItem("Stop replaying", osStopReplay)); + Add(new cOsdItem(tr("Stop replaying"), osStopReplay)); const char *s = NULL; while ((s = cRecordControls::GetInstantId(s)) != NULL) { char *buffer = NULL; @@ -1483,7 +1526,7 @@ cMenuMain::cMenuMain(bool Replaying) Add(new cOsdItem(buffer, osStopRecord)); delete buffer; } - SetHelp("Record", NULL, NULL, cReplayControl::LastReplayed() ? "Resume" : NULL); + SetHelp(tr("Record"), NULL, NULL, cReplayControl::LastReplayed() ? tr("Resume") : NULL); Display(); lastActivity = time(NULL); } @@ -1495,10 +1538,10 @@ eOSState cMenuMain::ProcessKey(eKeys Key) switch (state) { case osSchedule: return AddSubMenu(new cMenuSchedule); case osChannels: return AddSubMenu(new cMenuChannels); - case osTimer: return AddSubMenu(new cMenuTimers); + case osTimers: return AddSubMenu(new cMenuTimers); case osRecordings: return AddSubMenu(new cMenuRecordings); case osSetup: return AddSubMenu(new cMenuSetup); - case osStopRecord: if (Interface->Confirm("Stop Recording?")) { + case osStopRecord: if (Interface->Confirm(tr("Stop Recording?"))) { cOsdItem *item = Get(Current()); if (item) { cRecordControls::Stop(item->Text() + strlen(STOP_RECORDING)); @@ -1571,7 +1614,7 @@ void cDisplayChannel::DisplayChannel(const cChannel *Channel) if (Channel && Channel->number) snprintf(buffer, BufSize, "%d %s", Channel->number, Channel->name); else - snprintf(buffer, BufSize, "%s", Channel ? Channel->name : "*** Invalid Channel ***"); + snprintf(buffer, BufSize, "%s", Channel ? Channel->name : tr("*** Invalid Channel ***")); Interface->Fill(0, 0, MenuColumns, 1, clrBackground); Interface->Write(0, 0, buffer); time_t t = time(NULL); @@ -1697,7 +1740,7 @@ cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer) timer = new cTimer(true); Timers.Add(timer); Timers.Save(); - asprintf(&instantId, cDvbApi::NumDvbApis > 1 ? "%s on %d" : "%s", Channels.GetChannelNameByNumber(timer->channel), dvbApi->Index() + 1); + asprintf(&instantId, cDvbApi::NumDvbApis > 1 ? "%s - %d" : "%s", Channels.GetChannelNameByNumber(timer->channel), dvbApi->Index() + 1); } timer->SetRecording(true); Channels.SwitchTo(timer->channel, dvbApi); |