gtk_callbacks.c
来自「VLC媒体播放程序」· C语言 代码 · 共 654 行 · 第 1/2 页
C
654 行
/***************************************************************************** * gtk_callbacks.c : Callbacks for the Gtk+ plugin. ***************************************************************************** * Copyright (C) 2000, 2001, 2003 VideoLAN * $Id: gtk_callbacks.c,v 1.16 2003/12/22 14:32:56 sam Exp $ * * Authors: Sam Hocevar <sam@zoy.org> * St閜hane Borel <stef@via.ecp.fr> * Julien BLACHE <jb@technologeek.org> * * 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 * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <sys/types.h> /* off_t */#include <stdlib.h>#include <vlc/vlc.h>#include <vlc/intf.h>#include <vlc/vout.h>#include <vlc/aout.h>#include <unistd.h>#include <gtk/gtk.h>#include <string.h>#include "gtk_callbacks.h"#include "gtk_interface.h"#include "gtk_support.h"#include "common.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 * E_(__GtkGetIntf)( GtkWidget * widget ){ void *p_data; if( GTK_IS_MENU_ITEM( widget ) ) { /* Look for a GTK_MENU */ while( widget->parent && !GTK_IS_MENU( widget ) ) { widget = widget->parent; } /* Maybe this one has the data */ p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" ); if( p_data ) { return p_data; } /* 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;}/***************************************************************************** * Callbacks *****************************************************************************//* * Main interface callbacks */#ifdef MODULE_NAME_IS_gtk# define GTKEXIT GtkExit#else# define GTKEXIT GnomeExit#endifgboolean GTKEXIT( GtkWidget *widget, gpointer user_data ){ intf_thread_t *p_intf = GtkGetIntf( widget ); vlc_mutex_lock( &p_intf->change_lock ); p_intf->p_vlc->b_die = VLC_TRUE; vlc_mutex_unlock( &p_intf->change_lock ); return TRUE;}void GtkClose( GtkMenuItem *menuitem, gpointer user_data ){ intf_thread_t *p_intf = GtkGetIntf( menuitem ); p_intf->b_die = VLC_TRUE;}gboolean GtkWindowDelete( GtkWidget *widget, GdkEvent *event, gpointer user_data ){ GTKEXIT( GTK_WIDGET( widget ), user_data ); return TRUE;}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 { gtk_widget_show( p_intf->p_sys->p_window ); } return TRUE;}gboolean GtkFullscreen( GtkWidget *widget, gpointer user_data){ 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 ) { return FALSE; } p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; vlc_object_release( p_vout ); return TRUE;}void GtkWindowDrag( GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data){ intf_thread_t * p_intf = GtkGetIntf( widget ); GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );}/**************************************************************************** * Slider management ****************************************************************************/gboolean GtkSliderRelease( GtkWidget *widget, GdkEventButton *event, gpointer user_data ){ intf_thread_t *p_intf = GtkGetIntf( widget ); vlc_mutex_lock( &p_intf->change_lock ); p_intf->p_sys->b_slider_free = VLC_TRUE; vlc_mutex_unlock( &p_intf->change_lock ); return FALSE;}gboolean GtkSliderPress( GtkWidget *widget, GdkEventButton *event, gpointer user_data){ intf_thread_t *p_intf = GtkGetIntf( widget ); vlc_mutex_lock( &p_intf->change_lock ); p_intf->p_sys->b_slider_free = VLC_FALSE; vlc_mutex_unlock( &p_intf->change_lock ); return FALSE;}/**************************************************************************** * DVD specific items ****************************************************************************/void GtkTitlePrev( GtkButton * button, gpointer user_data ){ intf_thread_t * p_intf; input_area_t * p_area; int i_id; p_intf = GtkGetIntf( button ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1; if( i_id > 0 ) { p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); input_ChangeArea( p_intf->p_sys->p_input, p_area ); input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); 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; unsigned int i_id; p_intf = GtkGetIntf( button ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 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]; vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); input_ChangeArea( p_intf->p_sys->p_input, p_area ); input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); 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 ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); p_area = p_intf->p_sys->p_input->stream.p_selected_area; if( p_area->i_part - 1 > 0 ) { p_area->i_part--; vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); input_ChangeArea( p_intf->p_sys->p_input, p_area ); input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); 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 ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); p_area = p_intf->p_sys->p_input->stream.p_selected_area; if( p_area->i_part + 1 < p_area->i_part_nb ) { p_area->i_part++; vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); input_ChangeArea( p_intf->p_sys->p_input, p_area ); input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?