]> git.sesse.net Git - vlc/blob - plugins/kde/kde.cpp
* ./po/no.po: Norwegian translation by Sigmund Augdal. Berd� ka p� t�t.
[vlc] / plugins / kde / kde.cpp
1 /*****************************************************************************
2  * kde.cpp : KDE plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: kde.cpp,v 1.8 2002/03/01 16:07:00 sam Exp $
6  *
7  * Authors: Andres Krapf <dae@chez.com> Sun Mar 25 2001
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, USA.
22  *****************************************************************************/
23
24 #include "kde_common.h"
25
26 #include "kde_interface.h"
27
28 #include <iostream>
29
30 #include <kaction.h>
31 #include <kapp.h>
32 #include <kaboutdata.h>
33 #include <kcmdlineargs.h>
34 #include <klocale.h>
35 #include <kmainwindow.h>
36 #include <kstdaction.h>
37 #include <qwidget.h>
38
39 /*****************************************************************************
40  * Capabilities defined in the other files.
41  *****************************************************************************/
42 static void intf_getfunctions( function_list_t * p_function_list );
43
44 /*****************************************************************************
45  * Build configuration tree.
46  *****************************************************************************/
47 extern "C"
48 {
49
50 MODULE_CONFIG_START
51 MODULE_CONFIG_STOP
52
53 MODULE_INIT_START
54     SET_DESCRIPTION( "KDE interface module" )
55     ADD_CAPABILITY( INTF, 80 )
56     ADD_SHORTCUT( "kde" )
57     ADD_PROGRAM( "kvlc" )
58 MODULE_INIT_STOP
59
60 MODULE_ACTIVATE_START
61     intf_getfunctions( &p_module->p_functions->intf );
62 MODULE_ACTIVATE_STOP
63
64 MODULE_DEACTIVATE_START
65 MODULE_DEACTIVATE_STOP
66
67 } // extern "C"
68
69 /*****************************************************************************
70  * The local class.
71  *****************************************************************************/
72 class KInterface;
73 class KAboutData;
74
75 class KThread
76 {
77     private:
78         KThread ( KThread &thread ) { };
79         KThread &operator= ( KThread &thread ) { return ( *this ); };
80
81         intf_thread_t *p_intf;
82         
83     public:
84         KThread(intf_thread_t *p_intf);
85         ~KThread();
86
87         // These methods get exported to the core
88         static int     probe   ( probedata_t *p_data );
89         static int     open    ( intf_thread_t *p_intf );
90         static void    close   ( intf_thread_t *p_intf );
91         static void    run     ( intf_thread_t *p_intf );
92 };
93
94 /*****************************************************************************
95  * Functions exported as capabilities.
96  *****************************************************************************/
97 static void intf_getfunctions( function_list_t * p_function_list )
98 {
99     p_function_list->pf_probe = KThread::probe;
100     p_function_list->functions.intf.pf_open  = KThread::open;
101     p_function_list->functions.intf.pf_close = KThread::close;
102     p_function_list->functions.intf.pf_run   = KThread::run;
103 }
104
105 /*****************************************************************************
106  * KThread::KThread: KDE interface constructor
107  *****************************************************************************/
108 KThread::KThread(intf_thread_t *p_intf)
109 {
110     this->p_intf = p_intf;
111
112     p_intf->p_sys->p_about =
113         new KAboutData( "VideoLAN Client", I18N_NOOP("Kvlc"), VERSION,
114             "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,
115             "(C) 1996, 1997, 1998, 1999, 2000, 2001 - the VideoLAN Team", 0, 0, "dae@chez.com");
116
117     char *authors[][2] = {
118         { "Régis Duchesne", "<regis@via.ecp.fr>" },
119         { "Michel Lespinasse", "<walken@zoy.org>" },
120         { "Olivier Pomel", "<pomel@via.ecp.fr>" },
121         { "Pierre Baillet", "<oct@zoy.org>" },
122         { "Jean-Philippe Grimaldi", "<jeanphi@via.ecp.fr>" },
123         { "Andres Krapf", "<dae@via.ecp.fr>" },
124         { "Christophe Massiot", "<massiot@via.ecp.fr>" },
125         { "Vincent Seguin", "<seguin@via.ecp.fr>" },
126         { "Benoit Steiner", "<benny@via.ecp.fr>" },
127         { "Arnaud de Bossoreille de Ribou", "<bozo@via.ecp.fr>" },
128         { "Jean-Marc Dressler", "<polux@via.ecp.fr>" },
129         { "Gaël Hendryckx", "<jimmy@via.ecp.fr>" },
130         { "Samuel Hocevar","<sam@zoy.org>" },
131         { "Brieuc Jeunhomme", "<bbp@via.ecp.fr>" },
132         { "Michel Kaempf", "<maxx@via.ecp.fr>" },
133         { "Stéphane Borel", "<stef@via.ecp.fr>" },
134         { "Renaud Dartus", "<reno@via.ecp.fr>" },
135         { "Henri Fallon", "<henri@via.ecp.fr>" },
136         { NULL, NULL },
137     };
138
139     for ( int i = 0; NULL != authors[i][0]; i++ ) {
140         p_intf->p_sys->p_about->addAuthor( authors[i][0], 0, authors[i][1] );
141     }
142
143     int argc = 1;
144     char *argv[] = { p_main->psz_arg0, NULL };
145     KCmdLineArgs::init( argc, argv, p_intf->p_sys->p_about );
146
147     p_intf->p_sys->p_app = new KApplication();
148     p_intf->p_sys->p_window = new KInterface(p_intf);
149     p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (KDE interface)" );
150 }
151
152 /*****************************************************************************
153  * KThread::~KThread: KDE interface destructor
154  *****************************************************************************/
155 KThread::~KThread()
156 {
157     /* XXX: can be deleted if the user closed the window ! */
158     //delete p_intf->p_sys->p_window;
159
160     delete p_intf->p_sys->p_app;
161     delete p_intf->p_sys->p_about;
162 }
163
164 /*****************************************************************************
165  * KThread::probe: probe the interface and return a score
166  *****************************************************************************
167  * This function tries to initialize KDE and returns a score to the
168  * plugin manager so that it can select the best plugin.
169  *****************************************************************************/
170 int KThread::probe(probedata_t *p_data )
171 {
172     return ( 80 );
173 }
174
175 /*****************************************************************************
176  * KThread::open: initialize and create window
177  *****************************************************************************/
178 int KThread::open(intf_thread_t *p_intf)
179 {
180     /* Allocate instance and initialize some members */
181     p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
182     if( p_intf->p_sys == NULL )
183     {
184         intf_ErrMsg( "intf error: %s", strerror(ENOMEM) );
185         return( 1 );
186     }
187
188     p_intf->p_sys->p_thread = new KThread(p_intf);
189     return ( 0 );
190 }
191
192 /*****************************************************************************
193  * KThread::close: destroy interface window
194  *****************************************************************************/
195 void KThread::close(intf_thread_t *p_intf)
196 {
197     delete p_intf->p_sys->p_thread;
198     free( p_intf->p_sys );
199 }
200
201 /*****************************************************************************
202  * KThread::run: KDE thread
203  *****************************************************************************
204  * This part of the interface is in a separate thread so that we can call
205  * exec() from within it without annoying the rest of the program.
206  *****************************************************************************/
207 void KThread::run(intf_thread_t *p_intf)
208 {
209     p_intf->p_sys->p_window->show();
210     p_intf->p_sys->p_app->exec();
211 }
212