Commit e80505af authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wince: new open directory menu (win32 only for now)

parent 7b9a0651
......@@ -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 *)
......
......@@ -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
}
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment