diff -Nru vdr-1.5.10/mainmenuitemsprovider.h vdr-1.5.10-menuorg/mainmenuitemsprovider.h --- vdr-1.5.10/mainmenuitemsprovider.h 1970-01-01 01:00:00.000000000 +0100 +++ vdr-1.5.10-menuorg/mainmenuitemsprovider.h 2007-10-19 22:26:26.000000000 +0200 @@ -0,0 +1,57 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id:$ + * + */ + +#ifndef __MAINMENUITEMSPROVIDER_H +#define __MAINMENUITEMSPROVIDER_H + +#include + +class cOsdItem; +class cOsdMenu; + +class IMenuItemDefinition +{ + public: + virtual ~IMenuItemDefinition() {}; + virtual bool IsCustomOsdItem() = 0; + virtual bool IsPluginItem() = 0; + virtual cOsdItem* CustomOsdItem() = 0; + virtual const char* PluginMenuEntry() = 0; + virtual int PluginIndex() = 0; +}; + +typedef std::vector MenuItemDefinitions; + +#define MENU_ITEMS_PROVIDER_SERVICE_ID "MenuOrgPatch-v0.1::MainMenuItemsProvider" + +class IMainMenuItemsProvider +{ + public: + virtual ~IMainMenuItemsProvider() {}; + virtual MenuItemDefinitions* MainMenuItems() = 0; + virtual void EnterRootMenu() = 0; + virtual void EnterSubMenu(cOsdItem* item) = 0; + virtual bool LeaveSubMenu() = 0; + virtual cOsdMenu* Execute(cOsdItem* item) = 0; +}; + +#endif //__MAINMENUITEMSPROVIDER_H diff -Nru vdr-1.5.10/menu.c vdr-1.5.10-menuorg/menu.c --- vdr-1.5.10/menu.c 2007-10-19 22:23:18.000000000 +0200 +++ vdr-1.5.10-menuorg/menu.c 2007-10-19 22:29:07.000000000 +0200 @@ -14,6 +14,7 @@ #include #include #include +#include "menuorgpatch.h" #include "channels.h" #include "config.h" #include "cutter.h" @@ -3133,6 +3134,9 @@ cancelEditingItem = NULL; stopRecordingItem = NULL; recordControlsState = 0; + + MenuOrgPatch::EnterRootMenu(); + Set(); // Initial submenus: @@ -3177,6 +3181,25 @@ SetTitle("VDR"); SetHasHotkeys(); + if (MenuOrgPatch::IsCustomMenuAvailable()) { + MenuItemDefinitions* menuItems = MenuOrgPatch::MainMenuItems(); + for (MenuItemDefinitions::iterator i = menuItems->begin(); i != menuItems->end(); i++) { + if ((*i)->IsCustomOsdItem()) { + cOsdItem* osdItem = (*i)->CustomOsdItem(); + if (osdItem) { + osdItem->SetText(hk(osdItem->Text())); + Add(osdItem); + } + } + else if ((*i)->IsPluginItem()) { + const char *item = (*i)->PluginMenuEntry(); + if (item) + Add(new cMenuPluginItem(hk(item), (*i)->PluginIndex())); + } + } + } + else { + // Basic menu items: Add(new cOsdItem(hk(tr("Schedule")), osSchedule)); @@ -3203,6 +3226,8 @@ if (Commands.Count()) Add(new cOsdItem(hk(tr("Commands")), osCommands)); + } + Update(true); Display(); @@ -3351,6 +3376,41 @@ state = osEnd; } break; + case osBack: { + if (MenuOrgPatch::IsCustomMenuAvailable()) + { + bool leavingMenuSucceeded = MenuOrgPatch::LeaveSubMenu(); + Set(); + stopReplayItem = NULL; + cancelEditingItem = NULL; + stopRecordingItem = NULL; + recordControlsState = 0; + Update(true); + Display(); + if (leavingMenuSucceeded) + return osContinue; + else + return osEnd; + } + } + break; + case osUser1: { + if (MenuOrgPatch::IsCustomMenuAvailable()) { + MenuOrgPatch::EnterSubMenu(Get(Current())); + Set(); + return osContinue; + } + } + break; + case osUser2: { + if (MenuOrgPatch::IsCustomMenuAvailable()) { + cOsdMenu* osdMenu = MenuOrgPatch::Execute(Get(Current())); + if (osdMenu) + return AddSubMenu(osdMenu); + return osEnd; + } + } + break; default: switch (Key) { case kRecord: case kRed: if (!HadSubMenu) diff -Nru vdr-1.5.10/menuorgpatch.h vdr-1.5.10-menuorg/menuorgpatch.h --- vdr-1.5.10/menuorgpatch.h 1970-01-01 01:00:00.000000000 +0100 +++ vdr-1.5.10-menuorg/menuorgpatch.h 2007-10-19 22:29:48.000000000 +0200 @@ -0,0 +1,101 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id:$ + * + */ + +#ifndef __MENUORGPATCH_H +#define __MENUORGPATCH_H + +#include "mainmenuitemsprovider.h" +#include "plugin.h" + +class MenuOrgPatch +{ + private: + static IMainMenuItemsProvider* _mainMenuItemsProvider; + + private: + static IMainMenuItemsProvider* MainMenuItemsProvider() + { + if (!_mainMenuItemsProvider) + { + IMainMenuItemsProvider* mainMenuItemsProvider; + + if (cPluginManager::CallFirstService(MENU_ITEMS_PROVIDER_SERVICE_ID, &mainMenuItemsProvider)) + { + _mainMenuItemsProvider = mainMenuItemsProvider; + } + } + return _mainMenuItemsProvider; + } + + public: + static bool IsCustomMenuAvailable() + { + return (MainMenuItemsProvider() != NULL); + } + + static void EnterRootMenu() + { + if (MainMenuItemsProvider()) + { + MainMenuItemsProvider()->EnterRootMenu(); + } + } + + static bool LeaveSubMenu() + { + if (MainMenuItemsProvider()) + { + return MainMenuItemsProvider()->LeaveSubMenu(); + } + return false; + } + + static void EnterSubMenu(cOsdItem* item) + { + if (MainMenuItemsProvider()) + { + MainMenuItemsProvider()->EnterSubMenu(item); + } + } + + static MenuItemDefinitions* MainMenuItems() + { + if (MainMenuItemsProvider()) + { + return MainMenuItemsProvider()->MainMenuItems(); + } + return NULL; + } + + static cOsdMenu* Execute(cOsdItem* item) + { + if (MainMenuItemsProvider()) + { + return MainMenuItemsProvider()->Execute(item); + } + return NULL; + } +}; + +IMainMenuItemsProvider* MenuOrgPatch::_mainMenuItemsProvider = NULL; + +#endif //__MENUORGPATCH_H