blob: 97666dc9282ec98b5def4ff86c1498cd8280529b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* See the README file for copyright information and how to reach the author.
*
* This code is directly taken from VDR with some changes by me to work with this plugin
*/
#include <vdr/menu.h>
#include <vdr/config.h>
#include <vdr/interface.h>
#include "mymenucommands.h"
myMenuCommands::myMenuCommands(const char *Title,cCommands *Commands,const char *Parameters):cOsdMenu(Title)
{
SetHasHotkeys();
commands=Commands;
parameters=Parameters?strdup(Parameters):NULL;
for(cCommand *command=commands->First();command;command=commands->Next(command))
Add(new cOsdItem(hk(command->Title())));
}
myMenuCommands::~myMenuCommands()
{
free(parameters);
}
eOSState myMenuCommands::Execute()
{
cCommand *command=commands->Get(Current());
if(command)
{
char *buffer=NULL;
bool confirmed=true;
#ifdef CMD_SUBMENUS
if (command->hasChilds()) {
AddSubMenu(new cMenuCommands(command->Title(), command->getChilds(), parameters));
return osContinue;
}
#endif // CMD_SUBMENUS
if(command->Confirm()) {
asprintf(&buffer,"%s?",command->Title());
confirmed=Interface->Confirm(buffer);
free(buffer);
}
if(confirmed)
{
asprintf(&buffer, "%s...",command->Title());
Skins.Message(mtStatus,buffer);
free(buffer);
const char *Result=command->Execute(parameters);
Skins.Message(mtStatus, NULL);
if(Result)
return AddSubMenu(new cMenuText(command->Title(),Result,fontFix));
return osEnd;
}
}
return osContinue;
}
eOSState myMenuCommands::ProcessKey(eKeys Key)
{
eOSState state=cOsdMenu::ProcessKey(Key);
if(state==osUnknown)
{
switch(Key)
{
case kRed:
case kGreen:
case kYellow:
case kBlue: return osContinue;
case kOk: return Execute();
default: break;
}
}
return state;
}
|