diff options
author | Martin Prochnow <nordlicht@martins-kabuff.de> | 2006-03-13 13:43:16 +0100 |
---|---|---|
committer | Andreas Mair <andreas@vdr-developer.org> | 2006-03-13 13:43:16 +0100 |
commit | 69ab28fe3563ca25153a7bc5bfab003f6c23d9aa (patch) | |
tree | 7c0194a56f46a7bd06fd56437daffd1bff647dbe | |
parent | 17f89bafd559b28b5a175aa82730226dfe9f7d69 (diff) | |
download | vdr-plugin-extrecmenu-69ab28fe3563ca25153a7bc5bfab003f6c23d9aa.tar.gz vdr-plugin-extrecmenu-69ab28fe3563ca25153a7bc5bfab003f6c23d9aa.tar.bz2 |
Version 0.4v0.4
- add option to hide main menu entry
- set tabs depending on the shown recordings details - looks more fancy and there is more space for the recording names
- fixed a possible memory leak
-rw-r--r-- | HISTORY | 6 | ||||
-rw-r--r-- | extrecmenu.c | 9 | ||||
-rw-r--r-- | extrecmenu.h | 83 | ||||
-rw-r--r-- | i18n.c | 3 | ||||
-rw-r--r-- | mymenumoverecording.c | 6 | ||||
-rw-r--r-- | mymenurecordinginfo.c | 1 | ||||
-rw-r--r-- | mymenurecordings.c | 107 | ||||
-rw-r--r-- | mymenurecordings.h | 75 | ||||
-rw-r--r-- | mymenurenamerecording.c | 6 | ||||
-rw-r--r-- | mymenusetup.c | 4 | ||||
-rw-r--r-- | mymenusetup.h | 4 | ||||
-rw-r--r-- | myreplaycontrol.c | 3 | ||||
-rw-r--r-- | myreplaycontrol.h | 3 |
13 files changed, 189 insertions, 121 deletions
@@ -1,6 +1,12 @@ VDR Plugin 'extrecmenu' Revision History ---------------------------------------- +2006-03-13: Version 0.4 +- add option to hide main menu entry +- set tabs depending on the shown recordings details - looks more fancy and + there is more space for the recording names +- fixed a possible memory leak + 2006-03-12: Version 0.3 - details for directories are shown now (# of entries, # of new entries) - option to shown the length of a recording diff --git a/extrecmenu.c b/extrecmenu.c index dc94164..e5a6774 100644 --- a/extrecmenu.c +++ b/extrecmenu.c @@ -1,5 +1,7 @@ -#include "extrecmenu.h" #include "mymenusetup.h" +#include "mymenurecordings.h" +#include "extrecmenu.h" +#include "i18n.h" cPluginExtrecmenu::cPluginExtrecmenu(void) { @@ -70,7 +72,10 @@ bool cPluginExtrecmenu::SetupParse(const char *Name, const char *Value) if(!strcasecmp(Name,"ShowRecLength")) mysetup.ShowRecLength=atoi(Value); else - return false; + if(!strcasecmp(Name,"HideMainMenuEntry")) + mysetup.HideMainMenuEntry=atoi(Value); + else + return false; return true; } diff --git a/extrecmenu.h b/extrecmenu.h index 139dcd8..613bdf1 100644 --- a/extrecmenu.h +++ b/extrecmenu.h @@ -1,15 +1,9 @@ #include <vdr/plugin.h> -#include <vdr/menu.h> -#include <vdr/skins.h> -#include <vdr/videodir.h> -#include "i18n.h" -static const char *VERSION = "0.3"; +static const char *VERSION = "0.4"; static const char *DESCRIPTION = "Extended recordings menu"; static const char *MAINMENUENTRY = "ExtRecMenu"; -extern bool clearall; // needed for myMenuMoveRecording - // --- cPluginExtrecmenu ------------------------------------------------------ class cPluginExtrecmenu:public cPlugin { @@ -25,7 +19,7 @@ class cPluginExtrecmenu:public cPlugin virtual bool Start(void); virtual void Stop(void); virtual void Housekeeping(void); - virtual const char *MainMenuEntry(void){return MAINMENUENTRY;} + virtual const char *MainMenuEntry(void){return mysetup.HideMainMenuEntry?NULL:MAINMENUENTRY;} virtual cOsdObject *MainMenuAction(void); virtual cMenuSetupPage *SetupMenu(void); virtual bool SetupParse(const char *Name,const char *Value); @@ -33,76 +27,3 @@ class cPluginExtrecmenu:public cPlugin virtual const char **SVDRPHelpPages(void); virtual cString SVDRPCommand(const char *Command,const char *Option,int &ReplyCode); }; - -// --- myMenuRecordingsItem --------------------------------------------------- -class myMenuRecordingsItem:public cOsdItem -{ - private: - int level,isdirectory; - int totalentries,newentries; - char *title; - char *name; - const char *filename; - public: - myMenuRecordingsItem(cRecording *Recording,int Level); - ~myMenuRecordingsItem(); - const char *FileName(){return filename;} - const char *Name(){return name;} - bool IsDirectory(){return name!=NULL;} - void IncrementCounter(bool IsNew); -}; - -// --- myMenuRecordings ------------------------------------------------------- -class myMenuRecordings:public cOsdMenu -{ - private: - bool edit; - int level,helpkeys; - int recordingsstate; - char *base; - bool Open(); - void SetHelpKeys(); - cRecording *GetRecording(myMenuRecordingsItem *Item); - eOSState Play(); - eOSState Rewind(); - eOSState Delete(); - eOSState Rename(); - eOSState MoveRec(); - eOSState Info(); - public: - myMenuRecordings(const char *Base=NULL,int Level=0); - ~myMenuRecordings(); - void Set(bool Refresh=false); - virtual eOSState ProcessKey(eKeys Key); -}; - -// --- myMenuRenameRecording -------------------------------------------------- -class myMenuRenameRecording:public cOsdMenu -{ - private: - char name[MaxFileName]; - char path[MaxFileName]; - cRecording *recording; - myMenuRecordings *menurecordings; - public: - myMenuRenameRecording(cRecording *Recording,myMenuRecordings *MenuRecordings); - virtual eOSState ProcessKey(eKeys Key); -}; - -// --- myMenuMoveRecording ---------------------------------------------------- -class myMenuMoveRecording:public cOsdMenu -{ - private: - int level; - char *base; - cRecording *recording; - myMenuRecordings *menurecordings; - void Set(); - eOSState Open(); - eOSState MoveRec(); - eOSState Create(); - public: - myMenuMoveRecording(cRecording *Recording,myMenuRecordings *MenuRecordings,const char *Base=NULL,int Level=0); - myMenuMoveRecording::~myMenuMoveRecording(); - virtual eOSState ProcessKey(eKeys Key); -}; @@ -56,5 +56,8 @@ const tI18nPhrase Phrases[] = { { "Show recording length", "Zeige Aufnahmelänge", }, + { "Hide main menu entry", + "Hauptmenüeintrag ausblenden", + }, { NULL } }; diff --git a/mymenumoverecording.c b/mymenumoverecording.c index f0a64d1..198198f 100644 --- a/mymenumoverecording.c +++ b/mymenumoverecording.c @@ -1,4 +1,6 @@ -#include "extrecmenu.h" +#include <vdr/videodir.h> +#include <vdr/menu.h> +#include "mymenurecordings.h" bool clearall; char newname[128]; @@ -174,7 +176,7 @@ eOSState myMenuMoveRecording::MoveRec() // update recordings list Recordings.Update(true); // update menu - menurecordings->Set(); + menurecordings->Set(true); // close move-recordings-menu clearall=true; } diff --git a/mymenurecordinginfo.c b/mymenurecordinginfo.c index 298a943..6610227 100644 --- a/mymenurecordinginfo.c +++ b/mymenurecordinginfo.c @@ -1,3 +1,4 @@ +#include <vdr/status.h> #include "myreplaycontrol.h" myMenuRecordingInfo::myMenuRecordingInfo(const cRecording *Recording,bool WithButtons):cOsdMenu(tr("Recording info")) diff --git a/mymenurecordings.c b/mymenurecordings.c index b29242e..573d1c9 100644 --- a/mymenurecordings.c +++ b/mymenurecordings.c @@ -1,3 +1,4 @@ +#include <vdr/interface.h> #include "mymenurecordings.h" #include "mymenusetup.h" @@ -108,8 +109,20 @@ void myMenuRecordingsItem::IncrementCounter(bool IsNew) } // --- myMenuRecordings ------------------------------------------------------- -myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Base:tr(DESCRIPTION),8,6,4) +myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Base:tr("Extended recordings menu")) { + // set tabs + if(mysetup.ShowRecDate&&mysetup.ShowRecTime&&mysetup.ShowRecLength) // all details are shown + SetCols(8,6,4); + else + if(mysetup.ShowRecDate&&!mysetup.ShowRecTime&&mysetup.ShowRecLength) // recording time is not shown + SetCols(8,4); + else + if(!mysetup.ShowRecDate&&mysetup.ShowRecTime&&mysetup.ShowRecLength) // recording date is not shown + SetCols(6,4); + else // recording date and time are not shown; even if recording length should be not shown we must set two tabs because the details of the directories + SetCols(4,4); + edit=false; level=Level; helpkeys=-1; @@ -117,7 +130,15 @@ myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Bas Recordings.StateChanged(recordingsstate); + Display(); Set(); + /* + if(Current()<0) + SetCurrent(First()); + else + if(myReplayControl::LastReplayed&&Open()) + return; + */ Display(); SetHelpKeys(); } @@ -127,14 +148,46 @@ myMenuRecordings::~myMenuRecordings() free(base); } +void myMenuRecordings::SetHelpKeys() +{ + if(!HasSubMenu()) + { + myMenuRecordingsItem *item=(myMenuRecordingsItem*)Get(Current()); + int newhelpkeys=0; + if(item) + { + if(item->IsDirectory()) + newhelpkeys=1; + else + { + newhelpkeys=2; + } + if(newhelpkeys!=helpkeys) + { + switch(newhelpkeys) + { + case 0: SetHelp(NULL);break; + case 1: SetHelp(tr("Button$Open"));break; + case 2: + case 3: SetHelp(tr("Button$Play"),tr("Button$Rewind"),tr("Button$Edit"),tr("Button$Info"));break; + } + } + helpkeys=newhelpkeys; + } + } +} + void myMenuRecordings::Set(bool Refresh) { +// const char *currentrecording=myReplayControl::LastReplayed(); + cThreadLock RecordingsLock(&Recordings); Clear(); Recordings.Sort(); char *lastitemtext=NULL; myMenuRecordingsItem *lastitem=NULL; + bool inlist=false; // add first the directories for(cRecording *recording=Recordings.First();recording;recording=Recordings.Next(recording)) { @@ -144,7 +197,10 @@ void myMenuRecordings::Set(bool Refresh) if(*item->Text()&&(!lastitem||strcmp(item->Text(),lastitemtext))) { if(item->IsDirectory()) + { Add(item); + inlist=true; + } lastitem=item; free(lastitemtext); @@ -157,9 +213,17 @@ void myMenuRecordings::Set(bool Refresh) { if(lastitem->IsDirectory()) lastitem->IncrementCounter(recording->IsNew()); // counts the number of entries in a directory + // delete items that are not in the list + if(!inlist) + { + delete lastitem; + lastitem=NULL; + inlist=false; + } } } } + inlist=false; lastitem=NULL; // and now the recordings for(cRecording *recording=Recordings.First();recording;recording=Recordings.Next(recording)) @@ -170,47 +234,32 @@ void myMenuRecordings::Set(bool Refresh) if(*item->Text()&&(!lastitem||strcmp(lastitemtext,item->Text()))) { if(!item->IsDirectory()) + { Add(item); + inlist=true; + } lastitem=item; free(lastitemtext); lastitemtext=strdup(lastitem->Text()); } else delete item; - } - } - free(lastitemtext); - if(Refresh) - Display(); -} - -void myMenuRecordings::SetHelpKeys() -{ - if(!HasSubMenu()) - { - myMenuRecordingsItem *item=(myMenuRecordingsItem*)Get(Current()); - int newhelpkeys=0; - if(item) - { - if(item->IsDirectory()) - newhelpkeys=1; - else - { - newhelpkeys=2; - } - if(newhelpkeys!=helpkeys) + + if(lastitem) { - switch(newhelpkeys) + // delete items that are not in the list + if(!inlist) { - case 0: SetHelp(NULL);break; - case 1: SetHelp(tr("Button$Open"));break; - case 2: - case 3: SetHelp(tr("Button$Play"),tr("Button$Rewind"),tr("Button$Edit"),tr("Button$Info"));break; + delete lastitem; + lastitem=NULL; + inlist=false; } } - helpkeys=newhelpkeys; } } + free(lastitemtext); + if(Refresh) + Display(); } // returns the corresponding recording to an item diff --git a/mymenurecordings.h b/mymenurecordings.h index 719acf0..a5789ad 100644 --- a/mymenurecordings.h +++ b/mymenurecordings.h @@ -1,3 +1,76 @@ -#include "extrecmenu.h" #include "myreplaycontrol.h" +extern bool clearall; // needed for myMenuMoveRecording + +// --- myMenuRecordingsItem --------------------------------------------------- +class myMenuRecordingsItem:public cOsdItem +{ + private: + int level,isdirectory; + int totalentries,newentries; + char *title; + char *name; + const char *filename; + public: + myMenuRecordingsItem(cRecording *Recording,int Level); + ~myMenuRecordingsItem(); + const char *FileName(){return filename;} + const char *Name(){return name;} + bool IsDirectory(){return name!=NULL;} + void IncrementCounter(bool IsNew); +}; + +// --- myMenuRecordings ------------------------------------------------------- +class myMenuRecordings:public cOsdMenu +{ + private: + bool edit; + int level,helpkeys; + int recordingsstate; + char *base; + bool Open(); + void SetHelpKeys(); + cRecording *GetRecording(myMenuRecordingsItem *Item); + eOSState Play(); + eOSState Rewind(); + eOSState Delete(); + eOSState Rename(); + eOSState MoveRec(); + eOSState Info(); + public: + myMenuRecordings(const char *Base=NULL,int Level=0); + ~myMenuRecordings(); + void Set(bool Refresh=false); + virtual eOSState ProcessKey(eKeys Key); +}; + +// --- myMenuRenameRecording -------------------------------------------------- +class myMenuRenameRecording:public cOsdMenu +{ + private: + char name[MaxFileName]; + char path[MaxFileName]; + cRecording *recording; + myMenuRecordings *menurecordings; + public: + myMenuRenameRecording(cRecording *Recording,myMenuRecordings *MenuRecordings); + virtual eOSState ProcessKey(eKeys Key); +}; + +// --- myMenuMoveRecording ---------------------------------------------------- +class myMenuMoveRecording:public cOsdMenu +{ + private: + int level; + char *base; + cRecording *recording; + myMenuRecordings *menurecordings; + void Set(); + eOSState Open(); + eOSState MoveRec(); + eOSState Create(); + public: + myMenuMoveRecording(cRecording *Recording,myMenuRecordings *MenuRecordings,const char *Base=NULL,int Level=0); + myMenuMoveRecording::~myMenuMoveRecording(); + virtual eOSState ProcessKey(eKeys Key); +}; diff --git a/mymenurenamerecording.c b/mymenurenamerecording.c index 492a3c6..172cb40 100644 --- a/mymenurenamerecording.c +++ b/mymenurenamerecording.c @@ -1,4 +1,6 @@ -#include "extrecmenu.h" +#include <vdr/videodir.h> +#include <vdr/menu.h> +#include "mymenurecordings.h" myMenuRenameRecording::myMenuRenameRecording(cRecording *Recording,myMenuRecordings *MenuRecordings):cOsdMenu(tr("Rename recording"),12) { @@ -50,7 +52,7 @@ eOSState myMenuRenameRecording::ProcessKey(eKeys Key) // update recordings list Recordings.Update(true); // update menu - menurecordings->Set(); + menurecordings->Set(true); return osBack; } else diff --git a/mymenusetup.c b/mymenusetup.c index 2f3ae40..f0d2cc7 100644 --- a/mymenusetup.c +++ b/mymenusetup.c @@ -1,14 +1,15 @@ -#include <vdr/menu.h> #include "mymenusetup.h" mySetup mysetup; myMenuSetup::myMenuSetup() { + hidemainmenuentry=mysetup.HideMainMenuEntry; showrecdate=mysetup.ShowRecDate; showrectime=mysetup.ShowRecTime; showreclength=mysetup.ShowRecLength; + Add(new cMenuEditBoolItem(tr("Hide main menu entry"),&hidemainmenuentry)); Add(new cMenuEditBoolItem(tr("Show recording date"),&showrecdate)); Add(new cMenuEditBoolItem(tr("Show recording time"),&showrectime)); Add(new cMenuEditBoolItem(tr("Show recording length"),&showreclength)); @@ -16,6 +17,7 @@ myMenuSetup::myMenuSetup() void myMenuSetup::Store() { + SetupStore("HideMainMenuEntry",mysetup.HideMainMenuEntry=hidemainmenuentry); SetupStore("ShowRecDate",mysetup.ShowRecDate=showrecdate); SetupStore("ShowRecTime",mysetup.ShowRecTime=showrectime); SetupStore("ShowRecLength",mysetup.ShowRecLength=showreclength); diff --git a/mymenusetup.h b/mymenusetup.h index b137789..7dde4bb 100644 --- a/mymenusetup.h +++ b/mymenusetup.h @@ -1,9 +1,12 @@ +#include <vdr/menu.h> + class mySetup { public: int ShowRecDate; int ShowRecTime; int ShowRecLength; + int HideMainMenuEntry; }; extern mySetup mysetup; @@ -14,6 +17,7 @@ class myMenuSetup:public cMenuSetupPage int showrecdate; int showrectime; int showreclength; + int hidemainmenuentry; protected: virtual void Store(); public: diff --git a/myreplaycontrol.c b/myreplaycontrol.c index 6003c44..a9a60a4 100644 --- a/myreplaycontrol.c +++ b/myreplaycontrol.c @@ -1,3 +1,6 @@ +#include <vdr/interface.h> +#include <vdr/status.h> +#include <vdr/cutter.h> #include "myreplaycontrol.h" char *myReplayControl::fileName = NULL; diff --git a/myreplaycontrol.h b/myreplaycontrol.h index 25c5f45..cd14c96 100644 --- a/myreplaycontrol.h +++ b/myreplaycontrol.h @@ -1,6 +1,3 @@ -#include <vdr/cutter.h> -#include <vdr/status.h> -#include <vdr/interface.h> #include "mydvbplayer.h" #define MODETIMEOUT 3 // seconds |