1 /*****************************************************************************
2 * kde.cpp : KDE plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: kde.cpp,v 1.11 2002/04/04 15:35:09 sam Exp $
7 * Authors: Andres Krapf <dae@chez.com> Sun Mar 25 2001
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.
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.
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, USA.
22 *****************************************************************************/
24 #include "kde_common.h"
26 #include "kde_interface.h"
32 #include <kaboutdata.h>
33 #include <kcmdlineargs.h>
35 #include <kmainwindow.h>
36 #include <kstdaction.h>
39 /*****************************************************************************
40 * Capabilities defined in the other files.
41 *****************************************************************************/
42 static void intf_getfunctions( function_list_t * p_function_list );
44 /*****************************************************************************
45 * Build configuration tree.
46 *****************************************************************************/
54 SET_DESCRIPTION( "KDE interface module" )
56 if( getenv( "DISPLAY" ) == NULL )
58 ADD_CAPABILITY( INTF, 8 )
63 ADD_CAPABILITY( INTF, 85 )
70 intf_getfunctions( &p_module->p_functions->intf );
73 MODULE_DEACTIVATE_START
74 MODULE_DEACTIVATE_STOP
78 /*****************************************************************************
80 *****************************************************************************/
87 KThread ( KThread &thread ) { };
88 KThread &operator= ( KThread &thread ) { return ( *this ); };
90 intf_thread_t *p_intf;
93 KThread(intf_thread_t *p_intf);
96 // These methods get exported to the core
97 static int open ( intf_thread_t *p_intf );
98 static void close ( intf_thread_t *p_intf );
99 static void run ( intf_thread_t *p_intf );
102 /*****************************************************************************
103 * Functions exported as capabilities.
104 *****************************************************************************/
105 static void intf_getfunctions( function_list_t * p_function_list )
107 p_function_list->functions.intf.pf_open = KThread::open;
108 p_function_list->functions.intf.pf_close = KThread::close;
109 p_function_list->functions.intf.pf_run = KThread::run;
112 /*****************************************************************************
113 * KThread::KThread: KDE interface constructor
114 *****************************************************************************/
115 KThread::KThread(intf_thread_t *p_intf)
117 this->p_intf = p_intf;
119 p_intf->p_sys->p_about =
120 new KAboutData( "VideoLAN Client", I18N_NOOP("Kvlc"), VERSION,
121 "This is the VideoLAN client, a DVD and MPEG player. It can play MPEG and MPEG 2 files from a file or from a network source.", KAboutData::License_GPL,
122 "(C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 - the VideoLAN Team", 0, 0, "dae@chez.com");
124 char *authors[][2] = {
125 { "the VideoLAN Team", "<videolan@videolan.org>" },
129 for ( int i = 0; NULL != authors[i][0]; i++ ) {
130 p_intf->p_sys->p_about->addAuthor( authors[i][0], 0, authors[i][1] );
134 char *argv[] = { p_main->psz_arg0, NULL };
135 KCmdLineArgs::init( argc, argv, p_intf->p_sys->p_about );
137 p_intf->p_sys->p_app = new KApplication();
138 p_intf->p_sys->p_window = new KInterface(p_intf);
139 p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (KDE interface)" );
142 /*****************************************************************************
143 * KThread::~KThread: KDE interface destructor
144 *****************************************************************************/
147 /* XXX: can be deleted if the user closed the window ! */
148 //delete p_intf->p_sys->p_window;
150 delete p_intf->p_sys->p_app;
151 delete p_intf->p_sys->p_about;
154 /*****************************************************************************
155 * KThread::open: initialize and create window
156 *****************************************************************************/
157 int KThread::open(intf_thread_t *p_intf)
159 /* Allocate instance and initialize some members */
160 p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
161 if( p_intf->p_sys == NULL )
163 intf_ErrMsg( "intf error: %s", strerror(ENOMEM) );
167 p_intf->p_sys->p_thread = new KThread(p_intf);
171 /*****************************************************************************
172 * KThread::close: destroy interface window
173 *****************************************************************************/
174 void KThread::close(intf_thread_t *p_intf)
176 delete p_intf->p_sys->p_thread;
177 free( p_intf->p_sys );
180 /*****************************************************************************
181 * KThread::run: KDE thread
182 *****************************************************************************
183 * This part of the interface is in a separate thread so that we can call
184 * exec() from within it without annoying the rest of the program.
185 *****************************************************************************/
186 void KThread::run(intf_thread_t *p_intf)
188 p_intf->p_sys->p_window->show();
189 p_intf->p_sys->p_app->exec();