fix
[enigma2.git] / main / enigma.cpp
index 46ffccce0ea4e9a9049a720450f48513146d544d..c868902f860a56434c024c6ea8d8f4fce69d44de 100644 (file)
@@ -1,8 +1,7 @@
-#undef WITH_SDL
 #ifdef WITH_SDL
-#error
 #define SDLDC
 #endif
+
 #include <stdio.h>
 #include <libsig_comp.h>
 #include <lib/base/ebase.h>
@@ -15,8 +14,8 @@
 #include <lib/gdi/grc.h>
 #include <lib/gdi/gfbdc.h>
 #include <lib/gdi/glcddc.h>
+
 #ifdef WITH_SDL
-#error
 #include <lib/gdi/sdl.h>
 #endif
 #include <lib/gdi/font.h> 
@@ -112,7 +111,7 @@ class eMain: public eApplication, public Object
        ePtr<eDVBDB> m_dvbdb;
        ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
        ePtr<eComponentScan> m_scan;
-//     ePtr<eEPGCache> m_epgcache;
+       ePtr<eEPGCache> m_epgcache;
 
 public:
        eMain()
@@ -123,23 +122,22 @@ public:
                m_dvbdb = new eDVBDB();
                m_mgr = new eDVBResourceManager();
                m_locale_time_handler = new eDVBLocalTimeHandler();
-//             m_epgcache = new eEPGCache();
+               m_epgcache = new eEPGCache();
                m_mgr->setChannelList(m_dvbdb);
-               
-//             m_scan = new eComponentScan();
-//             m_scan->start();
-
        }
        
        ~eMain()
        {
+               m_dvbdb->saveServicelist();
                m_scan = 0;
        }
 };
 
 /************************************************/
 
-eLabel *lcd_label;
+eLabel *lcd_label, *lcd_clock;
+
+int exit_code;
 
 int main(int argc, char **argv)
 {
@@ -147,6 +145,10 @@ int main(int argc, char **argv)
        atexit(object_dump);
 #endif
 
+       // set pythonpath if unset
+       setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0);
+       printf("PYTHONPATH: %s\n", getenv("PYTHONPATH"));
+
 
        ePython python;
        eMain main;
@@ -167,16 +169,26 @@ int main(int argc, char **argv)
        ePtr<gLCDDC> my_lcd_dc;
        gLCDDC::getInstance(my_lcd_dc);
 
-       fontRenderClass::getInstance()->AddFont(FONTDIR "/arial.ttf", "Arial", 100);
+       fontRenderClass::getInstance()->AddFont(FONTDIR "/md_khmurabi_10.ttf", "Regular", 100);
+       fontRenderClass::getInstance()->AddFont(FONTDIR "/ae_AlMateen.ttf", "Replacement", 90);
+       eTextPara::setReplacementFont("Replacement");
+       
+                       /* some characters are wrong in the regular font, force them to use the replacement font */
+       for (int i = 0x60c; i <= 0x66d; ++i)
+               eTextPara::forceReplacementGlyph(i);
+       eTextPara::forceReplacementGlyph(0xfdf2);
+       for (int i = 0xfe80; i < 0xff00; ++i)
+               eTextPara::forceReplacementGlyph(i);
+       
 
        eWidgetDesktop dsk(eSize(720, 576));
        eWidgetDesktop dsk_lcd(eSize(132, 64));
        
-       if (double_buffer)
+/*     if (double_buffer)
        {
                eDebug(" - double buffering found, enable buffered graphics mode.");
                dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
-       }
+       } */
        
        wdsk = &dsk;
        lcddsk = &dsk_lcd;
@@ -185,10 +197,10 @@ int main(int argc, char **argv)
        dsk_lcd.setDC(my_lcd_dc);
 
        ePtr<gPixmap> m_pm;
-       loadPNG(m_pm, "data/pal.png");
+       loadPNG(m_pm, DATADIR "/enigma2/pal.png");
        if (!m_pm)
        {
-               eFatal("hi ghost, please copy pal.png into your ./data, thanks!");
+               eFatal("pal.png not found!");
        } else
                dsk.setPalette(*m_pm);
 
@@ -207,9 +219,20 @@ int main(int argc, char **argv)
        lcd_win->resize(eSize(132, 64));
        
        lcd_label = new eLabel(lcd_win);
-       lcd_label->move(ePoint(0, 0));
-       lcd_label->resize(eSize(132, 64));
-       lcd_label->setText("bla bla bla, this lcd\nSUCKS!");
+       lcd_label->move(ePoint(0, 4));
+       lcd_label->resize(eSize(132, 42));
+       ePtr<gFont> font = new gFont("Regular", 19);
+       //ePtr<gFont> font = new gFont("Regular", 16);
+       lcd_label->setFont(font);
+
+       lcd_clock = new eLabel(lcd_win);
+       lcd_clock->move(ePoint(50, 46));
+       lcd_clock->resize(eSize(132, 18));
+       ePtr<gFont> clkfont = new gFont("Regular", 16);
+       lcd_clock->setFont(clkfont);
+
+       //lcd_label->setText("bla bla bla, this lcd\nSUCKS!");
+       //lcd_clock->setText("88:88:88");
 
        lcd_win->show();
        
@@ -219,9 +242,7 @@ int main(int argc, char **argv)
 
        python.execute("mytest", "__main__");
 
-//     eApp->exec();
-
-       return 0;
+       return exit_code;
 }
 
 eWidgetDesktop *getDesktop()
@@ -229,17 +250,27 @@ eWidgetDesktop *getDesktop()
        return wdsk;
 }
 
+eApplication *getApplication()
+{
+       return eApp;
+}
+
 void runMainloop()
 {
-       eApp->exec();
+       exit_code = eApp->runLoop();
 }
 
-void quitMainloop()
+void quitMainloop(int exitCode)
 {
-       eApp->quit(0);
+       eApp->quit(exitCode);
 }
 
 void setLCD(const char *string)
 {
        lcd_label->setText(string);
 }
+
+void setLCDClock(const char *string)
+{
+       lcd_clock->setText(string);
+}