1
mirror of https://github.com/mpv-player/mpv synced 2025-01-24 19:37:30 +01:00

Add subtitle loader for gui

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3500 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
pontscho 2001-12-15 15:36:07 +00:00
parent c1099888ad
commit f0446a09ad
10 changed files with 279 additions and 190 deletions

View File

@ -64,6 +64,7 @@
#define evSetDVDSubtitle 5008 #define evSetDVDSubtitle 5008
#define evSetDVDTitle 5009 #define evSetDVDTitle 5009
#define evSetDVDChapter 5010 #define evSetDVDChapter 5010
#define evSubtitleLoaded 5011
#define evFName 7000 #define evFName 7000
#define evMovieTime 7001 #define evMovieTime 7001

View File

@ -32,20 +32,37 @@
gchar * fsSelectedFile = NULL; gchar * fsSelectedFile = NULL;
gchar * fsSelectedDirectory = NULL; gchar * fsSelectedDirectory = NULL;
unsigned char * fsThatDir = "."; unsigned char * fsThatDir = ".";
gchar * fsFilter = NULL; gchar fsFilter[8] = "*";
int fsPressed = 0; int fsPressed = 0;
#define fsLastFilterNames 6 int fsMessage = -1;
unsigned char * fsFilterNames[fsLastFilterNames+1][2] = int fsType = 0;
{ { "MPEG files( *.mpg )", "*.mpg" },
{ "VOB files( *.vob )", "*.vob" },
{ "AVI files( *.avi )", "*.avi" },
{ "QT files( *.mov )", "*.mov" },
{ "ASF files( *.asf )", "*.asf" },
{ "VIVO files( *.viv )", "*.viv" },
{ "All files( * )", "*" } };
// .avi .mpg .vob .mov .viv .asf #define fsNumberOfVideoFilterNames 6
char * fsVideoFilterNames[fsNumberOfVideoFilterNames+1][2] =
{ { "MPEG files ( *.mpg )", "*.mpg" },
{ "VOB files ( *.vob )", "*.vob" },
{ "AVI files ( *.avi )", "*.avi" },
{ "QT files ( *.mov )", "*.mov" },
{ "ASF files ( *.asf )", "*.asf" },
{ "VIVO files ( *.viv )", "*.viv" },
{ "All files ( * )", "*" } };
#define fsNumberOfSubtitleFilterNames 8
char * fsSubtitleFilterNames[fsNumberOfSubtitleFilterNames+1][2] =
{ { "UTF ( *.utf )", "*.utf" },
{ "SUB ( *.sub )", "*.sub" },
{ "SRT ( *.srt )", "*.str" },
{ "SMI ( *.smi )", "*.smi" },
{ "RT ( *.rt )", "*.rt" },
{ "TXT ( *.txt )", "*.txt" },
{ "SSA ( *.ssa )", "*.ssa" },
{ "AQT ( *.aqt )", "*.aqt" },
{ "All files ( * )", "*" } };
#define fsNumberOfOtherFilterNames 0
char * fsOtherFilterNames[fsNumberOfOtherFilterNames+1][2] =
{ { "All types", "*" } };
GtkWidget * fsFileNamesList; GtkWidget * fsFileNamesList;
GtkWidget * fsFNameList; GtkWidget * fsFNameList;
@ -55,78 +72,134 @@ GtkWidget * fsOk;
GtkWidget * fsUp; GtkWidget * fsUp;
GtkWidget * fsCancel; GtkWidget * fsCancel;
GtkWidget * fsCombo4; GtkWidget * fsCombo4;
GtkWidget * fsComboEntry2; GtkWidget * fsPathCombo;
GList * fsList_items = NULL; GList * fsList_items = NULL;
GList * fsTopList_items = NULL; GList * fsTopList_items = NULL;
GtkWidget * List;
GtkWidget * fsFilterCombo;
void CheckDir( GtkWidget * list,unsigned char * directory )
GtkStyle * style;
GdkPixmap * dpixmap;
GdkPixmap * fpixmap;
GdkBitmap * dmask;
GdkBitmap * fmask;
void CheckDir( GtkWidget * list,char * directory )
{ {
struct stat fs; struct stat fs;
int i,c=2; int i,c=2;
gchar * str[1][2]; gchar * str[1][2];
GdkPixmap * dpixmap,*fpixmap,*pixmap; GdkPixmap * pixmap;
GdkBitmap * dmask,*fmask,*mask; GdkBitmap * mask;
GtkStyle * style;
glob_t gg; glob_t gg;
if ( !fsFilter[0] ) return;
gtk_widget_hide( list ); gtk_widget_hide( list );
gtk_clist_clear( GTK_CLIST( list ) );
str[0][0]=NULL; str[0][0]=NULL;
style=gtk_widget_get_style( fsFileSelect );
dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm );
fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm );
pixmap=dpixmap; mask=dmask; pixmap=dpixmap; mask=dmask;
str[0][0]=NULL; str[0][1]=(gchar *)malloc( 3 ); str[0][0]=NULL; str[0][1]=(gchar *)malloc( 3 );
strcpy( str[0][1],"." ); strcpy( str[0][1],"." ); gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),0,0,pixmap,mask );
gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),0,0,pixmap,mask ); strcpy( str[0][1],".." ); gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),1,0,pixmap,mask );
strcpy( str[0][1],".." );
gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),1,0,pixmap,mask );
free( str[0][0] ); free( str[0][0] );
glob( "*",GLOB_NOSORT,NULL,&gg ); glob( "*",0,NULL,&gg );
// glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg );
for( i=0;i<gg.gl_pathc;i++ ) for( i=0;i<gg.gl_pathc;i++ )
{ {
if( !strcmp( gg.gl_pathv[i],"." ) || !strcmp( gg.gl_pathv[i],".." ) ) continue;
stat( gg.gl_pathv[i],&fs ); stat( gg.gl_pathv[i],&fs );
if( S_ISDIR( fs.st_mode ) ) if( !S_ISDIR( fs.st_mode ) ) continue;
{
str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 2 ); str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 1 );
strcpy( str[0][1],"" ); strcpy( str[0][1],gg.gl_pathv[i] );
strcat( str[0][1],gg.gl_pathv[i] ); pixmap=dpixmap; mask=dmask;
pixmap=dpixmap; mask=dmask; gtk_clist_append( GTK_CLIST( list ),str[0] );
gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask );
gtk_clist_set_pixmap( GTK_CLIST( list ),c,0,pixmap,mask ); free( str[0][1] );
free( str[0][1] );
c++;
}
} }
globfree( &gg ); globfree( &gg );
glob( fsFilter,GLOB_NOSORT,NULL,&gg );
glob( fsFilter,0,NULL,&gg );
#if 0
if ( !strcmp( fsFilter,"*" ) )
{
char * f = strdup( fsFilter );
int i;
for( i=0;i<strlen( f );i++ )
if ( ( f[i] >= 'A' )&&( f[i] <= 'Z' ) ) f[i]+=32;
glob( f,GLOB_APPEND,NULL,&gg );
for( i=0;i<strlen( f );i++ )
if ( ( f[i] >= 'a' )&&( f[i] <= 'z' ) ) f[i]-=32;
glob( f,GLOB_APPEND,NULL,&gg );
free( f );
}
#endif
// glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg );
pixmap=fpixmap; mask=fmask; pixmap=fpixmap; mask=fmask;
for( i=0;i<gg.gl_pathc;i++ ) for( i=0;i<gg.gl_pathc;i++ )
{ {
if( !strcmp( gg.gl_pathv[i],"." ) || !strcmp( gg.gl_pathv[i],".." ) ) continue;
stat( gg.gl_pathv[i],&fs ); stat( gg.gl_pathv[i],&fs );
if( S_ISDIR( fs.st_mode ) ) continue; if( S_ISDIR( fs.st_mode ) ) continue;
str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 2 );
strcpy( str[0][1],"" ); strcat( str[0][1],gg.gl_pathv[i] ); str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 1 );
strcpy( str[0][1],gg.gl_pathv[i] );
gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_append( GTK_CLIST( list ),str[0] );
gtk_clist_set_pixmap( GTK_CLIST( list ),c,0,pixmap,mask ); gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask );
free( str[0][1] ); free( str[0][1] );
c++;
} }
globfree( &gg ); globfree( &gg );
gtk_clist_set_sort_type( GTK_CLIST( list ),GTK_SORT_ASCENDING );
gtk_clist_set_compare_func( GTK_CLIST( list ),NULL );
gtk_clist_set_sort_column( GTK_CLIST( list ),1 );
gtk_clist_sort( GTK_CLIST( list ) );
gtk_clist_set_column_width( GTK_CLIST( list ),0,17 ); gtk_clist_set_column_width( GTK_CLIST( list ),0,17 );
gtk_clist_select_row( GTK_CLIST( list ),0,1 ); gtk_clist_select_row( GTK_CLIST( list ),0,1 );
gtk_widget_show( list ); gtk_widget_show( list );
} }
void ShowFileSelect( int type )
{
int i;
if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect );
fsType=type;
switch ( type )
{
case fsVideoSelector:
fsMessage=evFileLoaded;
gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect );
fsList_items=NULL;
for( i=0;i<fsNumberOfVideoFilterNames + 1;i++ )
fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] );
gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items );
g_list_free( fsList_items );
gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[fsNumberOfVideoFilterNames][0] );
break;
case fsSubtitleSelector:
gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_SubtitleSelect );
fsList_items=NULL;
for( i=0;i<fsNumberOfSubtitleFilterNames + 1;i++ )
fsList_items=g_list_append( fsList_items,fsSubtitleFilterNames[i][0] );
gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items );
g_list_free( fsList_items );
gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsSubtitleFilterNames[fsNumberOfSubtitleFilterNames][0] );
break;
case fsOtherSelector:
gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_OtherSelect );
fsList_items=NULL;
for( i=0;i<fsNumberOfSubtitleFilterNames + 1;i++ )
fsList_items=g_list_append( fsList_items,fsOtherFilterNames[i][0] );
gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items );
g_list_free( fsList_items );
gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsOtherFilterNames[fsNumberOfOtherFilterNames][0] );
break;
}
gtk_widget_show( FileSelect );
gtkVisibleFileSelect=1;
}
void HideFileSelect( void ) void HideFileSelect( void )
{ {
gtk_widget_hide( fsFileSelect ); gtk_widget_hide( fsFileSelect );
@ -138,83 +211,74 @@ void HideFileSelect( void )
void fs_fsFileSelect_destroy( GtkObject * object,gpointer user_data ) void fs_fsFileSelect_destroy( GtkObject * object,gpointer user_data )
{ HideFileSelect(); } { HideFileSelect(); }
void fs_combo_entry1_activate( GtkEditable * editable,gpointer user_data ) void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data )
{ {
unsigned char * str; strcpy( fsFilter,gtk_entry_get_text( GTK_ENTRY( user_data ) ) );
CheckDir( fsFNameList,get_current_dir_name() );
str=gtk_entry_get_text( GTK_ENTRY(user_data ) );
gtk_clist_clear( GTK_CLIST( fsFNameList ) );
if( fsFilter ) free( fsFilter );
if( ( fsFilter=(unsigned char *)malloc( strlen( str ) + 1 ) ) == NULL )
{
dbprintf( 0,"[gtk] not enough memory.\n" );
exit( 0 );
}
strcpy( fsFilter,str );
CheckDir( fsFNameList,(unsigned char *)get_current_dir_name() );
} }
void fs_combo_entry1_changed( GtkEditable * editable,gpointer user_data ) void fs_fsFilterCombo_changed( GtkEditable * editable,gpointer user_data )
{ {
unsigned char * str; char * str;
int i; int i;
str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); str=gtk_entry_get_text( GTK_ENTRY(user_data ) );
for( i=0;i<fsLastFilterNames+1;i++ ) switch ( fsType )
{ {
if( !strcmp( str,fsFilterNames[i][0] ) ) case fsVideoSelector:
{ for( i=0;i<fsNumberOfVideoFilterNames+1;i++ )
if( fsFilter ) free( fsFilter ); if( !strcmp( str,fsVideoFilterNames[i][0] ) )
if( ( fsFilter=(unsigned char *)malloc( 6 ) ) == NULL ) {
{ strcpy( fsFilter,fsVideoFilterNames[i][1] );
dbprintf( 0,"[gtk] not enough memory.\n" ); CheckDir( fsFNameList,get_current_dir_name() );
exit( 0 ); break;
} }
strcpy( fsFilter,fsFilterNames[i][1] ); break;
} case fsSubtitleSelector:
for( i=0;i<fsNumberOfSubtitleFilterNames+1;i++ )
if( !strcmp( str,fsSubtitleFilterNames[i][0] ) )
{
strcpy( fsFilter,fsSubtitleFilterNames[i][1] );
CheckDir( fsFNameList,get_current_dir_name() );
break;
}
break;
case fsOtherSelector:
for( i=0;i<fsNumberOfOtherFilterNames+1;i++ )
if( !strcmp( str,fsOtherFilterNames[i][0] ) )
{
strcpy( fsFilter,fsOtherFilterNames[i][1] );
CheckDir( fsFNameList,get_current_dir_name() );
break;
}
break;
} }
gtk_clist_clear( GTK_CLIST( fsFNameList ) );
CheckDir( fsFNameList,(unsigned char *)get_current_dir_name() );
} }
void fs_fsComboEntry2_activate( GtkEditable * editable,gpointer user_data ) void fs_fsPathCombo_activate( GtkEditable * editable,gpointer user_data )
{ {
unsigned char * str; unsigned char * str;
str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
if ( chdir( str ) != -1 ) if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
{
gtk_clist_clear( GTK_CLIST( fsFNameList ) );
CheckDir( fsFNameList,(unsigned char *)get_current_dir_name() );
}
} }
void fs_fsComboEntry2_changed( GtkEditable * editable,gpointer user_data ) void fs_fsPathCombo_changed( GtkEditable * editable,gpointer user_data )
{ {
unsigned char * str; unsigned char * str;
str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
fsPressed=2; fsPressed=2;
// if ( if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
// tmp=(unsigned char *)malloc( strlen( fsSelectedDirectory ) + 5 );
// strcpy( tmp,fsSelectedDirectory ); strcat( tmp,"/*" );
// fprintf( stderr,"str: %s\n",tmp );
// free( tmp );
if ( chdir( str ) != -1 )
{
gtk_clist_clear( GTK_CLIST( fsFNameList ) );
CheckDir( fsFNameList,(unsigned char *)get_current_dir_name() );
}
} }
void fs_Up_released( GtkButton * button,gpointer user_data ) void fs_Up_released( GtkButton * button,gpointer user_data )
{ {
chdir( ".." ); chdir( ".." );
fsSelectedFile=fsThatDir; fsSelectedFile=fsThatDir;
gtk_clist_clear( GTK_CLIST( user_data ) ); CheckDir( fsFNameList,get_current_dir_name() );
CheckDir( fsFNameList,(unsigned char *)get_current_dir_name() ); gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
gtk_entry_set_text( GTK_ENTRY( fsComboEntry2 ),(unsigned char *)get_current_dir_name() );
return; return;
} }
@ -238,9 +302,8 @@ void fs_Ok_released( GtkButton * button,gpointer user_data )
{ {
chdir( fsSelectedFile ); chdir( fsSelectedFile );
fsSelectedFile=fsThatDir; fsSelectedFile=fsThatDir;
if( fsFNameList != NULL ) gtk_clist_clear( GTK_CLIST( fsFNameList ) ); CheckDir( fsFNameList,get_current_dir_name() );
CheckDir( fsFNameList,(unsigned char *)get_current_dir_name() ); gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
gtk_entry_set_text( GTK_ENTRY( fsComboEntry2 ),(unsigned char *)get_current_dir_name() );
return; return;
} }
@ -250,18 +313,18 @@ void fs_Ok_released( GtkButton * button,gpointer user_data )
{ {
case 1: case 1:
fsSelectedDirectory=(unsigned char *)get_current_dir_name(); fsSelectedDirectory=(unsigned char *)get_current_dir_name();
printf("[gtk-fs] 1-fsSelectedFile: %s\n",fsSelectedFile); // printf("[gtk-fs] 1-fsSelectedFile: %s\n",fsSelectedFile);
#ifdef DEBUG // #ifdef DEBUG
dbprintf( 1,"[gtk-fs] fsSelectedFile: %s\n",fsSelectedFile ); // dbprintf( 1,"[gtk-fs] fsSelectedFile: %s\n",fsSelectedFile );
#endif // #endif
break; break;
case 2: case 2:
str=gtk_entry_get_text( GTK_ENTRY( fsComboEntry2 ) ); str=gtk_entry_get_text( GTK_ENTRY( fsPathCombo ) );
fsSelectedFile=str; fsSelectedFile=str;
printf("[gtk-fs] 2-fsSelectedFile: '%s' \n",fsSelectedFile); // printf("[gtk-fs] 2-fsSelectedFile: '%s' \n",fsSelectedFile);
#ifdef DEBUG // #ifdef DEBUG
dbprintf( 1,"[gtk-fs] fsSelectedFile: %s\n",fsSelectedFile ); // dbprintf( 1,"[gtk-fs] fsSelectedFile: %s\n",fsSelectedFile );
#endif // #endif
if ( !fsFileExist( fsSelectedFile ) ) return; if ( !fsFileExist( fsSelectedFile ) ) return;
fsSelectedDirectory=fsSelectedFile; fsSelectedDirectory=fsSelectedFile;
size=strlen( fsSelectedDirectory ); size=strlen( fsSelectedDirectory );
@ -274,16 +337,33 @@ void fs_Ok_released( GtkButton * button,gpointer user_data )
break; break;
} }
} }
printf("[gtk-fs-xxx] fsSelectedFile: '%s' \n",fsSelectedFile); // printf("[gtk-fs-xxx] fsSelectedFile: '%s' \n",fsSelectedFile);
printf("[gtk-fs-xxx] fsSelectedDirectory: '%s' \n",fsSelectedDirectory); // printf("[gtk-fs-xxx] fsSelectedDirectory: '%s' \n",fsSelectedDirectory);
break; break;
} }
strcpy( gtkShMem->fs.dir,fsSelectedDirectory ); // printf( "----gtk---> directory: %s\n",fsSelectedDirectory );
strcpy( gtkShMem->fs.filename,fsSelectedFile ); // printf( "----gtk---> filename: %s\n",fsSelectedFile );
printf( "----gtk---> directory: %s\n",fsSelectedDirectory ); switch ( fsType )
printf( "----gtk---> filename: %s\n",fsSelectedFile ); {
printf( "----gtksm-> directory: %s\n",gtkShMem->fs.dir ); case fsVideoSelector:
printf( "----gtksm-> filename: %s\n",gtkShMem->fs.filename ); strcpy( gtkShMem->fs.dir,fsSelectedDirectory );
strcpy( gtkShMem->fs.filename,fsSelectedFile );
// printf( "----gtksm-> directory: %s\n",gtkShMem->fs.dir );
// printf( "----gtksm-> filename: %s\n",gtkShMem->fs.filename );
gtkSendMessage( evFileLoaded );
break;
case fsSubtitleSelector:
strcpy( gtkShMem->fs.subtitlename,fsSelectedDirectory );
strcat( gtkShMem->fs.subtitlename,"/" );
strcat( gtkShMem->fs.subtitlename,fsSelectedFile );
gtkSendMessage( evSubtitleLoaded );
break;
case fsOtherSelector:
strcpy( gtkShMem->fs.otherfilename,fsSelectedDirectory );
strcat( gtkShMem->fs.subtitlename,"/" );
strcat( gtkShMem->fs.otherfilename,fsSelectedFile );
break;
}
item=fsTopList_items; item=fsTopList_items;
while( item ) while( item )
{ {
@ -295,7 +375,6 @@ printf( "----gtksm-> filename: %s\n",gtkShMem->fs.filename );
fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() ); fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() );
gtk_combo_set_popdown_strings( GTK_COMBO( user_data ),fsTopList_items ); gtk_combo_set_popdown_strings( GTK_COMBO( user_data ),fsTopList_items );
} }
gtkSendMessage( evFileLoaded );
} }
void fs_Cancel_released( GtkButton * button,gpointer user_data ) void fs_Cancel_released( GtkButton * button,gpointer user_data )
@ -303,7 +382,7 @@ void fs_Cancel_released( GtkButton * button,gpointer user_data )
void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data )
{ {
gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); fsSelectedFile++; gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile );
fsPressed=1; fsPressed=1;
if( !bevent ) return; if( !bevent ) return;
if( bevent->type == GDK_2BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); if( bevent->type == GDK_2BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) );
@ -340,29 +419,15 @@ GtkWidget * create_FileSelect( void )
GtkWidget * fsFNameListWindow; GtkWidget * fsFNameListWindow;
GtkWidget * label1; GtkWidget * label1;
GtkWidget * hseparator2; GtkWidget * hseparator2;
GtkWidget * List;
GtkWidget * combo_entry1;
GtkWidget * hseparator3; GtkWidget * hseparator3;
GtkWidget * hbuttonbox3; GtkWidget * hbuttonbox3;
int i; int i;
// GtkWidget * okpixmapwid,*uppixmapwid,*cancelpixmapwid;
// GdkPixmap * okpixmap,*uppixmap,*cancelpixmap;
// GdkBitmap * okmask,*upmask,*cancelmask;
// GtkStyle * okstyle,*upstyle,*cancelstyle;
GtkWidget * uppixmapwid; GtkWidget * uppixmapwid;
GdkPixmap * uppixmap; GdkPixmap * uppixmap;
GdkBitmap * upmask; GdkBitmap * upmask;
GtkStyle * upstyle; GtkStyle * upstyle;
if( ( fsFilter=(unsigned char *)malloc( 3 ) ) == NULL )
{
dbprintf( 0,"[gtk] not enough memory.\n" );
exit( 0 );
}
strcpy( fsFilter,"*" );
fsFileSelect=gtk_window_new( GTK_WINDOW_DIALOG ); fsFileSelect=gtk_window_new( GTK_WINDOW_DIALOG );
gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); gtk_widget_set_name( fsFileSelect,"fsFileSelect" );
gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect );
@ -374,6 +439,10 @@ GtkWidget * create_FileSelect( void )
gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),FALSE,FALSE,TRUE ); gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),FALSE,FALSE,TRUE );
fsColorMap=gdk_colormap_get_system(); fsColorMap=gdk_colormap_get_system();
style=gtk_widget_get_style( fsFileSelect );
dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm );
fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm );
FSFrame=gtk_frame_new( NULL ); FSFrame=gtk_frame_new( NULL );
gtk_widget_set_name( FSFrame,"FSFrame" ); gtk_widget_set_name( FSFrame,"FSFrame" );
gtk_widget_ref( FSFrame ); gtk_widget_ref( FSFrame );
@ -444,12 +513,12 @@ GtkWidget * create_FileSelect( void )
fsTopList_items=g_list_append( fsTopList_items,"/" ); fsTopList_items=g_list_append( fsTopList_items,"/" );
gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items );
fsComboEntry2=GTK_COMBO( fsCombo4 )->entry; fsPathCombo=GTK_COMBO( fsCombo4 )->entry;
gtk_widget_set_name( fsComboEntry2,"fsComboEntry2" ); gtk_widget_set_name( fsPathCombo,"fsPathCombo" );
gtk_widget_ref( fsComboEntry2 ); gtk_widget_ref( fsPathCombo );
gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsComboEntry2",fsComboEntry2,( GtkDestroyNotify ) gtk_widget_unref ); gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsPathCombo",fsPathCombo,( GtkDestroyNotify ) gtk_widget_unref );
gtk_widget_show( fsComboEntry2 ); gtk_widget_show( fsPathCombo );
gtk_widget_set_usize( fsComboEntry2,-2,20 ); gtk_widget_set_usize( fsPathCombo,-2,20 );
vseparator1=gtk_vseparator_new(); vseparator1=gtk_vseparator_new();
gtk_widget_set_name( vseparator1,"vseparator1" ); gtk_widget_set_name( vseparator1,"vseparator1" );
@ -508,7 +577,7 @@ GtkWidget * create_FileSelect( void )
gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE );
gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) );
gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT );
CheckDir( fsFNameList,(unsigned char *)get_current_dir_name() ); CheckDir( fsFNameList,get_current_dir_name() );
label1=gtk_label_new( "label1" ); label1=gtk_label_new( "label1" );
gtk_widget_set_name( label1,"label1" ); gtk_widget_set_name( label1,"label1" );
@ -536,18 +605,19 @@ GtkWidget * create_FileSelect( void )
gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 );
gtk_widget_set_usize( List,-2,20 ); gtk_widget_set_usize( List,-2,20 );
fsList_items=NULL; fsList_items=NULL;
for( i=0;i<fsLastFilterNames + 1;i++ ) for( i=0;i<fsNumberOfVideoFilterNames + 1;i++ )
fsList_items=g_list_append( fsList_items,fsFilterNames[i][0] ); fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] );
gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items );
g_list_free( fsList_items ); g_list_free( fsList_items );
combo_entry1=GTK_COMBO( List )->entry; fsFilterCombo=GTK_COMBO( List )->entry;
gtk_widget_set_name( combo_entry1,"combo_entry1" ); gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" );
gtk_widget_ref( combo_entry1 ); gtk_widget_ref( fsFilterCombo );
gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"combo_entry1",combo_entry1, gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsFilterCombo",fsFilterCombo,
( GtkDestroyNotify ) gtk_widget_unref ); ( GtkDestroyNotify ) gtk_widget_unref );
gtk_widget_show( combo_entry1 ); gtk_widget_show( fsFilterCombo );
gtk_entry_set_text( GTK_ENTRY( combo_entry1 ),fsFilterNames[fsLastFilterNames][0] ); gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE );
gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[fsNumberOfVideoFilterNames][0] );
hseparator3=gtk_hseparator_new(); hseparator3=gtk_hseparator_new();
gtk_widget_set_name( hseparator3,"hseparator3" ); gtk_widget_set_name( hseparator3,"hseparator3" );
@ -570,15 +640,6 @@ GtkWidget * create_FileSelect( void )
gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox3 ),85,20 ); gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox3 ),85,20 );
gtk_button_box_set_child_ipadding( GTK_BUTTON_BOX( hbuttonbox3 ),0,0 ); gtk_button_box_set_child_ipadding( GTK_BUTTON_BOX( hbuttonbox3 ),0,0 );
// okstyle=gtk_widget_get_style( fsFileSelect );
// okpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&okmask,&okstyle->bg[GTK_STATE_NORMAL],(gchar **)ok_xpm );
// okpixmapwid=gtk_pixmap_new( okpixmap,okmask );
// gtk_widget_show( okpixmapwid );
// fsOk=gtk_button_new();
// gtk_container_add( GTK_CONTAINER(fsOk ),okpixmapwid );
// gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsOk );
// gtk_widget_show( fsOk );
fsOk=gtk_button_new_with_label( MSGTR_Ok ); fsOk=gtk_button_new_with_label( MSGTR_Ok );
gtk_widget_set_name( fsOk,MSGTR_Ok ); gtk_widget_set_name( fsOk,MSGTR_Ok );
gtk_widget_ref( fsOk ); gtk_widget_ref( fsOk );
@ -586,16 +647,6 @@ GtkWidget * create_FileSelect( void )
gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsOk ); gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsOk );
gtk_widget_show( fsOk ); gtk_widget_show( fsOk );
// cancelstyle=gtk_widget_get_style( fsFileSelect );
// cancelpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&cancelmask,&cancelstyle->bg[GTK_STATE_NORMAL],(gchar **)cancel_xpm );
// cancelpixmapwid=gtk_pixmap_new( cancelpixmap,cancelmask );
// gtk_widget_show( cancelpixmapwid );
// fsCancel=gtk_button_new();
// gtk_widget_show( fsCancel );
// gtk_container_add( GTK_CONTAINER( fsCancel ),cancelpixmapwid );
// gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsCancel );
// gtk_widget_show( fsCancel );
fsCancel=gtk_button_new_with_label( MSGTR_Cancel ); fsCancel=gtk_button_new_with_label( MSGTR_Cancel );
gtk_widget_set_name( fsCancel,MSGTR_Cancel ); gtk_widget_set_name( fsCancel,MSGTR_Cancel );
gtk_widget_ref( fsCancel ); gtk_widget_ref( fsCancel );
@ -609,18 +660,18 @@ GtkWidget * create_FileSelect( void )
gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event", gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",
GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ), GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),
NULL ); NULL );
gtk_signal_connect( GTK_OBJECT( combo_entry1 ),"changed", gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",
GTK_SIGNAL_FUNC( fs_combo_entry1_changed ), GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),
combo_entry1 ); fsFilterCombo );
gtk_signal_connect( GTK_OBJECT( combo_entry1 ),"activate", gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",
GTK_SIGNAL_FUNC( fs_combo_entry1_activate ), GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),
combo_entry1 ); fsFilterCombo );
gtk_signal_connect( GTK_OBJECT( fsComboEntry2 ),"changed", gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",
GTK_SIGNAL_FUNC( fs_fsComboEntry2_changed ), GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),
fsComboEntry2 ); fsPathCombo );
gtk_signal_connect( GTK_OBJECT( fsComboEntry2 ),"activate", gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",
GTK_SIGNAL_FUNC( fs_fsComboEntry2_activate ), GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),
fsComboEntry2 ); fsPathCombo );
gtk_signal_connect( GTK_OBJECT( fsUp ),"released", gtk_signal_connect( GTK_OBJECT( fsUp ),"released",
GTK_SIGNAL_FUNC( fs_Up_released ), GTK_SIGNAL_FUNC( fs_Up_released ),
fsFNameList ); fsFNameList );

