summaryrefslogtreecommitdiff
path: root/vdr-patch/menuorg-0.1.diff
blob: 9bc15ddda4f8b470c93f768f11f3b25767476785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
diff -Nur vdr-1.4.7/mainmenuitemsprovider.h vdr-1.4.7.patched/mainmenuitemsprovider.h
--- vdr-1.4.7/mainmenuitemsprovider.h	1970-01-01 01:00:00.000000000 +0100
+++ vdr-1.4.7.patched/mainmenuitemsprovider.h	2007-08-21 01:08:25.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 <vector>
+
+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<IMenuItemDefinition*> 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 -Nur vdr-1.4.7/menu.c vdr-1.4.7.patched/menu.c
--- vdr-1.4.7/menu.c	2006-12-02 12:12:02.000000000 +0100
+++ vdr-1.4.7.patched/menu.c	2007-08-21 01:08:25.000000000 +0200
@@ -28,6 +28,7 @@
 #include "timers.h"
 #include "transfer.h"
 #include "videodir.h"
+#include "menuorgpatch.h"
 
 #define MAXWAIT4EPGINFO   3 // seconds
 #define MODETIMEOUT       3 // seconds
@@ -2788,6 +2789,9 @@
   cancelEditingItem = NULL;
   stopRecordingItem = NULL;
   recordControlsState = 0;
+
+  MenuOrgPatch::EnterRootMenu();
+
   Set();
 
   // Initial submenus:
@@ -2815,6 +2819,25 @@
   Clear();
   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:
 
@@ -2842,6 +2865,8 @@
   if (Commands.Count())
      Add(new cOsdItem(hk(tr("Commands")),  osCommands));
 
+  }
+
   Update(true);
 
   Display();
@@ -2966,6 +2991,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 -Nur vdr-1.4.7/menuorgpatch.h vdr-1.4.7.patched/menuorgpatch.h
--- vdr-1.4.7/menuorgpatch.h	1970-01-01 01:00:00.000000000 +0100
+++ vdr-1.4.7.patched/menuorgpatch.h	2007-08-21 01:08:25.000000000 +0200
@@ -0,0 +1,100 @@
+/*
+ * 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"
+
+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