1 /*****************************************************************************
2 * gtk_control.c : functions to handle stream control buttons.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gtk_control.c,v 1.3 2001/05/23 23:08:20 stef Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Stéphane Borel <stef@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
29 #include <sys/types.h> /* off_t */
41 #include "stream_control.h"
42 #include "input_ext-intf.h"
44 #include "interface.h"
45 #include "intf_playlist.h"
48 #include "gtk_callbacks.h"
49 #include "gtk_interface.h"
50 #include "gtk_support.h"
51 #include "gtk_playlist.h"
56 /****************************************************************************
57 * Control functions: this is where the functions are defined
58 ****************************************************************************
59 * These functions are button-items callbacks, and are used
61 ****************************************************************************/
62 gboolean GtkControlBack( GtkWidget *widget,
63 GdkEventButton *event,
71 gboolean GtkControlStop( GtkWidget *widget,
72 GdkEventButton *event,
75 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
77 if( p_intf->p_input != NULL )
79 /* end playing item */
80 p_intf->p_input->b_eof = 1;
83 vlc_mutex_lock( &p_main->p_playlist->change_lock );
85 p_main->p_playlist->i_index--;
86 p_main->p_playlist->b_stopped = 1;
88 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
96 gboolean GtkControlPlay( GtkWidget *widget,
97 GdkEventButton *event,
100 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
102 if( p_intf->p_input != NULL )
104 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
105 p_main->p_playlist->b_stopped = 0;
109 vlc_mutex_lock( &p_main->p_playlist->change_lock );
111 if( p_main->p_playlist->b_stopped )
113 if( p_main->p_playlist->i_size )
115 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
116 intf_PlaylistJumpto( p_main->p_playlist,
117 p_main->p_playlist->i_index );
121 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
122 GtkFileOpenShow( widget, event, user_data );
128 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
137 gboolean GtkControlPause( GtkWidget *widget,
138 GdkEventButton *event,
141 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
143 if( p_intf->p_input != NULL )
145 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
147 vlc_mutex_lock( &p_main->p_playlist->change_lock );
148 p_main->p_playlist->b_stopped = 0;
149 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
156 gboolean GtkControlSlow( GtkWidget *widget,
157 GdkEventButton *event,
160 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
162 if( p_intf->p_input != NULL )
164 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
166 vlc_mutex_lock( &p_main->p_playlist->change_lock );
167 p_main->p_playlist->b_stopped = 0;
168 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
175 gboolean GtkControlFast( GtkWidget *widget,
176 GdkEventButton *event,
179 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
181 if( p_intf->p_input != NULL )
183 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
185 vlc_mutex_lock( &p_main->p_playlist->change_lock );
186 p_main->p_playlist->b_stopped = 0;
187 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
194 /****************************************************************************
195 * Control callbacks for menuitems
196 ****************************************************************************
197 * We have different callaback for menuitem since we must use the
198 * activate signal toi popdown the menu automatically
199 ****************************************************************************/
200 void GtkPlayActivate( GtkMenuItem * menuitem, gpointer user_data )
202 GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
206 void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
208 GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
214 GtKStopActivate (GtkMenuItem *menuitem,
217 GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
223 GtkBackActivate (GtkMenuItem *menuitem,
226 GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
232 GtkSlowActivate (GtkMenuItem *menuitem,
235 GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
241 GtkFastActivate (GtkMenuItem *menuitem,
244 GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );