summaryrefslogtreecommitdiffstats
path: root/Gui
diff options
context:
space:
mode:
authorvayne <vayne@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-06 02:07:03 +0000
committervayne <vayne@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-06 02:07:03 +0000
commit4aa477ef2cfb2973e87e9d0662fe1c4e6946f120 (patch)
tree58f7ffef779e9ebcb77ac5c75f822d6dba5bdeec /Gui
parentc5cf04f5430fa3a44ea1d92d5bcf75ca0623f5a7 (diff)
downloadmpv-4aa477ef2cfb2973e87e9d0662fe1c4e6946f120.tar.bz2
mpv-4aa477ef2cfb2973e87e9d0662fe1c4e6946f120.tar.xz
Initial win32 gui release.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18919 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'Gui')
-rw-r--r--Gui/win32/Changelog317
-rw-r--r--Gui/win32/README17
-rw-r--r--Gui/win32/dialogs.c1142
-rw-r--r--Gui/win32/dialogs.h129
-rw-r--r--Gui/win32/gui.c1555
-rw-r--r--Gui/win32/gui.h118
-rw-r--r--Gui/win32/interface.c975
-rw-r--r--Gui/win32/playlist.c154
-rw-r--r--Gui/win32/playlist.h57
-rw-r--r--Gui/win32/preferences.c714
-rw-r--r--Gui/win32/skinload.c809
-rw-r--r--Gui/win32/skinload.h213
-rw-r--r--Gui/win32/widgetrender.c350
-rw-r--r--Gui/win32/wincfg.c143
-rw-r--r--Gui/win32/wincfg.h38
15 files changed, 6731 insertions, 0 deletions
diff --git a/Gui/win32/Changelog b/Gui/win32/Changelog
new file mode 100644
index 0000000000..d439fa9dcd
--- /dev/null
+++ b/Gui/win32/Changelog
@@ -0,0 +1,317 @@
+HISTORY
+2006/06/30 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed display of wrong aspect ratios.
+
+2006/06/13 - Erik Augustson <erik_27can@yahoo.com>
+- Minor bugfixes.
+- Updated to current SVN
+
+2006/04/14 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed a crash bug.
+- Fixed a major fullscreen bug (WinID wasn't getting
+ reset when FS switching).
+
+2006/04/13 - Erik Augustson <erik_27can@yahoo.com>
+- More minor fixups
+
+2006/04/07 - Erik Augustson <erik_27can@yahoo.com>
+- Minor fixups to openurl and openfile from dialogs.c
+
+2006/04/06 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed IPC and drag&drop appending files to the
+ playlist instead of opening them right away.
+- Updated dvdnav patch.
+
+2006/04/03 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed a long pathnames issue with WM_COPYDATA.
+- Fixed a minor crash happening when rendering the
+ codec name.
+- Some code cleanup.
+
+2006/04/01 - Erik Augustson <erik_27can@yahoo.com>
+- Added ability to enable/disable videos displaying
+ in the sub window in preferences.
+- Small fix in update_subwindow() for coming out
+ of fullscreen when the sub window was minimized.
+
+2006/03/27 - Erik Augustson <erik_27can@yahoo.com>
+- Updated to current CVS.
+- Debug console now shows the extensions mplayer
+ was compiled with.
+
+2006/03/23 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed using -playlist and -shuffle.
+
+2006/03/22 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed a small bug with input events for dialogs.
+
+2006/03/16 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed left button mouse event in dvdnav patch.
+- More aspect fixes.
+- Fixed double-click in the playlist.
+- Fixed some drag&drop functionality.
+
+2006/03/14 - Erik Augustson <erik_27can@yahoo.com>
+- Simplified title/chapter selection dialog.
+- Code cleanup.
+
+2006/03/14 - Erik Augustson <erik_27can@yahoo.com>
+
+- Fixed resetting aspect on file ending in mplEnd()
+
+2006/03/13 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed double click events, forgot to add CS_DBLCLKS
+ to sub window's window style.
+- Fixed window focusing with drag&drop files.
+- Re-arranged some menu items, and added support for
+ runtime aspect switching. This adds 3 lines to
+ mplayer.c but is well worth it IMO.
+
+2006/03/12 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed window positioning for both windows.
+- Added more mouse button events.
+
+2006/03/10 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed mouse and sub window vanishing after coming
+ out of fullscreen by end of file.
+- Fixed sub window popping up when switching to
+ fullscreen and *not* using directx.
+- Added codec name to widgets to properly render
+ in some skins.
+- Middle and scroll wheel mouse event should work
+ now on the sub window.
+- #ifdef'd USE_DVDREAD to allow for compilation
+ when disabling mpdvdkit.
+- Updated license information.
+
+2006/03/08 - Erik Augustson <erik_27can@yahoo.com>
+- Removed unnecessary playerinfo struct
+- Fixed movies playing at wrong aspects
+- Minor bugfixes all around
+
+2006/03/07 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed some skin labels not displaying properly
+
+2006/03/06 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Temporaly fix crash if no vo_driver is specified
+ (interface.c:877)
+
+2006/02/28 - Erik Augustson <erik_27can@yahoo.com>
+- Added sub window. The sub window is the WinID
+ (-wid) when using the directx vo. The sub window
+ hides when the file is audio only, and as well
+ when the vo is not directx, and automatically
+ adjusts and maintains video aspect ratios
+- Minor fixups
+- TODO: Get WinID working when using gl2, and add
+ fix for both windows if going out of bounds on
+ right and bottom of screen.
+
+2006/01/30 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed playing movies from network drives.
+
+2006/01/27 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed a small annoyance when playing a network file
+ with file associations when mplayer wasn't running,
+ using GetLongPathNameA()
+
+2006/01/15 - Erik Augustson <erik_27can@yahoo.com>
+- Added some CD functionality if using libcdio.
+
+2005/12/02 - Erik Augustson <erik_27can@yahoo.com>
+- Fix to disable gui if running in slave mode.
+
+2005/11/14 - Erik Augustson <erik_27can@yahoo.com>
+- Implemented IPC with WM_COPYDATA to open new
+ files/playlists in the current running mplayer,
+ rather than having a new mplayer process spawn.
+
+2005/11/12 - Erik Augustson <erik_27can@yahoo.com>
+- Modified evMute to mute/unmute
+- Mute button should show as pressed when muted
+- Added evDecVolume and evIncVolume
+
+2005/11/09 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed screensaver issues
+
+2005/11/06 - Erik Augustson <erik_27can@yahoo.com>
+- Display fixes
+
+2005/09/18 - Erik Augustson <erik_27can@yahoo.com>
+- Playlist additions
+- Minor playlist bugfixes
+
+2005/09/16 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Code cleanup
+
+2005/09/05 - Erik Augustson <erik_27can@yahoo.com>
+- Updated to apply to current CVS
+
+2005/07/27 - Erik Augustson <erik_27can@yahoo.com>
+- Added initial evEqualizer for brightness, contrast,
+ hue and saturation of videos.
+
+2005/07/26 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed double click on playlist
+- Added support for screenshot video filter, vf_screenshot patch
+ is also needed
+
+2005/06/19 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Removed -console switch, moved console stuff out of mplayer main,
+ console option is handled in wincfg, it's switchable at runtime
+ from the gui and the state is saved
+
+2005/06/15 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed bugs with DVD chapter skipping
+- Title/chapter switching dialog works again :)
+- Fixed a bug with url's not working after playing a DVD
+- Removed fullscreen handling from mplayer.c. It's now
+ handled in interface.c
+- Disabled loading/saving playlists, and adding files/urls
+ while playing a DVD
+
+2005/06/12 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Added -console cmd line option to bring up a dos console
+ that displays mplayer messages
+
+2005/06/10 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed a bug with the audio filters not loading
+- Fixed bugs with the audio delay and stereo sliders
+- Added a few safety checks
+
+2005/06/08 - Erik Augustson <erik_27can@yahoo.com>
+- Added initial evPreferences
+- Fixed a bug with the load subtitle dialog
+- Some code cleanup and minor fixes here and there
+
+2005/06/02 - Erik Augustson <erik_27can@yahoo.com>
+- Fixed a bug with pathnames in the open url dialog
+
+2005/05/26 - Erik Augustson <erik_27can@yahoo.com>
+- Added "Add file" and "Add url" menu to the playlist
+- Fixed file skipping when double-clicking playlist entries
+
+2005/05/19 - Erik Augustson <erik_27can@yahoo.com>
+- added simple url history
+
+2005/05/12 - Erik Augustson <erik_27can@yahoo.com>
+- added load and save playlists options
+- fixed opening remote m3u and pls files in open url
+- no problems so far with evprev and evnext :)
+
+2005/05/10 - Erik Augustson <erik_27can@yahoo.com>
+- more evNext and evPrev fixes
+
+2005/05/06 - Erik Augustson <erik_27can@yahoo.com>
+- implemented mplEnd() for proper looping fix
+- fixed bugs in evNext and evPrev
+- re-organized the menus
+
+2005/03/02 - Gianluigi Tiesi <sherpya@netfarm.it>
+- adapted subtitle patch from Raul <zomps@mail.astar.ee>
+- readapted endless loop fix to not touch mp_msg.c
+Erik Augustson <erik_27can@yahoo.com>
+- small fixes, orginal endless loop fix
+
+2005/02/25 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Fixed exit stuff (I hope ;P)
+- Fixes to Erik's title/chapter selector
+Erik Augustson <erik_27can@yahoo.com>
+- Added additional gui events
+- Added evPrev and evNext dvd chapter switching
+
+2005/02/23 - Erik Augustson <erik_27can@yahoo.com>
+- added dvd title/chapter switching
+
+2005/02/20 - Gianluigi Tiesi <sherpya@netfarm.it>
+- fixed dvd stop and play
+Erik Augustson <erik_27can@yahoo.com>
+- imported some stuff from unix gui
+- fixed file play after dvd
+
+2005/02/18 - Erik Augustson <erik_27can@yahoo.com>
+- addons for dvd playing
+
+2005/02/16 - Gianluigi Tiesi <sherpya@netfarm.it>
+- renamed README to README.txt
+- retain window position even when switching the skin
+- converted all opendir calls to native win32 calls
+- adding filename as title without directory for all calls
+- more cleanups in skinloader/unloader
+- removed a lot of warnings
+- removed unused includes
+Erik Augustson <erik_27can@yahoo.com>
+- added online help menu
+
+2005/02/15 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Disabled access to gui when gui->mainwindow doesn't match hwnd passed to windproc
+- Fixed save position for main window gui
+- Cleanups in skinloader/unloader
+Erik Augustson erik_27can@yahoo.com
+- Added saving main window position to gui config
+- Fixes on playlist for vcd
+
+2005/02/13 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Fixed multithreaded (I hope ;P)
+- Skinbrowser window is closed when a skin is changed, this prevents crashes if multiple clicks
+- Playlist window is updated if files are added while playlist is visible
+- Removed patch on mplayer.rc, take icon using the included routine
+- SkinBrowser and Playlist dialogs can be opened/closed by clicking multiple times gui buttons
+- Added support for DVD, stop dvd + play is broken ;(
+- ifdef-ed a lot of debug stuff
+- Fixed systray icon removing
+- Added Erik and me to about dialog ;)
+Erik Augustson <erik_27can@yahoo.com>
+- Added key handling for the gui window
+- Small fixes on tray icon stuff
+
+2005/02/11 - Gianluigi Tiesi <sherpya@netfarm.it>
+- fixed sliders, balance is not 100% working, anyway dsound output driver doesn't support balanced audio
+- remade threaded
+- removed demuxer/avi patches, really needed ??
+- added a fake vo_init if opengl is not enabled
+Erik Augustson <erik_27can@yahoo.com>
+- fixes on traymenu play
+- added a base configuration reader/writer - only support for skin selection for now
+
+2005/02/10 - Gianluigi Tiesi <sherpya@netfarm.it>
+- fixed (workarounded) the NULL filename bug
+- moved add directory directly into gui.c
+- it starts to be usable :)
+Erik Augustson <erik_27can@yahoo.com>
+- Added systray support
+- Added skin browser option to menu (some skins don't show a skin browser button)
+
+2005/02/09 - Gianluigi Tiesi <sherpya@netfarm.it>
+- Fixed window disappearing bug
+- Made a patch compatible with current tree
+- Fixed icons in minor dialogs
+- Major cleanup and code reorganization
+
+2005/02/08 - Erik Augustson <erik_27can@yahoo.com>
+- Removed multi-threading, mplayer now runs in a single thread
+- Play directory now works as intended
+- Added a Skin browser, double-click skin names to switch skins
+- Still more things todo
+
+pre4
+- URL open
+- use windows native menus
+- Gui runs in a seperate thread now because some controls interupt playback :(
+
+pre 3
+- some of the previous features broken again
+- full font loading/display support
+- better integration into mplayer
+- seek bar, balance, volume control work
+
+pre 2
+- playlist
+- Drag 'N Drop support
+- fixed segfault when no skinfile found
+
+pre 1
+- initial revision
+- play/pause works
+- loads "blue" skin
+- still lot of things todo
diff --git a/Gui/win32/README b/Gui/win32/README
new file mode 100644
index 0000000000..f0a7123be7
--- /dev/null
+++ b/Gui/win32/README
@@ -0,0 +1,17 @@
+MPlayer Windows GUI (c)
+2003 Sascha Sommer - <saschasommer@freenet.de>
+2006 Erik Augustson - <erik_27can@yahoo.com>
+2006 Gianluigi Tiesi - <sherpya@netfarm.it>
+
+This beta gui for win32 was originally written by Sascha Sommer and
+has since been heavily modified by myself (Erik Augustson) and Gianluigi
+Tiesi. It follows the same concept for the linux gui, and should be
+able to load all(most) of the current skins available for the linux gui.
+
+To compile, quite simply pass --enable-gui to configure, and it is highly
+recommended to also pass --enable-static="-mwindows" to link mplayer as
+a windows binary. NOTE: this will also link mencoder with -mwindows
+and thus link mencoder as a windows binary as well.
+
+Please send all bug reports/comments/requests/gripes to:
+<erik_27can@yahoo.com>
diff --git a/Gui/win32/dialogs.c b/Gui/win32/dialogs.c
new file mode 100644
index 0000000000..815aab0cc1
--- /dev/null
+++ b/Gui/win32/dialogs.c
@@ -0,0 +1,1142 @@
+/*
+ MPlayer Gui for win32
+ Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de>
+ Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com>
+ Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ 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., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
+*/
+
+#include <windows.h>
+#include <commctrl.h>
+#include <interface.h>
+#include <mp_msg.h>
+#include <help_mp.h>
+#include <libmpdemux/stream.h>
+#include <libmpdemux/demuxer.h>
+#include <libmpdemux/stheader.h>
+#include "gui.h"
+#include "wincfg.h"
+#include "dialogs.h"
+
+WNDPROC OldUrlWndProc;
+LRESULT CALLBACK SubUrlWndProc(HWND, UINT, WPARAM, LPARAM);
+extern int vo_gamma_brightness;
+extern int vo_gamma_saturation;
+extern int vo_gamma_contrast;
+extern int vo_gamma_hue;
+extern int set_video_colors(sh_video_t *sh_video, char *item, int value);
+extern int get_video_colors(sh_video_t *sh_video, char *item, int *value);
+
+guiInterface_t guiIntfStruct;
+int addurl = 0;
+
+#ifdef USE_SUB
+extern mp_osd_obj_t* vo_osd_list;
+extern char **sub_name;
+
+void guiLoadSubtitle(char *name)
+{
+ if (!guiIntfStruct.Playing)
+ {
+ guiIntfStruct.SubtitleChanged = 1;
+ return;
+ }
+ if (subdata)
+ {
+ mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);
+ sub_free(subdata);
+ subdata = NULL;
+ vo_sub = NULL;
+ if (vo_osd_list)
+ {
+ int len;
+ mp_osd_obj_t *osd = vo_osd_list;
+ while (osd)
+ {
+ if (osd->type == OSDTYPE_SUBTITLE) break;
+ osd = osd->next;
+ }
+ if (osd && osd->flags & OSDFLAG_VISIBLE)
+ {
+ len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
+ memset(osd->bitmap_buffer, 0, len);
+ memset(osd->alpha_buffer, 0, len);
+ }
+ }
+ }
+
+ if (name)
+ {
+ mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);
+ subdata = sub_read_file(strdup(name), guiIntfStruct.FPS);
+ if (!subdata) mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub,name);
+ sub_name = (malloc(2 * sizeof(char*))); /* when mplayer will be restarted */
+ sub_name[0] = strdup(name); /* sub_name[0] will be read */
+ sub_name[1] = NULL;
+ }
+ update_set_of_subtitles();
+}
+#endif
+
+int display_openfilewindow(gui_t *gui, int add)
+{
+ OPENFILENAME fileopen;
+ int result = 0;
+ char filelist[MAXFILE];
+ char filename[MAX_PATH];
+ char directory[MAX_PATH];
+ char *filespec = NULL;
+ char *filepart = NULL;
+
+ memset(&fileopen, 0, sizeof(OPENFILENAME));
+ memset(filelist, 0, sizeof(filelist));
+
+ fileopen.lStructSize = sizeof(OPENFILENAME);
+ fileopen.hwndOwner = gui->mainwindow;
+ fileopen.hInstance = GetModuleHandle(NULL);
+ fileopen.lpstrFilter = "All Files (*.*)\0*.*\0"
+ "Media Files (*.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
+ *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg)\0\
+ *.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
+ *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg\0"
+ "Video Files (*.avi;*.mpg;*.mpeg;*.mov)\0*.avi;*.mpg;*.mpeg;*.mov\0"
+ "Avisynth Scripts (*.avs)\0*.avs\0"
+ "Audio Files (*.mp3;*.wav;*.ra)\0*.mp3;*.wav;*.ra\000";
+ fileopen.nFilterIndex = 0;
+ fileopen.lpstrTitle = "Add file(s)...";
+ fileopen.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST| OFN_LONGNAMES | OFN_EXPLORER| OFN_READONLY | OFN_HIDEREADONLY;
+ fileopen.lpstrFile = filelist;
+ fileopen.lpstrCustomFilter = NULL;
+ fileopen.nMaxFile = MAXFILE;
+
+ if(GetOpenFileName(&fileopen))
+ {
+ /* clear playlist */
+ if(!add) gui->playlist->clear_playlist(gui->playlist);
+
+ memcpy(directory, fileopen.lpstrFile, fileopen.nFileOffset - 1);
+ directory[fileopen.nFileOffset - 1] = 0;
+
+ do
+ {
+ filespec = &fileopen.lpstrFile[fileopen.nFileOffset];
+ filename[0] = 0;
+ strcat(filename, directory);
+ strcat(filename, "\\");
+ strcat(filename, filespec);
+
+ if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)
+ mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename);
+ else
+ {
+ if (GetFullPathName(filename, MAX_PATH, filename, &filepart))
+ {
+ if(!parse_filename(filename, playtree, mconfig, add? 0 : 1))
+ gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0);
+ mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename);
+ result++;
+ }
+ }
+ fileopen.nFileOffset += strlen(filespec) + 1;
+ } while (*filespec);
+ }
+ return result;
+}
+
+#ifdef USE_SUB
+void display_opensubtitlewindow(gui_t *gui)
+{
+ OPENFILENAME subtitleopen;
+ char subtitlefile[MAX_PATH];
+
+ /* Safety check */
+ if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return;
+
+ memset(&subtitleopen, 0, sizeof(OPENFILENAME));
+ memset(subtitlefile, 0, sizeof(subtitlefile));
+
+ subtitleopen.lStructSize = sizeof(OPENFILENAME);
+ subtitleopen.hwndOwner = gui->mainwindow;
+ subtitleopen.hInstance = GetModuleHandle(NULL);
+ subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0"
+ "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0";
+ subtitleopen.nFilterIndex = 0;
+ subtitleopen.lpstrTitle = "Add Subtitle...";
+ subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
+ subtitleopen.lpstrFile = subtitlefile;
+ subtitleopen.lpstrCustomFilter = NULL;
+ subtitleopen.nMaxFile = MAXFILE;
+
+ if(GetOpenFileName(&subtitleopen))
+ guiLoadSubtitle(subtitlefile);
+}
+#endif
+
+void display_loadplaylistwindow(gui_t *gui)
+{
+ OPENFILENAME playlistopen;
+ char playlistfile[MAX_PATH];
+
+ memset(&playlistopen, 0, sizeof(OPENFILENAME));
+ memset(playlistfile, 0, sizeof(playlistfile));
+
+ playlistopen.lStructSize = sizeof(OPENFILENAME);
+ playlistopen.hwndOwner = gui->mainwindow;
+ playlistopen.hInstance = GetModuleHandle(NULL);
+ playlistopen.lpstrFilter = "All Files (*.*)\0*.*\0"
+ "Playlist Files (*.m3u;*.pls;*.txt)\0*.m3u;*.pls;*.txt\0";
+ playlistopen.nFilterIndex = 0;
+ playlistopen.lpstrTitle = "Load Playlist...";
+ playlistopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
+ playlistopen.lpstrFile = playlistfile;
+ playlistopen.lpstrCustomFilter = NULL;
+ playlistopen.nMaxFile = MAXFILE;
+
+ if(GetOpenFileName(&playlistopen))
+ {
+ if(parse_filename(playlistfile, playtree, mconfig, 1))
+ gui->startplay(gui);
+ }
+}
+
+void display_saveplaylistwindow(gui_t* gui)
+{
+ OPENFILENAME playlistsave;
+ static FILE *playlist_file = NULL;
+ char playlistname[MAX_PATH];
+
+ memset(&playlistsave, 0, sizeof(OPENFILENAME));
+ memset(playlistname, 0, sizeof(playlistname));
+
+ playlistsave.lStructSize = sizeof(OPENFILENAME);
+ playlistsave.hwndOwner = gui->mainwindow;
+ playlistsave.hInstance = GetModuleHandle(NULL);
+ playlistsave.lpstrFilter = "Playlist Files (*.pls)\0*.pls\0";
+ playlistsave.nFilterIndex = 0;
+ playlistsave.lpstrTitle = "Save Playlist...";
+ playlistsave.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+ playlistsave.lpstrFile = playlistname;
+ playlistsave.lpstrCustomFilter = NULL;
+ playlistsave.nMaxFile = MAXFILE;
+
+ if(GetSaveFileName(&playlistsave))
+ {
+ int i=0;
+ HANDLE my_playlist;
+
+ if(!strstr(playlistname, ".pls")) strcat(playlistname, ".pls");
+
+ my_playlist = CreateFile(playlistname,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
+ NULL);
+
+ if(my_playlist != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(my_playlist); /* close the file first so we can write to it */
+ playlist_file = fopen(playlistsave.lpstrFile, "w");
+ fprintf(playlist_file, "[playlist]\n");
+ fprintf(playlist_file, "numberofentries=%d\n", gui->playlist->trackcount);
+
+ for(i=0; i<(gui->playlist->trackcount); i++)
+ {
+ fprintf(playlist_file, "File%i=%s\n", i + 1, gui->playlist->tracks[i]->filename);
+ fprintf(playlist_file, "Length%i=-1\n", i + 1);
+ }
+ fclose(playlist_file);
+ }
+ }
+}
+
+static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
+{
+ static HWND url;
+ HWND wdg;
+ FILE *f;
+ char *history = get_path("gui.url");
+ gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ switch (iMsg)
+ {
+ case WM_CREATE:
+ wdg = CreateWindow("button", "Ok",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 43, 80, 25, hwnd,
+ (HMENU) ID_OK,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
+
+ wdg = CreateWindow("button", "Cancel",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 90, 43, 80, 25, hwnd,
+ (HMENU) ID_CANCEL,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
+
+ url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE,
+ "edit", NULL,
+ WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
+ 4, 10, 300, 25, hwnd,
+ (HMENU) ID_URL,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
+ SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0);
+
+ /*subclass the edit box to capture the VK_RETURN key*/
+ OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc);
+
+ if((f = fopen(history, "r")))
+ {
+ char lasturl[MAX_PATH];
+ fgets(lasturl, MAX_PATH, f);
+ SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl);
+ SendMessage(url, EM_SETSEL, 0, -1);
+ fclose(f);
+ }
+ break;
+ case WM_KEYDOWN:
+ switch (LOWORD(wParam))
+ {
+ case VK_RETURN:
+ SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0);
+ break;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case ID_CANCEL:
+ DestroyWindow(hwnd);
+ return 0;
+ case ID_OK:
+ {
+ char file[MAX_PATH];
+ SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file);
+ mplSetFileName(NULL, file, STREAMTYPE_STREAM);
+ if((f = fopen(history, "wt+")))
+ {
+ fprintf(f, file);
+ fclose(f);
+ }
+ if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1))
+ gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0);
+ if(!addurl)
+ gui->startplay(gui);
+ else update_playlistwindow();
+ DestroyWindow(hwnd);
+ }
+ break;
+ }
+ }
+ return 0;
+ case WM_DESTROY:
+ {
+ PostQuitMessage (0);
+ addurl = 0;
+ return 0;
+ }
+ }
+ return DefWindowProc(hwnd, iMsg, wParam, lParam);
+}
+
+LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch(iMsg)
+ {
+ case WM_KEYDOWN:
+ switch (LOWORD(wParam))
+ {
+ case VK_RETURN:
+ SendMessage(FindWindow(NULL, "MPlayer - Open URL..."), WM_COMMAND, (WPARAM) ID_OK, 0);
+ break;
+ }
+ }
+ return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam);
+}
+
+void display_openurlwindow(gui_t *gui, int add)
+{
+ if(add) addurl = 1;
+ HWND hWnd;
+ HINSTANCE hInstance = GetModuleHandle(NULL);
+ WNDCLASS wc;
+ int x, y;
+ if(FindWindow(NULL, "MPlayer - Open URL...")) return;
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = OpenUrlWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hCursor = LoadCursor(NULL,IDC_ARROW);
+ wc.hIcon = gui->icon;
+ wc.hbrBackground = SOLID_GREY2;
+ wc.lpszClassName = "MPlayer - URL";
+ wc.lpszMenuName = NULL;
+ RegisterClass(&wc);
+ x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2);
+ y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
+ hWnd = CreateWindow("MPlayer - URL",
+ "MPlayer - Open URL...",
+ WS_POPUPWINDOW | WS_CAPTION,
+ x,
+ y,
+ 320,
+ 100,
+ NULL,
+ NULL,
+ hInstance,
+ NULL);
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
+ ShowWindow(hWnd, SW_SHOW);
+ UpdateWindow(hWnd);
+}
+
+static void create_playlistmenu(gui_t *gui)
+{
+ gui->playlistmenu = CreatePopupMenu();
+ AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File...");
+ AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url...");
+ AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
+ AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected");
+ AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist");
+ AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
+ AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close");
+}
+
+static void updatetracklist(HWND hwnd)
+{
+ int i=0;
+ gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST);
+ /* clear listbox */
+ SendMessage(tracklist, LB_RESETCONTENT, 0, 0);
+ for (i=0; i < gui->playlist->trackcount; i++)
+ if (gui->playlist->tracks[i]->title)
+ SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title);
+ else
+ SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename);
+}
+
+static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
+{
+ HWND wdg;
+ POINT cursor;
+ gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ playlist_t *pl = gui ? gui->playlist : NULL;
+ switch (iMsg)
+ {
+ case WM_CREATE:
+ {
+ wdg = CreateWindow("button", "Play",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 10, 80, 25, hwnd,
+ (HMENU) ID_PLAY,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
+
+ wdg = CreateWindow ("button", "Up",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 37, 80, 25, hwnd,
+ (HMENU) ID_UP,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
+
+ wdg = CreateWindow ("button", "Down",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 64, 80, 25, hwnd,
+ (HMENU) ID_DOWN,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
+
+ wdg = CreateWindow ("button", "Remove",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 91, 80, 25, hwnd,
+ (HMENU) ID_REMOVE,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
+
+ wdg = CreateWindow ("button", "Load",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 118, 80, 25, hwnd,
+ (HMENU) ID_PLAYLISTLOAD,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
+
+ wdg = CreateWindow ("button", "Save",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 145, 80, 25, hwnd,
+ (HMENU) ID_PLAYLISTSAVE,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
+
+ wdg = CreateWindow ("button", "Close",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 4, 193, 80, 25, hwnd,
+ (HMENU) ID_CLOSE,
+ ((LPCREATESTRUCT) lParam) -> hInstance,
+ NULL);
+ SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
+<