View File

@ -3,7 +3,13 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#define fsVideoSelector 0
#define fsSubtitleSelector 1
#define fsOtherSelector 2
extern void HideFileSelect( void ); extern void HideFileSelect( void );
extern void ShowFileSelect( int type );
extern GtkWidget * create_FileSelect( void ); extern GtkWidget * create_FileSelect( void );
#endif #endif

View File

@ -264,6 +264,10 @@ NoPause:
mplMainRender=1; mplMainRender=1;
gtkSendMessage( evLoad ); gtkSendMessage( evLoad );
break; break;
case evLoadSubtitle:
mplMainRender=1;
gtkSendMessage( evLoadSubtitle );
break;
case evPrev: case evPrev:
IZE("evPrev"); IZE("evPrev");
mplMainRender=1; mplMainRender=1;
@ -560,6 +564,8 @@ void mplMainKeyHandle( int State,int Type,int Key )
case wsF: msg=evFullScreen; break; case wsF: msg=evFullScreen; break;
case wsl: case wsl:
case wsL: msg=evLoad; break; case wsL: msg=evLoad; break;
case wsu:
case wsU: msg=evLoadSubtitle; break;
case wsm: case wsm:
case wsM: msg=evMute; break; case wsM: msg=evMute; break;
case wss: case wss:

