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