Index: libs/libmyth/mythcontext.h
===================================================================
--- libs/libmyth/mythcontext.h	(revision 9212)
+++ libs/libmyth/mythcontext.h	(working copy)
@@ -294,6 +294,7 @@
 
     QString FindThemeDir(const QString &themename);
     QString GetThemeDir(void);
+    QValueList<QString> GetThemeSearchPath(void);
 
     QString GetMenuThemeDir(void);
 
Index: libs/libmyth/xmlparse.cpp
===================================================================
--- libs/libmyth/xmlparse.cpp	(revision 9212)
+++ libs/libmyth/xmlparse.cpp	(working copy)
@@ -33,22 +33,16 @@
 
     fontSizeType = gContext->GetSetting("ThemeFontSizeType", "default");
 
-    
-    // first try to load the theme from the current theme directory
-    QString themepath = gContext->GetThemeDir();
-    QString themefile = themepath + specialfile + "ui.xml";
-     
-    if (doLoadTheme(ele, winName, themefile))
-        return true;
-        
-    // not found so now try the default theme directory
-    themepath = gContext->GetShareDir() + "themes/default/";
-    themefile = themepath + specialfile + "ui.xml";
-
-    if (doLoadTheme(ele, winName, themefile))
-    {    
-        //cout << "XMLParse::LoadTheme(): Using default theme file" << endl;
-        return true;
+    QValueList<QString> searchpath = gContext->GetThemeSearchPath();
+    for (QValueList<QString>::const_iterator ii = searchpath.begin();
+        ii != searchpath.end(); ii++)
+    {
+        QString themefile = *ii + specialfile + "ui.xml";
+        if (doLoadTheme(ele, winName, themefile))
+        {
+            VERBOSE(VB_GENERAL, "XMLParse::LoadTheme using " << themefile);
+            return true;
+        }
     }
     
     return false;
@@ -665,28 +659,32 @@
 
 bool XMLParse::parseDefaultCategoryColors(QMap<QString, QString> &catColors)
 {
-    QString catColorFile = gContext->GetThemesParentDir() + "default/categories.xml";
-    
-    QDomDocument doc;
-    QFile f(catColorFile);
-    
-    if (!f.open(IO_ReadOnly))
+    QFile f;
+    QValueList<QString> searchpath = gContext->GetThemeSearchPath();
+    for (QValueList<QString>::const_iterator ii = searchpath.begin();
+        ii != searchpath.end(); ii++)
     {
-        cerr << "Error: Unable to open " << catColorFile << endl;
+        f.setName(*ii + "categories.xml");
+        if (f.open(IO_ReadOnly))
+            break;
+    }
+    if (f.handle() == -1)
+    {
+        VERBOSE(VB_IMPORTANT, "Error: Unable to open " << f.name());
         return false;
     }
-    
+
+    QDomDocument doc;
     QString errorMsg;
     int errorLine = 0;
     int errorColumn = 0;
     
     if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn))
     {
-        cerr << "Error parsing: " << catColorFile << endl;
-        cerr << "at line: " << errorLine << "  column: " << errorColumn << endl;
-        cerr << errorMsg << endl;
+        VERBOSE(VB_IMPORTANT, "Error parsing: " << f.name()
+                << " line: " << errorLine << "  column: " << errorColumn
+                << ": " << errorMsg);
         f.close();
-        
         return false;
     }
     
@@ -3855,3 +3853,5 @@
         }
     }
 }
