]> git.sesse.net Git - vlc/blob - modules/gui/kde/kde.cpp
7cfd2bdd60b3c695955ec668610fb45ce9ef1779
[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.15 2004/01/25 18:53:07 gbazin 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     set_description( _("KDE interface") );
55     add_file( "kde-uirc", DATA_PATH "/ui.rc", NULL, N_( "path to ui.rc file" ), NULL, VLC_TRUE );
56     set_capability( "interface", 0 ); /* 0 used to be i, disabled because kvlc not maintained */
57     set_program( "kvlc" );
58     set_callbacks( open, close );
59 vlc_module_end();
60
61 /*****************************************************************************
62  * KThread::open: initialize and create window
63  *****************************************************************************/
64 static int open(vlc_object_t *p_this)
65 {
66     intf_thread_t *p_intf = (intf_thread_t *)p_this;
67
68     /* Allocate instance and initialize some members */
69     p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
70     if( p_intf->p_sys == NULL )
71     {
72         msg_Err( p_intf, "out of memory" );
73         return( 1 );
74     }
75
76     p_intf->pf_run = run;
77     return ( 0 );
78 }
79
80 /*****************************************************************************
81  * KThread::close: destroy interface window
82  *****************************************************************************/
83 static void close(vlc_object_t *p_this)
84 {
85     intf_thread_t *p_intf = (intf_thread_t *)p_this;
86     if( p_intf->p_sys->p_input )
87     {
88         vlc_object_release( p_intf->p_sys->p_input );
89     }
90
91     delete p_intf->p_sys->p_app;
92     delete p_intf->p_sys->p_about;
93     msg_Unsubscribe(p_intf, p_intf->p_sys->p_msg);
94     free( p_intf->p_sys );
95 }
96
97 /*****************************************************************************
98  * KThread::run: KDE thread
99  *****************************************************************************
100  * This part of the interface is in a separate thread so that we can call
101  * exec() from within it without annoying the rest of the program.
102  *****************************************************************************/
103 void run(intf_thread_t *p_intf)
104 {
105     p_intf->p_sys->p_about =
106       new KAboutData( "kvlc", I18N_NOOP("Kvlc"), VERSION,
107          _("This is the VLC media player, a DVD, MPEG and DivX player. It can "
108            "play MPEG and MPEG2 files from a file or from a network source."),
109          KAboutData::License_GPL,
110          _("(c) 1996-2004 the VideoLAN team"),
111          0, 0, "");
112
113     p_intf->p_sys->p_about->addAuthor( "the VideoLAN team", 0,
114                                        "<videolan@videolan.org>" );
115
116     int argc = 5;
117     char *argv[] = { "vlc", "--icon", DATA_PATH "/kvlc32x32.png", "--miniicon", DATA_PATH "/kvlc16x16.png" };
118     KCmdLineArgs::init( argc, argv, p_intf->p_sys->p_about );
119
120     /* Subscribe to message queue */
121     p_intf->p_sys->p_msg = msg_Subscribe( p_intf );
122
123     p_intf->p_sys->p_app = new KApplication();
124     p_intf->p_sys->p_window = new KInterface(p_intf);
125     p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (KDE interface)" );
126
127     p_intf->p_sys->p_input = NULL;
128
129     p_intf->p_sys->p_window->show();
130     p_intf->p_sys->p_app->exec();
131 }
132