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.4 2001/05/30 17:03:12 sam 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 #include "modules_export.h"
58 /****************************************************************************
59 * Control functions: this is where the functions are defined
60 ****************************************************************************
61 * These functions are button-items callbacks, and are used
63 ****************************************************************************/
64 gboolean GtkControlBack( GtkWidget *widget,
65 GdkEventButton *event,
73 gboolean GtkControlStop( GtkWidget *widget,
74 GdkEventButton *event,
77 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
79 if( p_intf->p_input != NULL )
81 /* end playing item */
82 p_intf->p_input->b_eof = 1;
85 vlc_mutex_lock( &p_main->p_playlist->change_lock );
87 p_main->p_playlist->i_index--;
88 p_main->p_playlist->b_stopped = 1;
90 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
98 gboolean GtkControlPlay( GtkWidget *widget,
99 GdkEventButton *event,
102 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
104 if( p_intf->p_input != NULL )
106 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
107 p_main->p_playlist->b_stopped = 0;
111 vlc_mutex_lock( &p_main->p_playlist->change_lock );
113 if( p_main->p_playlist->b_stopped )
115 if( p_main->p_playlist->i_size )
117 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
118 intf_PlaylistJumpto( p_main->p_playlist,
119 p_main->p_playlist->i_index );
123 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
124 GtkFileOpenShow( widget, event, user_data );
130 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
139 gboolean GtkControlPause( GtkWidget *widget,
140 GdkEventButton *event,
143 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
145 if( p_intf->p_input != NULL )
147 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
149 vlc_mutex_lock( &p_main->p_playlist->change_lock );
150 p_main->p_playlist->b_stopped = 0;
151 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
158 gboolean GtkControlSlow( GtkWidget *widget,
159 GdkEventButton *event,
162 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
164 if( p_intf->p_input != NULL )
166 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
168 vlc_mutex_lock( &p_main->p_playlist->change_lock );
169 p_main->p_playlist->b_stopped = 0;
170 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
177 gboolean GtkControlFast( GtkWidget *widget,
178 GdkEventButton *event,
181 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
183 if( p_intf->p_input != NULL )
185 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
187 vlc_mutex_lock( &p_main->p_playlist->change_lock );
188 p_main->p_playlist->b_stopped = 0;
189 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
196 /****************************************************************************
197 * Control callbacks for menuitems
198 ****************************************************************************
199 * We have different callaback for menuitem since we must use the
200 * activate signal toi popdown the menu automatically
201 ****************************************************************************/
202 void GtkPlayActivate( GtkMenuItem * menuitem, gpointer user_data )
204 GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
208 void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
210 GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
216 GtKStopActivate (GtkMenuItem *menuitem,
219 GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
225 GtkBackActivate (GtkMenuItem *menuitem,
228 GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
234 GtkSlowActivate (GtkMenuItem *menuitem,
237 GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
243 GtkFastActivate (GtkMenuItem *menuitem,
246 GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );