Mercurial > mplayer.hg
comparison gui/dialog/fileselect.c @ 35958:b522bc621d3c
Make create_FileSelect() and HideFileSelect() static.
They only have file scope.
In order to do so, relocate some other static functions.
author | ib |
---|---|
date | Sun, 24 Mar 2013 13:08:12 +0000 |
parents | 132d5af113c8 |
children | acec130e2ab2 |
comparison
equal
deleted
inserted
replaced
35957:7974f743eadf | 35958:b522bc621d3c |
---|---|
261 | 261 |
262 if (pos == GTK_POS_TOP) fsTopList_items = g_list_prepend(fsTopList_items, utf8name); | 262 if (pos == GTK_POS_TOP) fsTopList_items = g_list_prepend(fsTopList_items, utf8name); |
263 else fsTopList_items = g_list_append(fsTopList_items, utf8name); | 263 else fsTopList_items = g_list_append(fsTopList_items, utf8name); |
264 | 264 |
265 g_hash_table_insert(fsPathTable, strdup(utf8name), strdup(name)); | 265 g_hash_table_insert(fsPathTable, strdup(utf8name), strdup(name)); |
266 } | |
267 | |
268 static void HideFileSelect( void ) | |
269 { | |
270 if ( !fsFileSelect ) return; | |
271 gtk_widget_hide( fsFileSelect ); | |
272 gtk_widget_destroy( fsFileSelect ); | |
273 fsFileSelect=NULL; | |
274 fsLastFNameListSelected = fsCurrFNameListSelected; | |
275 } | |
276 | |
277 static void fs_PersistantHistory( char * subject ) | |
278 { | |
279 unsigned int i; | |
280 char * entry; | |
281 | |
282 if ( !subject ) return; | |
283 | |
284 for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ ) | |
285 if ( gstrcmp( fsHistory[i],subject ) == 0 ) | |
286 { | |
287 entry=fsHistory[i]; | |
288 break; | |
289 } | |
290 if ( i == FF_ARRAY_ELEMS(fsHistory) ) | |
291 { | |
292 entry=strdup( subject ); | |
293 free( fsHistory[--i] ); | |
294 } | |
295 for ( ;i;i-- ) fsHistory[i]=fsHistory[i - 1]; | |
296 fsHistory[0]=entry; | |
297 } | |
298 /* ----------------------------------------------- */ | |
299 | |
300 static void fs_fsFilterCombo_activate( GtkEntry * entry, | |
301 gpointer user_data ) | |
302 { | |
303 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
304 CheckDir( fsFNameList ); | |
305 } | |
306 | |
307 static void fs_fsFilterCombo_changed( GtkEditable * editable, | |
308 gpointer user_data ) | |
309 { | |
310 const char * str; | |
311 int i; | |
312 | |
313 str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); | |
314 | |
315 switch ( fsType ) | |
316 { | |
317 case fsVideoSelector: | |
318 for( i=0;fsVideoFilterNames[i][0];i++ ) | |
319 if( !strcmp( str,fsVideoFilterNames[i][0] ) ) | |
320 { fsFilter=fsVideoFilterNames[i][1]; fsLastVideoFilterSelected = i; break; } | |
321 break; | |
322 case fsSubtitleSelector: | |
323 for( i=0;fsSubtitleFilterNames[i][0];i++ ) | |
324 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) | |
325 { fsFilter=fsSubtitleFilterNames[i][1]; fsLastSubtitleFilterSelected = i; break; } | |
326 break; | |
327 /* case fsOtherSelector: | |
328 for( i=0;fsOtherFilterNames[i][0];i++ ) | |
329 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) | |
330 { fsFilter=fsOtherFilterNames[i][1]; break; } | |
331 break;*/ | |
332 case fsAudioSelector: | |
333 for( i=0;fsAudioFileNames[i][0];i++ ) | |
334 if( !strcmp( str,fsAudioFileNames[i][0] ) ) | |
335 { fsFilter=fsAudioFileNames[i][1]; fsLastAudioFilterSelected = i; break; } | |
336 break; | |
337 case fsFontSelector: | |
338 for( i=0;fsFontFileNames[i][0];i++ ) | |
339 if( !strcmp( str,fsFontFileNames[i][0] ) ) | |
340 { fsFilter=fsFontFileNames[i][1]; fsLastFontFilterSelected = i; break; } | |
341 break; | |
342 default: return; | |
343 } | |
344 CheckDir( fsFNameList ); | |
345 } | |
346 | |
347 static void fs_fsPathCombo_activate( GtkEntry * entry, | |
348 gpointer user_data ) | |
349 { | |
350 const unsigned char * str; | |
351 gchar * dirname; | |
352 | |
353 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
354 dirname=g_hash_table_lookup(fsPathTable, str); | |
355 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); | |
356 } | |
357 | |
358 static void fs_fsPathCombo_changed( GtkEditable * editable, | |
359 gpointer user_data ) | |
360 { | |
361 const unsigned char * str; | |
362 gchar * dirname; | |
363 | |
364 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
365 dirname=g_hash_table_lookup(fsPathTable, str); | |
366 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); | |
367 } | |
368 | |
369 static void fs_Up_released( GtkButton * button, gpointer user_data ) | |
370 { | |
371 char *utf8dir; | |
372 | |
373 chdir( ".." ); | |
374 fsSelectedFile=fsThatDir; | |
375 CheckDir( fsFNameList ); | |
376 utf8dir = get_current_dir_name_utf8(); | |
377 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)utf8dir ); | |
378 g_free(utf8dir); | |
379 return; | |
380 } | |
381 | |
382 static void fs_Ok_released( GtkButton * button, gpointer user_data ) | |
383 { | |
384 char * fsSelectedDirectory; | |
385 int l; | |
386 struct stat fs; | |
387 gchar * selected; | |
388 | |
389 if( ( stat( fsSelectedFile,&fs ) == 0 ) && S_ISDIR( fs.st_mode ) ) | |
390 { | |
391 char *utf8dir; | |
392 if ( chdir( fsSelectedFile ) != 0 ) return; | |
393 fsSelectedFile=fsThatDir; | |
394 CheckDir( fsFNameList ); | |
395 utf8dir = get_current_dir_name_utf8(); | |
396 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)utf8dir ); | |
397 g_free(utf8dir); | |
398 gtk_widget_grab_focus( fsFNameList ); | |
399 return; | |
400 } | |
401 | |
402 fsSelectedDirectory=(unsigned char *)get_current_dir_name(); | |
403 switch ( fsType ) | |
404 { | |
405 case fsVideoSelector: | |
406 for (l = 0; fsVideoFilterNames[l][0]; l++) | |
407 if (strcmp(fsVideoFilterNames[l][0], MSGTR_Filter_Playlists) == 0) break; | |
408 uiSetFile( fsSelectedDirectory,fsSelectedFile, fsLastVideoFilterSelected == l ? STREAMTYPE_PLAYLIST : STREAMTYPE_FILE ); | |
409 selected = g_strconcat(fsSelectedDirectory, "/", fsSelectedFile, NULL); | |
410 if (selected) | |
411 { | |
412 listMgr(PLAYLIST_DELETE, 0); | |
413 add_to_gui_playlist(selected, PLAYLIST_ITEM_APPEND); | |
414 g_free(selected); | |
415 } | |
416 guiInfo.NewPlay=GUI_FILE_NEW; sub_fps=0; | |
417 fs_PersistantHistory( fsSelectedDirectory ); | |
418 break; | |
419 case fsSubtitleSelector: | |
420 setddup( &guiInfo.SubtitleFilename,fsSelectedDirectory,fsSelectedFile ); | |
421 mplayerLoadSubtitle( guiInfo.SubtitleFilename ); | |
422 break; | |
423 /* case fsOtherSelector: | |
424 setddup( &guiInfo.Othername,fsSelectedDirectory,fsSelectedFile ); | |
425 break;*/ | |
426 case fsAudioSelector: | |
427 setddup( &guiInfo.AudioFilename,fsSelectedDirectory,fsSelectedFile ); | |
428 break; | |
429 case fsFontSelector: | |
430 setddup( &font_name,fsSelectedDirectory,fsSelectedFile ); | |
431 mplayerLoadFont(); | |
432 if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name ); | |
433 break; | |
434 } | |
435 | |
436 free(fsSelectedDirectory); | |
437 | |
438 HideFileSelect(); | |
439 | |
440 if ( uiLoadPlay ) { uiLoadPlay=False; uiEvent( evPlay,0 ); } | |
441 else gui( GUI_SET_STATE,(void *) GUI_STOP ); | |
442 } | |
443 | |
444 static void fs_Cancel_released( GtkButton * button,gpointer user_data ) | |
445 { | |
446 HideFileSelect(); | |
447 } | |
448 | |
449 static void fs_fsFNameList_select_row( GtkCList * clist, gint row, gint column, | |
450 GdkEvent * event, gpointer user_data) | |
451 { | |
452 fsCurrFNameListSelected = row; | |
453 fsSelectedFile = gtk_clist_get_row_data(clist, row); | |
454 if( event && event->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); | |
455 } | |
456 | |
457 static gboolean on_FileSelect_key_release_event( GtkWidget * widget, | |
458 GdkEvent * event, | |
459 gpointer user_data ) | |
460 { | |
461 if ( GTK_WIDGET_TYPE( widget ) == GTK_TYPE_BUTTON ) | |
462 { | |
463 if (event->key.keyval == GDK_Return) gtk_button_released( GTK_BUTTON( widget ) ); | |
464 } | |
465 else | |
466 { | |
467 switch ( event->key.keyval ) | |
468 { | |
469 case GDK_Escape: | |
470 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
471 break; | |
472 case GDK_Return: | |
473 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
474 break; | |
475 case GDK_BackSpace: | |
476 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
477 gtk_widget_grab_focus( fsFNameList ); | |
478 break; | |
479 } | |
480 } | |
481 return FALSE; | |
482 } | |
483 | |
484 static gboolean fs_fsFNameList_event( GtkWidget * widget, | |
485 GdkEvent * event, | |
486 gpointer user_data ) | |
487 { | |
488 GdkEventButton *bevent; | |
489 gint row, col; | |
490 | |
491 bevent = (GdkEventButton *) event; | |
492 | |
493 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
494 { | |
495 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
496 { | |
497 fsSelectedFile = gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
498 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
499 return TRUE; | |
500 } | |
501 } | |
502 | |
503 return FALSE; | |
504 } | |
505 | |
506 static void fs_Destroy( void ) | |
507 { | |
508 WidgetDestroy( fsFileSelect, &fsFileSelect ); | |
509 } | |
510 | |
511 static GtkWidget * create_FileSelect( void ) | |
512 { | |
513 GtkWidget * vbox4; | |
514 GtkWidget * hbox4; | |
515 GtkWidget * vseparator1; | |
516 GtkWidget * hbox6; | |
517 GtkWidget * fsFNameListWindow; | |
518 GtkWidget * hbuttonbox3; | |
519 | |
520 GtkWidget * uppixmapwid; | |
521 GdkPixmap * uppixmap; | |
522 GdkBitmap * upmask; | |
523 GtkStyle * upstyle; | |
524 | |
525 | |
526 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
527 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); | |
528 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | |
529 gtk_widget_set_usize( fsFileSelect,512,300 ); | |
530 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); | |
531 gtk_widget_set_events( fsFileSelect,GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK ); | |
532 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
533 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER ); | |
534 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE ); | |
535 gtk_window_set_wmclass( GTK_WINDOW( fsFileSelect ),"FileSelect","MPlayer" ); | |
536 fsColorMap=gdk_colormap_get_system(); | |
537 | |
538 gtk_widget_realize( fsFileSelect ); | |
539 gtkAddIcon( fsFileSelect ); | |
540 | |
541 style=gtk_widget_get_style( fsFileSelect ); | |
542 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
543 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
544 | |
545 vbox4=AddVBox( AddDialogFrame( fsFileSelect ),0 ); | |
546 hbox4=AddHBox( vbox4,1 ); | |
547 | |
548 fsCombo4=gtk_combo_new(); | |
549 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
550 gtk_widget_show( fsCombo4 ); | |
551 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
552 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
553 | |
554 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; | |
555 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
556 gtk_widget_show( fsPathCombo ); | |
557 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
558 | |
559 vseparator1=gtk_vseparator_new(); | |
560 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
561 gtk_widget_show( vseparator1 ); | |
562 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
563 gtk_widget_set_usize( vseparator1,7,20 ); | |
564 | |
565 upstyle=gtk_widget_get_style( fsFileSelect ); | |
566 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
567 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); | |
568 gtk_widget_show( uppixmapwid ); | |
569 | |
570 fsUp=gtk_button_new(); | |
571 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
572 gtk_widget_show( fsUp ); | |
573 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
574 gtk_widget_set_usize( fsUp,65,15 ); | |
575 | |
576 AddHSeparator( vbox4 ); | |
577 | |
578 hbox6=AddHBox( NULL,0 ); | |
579 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
580 | |
581 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
582 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
583 gtk_widget_show( fsFNameListWindow ); | |
584 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
585 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
586 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
587 | |
588 fsFNameList=gtk_clist_new( 2 ); | |
589 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
590 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); | |
591 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
592 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
593 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
594 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
595 | |
596 AddHSeparator( vbox4 ); | |
597 | |
598 List=gtk_combo_new(); | |
599 gtk_widget_set_name( List,"List" ); | |
600 gtk_widget_ref( List ); | |
601 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); | |
602 gtk_widget_show( List ); | |
603 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
604 gtk_widget_set_usize( List,-2,20 ); | |
605 | |
606 fsFilterCombo=GTK_COMBO( List )->entry; | |
607 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
608 gtk_widget_show( fsFilterCombo ); | |
609 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
610 gtk_widget_set_usize( fsFilterCombo,-2,20 ); | |
611 | |
612 AddHSeparator( vbox4 ); | |
613 | |
614 hbuttonbox3=AddHButtonBox( vbox4 ); | |
615 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
616 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
617 | |
618 fsOk=AddButton( MSGTR_Ok,hbuttonbox3 ); | |
619 fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 ); | |
620 | |
621 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( fs_Destroy ), NULL ); | |
622 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
623 | |
624 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); | |
625 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
626 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
627 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
628 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
629 gtk_signal_connect( GTK_OBJECT( fsUp ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
630 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); | |
631 gtk_signal_connect( GTK_OBJECT( fsOk ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
632 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); | |
633 gtk_signal_connect( GTK_OBJECT( fsCancel ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
634 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); | |
635 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"event", (GtkSignalFunc)fs_fsFNameList_event,NULL ); | |
636 | |
637 return fsFileSelect; | |
266 } | 638 } |
267 | 639 |
268 void ShowFileSelect( int type,int modal ) | 640 void ShowFileSelect( int type,int modal ) |
269 { | 641 { |
270 int i, k, fsMedium; | 642 int i, k, fsMedium; |
391 | 763 |
392 gtk_window_set_modal( GTK_WINDOW( fsFileSelect ),modal ); | 764 gtk_window_set_modal( GTK_WINDOW( fsFileSelect ),modal ); |
393 | 765 |
394 gtk_widget_show( fsFileSelect ); | 766 gtk_widget_show( fsFileSelect ); |
395 } | 767 } |
396 | |
397 void HideFileSelect( void ) | |
398 { | |
399 if ( !fsFileSelect ) return; | |
400 gtk_widget_hide( fsFileSelect ); | |
401 gtk_widget_destroy( fsFileSelect ); | |
402 fsFileSelect=NULL; | |
403 fsLastFNameListSelected = fsCurrFNameListSelected; | |
404 } | |
405 | |
406 static void fs_PersistantHistory( char * subject ) | |
407 { | |
408 unsigned int i; | |
409 char * entry; | |
410 | |
411 if ( !subject ) return; | |
412 | |
413 for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ ) | |
414 if ( gstrcmp( fsHistory[i],subject ) == 0 ) | |
415 { | |
416 entry=fsHistory[i]; | |
417 break; | |
418 } | |
419 if ( i == FF_ARRAY_ELEMS(fsHistory) ) | |
420 { | |
421 entry=strdup( subject ); | |
422 free( fsHistory[--i] ); | |
423 } | |
424 for ( ;i;i-- ) fsHistory[i]=fsHistory[i - 1]; | |
425 fsHistory[0]=entry; | |
426 } | |
427 /* ----------------------------------------------- */ | |
428 | |
429 static void fs_fsFilterCombo_activate( GtkEntry * entry, | |
430 gpointer user_data ) | |
431 { | |
432 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
433 CheckDir( fsFNameList ); | |
434 } | |
435 | |
436 static void fs_fsFilterCombo_changed( GtkEditable * editable, | |
437 gpointer user_data ) | |
438 { | |
439 const char * str; | |
440 int i; | |
441 | |
442 str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); | |
443 | |
444 switch ( fsType ) | |
445 { | |
446 case fsVideoSelector: | |
447 for( i=0;fsVideoFilterNames[i][0];i++ ) | |
448 if( !strcmp( str,fsVideoFilterNames[i][0] ) ) | |
449 { fsFilter=fsVideoFilterNames[i][1]; fsLastVideoFilterSelected = i; break; } | |
450 break; | |
451 case fsSubtitleSelector: | |
452 for( i=0;fsSubtitleFilterNames[i][0];i++ ) | |
453 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) | |
454 { fsFilter=fsSubtitleFilterNames[i][1]; fsLastSubtitleFilterSelected = i; break; } | |
455 break; | |
456 /* case fsOtherSelector: | |
457 for( i=0;fsOtherFilterNames[i][0];i++ ) | |
458 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) | |
459 { fsFilter=fsOtherFilterNames[i][1]; break; } | |
460 break;*/ | |
461 case fsAudioSelector: | |
462 for( i=0;fsAudioFileNames[i][0];i++ ) | |
463 if( !strcmp( str,fsAudioFileNames[i][0] ) ) | |
464 { fsFilter=fsAudioFileNames[i][1]; fsLastAudioFilterSelected = i; break; } | |
465 break; | |
466 case fsFontSelector: | |
467 for( i=0;fsFontFileNames[i][0];i++ ) | |
468 if( !strcmp( str,fsFontFileNames[i][0] ) ) | |
469 { fsFilter=fsFontFileNames[i][1]; fsLastFontFilterSelected = i; break; } | |
470 break; | |
471 default: return; | |
472 } | |
473 CheckDir( fsFNameList ); | |
474 } | |
475 | |
476 static void fs_fsPathCombo_activate( GtkEntry * entry, | |
477 gpointer user_data ) | |
478 { | |
479 const unsigned char * str; | |
480 gchar * dirname; | |
481 | |
482 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
483 dirname=g_hash_table_lookup(fsPathTable, str); | |
484 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); | |
485 } | |
486 | |
487 static void fs_fsPathCombo_changed( GtkEditable * editable, | |
488 gpointer user_data ) | |
489 { | |
490 const unsigned char * str; | |
491 gchar * dirname; | |
492 | |
493 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
494 dirname=g_hash_table_lookup(fsPathTable, str); | |
495 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList ); | |
496 } | |
497 | |
498 static void fs_Up_released( GtkButton * button, gpointer user_data ) | |
499 { | |
500 char *utf8dir; | |
501 | |
502 chdir( ".." ); | |
503 fsSelectedFile=fsThatDir; | |
504 CheckDir( fsFNameList ); | |
505 utf8dir = get_current_dir_name_utf8(); | |
506 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)utf8dir ); | |
507 g_free(utf8dir); | |
508 return; | |
509 } | |
510 | |
511 static void fs_Ok_released( GtkButton * button, gpointer user_data ) | |
512 { | |
513 char * fsSelectedDirectory; | |
514 int l; | |
515 struct stat fs; | |
516 gchar * selected; | |
517 | |
518 if( ( stat( fsSelectedFile,&fs ) == 0 ) && S_ISDIR( fs.st_mode ) ) | |
519 { | |
520 char *utf8dir; | |
521 if ( chdir( fsSelectedFile ) != 0 ) return; | |
522 fsSelectedFile=fsThatDir; | |
523 CheckDir( fsFNameList ); | |
524 utf8dir = get_current_dir_name_utf8(); | |
525 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)utf8dir ); | |
526 g_free(utf8dir); | |
527 gtk_widget_grab_focus( fsFNameList ); | |
528 return; | |
529 } | |
530 | |
531 fsSelectedDirectory=(unsigned char *)get_current_dir_name(); | |
532 switch ( fsType ) | |
533 { | |
534 case fsVideoSelector: | |
535 for (l = 0; fsVideoFilterNames[l][0]; l++) | |
536 if (strcmp(fsVideoFilterNames[l][0], MSGTR_Filter_Playlists) == 0) break; | |
537 uiSetFile( fsSelectedDirectory,fsSelectedFile, fsLastVideoFilterSelected == l ? STREAMTYPE_PLAYLIST : STREAMTYPE_FILE ); | |
538 selected = g_strconcat(fsSelectedDirectory, "/", fsSelectedFile, NULL); | |
539 if (selected) | |
540 { | |
541 listMgr(PLAYLIST_DELETE, 0); | |
542 add_to_gui_playlist(selected, PLAYLIST_ITEM_APPEND); | |
543 g_free(selected); | |
544 } | |
545 guiInfo.NewPlay=GUI_FILE_NEW; sub_fps=0; | |
546 fs_PersistantHistory( fsSelectedDirectory ); | |
547 break; | |
548 case fsSubtitleSelector: | |
549 setddup( &guiInfo.SubtitleFilename,fsSelectedDirectory,fsSelectedFile ); | |
550 mplayerLoadSubtitle( guiInfo.SubtitleFilename ); | |
551 break; | |
552 /* case fsOtherSelector: | |
553 setddup( &guiInfo.Othername,fsSelectedDirectory,fsSelectedFile ); | |
554 break;*/ | |
555 case fsAudioSelector: | |
556 setddup( &guiInfo.AudioFilename,fsSelectedDirectory,fsSelectedFile ); | |
557 break; | |
558 case fsFontSelector: | |
559 setddup( &font_name,fsSelectedDirectory,fsSelectedFile ); | |
560 mplayerLoadFont(); | |
561 if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name ); | |
562 break; | |
563 } | |
564 | |
565 free(fsSelectedDirectory); | |
566 | |
567 HideFileSelect(); | |
568 | |
569 if ( uiLoadPlay ) { uiLoadPlay=False; uiEvent( evPlay,0 ); } | |
570 else gui( GUI_SET_STATE,(void *) GUI_STOP ); | |
571 } | |
572 | |
573 static void fs_Cancel_released( GtkButton * button,gpointer user_data ) | |
574 { | |
575 HideFileSelect(); | |
576 } | |
577 | |
578 static void fs_fsFNameList_select_row( GtkCList * clist, gint row, gint column, | |
579 GdkEvent * event, gpointer user_data) | |
580 { | |
581 fsCurrFNameListSelected = row; | |
582 fsSelectedFile = gtk_clist_get_row_data(clist, row); | |
583 if( event && event->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); | |
584 } | |
585 | |
586 static gboolean on_FileSelect_key_release_event( GtkWidget * widget, | |
587 GdkEvent * event, | |
588 gpointer user_data ) | |
589 { | |
590 if ( GTK_WIDGET_TYPE( widget ) == GTK_TYPE_BUTTON ) | |
591 { | |
592 if (event->key.keyval == GDK_Return) gtk_button_released( GTK_BUTTON( widget ) ); | |
593 } | |
594 else | |
595 { | |
596 switch ( event->key.keyval ) | |
597 { | |
598 case GDK_Escape: | |
599 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
600 break; | |
601 case GDK_Return: | |
602 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
603 break; | |
604 case GDK_BackSpace: | |
605 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
606 gtk_widget_grab_focus( fsFNameList ); | |
607 break; | |
608 } | |
609 } | |
610 return FALSE; | |
611 } | |
612 | |
613 static gboolean fs_fsFNameList_event( GtkWidget * widget, | |
614 GdkEvent * event, | |
615 gpointer user_data ) | |
616 { | |
617 GdkEventButton *bevent; | |
618 gint row, col; | |
619 | |
620 bevent = (GdkEventButton *) event; | |
621 | |
622 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
623 { | |
624 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
625 { | |
626 fsSelectedFile = gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
627 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
628 return TRUE; | |
629 } | |
630 } | |
631 | |
632 return FALSE; | |
633 } | |
634 | |
635 static void fs_Destroy( void ) | |
636 { | |
637 WidgetDestroy( fsFileSelect, &fsFileSelect ); | |
638 } | |
639 | |
640 GtkWidget * create_FileSelect( void ) | |
641 { | |
642 GtkWidget * vbox4; | |
643 GtkWidget * hbox4; | |
644 GtkWidget * vseparator1; | |
645 GtkWidget * hbox6; | |
646 GtkWidget * fsFNameListWindow; | |
647 GtkWidget * hbuttonbox3; | |
648 | |
649 GtkWidget * uppixmapwid; | |
650 GdkPixmap * uppixmap; | |
651 GdkBitmap * upmask; | |
652 GtkStyle * upstyle; | |
653 | |
654 | |
655 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
656 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); | |
657 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | |
658 gtk_widget_set_usize( fsFileSelect,512,300 ); | |
659 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); | |
660 gtk_widget_set_events( fsFileSelect,GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK ); | |
661 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
662 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER ); | |
663 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE ); | |
664 gtk_window_set_wmclass( GTK_WINDOW( fsFileSelect ),"FileSelect","MPlayer" ); | |
665 fsColorMap=gdk_colormap_get_system(); | |
666 | |
667 gtk_widget_realize( fsFileSelect ); | |
668 gtkAddIcon( fsFileSelect ); | |
669 | |
670 style=gtk_widget_get_style( fsFileSelect ); | |
671 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
672 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
673 | |
674 vbox4=AddVBox( AddDialogFrame( fsFileSelect ),0 ); | |
675 hbox4=AddHBox( vbox4,1 ); | |
676 | |
677 fsCombo4=gtk_combo_new(); | |
678 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
679 gtk_widget_show( fsCombo4 ); | |
680 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
681 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
682 | |
683 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; | |
684 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
685 gtk_widget_show( fsPathCombo ); | |
686 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
687 | |
688 vseparator1=gtk_vseparator_new(); | |
689 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
690 gtk_widget_show( vseparator1 ); | |
691 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
692 gtk_widget_set_usize( vseparator1,7,20 ); | |
693 | |
694 upstyle=gtk_widget_get_style( fsFileSelect ); | |
695 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
696 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); | |
697 gtk_widget_show( uppixmapwid ); | |
698 | |
699 fsUp=gtk_button_new(); | |
700 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
701 gtk_widget_show( fsUp ); | |
702 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
703 gtk_widget_set_usize( fsUp,65,15 ); | |
704 | |
705 AddHSeparator( vbox4 ); | |
706 | |
707 hbox6=AddHBox( NULL,0 ); | |
708 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
709 | |
710 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
711 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
712 gtk_widget_show( fsFNameListWindow ); | |
713 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
714 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
715 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
716 | |
717 fsFNameList=gtk_clist_new( 2 ); | |
718 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
719 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); | |
720 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
721 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
722 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
723 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
724 | |
725 AddHSeparator( vbox4 ); | |
726 | |
727 List=gtk_combo_new(); | |
728 gtk_widget_set_name( List,"List" ); | |
729 gtk_widget_ref( List ); | |
730 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); | |
731 gtk_widget_show( List ); | |
732 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
733 gtk_widget_set_usize( List,-2,20 ); | |
734 | |
735 fsFilterCombo=GTK_COMBO( List )->entry; | |
736 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
737 gtk_widget_show( fsFilterCombo ); | |
738 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
739 gtk_widget_set_usize( fsFilterCombo,-2,20 ); | |
740 | |
741 AddHSeparator( vbox4 ); | |
742 | |
743 hbuttonbox3=AddHButtonBox( vbox4 ); | |
744 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
745 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
746 | |
747 fsOk=AddButton( MSGTR_Ok,hbuttonbox3 ); | |
748 fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 ); | |
749 | |
750 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( fs_Destroy ), NULL ); | |
751 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
752 | |
753 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); | |
754 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
755 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
756 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
757 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
758 gtk_signal_connect( GTK_OBJECT( fsUp ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
759 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); | |
760 gtk_signal_connect( GTK_OBJECT( fsOk ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
761 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); | |
762 gtk_signal_connect( GTK_OBJECT( fsCancel ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
763 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); | |
764 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"event", (GtkSignalFunc)fs_fsFNameList_event,NULL ); | |
765 | |
766 return fsFileSelect; | |
767 } |