1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Key macros can now call plugins that don't have a main menu entry

This commit is contained in:
Klaus Schmidinger 2005-09-03 11:33:43 +02:00
parent 2a91de02ab
commit 45a29e5b16
5 changed files with 32 additions and 14 deletions

View File

@ -3773,3 +3773,7 @@ Video Disk Recorder Revision History
Lauri Tischler). Lauri Tischler).
- Repeat keys are now ignored when waiting for a keypress to cancel an operation - Repeat keys are now ignored when waiting for a keypress to cancel an operation
(thanks to Marko Mäkelä). (thanks to Marko Mäkelä).
- The main menu function of a plugin can now be activated through a key macro of
the form "@plugin" even if that plugin doesn't have a main menu entry (using
part of a patch by Hardy Flor, which originally implemented calling plugins from
SVDRP).

3
keys.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: keys.c 1.7 2004/12/27 11:08:34 kls Exp $ * $Id: keys.c 1.8 2005/09/03 11:28:34 kls Exp $
*/ */
#include "keys.h" #include "keys.h"
@ -210,7 +210,6 @@ bool cKeyMacro::Parse(char *s)
} }
macro[n++] = k_Plugin; macro[n++] = k_Plugin;
if (n < MAXKEYSINMACRO) { if (n < MAXKEYSINMACRO) {
macro[n] = kOk;
plugin = strdup(p + 1); plugin = strdup(p + 1);
if (!cPluginManager::GetPlugin(plugin)) { if (!cPluginManager::GetPlugin(plugin)) {
esyslog("ERROR: unknown plugin '%s'", plugin); esyslog("ERROR: unknown plugin '%s'", plugin);

11
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.357 2005/08/27 09:37:23 kls Exp $ * $Id: menu.c 1.358 2005/09/03 10:34:46 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -2402,11 +2402,11 @@ cMenuPluginItem::cMenuPluginItem(const char *Name, int Index)
cOsdObject *cMenuMain::pluginOsdObject = NULL; cOsdObject *cMenuMain::pluginOsdObject = NULL;
cMenuMain::cMenuMain(bool Replaying, eOSState State, const char *Plugin) cMenuMain::cMenuMain(bool Replaying, eOSState State)
:cOsdMenu("") :cOsdMenu("")
{ {
replaying = Replaying; replaying = Replaying;
Set(Plugin); Set();
// Initial submenus: // Initial submenus:
@ -2417,7 +2417,6 @@ cMenuMain::cMenuMain(bool Replaying, eOSState State, const char *Plugin)
case osRecordings: AddSubMenu(new cMenuRecordings(NULL, 0, true)); break; case osRecordings: AddSubMenu(new cMenuRecordings(NULL, 0, true)); break;
case osSetup: AddSubMenu(new cMenuSetup); break; case osSetup: AddSubMenu(new cMenuSetup); break;
case osCommands: AddSubMenu(new cMenuCommands(tr("Commands"), &Commands)); break; case osCommands: AddSubMenu(new cMenuCommands(tr("Commands"), &Commands)); break;
case osPlugin: break; // the actual work is done in Set()
default: break; default: break;
} }
} }
@ -2429,7 +2428,7 @@ cOsdObject *cMenuMain::PluginOsdObject(void)
return o; return o;
} }
void cMenuMain::Set(const char *Plugin) void cMenuMain::Set(void)
{ {
Clear(); Clear();
//XXX //SetTitle("VDR"); // this is done below, including disk usage //XXX //SetTitle("VDR"); // this is done below, including disk usage
@ -2463,7 +2462,7 @@ void cMenuMain::Set(const char *Plugin)
if (p) { if (p) {
const char *item = p->MainMenuEntry(); const char *item = p->MainMenuEntry();
if (item) if (item)
Add(new cMenuPluginItem(hk(item), i), Plugin && strcmp(Plugin, p->Name()) == 0); Add(new cMenuPluginItem(hk(item), i));
} }
else else
break; break;

6
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.h 1.71 2005/08/27 09:37:33 kls Exp $ * $Id: menu.h 1.72 2005/09/03 10:33:17 kls Exp $
*/ */
#ifndef __MENU_H #ifndef __MENU_H
@ -58,9 +58,9 @@ private:
time_t lastActivity; time_t lastActivity;
bool replaying; bool replaying;
static cOsdObject *pluginOsdObject; static cOsdObject *pluginOsdObject;
void Set(const char *Plugin = NULL); void Set(void);
public: public:
cMenuMain(bool Replaying, eOSState State = osUnknown, const char *Plugin = NULL); cMenuMain(bool Replaying, eOSState State = osUnknown);
virtual eOSState ProcessKey(eKeys Key); virtual eOSState ProcessKey(eKeys Key);
static cOsdObject *PluginOsdObject(void); static cOsdObject *PluginOsdObject(void);
}; };

22
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/vdr * The project's page is at http://www.cadsoft.de/vdr
* *
* $Id: vdr.c 1.211 2005/08/21 08:47:06 kls Exp $ * $Id: vdr.c 1.212 2005/09/03 11:26:27 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -695,7 +695,7 @@ int main(int argc, char *argv[])
Menu = new cMenuMain(cControl::Control()); Menu = new cMenuMain(cControl::Control());
Temp = NULL; Temp = NULL;
break; break;
#define DirectMainFunction(function...)\ #define DirectMainFunction(function)\
DELETENULL(Menu);\ DELETENULL(Menu);\
if (cControl::Control())\ if (cControl::Control())\
cControl::Control()->Hide();\ cControl::Control()->Hide();\
@ -709,7 +709,23 @@ int main(int argc, char *argv[])
case kSetup: DirectMainFunction(osSetup); break; case kSetup: DirectMainFunction(osSetup); break;
case kCommands: DirectMainFunction(osCommands); break; case kCommands: DirectMainFunction(osCommands); break;
case kUser1 ... kUser9: cRemote::PutMacro(key); key = kNone; break; case kUser1 ... kUser9: cRemote::PutMacro(key); key = kNone; break;
case k_Plugin: DirectMainFunction(osPlugin, cRemote::GetPlugin()); break; case k_Plugin: {
DELETENULL(Menu);
Temp = NULL;
if (cControl::Control())
cControl::Control()->Hide();
cPlugin *plugin = cPluginManager::GetPlugin(cRemote::GetPlugin());
if (plugin) {
Menu = Temp = plugin->MainMenuAction();
if (Menu) {
Menu->Show();
if (Menu->IsMenu())
((cOsdMenu*)Menu)->Display();
}
}
key = kNone; // nobody else needs to see these keys
}
break;
// Channel up/down: // Channel up/down:
case kChanUp|k_Repeat: case kChanUp|k_Repeat:
case kChanUp: case kChanUp: