1 /*****************************************************************************
2 * gtk_callbacks.c : Callbacks for the Gtk+ plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gtk_callbacks.c,v 1.19 2001/05/19 00:39:30 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 #define MODULE_NAME gtk
26 #include "modules_inner.h"
28 /*****************************************************************************
30 *****************************************************************************/
32 #include <sys/types.h> /* off_t */
44 #include "stream_control.h"
45 #include "input_ext-intf.h"
47 #include "interface.h"
48 #include "intf_playlist.h"
52 #include "video_output.h"
54 #include "gtk_callbacks.h"
55 #include "gtk_interface.h"
56 #include "gtk_support.h"
61 /*****************************************************************************
63 *****************************************************************************/
66 * Main interface callbacks
69 gboolean GtkExit( GtkWidget *widget,
70 GdkEventButton *event,
73 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
75 vlc_mutex_lock( &p_intf->change_lock );
77 vlc_mutex_unlock( &p_intf->change_lock );
82 gboolean GtkWindowDelete( GtkWidget *widget,
86 GtkExit( GTK_WIDGET( widget ), NULL, user_data );
92 gboolean GtkWindowToggle( GtkWidget *widget,
93 GdkEventButton *event,
96 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
98 if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) )
100 gtk_widget_hide( p_intf->p_sys->p_window);
105 gtk_widget_show( p_intf->p_sys->p_window );
111 gboolean GtkFullscreen( GtkWidget *widget,
112 GdkEventButton *event,
115 if( p_vout_bank->i_count )
117 vlc_mutex_lock( &p_vout_bank->pp_vout[0]->change_lock );
119 p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;
121 vlc_mutex_unlock( &p_vout_bank->pp_vout[0]->change_lock );
131 void GtkWindowDrag( GtkWidget *widget,
132 GdkDragContext *drag_context,
135 GtkSelectionData *data,
140 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
141 int end = p_main->p_playlist->i_size;
142 GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
144 if( p_intf->p_input != NULL )
146 /* FIXME: temporary hack */
147 p_intf->p_input->b_eof = 1;
150 intf_PlaylistJumpto( p_main->p_playlist, end-1 );
154 /****************************************************************************
156 ****************************************************************************/
158 gboolean GtkSliderRelease( GtkWidget *widget,
159 GdkEventButton *event,
162 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
164 vlc_mutex_lock( &p_intf->change_lock );
165 p_intf->p_sys->b_slider_free = 1;
166 vlc_mutex_unlock( &p_intf->change_lock );
172 gboolean GtkSliderPress( GtkWidget *widget,
173 GdkEventButton *event,
176 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
178 vlc_mutex_lock( &p_intf->change_lock );
179 p_intf->p_sys->b_slider_free = 0;
180 vlc_mutex_unlock( &p_intf->change_lock );
186 /****************************************************************************
188 ****************************************************************************/
190 void GtkTitlePrev( GtkButton * button, gpointer user_data )
192 intf_thread_t * p_intf;
193 input_area_t * p_area;
196 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
197 i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
199 /* Disallow area 0 since it is used for video_ts.vob */
202 p_area = p_intf->p_input->stream.pp_areas[i_id];
203 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
205 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
207 p_intf->p_sys->b_title_update = 1;
208 GtkSetupMenus( p_intf );
213 void GtkTitleNext( GtkButton * button, gpointer user_data )
215 intf_thread_t * p_intf;
216 input_area_t * p_area;
219 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
220 i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
222 if( i_id < p_intf->p_input->stream.i_area_nb )
224 p_area = p_intf->p_input->stream.pp_areas[i_id];
225 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
227 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
229 p_intf->p_sys->b_title_update = 1;
230 GtkSetupMenus( p_intf );
236 void GtkChapterPrev( GtkButton * button, gpointer user_data )
238 intf_thread_t * p_intf;
239 input_area_t * p_area;
241 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
242 p_area = p_intf->p_input->stream.p_selected_area;
244 if( p_area->i_part > 0 )
247 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
249 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
251 p_intf->p_sys->b_chapter_update = 1;
252 GtkSetupMenus( p_intf );
257 void GtkChapterNext( GtkButton * button, gpointer user_data )
259 intf_thread_t * p_intf;
260 input_area_t * p_area;
262 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
263 p_area = p_intf->p_input->stream.p_selected_area;
265 if( p_area->i_part < p_area->i_part_nb )
268 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
270 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
272 p_intf->p_sys->b_chapter_update = 1;
273 GtkSetupMenus( p_intf );
277 /****************************************************************************
279 ****************************************************************************/
281 gboolean GtkAboutShow( GtkWidget *widget,
282 GdkEventButton *event,
285 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
287 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
289 p_intf->p_sys->p_about = create_intf_about();
290 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
293 gtk_widget_show( p_intf->p_sys->p_about );
294 gdk_window_raise( p_intf->p_sys->p_about->window );
299 void GtkAboutOk( GtkButton * button, gpointer user_data)
301 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
303 gtk_widget_hide( p_intf->p_sys->p_about );
307 /****************************************************************************
309 ****************************************************************************/
311 gboolean GtkJumpShow( GtkWidget *widget,
312 GdkEventButton *event,
315 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
317 if( !GTK_IS_WIDGET( p_intf->p_sys->p_jump ) )
319 p_intf->p_sys->p_jump = create_intf_jump();
320 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_jump ),
324 gtk_widget_show( p_intf->p_sys->p_jump );
325 gdk_window_raise( p_intf->p_sys->p_jump->window );
331 void GtkJumpOk( GtkButton *button,
334 intf_thread_t * p_intf;
341 p_intf = GetIntf( GTK_WIDGET( button ), (char*)user_data );
343 #define GET_VALUE( name ) \
344 gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( gtk_object_get_data( \
345 GTK_OBJECT( p_intf->p_sys->p_jump ), name ) ) )
347 i_hours = GET_VALUE( "jump_hour_spinbutton" );
348 i_minutes = GET_VALUE( "jump_minute_spinbutton" );
349 i_seconds = GET_VALUE( "jump_second_spinbutton" );
353 i_seconds += 60 *i_minutes + 3600* i_hours;
355 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
356 i_seek = i_seconds * 50 * p_intf->p_input->stream.i_mux_rate;
357 i_size = p_intf->p_input->stream.p_selected_area->i_size;
358 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
360 if( i_seek < i_size )
362 input_Seek( p_intf->p_input, i_seek );
364 p_main->p_playlist->b_stopped = 0;
365 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
369 void GtkJumpCancel( GtkButton *button,
372 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
376 /****************************************************************************
377 * Callbacks for menuitems
378 ****************************************************************************/
379 void GtkExitActivate( GtkMenuItem * menuitem, gpointer user_data )
381 GtkExit( GTK_WIDGET( menuitem ), NULL, user_data );
385 void GtkFullscreenActivate( GtkMenuItem * menuitem, gpointer user_data )
387 GtkFullscreen( GTK_WIDGET( menuitem ), NULL, user_data );
391 void GtkWindowToggleActivate( GtkMenuItem * menuitem, gpointer user_data )
393 GtkWindowToggle( GTK_WIDGET( menuitem ), NULL, user_data );
397 void GtkAboutActivate( GtkMenuItem * menuitem, gpointer user_data )
399 GtkAboutShow( GTK_WIDGET( menuitem ), NULL, user_data );
403 void GtkJumpActivate( GtkMenuItem * menuitem, gpointer user_data )
405 GtkJumpShow( GTK_WIDGET( menuitem ), NULL, user_data );