1 /*****************************************************************************
2 * kde.cpp : KDE plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: kde.cpp,v 1.1 2002/08/04 17:23:43 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 *****************************************************************************/
26 #include "interface.h"
32 #include <kaboutdata.h>
33 #include <kcmdlineargs.h>
35 #include <kmainwindow.h>
36 #include <kstdaction.h>
39 /*****************************************************************************
41 *****************************************************************************/
48 KThread ( KThread &thread ) { };
49 KThread &operator= ( KThread &thread ) { return ( *this ); };
51 intf_thread_t *p_intf;
54 KThread(intf_thread_t *p_intf);
57 // These methods get exported to the core
58 static int open ( vlc_object_t * );
59 static void close ( vlc_object_t * );
60 static void run ( intf_thread_t * );
63 /*****************************************************************************
65 *****************************************************************************/
70 int i = getenv( "DISPLAY" ) == NULL ? 8 : 85;
72 set_description( _("KDE interface module") );
73 set_capability( "interface", i );
74 set_program( "kvlc" );
75 //set_callbacks( E_(Open), E_(Close) );
76 set_callbacks( KThread::open, KThread::close );
79 /*****************************************************************************
80 * KThread::KThread: KDE interface constructor
81 *****************************************************************************/
82 KThread::KThread(intf_thread_t *p_intf)
84 this->p_intf = p_intf;
86 p_intf->p_sys->p_about =
87 new KAboutData( "VideoLAN Client", I18N_NOOP("Kvlc"), VERSION,
88 _("This is the VideoLAN client, a DVD and MPEG player. It can play "
89 "MPEG and MPEG 2 files from a file or from a network source."),
90 KAboutData::License_GPL,
91 _("(C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 - the VideoLAN Team"),
94 char *authors[][2] = {
95 { "the VideoLAN Team", "<videolan@videolan.org>" },
99 for ( int i = 0; NULL != authors[i][0]; i++ ) {
100 p_intf->p_sys->p_about->addAuthor( authors[i][0], 0, authors[i][1] );
104 char *argv[] = { p_intf->p_vlc->psz_object_name, NULL };
105 KCmdLineArgs::init( argc, argv, p_intf->p_sys->p_about );
107 p_intf->p_sys->p_app = new KApplication();
108 p_intf->p_sys->p_window = new KInterface(p_intf);
109 p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (KDE interface)" );
111 p_intf->p_sys->p_input = NULL;
114 /*****************************************************************************
115 * KThread::~KThread: KDE interface destructor
116 *****************************************************************************/
119 if( p_intf->p_sys->p_input )
121 vlc_object_release( p_intf->p_sys->p_input );
124 /* XXX: can be deleted if the user closed the window ! */
125 //delete p_intf->p_sys->p_window;
127 delete p_intf->p_sys->p_app;
128 delete p_intf->p_sys->p_about;
131 /*****************************************************************************
132 * KThread::open: initialize and create window
133 *****************************************************************************/
134 int KThread::open(vlc_object_t *p_this)
136 intf_thread_t *p_intf = (intf_thread_t *)p_this;
138 /* Allocate instance and initialize some members */
139 p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
140 if( p_intf->p_sys == NULL )
142 msg_Err( p_intf, "out of memory" );
146 p_intf->pf_run = KThread::run;
148 p_intf->p_sys->p_thread = new KThread(p_intf);
152 /*****************************************************************************
153 * KThread::close: destroy interface window
154 *****************************************************************************/
155 void KThread::close(vlc_object_t *p_this)
157 intf_thread_t *p_intf = (intf_thread_t *)p_this;
159 delete p_intf->p_sys->p_thread;
160 free( p_intf->p_sys );
163 /*****************************************************************************
164 * KThread::run: KDE thread
165 *****************************************************************************
166 * This part of the interface is in a separate thread so that we can call
167 * exec() from within it without annoying the rest of the program.
168 *****************************************************************************/
169 void KThread::run(intf_thread_t *p_intf)
171 p_intf->p_sys->p_window->show();
172 p_intf->p_sys->p_app->exec();