View File

@ -77,6 +77,9 @@ typedef struct
char Filename[4096]; char Filename[4096];
int FilenameChanged; int FilenameChanged;
char Subtitlename[4096];
int SubtitleChanged;
int SkinChange; int SkinChange;
} mplCommStruct; } mplCommStruct;

View File

@ -7,6 +7,7 @@
#include "widgets.h" #include "widgets.h"
#include "play.h" #include "play.h"
#include "gtk/fs.h"
#include "../app.h" #include "../app.h"
@ -83,16 +84,26 @@ void gtkSigHandler( int s )
gtkShow( evPlayList ); gtkShow( evPlayList );
break; break;
case evLoad: case evLoad:
ShowFileSelect( fsVideoSelector );
#if 0
if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect ); if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect );
gtk_widget_show( FileSelect ); gtk_widget_show( FileSelect );
gtkVisibleFileSelect=1; gtkVisibleFileSelect=1;
gtkShow( evPlay ); gtkShow( evPlay );
#endif
break; break;
case evFirstLoad: case evFirstLoad:
ShowFileSelect( fsVideoSelector );
#if 0
if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect ); if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect );
gtk_widget_show( FileSelect ); gtk_widget_show( FileSelect );
gtkVisibleFileSelect=1; gtkVisibleFileSelect=1;
gtkShow( evFirstLoad ); gtkShow( evFirstLoad );
#endif
break;
case evLoadSubtitle:
ShowFileSelect( fsSubtitleSelector );
// gtkShow( evPlay );
break; break;
case evMessageBox: case evMessageBox:
gtk_label_set_text( gtkMessageBoxText,(char *)gtkShMem->mb.str ); gtk_label_set_text( gtkMessageBoxText,(char *)gtkShMem->mb.str );
@ -189,6 +200,11 @@ void mplMainSigHandler( int s )
mplShMem->StreamType=STREAMTYPE_FILE; mplShMem->StreamType=STREAMTYPE_FILE;
if ( mplMainAutoPlay ) mplGeneralTimer=1; if ( mplMainAutoPlay ) mplGeneralTimer=1;
break; break;
case evSubtitleLoaded:
printf("*** gtkShMem->fs.subtitlename == '%s' \n",gtkShMem->fs.subtitlename );
strcpy( mplShMem->Subtitlename,gtkShMem->fs.subtitlename );
mplShMem->SubtitleChanged=1;
break;
case evShowPopUpMenu: case evShowPopUpMenu:
fprintf( stderr,"[psignal] PopUpMenu: %d param: %d\n",gtkShMem->popupmenu,gtkShMem->popupmenuparam ); fprintf( stderr,"[psignal] PopUpMenu: %d param: %d\n",gtkShMem->popupmenu,gtkShMem->popupmenuparam );
mplMiddleMenu=1; mplGeneralTimer=1; mplMiddleMenu=1; mplGeneralTimer=1;

