ae15adcd33abbc7cbcaaa12fdf737e2b5cb9cd46
[vlc.git] / 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.10 2002/06/01 12:31:59 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 <vlc/vlc.h>
32 #include <vlc/intf.h>
33
34 #ifdef MODULE_NAME_IS_gnome
35 #   include <gnome.h>
36 #else
37 #   include <gtk/gtk.h>
38 #endif
39
40 #include <string.h>
41
42 #include "gtk_callbacks.h"
43 #include "gtk_interface.h"
44 #include "gtk_support.h"
45 #include "gtk_playlist.h"
46 #include "gtk_common.h"
47
48 /****************************************************************************
49  * Control functions: this is where the functions are defined
50  ****************************************************************************
51  * These functions are button-items callbacks, and are used
52  * by other callbacks
53  ****************************************************************************/
54 gboolean GtkControlBack( GtkWidget       *widget,
55                          GdkEventButton  *event,
56                          gpointer         user_data )
57 {
58     return FALSE;
59 }
60
61
62 gboolean GtkControlStop( GtkWidget       *widget,
63                          GdkEventButton  *event,
64                          gpointer         user_data )
65 {
66     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
67     playlist_t *p_playlist;
68
69     p_playlist = vlc_object_find( p_intf->p_vlc,
70                                   VLC_OBJECT_PLAYLIST, FIND_CHILD );
71
72     if( p_playlist )
73     {
74         playlist_Stop( p_playlist );
75         vlc_object_release( p_playlist );
76     }
77
78     return TRUE;
79 }
80
81
82 gboolean GtkControlPlay( GtkWidget       *widget,
83                          GdkEventButton  *event,
84                          gpointer         user_data )
85 {
86     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
87     playlist_t *p_playlist;
88
89     p_playlist = vlc_object_find( p_intf->p_vlc,
90                                   VLC_OBJECT_PLAYLIST, FIND_CHILD );
91
92     if( p_playlist )
93     {
94         playlist_Play( p_playlist );
95         vlc_object_release( p_playlist );
96     }
97
98 #if 0 /* FIXME: deal with this */
99     {
100         vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
101         GtkFileOpenShow( widget, event, user_data );
102     }
103 #endif
104
105     return TRUE;
106 }
107
108
109 gboolean GtkControlPause( GtkWidget       *widget,
110                           GdkEventButton  *event,
111                           gpointer         user_data )
112 {
113     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
114     playlist_t *p_playlist;
115
116     p_playlist = vlc_object_find( p_intf->p_vlc,
117                                   VLC_OBJECT_PLAYLIST, FIND_CHILD );
118
119     if( p_playlist )
120     {
121         playlist_Pause( p_playlist );
122         vlc_object_release( p_playlist );
123     }
124
125     return TRUE;
126 }
127
128
129 gboolean GtkControlSlow( GtkWidget       *widget,
130                          GdkEventButton  *event,
131                          gpointer         user_data )
132 {
133     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
134     playlist_t *p_playlist;
135
136     p_playlist = vlc_object_find( p_intf->p_vlc,
137                                   VLC_OBJECT_PLAYLIST, FIND_CHILD );
138
139 #if 0
140     if( p_playlist )
141     {
142         playlist_Slow( p_playlist );
143         vlc_object_release( p_playlist );
144     }
145 #endif
146
147     return TRUE;
148 }
149
150
151 gboolean GtkControlFast( GtkWidget       *widget,
152                          GdkEventButton  *event,
153                          gpointer         user_data )
154 {
155     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
156     playlist_t *p_playlist;
157
158     p_playlist = vlc_object_find( p_intf->p_vlc,
159                                   VLC_OBJECT_PLAYLIST, FIND_CHILD );
160
161 #if 0
162     if( p_playlist )
163     {
164         playlist_Fast( p_playlist );
165         vlc_object_release( p_playlist );
166     }
167 #endif
168
169     return TRUE;
170 }
171
172
173 /****************************************************************************
174  * Control callbacks for menuitems
175  ****************************************************************************
176  * We have different callaback for menuitem since we must use the
177  * activate signal toi popdown the menu automatically
178  ****************************************************************************/
179 void GtkPlayActivate( GtkMenuItem * menuitem, gpointer user_data )
180 {
181     GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
182 }
183
184
185 void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
186 {
187     GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
188
189 }
190
191
192 void
193 GtKStopActivate                        (GtkMenuItem     *menuitem,
194                                         gpointer         user_data)
195 {
196     GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
197
198 }
199
200
201 void
202 GtkBackActivate                        (GtkMenuItem     *menuitem,
203                                         gpointer         user_data)
204 {
205     GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
206
207 }
208
209
210 void
211 GtkSlowActivate                        (GtkMenuItem     *menuitem,
212                                         gpointer         user_data)
213 {
214     GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
215
216 }
217
218
219 void
220 GtkFastActivate                        (GtkMenuItem     *menuitem,
221                                         gpointer         user_data)
222 {
223     GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );
224 }
225
226