1 /*****************************************************************************
2 * gtk_callbacks.c : Callbacks for the Gtk+ plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gtk_callbacks.c,v 1.21 2001/05/30 05:19:03 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"
59 /*****************************************************************************
61 *****************************************************************************/
64 * Main interface callbacks
67 gboolean GtkExit( GtkWidget *widget,
68 GdkEventButton *event,
71 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
73 vlc_mutex_lock( &p_intf->change_lock );
75 vlc_mutex_unlock( &p_intf->change_lock );
80 gboolean GtkWindowDelete( GtkWidget *widget,
84 GtkExit( GTK_WIDGET( widget ), NULL, user_data );
90 gboolean GtkWindowToggle( GtkWidget *widget,
91 GdkEventButton *event,
94 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
96 if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) )
98 gtk_widget_hide( p_intf->p_sys->p_window);
103 gtk_widget_show( p_intf->p_sys->p_window );
109 gboolean GtkFullscreen( GtkWidget *widget,
110 GdkEventButton *event,
113 if( p_vout_bank->i_count )
115 vlc_mutex_lock( &p_vout_bank->pp_vout[0]->change_lock );
117 p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;
119 vlc_mutex_unlock( &p_vout_bank->pp_vout[0]->change_lock );
129 void GtkWindowDrag( GtkWidget *widget,
130 GdkDragContext *drag_context,
133 GtkSelectionData *data,
138 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
139 int end = p_main->p_playlist->i_size;
140 GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
142 if( p_intf->p_input != NULL )
144 /* FIXME: temporary hack */
145 p_intf->p_input->b_eof = 1;
148 intf_PlaylistJumpto( p_main->p_playlist, end-1 );
152 /****************************************************************************
154 ****************************************************************************/
156 gboolean GtkSliderRelease( GtkWidget *widget,
157 GdkEventButton *event,
160 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
162 vlc_mutex_lock( &p_intf->change_lock );
163 p_intf->p_sys->b_slider_free = 1;
164 vlc_mutex_unlock( &p_intf->change_lock );
170 gboolean GtkSliderPress( GtkWidget *widget,
171 GdkEventButton *event,
174 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
176 vlc_mutex_lock( &p_intf->change_lock );
177 p_intf->p_sys->b_slider_free = 0;
178 vlc_mutex_unlock( &p_intf->change_lock );
184 /****************************************************************************
186 ****************************************************************************/
188 void GtkTitlePrev( GtkButton * button, gpointer user_data )
190 intf_thread_t * p_intf;
191 input_area_t * p_area;
194 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
195 i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
197 /* Disallow area 0 since it is used for video_ts.vob */
200 p_area = p_intf->p_input->stream.pp_areas[i_id];
201 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
203 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
205 p_intf->p_sys->b_title_update = 1;
206 GtkSetupMenus( p_intf );
211 void GtkTitleNext( GtkButton * button, gpointer user_data )
213 intf_thread_t * p_intf;
214 input_area_t * p_area;
217 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
218 i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
220 if( i_id < p_intf->p_input->stream.i_area_nb )
222 p_area = p_intf->p_input->stream.pp_areas[i_id];
223 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
225 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
227 p_intf->p_sys->b_title_update = 1;
228 GtkSetupMenus( p_intf );
234 void GtkChapterPrev( GtkButton * button, gpointer user_data )
236 intf_thread_t * p_intf;
237 input_area_t * p_area;
239 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
240 p_area = p_intf->p_input->stream.p_selected_area;
242 if( p_area->i_part > 0 )
245 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
247 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
249 p_intf->p_sys->b_chapter_update = 1;
250 GtkSetupMenus( p_intf );
255 void GtkChapterNext( GtkButton * button, gpointer user_data )
257 intf_thread_t * p_intf;
258 input_area_t * p_area;
260 p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
261 p_area = p_intf->p_input->stream.p_selected_area;
263 if( p_area->i_part < p_area->i_part_nb )
266 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
268 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
270 p_intf->p_sys->b_chapter_update = 1;
271 GtkSetupMenus( p_intf );
275 /****************************************************************************
276 * Network specific items
277 ****************************************************************************/
278 void GtkNetworkJoin( GtkEditable * editable, gpointer user_data )
282 i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( editable ) );
283 intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );
285 // network_ChannelJoin( i_channel );
288 void GtkChannelGo( GtkButton * button, gpointer user_data )
294 window = gtk_widget_get_toplevel( GTK_WIDGET (button) );
295 spin = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( window ),
296 "network_channel_spinbutton" ) );
298 i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spin ) );
299 intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );
301 network_ChannelJoin( i_channel );
305 /****************************************************************************
307 ****************************************************************************/
309 gboolean GtkAboutShow( GtkWidget *widget,
310 GdkEventButton *event,
313 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
315 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
317 p_intf->p_sys->p_about = create_intf_about();
318 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
321 gtk_widget_show( p_intf->p_sys->p_about );
322 gdk_window_raise( p_intf->p_sys->p_about->window );
327 void GtkAboutOk( GtkButton * button, gpointer user_data)
329 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
331 gtk_widget_hide( p_intf->p_sys->p_about );
335 /****************************************************************************
337 ****************************************************************************/
339 gboolean GtkJumpShow( GtkWidget *widget,
340 GdkEventButton *event,
343 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
345 if( !GTK_IS_WIDGET( p_intf->p_sys->p_jump ) )
347 p_intf->p_sys->p_jump = create_intf_jump();
348 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_jump ),
352 gtk_widget_show( p_intf->p_sys->p_jump );
353 gdk_window_raise( p_intf->p_sys->p_jump->window );
359 void GtkJumpOk( GtkButton *button,
362 intf_thread_t * p_intf;
369 p_intf = GetIntf( GTK_WIDGET( button ), (char*)user_data );
371 #define GET_VALUE( name ) \
372 gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( gtk_object_get_data( \
373 GTK_OBJECT( p_intf->p_sys->p_jump ), name ) ) )
375 i_hours = GET_VALUE( "jump_hour_spinbutton" );
376 i_minutes = GET_VALUE( "jump_minute_spinbutton" );
377 i_seconds = GET_VALUE( "jump_second_spinbutton" );
381 i_seconds += 60 *i_minutes + 3600* i_hours;
383 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
384 i_seek = i_seconds * 50 * p_intf->p_input->stream.i_mux_rate;
385 i_size = p_intf->p_input->stream.p_selected_area->i_size;
386 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
388 if( i_seek < i_size )
390 input_Seek( p_intf->p_input, i_seek );
392 p_main->p_playlist->b_stopped = 0;
393 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
397 void GtkJumpCancel( GtkButton *button,
400 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
404 /****************************************************************************
405 * Callbacks for menuitems
406 ****************************************************************************/
407 void GtkExitActivate( GtkMenuItem * menuitem, gpointer user_data )
409 GtkExit( GTK_WIDGET( menuitem ), NULL, user_data );
413 void GtkFullscreenActivate( GtkMenuItem * menuitem, gpointer user_data )
415 GtkFullscreen( GTK_WIDGET( menuitem ), NULL, user_data );
419 void GtkWindowToggleActivate( GtkMenuItem * menuitem, gpointer user_data )
421 GtkWindowToggle( GTK_WIDGET( menuitem ), NULL, user_data );
425 void GtkAboutActivate( GtkMenuItem * menuitem, gpointer user_data )
427 GtkAboutShow( GTK_WIDGET( menuitem ), NULL, user_data );
431 void GtkJumpActivate( GtkMenuItem * menuitem, gpointer user_data )
433 GtkJumpShow( GTK_WIDGET( menuitem ), NULL, user_data );