]> git.sesse.net Git - vlc/blob - plugins/gtk/gtk_control.c
888c907740e1d34265efe00746579f533eacac90
[vlc] / plugins / gtk / gtk_control.c
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 $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Stéphane Borel <stef@via.ecp.fr>
9  *      
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.
14  * 
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.
19  *
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  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <sys/types.h>                                              /* off_t */
29 #include <stdlib.h>
30
31 #include <videolan/vlc.h>
32
33 #ifdef MODULE_NAME_IS_gnome
34 #   include <gnome.h>
35 #else
36 #   include <gtk/gtk.h>
37 #endif
38
39 #include <string.h>
40
41 #include "stream_control.h"
42 #include "input_ext-intf.h"
43
44 #include "interface.h"
45 #include "intf_playlist.h"
46
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"
52
53 /****************************************************************************
54  * Control functions: this is where the functions are defined
55  ****************************************************************************
56  * These functions are button-items callbacks, and are used
57  * by other callbacks
58  ****************************************************************************/
59 gboolean GtkControlBack( GtkWidget       *widget,
60                          GdkEventButton  *event,
61                          gpointer         user_data )
62 {
63
64     return FALSE;
65 }
66
67
68 gboolean GtkControlStop( GtkWidget       *widget,
69                          GdkEventButton  *event,
70                          gpointer         user_data )
71 {
72     if( p_input_bank->pp_input[0] != NULL )
73     {
74         /* end playing item */
75         p_input_bank->pp_input[0]->b_eof = 1;
76
77         /* update playlist */
78         vlc_mutex_lock( &p_main->p_playlist->change_lock );
79
80         p_main->p_playlist->i_index--;
81         p_main->p_playlist->b_stopped = 1;
82
83         vlc_mutex_unlock( &p_main->p_playlist->change_lock );
84
85     }
86
87     return TRUE;
88 }
89
90
91 gboolean GtkControlPlay( GtkWidget       *widget,
92                          GdkEventButton  *event,
93                          gpointer         user_data )
94 {
95     if( p_input_bank->pp_input[0] != NULL )
96     {
97         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
98         p_main->p_playlist->b_stopped = 0;
99     }
100     else
101     {
102         vlc_mutex_lock( &p_main->p_playlist->change_lock );
103
104         if( p_main->p_playlist->b_stopped )
105         {
106             if( p_main->p_playlist->i_size )
107             {
108                 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
109                 intf_PlaylistJumpto( p_main->p_playlist,
110                                      p_main->p_playlist->i_index );
111             }
112             else
113             {
114                 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
115                 GtkFileOpenShow( widget, event, user_data );
116             }
117         }
118         else
119         {
120
121             vlc_mutex_unlock( &p_main->p_playlist->change_lock );
122         }
123
124     }
125
126     return TRUE;
127 }
128
129
130 gboolean GtkControlPause( GtkWidget       *widget,
131                           GdkEventButton  *event,
132                           gpointer         user_data )
133 {
134     if( p_input_bank->pp_input[0] != NULL )
135     {
136         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PAUSE );
137
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 );
141     }
142
143     return TRUE;
144 }
145
146
147 gboolean GtkControlSlow( GtkWidget       *widget,
148                          GdkEventButton  *event,
149                          gpointer         user_data )
150 {
151     if( p_input_bank->pp_input[0] != NULL )
152     {
153         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_SLOWER );
154
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 );
158     }
159
160     return TRUE;
161 }
162
163
164 gboolean GtkControlFast( GtkWidget       *widget,
165                          GdkEventButton  *event,
166                          gpointer         user_data )
167 {
168     if( p_input_bank->pp_input[0] != NULL )
169     {
170         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_FASTER );
171
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 );
175     }
176
177     return TRUE;
178 }
179
180
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 )
188 {
189     GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
190 }
191
192
193 void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
194 {
195     GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
196
197 }
198
199
200 void
201 GtKStopActivate                        (GtkMenuItem     *menuitem,
202                                         gpointer         user_data)
203 {
204     GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
205
206 }
207
208
209 void
210 GtkBackActivate                        (GtkMenuItem     *menuitem,
211                                         gpointer         user_data)
212 {
213     GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
214
215 }
216
217
218 void
219 GtkSlowActivate                        (GtkMenuItem     *menuitem,
220                                         gpointer         user_data)
221 {
222     GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
223
224 }
225
226
227 void
228 GtkFastActivate                        (GtkMenuItem     *menuitem,
229                                         gpointer         user_data)
230 {
231     GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );
232 }
233
234