Patch #4: Day separator in Schedule

Message ID 200509261508.06515.lists@magoa.net
State New
Headers

Commit Message

Sascha Volkenandt Sept. 26, 2005, 1:08 p.m. UTC
  Hi list,

I'll be releasing this and a few other patches for VDR 1.3.33, which have 
evolved during the last months while working on XeatreOS (a distribution 
based on LinVDR 0.7, which is used for the Xeatre boxes, 
http://www.xeatre.tv/). Some of their functionality may already be included 
in plugins or other patches. Nevertheless, I'd like to release them now, and 
let everybody decide whether they are useful or not. 


This one adds a non-selectable item in schedules whenever a date change 
occurs.

Greetings,
Sascha
  

Comments

Joachim Wilke Jan. 14, 2006, 5:48 p.m. UTC | #1
2005/9/26, Sascha Volkenandt <lists@magoa.net>:
>
> This one adds a non-selectable item in schedules whenever a date change
> occurs.
>

This useful patch does not work properly with 1.3.38 (for example:
segmentation fault, when pressing the info key followed by ok). I have
attached an adapted version of it.

Joachim.
  
Joachim Wilke Jan. 15, 2006, 7:13 p.m. UTC | #2
2006/1/14, Joachim Wilke <joachim.wilke@gmail.com>:
>
> 2005/9/26, Sascha Volkenandt <lists@magoa.net>:
> >
> > This one adds a non-selectable item in schedules whenever a date change
> > occurs.
> >
> This useful patch does not work properly with 1.3.38 (for example:
> segmentation fault, when pressing the info key followed by ok). I have
> attached an adapted version of it.


I adapted this patch again, now for vdr 1.3.39.

As 1.3.39 provides for different views in cMenuSchedule, i added the day
separator to the first three ones ("this channel", "this event on this
channel" and "this event on all channels").

Further I thought about translating the "New day" string which was part of
the separator but decided to drop it completely for cosmetic reasons
(personal opinion ;-), give it a try.

Joachim.
  
Matthias Becker Jan. 18, 2006, 7:41 a.m. UTC | #3
2006/1/15, Joachim Wilke <joachim.wilke@gmail.com>:
>
> 2006/1/14, Joachim Wilke <joachim.wilke@gmail.com>:
> >
> > 2005/9/26, Sascha Volkenandt <lists@magoa.net>:
> > >
> > > This one adds a non-selectable item in schedules whenever a date
> > > change
> > > occurs.
> > >
> > This useful patch does not work properly with 1.3.38 (for example:
> > segmentation fault, when pressing the info key followed by ok). I have
> > attached an adapted version of it.
>
>
> I adapted this patch again, now for vdr 1.3.39.
>
> As 1.3.39 provides for different views in cMenuSchedule, i added the day
> separator to the first three ones ("this channel", "this event on this
> channel" and "this event on all channels").
>
> Further I thought about translating the "New day" string which was part of
> the separator but decided to drop it completely for cosmetic reasons
> (personal opinion ;-), give it a try.
>
> Joachim.
>
> Also a very nice patch. It increases the usability of the Schedule menu
very much. Isn't this something that should go into core VDR?

Matthias
  
Joachim Wilke Jan. 21, 2006, 10:20 a.m. UTC | #4
2006/1/15, Joachim Wilke <joachim.wilke@gmail.com>:
>  I adapted this patch again, now for vdr 1.3.39.

I found a little but serious mistake in the patch, attached is the
fixed version.

Joachim.
  

Patch

diff -Nru vdr-1.3.33-orig/epg.c vdr-1.3.33/epg.c
--- vdr-1.3.33-orig/epg.c	Fri Sep  9 17:14:11 2005
+++ vdr-1.3.33/epg.c	Mon Sep 26 14:57:04 2005
@@ -230,6 +230,14 @@ 
   return buf;
 }
 
+cString cEvent::GetWeekdayString() const
+{
+   char buf[4];
+   struct tm tm_r;
+   strn0cpy(buf, WeekDayName(localtime_r(&startTime, &tm_r)->tm_wday), sizeof(buf));
+   return buf;
+}
+
 void cEvent::Dump(FILE *f, const char *Prefix, bool InfoOnly) const
 {
   if (InfoOnly || startTime + duration + Setup.EPGLinger * 60 >= time(NULL)) {
diff -Nru vdr-1.3.33-orig/epg.h vdr-1.3.33/epg.h
--- vdr-1.3.33-orig/epg.h	Sun Sep 11 14:54:30 2005
+++ vdr-1.3.33/epg.h	Mon Sep 26 14:57:04 2005
@@ -87,6 +87,7 @@ 
   cString GetTimeString(void) const;
   cString GetEndTimeString(void) const;
   cString GetVpsString(void) const;
+  cString GetWeekdayString(void) const;
   void SetEventID(u_int16_t EventID);
   void SetTableID(uchar TableID);
   void SetVersion(uchar Version);
diff -Nru vdr-1.3.33-orig/menu.c vdr-1.3.33/menu.c
--- vdr-1.3.33-orig/menu.c	Sun Sep 25 15:37:21 2005
+++ vdr-1.3.33/menu.c	Mon Sep 26 14:57:04 2005
@@ -1078,6 +1078,23 @@ 
   SetText(buffer, false);
 }
 
+// --- cMenuScheduleSeparator ------------------------------------------------
+
+class cMenuScheduleSeparator : public cOsdItem {
+public:
+  const cEvent *event;
+  cMenuScheduleSeparator(const char *DateString);
+};
+
+cMenuScheduleSeparator::cMenuScheduleSeparator(const char *DateString)
+{
+  event = NULL;
+  char *buffer = NULL;
+  asprintf(&buffer, ">>> %s: %.*s", tr("New Day"), 10, DateString);
+  SetText(buffer, false);
+  SetSelectable(false);
+}
+
 // --- cMenuSchedule ---------------------------------------------------------
 
 class cMenuSchedule : public cOsdMenu {
@@ -1126,9 +1143,14 @@ 
      if (Schedule) {
         const cEvent *PresentEvent = Schedule->GetPresentEvent(Channel->Number() == cDevice::CurrentChannel());
         time_t now = time(NULL) - Setup.EPGLinger * 60;
+		char curDate[10] = "";
         for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) {
-            if (Event->EndTime() > now || Event == PresentEvent)
+            if (Event->EndTime() > now || Event == PresentEvent) {
+			   if (strlen(curDate) > 0 && strncmp(Event->GetWeekdayString(), curDate, 10) != 0)
+                  Add(new cMenuScheduleSeparator(Event->GetDateString()));
                Add(new cMenuScheduleItem(Event), Event == PresentEvent);
+			   strncpy(curDate, Event->GetWeekdayString(), 10);
+               }
             }
         }
      }