~ubuntu-branches/debian/wheezy/vlc/wheezy

« back to all changes in this revision

Viewing changes to plugins/gtk/gtk_control.c

Tags: upstream-0.7.2.final
Import upstream version 0.7.2.final

Show diffs side-by-side

added added

removed removed

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