]> git.sesse.net Git - vlc/blob - modules/gui/kde/kde.cpp
f23b61441ef4a5d76ca9cef1815fa03f943fc298
[vlc] / modules / gui / kde / kde.cpp
1 /*****************************************************************************
2  * kde.cpp : KDE plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: kde.cpp,v 1.7 2003/01/28 22:03:21 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 "common.h"
25
26 #include "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  * The local class and prototypes
41  *****************************************************************************/
42 class KInterface;
43 class KAboutData;
44
45 static int open( vlc_object_t * p_this );
46 static void close( vlc_object_t * p_this );
47 static void run(intf_thread_t *p_intf);
48
49 /*****************************************************************************
50  * Module descriptor
51  *****************************************************************************/
52 vlc_module_begin();
53     int i = getenv( "DISPLAY" ) == NULL ? 8 : 85;
54     add_category_hint( "kde", NULL );
55     add_file( "kdeuirc", DATA_PATH "/ui.rc", NULL, N_( "path to ui.rc file" ), NULL );
56     set_description( _("KDE interface module") );
57     set_capability( "interface", i );
58     set_program( "kvlc" );
59     set_callbacks( open, close );
60 vlc_module_end();
61
62 /*****************************************************************************
63  * KThread::open: initialize and create window
64  *****************************************************************************/
65 static int open(vlc_object_t *p_this)
66 {
67     intf_thread_t *p_intf = (intf_thread_t *)p_this;
68
69     /* Allocate instance and initialize some members */
70     p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
71     if( p_intf->p_sys == NULL )
72     {
73         msg_Err( p_intf, "out of memory" );
74         return( 1 );
75     }
76
77     p_intf->pf_run = run;
78     return ( 0 );
79 }
80
81 /*****************************************************************************
82  * KThread::close: destroy interface window
83  *****************************************************************************/
84 static void close(vlc_object_t *p_this)
85 {
86     intf_thread_t *p_intf = (intf_thread_t *)p_this;
87     if( p_intf->p_sys->p_input )
88     {
89         vlc_object_release( p_intf->p_sys->p_input );
90     }
91
92     delete p_intf->p_sys->p_app;
93     delete p_intf->p_sys->p_about;
94     msg_Unsubscribe(p_intf, p_intf->p_sys->p_msg);
95     free( p_intf->p_sys );
96 }
97
98 /*****************************************************************************
99  * KThread::run: KDE thread
100  *****************************************************************************
101  * This part of the interface is in a separate thread so that we can call
102  * exec() from within it without annoying the rest of the program.
103  *****************************************************************************/
104 void run(intf_thread_t *p_intf)
105 {
106     p_intf->p_sys->p_about =
107       new KAboutData( "VideoLAN Client", I18N_NOOP("Kvlc"), VERSION,
108          _("This is the VideoLAN Client, a DVD, MPEG and DivX player. It can "
109            "play MPEG and MPEG2 files from a file or from a network source."),
110          KAboutData::License_GPL,
111          _("(C) 1996-2003 - the VideoLAN Team"),
112          0, 0, "");
113
114     p_intf->p_sys->p_about->addAuthor( "the VideoLAN Team", 0,
115                                        "<videolan@videolan.org>" );
116
117     int argc = 1;
118     char *argv[] = { p_intf->p_vlc->psz_object_name, NULL };
119     KCmdLineArgs::init( argc, argv, p_intf->p_sys->p_about );
120
121     /* Subscribe to message queue */
122     p_intf->p_sys->p_msg = msg_Subscribe( p_intf );
123
124     p_intf->p_sys->p_app = new KApplication();
125     p_intf->p_sys->p_window = new KInterface(p_intf);
126     p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (KDE interface)" );
127
128     p_intf->p_sys->p_input = NULL;
129
130     p_intf->p_sys->p_window->show();
131     p_intf->p_sys->p_app->exec();
132 }
133