#!/bin/sh /usr/share/dpatch/dpatch-run ## submenu patch - version 0.3 ## ## 2004-12-01: Version 0.1 - Jlac ## Extracted from submenu plugin 0.0.1 (vdr-1.3.15-submenu.diff) ## http://www.freewebs.com/sadhome/Plugin/Submenu.html ## ## 2004-12-24: Version 0.2 - Keef ## Set first menu item as current (vdr-1.3.17-submenu.diff) ## http://www.vdrportal.de/board/thread.php?postid=235991#post235991 ## ## 2005-02-01: Version 0.3 - Thomas Günther ## Fixed closing of new created MainMenu.conf ## Immediately read new created MainMenu.conf ## http://toms-cafe.de/vdr/download/vdr-submenu-0.3-1.3.17.diff ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: This patch is needed for the submenu plugin. @DPATCH@ diff -ruN vdr-1.3.17.orig/Makefile vdr-1.3.17/Makefile --- vdr-1.3.17.orig/Makefile 2004-11-21 12:28:55.000000000 +0100 +++ vdr-1.3.17/Makefile 2004-12-24 06:51:17.000000000 +0100 @@ -38,7 +38,7 @@ lirc.o menu.o menuitems.o nit.o osdbase.o osd.o pat.o player.o plugin.o rcu.o\ receiver.o recorder.o recording.o remote.o remux.o ringbuffer.o sdt.o sections.o\ skinclassic.o skins.o skinsttng.o sources.o spu.o status.o svdrp.o themes.o thread.o\ - timers.o tools.o transfer.o vdr.o videodir.o + timers.o tools.o transfer.o vdr.o videodir.o submenu.o FIXFONT_ISO8859_1 = -adobe-courier-bold-r-normal--25-*-100-100-m-*-iso8859-1 OSDFONT_ISO8859_1 = -adobe-helvetica-medium-r-normal--23-*-100-100-p-*-iso8859-1 diff -ruN vdr-1.3.17.orig/menu.c vdr-1.3.17/menu.c --- vdr-1.3.17.orig/menu.c 2004-11-20 11:49:17.000000000 +0100 +++ vdr-1.3.17/menu.c 2004-12-24 06:56:24.000000000 +0100 @@ -2355,6 +2355,104 @@ //XXX -> skin function!!! SetTitle(buffer); +if ( cPluginManager::GetPlugin("submenu") && !Plugin) +{ +cPlugin *p; +/* +0::Schedule +0::Channels +0:1:Games +1::games +1::freecell +1::solitaire +*/ + +// Parse info of current Menu +// add item of menu + for( int i = 0; i < submenu.nbSubMenuItem; i++) + { + if( submenu.subMenuItem[i].menuLevel == submenu.currentMenuLevel ) + { + if( submenu.subMenuItem[i].kindOfItem == 0 ) + { + // Basic menu items: + if( strcmp(submenu.subMenuItem[i].name,"Schedule") == 0 ) + Add(new cOsdItem(hk(tr("Schedule")), osSchedule)); + + if( strcmp(submenu.subMenuItem[i].name,"Channels") == 0 ) + Add(new cOsdItem(hk(tr("Channels")), osChannels)); + + if( strcmp(submenu.subMenuItem[i].name,"Timers") == 0 ) + Add(new cOsdItem(hk(tr("Timers")), osTimers)); + + if( strcmp(submenu.subMenuItem[i].name,"Recordings") == 0 ) + Add(new cOsdItem(hk(tr("Recordings")), osRecordings)); + + if( strcmp(submenu.subMenuItem[i].name,"Setup") == 0 ) + Add(new cOsdItem(hk(tr("Setup")), osSetup)); + + if( strcmp(submenu.subMenuItem[i].name,"Commands") == 0 ) + { + if (Commands.Count()) + Add(new cOsdItem(hk(tr("Commands")), osCommands)); + } + + // Plugins Item: + int j=0; + do + { + p = cPluginManager::GetPlugin(j); + if( p != NULL ) + { + const char *item = p->MainMenuEntry(); + if (item) + { + if( strcmp( submenu.subMenuItem[i].name , p->Name() ) == 0 ) + Add(new cMenuPluginItem(hk(item), j), osPlugin); + } + } + j++; + } + while( p != NULL); + } + else + { + Add(new cOsdItem(hk(submenu.subMenuItem[i].name), osUser9)); + } + } +} + + + /* Add all plugin entry not listed in config file */ + if ( submenu.currentMenuLevel == 0 ) + { + int j=0; + do + { + p = cPluginManager::GetPlugin(j); + if( p != NULL ) + { + const char *item = p->MainMenuEntry(); + if (item) + { + int trv = 0; + for( int i = 0; i < submenu.nbSubMenuItem; i++) + { + if( strcmp( submenu.subMenuItem[i].name , p->Name() ) == 0 ) + trv = 1; + } + if(trv == 0) + Add(new cMenuPluginItem(hk(item), j), osPlugin); + } + } + j++; + } + while( p != NULL); + } + SetCurrent(First()); +} +else +{ // Basic menu items: Add(new cOsdItem(hk(tr("Schedule")), osSchedule)); @@ -2380,6 +2478,7 @@ Add(new cOsdItem(hk(tr("Setup")), osSetup)); if (Commands.Count()) Add(new cOsdItem(hk(tr("Commands")), osCommands)); +} // Replay control: @@ -2446,6 +2545,28 @@ return osEnd; } break; + + case osBack: + if (submenu.nbLevelMenu > 0 ) + { + submenu.nbLevelMenu--; + submenu.currentMenuLevel = submenu.oldNumberMenu[ submenu.nbLevelMenu ]; + Set(NULL); + return osContinue; + } + else + return osEnd; + break; + + case osUser9: + submenu.oldNumberMenu[ submenu.nbLevelMenu ] = submenu.currentMenuLevel; + submenu.nbLevelMenu++; + //submenu.currentMenuLevel = submenu.subMenuItem[ Current()].kindOfItem; + submenu.currentMenuLevel = submenu.GetByLevel(submenu.currentMenuLevel,Current()); + Set(NULL); + return osContinue; + break; + case osPlugin: { cMenuPluginItem *item = (cMenuPluginItem *)Get(Current()); if (item) { diff -ruN vdr-1.3.17.orig/menu.h vdr-1.3.17/menu.h --- vdr-1.3.17.orig/menu.h 2004-06-13 13:46:03.000000000 +0200 +++ vdr-1.3.17/menu.h 2004-12-24 06:51:17.000000000 +0100 @@ -17,6 +17,7 @@ #include "dvbplayer.h" #include "recorder.h" #include "skins.h" +#include "submenu.h" class cMenuText : public cOsdMenu { private: @@ -32,6 +33,7 @@ class cMenuMain : public cOsdMenu { private: time_t lastActivity; + cSubMenu submenu; bool replaying; static cOsdObject *pluginOsdObject; void Set(const char *Plugin = NULL); diff -ruN vdr-1.3.17.orig/submenu.c vdr-1.3.17/submenu.c --- vdr-1.3.17.orig/submenu.c 1970-01-01 01:00:00.000000000 +0100 +++ vdr-1.3.17/submenu.c 2004-12-24 06:51:17.000000000 +0100 @@ -0,0 +1,391 @@ +#include "submenu.h" +#include +#include +#include "plugin.h" + +cSubMenuItemInfo::cSubMenuItemInfo() + { + menuLevel = 0; + kindOfItem = 0; + name[0] = 0; + } + +cSubMenuItemInfo::~cSubMenuItemInfo() +{ +} + +void cSubMenuItemInfo::setname(const char *n) +{ + int i,l; + l = strlen(n); + + for(i=0;i= SIZEMAXNAMESUBMENUITEMINFO ) + l = SIZEMAXNAMESUBMENUITEMINFO; + + for(i=0;iName()); + } + j++; + } + while (p !=NULL); + + fclose(fo); + } + /* -- Create example file -- */ + f = fopen(fichier,"rt"); + } + if ( f != NULL) + { + while (fgets(lig,80,f) ) + { + ParseOneLigOfFile( lig ); + } + fclose(f); + } +} + +void cSubMenu::ParseOneLigOfFile(const char *lig) +{ + int level=-1; + int kind=-1; + int i,j,l; + char txt[SIZEMAXNAMESUBMENUITEMINFO]; + char name[SIZEMAXNAMESUBMENUITEMINFO]; + int fin,status = 0; + int namefound = 0; + + l = strlen(lig); + + name[0]= 0; + + fin = 0; + + i=0;j=0; + + while( fin == 0) + { + switch(status) + { + case 0: //looking for level + txt[j++] = lig[i]; + if ( lig[i] == ':' ) + { + txt[j] = 0; + status ++; + level = atoi(txt); + j = 0; + } + + break; + case 1: + txt[j++] = lig[i]; + if (lig[i] == ':') + { + txt[j] = 0; + status ++; + kind = atoi(txt); + j = 0; + } + break; + case 2: + if (lig[i]>32) + name[j++] = lig[i]; + if(lig[i]== 0) + { + name[j]=0; + namefound=1; + status++; + } + break; + default: + break; + + } + if (lig[i] == '/') + fin = 1; + if (lig[i] == 0) + fin = 1; + if ( i == l ) + fin = 1; + + i++; + } + + if (level!=-1 && kind!=-1 && namefound==1) + { + name[j]=0; + subMenuItem[nbSubMenuItem].menuLevel = level; + subMenuItem[nbSubMenuItem].kindOfItem = kind; + subMenuItem[nbSubMenuItem].setname(name); + nbSubMenuItem++; + } +} + +void cSubMenu::SaveInfoSubMenu() +{ + FILE *f; + char *fichier; + asprintf(&fichier,"%s/MainMenu.conf",cPlugin::ConfigDirectory()); + f=fopen(fichier,"w"); + if (f) + { + for (int i=0;iposition;i--) + { + subMenuItem[i]=subMenuItem[i-1]; + } + nbSubMenuItem++; + Arbo.Populate(this); +} + + +cArbo::cArbo(void) +{ + MaxLevel=0; + for (int i=0;inbSubMenuItem;i++) + { + Index[ submenu->subMenuItem[i].menuLevel ][ submenu->Arbo.MaxItem[submenu->subMenuItem[i].menuLevel]] = i; + submenu->Arbo.MaxItem[submenu->subMenuItem[i].menuLevel]++; + if (submenu->subMenuItem[i].menuLevel > submenu->Arbo.MaxLevel) + { + submenu->Arbo.MaxLevel = submenu->subMenuItem[i].menuLevel; + } + if (submenu->subMenuItem[i].kindOfItem > submenu->Arbo.MaxLevel) + { + submenu->Arbo.MaxLevel = submenu->subMenuItem[i].kindOfItem; + } + } +} diff -ruN vdr-1.3.17.orig/submenu.h vdr-1.3.17/submenu.h --- vdr-1.3.17.orig/submenu.h 1970-01-01 01:00:00.000000000 +0100 +++ vdr-1.3.17/submenu.h 2004-12-24 06:51:17.000000000 +0100 @@ -0,0 +1,60 @@ +#ifndef __SUBMENU_H +#define __SUBMENU_H + +#define SIZEMAXNAMESUBMENUITEMINFO 30 +#define NBMAXSUBMENUANDITEM 50 + +class cSubMenu; + +class cSubMenuItemInfo +{ + private: + public: + cSubMenuItemInfo(); + ~cSubMenuItemInfo(); + + int menuLevel; + int kindOfItem; + char name[SIZEMAXNAMESUBMENUITEMINFO]; //todo revoir ca(la taille en dur) + + void setname(const char *n); +}; + +class cArbo +{ + private: + public: + cArbo(void); + ~cArbo(void); + int Index[NBMAXSUBMENUANDITEM][NBMAXSUBMENUANDITEM]; + int CurrentIndex[NBMAXSUBMENUANDITEM]; + int MaxLevel; + int MaxItem[NBMAXSUBMENUANDITEM]; + void Populate(cSubMenu *submenu); + void Clear(void); +}; + +class cSubMenu +{ + private: + public: + int currentMenuLevel; + cSubMenuItemInfo *subMenuItem; + cArbo Arbo; + int nbSubMenuItem; + int oldNumberMenu[ NBMAXSUBMENUANDITEM ]; + int nbLevelMenu; + + cSubMenu(); + virtual ~cSubMenu(); + void LoadInfoSubMenu(void); + void ParseOneLigOfFile (const char *lig); + void SaveInfoSubMenu(void); + int GetByLevel(int Level, int curr); + int GetByLevel(int Level); + void CreateItem(int type,int position,int where,char *Name=""); + void DeleteItem(int position,int kindItem=-1); + void InsertItem(int position); + void Dump(void); +}; +#endif //__SUBMENU_H