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,
98 on_menubar_plugins_activate (GtkMenuItem *menuitem,
106 on_menubar_preferences_activate (GtkMenuItem *menuitem,
114 on_menubar_about_activate (GtkMenuItem *menuitem,
117 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
119 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
121 p_intf->p_sys->p_about = create_intf_about();
123 gtk_widget_show( p_intf->p_sys->p_about );
128 on_toolbar_open_clicked (GtkButton *button,
131 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
133 /* If we have never used the file selector, open it */
134 if( p_intf->p_sys->p_fileopen == NULL)
136 p_intf->p_sys->p_fileopen = create_intf_fileopen();
137 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
141 gtk_widget_show( p_intf->p_sys->p_fileopen );
142 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
147 on_toolbar_back_clicked (GtkButton *button,
155 on_toolbar_stop_clicked (GtkButton *button,
163 on_toolbar_play_clicked (GtkButton *button,
166 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
168 if( p_intf->p_input != NULL )
170 input_Play( p_intf->p_input );
176 on_toolbar_pause_clicked (GtkButton *button,
179 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
181 if( p_intf->p_input != NULL )
183 input_Pause( p_intf->p_input );
189 on_toolbar_playlist_clicked (GtkButton *button,
197 on_toolbar_prev_clicked (GtkButton *button,
205 on_toolbar_next_clicked (GtkButton *button,
213 on_popup_play_activate (GtkMenuItem *menuitem,
216 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
218 if( p_intf->p_input != NULL )
220 input_Play( p_intf->p_input );
226 on_popup_pause_activate (GtkMenuItem *menuitem,
229 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
231 if( p_intf->p_input != NULL )
233 input_Pause( p_intf->p_input );
239 on_popup_exit_activate (GtkMenuItem *menuitem,
242 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
249 on_intf_window_destroy (GtkObject *object,
252 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
254 /* FIXME don't destroy the window, just hide it */
256 p_intf->p_sys->p_window = NULL;
261 on_fileopen_ok_clicked (GtkButton *button,
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));
271 intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
276 on_fileopen_cancel_clicked (GtkButton *button,
279 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
284 on_intf_fileopen_destroy (GtkObject *object,
287 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
289 p_intf->p_sys->p_fileopen = NULL;
294 on_popup_open_activate (GtkMenuItem *menuitem,
297 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
299 /* If we have never used the file selector, open it */
300 if( p_intf->p_sys->p_fileopen == NULL)
302 p_intf->p_sys->p_fileopen = create_intf_fileopen();
303 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
307 gtk_widget_show( p_intf->p_sys->p_fileopen );
308 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
313 on_popup_about_activate (GtkMenuItem *menuitem,
316 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
318 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
320 p_intf->p_sys->p_about = create_intf_about();
322 gtk_widget_show( p_intf->p_sys->p_about );