]> git.sesse.net Git - vlc/blobdiff - modules/gui/wince/dialogs.cpp
Use pl_Yield and pl_Release instead of vlc_object_find.
[vlc] / modules / gui / wince / dialogs.cpp
index f8215b2a861bab1594dd7939f9c89f42915a368f..1fa35cdbc82b72b72e9842818dc54144cd29e629 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * dialogs.cpp : WinCE plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000-2005 VideoLAN
- * $Id: dialogs.cpp 10101 2005-03-02 16:47:31Z robux4 $
+ * Copyright (C) 2000-2005 the VideoLAN team
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 
-#include <vlc/vlc.h>
-#include <vlc/aout.h>
-#include <vlc/intf.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_aout.h>
+#include <vlc_interface.h>
 
 #include "wince.h"
 
@@ -55,6 +58,7 @@ private:
     void OnMessages( void );
     void OnFileInfo( void );
     void OnPreferences( void );
+    void OnPopupMenu( void );
 
     void OnOpen( int, int );
     void OnOpenFileSimple( int );
@@ -114,11 +118,11 @@ DialogsProvider::DialogsProvider( intf_thread_t *p_intf,
 DialogsProvider::~DialogsProvider()
 {
     /* Clean up */
-    if( p_open_dialog )     delete p_open_dialog;
-    if( p_playlist_dialog ) delete p_playlist_dialog;
-    if( p_messages_dialog ) delete p_messages_dialog;
-    if( p_fileinfo_dialog ) delete p_fileinfo_dialog;
-    if( p_prefs_dialog )    delete p_prefs_dialog;
+    delete p_open_dialog;
+    delete p_playlist_dialog;
+    delete p_messages_dialog;
+    delete p_fileinfo_dialog;
+    delete p_prefs_dialog;
 
     if( h_gsgetfile_dll ) FreeLibrary( h_gsgetfile_dll );
 }
@@ -137,6 +141,7 @@ LRESULT DialogsProvider::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
     case WM_APP + INTF_DIALOG_MESSAGES: OnMessages(); return TRUE;
     case WM_APP + INTF_DIALOG_FILEINFO: OnFileInfo(); return TRUE;
     case WM_APP + INTF_DIALOG_PREFS: OnPreferences(); return TRUE;
+    case WM_APP + INTF_DIALOG_POPUPMENU: OnPopupMenu(); return TRUE;
     }
 
     return DefWindowProc( hwnd, msg, wp, lp );
@@ -154,6 +159,12 @@ void DialogsProvider::OnIdle( void )
     if( p_fileinfo_dialog ) p_fileinfo_dialog->UpdateFileInfo();
 }
 
+void DialogsProvider::OnPopupMenu( void )
+{
+    POINT point = {0};
+    PopupMenu( p_intf, hWnd, point );
+}
+
 void DialogsProvider::OnPlaylist( void )
 {
 #if 1
@@ -263,13 +274,13 @@ void DialogsProvider::OnOpenFileGeneric( intf_dialog_args_t *p_arg )
     ofn.lpstrCustomFilter = NULL;
     ofn.nMaxCustFilter = 0;
     ofn.nFilterIndex = 1;
-    ofn.lpstrFile = (LPTSTR)szFile; 
+    ofn.lpstrFile = (LPTSTR)szFile;
     ofn.nMaxFile = MAX_PATH;
-    ofn.lpstrFileTitle = NULL; 
+    ofn.lpstrFileTitle = NULL;
     ofn.nMaxFileTitle = 40;
     ofn.lpstrInitialDir = NULL;
     ofn.lpstrTitle = _FROMMB(p_arg->psz_title);
-    ofn.Flags = 0; 
+    ofn.Flags = 0;
     ofn.nFileOffset = 0;
     ofn.nFileExtension = 0;
     ofn.lpstrDefExt = NULL;
@@ -309,8 +320,8 @@ void DialogsProvider::OnOpenFileGeneric( intf_dialog_args_t *p_arg )
         }
         free( p_arg->psz_results );
     }
-    if( p_arg->psz_title ) free( p_arg->psz_title );
-    if( p_arg->psz_extensions ) free( p_arg->psz_extensions );
+    free( p_arg->psz_title );
+    free( p_arg->psz_extensions );
 
     free( p_arg );
 }
@@ -321,8 +332,7 @@ void DialogsProvider::OnOpenFileSimple( int i_arg )
     TCHAR szFile[MAX_PATH] = _T("\0");
     static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
 
-    playlist_t *p_playlist = (playlist_t *)
-        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    playlist_t *p_playlist = pl_Yield( p_intf );
     if( p_playlist == NULL ) return;
 
     memset( &ofn, 0, sizeof(OPENFILENAME) );
@@ -332,14 +342,14 @@ void DialogsProvider::OnOpenFileSimple( int i_arg )
     ofn.lpstrFilter = szFilter;
     ofn.lpstrCustomFilter = NULL;
     ofn.nMaxCustFilter = 0;
-    ofn.nFilterIndex = 1;     
-    ofn.lpstrFile = (LPTSTR)szFile; 
+    ofn.nFilterIndex = 1;
+    ofn.lpstrFile = (LPTSTR)szFile;
     ofn.nMaxFile = MAX_PATH;
-    ofn.lpstrFileTitle = NULL; 
+    ofn.lpstrFileTitle = NULL;
     ofn.nMaxFileTitle = 40;
     ofn.lpstrInitialDir = NULL;
     ofn.lpstrTitle = _T("Quick Open File");
-    ofn.Flags = 0; 
+    ofn.Flags = 0;
     ofn.nFileOffset = 0;
     ofn.nFileExtension = 0;
     ofn.lpstrDefExt = NULL;
@@ -356,7 +366,7 @@ void DialogsProvider::OnOpenFileSimple( int i_arg )
                       PLAYLIST_APPEND | (i_arg?PLAYLIST_GO:0), PLAYLIST_END );
     }
 
-    vlc_object_release( p_playlist );
+    pl_Release( p_playlist );
 }
 
 void DialogsProvider::OnOpenDirectory( int i_arg )
@@ -375,14 +385,14 @@ void DialogsProvider::OnOpenDirectory( int i_arg )
     HMODULE ceshell_dll = LoadLibrary( _T("ceshell") );
     if( !ceshell_dll ) return;
 
-    HRESULT WINAPI (*SHGetMalloc)(LPMALLOC *) =
-        (HRESULT WINAPI (*)(LPMALLOC *))
+    HRESULT (WINAPI *SHGetMalloc)(LPMALLOC *) =
+        (HRESULT (WINAPI *)(LPMALLOC *))
         GetProcAddress( ceshell_dll, _T("SHGetMalloc") );
-    LPITEMIDLIST WINAPI (*SHBrowseForFolder)(LPBROWSEINFO) =
-        (LPITEMIDLIST WINAPI (*)(LPBROWSEINFO))
+    LPITEMIDLIST (WINAPI *SHBrowseForFolder)(LPBROWSEINFO) =
+        (LPITEMIDLIST (WINAPI *)(LPBROWSEINFO))
         GetProcAddress( ceshell_dll, _T("SHBrowseForFolder") );
-    BOOL WINAPI (*SHGetPathFromIDList)(LPCITEMIDLIST, LPTSTR) =
-        (BOOL WINAPI (*)(LPCITEMIDLIST, LPTSTR))
+    BOOL (WINAPI *SHGetPathFromIDList)(LPCITEMIDLIST, LPTSTR) =
+        (BOOL (WINAPI *)(LPCITEMIDLIST, LPTSTR))
         GetProcAddress( ceshell_dll, _T("SHGetPathFromIDList") );
 
     if( !SHGetMalloc || !SHBrowseForFolder || !SHGetPathFromIDList )
@@ -395,8 +405,7 @@ void DialogsProvider::OnOpenDirectory( int i_arg )
 
     if( !SUCCEEDED( SHGetMalloc(&p_malloc) ) ) goto error;
 
-    p_playlist = (playlist_t *)
-        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    p_playlist = pl_Yield( p_intf );
     if( !p_playlist ) goto error;
 
     memset( &bi, 0, sizeof(BROWSEINFO) );
@@ -422,7 +431,7 @@ void DialogsProvider::OnOpenDirectory( int i_arg )
  error:
 
     if( p_malloc) p_malloc->Release();
-    if( p_playlist ) vlc_object_release( p_playlist );
+    if( p_playlist ) pl_Release( p_playlist );
 
 #ifdef UNDER_CE
     FreeLibrary( ceshell_dll );