1 /*****************************************************************************
2 * gnome_callbacks.c : Callbacks for the Gnome plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
6 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
23 /*****************************************************************************
25 *****************************************************************************/
35 #include "stream_control.h"
36 #include "input_ext-intf.h"
38 #include "interface.h"
39 #include "intf_plst.h"
41 #include "gnome_sys.h"
42 #include "gnome_callbacks.h"
43 #include "gnome_interface.h"
44 #include "gnome_support.h"
48 /*****************************************************************************
49 * Inline function to retrieve the interface structure
50 *****************************************************************************/
51 static __inline__ intf_thread_t * GetIntf( GtkWidget *item, char * psz_parent )
53 return( gtk_object_get_data( GTK_OBJECT( lookup_widget(item, psz_parent) ),
57 /*****************************************************************************
59 ******************************************************************************/
61 on_menubar_open_activate (GtkMenuItem *menuitem,
64 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
66 /* If we have never used the file selector, open it */
67 if( p_intf->p_sys->p_fileopen == NULL)
69 p_intf->p_sys->p_fileopen = create_intf_fileopen();
70 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
74 gtk_widget_show( p_intf->p_sys->p_fileopen );
75 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
80 on_menubar_exit_activate (GtkMenuItem *menuitem,
83 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
90 on_menubar_playlist_activate (GtkMenuItem *menuitem,
93 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
95 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
97 p_intf->p_sys->p_playlist = create_intf_playlist();
98 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
101 gtk_widget_show( p_intf->p_sys->p_playlist );
106 on_menubar_plugins_activate (GtkMenuItem *menuitem,
114 on_menubar_preferences_activate (GtkMenuItem *menuitem,
122 on_menubar_about_activate (GtkMenuItem *menuitem,
125 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
127 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
129 p_intf->p_sys->p_about = create_intf_about();
130 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
133 gtk_widget_show( p_intf->p_sys->p_about );
138 on_toolbar_open_clicked (GtkButton *button,
141 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
143 /* If we have never used the file selector, open it */
144 if( p_intf->p_sys->p_fileopen == NULL)
146 p_intf->p_sys->p_fileopen = create_intf_fileopen();
147 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
151 gtk_widget_show( p_intf->p_sys->p_fileopen );
152 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
157 on_toolbar_back_clicked (GtkButton *button,
165 on_toolbar_stop_clicked (GtkButton *button,
173 on_toolbar_play_clicked (GtkButton *button,
176 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
178 if( p_intf->p_input != NULL )
180 input_SetRate( p_intf->p_input, INPUT_RATE_PLAY );
186 on_toolbar_pause_clicked (GtkButton *button,
189 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
191 if( p_intf->p_input != NULL )
193 input_SetRate( p_intf->p_input, INPUT_RATE_PAUSE );
199 on_toolbar_playlist_clicked (GtkButton *button,
202 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
204 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
206 p_intf->p_sys->p_playlist = create_intf_playlist();
207 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
210 gtk_widget_show( p_intf->p_sys->p_playlist );
215 on_toolbar_prev_clicked (GtkButton *button,
218 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
220 if( p_intf->p_input != NULL )
222 /* FIXME: temporary hack */
223 intf_PlstPrev( p_main->p_playlist );
224 intf_PlstPrev( p_main->p_playlist );
225 p_intf->p_input->b_eof = 1;
231 on_toolbar_next_clicked (GtkButton *button,
234 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
236 if( p_intf->p_input != NULL )
238 /* FIXME: temporary hack */
239 p_intf->p_input->b_eof = 1;
245 on_popup_play_activate (GtkMenuItem *menuitem,
248 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
250 if( p_intf->p_input != NULL )
252 input_SetRate( p_intf->p_input, INPUT_RATE_PLAY );
258 on_popup_pause_activate (GtkMenuItem *menuitem,
261 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
263 if( p_intf->p_input != NULL )
265 input_SetRate( p_intf->p_input, INPUT_RATE_PAUSE );
271 on_popup_exit_activate (GtkMenuItem *menuitem,
274 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
281 on_intf_window_destroy (GtkObject *object,
284 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
286 /* FIXME don't destroy the window, just hide it */
288 p_intf->p_sys->p_window = NULL;
293 on_fileopen_ok_clicked (GtkButton *button,
299 filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
300 gtk_widget_hide (filesel);
301 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
303 intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
308 on_fileopen_cancel_clicked (GtkButton *button,
311 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
316 on_intf_fileopen_destroy (GtkObject *object,
319 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
321 p_intf->p_sys->p_fileopen = NULL;
326 on_popup_open_activate (GtkMenuItem *menuitem,
329 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
331 /* If we have never used the file selector, open it */
332 if( p_intf->p_sys->p_fileopen == NULL)
334 p_intf->p_sys->p_fileopen = create_intf_fileopen();
335 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
339 gtk_widget_show( p_intf->p_sys->p_fileopen );
340 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
345 on_popup_about_activate (GtkMenuItem *menuitem,
348 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
350 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
352 p_intf->p_sys->p_about = create_intf_about();
353 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
356 gtk_widget_show( p_intf->p_sys->p_about );
361 on_intf_playlist_destroy (GtkObject *object,
364 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
366 p_intf->p_sys->p_playlist = NULL;
371 on_playlist_close_clicked (GtkButton *button,
374 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
379 on_popup_slow_activate (GtkMenuItem *menuitem,
382 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
384 if( p_intf->p_input != NULL )
386 input_SetRate( p_intf->p_input, INPUT_RATE_SLOWER );
392 on_popup_fast_activate (GtkMenuItem *menuitem,
395 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
397 if( p_intf->p_input != NULL )
399 input_SetRate( p_intf->p_input, INPUT_RATE_FASTER );
405 on_toolbar_slow_clicked (GtkButton *button,
408 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
410 if( p_intf->p_input != NULL )
412 input_SetRate( p_intf->p_input, INPUT_RATE_SLOWER );
418 on_toolbar_fast_clicked (GtkButton *button,
421 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
423 if( p_intf->p_input != NULL )
425 input_SetRate( p_intf->p_input, INPUT_RATE_FASTER );