]> git.sesse.net Git - vlc/blob - modules/gui/skins/src/dialogs.cpp
* modules/gui/wxwindows/*: The wxwindows interface is now a "dialogs provider" module...
[vlc] / modules / gui / skins / src / dialogs.cpp
1 /*****************************************************************************
2  * dialogs.cpp: Handles all the different dialog boxes we provide.
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: dialogs.cpp,v 1.10 2003/07/17 17:30:40 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
22  * USA.
23  *****************************************************************************/
24
25 //--- VLC -------------------------------------------------------------------
26 #include <vlc/vlc.h>
27 #include <vlc/intf.h>
28
29 //--- SKIN ------------------------------------------------------------------
30 #include "../os_api.h"
31 #include "event.h"
32 #include "banks.h"
33 #include "theme.h"
34 #include "../os_theme.h"
35 #include "themeloader.h"
36 #include "window.h"
37 #include "vlcproc.h"
38 #include "skin_common.h"
39 #include "dialogs.h"
40
41 /* Callback prototype */
42 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
43                        vlc_value_t old_val, vlc_value_t new_val, void *param );
44
45 //---------------------------------------------------------------------------
46 // Implementation of Dialogs class
47 //---------------------------------------------------------------------------
48 Dialogs::Dialogs( intf_thread_t *_p_intf )
49 {
50     /* Errors while loading the dialogs provider are not fatal.
51      * Dialogs just won't be available. */
52
53     p_intf = _p_intf;
54     p_intf->p_sys->p_dialogs = this;
55     b_popup_change = VLC_FALSE;
56
57     /* Allocate descriptor */
58     p_provider = (intf_thread_t *)vlc_object_create( p_intf, VLC_OBJECT_INTF );
59     if( p_provider == NULL )
60     {
61         msg_Err( p_intf, "out of memory" );
62         return;
63     }
64
65     p_module = module_Need( p_provider, "dialogs provider", NULL );
66     if( p_module == NULL )
67     {
68         msg_Err( p_intf, "no suitable dialogs provider found" );
69         vlc_object_destroy( p_provider );
70         p_provider = NULL;
71         return;
72     }
73
74     /* Initialize dialogs provider
75      * (returns as soon as initialization is done) */
76     if( p_provider->pf_run ) p_provider->pf_run( p_provider );
77 }
78
79 Dialogs::~Dialogs()
80 {
81     if( p_provider && p_module )
82     {
83         module_Unneed( p_provider, p_module );
84         vlc_object_destroy( p_provider );
85     }
86 }
87
88 void Dialogs::ShowDialog( intf_thread_t *p_intf, int i_dialog_event,
89                           int i_arg )
90 {
91 }
92
93 void Dialogs::ShowOpen( bool b_play )
94 {
95     if( p_provider && p_provider->pf_show_dialog )
96         p_provider->pf_show_dialog( p_provider, INTF_DIALOG_FILE, b_play );
97 }
98
99 void Dialogs::ShowOpenSkin()
100 {
101     if( p_provider && p_provider->pf_show_dialog )
102         p_provider->pf_show_dialog( p_provider, INTF_DIALOG_FILE, 0 );
103 }
104
105 void Dialogs::ShowMessages()
106 {
107     if( p_provider && p_provider->pf_show_dialog )
108         p_provider->pf_show_dialog( p_provider, INTF_DIALOG_MESSAGES, 0 );
109 }
110
111 void Dialogs::ShowPrefs()
112 {
113     if( p_provider && p_provider->pf_show_dialog )
114         p_provider->pf_show_dialog( p_provider, INTF_DIALOG_PREFS, 0 );
115 }
116
117 void Dialogs::ShowFileInfo()
118 {
119     if( p_provider && p_provider->pf_show_dialog )
120         p_provider->pf_show_dialog( p_provider, INTF_DIALOG_FILEINFO, 0 );
121 }
122
123 void Dialogs::ShowPopup()
124 {
125 }
126
127 /*****************************************************************************
128  * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
129  *  We don't show the menu directly here because we don't want the
130  *  caller to block for a too long time.
131  *****************************************************************************/
132 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
133                         vlc_value_t old_val, vlc_value_t new_val, void *param )
134 {
135     Dialogs *p_dialogs = (Dialogs *)param;
136     p_dialogs->ShowPopup();
137
138     return VLC_SUCCESS;
139 }