]> git.sesse.net Git - vlc/blob - modules/gui/gtk/control.c
* ./modules/*: moved plugins to the new tree. Yet untested builds include
[vlc] / modules / gui / gtk / control.c
1 /*****************************************************************************
2  * control.c : functions to handle stream control buttons.
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  * $Id: control.c,v 1.1 2002/08/04 17:23:43 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
46 #include "playlist.h"
47 #include "common.h"
48
49 /****************************************************************************
50  * Control functions: this is where the functions are defined
51  ****************************************************************************
52  * These functions are button-items callbacks, and are used
53  * by other callbacks
54  ****************************************************************************/
55 gboolean GtkControlBack( GtkWidget       *widget,
56                          gpointer         user_data )
57 {
58     return FALSE;
59 }
60
61
62 gboolean GtkControlStop( GtkWidget       *widget,
63                          gpointer         user_data )
64 {
65     intf_thread_t *  p_intf = GtkGetIntf( widget );
66     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
67                                                        FIND_ANYWHERE );
68     if( p_playlist == NULL )
69     {
70         return FALSE;
71     }
72
73     playlist_Stop( p_playlist );
74     vlc_object_release( p_playlist );
75
76     return TRUE;
77 }
78
79
80 gboolean GtkControlPlay( GtkWidget       *widget,
81                          gpointer         user_data )
82 {
83     intf_thread_t *  p_intf = GtkGetIntf( widget );
84     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
85                                                        FIND_ANYWHERE );
86     if( p_playlist == NULL )
87     {
88         GtkFileOpenShow( widget, user_data );
89         return TRUE;
90     }
91
92     /* If the playlist is empty, open a file requester instead */
93     vlc_mutex_lock( &p_playlist->object_lock );
94     if( p_playlist->i_size )
95     {
96         vlc_mutex_unlock( &p_playlist->object_lock );
97         playlist_Play( p_playlist );
98         vlc_object_release( p_playlist );
99     }
100     else
101     {
102         vlc_mutex_unlock( &p_playlist->object_lock );
103         vlc_object_release( p_playlist );
104         GtkFileOpenShow( widget, user_data );
105     }
106
107     return TRUE;
108 }
109
110
111 gboolean GtkControlPause( GtkWidget       *widget,
112                           gpointer         user_data )
113 {
114     intf_thread_t *  p_intf = GtkGetIntf( widget );
115
116     if( p_intf->p_sys->p_input == NULL )
117     {
118         return FALSE;
119     }
120
121     input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
122
123     return TRUE;
124 }
125
126
127 gboolean GtkControlSlow( GtkWidget       *widget,
128                          gpointer         user_data )
129 {
130     intf_thread_t *  p_intf = GtkGetIntf( widget );
131
132     if( p_intf->p_sys->p_input == NULL )
133     {
134         return FALSE;
135     }
136
137     input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
138
139     return TRUE;
140 }
141
142
143 gboolean GtkControlFast( GtkWidget       *widget,
144                          gpointer         user_data )
145 {
146     intf_thread_t *  p_intf = GtkGetIntf( widget );
147
148     if( p_intf->p_sys->p_input == NULL )
149     {
150         return FALSE;
151     }
152
153     input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
154
155     return TRUE;
156 }
157