X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fgtk%2Fgtk_callbacks.c;h=5c17f40603bfd1a01ece3e9ad7fa4aefa6c8a359;hb=063cb8b6211d7acd370100dcfa3a839b91254e6b;hp=46ca900d9ec26d37849b1cc382bf2ffa0ef5f506;hpb=19ea8feb6db01c1deafb19f35ecee8eff81aeb02;p=vlc diff --git a/modules/gui/gtk/gtk_callbacks.c b/modules/gui/gtk/gtk_callbacks.c index 46ca900d9e..5c17f40603 100644 --- a/modules/gui/gtk/gtk_callbacks.c +++ b/modules/gui/gtk/gtk_callbacks.c @@ -1,18 +1,18 @@ /***************************************************************************** * gtk_callbacks.c : Callbacks for the Gtk+ plugin. ***************************************************************************** - * Copyright (C) 2000, 2001 VideoLAN - * $Id: gtk_callbacks.c,v 1.1 2002/08/04 17:23:43 sam Exp $ + * Copyright (C) 2000, 2001, 2003 the VideoLAN team + * $Id$ * - * Authors: Samuel Hocevar + * Authors: Sam Hocevar * Stéphane Borel * Julien BLACHE - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -45,12 +46,22 @@ #include "common.h" -#include "netutils.h" +#ifdef HAVE_CDDAX +#define CDDA_MRL "cddax://" +#else +#define CDDA_MRL "cdda://" +#endif + +#ifdef HAVE_VCDX +#define VCD_MRL "vcdx://" +#else +#define VCD_MRL "vcdx://" +#endif /***************************************************************************** * Useful function to retrieve p_intf ****************************************************************************/ -void * __GtkGetIntf( GtkWidget * widget ) +void * E_(__GtkGetIntf)( GtkWidget * widget ) { void *p_data; @@ -71,11 +82,15 @@ void * __GtkGetIntf( GtkWidget * widget ) /* Otherwise, the parent widget has it */ widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) ); + p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" ); + if( p_data ) + { + return p_data; + } } /* We look for the top widget */ widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) ); - p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" ); return p_data; @@ -89,7 +104,13 @@ void * __GtkGetIntf( GtkWidget * widget ) * Main interface callbacks */ -gboolean GtkExit( GtkWidget *widget, +#ifdef MODULE_NAME_IS_gtk +# define GTKEXIT GtkExit +#else +# define GTKEXIT GnomeExit +#endif + +gboolean GTKEXIT( GtkWidget *widget, gpointer user_data ) { intf_thread_t *p_intf = GtkGetIntf( widget ); @@ -112,7 +133,7 @@ gboolean GtkWindowDelete( GtkWidget *widget, GdkEvent *event, gpointer user_data ) { - GtkExit( GTK_WIDGET( widget ), user_data ); + GTKEXIT( GTK_WIDGET( widget ), user_data ); return TRUE; } @@ -122,12 +143,12 @@ gboolean GtkWindowToggle( GtkWidget *widget, gpointer user_data ) { intf_thread_t *p_intf = GtkGetIntf( widget ); - + if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) ) { gtk_widget_hide( p_intf->p_sys->p_window); - } - else + } + else { gtk_widget_show( p_intf->p_sys->p_window ); } @@ -141,6 +162,11 @@ gboolean GtkFullscreen( GtkWidget *widget, intf_thread_t *p_intf = GtkGetIntf( widget ); vout_thread_t *p_vout; + if( p_intf->p_sys->p_input == NULL ) + { + return FALSE; + } + p_vout = vlc_object_find( p_intf->p_sys->p_input, VLC_OBJECT_VOUT, FIND_CHILD ); if( p_vout == NULL ) @@ -178,7 +204,7 @@ gboolean GtkSliderRelease( GtkWidget *widget, intf_thread_t *p_intf = GtkGetIntf( widget ); vlc_mutex_lock( &p_intf->change_lock ); - p_intf->p_sys->b_slider_free = 1; + p_intf->p_sys->b_slider_free = VLC_TRUE; vlc_mutex_unlock( &p_intf->change_lock ); return FALSE; @@ -192,7 +218,7 @@ gboolean GtkSliderPress( GtkWidget *widget, intf_thread_t *p_intf = GtkGetIntf( widget ); vlc_mutex_lock( &p_intf->change_lock ); - p_intf->p_sys->b_slider_free = 0; + p_intf->p_sys->b_slider_free = VLC_FALSE; vlc_mutex_unlock( &p_intf->change_lock ); return FALSE; @@ -205,134 +231,55 @@ gboolean GtkSliderPress( GtkWidget *widget, void GtkTitlePrev( GtkButton * button, gpointer user_data ) { - intf_thread_t * p_intf; - input_area_t * p_area; - int i_id; - - p_intf = GtkGetIntf( button ); + intf_thread_t * p_intf = GtkGetIntf( button ); - i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1; + var_SetVoid( p_intf->p_sys->p_input, "prev-title" ); - if( i_id >= 0 ) - { - p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; - input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); - - input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); - - p_intf->p_sys->b_title_update = 1; - vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); - GtkSetupMenus( p_intf ); - vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); - } + p_intf->p_sys->b_title_update = VLC_TRUE; + vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); + GtkSetupMenus( p_intf ); + vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); } void GtkTitleNext( GtkButton * button, gpointer user_data ) { - intf_thread_t * p_intf; - input_area_t * p_area; - int i_id; - - p_intf = GtkGetIntf( button ); - i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1; - - if( i_id < p_intf->p_sys->p_input->stream.i_area_nb ) - { - p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; - input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); + intf_thread_t * p_intf = GtkGetIntf( button ); - input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); + var_SetVoid( p_intf->p_sys->p_input, "next-title" ); - p_intf->p_sys->b_title_update = 1; - vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); - GtkSetupMenus( p_intf ); - vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); - } + p_intf->p_sys->b_title_update = VLC_TRUE; + vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); + GtkSetupMenus( p_intf ); + vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); } void GtkChapterPrev( GtkButton * button, gpointer user_data ) { - intf_thread_t * p_intf; - input_area_t * p_area; - - p_intf = GtkGetIntf( button ); - p_area = p_intf->p_sys->p_input->stream.p_selected_area; - - if( p_area->i_part > 0 ) - { - p_area->i_part--; - input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); + intf_thread_t * p_intf = GtkGetIntf( button ); - input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); + var_SetVoid( p_intf->p_sys->p_input, "prev-chapter" ); - p_intf->p_sys->b_chapter_update = 1; - vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); - GtkSetupMenus( p_intf ); - vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); - } + p_intf->p_sys->b_chapter_update = VLC_TRUE; + vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); + GtkSetupMenus( p_intf ); + vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); } void GtkChapterNext( GtkButton * button, gpointer user_data ) { - intf_thread_t * p_intf; - input_area_t * p_area; - - p_intf = GtkGetIntf( button ); - p_area = p_intf->p_sys->p_input->stream.p_selected_area; - - if( p_area->i_part < p_area->i_part_nb ) - { - p_area->i_part++; - input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); + intf_thread_t * p_intf = GtkGetIntf( button ); - input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); + var_SetVoid( p_intf->p_sys->p_input, "next-chapter" ); - p_intf->p_sys->b_chapter_update = 1; - vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); - GtkSetupMenus( p_intf ); - vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); - } + p_intf->p_sys->b_chapter_update = VLC_TRUE; + vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); + GtkSetupMenus( p_intf ); + vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); } -/**************************************************************************** - * Network specific items - ****************************************************************************/ -void GtkNetworkJoin( GtkEditable * editable, gpointer user_data ) -{ - int i_channel; - - i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( editable ) ); -// msg_Dbg( "intf info: joining channel %d", i_channel ); - -// network_ChannelJoin( i_channel ); -} - -void GtkChannelGo( GtkButton * button, gpointer user_data ) -{ - GtkWidget * window; - GtkWidget * spin; - int i_channel; - - intf_thread_t *p_intf = GtkGetIntf( button ); - - window = gtk_widget_get_toplevel( GTK_WIDGET (button) ); - spin = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( window ), - "network_channel_spinbutton" ) ); - - i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spin ) ); - msg_Dbg( p_intf, "joining channel %d", i_channel ); - - vlc_mutex_lock( &p_intf->change_lock ); - network_ChannelJoin( p_intf, i_channel ); - vlc_mutex_unlock( &p_intf->change_lock ); - -// input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); -} - - /**************************************************************************** * About box ****************************************************************************/ @@ -404,9 +351,8 @@ void GtkJumpOk( GtkButton *button, i_seconds = GET_VALUE( "jump_second_spinbutton" ); #undef GET_VALUE - input_Seek( p_intf->p_sys->p_input, - i_seconds + 60 * i_minutes + 3600 * i_hours, - INPUT_SEEK_SECONDS | INPUT_SEEK_SET ); + var_SetTime( p_intf->p_sys->p_input, "time", + (int64_t)(i_seconds+60*i_minutes+3600*i_hours)*I64C(1000000)); gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) ); } @@ -444,7 +390,7 @@ gboolean GtkDiscEject ( GtkWidget *widget, gpointer user_data ) return FALSE; } - psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name; + psz_current = p_playlist->pp_items[ p_playlist->i_index ]->input.psz_name; /* * Get the active input @@ -458,31 +404,45 @@ gboolean GtkDiscEject ( GtkWidget *widget, gpointer user_data ) if( psz_current != NULL ) { - if( !strncmp(psz_current, "dvd:", 4) ) + if( !strncmp(psz_current, "dvd://", 4) ) { - switch( psz_current[4] ) + switch( psz_current[strlen("dvd://")] ) { case '\0': case '@': psz_device = config_GetPsz( p_intf, "dvd" ); break; default: - /* Omit the first 4 characters */ - psz_device = strdup( psz_current + 4 ); + /* Omit the first MRL-selector characters */ + psz_device = strdup( psz_current + strlen("dvd://" ) ); + break; + } + } + else if( !strncmp(psz_current, "vcd:", strlen("vcd:")) ) + { + switch( psz_current[strlen("vcd:")] ) + { + case '\0': + case '@': + psz_device = config_GetPsz( p_intf, VCD_MRL ); + break; + default: + /* Omit the beginning MRL-selector characters */ + psz_device = strdup( psz_current + strlen(VCD_MRL) ); break; } } - else if( !strncmp(psz_current, "vcd:", 4) ) + else if( !strncmp(psz_current, CDDA_MRL, strlen(CDDA_MRL) ) ) { - switch( psz_current[4] ) + switch( psz_current[strlen(CDDA_MRL)] ) { case '\0': case '@': - psz_device = config_GetPsz( p_intf, "vcd" ); + psz_device = config_GetPsz( p_intf, "cd-audio" ); break; default: - /* Omit the first 4 characters */ - psz_device = strdup( psz_current + 4 ); + /* Omit the beginning MRL-selector characters */ + psz_device = strdup( psz_current + strlen(CDDA_MRL) ); break; } } @@ -549,7 +509,6 @@ gboolean GtkMessagesShow( GtkWidget *widget, return TRUE; } - void GtkMessagesOk (GtkButton *button, gpointer user_data) @@ -579,3 +538,61 @@ GtkOpenNotebookChanged (GtkNotebook *notebook, GtkOpenChanged( GTK_WIDGET( notebook ), user_data ); } +/**************************************************************************** + * Audio management + ****************************************************************************/ +void GtkVolumeUp ( GtkMenuItem *menuitem, + gpointer user_data ) +{ + intf_thread_t *p_intf = GtkGetIntf( menuitem ); + audio_volume_t i_volume; + + aout_VolumeUp( p_intf, 1, &i_volume ); + p_intf->p_sys->b_mute = ( i_volume == 0 ) ? 1 : 0; +} + + +void GtkVolumeDown ( GtkMenuItem *menuitem, + gpointer user_data ) +{ + intf_thread_t *p_intf = GtkGetIntf( menuitem ); + audio_volume_t i_volume; + + aout_VolumeDown( p_intf, 1, &i_volume ); + p_intf->p_sys->b_mute = ( i_volume == 0 ) ? 1 : 0; +} + + +void GtkVolumeMute ( GtkMenuItem *menuitem, + gpointer user_data ) +{ + intf_thread_t *p_intf = GtkGetIntf( menuitem ); + audio_volume_t i_volume; + + aout_VolumeMute( p_intf, &i_volume ); + p_intf->p_sys->b_mute = ( i_volume == 0 ) ? 1 : 0; +} + +void +GtkMenubarDeinterlace ( GtkMenuItem *menuitem, + gpointer user_data) +{ + intf_thread_t *p_intf = GtkGetIntf( menuitem ); + + if( p_intf ) + msg_Dbg( p_intf, "GtkMenubarDeinterlace" ); +} + + +void +GtkPopupDeinterlace (GtkRadioMenuItem *radiomenuitem, + gpointer user_data) +{ + intf_thread_t *p_intf = GtkGetIntf( radiomenuitem ); + + if( p_intf ) + msg_Dbg( p_intf, "GtkPopupDeinterlace" ); +} + + +