--- libs/libmythui/mythuibuttontree.cpp
+++ libs/libmythui/mythuibuttontree.cpp
@@ -347,6 +347,21 @@ bool MythUIButtonTree::SetCurrentNode(MythGenericTree *node)
 }
 
 /*!
+ * \brief Set depth of the currently selected list
+ * 
+ * \param depth Depth of the tree for currently selected node
+ *
+ * \return True if successful
+ */
+bool MythUIButtonTree::SetCurrentDepth(int depth) {
+    bool listadvance = true;
+    for(int position=0; position < depth - 1 && listadvance; position++)
+        listadvance = SwitchList(true);
+ 
+    return listadvance;
+}
+
+/*!
  * \brief Remove the item from the tree
  *
  * \param item Item to be removed
@@ -413,8 +428,10 @@ void MythUIButtonTree::SetActive(bool active)
  *
  * \param right If true move to the right or away from the root, if false move to
  *              the left or towards the root
+ *
+ * \return True if successful
  */
-void MythUIButtonTree::SwitchList(bool right)
+bool MythUIButtonTree::SwitchList(bool right)
 {
     bool doUpdate = false;
     if (right)
@@ -427,7 +444,7 @@ void MythUIButtonTree::SwitchList(bool right)
             doUpdate = true;
         }
         else
-            return;
+            return false;
     }
     else if (!right)
     {
@@ -439,7 +456,7 @@ void MythUIButtonTree::SwitchList(bool right)
             doUpdate = true;
         }
         else
-            return;
+            return false;
     }
 
     if (doUpdate)
@@ -451,6 +468,7 @@ void MythUIButtonTree::SwitchList(bool right)
         m_activeList = m_buttonlists[m_activeListID];
         m_activeList->Select();
     }
+    return true;
 }
 
 /*!
--- libs/libmythui/mythuibuttontree.h
+++ libs/libmythui/mythuibuttontree.h
@@ -27,6 +27,7 @@ class MPUBLIC MythUIButtonTree : public MythUIType
     bool SetNodeByString(QStringList route);
     bool SetNodeById(QList<int> route);
     bool SetCurrentNode(MythGenericTree *node);
+    bool SetCurrentDepth(int depth);
     MythGenericTree* GetCurrentNode(void) const { return m_currentNode; }
 
     void SetActive(bool active);
@@ -55,7 +56,7 @@ class MPUBLIC MythUIButtonTree : public MythUIType
     void SetTreeState(bool refreshAll = false);
     bool UpdateList(MythUIButtonList *list, MythGenericTree *node);
 
-    void SwitchList(bool right);
+    bool SwitchList(bool right);
 
     bool m_active;
     bool m_initialized;

--- mythvideo/mythvideo/videodlg.cpp	2010-02-12 14:18:04.037342511 +0100
+++ mythvideo/mythvideo/videodlg.cpp	2010-04-05 23:25:57.000000000 +0200
@@ -1415,7 +1415,9 @@
         }
 
         m_rememberPosition =
-                gContext->GetNumSetting("mythvideo.VideoTreeRemember", 0);
+                gContext->GetNumSetting("mythvideo.VideoTreeRemember", 1);
+        m_lastTreeNodePath =
+                gContext->GetSetting("mythvideo.VideoTreeLastActive", "");
 
         m_isFileBrowser = gContext->GetNumSetting("VideoDialogNoDB", 0);
         m_groupType = gContext->GetNumSetting("mythvideo.db_group_type", 0); 
@@ -1434,10 +1436,12 @@
         delete m_scanner;
         StopAllRunningImageDownloads();
 
-        if (m_rememberPosition && m_lastTreeNodePath.length())
+        if (m_rememberPosition && m_lastTreeNodePath.length() > 0)
         {
-            gContext->SaveSetting("mythvideo.VideoTreeLastActive",
-                    m_lastTreeNodePath);
+            // append the last active filename to the node path so we can
+            // preselect the filename and not only the directory next time
+            m_lastTreeNodePath.append("\n").append(m_currentNode->getSelectedChild()->getString());
+            gContext->SaveSetting("mythvideo.VideoTreeLastActive", m_lastTreeNodePath);
         }
     }
 
@@ -1800,9 +1804,10 @@
 
             if (m_d->m_rememberPosition)
             {
-                QStringList route =
-                        gContext->GetSetting("mythvideo.VideoTreeLastActive",
-                                "").split("\n");
+                QStringList route = m_d->m_lastTreeNodePath.split("\n");
+                route.removeFirst();
+
-                m_videoButtonTree->SetNodeByString(route);
+                if (m_videoButtonTree->SetNodeByString(route))
+				     m_videoButtonTree->SetCurrentDepth(route.length());
             }
         }
@@ -1820,7 +1824,12 @@
         if (!m_d->m_currentNode)
             return;
 
-        MythGenericTree *selectedNode = m_d->m_currentNode->getSelectedChild();
+        MythGenericTree *selectedNode =
+                m_d->m_currentNode->getSelectedChild();
+
+        MythGenericTree *lastSelectedNode =
+                m_d->m_currentNode->getChildByName(
+                        m_d->m_lastTreeNodePath.split("\n").last());
 
         typedef QList<MythGenericTree *> MGTreeChildList;
         MGTreeChildList *lchildren = m_d->m_currentNode->getAllChildren();
@@ -1838,8 +1847,17 @@
 
                 UpdateItem(item);
 
-                if (*p == selectedNode)
-                    m_videoButtonList->SetItemCurrent(item);
+                if (m_d->m_rememberPosition && 
+                    m_d->m_type == DLG_GALLERY )
+                {
+                    if (*p == lastSelectedNode)
+                        m_videoButtonList->SetItemCurrent(item);
+                }
+                else
+                {
+                    if (*p == selectedNode)
+                        m_videoButtonList->SetItemCurrent(item);
+                }
             }
         }
     }
@@ -1980,6 +1997,43 @@
 
     if (!m_d->m_currentNode || m_d->m_rootNode != oldroot)
         SetCurrentNode(m_d->m_rootNode);
+
+    if (m_d->m_rememberPosition && 
+        m_d->m_lastTreeNodePath.length() > 0 && 
+        m_d->m_type == DLG_GALLERY )
+    {
+        // Get the list of the last video tree path directories and remove the first
+        // two elements of the route since it is the name of the root 'Video Home' element
+        QStringList routeList = m_d->m_lastTreeNodePath.split("\n");
+        routeList.removeFirst();
+        routeList.removeFirst();
+
+        routeList.removeLast();
+
+        // continue if we have a path
+        if (routeList.size() > 0)
+        {
+            // use the root node as the current node
+            m_d->m_currentNode = m_d->m_rootNode;
+
+            // go through the path list and set the current node
+            for (int i = 0; i < routeList.size(); i++)
+            {
+                // get the node that has the name of the path in the routelist
+                MythGenericTree *node = m_d->m_currentNode->getChildByName(routeList.at(i));
+                if (node != NULL)
+                {
+                    if (node->getInt() == kSubFolder &&
+                        node->getString().compare(routeList.at(i)) == 0 &&
+                        node->childCount() > 1)
+                    {
+                        SetCurrentNode(node);
+                    }
+                }
+            }
+            SetCurrentNode(m_d->m_currentNode);
+        }
+    }
 }
 
 /** \fn VideoDialog::RemoteImageCheck(QString host, QString filename)
@@ -2920,6 +2972,8 @@
     if (m_d->m_currentNode)
         CheckedSet(m_crumbText, m_d->m_currentNode->getRouteByString().join(" > "));
 
+    m_d->m_lastTreeNodePath = m_d->m_currentNode->getRouteByString().join("\n");
+
     if (node && node->getInt() == kSubFolder)
         CheckedSet(this, "childcount",
                    QString("%1").arg(node->visibleChildCount()));