View File

@ -19,6 +19,8 @@ typedef struct
{ {
char dir[ 2048 ]; char dir[ 2048 ];
char filename[ 2048 ]; char filename[ 2048 ];
char subtitlename[ 4096 ];
char otherfilename[ 4096 ];
} gtkFileSelectorStruct; } gtkFileSelectorStruct;
typedef struct typedef struct

View File

@ -229,6 +229,8 @@ static char help_text[]=
// --- labels --- // --- labels ---
#define MSGTR_About "About" #define MSGTR_About "About"
#define MSGTR_FileSelect "Select file ..." #define MSGTR_FileSelect "Select file ..."
#define MSGTR_SubtitleSelect "Select subtitle ..."
#define MSGTR_OtherSelect "Select ..."
#define MSGTR_MessageBox "MessageBox" #define MSGTR_MessageBox "MessageBox"
#define MSGTR_PlayList "PlayList" #define MSGTR_PlayList "PlayList"
#define MSGTR_SkinBrowser "Skin Browser" #define MSGTR_SkinBrowser "Skin Browser"

View File

@ -224,6 +224,8 @@ static char help_text[]=
// --- labels --- // --- labels ---
#define MSGTR_About "A GUI-ról" #define MSGTR_About "A GUI-ról"
#define MSGTR_FileSelect "File kiválasztása ..." #define MSGTR_FileSelect "File kiválasztása ..."
#define MSGTR_SubtitleSelect "Felirat kiválasztása ..."
#define MSGTR_OtherSelect "File kiválasztása ..."
#define MSGTR_MessageBox "Üzenetablak" #define MSGTR_MessageBox "Üzenetablak"
#define MSGTR_PlayList "Lejátszási lista" #define MSGTR_PlayList "Lejátszási lista"
#define MSGTR_SkinBrowser "Skin böngészõ" #define MSGTR_SkinBrowser "Skin böngészõ"