+
+// vim:set sw=4 expandtab:
Index: libs/libmyth/uitypes.cpp
===================================================================
--- libs/libmyth/uitypes.cpp	(revision 9212)
+++ libs/libmyth/uitypes.cpp	(working copy)
@@ -387,77 +387,57 @@
 
 void UIBarType::LoadImage(int loc, QString myFile)
 {
+    QImage sourceImg;
+    int doX = 0;
+    int doY = 0;
+    QImage scalerImg;
+
     if (m_size == 0)
     {
-        cerr << "uitypes.cpp:UIBarType:LoadImage:m_size == 0";
+        VERBOSE(VB_IMPORTANT, "uitypes.cpp:UIBarType:LoadImage:m_size == 0");
         return;
     }
     QString filename = m_filename;
     if (loc != -1)
         filename = myFile;
 
-    QString file;
+    QString file = filename;
+    if (!gContext->FindThemeFile(file))
+        goto error;
 
-    QString themeDir = gContext->GetThemeDir();
-    QString baseDir = gContext->GetShareDir() + "themes/default/";
+    if (!sourceImg.load(file))
+        goto error;
 
-    QFile checkFile(themeDir + filename);
-
-    if (checkFile.exists())
-        file = themeDir + filename;
-    else
-        file = baseDir + filename;
-    checkFile.setName(file);
-    if (!checkFile.exists())
-        file = "/tmp/" + filename;
-
-    checkFile.setName(file);
-    if (!checkFile.exists())
-        file = filename;
-
-    if (m_debug == true)
-        cerr << "     -Filename: " << file << endl;
-
-    QImage *sourceImg = new QImage();
-    if (sourceImg->load(file))
+    if (m_orientation == 1)
     {
-        QImage scalerImg;
-        int doX = 0;
-        int doY = 0;
-        if (m_orientation == 1)
-        {
-            doX = m_displaysize.width() / m_size;
-            doY = m_displaysize.height();
-        }
-        else if (m_orientation == 2)
-        {
-            doX = m_displaysize.width();
-            doY = m_displaysize.height() / m_size;
-        }
-        if (loc != -1)
-        {
-            doX = m_iconsize.x();
-            doY = m_iconsize.y();
-        }
-
-        scalerImg = sourceImg->smoothScale(doX, doY);
-        if (loc == -1)
-            m_image.convertFromImage(scalerImg);
-        else
-            iconData[loc].convertFromImage(scalerImg);
-
-        if (m_debug == true)
-            cerr << "     -Image: " << file << " loaded.\n";
+        doX = m_displaysize.width() / m_size;
+        doY = m_displaysize.height();
     }
-    else
+    else if (m_orientation == 2)
     {
-      if (m_debug == true)
-          cerr << "     -Image: " << file << " failed to load.\n";
-      iconData[loc].resize(0, 0);
+        doX = m_displaysize.width();
+        doY = m_displaysize.height() / m_size;
     }
+    if (loc != -1)
+    {
+        doX = m_iconsize.x();
+        doY = m_iconsize.y();
+    }
 
-    delete sourceImg;
+    scalerImg = sourceImg.smoothScale(doX, doY);
+    if (loc == -1)
+        m_image.convertFromImage(scalerImg);
+    else
+        iconData[loc].convertFromImage(scalerImg);
 
+    if (m_debug == true)
+        VERBOSE(VB_IMPORTANT, "     -Image: " << file << " loaded.");
+    return;
+
+error:
+    if (m_debug == true)
+        VERBOSE(VB_IMPORTANT, "     -Image: " << file << " failed to load.");
+    iconData[loc].resize(0, 0);
 }
 
 void UIBarType::Draw(QPainter *dr, int drawlayer, int context)
@@ -1313,28 +1293,16 @@
     QString file;
     if (m_flex == true)
     {
+        QString flexprefix = m_transparent ? "trans-" : "solid-";
         int pathStart = m_filename.findRev('/');
-        if (m_transparent)
-        {
-            if (pathStart < 0 )
-                m_filename = "trans-" + m_filename;
-            else
-                m_filename.replace(pathStart, 1, "/trans-");
-        }
+        if (pathStart < 0 )
+            m_filename = flexprefix + m_filename;
         else
-        {
-            if (pathStart < 0 )
-                m_filename = "solid-" + m_filename;
-            else
-                m_filename.replace(pathStart, 1, "/solid-");
-        }
+            m_filename.replace(pathStart, 1, "/" + flexprefix);
     }
 
-    QString themeDir = gContext->GetThemeDir();
-    QString baseDir = gContext->GetShareDir() + "themes/default/";
+    QString filename = gContext->GetThemeDir() + m_filename;
 
-    QString filename = themeDir + m_filename;
-
     if (m_force_x == -1 && m_force_y == -1)
     {
         QPixmap *tmppix = gContext->LoadScalePixmap(filename);
@@ -1354,13 +1322,14 @@
 
     if (!gContext->FindThemeFile(file))
     {
-        cerr << "UIImageType::LoadImage() - Cannot find image: " << m_filename << endl;
+        VERBOSE(VB_IMPORTANT, "UIImageType::LoadImage() - Cannot find image: "
+                << m_filename);
         m_show = false;
         return;
     }
 
     if (m_debug == true)
-        cerr << "     -Filename: " << file << endl;
+        VERBOSE(VB_GENERAL, "     -Filename: " << file);
 
     if (m_hmult == 1 && m_wmult == 1 && m_force_x == -1 && m_force_y == -1)
     {
@@ -1379,13 +1348,13 @@
             {
                 doX = m_force_x;
                 if (m_debug == true)
-                    cerr << "         +Force X: " << doX << endl;
+                    VERBOSE(VB_GENERAL, "         +Force X: " << doX);
             }
             if (m_force_y != -1)
             {
                 doY = m_force_y;
                 if (m_debug == true)
-                    cerr << "         +Force Y: " << doY << endl;
+                    VERBOSE(VB_GENERAL, "         +Force Y: " << doY);
             }
 
             scalerImg = sourceImg->smoothScale((int)(doX * m_wmult),
@@ -1393,13 +1362,13 @@
             m_show = true;
             img.convertFromImage(scalerImg);
             if (m_debug == true)
-                    cerr << "     -Image: " << file << " loaded.\n";
+                VERBOSE(VB_GENERAL, "     -Image: " << file << " loaded.");
         }
         else
         {
             m_show = false;
             if (m_debug == true)
-                cerr << "     -Image: " << file << " failed to load.\n";
+                VERBOSE(VB_GENERAL, "     -Image: " << file << " failed to load.");
         }
         delete sourceImg;
     }
@@ -1564,49 +1533,11 @@
     if (imageNo >= m_imagecount)
         return false;
 
-    bool bSuccess = false;
-    QString file;
-
-    file = m_filename.arg(imageNo);
-
-    // first try the absolute filename
-    bool  filefound = false;
-    QString filename;
-    QString themeDir = gContext->GetThemeDir();
-    QString baseDir = gContext->GetShareDir() + "themes/default/";
-    QFile checkFile(file);
-
-    if (checkFile.exists())
-    {
-        filefound = true;
-        filename = file;
-    }
-
-    if (!filefound)
-    {
-        checkFile.setName(baseDir + file);
-        if (checkFile.exists())
-        {
-            filefound = true;
-            filename = baseDir + file;
-        }
-    }
-
-    if (!filefound)
-    {
-        checkFile.setName(themeDir + file);
-        if (checkFile.exists())
-        {
-            filefound = true;
-            filename = themeDir + file;
-        }
-    }
-
-    if (!filefound)
-    {
+    QString filename = m_filename.arg(imageNo);
+    if (!gContext->FindThemeFile(filename))
          return true;
-    }
 
+    bool bSuccess = false;
     if (m_force_x == -1 && m_force_y == -1)
     {
         QPixmap *tmppix = gContext->LoadScalePixmap(filename);
@@ -1632,14 +1563,11 @@
     }
     else
     {
-        QPixmap *img = new QPixmap();
-        QImage *sourceImg = new QImage();
-
-        if (sourceImg->load(filename))
+        QImage sourceImg(filename);
+        if (!sourceImg.isNull())
         {
-            QImage scalerImg;
-            int doX = sourceImg->width();
-            int doY = sourceImg->height();
+            int doX = sourceImg.width();
+            int doY = sourceImg.height();
             if (m_force_x != -1)
             {
                 doX = m_force_x;
@@ -1649,13 +1577,15 @@
                 doY = m_force_y;
             }
 
-            scalerImg = sourceImg->smoothScale((int)(doX * m_wmult),
+            QImage scalerImg = sourceImg.smoothScale((int)(doX * m_wmult),
                                                (int)(doY * m_hmult));
-            bSuccess = true;
+
+            QPixmap *img = new QPixmap();
             img->convertFromImage(scalerImg);
             imageList->push_back(img);
+
+            bSuccess = true;
         }
-        delete sourceImg;
     }
 
     return bSuccess;
@@ -5444,3 +5374,4 @@
     }
 }
 
+// vim:set sw=4 expandtab:
Index: libs/libmyth/mythcontext.cpp
===================================================================
--- libs/libmyth/mythcontext.cpp	(revision 9212)
+++ libs/libmyth/mythcontext.cpp	(working copy)
@@ -1359,13 +1359,13 @@
     
 void MythContext::CacheThemeImages(void)
 {
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
-
     if (d->m_screenwidth == d->m_baseWidth && d->m_screenheight == d->m_baseHeight)
         return;
 
     CacheThemeImagesDirectory(d->m_themepathname);
-    CacheThemeImagesDirectory(baseDir);
+    if (d->IsWideMode())
+        CacheThemeImagesDirectory(GetThemesParentDir() + "default-wide/");
+    CacheThemeImagesDirectory(GetThemesParentDir() + "default/");
 }
 
 void MythContext::CacheThemeImagesDirectory(const QString &dirname,
@@ -1645,7 +1645,7 @@
     if (dir.exists())
         return testdir;
 
-    testdir = d->m_installprefix + "/share/mythtv/themes/" + themename;
+    testdir = GetThemesParentDir() + themename;
     dir.setPath(testdir);
     if (dir.exists())
         return testdir;
@@ -1659,13 +1659,13 @@
     // Don't complain about the "default" theme being missing
     if (themename == QObject::tr("Default"))
     {
-        testdir = d->m_installprefix + "/share/mythtv/";
+        testdir = GetShareDir();
         dir.setPath(testdir);
         if (dir.exists())
             return testdir;
     }
 
-    testdir = d->m_installprefix + "/share/mythtv/themes/G.A.N.T.";
+    testdir = GetThemesParentDir() + "G.A.N.T.";
     dir.setPath(testdir);
     if (dir.exists())
         return testdir;
@@ -1683,6 +1683,18 @@
     return d->m_themepathname;
 }
 
+QValueList<QString> MythContext::GetThemeSearchPath(void)
+{
+    QValueList<QString> searchpath;
+
+    searchpath.append(GetThemeDir());
+    if (d->IsWideMode())
+        searchpath.append(GetThemesParentDir() + "default-wide/");
+    searchpath.append(GetThemesParentDir() + "default/");
+    searchpath.append("/tmp/");
+    return searchpath;
+}
+
 MDBManager *MythContext::GetDBManager(void)
 {
     return &d->m_dbmanager;
@@ -2039,52 +2051,29 @@
 
 bool MythContext::FindThemeFile(QString &filename)
 {
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
-    QString file;
+    // Given a full path, or in current working directory?
+    if (QFile::exists(filename))
+        return true;
+
     int pathStart = filename.findRev('/');
-    bool bFound = false;
+    QString basename;
+    if (pathStart > 0)
+        basename = filename.mid(pathStart + 1);
 
-    // Given a full path?
-    file = filename;
-    bFound = QFile::exists(file);
-
-    // look in theme directory first including any sub directory
-    if (!bFound)
+    QString file;
+    QValueList<QString> searchpath = GetThemeSearchPath();
+    for (QValueList<QString>::const_iterator ii = searchpath.begin();
+        ii != searchpath.end(); ii++)
     {
-        file = d->m_themepathname + filename;
-        bFound = QFile::exists(file);
+        if (QFile::exists((file = *ii + filename)))
+            goto found;
+        if (pathStart > 0 && QFile::exists((file = *ii + basename)))
+            goto found;
     }
 
-    if (!bFound && pathStart > 0)
-    {
-        // look in theme directory minus any sub directories
-        file = d->m_themepathname + filename.mid(pathStart + 1);
-        bFound = QFile::exists(file);
-    }
+    return false;
 
-    // look in default theme directory
-    if (!bFound)
-    {
-        file = baseDir + filename;
-        bFound = QFile::exists(file);
-    }
-
-    if (!bFound && pathStart > 0)
-    {
-        file = baseDir + filename.mid(pathStart + 1);
-        bFound = QFile::exists(file);
-    }
-
-    // look in tmp directory
-    if (!bFound)
-    {
-        file = "/tmp/" + filename;
-        bFound = QFile::exists(file);
-    }
-
-    if (!bFound)
-        return false;
-
+found:
     filename = file;
     return true;
 }
@@ -2093,7 +2082,6 @@
 {
     if (filename.left(5) == "myth:")
         return NULL;
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
 
     if (d->themecachedir != "" && fromcache)
     {
@@ -2187,7 +2175,6 @@
 {
     if (filename.left(5) == "myth:")
         return NULL;
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
 
     if (d->themecachedir != "" && fromcache)
     {
@@ -2726,7 +2713,12 @@
         }
 
         if (priority <= d->m_logprintlevel)
-            VERBOSE(VB_IMPORTANT, module + ": " + message);
+        {
+            if (details.isEmpty())
+                VERBOSE(VB_IMPORTANT, module + ": " + message);
+            else
+                VERBOSE(VB_IMPORTANT, module + ": " + message + ": " + details);
+        }
     }
 }
 
