]> git.sesse.net Git - vlc/blob - plugins/gtk/gtk_control.c
* Fixed the BeOS compile typo.
[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.4 2001/05/30 17:03:12 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 "defs.h"
29 #include <sys/types.h>                                              /* off_t */
30 #include <stdlib.h>
31
32 #include <gtk/gtk.h>
33
34 #include <string.h>
35
36 #include "config.h"
37 #include "common.h"
38 #include "threads.h"
39 #include "mtime.h"
40
41 #include "stream_control.h"
42 #include "input_ext-intf.h"
43
44 #include "interface.h"
45 #include "intf_playlist.h"
46 #include "intf_msg.h"
47
48 #include "gtk_callbacks.h"
49 #include "gtk_interface.h"
50 #include "gtk_support.h"
51 #include "gtk_playlist.h"
52 #include "intf_gtk.h"
53
54 #include "main.h"
55
56 #include "modules_export.h"
57
58 /****************************************************************************
59  * Control functions: this is where the functions are defined
60  ****************************************************************************
61  * These functions are button-items callbacks, and are used
62  * by other callbacks
63  ****************************************************************************/
64 gboolean GtkControlBack( GtkWidget       *widget,
65                          GdkEventButton  *event,
66                          gpointer         user_data )
67 {
68
69     return FALSE;
70 }
71
72
73 gboolean GtkControlStop( GtkWidget       *widget,
74                          GdkEventButton  *event,
75                          gpointer         user_data )
76 {
77     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
78
79     if( p_intf->p_input != NULL )
80     {
81         /* end playing item */
82         p_intf->p_input->b_eof = 1;
83
84         /* update playlist */
85         vlc_mutex_lock( &p_main->p_playlist->change_lock );
86
87         p_main->p_playlist->i_index--;
88         p_main->p_playlist->b_stopped = 1;
89
90         vlc_mutex_unlock( &p_main->p_playlist->change_lock );
91
92     }
93
94     return TRUE;
95 }
96
97
98 gboolean GtkControlPlay( GtkWidget       *widget,
99                          GdkEventButton  *event,
100                          gpointer         user_data )
101 {
102     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
103
104     if( p_intf->p_input != NULL )
105     {
106         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
107         p_main->p_playlist->b_stopped = 0;
108     }
109     else
110     {
111         vlc_mutex_lock( &p_main->p_playlist->change_lock );
112
113         if( p_main->p_playlist->b_stopped )
114         {
115             if( p_main->p_playlist->i_size )
116             {
117                 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
118                 intf_PlaylistJumpto( p_main->p_playlist,
119                                      p_main->p_playlist->i_index );
120             }
121             else
122             {
123                 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
124                 GtkFileOpenShow( widget, event, user_data );
125             }
126         }
127         else
128         {
129
130             vlc_mutex_unlock( &p_main->p_playlist->change_lock );
131         }
132
133     }
134
135     return TRUE;
136 }
137
138
139 gboolean GtkControlPause( GtkWidget       *widget,
140                           GdkEventButton  *event,
141                           gpointer         user_data )
142 {
143     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
144
145     if( p_intf->p_input != NULL )
146     {
147         input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
148
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 );
152     }
153
154     return TRUE;
155 }
156
157
158 gboolean GtkControlSlow( GtkWidget       *widget,
159                          GdkEventButton  *event,
160                          gpointer         user_data )
161 {
162     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
163
164     if( p_intf->p_input != NULL )
165     {
166         input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
167
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 );
171     }
172
173     return TRUE;
174 }
175
176
177 gboolean GtkControlFast( GtkWidget       *widget,
178                          GdkEventButton  *event,
179                          gpointer         user_data )
180 {
181     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
182
183     if( p_intf->p_input != NULL )
184     {
185         input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
186
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 );
190     }
191
192     return TRUE;
193 }
194
195
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 )
203 {
204     GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
205 }
206
207
208 void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
209 {
210     GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
211
212 }
213
214
215 void
216 GtKStopActivate                        (GtkMenuItem     *menuitem,
217                                         gpointer         user_data)
218 {
219     GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
220
221 }
222
223
224 void
225 GtkBackActivate                        (GtkMenuItem     *menuitem,
226                                         gpointer         user_data)
227 {
228     GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
229
230 }
231
232
233 void
234 GtkSlowActivate                        (GtkMenuItem     *menuitem,
235                                         gpointer         user_data)
236 {
237     GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
238
239 }
240
241
242 void
243 GtkFastActivate                        (GtkMenuItem     *menuitem,
244                                         gpointer         user_data)
245 {
246     GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );
247 }
248
249