View File

@ -589,18 +589,6 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){
} }
#endif #endif
#ifdef USE_SUB
// check .sub
if(sub_name){
int l=strlen(sub_name);
if ((l>4) && ((0==strcmp(&sub_name[l-4],".utf"))
||(0==strcmp(&sub_name[l-4],".UTF"))))
sub_utf8=1;
subtitles=sub_read_file(sub_name);
if(!subtitles || sub_num == 0) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name);
}
#endif
// It's time to init the GUI code: (and fork() the GTK process) // It's time to init the GUI code: (and fork() the GTK process)
#ifdef HAVE_NEW_GUI #ifdef HAVE_NEW_GUI
if(use_gui){ if(use_gui){
@ -678,6 +666,10 @@ play_next_file:
if(mplShMem->FilenameChanged){ if(mplShMem->FilenameChanged){
filename=mplShMem->Filename; filename=mplShMem->Filename;
} }
#ifdef USE_SUB
sub_name=NULL;
if ( mplShMem->SubtitleChanged ) sub_name=mplShMem->Subtitlename;
#endif
} }
#endif #endif
@ -685,6 +677,14 @@ play_next_file:
#ifdef USE_SUB #ifdef USE_SUB
// check .sub // check .sub
if(sub_name){
int l=strlen(sub_name);
if ((l>4) && ((0==strcmp(&sub_name[l-4],".utf"))
||(0==strcmp(&sub_name[l-4],".UTF"))))
sub_utf8=1;
subtitles=sub_read_file(sub_name);
if(!subtitles || sub_num == 0) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name);
}
if(!sub_name){ if(!sub_name){
if(sub_auto && filename) { // auto load sub file ... if(sub_auto && filename) { // auto load sub file ...
subtitles=sub_read_file( sub_filename( get_path("sub/"), filename ) ); subtitles=sub_read_file( sub_filename( get_path("sub/"), filename ) );