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
|
/*
* See the README file for copyright information and how to reach the author.
*/
#include <string>
#include <locale.h>
#include <langinfo.h>
#include <math.h>
#include <vdr/menu.h>
#include <vdr/status.h>
#include "osditem.h"
#include "neutrinoepg.h"
// --- Icons ------------------------------------------------------------------
bool Icons::IsUTF8 = false;
void Icons::InitCharSet()
{
// Taken from VDR's vdr.c
char *CodeSet = NULL;
if(setlocale(LC_CTYPE, ""))
CodeSet = nl_langinfo(CODESET);
else
{
char *LangEnv = getenv("LANG"); // last resort in case locale stuff isn't installed
if(LangEnv)
{
CodeSet = strchr(LangEnv,'.');
if( CodeSet )
CodeSet++; // skip the dot
}
}
if( CodeSet && strcasestr(CodeSet,"UTF-8") != 0 )
IsUTF8 = true;
}
// --- myWhatsOnItem ----------------------------------------------------------
myOsdItem::myOsdItem(const cEvent *Event, cChannel *Channel, bool Next)
{
event = Event;
channel = Channel;
next = Next;
timer = NULL;
Set();
}
void myOsdItem::Set()
{
int i;
char *buffer = NULL, *strProgress = NULL;
const char *m = " ";
// look for timers
for(cTimer *ti = Timers.First(); ti; ti = Timers.Next(ti))
{
if(ti->Matches(t) && (ti->Channel() == channel))
{
timer = ti;
m = timer->Recording() ? Icons::Recording() : Icons::AlarmClock();
}
}
if(event)
{
if( percentprogress == 1 )
{
// calculate progress bar
float progress = (int)roundf( (float)(time(NULL) - event->StartTime()) / (float) (event->Duration()) * 100.0);
if(progress < 0)
progress = 0.;
else if(progress > 100)
progress = 100;
asprintf(&strProgress, "%3.0f%%", progress);
if(showchannelnumbers)
asprintf(&buffer,"%s\t%d\t%-10s\t %s\t%s", m, channel->Number(), channel->ShortName(true),
(!(event->RunningStatus()==4)&&next) ? *event->GetTimeString() : strProgress, event->Title());
else
asprintf(&buffer,"%s\t%-10s\t %s\t%s", m, channel->ShortName(true),
(!(event->RunningStatus()==4)&&next) ? *event->GetTimeString() : strProgress,event->Title());
} else
{
// calculate progress bar
float progress = (int)roundf( (float)(time(NULL) - event->StartTime()) / (float) (event->Duration()) * 10.0);
if(progress < 0)
progress = 0.;
else if(progress > 9)
progress = 9;
std::string ProgressBar;
ProgressBar += Icons::ProgressStart();
for(i=0;i < 10;i++)
{
if(i < progress)
ProgressBar += Icons::ProgressFilled();
else
ProgressBar += Icons::ProgressEmpty();
}
ProgressBar += Icons::ProgressEnd();
if(showchannelnumbers)
asprintf(&buffer,"%s\t%d\t%-10s\t %s\t%s", m, channel->Number(), channel->ShortName(true),
(!(event->RunningStatus()==4)&&next) ? *event->GetTimeString() : ProgressBar.c_str(), event->Title());
else
asprintf(&buffer,"%s\t%-10s\t %s\t%s", m, channel->ShortName(true),
(!(event->RunningStatus()==4)&&next) ? *event->GetTimeString() : ProgressBar.c_str(), event->Title());
}
}
else
{
if(showchannelnumbers)
asprintf(&buffer,"%s\t%d\t%-10s\t \t(%s)", m, channel->Number(), channel->ShortName(true), tr("no program info"));
else
asprintf(&buffer,"%s\t%-10s\t \t(%s)", m, channel->ShortName(true), tr("no program info"));
}
SetText(buffer, false);
}
|