]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wince: new open directory menu (win32 only for now)
authorGildas Bazin <gbazin@videolan.org>
Tue, 29 Mar 2005 15:22:12 +0000 (15:22 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 29 Mar 2005 15:22:12 +0000 (15:22 +0000)
modules/gui/wince/interface.cpp
modules/gui/wince/wince.cpp
modules/gui/wince/wince.h

index 3f56debb4a5641c7fb83b2dce0bc978cb3d035c2..6c7c49d3f17e462ab801fa61873a463ee2735ffd 100644 (file)
@@ -38,6 +38,7 @@
 #include <windowsx.h>
 #include <commctrl.h>
 #include <commdlg.h>
+#include <shlobj.h>
 
 #define NUMIMAGES     9   // Number of buttons in the toolbar           
 #define IMAGEWIDTH    17   // Width of the buttons in the toolbar  
@@ -218,6 +219,8 @@ HWND Interface::CreateMenuBar( HWND hwnd, HINSTANCE hInst )
     AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
     AppendMenu( menu_file, MF_STRING, ID_FILE_OPENFILE,
                 _T("Open &File...") );
+    AppendMenu( menu_file, MF_STRING, ID_FILE_OPENDIR,
+                _T("Open &Directory...") );
     AppendMenu( menu_file, MF_STRING, ID_FILE_OPENNET,
                 _T("Open &Network Stream...") );
     AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
@@ -565,6 +568,10 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
             delete open;
             break;
 
+        case ID_FILE_OPENDIR:
+            OnOpenDirectory();
+            break;
+
         case ID_FILE_OPENNET:
             open = new OpenDialog( p_intf, hInst, NET_ACCESS, ID_FILE_OPENNET,
                                    OPEN_NORMAL );
@@ -742,7 +749,7 @@ void Interface::OnOpenFileSimple( void )
 
     memset( &ofn, 0, sizeof(OPENFILENAME) );
     ofn.lStructSize = sizeof(OPENFILENAME);
-    ofn.hwndOwner = NULL;
+    ofn.hwndOwner = hwndMain;
     ofn.hInstance = hInst;
     ofn.lpstrFilter = szFilter;
     ofn.lpstrCustomFilter = NULL;
@@ -774,6 +781,75 @@ void Interface::OnOpenFileSimple( void )
     vlc_object_release( p_playlist );
 }
 
+void Interface::OnOpenDirectory( void )
+{
+    TCHAR psz_result[MAX_PATH];
+    LPMALLOC p_malloc = 0;
+    LPITEMIDLIST pidl;
+    BROWSEINFO bi;
+    playlist_t *p_playlist = 0;
+
+#ifdef UNDER_CE
+#   define SHGetMalloc MySHGetMalloc
+#   define SHBrowseForFolder MySHBrowseForFolder
+#   define SHGetPathFromIDList MySHGetPathFromIDList
+
+    HMODULE ceshell_dll = LoadLibrary( _T("ceshell") );
+    if( !ceshell_dll ) return;
+
+    HRESULT WINAPI (*SHGetMalloc)(LPMALLOC *) =
+        (HRESULT WINAPI (*)(LPMALLOC *))
+        GetProcAddress( ceshell_dll, _T("SHGetMalloc") );
+    LPITEMIDLIST WINAPI (*SHBrowseForFolder)(LPBROWSEINFO) =
+        (LPITEMIDLIST WINAPI (*)(LPBROWSEINFO))
+        GetProcAddress( ceshell_dll, _T("SHBrowseForFolder") );
+    BOOL WINAPI (*SHGetPathFromIDList)(LPCITEMIDLIST, LPTSTR) =
+        (BOOL WINAPI (*)(LPCITEMIDLIST, LPTSTR))
+        GetProcAddress( ceshell_dll, _T("SHGetPathFromIDList") );
+
+    if( !SHGetMalloc || !SHBrowseForFolder || !SHGetPathFromIDList )
+    {
+        msg_Err( p_intf, "couldn't load SHBrowseForFolder API" );
+        FreeLibrary( ceshell_dll );
+        return;
+    }
+#endif
+
+    if( !SUCCEEDED( SHGetMalloc(&p_malloc) ) ) goto error;
+
+    p_playlist = (playlist_t *)
+        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( !p_playlist ) goto error;
+
+    memset( &bi, 0, sizeof(BROWSEINFO) );
+    bi.hwndOwner = hwndMain;
+    bi.pszDisplayName = psz_result;
+    bi.ulFlags = BIF_EDITBOX;
+#ifndef UNDER_CE
+    bi.ulFlags |= BIF_USENEWUI;
+#endif
+
+    if( (pidl = SHBrowseForFolder( &bi ) ) )
+    {
+        if( SHGetPathFromIDList( pidl, psz_result ) )
+        {
+            char *psz_filename = _TOMB(psz_result);
+            playlist_Add( p_playlist, psz_filename, psz_filename,
+                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+        }
+        p_malloc->Free( pidl );
+    }
+
+ error:
+
+    if( p_malloc) p_malloc->Release();
+    if( p_playlist ) vlc_object_release( p_playlist );
+
+#ifdef UNDER_CE
+    FreeLibrary( ceshell_dll );
+#endif
+}
+
 void Interface::OnPlayStream( void )
 {
     playlist_t *p_playlist = (playlist_t *)
index a0ac4ca72dec49b176948fefa6168801877cc226..59547453cb34c913545feacc02754779f0d71c66 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "wince.h"
 
+#include <objbase.h>
 #include <commctrl.h>
 #include <commdlg.h>
 
@@ -171,12 +172,17 @@ static void Close( vlc_object_t *p_this )
 static void Run( intf_thread_t *p_intf )
 {
     MSG msg;
-    Interface interface;
+    Interface intf;
 
-    p_intf->p_sys->p_main_window = &interface;
+    p_intf->p_sys->p_main_window = &intf;
     if( !hInstance ) hInstance = GetModuleHandle(NULL);
 
-    if( !interface.InitInstance( hInstance, p_intf ) ) return;
+#ifndef UNDER_CE
+    /* Initialize OLE/COM */
+    CoInitialize( 0 );
+#endif
+
+    if( !intf.InitInstance( hInstance, p_intf ) ) return;
 
     // Main message loop
     while( GetMessage( &msg, NULL, 0, 0 ) > 0 )
@@ -184,4 +190,9 @@ static void Run( intf_thread_t *p_intf )
         TranslateMessage( &msg );
         DispatchMessage( &msg );
     }
+
+#ifndef UNDER_CE
+    /* Uninitialize OLE/COM */
+    CoUninitialize();
+#endif
 }
index 31c6afff4d2b994f8a5f6f4b8de68f31d0fe664b..2e7248010d5ada59af5ac2b15d01ddc442fc8d0a 100644 (file)
@@ -167,6 +167,7 @@ protected:
     virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
 
     void OnOpenFileSimple( void );
+    void OnOpenDirectory( void );
     void OnPlayStream( void );
     void OnVideoOnTop( void );
 
@@ -653,7 +654,8 @@ extern "C" {
 #define IDM_NAVIGATION                  40053
 #define ID_FILE_QUICKOPEN               40057
 #define ID_FILE_OPENFILE                40058
-#define ID_FILE_OPENNET                 40059
+#define ID_FILE_OPENDIR                 40059
+#define ID_FILE_OPENNET                 40060
 #define ID_FILE_EXIT                    40061
 #define ID_VIEW_PLAYLIST                40063
 #define ID_VIEW_MESSAGES                40064