1 /*****************************************************************************
2 * gtk_callbacks.c : Callbacks for the Gtk+ plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gtk_callbacks.c,v 1.20 2001/05/23 23:08:20 stef Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Stéphane Borel <stef@via.ecp.fr>
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.
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.
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 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
29 #include <sys/types.h> /* off_t */
41 #include "stream_control.h"
42 #include "input_ext-intf.h"
44 #include "interface.h"
45 #include "intf_playlist.h"
49 #include "video_output.h"
51 #include "gtk_callbacks.h"
52 #include "gtk_interface.h"
53 #include "gtk_support.h"
58 /*****************************************************************************
60 *****************************************************************************/
63 * Main interface callbacks
66 gboolean GtkExit( GtkWidget *widget,
67 GdkEventButton *event,
70 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
72 vlc_mutex_lock( &p_intf->change_lock );
74 vlc_mutex_unlock( &p_intf->change_lock );
79 gboolean GtkWindowDelete( GtkWidget *widget,
83 GtkExit( GTK_WIDGET( widget ), NULL, user_data );
89 gboolean GtkWindowToggle( GtkWidget *widget,
90 GdkEventButton *event,
93 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
95 if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) )
97 gtk_widget_hide( p_intf->p_sys->p_window);
102 gtk_widget_show( p_intf->p_sys->p_window );
108 gboolean GtkFullscreen( GtkWidget *widget,
109 GdkEventButton *event,
112 if( p_vout_bank->i_count )
114 vlc_mutex_lock( &p_vout_bank->pp_vout[0]->change_lock );
116 p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;
118 vlc_mutex_unlock( &p_vout_bank->pp_vout[0]->change_lock );
128 void GtkWindowDrag( GtkWidget *widget,
129 GdkDragContext *drag_context,
132 GtkSelectionData *data,
137 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
138 int end = p_main->p_playlist->i_size;
139 GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
141 if( p_intf->p_input != NULL )
143 /* FIXME: temporary hack */
144 p_intf->p_input->b_eof = 1;
147 intf_PlaylistJumpto( p_main->p_playlist, end-1 );
151 /****************************************************************************
153 ****************************************************************************/
155 gboolean GtkSliderRelease( GtkWidget *widget,
156 GdkEventButton *event,
159 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
161 vlc_mutex_lock( &p_intf->change_lock );
162 p_intf->p_sys->b_slider_free = 1;
163 vlc_mutex_unlock( &p_intf->change_lock );
169 gboolean GtkSliderPress( GtkWidget *widget,
170 GdkEventButton *event,
173 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
175 vlc_mutex_lock( &p_intf->change_lock );
176 p_intf->p_sys->b_slider_free = 0;
177 vlc_mutex_unlock( &p_intf->change_lock );
183 /****************************************************************************
185 ****************************************************************************/
187 void GtkTitlePrev( GtkButton * button, gpointer user_data )
189 intf_thread_t * p_intf;
190 input_area_t * p_area;
193 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
194 i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
196 /* Disallow area 0 since it is used for video_ts.vob */
199 p_area = p_intf->p_input->stream.pp_areas[i_id];
200 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
202 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
204 p_intf->p_sys->b_title_update = 1;
205 GtkSetupMenus( p_intf );
210 void GtkTitleNext( GtkButton * button, gpointer user_data )
212 intf_thread_t * p_intf;
213 input_area_t * p_area;
216 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
217 i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
219 if( i_id < p_intf->p_input->stream.i_area_nb )
221 p_area = p_intf->p_input->stream.pp_areas[i_id];
222 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
224 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
226 p_intf->p_sys->b_title_update = 1;
227 GtkSetupMenus( p_intf );
233 void GtkChapterPrev( GtkButton * button, gpointer user_data )
235 intf_thread_t * p_intf;
236 input_area_t * p_area;
238 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
239 p_area = p_intf->p_input->stream.p_selected_area;
241 if( p_area->i_part > 0 )
244 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
246 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
248 p_intf->p_sys->b_chapter_update = 1;
249 GtkSetupMenus( p_intf );
254 void GtkChapterNext( GtkButton * button, gpointer user_data )
256 intf_thread_t * p_intf;
257 input_area_t * p_area;
259 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
260 p_area = p_intf->p_input->stream.p_selected_area;
262 if( p_area->i_part < p_area->i_part_nb )
265 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
267 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
269 p_intf->p_sys->b_chapter_update = 1;
270 GtkSetupMenus( p_intf );
274 /****************************************************************************
276 ****************************************************************************/
278 gboolean GtkAboutShow( GtkWidget *widget,
279 GdkEventButton *event,
282 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
284 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
286 p_intf->p_sys->p_about = create_intf_about();
287 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
290 gtk_widget_show( p_intf->p_sys->p_about );
291 gdk_window_raise( p_intf->p_sys->p_about->window );
296 void GtkAboutOk( GtkButton * button, gpointer user_data)
298 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
300 gtk_widget_hide( p_intf->p_sys->p_about );
304 /****************************************************************************
306 ****************************************************************************/
308 gboolean GtkJumpShow( GtkWidget *widget,
309 GdkEventButton *event,
312 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
314 if( !GTK_IS_WIDGET( p_intf->p_sys->p_jump ) )
316 p_intf->p_sys->p_jump = create_intf_jump();
317 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_jump ),
321 gtk_widget_show( p_intf->p_sys->p_jump );
322 gdk_window_raise( p_intf->p_sys->p_jump->window );
328 void GtkJumpOk( GtkButton *button,
331 intf_thread_t * p_intf;
338 p_intf = GetIntf( GTK_WIDGET( button ), (char*)user_data );
340 #define GET_VALUE( name ) \
341 gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( gtk_object_get_data( \
342 GTK_OBJECT( p_intf->p_sys->p_jump ), name ) ) )
344 i_hours = GET_VALUE( "jump_hour_spinbutton" );
345 i_minutes = GET_VALUE( "jump_minute_spinbutton" );
346 i_seconds = GET_VALUE( "jump_second_spinbutton" );
350 i_seconds += 60 *i_minutes + 3600* i_hours;
352 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
353 i_seek = i_seconds * 50 * p_intf->p_input->stream.i_mux_rate;
354 i_size = p_intf->p_input->stream.p_selected_area->i_size;
355 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
357 if( i_seek < i_size )
359 input_Seek( p_intf->p_input, i_seek );
361 p_main->p_playlist->b_stopped = 0;
362 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
366 void GtkJumpCancel( GtkButton *button,
369 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
373 /****************************************************************************
374 * Callbacks for menuitems
375 ****************************************************************************/
376 void GtkExitActivate( GtkMenuItem * menuitem, gpointer user_data )
378 GtkExit( GTK_WIDGET( menuitem ), NULL, user_data );
382 void GtkFullscreenActivate( GtkMenuItem * menuitem, gpointer user_data )
384 GtkFullscreen( GTK_WIDGET( menuitem ), NULL, user_data );
388 void GtkWindowToggleActivate( GtkMenuItem * menuitem, gpointer user_data )
390 GtkWindowToggle( GTK_WIDGET( menuitem ), NULL, user_data );
394 void GtkAboutActivate( GtkMenuItem * menuitem, gpointer user_data )
396 GtkAboutShow( GTK_WIDGET( menuitem ), NULL, user_data );
400 void GtkJumpActivate( GtkMenuItem * menuitem, gpointer user_data )
402 GtkJumpShow( GTK_WIDGET( menuitem ), NULL, user_data );