2008-04-22 09:33:39 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer 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.
|
|
|
|
*
|
|
|
|
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2002-06-04 16:38:18 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2008-03-05 07:59:37 +00:00
|
|
|
#include "gtk_url.h"
|
2008-01-06 16:22:00 +00:00
|
|
|
#include "gtk_common.h"
|
2008-04-11 16:55:27 +00:00
|
|
|
#include "gui/interface.h"
|
|
|
|
#include "gui/app.h"
|
2008-04-12 16:03:07 +00:00
|
|
|
#include "gui/mplayer/gmplayer.h"
|
|
|
|
#include "gui/mplayer/widgets.h"
|
2007-03-16 00:00:13 +00:00
|
|
|
#include "help_mp.h"
|
2002-06-04 16:38:18 +00:00
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
GtkWidget * URL = NULL;
|
2002-06-04 16:38:18 +00:00
|
|
|
|
|
|
|
static GtkWidget * URLCombo;
|
|
|
|
static GtkWidget * URLEntry;
|
|
|
|
static GList * URLComboEntrys = NULL;
|
|
|
|
|
|
|
|
void ShowURLDialogBox( void )
|
|
|
|
{
|
2002-11-27 22:48:56 +00:00
|
|
|
if ( URL ) gtkActive( URL );
|
2002-06-04 16:38:18 +00:00
|
|
|
else URL=create_URL();
|
|
|
|
|
2002-08-26 22:20:58 +00:00
|
|
|
if ( URLList )
|
|
|
|
{
|
|
|
|
URLItem * item = URLList;
|
|
|
|
g_list_free( URLComboEntrys );
|
|
|
|
URLComboEntrys=NULL;
|
|
|
|
while( item )
|
|
|
|
{
|
|
|
|
URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url );
|
|
|
|
item=item->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-04 16:38:18 +00:00
|
|
|
if ( URLComboEntrys )
|
|
|
|
{
|
|
|
|
gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data );
|
|
|
|
gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys );
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show( URL );
|
|
|
|
}
|
|
|
|
|
|
|
|
void HideURLDialogBox( void )
|
|
|
|
{
|
2002-11-27 22:48:56 +00:00
|
|
|
if ( !URL ) return;
|
2002-06-04 16:38:18 +00:00
|
|
|
gtk_widget_hide( URL );
|
|
|
|
gtk_widget_destroy( URL );
|
2002-11-27 22:48:56 +00:00
|
|
|
URL=0;
|
2002-06-04 16:38:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void on_Button_pressed( GtkButton * button,gpointer user_data )
|
|
|
|
{
|
2002-08-26 22:20:58 +00:00
|
|
|
URLItem * item;
|
|
|
|
|
2002-06-04 16:38:18 +00:00
|
|
|
if ( (int)user_data )
|
|
|
|
{
|
|
|
|
gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) );
|
|
|
|
|
|
|
|
if ( str )
|
|
|
|
{
|
2003-05-23 12:58:13 +00:00
|
|
|
if ( strncmp( str,"http://",7 )
|
|
|
|
&& strncmp( str,"ftp://",6 )
|
|
|
|
&& strncmp( str,"mms://",6 )
|
|
|
|
&& strncmp( str,"pnm://",6 )
|
|
|
|
&& strncmp( str,"rtsp://",7 ) )
|
2002-06-04 16:38:18 +00:00
|
|
|
{
|
|
|
|
gchar * tmp;
|
|
|
|
tmp=malloc( strlen( str ) + 8 );
|
|
|
|
sprintf( tmp,"http://%s",str );
|
|
|
|
free( str ); str=tmp;
|
|
|
|
}
|
|
|
|
URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str );
|
2002-08-26 22:20:58 +00:00
|
|
|
|
|
|
|
item=calloc( 1,sizeof( URLItem ) );
|
|
|
|
item->url=gstrdup( str );
|
|
|
|
gtkSet( gtkAddURLItem,0,(void *)item );
|
2002-06-04 16:38:18 +00:00
|
|
|
|
|
|
|
guiSetFilename( guiIntfStruct.Filename,str ); guiIntfStruct.FilenameChanged=1;
|
2002-07-05 23:47:00 +00:00
|
|
|
mplEventHandling( evPlayNetwork,0 );
|
2002-06-04 16:38:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
HideURLDialogBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget * create_URL( void )
|
|
|
|
{
|
|
|
|
GtkWidget * vbox1;
|
|
|
|
GtkWidget * hbox1;
|
|
|
|
GtkWidget * hbuttonbox1;
|
|
|
|
GtkWidget * Ok;
|
|
|
|
GtkWidget * Cancel;
|
|
|
|
GtkAccelGroup * accel_group;
|
|
|
|
|
|
|
|
accel_group=gtk_accel_group_new();
|
|
|
|
|
2002-11-02 16:09:05 +00:00
|
|
|
URL=gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
2002-06-04 16:38:18 +00:00
|
|
|
gtk_widget_set_name( URL,"URL" );
|
|
|
|
gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL );
|
2002-07-05 23:47:00 +00:00
|
|
|
gtk_widget_set_usize( URL,384,70 );
|
2002-06-04 16:38:18 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT );
|
2002-07-05 23:47:00 +00:00
|
|
|
gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network );
|
2002-06-04 16:38:18 +00:00
|
|
|
gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER );
|
|
|
|
gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE );
|
2002-11-27 22:48:56 +00:00
|
|
|
gtk_window_set_wmclass( GTK_WINDOW( URL ),"Network","MPlayer" );
|
2002-07-05 23:47:00 +00:00
|
|
|
|
|
|
|
gtk_widget_realize( URL );
|
|
|
|
gtkAddIcon( URL );
|
2002-06-04 16:38:18 +00:00
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
vbox1=AddVBox( AddDialogFrame( URL ),0 );
|
|
|
|
hbox1=AddHBox( vbox1,1 );
|
|
|
|
AddLabel( "URL: ",hbox1 );
|
|
|
|
|
|
|
|
URLCombo=AddComboBox( hbox1 );
|
|
|
|
/*
|
|
|
|
gtk_combo_new();
|
2002-06-04 16:38:18 +00:00
|
|
|
gtk_widget_set_name( URLCombo,"URLCombo" );
|
|
|
|
gtk_widget_show( URLCombo );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 );
|
2002-11-27 22:48:56 +00:00
|
|
|
*/
|
2002-06-04 16:38:18 +00:00
|
|
|
URLEntry=GTK_COMBO( URLCombo )->entry;
|
|
|
|
gtk_widget_set_name( URLEntry,"URLEntry" );
|
|
|
|
gtk_widget_show( URLEntry );
|
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
AddHSeparator( vbox1 );
|
|
|
|
|
|
|
|
hbuttonbox1=AddHButtonBox( vbox1 );
|
|
|
|
gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
|
|
|
|
gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );
|
|
|
|
|
|
|
|
Ok=AddButton( MSGTR_Ok,hbuttonbox1 );
|
|
|
|
Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 );
|
2002-06-04 16:38:18 +00:00
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE );
|
|
|
|
gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );
|
|
|
|
|
2003-01-02 15:48:29 +00:00
|
|
|
gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&URL );
|
2002-11-27 22:48:56 +00:00
|
|
|
gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 );
|
|
|
|
gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL );
|
2002-06-04 16:38:18 +00:00
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
gtk_widget_grab_focus( URLEntry );
|
2002-06-04 16:38:18 +00:00
|
|
|
gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group );
|
|
|
|
|
|
|
|
return URL;
|
|
|
|
}
|
|
|
|
|