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.9 2002/01/07 02:12:29 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 *****************************************************************************/
28 #include <sys/types.h> /* off_t */
31 #include <videolan/vlc.h>
33 #ifdef MODULE_NAME_IS_gnome
41 #include "stream_control.h"
42 #include "input_ext-intf.h"
44 #include "interface.h"
45 #include "intf_playlist.h"
47 #include "gtk_callbacks.h"
48 #include "gtk_interface.h"
49 #include "gtk_support.h"
50 #include "gtk_playlist.h"
51 #include "gtk_common.h"
53 /****************************************************************************
54 * Control functions: this is where the functions are defined
55 ****************************************************************************
56 * These functions are button-items callbacks, and are used
58 ****************************************************************************/
59 gboolean GtkControlBack( GtkWidget *widget,
60 GdkEventButton *event,
68 gboolean GtkControlStop( GtkWidget *widget,
69 GdkEventButton *event,
72 if( p_input_bank->pp_input[0] != NULL )
74 /* end playing item */
75 p_input_bank->pp_input[0]->b_eof = 1;
78 vlc_mutex_lock( &p_main->p_playlist->change_lock );
80 p_main->p_playlist->i_index--;
81 p_main->p_playlist->b_stopped = 1;
83 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
91 gboolean GtkControlPlay( GtkWidget *widget,
92 GdkEventButton *event,
95 if( p_input_bank->pp_input[0] != NULL )
97 input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
98 p_main->p_playlist->b_stopped = 0;
102 vlc_mutex_lock( &p_main->p_playlist->change_lock );
104 if( p_main->p_playlist->b_stopped )
106 if( p_main->p_playlist->i_size )
108 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
109 intf_PlaylistJumpto( p_main->p_playlist,
110 p_main->p_playlist->i_index );
114 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
115 GtkFileOpenShow( widget, event, user_data );
121 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
130 gboolean GtkControlPause( GtkWidget *widget,
131 GdkEventButton *event,
134 if( p_input_bank->pp_input[0] != NULL )
136 input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PAUSE );
138 vlc_mutex_lock( &p_main->p_playlist->change_lock );
139 p_main->p_playlist->b_stopped = 0;
140 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
147 gboolean GtkControlSlow( GtkWidget *widget,
148 GdkEventButton *event,
151 if( p_input_bank->pp_input[0] != NULL )
153 input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_SLOWER );
155 vlc_mutex_lock( &p_main->p_playlist->change_lock );
156 p_main->p_playlist->b_stopped = 0;
157 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
164 gboolean GtkControlFast( GtkWidget *widget,
165 GdkEventButton *event,
168 if( p_input_bank->pp_input[0] != NULL )
170 input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_FASTER );
172 vlc_mutex_lock( &p_main->p_playlist->change_lock );
173 p_main->p_playlist->b_stopped = 0;
174 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
181 /****************************************************************************
182 * Control callbacks for menuitems
183 ****************************************************************************
184 * We have different callaback for menuitem since we must use the
185 * activate signal toi popdown the menu automatically
186 ****************************************************************************/
187 void GtkPlayActivate( GtkMenuItem * menuitem, gpointer user_data )
189 GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
193 void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
195 GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
201 GtKStopActivate (GtkMenuItem *menuitem,
204 GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
210 GtkBackActivate (GtkMenuItem *menuitem,
213 GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
219 GtkSlowActivate (GtkMenuItem *menuitem,
222 GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
228 GtkFastActivate (GtkMenuItem *menuitem,
231 GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );