Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] patch reccmd submenu for vdr1.2.5
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
just started getting into vdr and digital video recording and just stumbled
over this list. :)
After having installed my first vdr a few days ago I noticed the difficulty to
navigate quickly through menus. Especially the commands and recording
commands menu could get quite crowded. So I had a look at the code and came
up with a small patch to enable submenus in all command menus.
After having applied attached patch you can configure / group your menu items
using '-' chars, e.g. (replace command with actual command):
Divx : echo "nothing"
- -To Divx List : command
- -Show List : command
- -Activate : command
DVD : echo "nothing"
- -To List : command
- -Show List : command
- -Grab : echo "nothing"
- --Grab Background : command
- --Grab SubBack : command
etc.
So now you can shorten your command lists and thus increase accessibility,
because you can simply use number keys to quickly navigate to the desired
function.
The patch has been tested on vdrportal.de and the only unresolved problem is a
compiler warning concerning hidden virtual functions, which I could not
reproduce on my system.
The patch is considered for inclusion in 1.3 (though not confirmed).
I hope you like the patch and please do keep up the good work on this project.
- --
Regards
Alexander Blum
- -----------------------------------------
KewBee GbR
Steinweg 11
36119 Neuhof
http://www.kewbee.de
Tel.: +49 (0) 6655 9110571
Fax.: +49 (0) 6655 9110572
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE/iJd7V+GRcpXoYPIRAhnhAJoCi5rSxw+8o2wdoug1Y9UvU/r9RwCfTibK
jpbW8RRRUuKNHTg7PUgX5GA=
=rhlp
-----END PGP SIGNATURE-----
diff -ru vdr-1.2.5orig/Makefile vdr-1.2.5/Makefile
--- vdr-1.2.5orig/Makefile Thu Oct 9 11:42:01 2003
+++ vdr-1.2.5/Makefile Thu Oct 9 01:57:24 2003
@@ -51,6 +53,7 @@
DEFINES += -DREMOTE_$(REMOTE)
+DEFINES += -DCMD_SUBMENUS
DEFINES += -D_GNU_SOURCE
DEFINES += -DVIDEODIR=\"$(VIDEODIR)\"
diff -ru vdr-1.2.5orig/config.c vdr-1.2.5/config.c
--- vdr-1.2.5orig/config.c Thu Oct 9 11:42:01 2003
+++ vdr-1.2.5/config.c Thu Oct 9 00:14:17 2003
@@ -27,18 +27,29 @@
{
title = command = NULL;
confirm = false;
+ nIndent = 0;
+ childs = NULL;
}
cCommand::~cCommand()
{
free(title);
free(command);
+ delete childs;
}
bool cCommand::Parse(const char *s)
{
const char *p = strchr(s, ':');
if (p) {
+ nIndent = 0;
+#ifdef CMD_SUBMENUS
+ while (*s == '-')
+ {
+ nIndent++;
+ s++;
+ }
+#endif // CMD_SUBMENUS
int l = p - s;
if (l > 0) {
title = MALLOC(char, l + 1);
@@ -83,6 +94,76 @@
esyslog("ERROR: can't open pipe for command '%s'", cmd);
free(cmdbuf);
return result;
+}
+
+int cCommand::getIndent ()
+{
+ return nIndent;
+}
+
+void cCommand::setIndent (int nNewIndent)
+{
+ nIndent = nNewIndent;
+}
+
+bool cCommand::hasChilds ()
+{
+ if (!childs)
+ {
+ return false;
+ }
+ return (childs->Count () > 0);
+}
+
+int cCommand::getChildCount ()
+{
+ if (!childs)
+ {
+ return false;
+ }
+ return childs->Count ();
+}
+
+void cCommand::addChild (cCommand *newChild)
+{
+ if (!childs)
+ {
+ childs = new cCommands ();
+ }
+ childs->Add (newChild);
+}
+
+
+cCommands *cCommand::getChilds ()
+{
+ return childs;
+}
+
+// --- cCommands -------------------------------------------------------
+
+void cCommands::Add(cListObject *Object, cListObject *After = NULL)
+{
+ cCommand *c = (cCommand *) Object;
+ cCommand *cParent;
+ int nIndent;
+ int nIndex;
+
+ if (!c)
+ {
+ return;
+ }
+ nIndent = c->getIndent ();
+ // isyslog ("nIndent %d %s\n", nIndent, c->Title ());
+ for (nIndex = Count () - 1; nIndex >= 0; nIndex--)
+ {
+ cParent = (cCommand *) Get (nIndex);
+ if (cParent->getIndent () < nIndent)
+ {
+ cParent->addChild (c);
+ return;
+ }
+ }
+ cConfig<cCommand>::Add (Object, After);
}
// -- cSVDRPhost -------------------------------------------------------------
diff -ru vdr-1.2.5orig/config.h vdr-1.2.5/config.h
--- vdr-1.2.5orig/config.h Thu Oct 9 11:42:01 2003
+++ vdr-1.2.5/config.h Thu Oct 9 01:28:20 2003
@@ -33,11 +33,15 @@
#define MaxFileName 256
+class cCommands;
+
class cCommand : public cListObject {
private:
char *title;
char *command;
bool confirm;
+ int nIndent;
+ cCommands *childs;
static char *result;
public:
cCommand(void);
@@ -46,6 +50,12 @@
const char *Title(void) { return title; }
bool Confirm(void) { return confirm; }
const char *Execute(const char *Parameters = NULL);
+ int getIndent ();
+ void setIndent (int nNewIndent);
+ bool hasChilds ();
+ int getChildCount ();
+ cCommands *getChilds ();
+ void addChild (cCommand *newChild);
};
typedef uint32_t in_addr_t; //XXX from /usr/include/netinet/in.h (apparently this is not defined on systems with glibc < 2.2)
@@ -222,7 +232,11 @@
}
};
-class cCommands : public cConfig<cCommand> {};
+class cCommands : public cConfig<cCommand>
+{
+ public:
+ virtual void Add(cListObject *Object, cListObject *After = NULL);
+};
class cSVDRPhosts : public cConfig<cSVDRPhost> {
public:
diff -ru vdr-1.2.5orig/menu.c vdr-1.2.5/menu.c
--- vdr-1.2.5orig/menu.c Thu Oct 9 11:42:01 2003
+++ vdr-1.2.5/menu.c Thu Oct 9 01:39:01 2003
@@ -28,6 +28,7 @@
#include "timers.h"
#include "transfer.h"
#include "videodir.h"
+#include "dvbsub.h"
#include <malloc.h>//TK
@@ -1744,6 +1745,16 @@
if (command) {
char *buffer = NULL;
bool confirmed = true;
+#ifdef CMD_SUBMENUS
+ if (command->hasChilds ())
+ {
+ cMenuCommands *menu;
+ eOSState state = AddSubMenu(menu = new cMenuCommands(command->Title (), command->getChilds (), parameters));
+ return osContinue;
+ }
+ else
+ {
+#endif // CMD_SUBMENUS
if (command->Confirm()) {
asprintf(&buffer, "%s?", command->Title());
confirmed = Interface->Confirm(buffer);
@@ -1759,7 +1770,11 @@
return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
return osEnd;
}
+#ifdef CMD_SUBMENUS
}
+#endif // CMD_SUBMENUS
+
+ }
return osContinue;
}
diff -ru vdr-1.2.5orig/tools.h vdr-1.2.5/tools.h
--- vdr-1.2.5orig/tools.h Thu Oct 9 11:42:01 2003
+++ vdr-1.2.5/tools.h Thu Oct 9 00:14:17 2003
@@ -158,7 +158,7 @@
cListBase(void);
public:
virtual ~cListBase();
- void Add(cListObject *Object, cListObject *After = NULL);
+ virtual void Add(cListObject *Object, cListObject *After = NULL);
void Ins(cListObject *Object, cListObject *Before = NULL);
void Del(cListObject *Object, bool DeleteObject = true);
virtual void Move(int From, int To);
Home |
Main Index |
Thread Index