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.2 2001/05/15 14:49:48 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 #define MODULE_NAME gtk
26 #include "modules_inner.h"
28 /*****************************************************************************
30 *****************************************************************************/
32 #include <sys/types.h> /* off_t */
44 #include "stream_control.h"
45 #include "input_ext-intf.h"
47 #include "interface.h"
48 #include "intf_playlist.h"
51 #include "gtk_callbacks.h"
52 #include "gtk_interface.h"
53 #include "gtk_support.h"
54 #include "gtk_playlist.h"
59 /****************************************************************************
60 * Control functions: this is where the functions are defined
61 ****************************************************************************
62 * These functions are button-items callbacks, and are used
64 ****************************************************************************/
65 gboolean GtkControlBack( GtkWidget *widget,
66 GdkEventButton *event,
74 gboolean GtkControlStop( GtkWidget *widget,
75 GdkEventButton *event,
78 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
80 if( p_intf->p_input != NULL )
82 /* end playing item */
83 p_intf->p_input->b_eof = 1;
86 vlc_mutex_lock( &p_main->p_playlist->change_lock );
88 p_main->p_playlist->i_index--;
89 p_main->p_playlist->b_stopped = 1;
91 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
99 gboolean GtkControlPlay( GtkWidget *widget,
100 GdkEventButton *event,
103 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
105 if( p_intf->p_input != NULL )
107 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
108 p_main->p_playlist->b_stopped = 0;
112 vlc_mutex_lock( &p_main->p_playlist->change_lock );
114 if( p_main->p_playlist->b_stopped )
116 if( p_main->p_playlist->i_size )
118 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
119 intf_PlaylistJumpto( p_main->p_playlist,
120 p_main->p_playlist->i_index );
124 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
125 GtkFileOpenShow( widget, event, user_data );
131 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
140 gboolean GtkControlPause( GtkWidget *widget,
141 GdkEventButton *event,
144 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
146 if( p_intf->p_input != NULL )
148 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
150 vlc_mutex_lock( &p_main->p_playlist->change_lock );
151 p_main->p_playlist->b_stopped = 0;
152 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
159 gboolean GtkControlSlow( GtkWidget *widget,
160 GdkEventButton *event,
163 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
165 if( p_intf->p_input != NULL )
167 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
169 vlc_mutex_lock( &p_main->p_playlist->change_lock );
170 p_main->p_playlist->b_stopped = 0;
171 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
178 gboolean GtkControlFast( GtkWidget *widget,
179 GdkEventButton *event,
182 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
184 if( p_intf->p_input != NULL )
186 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
188 vlc_mutex_lock( &p_main->p_playlist->change_lock );
189 p_main->p_playlist->b_stopped = 0;
190 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
197 /****************************************************************************
198 * Control callbacks for menuitems
199 ****************************************************************************
200 * We have different callaback for menuitem since we must use the
201 * activate signal toi popdown the menu automatically
202 ****************************************************************************/
203 void GtkPlayActivate( GtkMenuItem * menuitem, gpointer user_data )
205 GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
209 void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
211 GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
217 GtKStopActivate (GtkMenuItem *menuitem,
220 GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
226 GtkBackActivate (GtkMenuItem *menuitem,
229 GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
235 GtkSlowActivate (GtkMenuItem *menuitem,
238 GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
244 GtkFastActivate (GtkMenuItem *menuitem,
247 GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );