* modules/gui/skins/src/*: oops, forgot to add a bunch of files.
authorGildas Bazin <gbazin@videolan.org>
Tue, 3 Jun 2003 22:20:00 +0000 (22:20 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 3 Jun 2003 22:20:00 +0000 (22:20 +0000)
modules/gui/skins/src/dialogs.cpp [new file with mode: 0644]
modules/gui/skins/src/dialogs.h [new file with mode: 0644]

diff --git a/modules/gui/skins/src/dialogs.cpp b/modules/gui/skins/src/dialogs.cpp
new file mode 100644 (file)
index 0000000..b44e7a2
--- /dev/null
@@ -0,0 +1,333 @@
+/*****************************************************************************\r
+ * dialogs.cpp: Handles all the different dialog boxes we provide.\r
+ *****************************************************************************\r
+ * Copyright (C) 2003 VideoLAN\r
+ * $Id: dialogs.cpp,v 1.1 2003/06/03 22:20:00 gbazin Exp $\r
+ *\r
+ * Authors: Olivier Teulière <ipkiss@via.ecp.fr>\r
+ *          Emmanuel Puig    <karibu@via.ecp.fr>\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,\r
+ * USA.\r
+ *****************************************************************************/\r
+\r
+//--- VLC -------------------------------------------------------------------\r
+#include <vlc/vlc.h>\r
+#include <vlc/intf.h>\r
+\r
+//--- SKIN ------------------------------------------------------------------\r
+#include "../os_api.h"\r
+#include "event.h"\r
+#include "banks.h"\r
+#include "theme.h"\r
+#include "../os_theme.h"\r
+#include "themeloader.h"\r
+#include "window.h"\r
+#include "vlcproc.h"\r
+#include "skin_common.h"\r
+#include "dialogs.h"\r
+\r
+#ifdef BASIC_SKINS\r
+\r
+// Constructor\r
+Dialogs::Dialogs( intf_thread_t *_p_intf ){}\r
+// Destructor\r
+Dialogs::~Dialogs(){}\r
+\r
+void Dialogs::ShowOpen( bool b_play ){}\r
+void Dialogs::ShowMessages(){}\r
+void Dialogs::ShowPrefs(){}\r
+void Dialogs::ShowFileInfo(){}\r
+\r
+#else // BASIC_SKINS\r
+\r
+#include "../../wxwindows/wxwindows.h"\r
+#include "share/vlc32x32.xpm"       // include the graphic icon\r
+\r
+#define ShowOpen_Event     0\r
+#define ShowMessages_Event 1\r
+#define ShowPrefs_Event    2\r
+#define ShowFileInfo_Event 3\r
+#define ExitThread_Event   99\r
+\r
+//---------------------------------------------------------------------------\r
+// Local classes declarations.\r
+//---------------------------------------------------------------------------\r
+\r
+DEFINE_EVENT_TYPE(wxEVT_DIALOG)\r
+\r
+class Instance: public wxApp\r
+{\r
+public:\r
+    Instance();\r
+#ifdef GTK2_SKINS\r
+    Instance( intf_thread_t *_p_intf, CallBackObjects *callback );\r
+#else\r
+    Instance( intf_thread_t *_p_intf );\r
+#endif\r
+\r
+    bool OnInit();\r
+    int  OnExit();\r
+\r
+private:\r
+    intf_thread_t *p_intf;\r
+\r
+#ifdef GTK2_SKINS\r
+    CallBackObjects *callbackobj;\r
+#endif\r
+\r
+    DECLARE_EVENT_TABLE();\r
+};\r
+\r
+BEGIN_EVENT_TABLE(Instance, wxApp)\r
+    EVT_COMMAND(ShowOpen_Event, wxEVT_DIALOG, Dialogs::OnShowOpen)\r
+    EVT_COMMAND(ShowMessages_Event, wxEVT_DIALOG, Dialogs::OnShowMessages)\r
+    EVT_COMMAND(ShowPrefs_Event, wxEVT_DIALOG, Dialogs::OnShowPrefs)\r
+    EVT_COMMAND(ShowFileInfo_Event, wxEVT_DIALOG, Dialogs::OnShowFileInfo)\r
+    EVT_COMMAND(ExitThread_Event, wxEVT_DIALOG, Dialogs::OnExitThread)\r
+END_EVENT_TABLE()\r
+\r
+//---------------------------------------------------------------------------\r
+// Implementation of Instance class\r
+//---------------------------------------------------------------------------\r
+Instance::Instance( )\r
+{\r
+}\r
+\r
+#ifdef GTK2_SKINS\r
+Instance::Instance( intf_thread_t *_p_intf, CallBackObjects *callback )\r
+{\r
+    // Initialization\r
+    p_intf = _p_intf;\r
+    callbackobj = callback;\r
+}\r
+#else\r
+Instance::Instance( intf_thread_t *_p_intf )\r
+{\r
+    // Initialization\r
+    p_intf = _p_intf;\r
+}\r
+#endif\r
+\r
+IMPLEMENT_APP_NO_MAIN(Instance)\r
+\r
+bool Instance::OnInit()\r
+{\r
+    p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );\r
+\r
+#ifdef GTK2_SKINS\r
+    // Set event callback. Yes, it's a big hack ;)\r
+    gdk_event_handler_set( GTK2Proc, (gpointer)callbackobj, NULL );\r
+#endif\r
+\r
+    // Create all the dialog boxes\r
+    p_intf->p_sys->p_dialogs->OpenDlg =\r
+        new OpenDialog( p_intf, NULL, FILE_ACCESS );\r
+    p_intf->p_sys->p_dialogs->MessagesDlg = new Messages( p_intf, NULL );\r
+    p_intf->p_sys->p_dialogs->PrefsDlg = new PrefsDialog( p_intf, NULL );\r
+    p_intf->p_sys->p_dialogs->FileInfoDlg = new FileInfo( p_intf, NULL );\r
+\r
+#ifdef GTK2_SKINS\r
+    // Add timer\r
+    g_timeout_add( 200, (GSourceFunc)RefreshTimer, (gpointer)p_intf );\r
+#endif\r
+\r
+    // OK, initialization is over, now the other thread can go on working...\r
+    vlc_thread_ready( p_intf );\r
+\r
+    return TRUE;\r
+}\r
+\r
+int Instance::OnExit()\r
+{\r
+    // Delete evertything\r
+    delete p_intf->p_sys->p_dialogs->FileInfoDlg;\r
+    delete p_intf->p_sys->p_dialogs->PrefsDlg;\r
+    delete p_intf->p_sys->p_dialogs->MessagesDlg;\r
+    delete p_intf->p_sys->p_dialogs->OpenDlg;\r
+    delete p_intf->p_sys->p_icon;\r
+\r
+    return 0;\r
+}\r
+\r
+//---------------------------------------------------------------------------\r
+#if !defined(__BUILTIN__) && defined( WIN32 )\r
+HINSTANCE hInstance = 0;\r
+extern "C" BOOL WINAPI\r
+DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)\r
+{\r
+    hInstance = (HINSTANCE)hModule;\r
+    return TRUE;\r
+}\r
+#endif\r
+\r
+//---------------------------------------------------------------------------\r
+// Thread callback\r
+// We create all wxWindows dialogs in a separate thread because we don't want\r
+// any interaction with our own message loop\r
+//---------------------------------------------------------------------------\r
+void SkinsDialogsThread( intf_thread_t *p_intf )\r
+{\r
+#if !defined( WIN32 )\r
+    static char  *p_args[] = { "" };\r
+#endif\r
+\r
+    /* Hack to pass the p_intf pointer to the new wxWindow Instance object */\r
+    wxTheApp = new Instance( p_intf );\r
+\r
+#if defined( WIN32 )\r
+#if !defined(__BUILTIN__)\r
+    wxEntry( hInstance/*GetModuleHandle(NULL)*/, NULL, NULL, SW_SHOW, TRUE );\r
+#else\r
+    wxEntry( GetModuleHandle( NULL ), NULL, NULL, SW_SHOW, TRUE );\r
+#endif\r
+#else\r
+    wxEntry( 1, p_args );\r
+#endif\r
+\r
+    return;\r
+}\r
+\r
+//---------------------------------------------------------------------------\r
+// Implementation of Dialogs class\r
+//---------------------------------------------------------------------------\r
+Dialogs::Dialogs( intf_thread_t *_p_intf )\r
+{\r
+    p_intf = _p_intf;\r
+    p_intf->p_sys->p_dialogs = this;\r
+\r
+    // Create a new thread for wxWindows\r
+    if( vlc_thread_create( p_intf, "Skins Dialogs Thread", SkinsDialogsThread,\r
+                           0, VLC_TRUE ) )\r
+    {\r
+        OpenDlg = NULL;\r
+        msg_Err( p_intf, "cannot create SkinsDialogsThread" );\r
+    }\r
+}\r
+\r
+Dialogs::~Dialogs()\r
+{\r
+    wxCommandEvent event( wxEVT_DIALOG, ExitThread_Event );\r
+    event.SetClientData( this );\r
+\r
+    wxTheApp->AddPendingEvent( event );\r
+\r
+    vlc_thread_join( p_intf ); //FIXME, use own vlc_object\r
+}\r
+\r
+void Dialogs::ShowOpen( bool b_play )\r
+{\r
+    wxCommandEvent event( wxEVT_DIALOG, ShowOpen_Event );\r
+    event.SetClientData( this );\r
+    event.SetInt( b_play );\r
+\r
+    wxTheApp->AddPendingEvent( event );\r
+}\r
+\r
+void Dialogs::ShowMessages()\r
+{\r
+    wxCommandEvent event( wxEVT_DIALOG, ShowMessages_Event );\r
+    event.SetClientData( this );\r
+\r
+    wxTheApp->AddPendingEvent( event );\r
+}\r
+\r
+void Dialogs::ShowPrefs()\r
+{\r
+    wxCommandEvent event( wxEVT_DIALOG, ShowPrefs_Event );\r
+    event.SetClientData( this );\r
+\r
+    wxTheApp->AddPendingEvent( event );\r
+}\r
+\r
+void Dialogs::ShowFileInfo()\r
+{\r
+    wxCommandEvent event( wxEVT_DIALOG, ShowFileInfo_Event );\r
+    event.SetClientData( this );\r
+\r
+    wxTheApp->AddPendingEvent( event );\r
+}\r
+\r
+void Dialogs::OnShowOpen( wxCommandEvent& event )\r
+{\r
+    Dialogs *p_dialogs = (Dialogs *)event.GetClientData();\r
+    bool b_play = event.GetInt() ? TRUE : FALSE;\r
+\r
+    //p_dialogs->OpenDlg->Show( !p_dialogs->OpenDlg->IsShown() );\r
\r
+    if( p_dialogs->OpenDlg->ShowModal() != wxID_OK )\r
+    {\r
+        return;\r
+    }\r
+\r
+    // Check if playlist is available\r
+    playlist_t *p_playlist = p_dialogs->p_intf->p_sys->p_playlist;\r
+    if( p_playlist == NULL )\r
+    {\r
+        return;\r
+    }\r
+\r
+    if( b_play )\r
+    {\r
+        // Append and play\r
+        for( size_t i = 0; i < p_dialogs->OpenDlg->mrl.GetCount(); i++ )\r
+        {\r
+            playlist_Add( p_playlist,\r
+                (const char *)p_dialogs->OpenDlg->mrl[i].mb_str(),\r
+                PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );\r
+        }\r
+        p_dialogs->p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();\r
+    }\r
+    else\r
+    {\r
+        // Append only\r
+        for( size_t i = 0; i < p_dialogs->OpenDlg->mrl.GetCount(); i++ )\r
+        {\r
+            playlist_Add( p_playlist,\r
+                (const char *)p_dialogs->OpenDlg->mrl[i].mb_str(),\r
+                PLAYLIST_APPEND, PLAYLIST_END );\r
+        }\r
+    }\r
+\r
+    // Refresh interface !\r
+    p_dialogs->p_intf->p_sys->p_theme->EvtBank->Get( "playlist_refresh" )\r
+        ->PostSynchroMessage();\r
+\r
+    return;\r
+}\r
+\r
+void Dialogs::OnShowMessages( wxCommandEvent& event )\r
+{\r
+    Dialogs *p_dialogs = (Dialogs *)event.GetClientData();\r
+    p_dialogs->MessagesDlg->Show( !p_dialogs->MessagesDlg->IsShown() );\r
+}\r
+\r
+void Dialogs::OnShowPrefs( wxCommandEvent& event )\r
+{\r
+    Dialogs *p_dialogs = (Dialogs *)event.GetClientData();\r
+    p_dialogs->PrefsDlg->Show( !p_dialogs->PrefsDlg->IsShown() );\r
+}\r
+\r
+void Dialogs::OnShowFileInfo( wxCommandEvent& event )\r
+{\r
+    Dialogs *p_dialogs = (Dialogs *)event.GetClientData();\r
+    p_dialogs->FileInfoDlg->Show( !p_dialogs->FileInfoDlg->IsShown() );\r
+}\r
+\r
+void Dialogs::OnExitThread( wxCommandEvent& event )\r
+{\r
+    wxTheApp->ExitMainLoop();\r
+}\r
+#endif // BASIC_SKINS\r
diff --git a/modules/gui/skins/src/dialogs.h b/modules/gui/skins/src/dialogs.h
new file mode 100644 (file)
index 0000000..4947408
--- /dev/null
@@ -0,0 +1,89 @@
+/*****************************************************************************\r
+ * dialogs.h: Dialogs class\r
+ *****************************************************************************\r
+ * Copyright (C) 2003 VideoLAN\r
+ * $Id: dialogs.h,v 1.1 2003/06/03 22:20:00 gbazin Exp $\r
+ *\r
+ * Authors: Gildas Bazin <gbazin@netcourrier.com>\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,\r
+ * USA.\r
+ *****************************************************************************/\r
+\r
+#ifndef VLC_SKIN_DIALOGS\r
+#define VLC_SKIN_DIALOGS\r
+\r
+//--- GENERAL ---------------------------------------------------------------\r
+#include <string>\r
+using namespace std;\r
+\r
+//---------------------------------------------------------------------------\r
+struct intf_thread_t;\r
+\r
+#ifndef BASIC_SKINS\r
+\r
+#ifdef WIN32                                               /* mingw32 hack */\r
+#   undef Yield\r
+#   undef CreateDialog\r
+#endif\r
+/* Let vlc take care of the i18n stuff */\r
+#define WXINTL_NO_GETTEXT_MACRO\r
+#include <wx/wx.h>\r
+\r
+class OpenDialog;\r
+class Messages;\r
+class SoutDialog;\r
+class PrefsDialog;\r
+class FileInfo;\r
+class wxIcon;\r
+#endif\r
+\r
+//---------------------------------------------------------------------------\r
+class Dialogs\r
+{\r
+    protected:\r
+        intf_thread_t *p_intf;\r
+\r
+    public:\r
+        // Constructor\r
+        Dialogs( intf_thread_t *_p_intf );\r
+\r
+        // Destructor\r
+        virtual ~Dialogs();\r
+\r
+        void ShowOpen( bool b_play );\r
+        void ShowMessages();\r
+        void ShowPrefs();\r
+        void ShowFileInfo();\r
+\r
+#ifndef BASIC_SKINS\r
+        // Dialogs\r
+        OpenDialog  *OpenDlg;\r
+        Messages    *MessagesDlg;\r
+        PrefsDialog *PrefsDlg;\r
+        FileInfo    *FileInfoDlg;\r
+\r
+        wxIcon      *p_icon;\r
+\r
+        void OnShowOpen( wxCommandEvent& event );\r
+        void OnShowMessages( wxCommandEvent& event );\r
+        void OnShowPrefs( wxCommandEvent& event );\r
+        void OnShowFileInfo( wxCommandEvent& event );\r
+        void OnExitThread( wxCommandEvent& event );\r
+#endif\r
+};\r
+//---------------------------------------------------------------------------\r
+\r
+#endif\r