]> git.sesse.net Git - vlc/blob - plugins/gtk/gtk_control.c
* ./plugins/gtk/*: the Gnome/Gtk+ interfaces have all their features back.
[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.12 2002/06/07 14:30:41 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                          gpointer         user_data )
56 {
57     return FALSE;
58 }
59
60
61 gboolean GtkControlStop( GtkWidget       *widget,
62                          gpointer         user_data )
63 {
64     intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
65     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
66                                                        FIND_ANYWHERE );
67     if( p_playlist == NULL )
68     {
69         return FALSE;
70     }
71
72     playlist_Stop( p_playlist );
73     vlc_object_release( p_playlist );
74
75     return TRUE;
76 }
77
78
79 gboolean GtkControlPlay( GtkWidget       *widget,
80                          gpointer         user_data )
81 {
82     intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
83     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
84                                                        FIND_ANYWHERE );
85     if( p_playlist == NULL )
86     {
87         GtkFileOpenShow( widget, user_data );
88         return TRUE;
89     }
90
91     /* If the playlist is empty, open a file requester instead */
92     vlc_mutex_lock( &p_playlist->object_lock );
93     if( p_playlist->i_size )
94     {
95         vlc_mutex_unlock( &p_playlist->object_lock );
96         playlist_Play( p_playlist );
97         vlc_object_release( p_playlist );
98     }
99     else
100     {
101         vlc_mutex_unlock( &p_playlist->object_lock );
102         vlc_object_release( p_playlist );
103         GtkFileOpenShow( widget, user_data );
104     }
105
106     return TRUE;
107 }
108
109
110 gboolean GtkControlPause( GtkWidget       *widget,
111                           gpointer         user_data )
112 {
113     intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
114
115     if( p_intf->p_sys->p_input == NULL )
116     {
117         return FALSE;
118     }
119
120     input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
121
122     return TRUE;
123 }
124
125
126 gboolean GtkControlSlow( GtkWidget       *widget,
127                          gpointer         user_data )
128 {
129     intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
130
131     if( p_intf->p_sys->p_input == NULL )
132     {
133         return FALSE;
134     }
135
136     input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
137
138     return TRUE;
139 }
140
141
142 gboolean GtkControlFast( GtkWidget       *widget,
143                          gpointer         user_data )
144 {
145     intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
146
147     if( p_intf->p_sys->p_input == NULL )
148     {
149         return FALSE;
150     }
151
152     input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
153
154     return TRUE;
155 }
156