]> git.sesse.net Git - vlc/blob - modules/gui/skins2/commands/cmd_dialogs.hpp
8bdb6edf43bd4a81fe3e94359ccbed0ea93d4e78
[vlc] / modules / gui / skins2 / commands / cmd_dialogs.hpp
1 /*****************************************************************************
2  * cmd_dialogs.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef CMD_DIALOGS_HPP
26 #define CMD_DIALOGS_HPP
27
28 #include "cmd_generic.hpp"
29 #include "../src/dialogs.hpp"
30 #include "cmd_change_skin.hpp"
31
32 #include <vlc_interaction.h>
33
34 template<int TYPE = 0> class CmdDialogs;
35
36 // XXX use an enum instead
37 typedef CmdDialogs<1> CmdDlgChangeSkin;
38 typedef CmdDialogs<2> CmdDlgFileSimple;
39 typedef CmdDialogs<3> CmdDlgFile;
40 typedef CmdDialogs<4> CmdDlgDisc;
41 typedef CmdDialogs<5> CmdDlgNet;
42 typedef CmdDialogs<6> CmdDlgMessages;
43 typedef CmdDialogs<7> CmdDlgPrefs;
44 typedef CmdDialogs<8> CmdDlgFileInfo;
45 typedef CmdDialogs<9> CmdDlgShowPopupMenu;
46 typedef CmdDialogs<10> CmdDlgHidePopupMenu;
47 typedef CmdDialogs<11> CmdDlgAdd;
48 typedef CmdDialogs<12> CmdDlgPlaylistLoad;
49 typedef CmdDialogs<13> CmdDlgPlaylistSave;
50 typedef CmdDialogs<14> CmdDlgDirectory;
51 typedef CmdDialogs<15> CmdDlgStreamingWizard;
52 typedef CmdDialogs<16> CmdDlgPlaytreeLoad;
53 typedef CmdDialogs<17> CmdDlgPlaytreeSave;
54
55
56 /// Generic "Open dialog" command
57 template<int TYPE>
58 class CmdDialogs: public CmdGeneric
59 {
60     public:
61         CmdDialogs( intf_thread_t *pIntf ): CmdGeneric( pIntf ) {}
62         virtual ~CmdDialogs() {}
63
64         /// This method does the real job of the command
65         virtual void execute()
66         {
67             /// Get the dialogs provider
68             Dialogs *pDialogs = Dialogs::instance( getIntf() );
69             if( pDialogs == NULL )
70             {
71                 return;
72             }
73
74             switch( TYPE )
75             {
76                 case 1:
77                     pDialogs->showChangeSkin();
78                     break;
79                 case 2:
80                     pDialogs->showFileSimple( true );
81                     break;
82                 case 3:
83                     pDialogs->showFile( true );
84                     break;
85                 case 4:
86                     pDialogs->showDisc( true );
87                     break;
88                 case 5:
89                     pDialogs->showNet( true );
90                     break;
91                 case 6:
92                     pDialogs->showMessages();
93                     break;
94                 case 7:
95                     pDialogs->showPrefs();
96                     break;
97                 case 8:
98                     pDialogs->showFileInfo();
99                     break;
100                 case 9:
101                     pDialogs->showPopupMenu( true );
102                     break;
103                 case 10:
104                     pDialogs->showPopupMenu( false );
105                     break;
106                 case 11:
107                     pDialogs->showFile( false );
108                     break;
109                 case 12:
110                     pDialogs->showPlaylistLoad();
111                     break;
112                 case 13:
113                     pDialogs->showPlaylistSave();
114                     break;
115                 case 14:
116                     pDialogs->showDirectory( true );
117                     break;
118                 case 15:
119                     pDialogs->showStreamingWizard();
120                     break;
121                 default:
122                     msg_Warn( getIntf(), "Unknown dialog type" );
123                     break;
124             }
125         }
126
127         /// Return the type of the command
128         virtual string getType() const { return "dialog"; }
129 };
130
131 class CmdInteraction: public CmdGeneric
132 {
133     public:
134         CmdInteraction( intf_thread_t *pIntf, interaction_dialog_t *
135                         p_dialog ): CmdGeneric( pIntf ), m_pDialog( p_dialog )
136         {}
137         virtual ~CmdInteraction() {}
138
139         /// This method does the real job of the command
140         virtual void execute()
141         {
142             if( m_pDialog->i_type == INTERACT_PROGRESS )
143             {
144                  /// \todo Handle progress in the interface
145             }
146             else
147             {
148                 /// Get the dialogs provider
149                 Dialogs *pDialogs = Dialogs::instance( getIntf() );
150                 if( pDialogs == NULL )
151                 {
152                     return;
153                 }
154                 pDialogs->showInteraction( m_pDialog );
155             }
156         }
157
158         virtual string getType() const { return "interaction"; }
159     private:
160         interaction_dialog_t *m_pDialog;
161 };
162
163 #endif