]> git.sesse.net Git - vlc/blob - plugins/gnome/gnome_callbacks.c
* The pure Gnome part of the Gnome interface has been rewritten from
[vlc] / plugins / gnome / gnome_callbacks.c
1 /*****************************************************************************
2  * gnome_callbacks.c : Callbacks for the Gnome plugin.
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
7  *      
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26 #include "defs.h"
27
28 #include <gnome.h>
29
30 #include "config.h"
31 #include "common.h"
32 #include "threads.h"
33 #include "mtime.h"
34
35 #include "stream_control.h"
36 #include "input_ext-intf.h"
37
38 #include "interface.h"
39 #include "intf_plst.h"
40
41 #include "gnome_sys.h"
42 #include "gnome_callbacks.h"
43 #include "gnome_interface.h"
44 #include "gnome_support.h"
45
46 #include "main.h"
47
48 /*****************************************************************************
49  * Inline function to retrieve the interface structure
50  *****************************************************************************/
51 static __inline__ intf_thread_t * GetIntf( GtkWidget *item, char * psz_parent )
52 {
53     return( gtk_object_get_data( GTK_OBJECT( lookup_widget(item, psz_parent) ),
54                                  "p_intf" ) );
55 }
56
57 /*****************************************************************************
58  * Callbacks
59  ******************************************************************************/
60 void
61 on_menubar_open_activate               (GtkMenuItem     *menuitem,
62                                         gpointer         user_data)
63 {
64     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
65
66     /* If we have never used the file selector, open it */
67     if( p_intf->p_sys->p_fileopen == NULL)
68     {
69         p_intf->p_sys->p_fileopen = create_intf_fileopen();
70         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
71                              "p_intf", p_intf );
72     }
73
74     gtk_widget_show( p_intf->p_sys->p_fileopen );
75     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
76 }
77
78
79 void
80 on_menubar_exit_activate               (GtkMenuItem     *menuitem,
81                                         gpointer         user_data)
82 {
83     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
84
85     p_intf->b_die = 1;
86 }
87
88
89 void
90 on_menubar_playlist_activate           (GtkMenuItem     *menuitem,
91                                         gpointer         user_data)
92 {
93
94 }
95
96
97 void
98 on_menubar_plugins_activate            (GtkMenuItem     *menuitem,
99                                         gpointer         user_data)
100 {
101
102 }
103
104
105 void
106 on_menubar_preferences_activate        (GtkMenuItem     *menuitem,
107                                         gpointer         user_data)
108 {
109
110 }
111
112
113 void
114 on_menubar_about_activate              (GtkMenuItem     *menuitem,
115                                         gpointer         user_data)
116 {
117     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
118
119     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
120     {
121         p_intf->p_sys->p_about = create_intf_about();
122     }
123     gtk_widget_show( p_intf->p_sys->p_about );
124 }
125
126
127 void
128 on_toolbar_open_clicked                (GtkButton       *button,
129                                         gpointer         user_data)
130 {
131     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
132
133     /* If we have never used the file selector, open it */
134     if( p_intf->p_sys->p_fileopen == NULL)
135     {
136         p_intf->p_sys->p_fileopen = create_intf_fileopen();
137         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
138                              "p_intf", p_intf );
139     }
140
141     gtk_widget_show( p_intf->p_sys->p_fileopen );
142     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
143 }
144
145
146 void
147 on_toolbar_back_clicked                (GtkButton       *button,
148                                         gpointer         user_data)
149 {
150
151 }
152
153
154 void
155 on_toolbar_stop_clicked                (GtkButton       *button,
156                                         gpointer         user_data)
157 {
158
159 }
160
161
162 void
163 on_toolbar_play_clicked                (GtkButton       *button,
164                                         gpointer         user_data)
165 {
166     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
167
168     if( p_intf->p_input != NULL )
169     {
170         input_Play( p_intf->p_input );
171     }
172 }
173
174
175 void
176 on_toolbar_pause_clicked               (GtkButton       *button,
177                                         gpointer         user_data)
178 {
179     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
180
181     if( p_intf->p_input != NULL )
182     {
183         input_Pause( p_intf->p_input );
184     }
185 }
186
187
188 void
189 on_toolbar_playlist_clicked            (GtkButton       *button,
190                                         gpointer         user_data)
191 {
192
193 }
194
195
196 void
197 on_toolbar_prev_clicked                (GtkButton       *button,
198                                         gpointer         user_data)
199 {
200
201 }
202
203
204 void
205 on_toolbar_next_clicked                (GtkButton       *button,
206                                         gpointer         user_data)
207 {
208
209 }
210
211
212 void
213 on_popup_play_activate                 (GtkMenuItem     *menuitem,
214                                         gpointer         user_data)
215 {
216     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
217
218     if( p_intf->p_input != NULL )
219     {
220         input_Play( p_intf->p_input );
221     }
222 }
223
224
225 void
226 on_popup_pause_activate                (GtkMenuItem     *menuitem,
227                                         gpointer         user_data)
228 {
229     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
230
231     if( p_intf->p_input != NULL )
232     {
233         input_Pause( p_intf->p_input );
234     }
235 }
236
237
238 void
239 on_popup_exit_activate                 (GtkMenuItem     *menuitem,
240                                         gpointer         user_data)
241 {
242     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
243
244     p_intf->b_die = 1;
245 }
246
247
248 void
249 on_intf_window_destroy                 (GtkObject       *object,
250                                         gpointer         user_data)
251 {
252     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
253
254     /* FIXME don't destroy the window, just hide it */
255     p_intf->b_die = 1;
256     p_intf->p_sys->p_window = NULL;
257 }
258
259
260 void
261 on_fileopen_ok_clicked                 (GtkButton       *button,
262                                         gpointer         user_data)
263 {
264     GtkWidget *filesel;
265     gchar *filename;
266
267     filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
268     gtk_widget_hide (filesel);
269     filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
270
271     intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
272 }
273
274
275 void
276 on_fileopen_cancel_clicked             (GtkButton       *button,
277                                         gpointer         user_data)
278 {
279     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
280 }
281
282
283 void
284 on_intf_fileopen_destroy               (GtkObject       *object,
285                                         gpointer         user_data)
286 {
287     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
288
289     p_intf->p_sys->p_fileopen = NULL;
290 }
291
292
293 void
294 on_popup_open_activate                 (GtkMenuItem     *menuitem,
295                                         gpointer         user_data)
296 {
297     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
298
299     /* If we have never used the file selector, open it */
300     if( p_intf->p_sys->p_fileopen == NULL)
301     {
302         p_intf->p_sys->p_fileopen = create_intf_fileopen();
303         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
304                              "p_intf", p_intf );
305     }
306
307     gtk_widget_show( p_intf->p_sys->p_fileopen );
308     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
309 }
310
311
312 void
313 on_popup_about_activate                (GtkMenuItem     *menuitem,
314                                         gpointer         user_data)
315 {
316     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
317
318     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
319     {
320         p_intf->p_sys->p_about = create_intf_about();
321     }
322     gtk_widget_show( p_intf->p_sys->p_about );
323 }
324