1 /*****************************************************************************
2 * callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: callbacks.c,v 1.1 2002/08/04 17:23:43 sam Exp $
7 * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
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.
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.
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 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <sys/types.h> /* off_t */
43 #include "callbacks.h"
44 #include "interface.h"
48 //#include "netutils.h"
50 /*****************************************************************************
51 * Useful function to retrieve p_intf
52 ****************************************************************************/
53 void * __GtkGetIntf( GtkWidget * widget )
57 if( GTK_IS_MENU_ITEM( widget ) )
59 /* Look for a GTK_MENU */
60 while( widget->parent && !GTK_IS_MENU( widget ) )
62 widget = widget->parent;
65 /* Maybe this one has the data */
66 p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
72 /* Otherwise, the parent widget has it */
73 widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
76 /* We look for the top widget */
77 widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );
79 p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
85 * Main interface callbacks
88 gboolean GtkExit( GtkWidget *widget,
91 intf_thread_t *p_intf = GtkGetIntf( widget );
93 vlc_mutex_lock( &p_intf->change_lock );
94 p_intf->p_vlc->b_die = VLC_TRUE;
95 vlc_mutex_unlock( &p_intf->change_lock );
101 on_familiar_destroy_event (GtkWidget *widget,
105 GtkExit( GTK_WIDGET( widget ), user_data );
111 on_toolbar_open_clicked (GtkButton *button,
114 intf_thread_t *p_intf = GtkGetIntf( button );
116 gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
121 on_toolbar_preferences_clicked (GtkButton *button,
124 intf_thread_t *p_intf = GtkGetIntf( button );
126 gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
131 on_toolbar_rewind_clicked (GtkButton *button,
134 intf_thread_t * p_intf = GtkGetIntf( button );
138 if( p_intf->p_sys->p_input )
140 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
147 on_toolbar_pause_clicked (GtkButton *button,
150 intf_thread_t * p_intf = GtkGetIntf( button );
154 if( p_intf->p_sys->p_input )
156 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
163 on_toolbar_play_clicked (GtkButton *button,
166 intf_thread_t * p_intf = GtkGetIntf( button );
167 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
169 if( p_playlist == NULL )
174 /* If the playlist is empty, open a file requester instead */
175 vlc_mutex_lock( &p_playlist->object_lock );
176 if( p_playlist->i_size )
178 vlc_mutex_unlock( &p_playlist->object_lock );
179 playlist_Play( p_playlist );
180 vlc_object_release( p_playlist );
184 vlc_mutex_unlock( &p_playlist->object_lock );
185 vlc_object_release( p_playlist );
192 on_toolbar_stop_clicked (GtkButton *button,
195 intf_thread_t * p_intf = GtkGetIntf( button );
196 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
198 if( p_playlist == NULL )
200 playlist_Stop( p_playlist );
201 vlc_object_release( p_playlist );
207 on_toolbar_forward_clicked (GtkButton *button,
210 intf_thread_t * p_intf = GtkGetIntf( button );
214 if( p_intf->p_sys->p_input )
216 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
223 on_toolbar_about_clicked (GtkButton *button,
226 intf_thread_t *p_intf = GtkGetIntf( button );
229 // if ( gtk_get_data( GTK_WIDGET(p_intf->p_sys->p_notebook), "visible" ) )
230 // gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) );
232 gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );