diff -NaurwB -X diffexclude mms-1.1.0-bzr-head/plugins/feature/epg/epg.cpp mms-1.1.0-bzr-head-fixepg/plugins/feature/epg/epg.cpp
--- mms-1.1.0-bzr-head/plugins/feature/epg/epg.cpp	2008-09-13 06:53:50.000000000 +0200
+++ mms-1.1.0-bzr-head-fixepg/plugins/feature/epg/epg.cpp	2008-09-24 19:42:01.000000000 +0200
@@ -356,7 +356,8 @@
 	}
 }
 
-XmlEpgEvent::XmlEpgEvent(BaseChannel *ch, TiXmlElement *element) : EpgEvent() {
+XmlEpgEvent::XmlEpgEvent(BaseChannel *ch, TiXmlElement *element) :
+	EpgEvent() {
   TiXmlNode *node;
   TiXmlText *text;
 
@@ -425,8 +426,8 @@
 	program.clear();
 }
 
-XMLChannel::XMLChannel(int _number, TiXmlElement *element) : Channel()
-{
+XMLChannel::XMLChannel(int _number, TiXmlElement *element) :
+	Channel() {
   TiXmlNode *node = 0;
   TiXmlText *text = 0;
 	epgsource = XML;
@@ -449,8 +450,7 @@
   }
 }
 
-void Epg::create_db()
-{
+void Epg::create_db() {
   vector<string> fields;
   fields.push_back("version INTEGER NOT NULL");
   fields.push_back("date TEXT");
@@ -548,8 +547,7 @@
   create_indexes();
 }
 
-void Epg::create_indexes()
-{
+void Epg::create_indexes() {
   db.execute("CREATE INDEX idx_program_title ON Program (ltitle)");
   db.execute("CREATE INDEX idx_program_desc ON Program (ldescription)");
   db.execute("CREATE INDEX idx_channel_tvid ON Channel (tvid)");
@@ -558,8 +556,7 @@
 
 }
 
-void Epg::clear_db()
-{
+void Epg::clear_db() {
 	SQLQuery *dq = db.query("sqlite_master",
 			"SELECT name FROM %t WHERE type='table'");
   if (dq) {
@@ -580,8 +577,7 @@
   delete dq;
 }
 
-void Epg::insert_schema()
-{
+void Epg::insert_schema() {
   struct stat64 s;
   stat64(epg_conf->p_epg_data().c_str(), &s);
 
@@ -591,8 +587,7 @@
   sqlite3_free(tmp);
 }
 
-bool Epg::check_db()
-{
+bool Epg::check_db() {
   if (!file_exists(epg_conf->p_epg_data()))
     return true;
 
@@ -682,7 +677,8 @@
 	}
 }
 
-void Epg::parse_channels(std::string _channels, std::vector<int> *_channelnumbers) {
+void Epg::parse_channels(std::string _channels,
+		std::vector<int> *_channelnumbers) {
 	std::vector<int>::iterator it;
 
 	int fc, lc, posc, posr;
@@ -708,7 +704,8 @@
 			if (_channelnumbers->empty()) {
 				_channelnumbers->push_back(i);
 			} else {
-				for (it = _channelnumbers->begin(); *it < i && it != _channelnumbers->end(); it++) {
+				for (it = _channelnumbers->begin(); *it < i && it
+						!= _channelnumbers->end(); it++) {
 				}
 				if (it == _channelnumbers->end() && *it != i) {
 					_channelnumbers->push_back(i);
@@ -739,7 +736,8 @@
 			if (_channelnumbers->empty()) {
 				_channelnumbers->push_back(i);
 			} else {
-				for (it = _channelnumbers->begin(); *it < i && it != _channelnumbers->end(); it++) {
+				for (it = _channelnumbers->begin(); *it < i && it
+						!= _channelnumbers->end(); it++) {
 				}
 				if (it == _channelnumbers->end() && *it != i) {
 					_channelnumbers->push_back(i);
@@ -753,10 +751,11 @@
 
 Epg::Epg() :
 
-	db((conf->p_homedir() + "epg.db").c_str()), exit_loop(false),
-			x_start(1), epg_script_found(true),
-			update_running(false) {
 
+	db((conf->p_homedir() + "epg.db").c_str()), exit_loop(false), x_start(1),
+			epg_script_found(true), update_running(false) {
+
+	ende = false;
 #ifdef use_nls
   // gettext
   setlocale(LC_ALL, ""); /* set from the environment variables */
@@ -767,40 +766,70 @@
 	epg_conf = S_EPGConfig::get_instance();
 
 	// Resolution-Independent-Stuff
-	header_font     = "Vera/" + conv::itos(resolution_dependant_font_size(28, conf->p_v_res()));
-	title_font      = "Vera/" + conv::itos(resolution_dependant_font_size(22, conf->p_v_res()));
-	subtitle_font   = "Vera/" + conv::itos(resolution_dependant_font_size(18, conf->p_v_res()));
-	normal_font     = "Vera/" + conv::itos(resolution_dependant_font_size(16, conf->p_v_res()));
-	annotation_font = "Vera/" + conv::itos(resolution_dependant_font_size(12, conf->p_v_res()));
-	grid_font	    = "Vera/" + conv::itos(resolution_dependant_font_size(14, conf->p_v_res()));
-	search_font 	= "Vera/" + conv::itos(resolution_dependant_font_size(22, conf->p_v_res()));
-	search_select_font = "Vera/" + conv::itos(resolution_dependant_font_size(17, conf->p_v_res()));
-
-	header_size 	= string_format::calculate_string_size("abcltuwHPMjJg", header_font);
-	title_size  	= string_format::calculate_string_size("abcltuwHPMjJg", title_font);
-	subtitle_size 	= string_format::calculate_string_size("abcltuwHPMjJg", subtitle_font);
-	normal_size 	= string_format::calculate_string_size("abcltuwHPMjJg", normal_font);
-	annotation_size = string_format::calculate_string_size("abcltuwHPMjJg", annotation_font);
-    grid_size       = string_format::calculate_string_size("abcltuwHPMjJg", grid_font);
-    search_size		= string_format::calculate_string_size("abcltuwHPMjJg", search_font);
+	border_left = 25;
+	border_right = 25;
+	border_top = 10;
+	border_bottom = 10;
+	spacing = 10;
+
+#ifdef use_notify_area
+	border_bottom += (NotifyArea::height + spacing);
+#endif
+
+	header_font = "Vera/" + conv::itos(resolution_dependant_font_size(28,
+			conf->p_v_res()));
+	title_font = "Vera/" + conv::itos(resolution_dependant_font_size(22,
+			conf->p_v_res()));
+	subtitle_font = "Vera/" + conv::itos(resolution_dependant_font_size(18,
+			conf->p_v_res()));
+	normal_font = "Vera/" + conv::itos(resolution_dependant_font_size(16,
+			conf->p_v_res()));
+	annotation_font = "Vera/" + conv::itos(resolution_dependant_font_size(12,
+			conf->p_v_res()));
+	grid_font = "Vera/" + conv::itos(resolution_dependant_font_size(14,
+			conf->p_v_res()));
+	search_font = "Vera/" + conv::itos(resolution_dependant_font_size(22,
+			conf->p_v_res()));
+	search_select_font = "Vera/" + conv::itos(resolution_dependant_font_size(
+			16, conf->p_v_res()));
+
+	header_size = string_format::calculate_string_size("abcltuwHPMjJg",
+			header_font);
+	title_size = string_format::calculate_string_size("abcltuwHPMjJg",
+			title_font);
+	subtitle_size = string_format::calculate_string_size("abcltuwHPMjJg",
+			subtitle_font);
+	normal_size = string_format::calculate_string_size("abcltuwHPMjJg",
+			normal_font);
+	annotation_size = string_format::calculate_string_size("abcltuwHPMjJg",
+			annotation_font);
+	grid_size
+			= string_format::calculate_string_size("abcltuwHPMjJg", grid_font);
+	search_size = string_format::calculate_string_size("abcltuwHPMjJg",
+			search_font);
+	search_select_size = string_format::calculate_string_size("abcltuwHPMjJg",
+			search_select_font);
 
-    channel_size    = string_format::calculate_string_size("abcltuwHPMjJgmi", grid_font);
+	channel_size = string_format::calculate_string_size("abcltuwHPMjJgmi",
+			grid_font);
 
 	header_box_size = static_cast<int>(header_size.second * 0.75);
 	search_box_size = static_cast<int>(search_size.second * 0.75);
 
-
-	timeslot_interval    = (epg_conf->p_timeslot_interval() > 5 ? epg_conf->p_timeslot_interval() : 30);
+	timeslot_interval
+			= (epg_conf->p_timeslot_interval() > 5 ? epg_conf->p_timeslot_interval()
+					: 30);
 
 	display_channel_name = epg_conf->p_display_channel_name();
 	display_channel_logo = epg_conf->p_display_channel_logo();
 
 	timeslots = epg_conf->p_timeslots();
 
-	grid_header_x = int((conf->p_h_res() * 0.75) + SPACING/2);
+	grid_header_x = int((conf->p_h_res() * 0.75) + spacing/2);
 	grid_x		  = grid_header_x;
 
-	scale_factor = (timeslot_interval * SECONDS_PER_MINUTE * timeslots) / (double(conf->p_h_res() * 0.75) - (SPACING / 2) - BORDER_RIGHT);
+	scale_factor = (timeslot_interval * SECONDS_PER_MINUTE * timeslots)
+			/ (double(conf->p_h_res() * 0.75) - (spacing / 2) - border_right);
 
 	max_logo_size_x = 0;
 
@@ -829,6 +858,9 @@
 
 			if (epg_conf->p_svdrp_convert()) {
 				svdrp->SetLocale(epg_conf->p_svdrp_locale());
+				printf("Convert is %s, Locale is %s\n",
+						epg_conf->p_svdrp_convert() ? "true" : "false",
+						epg_conf->p_svdrp_locale().c_str());
 			}
 		}
 	}
@@ -841,11 +873,13 @@
 }
 
 Epg::~Epg() {
-  delete epg_updater;
-
   db_mutex.enterMutex();
   db.close();
   db_mutex.leaveMutex();
+	
+	ende = true;
+	
+	delete epg_updater;
 }
 
 bool Epg::valid_program() {
@@ -872,7 +906,8 @@
   --end;
 
 	vector<EpgEvent *>::iterator piter;
-	for (piter = sel_channel->program.begin(), program_iter_end = sel_channel->program.end(); piter != program_iter_end; piter++) {
+	for (piter = sel_channel->program.begin(), program_iter_end
+			= sel_channel->program.end(); piter != program_iter_end; piter++) {
 		if ((*piter)->start >= sel_time) {
 			if ((*piter)->start == sel_time && piter != end) {
 
@@ -880,8 +915,7 @@
 	++piter;
 
 	// fix for strange programs with no length
-				if ((*last_program_iter)->start == (*last_program_iter)->stop
-						|| (*piter)->start == (*piter)->stop && piter != end) {
+				if ((*last_program_iter)->start == (*last_program_iter)->stop || (*piter)->start == (*piter)->stop && piter != end) {
 	  ++piter;
 	}
       }
@@ -924,15 +958,16 @@
     std::vector<Channel>::iterator ch;
 	
 	foreach(Channel& channel, channels) {
-		string logo_file = epg_conf->p_icon_path() + "/" + channel.display_name + ".xpm";
+		string logo_file = epg_conf->p_icon_path() + "/" + channel.display_name
+				+ ".xpm";
 		if (file_exists(logo_file)) {
 			channel.logo = logo_file;
-			grid_header_x = int((conf->p_h_res() * 0.75) + SPACING/2);
+			grid_header_x = int((conf->p_h_res() * 0.75) + spacing/2);
 			render->image_mut.enterMutex();
 			render->device->wait_for_not_drawing();
-			render->create_scaled_image_wrapper_upscaled(logo_file, int(conf->p_h_res() * 0.25 - SPACING/2), grid_size.second);
+			render->create_scaled_image_wrapper_upscaled(logo_file, int(conf->p_h_res() * 0.25 - spacing/2), grid_size.second);
 			
-			PFObj *l = new PFObj(logo_file, 1, 1, int(conf->p_h_res() * 0.25 - SPACING/2), grid_size.second, false, 2);
+			PFObj*l = new PFObj(logo_file, 1, 1, int(conf->p_h_res() * 0.25 - spacing/2), grid_size.second, false, 2);
 
 			if (l) {
 				if (l->w > max_logo_size_x)
@@ -964,7 +999,8 @@
 			if (dot_pos == string::npos) {
 				dot_pos = channel.id.size();
 				print_critical(dgettext("mms-epg",
-						"Error in channel id, please report this problem"), "EPG");
+						"Error in channel id, please report this problem"),
+						"EPG");
 			}
 		}
 	}
@@ -992,14 +1028,10 @@
 
 // commands
 void Epg::print_description() {
-  ScreenUpdater *screen_updater = S_ScreenUpdater::get_instance();
-
   S_BusyIndicator::get_instance()->idle();
 
-    screen_updater->timer.deactivate("epg");
 	(*program_iter)->PrintDescription(render, themes, conf->p_h_res(),
 			conf->p_v_res());
-    screen_updater->timer.activate("epg");
 }
 
 bool Epg::toggle_timer() {
@@ -1007,35 +1039,27 @@
 }
 
 bool Epg::toggle_timer(EpgEvent *ev) {
-  ScreenUpdater *screen_updater = S_ScreenUpdater::get_instance();
 
   S_BusyIndicator::get_instance()->idle();
 
-  screen_updater->timer.deactivate("epg");
-
 	if (use_svdrp) {
 		if (!svdrp->Connect()) {
-			screen_updater->timer.activate("epg");
 			return false;
   }
 		if (!svdrp->GetTimer(Timers)) {
 			svdrp->Disconnect();
-  screen_updater->timer.activate("epg");
 			return false;
 }
 		if (!svdrp->AssociateTimersAndEpgEvents(&channels, Timers)) {
 			svdrp->Disconnect();
-			screen_updater->timer.activate("epg");
 			return false;
 		}
 		svdrp->Disconnect();
 
 		if (ev->ToggleTimer(render, themes, conf->p_h_res(), conf->p_v_res())) {
 			if ( ev->HasTimer() ) {
-				screen_updater->timer.activate("epg");
 				return delete_timer((SvdrpEpgEvent *)ev);
 			} else {
-				screen_updater->timer.activate("epg");
 				return create_timer((SvdrpEpgEvent *)ev);
 			}		
 		}
@@ -1057,7 +1081,8 @@
 		svdrp->Disconnect();
 	    svdrp_mutex.leaveMutex();
 		if (result) {
-			  run::exclusive_external_program(epg_conf->p_svdrp_tv_path() + ' ' + epg_conf->p_svdrp_tv_opts());
+			run::exclusive_external_program(epg_conf->p_svdrp_tv_path() + ' '
+					+ epg_conf->p_svdrp_tv_opts());
 		}
 		
 		return result;
@@ -1073,11 +1098,14 @@
 		return false;
 	}
 	
-	result = svdrp->NewTimer(TIMER_ACTIVE, _epgevent->basechannel->number, "1", _epgevent->start - (timer_lead * SECONDS_PER_MINUTE), _epgevent->stop + (timer_trailer * SECONDS_PER_MINUTE), 
-			50, 50, _epgevent->org_title, "<created by mms>");
+	result = svdrp->NewTimer(TIMER_ACTIVE, _epgevent->basechannel->number, "1",
+			_epgevent->start - (timer_lead * SECONDS_PER_MINUTE),
+			_epgevent->stop + (timer_trailer * SECONDS_PER_MINUTE), 50, 50,
+			_epgevent->title, "<created by mms>");
 
 	if (result) {
-		for (std::vector<SvdrpTimerEvent>::iterator te=Timers->begin(); te != Timers->end(); te++) {
+		for (std::vector<SvdrpTimerEvent>::iterator te=Timers->begin(); te
+				!= Timers->end(); te++) {
 			if (te->epgevent != NULL) {
 				((SvdrpEpgEvent *)(te->epgevent))->Cleartimer();
 			}
@@ -1146,7 +1173,8 @@
 		result = svdrp->DeleteTimer(_epgevent->Timer()->Number());
 	
 		if (result) {
-			for (std::vector<SvdrpTimerEvent>::iterator te=Timers->begin(); te != Timers->end(); te++) {
+			for (std::vector<SvdrpTimerEvent>::iterator te=Timers->begin(); te
+					!= Timers->end(); te++) {
 				if (te->epgevent != NULL) {
 					((SvdrpEpgEvent *)(te->epgevent))->Cleartimer();
 				}
@@ -1187,8 +1215,6 @@
 	
 	ScreenUpdater *screen_updater = S_ScreenUpdater::get_instance();
 
-	screen_updater->timer.del("epg");
-
 	search_mode = true;
 	search_help_offset = -1;
 
@@ -1221,12 +1247,11 @@
 	search_mutex.enterMutex();
 
 	input_master->epg_search<EpgEvent *>(all_events, &search_position,
-					boost::bind(&Epg::search_print, this, _1),
-					boost::bind(&Epg::search_compare, this, _1),
-					boost::bind(&Epg::search_get_title, this, _1),
-					search_mode, search_str, lowercase_search_str, offset,
-					boost::bind(&Epg::search_action, this, _1),
-					busy_indicator);
+			boost::bind(&Epg::search_print, this, _1), boost::bind(
+					&Epg::search_compare, this, _1), boost::bind(
+					&Epg::search_get_title, this, _1), search_mode, search_str,
+			lowercase_search_str, offset, boost::bind(&Epg::search_action,
+					this, _1), busy_indicator);
 
 	search_mutex.leaveMutex();
 	
@@ -1237,8 +1262,6 @@
 			conf->p_input(), string("evdev")))
 		search_top_size -= search_size;
 
-	screen_updater->timer.add(TimeElement("epg", boost::bind(
-			&Epg::check_epg_print, this), boost::bind(&Epg::epg_print, this)));
 }
 
 void Epg::search_touch_action(const vector<EpgEvent *>& events, int pos) {
@@ -1267,7 +1290,7 @@
 }
 
 void Epg::search_print(const vector<EpgEvent *>& events) {
-	int y= BORDER_TOP;
+	int y= border_top;
 	int pos = 0;
 	static int cursor, start, end, i;
 
@@ -1276,19 +1299,19 @@
 	}
 
 	if (display_channel_logo) {
-		logo_x = BORDER_LEFT;
-		channel_x = logo_x + max_logo_size_x + SPACING;
+		logo_x = border_left;
+		channel_x = logo_x + max_logo_size_x + spacing;
 	} else {
 		logo_x = 0;
-		channel_x = BORDER_LEFT;
+		channel_x = border_left;
 		display_channel_name = true;
 	}
 
 	if (display_channel_name == false) { // This only happens when all Channel-Logos are present and display_channel_name is set to false
-		grid_header_x = BORDER_LEFT + max_logo_size_x + SPACING;
+		grid_header_x = border_left + max_logo_size_x + spacing;
 		grid_x = grid_header_x;
 	} else {
-		grid_header_x = int((conf->p_h_res() * 0.25) + SPACING/2);
+		grid_header_x = int((conf->p_h_res() * 0.25) + spacing/2);
 		grid_x = grid_header_x;
 	}
 
@@ -1296,13 +1319,13 @@
 
 	render->current.add(new PObj(themes->epg_background, 0, 0, 0, SCALE_FULL));
 
-	PObj *back = new PFObj(themes->startmenu_epg, BORDER_LEFT, y, header_box_size, header_box_size, 1, true);
+	PObj *back = new PFObj(themes->startmenu_epg, border_left, y, header_box_size, header_box_size, 1, true);
 
 	render->current.add(back);
 
 	if (themes->show_header) {
 		TObj *t = new TObj(dgettext("mms-epg", "EPG"), header_font, 
-								BORDER_LEFT + header_box_size + SPACING,
+								border_left + header_box_size + spacing,
 								y + (header_box_size - header_size.second) / 2,
 								themes->epg_header_font1, themes->epg_header_font2,
 								themes->epg_header_font3, 1);
@@ -1315,22 +1338,28 @@
 
 	y += header_size.second * 0.75;
 
-	grid_header_y 	= BORDER_TOP + header_size.second + SPACING + annotation_size.second;
+	grid_header_y 	= border_top + header_size.second + spacing + annotation_size.second;
 	grid_spacing 	= int(3 * conf->p_v_res() / 405); // for adjustment of vertical spacing on higher resolutions
-	grid_y 			= grid_header_y + normal_size.second + SPACING;
+	grid_y 			= grid_header_y + normal_size.second + spacing;
 
 	grid_header_y 	+= search_size.second;
 	grid_y 			+= search_size.second;
 
-	render->current.add(new RObj(BORDER_LEFT + header_box_size, y, conf->p_h_res() - BORDER_LEFT - BORDER_RIGHT - header_box_size, search_size.second, 100, 100, 100, 215, 2));
+	render->current.add(new RObj(border_left, y, conf->p_h_res() - border_left - border_right, search_size.second,
+			   themes->general_search_rectangle_color1,
+			   themes->general_search_rectangle_color2,
+			   themes->general_search_rectangle_color3,
+			   themes->general_search_rectangle_color4, 2));
 
-	render->current.add(new PFObj(themes->general_search, BORDER_LEFT + header_box_size + SPACING, y + (search_size.second - search_box_size)/2, search_box_size, search_box_size, 3, true));
+	render->current.add(new PFObj(themes->general_search, border_left + spacing, y + (search_size.second - search_box_size)/2, search_box_size, search_box_size, 3, true));
 
-	int max_x = conf->p_h_res() - BORDER_LEFT - BORDER_RIGHT - header_box_size - 2 * SPACING;
+	int max_x = conf->p_h_res() - border_left - border_right - header_box_size - 2 * spacing;
 
 	string sw = search_str;
 
-	string s = dgettext("mms-epg", "Search: ");
+	string s = gettext("Search");
+	s.append(" : ");
+	
 	int x_size = string_format::calculate_string_width(s, search_font);
 
 	string_format::format_to_size(sw, search_font, max_x - x_size, true);
@@ -1338,16 +1367,16 @@
 	int search_text_height = string_format::calculate_string_size(s + sw, search_font).second;
 
 	render->current.add(new TObj(s + sw, search_font, 
-				BORDER_LEFT + header_box_size + search_box_size + 2 * SPACING,
+				border_left + search_box_size + 2 * spacing,
 				y, themes->search_font1, themes->search_font2, themes->search_font3, 3));
-
 	// print_marked_search_letter();
 
-	y += (search_size.second * 2) + SPACING;
+	y += (search_size.second * 2) + spacing;
 
 	y_start = grid_y;
 
-	rows = (conf->p_v_res() - (y + BORDER_BOTTOM + SPACING)) / (grid_size.second + grid_spacing);
+	// rows = (conf->p_v_res() - (y + BORDER_BOTTOM + SPACING)) / (grid_size.second + grid_spacing);
+	rows = (conf->p_v_res() - (y + border_bottom)) / (grid_size.second + grid_spacing);
 
 	if (events.size() > 0) {
 		pos = offset % events.size();
@@ -1372,13 +1401,15 @@
 	}
 	end = start + rows;
 
-	char count_str[255];
+	// char count_str[255];
 	char time_str[30];
 	time_t tmp_time = time(0);
 	
-	sprintf(count_str, "%d/%d", pos + 1, events.size());
+	string counts;
+	
+	counts = string_format::str_printf("%d/%d", pos + 1, events.size());
 	
-	x_size = string_format::calculate_string_width(count_str, normal_font);	
+	x_size = string_format::calculate_string_width(counts, normal_font);	
 
 	int time_pos_from_right = 15;
 
@@ -1386,7 +1417,7 @@
 		time_pos_from_right = 32;
 
 	if (events.size() > 0) {
-		render->current.add(new TObj(count_str, normal_font, conf->p_h_res()-(x_size + time_pos_from_right), BORDER_TOP + (header_box_size - normal_size.second) / 2,
+		render->current.add(new TObj(counts, normal_font, conf->p_h_res()-(x_size + time_pos_from_right), border_top + (header_box_size - normal_size.second) / 2,
 				themes->epg_font1, themes->epg_font2,
 				themes->epg_font3, 2));
 	}
@@ -1411,30 +1442,30 @@
 						themes->epg_timer_marked1, themes->epg_timer_marked2, themes->epg_timer_marked3, 3));
 		
 				string_format::format_to_size(events[i + start]->title, grid_font, conf->p_h_res() - (grid_x + time_size
-						+ SPACING) - BORDER_RIGHT, true);
+						+ spacing) - border_right, true);
 		
-				render->current.add(new TObj(events[i + start]->title, grid_font, grid_x + time_size + SPACING, y + (i * (grid_size.second + grid_spacing)),
+				render->current.add(new TObj(events[i + start]->title, grid_font, grid_x + time_size + spacing, y + (i * (grid_size.second + grid_spacing)),
 						themes->epg_timer_marked1, themes->epg_timer_marked2, themes->epg_timer_marked3, 3));
 			} else {
 				render->current.add(new TObj(time, grid_font, grid_x, y + (i * (grid_size.second + grid_spacing)),
 						themes->epg_font1, themes->epg_font2, themes->epg_font3, 3));
 		
 				string_format::format_to_size(events[i + start]->title, grid_font, conf->p_h_res() - (grid_x + time_size
-						+ SPACING) - BORDER_RIGHT, true);
+						+ spacing) - border_right, true);
 		
-				render->current.add(new TObj(events[i + start]->title, grid_font, grid_x + time_size + SPACING, y + (i * (grid_size.second + grid_spacing)),
+				render->current.add(new TObj(events[i + start]->title, grid_font, grid_x + time_size + spacing, y + (i * (grid_size.second + grid_spacing)),
 						themes->epg_font1, themes->epg_font2, themes->epg_font3, 3));
 			}
 			
 		    S_Touch::get_instance()->register_area(
 		    		TouchArea( 
-		    				rect(grid_x, y + (i * (grid_size.second + grid_spacing)), conf->p_h_res() - (grid_x + BORDER_RIGHT), grid_size.second + grid_spacing),
+		    				rect(grid_x, y + (i * (grid_size.second + grid_spacing)), conf->p_h_res() - (grid_x + border_right), grid_size.second + grid_spacing),
 		    					3,
 		  						boost::bind(&Epg::search_touch_action, this, events, i + start)
 		    				)
 		  				);
 		}
-		render->current.add(new PFObj(themes->general_marked, logo_x - 10, y + cursor * (grid_size.second + grid_spacing) - (grid_spacing / 2), conf->p_h_res() - BORDER_RIGHT - logo_x + 20, grid_size.second + grid_spacing, 2, true));
+		render->current.add(new PFObj(themes->general_marked, logo_x - 10, y + cursor * (grid_size.second + grid_spacing) - (grid_spacing / 2), conf->p_h_res() - border_right - logo_x + 20, grid_size.second + grid_spacing, 2, true));
 	}
 	render->draw_and_release("epg-search");
 }
@@ -1450,20 +1481,21 @@
 
 		render->wait_and_aquire();
 
-		string header_font = graphics::resolution_dependant_font_wrapper(22, conf);
-		std::pair<int, int> header_size = string_format::calculate_string_size("abcltuwHPMjJg", header_font);
+		// string header_font = graphics::resolution_dependant_font_wrapper(22, conf);
+		// std::pair<int, int> header_size = string_format::calculate_string_size("abcltuwHPMjJg", search_font);
+		// std::pair<int, int> search_select_size = string_format::calculate_string_size("abcltuwHPMjJg", search_font);
 
-		int y_offset = static_cast<int>(header_size.second * 0.75) + search_top_size;
+		int y_offset = static_cast<int>(search_size.second + search_top_size);
 
 		if (overlay_search.elements.size() > 0)
 			overlay_search.partial_cleanup();
 
 		int marked_thickness = 28;
-		int marked_height = 38;
+		int marked_height = search_select_size.second;
 		int magic_offset = -8;
 		if (conf->p_h_res() <= 800) {
 			marked_thickness = 22;
-			marked_height = 30;
+		// 	marked_height = 30;
 			magic_offset = -10;
 		}
 
@@ -1476,10 +1508,12 @@
 		string keys = global->get_valid_keys();
 		string spaced_keys = "";
 
-		int start_pos = 85;
+		int start_pos = border_left;
 
+/*		
 		if (conf->p_h_res() <= 800)
 			start_pos = 15;
+*/
 
 		for (int i = 0; i < keys.size(); ++i) {
 			if (keys[i] != '|')
@@ -1489,18 +1523,18 @@
 
 				spaced_keys = spaced_keys.substr(0, spaced_keys.size()-1);
 
-				string font = "Vera/22";
-
+			//	string font = "Vera/18";
+/*
 				if (conf->p_h_res() <= 800)
 					font = "Vera/16";
-
+*/
 				int letters_width = string_format::calculate_string_width(
-						spaced_keys, font);
+						spaced_keys, search_select_font);
 
 				overlay_search.add(new RObj(start_pos-4, y_offset+5, letters_width, marked_height,
 						20, 30, 20, 255, 3));
 
-				overlay_search.add(new TObj(spaced_keys, font,
+				overlay_search.add(new TObj(spaced_keys, search_select_font,
 						start_pos, y_offset, themes->audio_font1,
 						themes->audio_font2, themes->audio_font3, 5));
 
@@ -1665,7 +1699,9 @@
     } else if (input.command == "action") {
 			refresh_mutex.enterMutex();
 
+			screen_updater->timer.deactivate("epg");
       print_description();
+			screen_updater->timer.activate("epg");
 
 			refresh_mutex.leaveMutex();
 
@@ -1682,7 +1718,8 @@
 			vector<EpgEvent *>::iterator old_program_iter = program_iter;
 			vector<EpgEvent *>::iterator piter;
 
-			for (piter = sel_channel->program.begin(); piter != sel_channel->program.end(); ++piter) {
+			for (piter = sel_channel->program.begin(); piter
+					!= sel_channel->program.end(); ++piter) {
 				if ((*piter)->start > sel_time) {
 					if (piter != sel_channel->program.begin())
 	    --piter;
@@ -1698,10 +1735,12 @@
 
       program_iter = piter;
 
-			if (program_iter == sel_channel->program.end() && program_iter != sel_channel->program.begin()) {
+			if (program_iter == sel_channel->program.end() && program_iter
+					!= sel_channel->program.begin()) {
 	--program_iter;
 			}
-			if (program_iter == sel_channel->program.end() && program_iter != sel_channel->program.begin()) {
+			if (program_iter == sel_channel->program.end() && program_iter
+					!= sel_channel->program.begin()) {
 	--program_iter;
       }
 
@@ -1713,6 +1752,7 @@
 			refresh_mutex.leaveMutex();
 
 		} else if (input.command == "second_action") {
+			screen_updater->timer.deactivate("epg");
 			ExtraMenu em;
 
 			em.add_item(ExtraMenuItem(dgettext("mms-epg", "Print description"),
@@ -1724,16 +1764,17 @@
 							&Epg::read_db, this)));
 			if (use_svdrp) {
 				em.add_item(ExtraMenuItem(dgettext("mms-epg", "Toggle Timer"),
-						input_master->find_shortcut("toggle_timer"), boost::bind(
-								&Epg::toggle_timer, this)));
+						input_master->find_shortcut("toggle_timer"),
+						boost::bind( &Epg::toggle_timer, this)));
 
-				em.add_item(ExtraMenuItem(dgettext("mms-epg", "Switch to Channel"),
-						input_master->find_shortcut("switch_to_channel"), boost::bind(
-								&Epg::switch_to_channel, this)));
+				em.add_item(ExtraMenuItem(dgettext("mms-epg",
+						"Switch to Channel"),
+						input_master->find_shortcut("switch_to_channel"),
+						boost::bind( &Epg::switch_to_channel, this)));
 				
 			}
 
-			em.add_item(ExtraMenuItem(dgettext("mms-epg", "Search"),
+			em.add_item(ExtraMenuItem(gettext("Search"),
 					input_master->find_shortcut("search"), boost::bind(
 							&Epg::search_func, this)));
 			
@@ -1746,12 +1787,18 @@
 	  em.add_persistent_item(item);
 
 	em.mainloop();
+			screen_updater->timer.activate("epg");
 	    } else if (input.command == "search") {
+			screen_updater->timer.deactivate("epg");
 	    	search_func();
+			screen_updater->timer.activate("epg");
 		} else if (input.command == "toggle_timer") {
 			refresh_mutex.enterMutex();
+			screen_updater->timer.deactivate("epg");
 
 			toggle_timer(*program_iter);
+			screen_updater->timer.activate("epg");
+
 			refresh_mutex.leaveMutex();
 
 		} else if (input.command == "reload") {
@@ -1777,11 +1824,11 @@
 
 void Epg::print_timelines(double diff) {
 	if (diff > 0 && diff < timeslots)
-		render->current.add(new RObj(int(grid_x + diff * timeslot_interval * SECONDS_PER_MINUTE / scale_factor), grid_y - SPACING, 2, rows * (grid_size.second + grid_spacing) + SPACING * 2,
+		render->current.add(new RObj(int(grid_x + diff * timeslot_interval * SECONDS_PER_MINUTE / scale_factor), grid_y - spacing, 2, rows * (grid_size.second + grid_spacing) + spacing * 2,
 				themes->epg_time_bar1, themes->epg_time_bar2,
 				themes->epg_time_bar3, themes->epg_time_bar4, 1));
 
-	render->current.add(new RObj(grid_x, grid_y - SPACING, 2, rows * (grid_size.second + grid_spacing) + SPACING * 2,
+	render->current.add(new RObj(grid_x, grid_y - spacing, 2, rows * (grid_size.second + grid_spacing) + spacing * 2,
 			themes->epg_bar1, themes->epg_bar2,
 			themes->epg_bar3, themes->epg_bar4, 1));
 
@@ -1790,12 +1837,13 @@
 		char time_str[30];
 		strftime(time_str, 30, "%H:%M", localtime(&tmp_time));
 		
-		std::pair<int, int> time_size = string_format::calculate_string_size(time_str, grid_font);
+		std::pair<int, int> time_size = string_format::calculate_string_size(
+				time_str, grid_font);
 		render->current.add(new TObj(time_str, grid_font,
 				static_cast<int>(grid_x - (time_size.first / 2) + (x * timeslot_interval * SECONDS_PER_MINUTE)/scale_factor), grid_header_y ,
 				themes->epg_font1, themes->epg_font2,
 				themes->epg_font3, 2));
-		render->current.add(new RObj(static_cast<int>(grid_x + ((x+1) * timeslot_interval * SECONDS_PER_MINUTE) / scale_factor), grid_y - SPACING, 2, rows * (grid_size.second + grid_spacing) + SPACING * 2,
+		render->current.add(new RObj(static_cast<int>(grid_x + ((x+1) * timeslot_interval * SECONDS_PER_MINUTE) / scale_factor), grid_y - spacing, 2, rows * (grid_size.second + grid_spacing) + spacing * 2,
 				themes->epg_bar1, themes->epg_bar2, themes->epg_bar3,
 				themes->epg_bar4, 1));
 	}
@@ -1806,14 +1854,16 @@
 	// printf("x = %d, y = %d, %s, %s \n", logo_x, y, cur_chan->display_name.c_str(), cur_chan->logo.c_str());
 	if (display_channel_logo) {
 		if (!cur_chan->logo.empty()) {
-			render->create_scaled_image_wrapper_upscaled(cur_chan->logo, max_logo_size_x, grid_size.second);
+			render->create_scaled_image_wrapper_upscaled(cur_chan->logo,
+					max_logo_size_x, grid_size.second);
 		
 			render->current.add(new PFObj(cur_chan->logo, logo_x, y,  max_logo_size_x, grid_size.second, false, 3));
 		}
 	}
 	if (display_channel_name) {
 		string channel_name = cur_chan->display_name;
-		string_format::format_to_size(channel_name, grid_font, grid_x - channel_x - SPACING/2, false);
+		string_format::format_to_size(channel_name, grid_font, grid_x
+				- channel_x - spacing/2, false);
 		render->current.add(new TObj(channel_name, grid_font, channel_x, y,
 				themes->epg_font1, themes->epg_font2,
 				themes->epg_font3, 3));
@@ -1824,14 +1873,16 @@
 void Epg::print_channel(int y, std::vector<Channel>::iterator cur_chan) {
 	if (display_channel_logo) {
 		if (!cur_chan->logo.empty()) {
-			render->create_scaled_image_wrapper_upscaled(cur_chan->logo, max_logo_size_x, grid_size.second);
+			render->create_scaled_image_wrapper_upscaled(cur_chan->logo,
+					max_logo_size_x, grid_size.second);
 		
 			render->current.add(new PFObj(cur_chan->logo, logo_x, grid_y + y * (grid_size.second + grid_spacing),  max_logo_size_x, grid_size.second, false, 3));
 		}
 	}
 	if (display_channel_name) {
 		string channel_name = cur_chan->display_name;
-		string_format::format_to_size(channel_name, grid_font, grid_x - channel_x - SPACING/2, false);
+		string_format::format_to_size(channel_name, grid_font, grid_x
+				- channel_x - spacing/2, false);
 		render->current.add(new TObj(channel_name, grid_font, channel_x, grid_y + y * (grid_size.second + grid_spacing) ,
 				themes->epg_font1, themes->epg_font2,
 				themes->epg_font3, 3));
@@ -1839,36 +1890,39 @@
 }
 
 void Epg::print() {
-	int y = BORDER_TOP;
+	int y = border_top;
 
 	if (!all_logos) {
 		display_channel_name = true;
 	}
 	
 	if (display_channel_logo) {
-		logo_x = BORDER_LEFT;
-		channel_x = logo_x + max_logo_size_x + SPACING;
+		logo_x = border_left;
+		channel_x = logo_x + max_logo_size_x + spacing;
 	} else {
 		logo_x = 0;
-		channel_x = BORDER_LEFT;
+		channel_x = border_left;
 		display_channel_name = true;
 	}
 
 	if (display_channel_name == false) { // This only happens when all Channel-Logos are present and display_channel_name is set to false
-		grid_header_x = BORDER_LEFT + max_logo_size_x + SPACING;
+		grid_header_x = border_left + max_logo_size_x + spacing;
 		grid_x = grid_header_x;
 	} else {
-		grid_header_x = int((conf->p_h_res() * 0.25) + SPACING/2);
+		grid_header_x = int((conf->p_h_res() * 0.25) + spacing/2);
 		grid_x		  = grid_header_x;
 	}
 	
-	scale_factor = (timeslot_interval * SECONDS_PER_MINUTE * timeslots) / (double(conf->p_h_res() - grid_x - BORDER_RIGHT));
+	scale_factor = (timeslot_interval * SECONDS_PER_MINUTE * timeslots)
+			/ (double(conf->p_h_res() - grid_x - border_right));
 	
   render->prepare_new_image();
 
   render->current.add(new PObj(themes->epg_background, 0, 0, 0, SCALE_FULL));
 
-	PObj *back = new PFObj(themes->startmenu_epg, BORDER_LEFT, y, header_box_size, header_box_size, 1, true);
+	PObj
+			*back =
+					new PFObj(themes->startmenu_epg, border_left, y, header_box_size, header_box_size, 1, true);
 
   render->current.add(back);
 
@@ -1877,7 +1931,9 @@
 					&Epg::exit, this)));
 
   if (themes->show_header) {
-		TObj *t = new TObj(dgettext("mms-epg", "EPG"), header_font, BORDER_LEFT + header_box_size + SPACING, y + (header_box_size - header_size.second) / 2,
+		TObj
+				*t =
+						new TObj(dgettext("mms-epg", "EPG"), header_font, border_left + header_box_size + spacing, y + (header_box_size - header_size.second) / 2,
 		       themes->epg_header_font1, themes->epg_header_font2,
 		       themes->epg_header_font3, 1);
 
@@ -1902,16 +1958,17 @@
 			       themes->epg_font1, themes->epg_font2,
 			       themes->epg_font3, 2));
 
-	y += header_size.second + SPACING;
-	
+	y += header_size.second + spacing;
 
-	grid_header_y = BORDER_TOP + header_size.second + SPACING + annotation_size.second;
+	grid_header_y = border_top + header_size.second + spacing
+			+ annotation_size.second;
 	grid_spacing  = int(3 * conf->p_v_res() / 405); // for adjustment of vertical spacing on higher resolutions
-	grid_y		  = grid_header_y + normal_size.second + SPACING;
+	grid_y = grid_header_y + normal_size.second + spacing;
 
 	y_start = grid_y;
 
-	rows = (conf->p_v_res() - (grid_y + BORDER_BOTTOM + normal_size.second + 2 * SPACING)) / (grid_size.second + grid_spacing);
+	rows = (conf->p_v_res() - (grid_y + border_bottom + normal_size.second + 2
+			* spacing)) / (grid_size.second + grid_spacing);
 	
 	strftime(time_str, 30, "%x - %R", localtime(&cur_time));
 
@@ -1926,11 +1982,13 @@
 
   double diff = 0;
 	diff += (temp_time-cur_time)/(timeslot_interval*SECONDS_PER_MINUTE);
-	diff += ((temp_time-cur_time)/SECONDS_PER_MINUTE-diff*timeslot_interval)/timeslot_interval;
+	diff += ((temp_time-cur_time)/SECONDS_PER_MINUTE-diff*timeslot_interval)
+			/timeslot_interval;
 
   print_timelines(diff);
 
-	if ((grid_x + timeslots * timeslot_interval * SECONDS_PER_MINUTE / scale_factor + BORDER_RIGHT) < conf->p_h_res()) {
+	if ((grid_x + timeslots * timeslot_interval * SECONDS_PER_MINUTE
+			/ scale_factor + border_right) < conf->p_h_res()) {
 		tmp_time = cur_time + timeslots*timeslot_interval*SECONDS_PER_MINUTE;
     strftime(time_str, 30, "%H:%M", localtime(&tmp_time));
 		render->current.add(new TObj(time_str, grid_font, 
@@ -1989,12 +2047,12 @@
 						string f = footer.str() + "   " + program->title;
 
 	    int f_size = f.size();
-						string_format::format_to_size(f, grid_font, conf->p_h_res() - BORDER_LEFT - BORDER_RIGHT, false);
+						string_format::format_to_size(f, grid_font, conf->p_h_res() - border_left - border_right, false);
 
 	    if (f.size() != f_size)
 	      f += "...";
 
-						render->current.add(new TObj(f, grid_font, BORDER_LEFT, grid_y + rows * (grid_size.second + grid_spacing) + (2 * SPACING), themes->epg_font1,
+						render->current.add(new TObj(f, grid_font, border_left, grid_y + rows * (grid_size.second + grid_spacing) + (2 * spacing), themes->epg_font1,
 					 themes->epg_font2, themes->epg_font3, 4));
 
 	    S_Touch::get_instance()->register_area(TouchArea(rect(r->x, r->y, r->w, r->h), r->layer,
@@ -2043,7 +2101,8 @@
 	if (conf->p_idle_time() != 0) {
 		// update the idle timer
 		int idle = time(0)-conf->p_last_key();
-		if (idle > SECONDS_PER_MINUTE*conf->p_idle_time() && ((*program_iter)->stop > time(0) && (*program_iter)->start < (time(0) + timeslots*timeslot_interval*SECONDS_PER_MINUTE)))
+		if (idle > SECONDS_PER_MINUTE*conf->p_idle_time() && ((*program_iter)->stop > time(0) && (*program_iter)->start < (time(0) + timeslots*timeslot_interval
+				*SECONDS_PER_MINUTE)))
 			update_time();
 	}
 
@@ -2062,13 +2120,11 @@
 	print();
 }
 
-int Epg::check_epg_print()
-{
+int Epg::check_epg_print() {
 	return SECONDS_PER_MINUTE*1000; // ms
 }
 
-void Epg::update_svdrp_data()
-{
+void Epg::update_svdrp_data() {
 	 if (svdrp && !update_running) {
 		 update_running = true;
 		 DialogWaitPrint pdialog(dgettext("mms-epg", "Rereading TV Data"), 1000);
@@ -2076,16 +2132,15 @@
 	 }
 }
 
-void Epg::update_epg_datafile()
-{
-	 if (!epg_conf->p_epg_update_script().empty()
-	       && file_exists(epg_conf->p_epg_update_script())
+void Epg::update_epg_datafile() {
+	if (!epg_conf->p_epg_update_script().empty() && file_exists(epg_conf->p_epg_update_script())
 	       && !update_running) {
 		 update_running = true;
 	     epg_updater->start();
 	 } else {
 	     epg_script_found = false;
-	     print_warning(dgettext("mms-epg", "Could not find epg update program"), "EPG");
+		print_warning(dgettext("mms-epg", "Could not find epg update program"),
+				"EPG");
 	 }
 }
 
@@ -2100,8 +2155,7 @@
     printf("%s - Timestamp (%s)\n", timestr, message.c_str());		
 }
 
-bool Epg::read_xml_file(vector<Channel> *chan)
-{
+bool Epg::read_xml_file(vector<Channel> *chan) {
     std::vector<Channel>::iterator ch;
 	std::vector<EpgEvent *> new_program, old_program;
 	std::vector<EpgEvent *>::iterator e;
@@ -2132,8 +2186,8 @@
 
         int channel_number = 1;
 	
-		for (element = root_element->FirstChildElement("channel"); element != 0;
-			element = element->NextSiblingElement("channel")) {
+		for (element = root_element->FirstChildElement("channel"); element != 0; element
+				= element->NextSiblingElement("channel")) {
 			Channel temp = XMLChannel(channel_number++, element);
 			chan->push_back(temp);
 		}
@@ -2141,7 +2195,9 @@
 		for (ch = channels.begin(); ch != channels.end(); ch++) {
 			if (ch->program.empty()) {
 				time_t now = time(NULL);
-				XmlEpgEvent *ev = new XmlEpgEvent(&(*ch), now, 7 * 24*60*SECONDS_PER_MINUTE, dgettext("mms-epg", "No Epg available"));
+				XmlEpgEvent
+						*ev =
+								new XmlEpgEvent(&(*ch), now, 7 * 24*60*SECONDS_PER_MINUTE, dgettext("mms-epg", "No Epg available"));
 				ch->program.push_back(ev);
 			}
 		}
@@ -2180,9 +2236,11 @@
 	search_mutex.enterMutex();
 	all_events.clear();
 	
-	for (element = root_element->FirstChildElement("programme"); element != 0; element = element->NextSiblingElement("programme")) {
+	for (element = root_element->FirstChildElement("programme"); element != 0; element
+			= element->NextSiblingElement("programme")) {
 		std::string channel_id = element->Attribute("channel");
-		for (ch = channels.begin(); (ch != channels.end() && channel_id != ch->id); ch++) {
+		for (ch = channels.begin(); (ch != channels.end() && channel_id
+				!= ch->id); ch++) {
 		}
 		
 		if (ch != channels.end()) { // Found matching Channel !!!
@@ -2201,7 +2259,8 @@
 				new_program.clear();
 			}
 
-			for (e = new_program.begin(); e != new_program.end() && p->start > (*e)->start; e++) {
+			for (e = new_program.begin(); e != new_program.end() && p->start
+					> (*e)->start; e++) {
 			}
 			if (e == new_program.end()) {
 				if (new_program.size() > 0) {
@@ -2236,8 +2295,9 @@
 				cur_time = time(0);
 				sel_time = cur_time;
 			
-				for (program_iter = sel_channel->program.begin(), program_iter_end
-							= sel_channel->program.end(); program_iter != program_iter_end; ++program_iter)
+				for (program_iter = sel_channel->program.begin(),
+						program_iter_end = sel_channel->program.end(); program_iter
+						!= program_iter_end; ++program_iter)
 					if ((*program_iter)->stop >= sel_time)
 	break;
 
@@ -2279,15 +2338,19 @@
 	db.execute("BEGIN TRANSACTION");
 	
 	for (ch = channels.begin(); ch != channels.end(); ch++) {
-		char *tmp = sqlite3_mprintf("delete from Channel where tvid = '%q'",  ch->id.c_str());
+		char *tmp = sqlite3_mprintf("delete from Channel where tvid = '%q'",
+				ch->id.c_str());
 		db.execute(tmp);
 		sqlite3_free(tmp);
 		
-		tmp = sqlite3_mprintf("delete from Program where cid = '%q'", ch->id.c_str());
+		tmp = sqlite3_mprintf("delete from Program where cid = '%q'",
+				ch->id.c_str());
 		db.execute(tmp);
 		sqlite3_free(tmp);
 		
-		tmp = sqlite3_mprintf("INSERT INTO Channel (id, number, tvid, name) VALUES (NULL, %d, '%q', '%q')",
+		tmp
+				= sqlite3_mprintf(
+						"INSERT INTO Channel (id, number, tvid, name) VALUES (NULL, %d, '%q', '%q')",
 			  ch->number, ch->id.c_str(), ch->display_name.c_str());
 		db.execute(tmp);
 		sqlite3_free(tmp);
@@ -2298,11 +2361,14 @@
 			x = (XmlEpgEvent *)(*e);	
 			// FIXME: determine if movie, episode or ordinary program
 
-			char *insert = sqlite3_mprintf("INSERT INTO Program (id, cid, title, ltitle, description, ldescription, start_time, end_time, duration) VALUES (NULL, '%q', '%q', '%q', '%q', '%q', %ld, %ld, %ld)",
+			char
+					*insert =
+							sqlite3_mprintf(
+									"INSERT INTO Program (id, cid, title, ltitle, description, ldescription, start_time, end_time, duration) VALUES (NULL, '%q', '%q', '%q', '%q', '%q', %ld, %ld, %ld)",
 					  ch->id.c_str(), x->title.c_str(),
-					  string_format::lowercase(x->title).c_str(),
-					  x->desc.c_str(), string_format::lowercase(x->desc).c_str(),
-					  x->start, x->stop, x->duration);
+									string_format::lowercase(x->title).c_str(), x->desc.c_str(),
+									string_format::lowercase(x->desc).c_str(), x->start,
+									x->stop, x->duration);
 	
 			db.execute(insert);
 			sqlite3_free(insert);
@@ -2344,7 +2410,9 @@
 		for (ch = channels.begin(); ch != channels.end(); ch++) {
 			if (ch->program.empty()) {
 				time_t now  = time(NULL);
-				SvdrpEpgEvent *ev = new SvdrpEpgEvent(&(*ch), 1, ch->id, now, 7 * 24*60*SECONDS_PER_MINUTE, 0, 0);
+				SvdrpEpgEvent
+						*ev =
+								new SvdrpEpgEvent(&(*ch), 1, ch->id, now, 7 * 24*60*SECONDS_PER_MINUTE, 0, 0);
 				ev->title = dgettext("mms-epg", "No Epg available");
 				
 				ch->program.push_back(ev);
@@ -2385,8 +2453,9 @@
 				cur_time = time(0);
 				sel_time = cur_time;
 		
-				for (program_iter = sel_channel->program.begin(), program_iter_end
-						= sel_channel->program.end(); program_iter != program_iter_end; ++program_iter)
+				for (program_iter = sel_channel->program.begin(),
+						program_iter_end = sel_channel->program.end(); program_iter
+						!= program_iter_end; ++program_iter)
 					if ((*program_iter)->stop >= sel_time)
 						break;
 
@@ -2440,20 +2509,21 @@
 	for (ch = channels.begin(); ch != channels.end(); ch++) {
 		SvdrpChannel *sc = (SvdrpChannel *)&(*ch);
 		
-		char *tmp = sqlite3_mprintf("delete from Channel where tvid = '%q'",  sc->id.c_str());
+		char *tmp = sqlite3_mprintf("delete from Channel where tvid = '%q'",
+				sc->id.c_str());
 		db.execute(tmp);
 		sqlite3_free(tmp);
 
-		tmp = sqlite3_mprintf("delete from Program where cid = '%q'", sc->id.c_str());
+		tmp = sqlite3_mprintf("delete from Program where cid = '%q'",
+				sc->id.c_str());
 
 		db.execute(tmp);
 		sqlite3_free(tmp);
 
-		tmp = sqlite3_mprintf("INSERT INTO Channel (id, number, tvid, name) VALUES (NULL, %d, '%q', '%q')", 
-			  sc->number, 
-			  sc->id.c_str(), 
-			  sc->display_name.c_str()
-			  );
+		tmp
+				= sqlite3_mprintf(
+						"INSERT INTO Channel (id, number, tvid, name) VALUES (NULL, %d, '%q', '%q')",
+						sc->number, sc->id.c_str(), sc->display_name.c_str() );
 
 		db.execute(tmp);
 		sqlite3_free(tmp);
@@ -2463,11 +2533,14 @@
 		
 		for (ev = ch->program.begin(); ev != ch->program.end(); ev++) {
 			p = (SvdrpEpgEvent *)(*ev);		
-			char *insert = sqlite3_mprintf("INSERT INTO Program (id, cid, title, ltitle, description, ldescription, start_time, end_time, duration, vps) VALUES (NULL, '%q', '%q', '%q', '%q', '%q', %ld, %ld, %ld, %ld)",
+			char
+					*insert =
+							sqlite3_mprintf(
+									"INSERT INTO Program (id, cid, title, ltitle, description, ldescription, start_time, end_time, duration, vps) VALUES (NULL, '%q', '%q', '%q', '%q', '%q', %ld, %ld, %ld, %ld)",
 					  ch->id.c_str(), p->title.c_str(),
-					  string_format::lowercase(p->title).c_str(),
-					  p->desc.c_str(), string_format::lowercase(p->desc).c_str(),
-					  p->start, p->stop, p->duration, p->Vps());
+									string_format::lowercase(p->title).c_str(), p->desc.c_str(),
+									string_format::lowercase(p->desc).c_str(), p->start,
+									p->stop, p->duration, p->Vps());
 	
 			db.execute(insert);
 			sqlite3_free(insert);
@@ -2490,17 +2563,21 @@
   if (epg->use_svdrp) {
 	  if (epg->svdrp) {
 		  if (epg->GetSvdrpData()) {
+				if (epg->ende != true) {
 			  Print pdialog(Print::SCREEN);
 				pdialog.add_line(dgettext("mms-epg",
 						"EPG TV listings reloaded from Svdrp-Host"));
 			  pdialog.print();
+				}
 			  epg->reload_needed = false;
 		  } else {
+				if (epg->ende != true) {
 			  Print pdialog(Print::SCREEN);
 				pdialog.add_line(dgettext("mms-epg",
 						"EPG TV listings couldn't be loaded from Svdrp-Host"));
 			  pdialog.add_line("");
 			  pdialog.print();	  
+				}
 			  epg->reload_needed = true;
 		  }
 		  epg->update_running = false;
@@ -2508,12 +2585,14 @@
   } else {
   run::external_program(epg_conf->p_epg_update_script());
 
+		if (epg->ende != true) {
   Print pdialog(Print::SCREEN);
   pdialog.add_line(dgettext("mms-epg", "EPG TV listings file reloaded"));
   pdialog.add_line("");
   pdialog.add_line(dgettext("mms-epg", "The new data file will be used"));
   pdialog.add_line(dgettext("mms-epg", "the next time you enter EPG"));
   pdialog.print();
+		}
 
   epg->reload_needed = false;
   epg->update_running = false;
@@ -2536,9 +2615,8 @@
 				return 0;
 			}
 		}
-		return (epg_conf->p_interval() >= 5) ? (epg_conf->p_interval()
-					* 60 * 1000)
-					: (5 * 60 * 1000); // ms
+		return (epg_conf->p_interval() >= 5) ? (epg_conf->p_interval() * 60
+				* 1000) : (5 * 60 * 1000); // ms
 	} else
 		return 24*60*60*1000; // just wait a long time
 }
@@ -2551,9 +2629,8 @@
 			lastrefresh = now;
       return 0; // update now
   }
-		return (epg_conf->p_interval() >= 5) ? (epg_conf->p_interval()
-				* 60 * 1000)
-				: (5 * 60 * 1000); // ms
+		return (epg_conf->p_interval() >= 5) ? (epg_conf->p_interval() * 60
+				* 1000) : (5 * 60 * 1000); // ms
 	} else {
 		return 24*60*60*1000; // Wait a day
 }
@@ -2563,18 +2640,14 @@
   ScreenUpdater *screen_updater = S_ScreenUpdater::get_instance();
 
 	if (use_svdrp) {
-		screen_updater->timer.add(TimeElement("epg_data_update",
-				boost::bind(&Epg::check_svdrp_data, this),
-				boost::bind(&Epg::update_svdrp_data, this)));
-	} else {
-		screen_updater->timer.add(TimeElement("epg_data_update", 
-				boost::bind(&Epg::check_epg_datafile, this),
-				boost::bind(&Epg::update_epg_datafile, this)));
-/*		
-		S_Search::get_instance()->register_module(SearchModule(dgettext("mms-epg", "EPG"),
-				boost::bind(&Epg::gen_search_list, this, _1),
-							 boost::bind(&Epg::reenter, this, _1)));
-*/
+		screen_updater->timer.add(TimeElement("epg_data_update", boost::bind(
+				&Epg::check_svdrp_data, this), boost::bind(
+				&Epg::update_svdrp_data, this)));
+	} else {
+		screen_updater->timer.add(TimeElement("epg_data_update", boost::bind(
+				&Epg::check_epg_datafile, this), boost::bind(
+				&Epg::update_epg_datafile, this)));
+
 }
 }
 
@@ -2594,6 +2666,8 @@
 
   SQLQuery *q = db.query("Program", ("SELECT cid, start_time, end_time FROM %t WHERE id='" + conv::itos(db_id) + "'").c_str());
 
+	db_mutex.leaveMutex();
+
   if (q && q->numberOfTuples() > 0) {
 
     SQLRow &row = (*q)[0];
@@ -2609,8 +2683,7 @@
       }
 
 		for (program_iter = sel_channel->program.begin(), program_iter_end
-				= sel_channel->program.end(); program_iter
-				!= program_iter_end; ++program_iter)
+				= sel_channel->program.end(); program_iter != program_iter_end; ++program_iter)
 			if ((*program_iter)->start == start)
 	break;
 
@@ -2637,5 +2710,4 @@
 
   delete q;
 
-  db_mutex.leaveMutex();
 }
diff -NaurwB -X diffexclude mms-1.1.0-bzr-head/plugins/feature/epg/epg.hpp mms-1.1.0-bzr-head-fixepg/plugins/feature/epg/epg.hpp
--- mms-1.1.0-bzr-head/plugins/feature/epg/epg.hpp	2008-09-13 06:53:50.000000000 +0200
+++ mms-1.1.0-bzr-head-fixepg/plugins/feature/epg/epg.hpp	2008-09-24 19:43:11.000000000 +0200
@@ -13,12 +13,19 @@
 
 #define DB_VERSION 4
 
-
+/*
 #define BORDER_TOP 		10
 #define BORDER_BOTTOM 	93
 #define BORDER_LEFT		25
 #define BORDER_RIGHT	25
 #define SPACING			10
+*/
+
+#define BORDER_TOP 		(epg->border_top)
+#define BORDER_BOTTOM 	(epg->border_bottom)
+#define BORDER_LEFT		(epg->border_left)
+#define BORDER_RIGHT	(epg->border_right)
+#define SPACING			(epg->spacing)
 
 #define SECONDS_PER_MINUTE 60
 
@@ -267,6 +274,7 @@
 		std::pair<int, int> grid_size;			// Size of Grid-Font
 		std::pair<int, int> channel_size;		// Size of Channel-Text
 		std::pair<int, int> search_size;		// Size of Search-Text
+		std::pair<int, int> search_select_size; // Size for Letters below Search-Input
 		
 		int header_box_size;
 		int search_box_size;
@@ -280,11 +288,16 @@
 		int grid_y;
 		int grid_spacing;
 
+		int border_top, border_bottom, border_left, border_right;
+		int spacing;
+
 		int interval;
 		
 		int timeslot_interval;
 		
 		int search_position;
+		
+		bool ende;
 };
 
 #endif
diff -NaurwB -X diffexclude mms-1.1.0-bzr-head/plugins/feature/epg/svdrp.cpp mms-1.1.0-bzr-head-fixepg/plugins/feature/epg/svdrp.cpp
--- mms-1.1.0-bzr-head/plugins/feature/epg/svdrp.cpp	2008-09-13 06:53:50.000000000 +0200
+++ mms-1.1.0-bzr-head-fixepg/plugins/feature/epg/svdrp.cpp	2008-09-25 19:28:33.000000000 +0200
@@ -234,8 +234,7 @@
 	int hour;
 	int min;
 
-	sprintf(b, "LSTT\n");
-	cmd.assign(b);
+	cmd = string_format::str_printf("LSTT\n");
 	
 	if (send(cmd)) {
 		do {
@@ -249,6 +248,11 @@
 				break;
 			}
 
+
+			if (convert) {
+				svdrl = string_format::convert_locale(svdrl, locale, "UTF-8");
+			}
+			
 			int fields = sscanf(svdrl.c_str(),"%d %d :%d :%a[^:]:%a[^:]:%a[^:]:%d :%d:%a[^:]:%a[^\n^\r]",
 		    		&timer,
 		    		&flags,
@@ -261,10 +265,20 @@
 		    		&filebuf,
 		    		&infobuf);
 
+			if (fields < 9) {
+				return false;
+			}
+
 		    days.assign(daysbuf);
 		    
 		    filename.assign(filebuf);
 
+		    if (fields >  9) {
+		    	info.assign(infobuf);
+		    } else {
+		    	info.assign("");
+		    }
+
 		    // Patch "|" in Filename and Info - they stand for ":"
 		    int colon = 0;
 		    
@@ -318,6 +332,11 @@
 	        if (ti) {
 	        	_timers->push_back(*ti);
 	        }
+	        free(daysbuf);
+	        free(startbuf);
+	        free(stopbuf);
+	        free(filebuf);
+	        free(infobuf);
 		} while (! last);
 	}
 	if (!result) {
@@ -353,12 +372,15 @@
 	int hour;
 	int min;
 	
-	sprintf(b, "LSTT %d\n", _t);
-	cmd.assign(b);
+	cmd = string_format::str_printf("LSTT %d\n", _t);
 	
 	if (send(cmd)) {
 		if (ProcessResult(svdrl, &last)) {
 
+			if (convert) {
+				svdrl = string_format::convert_locale(svdrl, locale, "UTF-8");
+			}
+			
 		    int fields = sscanf(svdrl.c_str(),"%d %d :%d :%a[^:]:%a[^:]:%a[^:]:%d :%d:%a[^:]:%a[^\n^\r]",
 		    		&timer,
 		    		&flags,
@@ -371,9 +393,17 @@
 		    		&filebuf,
 		    		&infobuf);
 		    
+			if (fields < 9) {
+				return false;
+			}
 
 		    filename.assign(filebuf);
+		    
+		    if (fields >  9) {
 		    info.assign(infobuf);
+		    } else {
+		    	info.assign("");
+		    }
 
 		    // Patch "|" in Filename and Info - they stand for ":"
 		    int colon = 0;
@@ -422,6 +452,11 @@
 
 		    *_timer = new SvdrpTimerEvent(timer, flags,channel, days, start, stop, 
 	        		  		priority, lifetime, filename, info);
+	        free(daysbuf);
+	        free(startbuf);
+	        free(stopbuf);
+	        free(filebuf);
+	        free(infobuf);
 	        
 			result = true;
 		} else {
@@ -443,8 +478,7 @@
     bool result = false;
     bool last = false;
 
-    sprintf(b, "DELT %d\n", _timer);
-    cmd.assign(b);
+    cmd = string_format::str_printf("DELT %d\n", _timer);
 	
     if (send(cmd)) {
     	if (ProcessResult(svdrl, &last)) {
@@ -463,24 +497,25 @@
 	std::string cmd, svdrl;
 	bool result = false;
 	bool last = false;
-	char _buf[256];
-	char _startbuf[32];
-	char _stopbuf[32];
 	
 	tm *start_time, *stop_time;
 
 	stop_time = localtime(&_stop);
-	sprintf((char *)&_stopbuf[0], "%02d%02d", stop_time->tm_hour, stop_time->tm_min);
+	string stops = string_format::str_printf("%02d%02d", stop_time->tm_hour, stop_time->tm_min);
 
 	start_time = localtime(&_start);
-	sprintf((char *)&_startbuf[0], "%02d%02d", start_time->tm_hour, start_time->tm_min);
+	string starts = string_format::str_printf("%02d%02d", start_time->tm_hour, start_time->tm_min);
+
+
+	string timers;
 
 	if (isdigit(*_days.c_str() ) ) {
-		sprintf((char *)&_buf[0], "%4d-%02d-%02d:%s:%s", 	start_time->tm_year + 1900, 
+		timers = string_format::str_printf("%4d-%02d-%02d:%s:%s",
+				start_time->tm_year + 1900, 
 															start_time->tm_mon + 1,
 															start_time->tm_mday,
-															(char *)&_startbuf[0],
-															(char *)&_stopbuf[0]);
+				starts.c_str(),
+				stops.c_str());	
 	}
 
     // Patch ":" in Filename and Info - to be "|"
@@ -502,11 +537,13 @@
     	}
     } while (colon >= 0 && colon < _info.size());
 
-	sprintf(b, "NEWT %d:%d:%s:%d:%d:%s:%s\n", _flags, _channel, (char *)&_buf[0], _priority, _lifetime, _filename.c_str(), _info.c_str());
-
 	// NEWT 1:8:50:50:Damages - Im Netz der Macht:<bla>
 
-	cmd.assign(b);
+	cmd = string_format::str_printf("NEWT %d:%d:%s:%d:%d:%s:%s\n", _flags, _channel, timers.c_str(), _priority, _lifetime, _filename.c_str(), _info.c_str());
+	
+	if (convert) {
+		cmd = string_format::convert_locale(cmd, "UTF-8", locale);
+	}
 	
 	if (send(cmd)) {
     	if (ProcessResult(svdrl, &last)) {
@@ -527,9 +564,8 @@
 	bool result = false;
 	bool last = false;
 
-	sprintf(b, "MODT %d %s\n", _timer, _on ? "ON" : "OFF");
+	cmd = string_format::str_printf("MODT %d %s\n", _timer, _on ? "ON" : "OFF");
 
-	cmd.assign(b);
     if (send(cmd)) {
     	if (ProcessResult(svdrl, &last)) {
     		result = true;
@@ -548,9 +584,8 @@
 	bool result = false;
 	bool last = false;
 
-	sprintf(b, "CHAN %d\n", _channel);
+	cmd = string_format::str_printf("CHAN %d\n", _channel);
 
-	cmd.assign(b);
     if (send(cmd)) {
     	if (ProcessResult(svdrl, &last)) {
     		result = true;
@@ -597,8 +632,7 @@
 
     char token;
 
-	sprintf(b, "LSTE %d\n", _channel);
-	cmd.assign(b);
+	cmd = string_format::str_printf("LSTE %d\n", _channel);
 
 	if (send(cmd)) {
 		do {
@@ -619,7 +653,7 @@
 			
 			org = svdrl;
 			if (convert) {
-				svdrl = string_format::convert_from_locale(svdrl, locale);
+				svdrl = string_format::convert_locale(svdrl, locale, "UTF-8");
 			}
 
 			switch(token) {
@@ -752,9 +786,7 @@
 	
 	int rec_num;
 
-	sprintf(b, "LSTR\n");
-	cmd.assign(b);
-	
+	cmd = string_format::str_printf("LSTR\n");
 	if (send(cmd)) {
 		do {
 			result = ProcessResult(svdrl, &last);
@@ -812,8 +844,7 @@
 
     char token;
 	
-	sprintf(b, "LSTR %d\n", _num);
-	cmd.assign(b);
+	cmd = string_format::str_printf("LSTR %d\n", _num);
 	
 	if (send(cmd)) {
 		do {
@@ -828,7 +859,7 @@
 			
 
 			if (convert) {
-				svdrl = string_format::convert_from_locale(svdrl, locale);
+				svdrl = string_format::convert_locale(svdrl, locale, "UTF-8");
 			}
 			
 			switch(token) {
@@ -960,15 +991,15 @@
 	bool result = false;
 	
 	std::string cmd, svdrl;
-	sprintf(b, "LSTC\n");
-	cmd.assign(b);
+
+	cmd = string_format::str_printf("LSTC\n");
 	
 	if (send(cmd)) {
 		do {
 			result = ProcessResult(svdrl, &last);
 
 			if (convert) {
-				svdrl = string_format::convert_from_locale(svdrl, locale);
+				svdrl = string_format::convert_locale(svdrl, locale, "UTF-8");
 			}
 			
 			std::string a_string;
@@ -999,6 +1030,10 @@
 		    		&number, &namebuf, &frequency, &parambuf, &sourcebuf, &rate, &vpidbuf, &apidbuf,
 		    		&tpid, &caidbuf, &sid, &nid, &tid, &rid);
 
+			if (fields != 14) {
+				return false;
+			}
+		    
 		    int pos;
 		    a_string.assign(namebuf);
 		    
@@ -1047,6 +1082,13 @@
 		        }	        	
 	        }
 		
+	        free(namebuf);
+	        free(parambuf);
+	        free(sourcebuf);
+	        free(vpidbuf);
+	        free(apidbuf);
+	        free(caidbuf);
+	        
 	        result = true;
 		}  while (! last);
 	}
@@ -1920,7 +1962,8 @@
 								ev->AssociateTimer(&(*ti));
 								ti->epgevent = &(*ev);
 							} else {
-								if (ev->org_title == ti->title) {
+								//								if (ev->org_title == ti->title) {
+								if (ev->title == ti->title) {
 								    ev->AssociateTimer(&(*ti));
 									ti->epgevent = &(*ev);
 								}
diff -NaurwB -X diffexclude mms-1.1.0-bzr-head/plugins/input/input.hpp mms-1.1.0-bzr-head-fixepg/plugins/input/input.hpp
--- mms-1.1.0-bzr-head/plugins/input/input.hpp	2008-09-13 06:53:54.000000000 +0200
+++ mms-1.1.0-bzr-head-fixepg/plugins/input/input.hpp	2008-09-21 11:08:32.000000000 +0200
@@ -410,6 +410,7 @@
 					device->enable_all_input();
 					device->search_top();
 				}
+		    	print_func(result_list);
 
 				search_mode = true;
 			} else if (device_input.key != "") {
