2001-11-14 16:04:25 +00:00
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <glob.h>
|
|
|
|
#include <unistd.h>
|
2001-11-18 21:59:20 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2002-02-23 15:12:55 +00:00
|
|
|
#include <stdio.h>
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2008-03-14 16:46:13 +00:00
|
|
|
#include "config.h"
|
2001-11-14 16:04:25 +00:00
|
|
|
#include "sb.h"
|
2008-01-06 16:22:00 +00:00
|
|
|
#include "gtk_common.h"
|
2002-11-27 22:48:56 +00:00
|
|
|
|
2008-04-11 16:55:27 +00:00
|
|
|
#include "gui/app.h"
|
2007-03-16 00:00:13 +00:00
|
|
|
#include "help_mp.h"
|
2001-11-14 16:04:25 +00:00
|
|
|
|
|
|
|
#include "../widgets.h"
|
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
GtkWidget * SkinList = NULL;
|
2001-11-14 16:04:25 +00:00
|
|
|
char * sbSelectedSkin=NULL;
|
2006-03-27 11:39:27 +00:00
|
|
|
/* FIXME: Eventually remove the obsolete directory names. */
|
2001-11-14 16:04:25 +00:00
|
|
|
char * sbMPlayerDirInHome=NULL;
|
2006-03-27 11:39:27 +00:00
|
|
|
char * sbMPlayerDirInHome_obsolete=NULL;
|
2001-11-14 16:04:25 +00:00
|
|
|
char * sbMPlayerPrefixDir=NULL;
|
2006-03-27 11:39:27 +00:00
|
|
|
char * sbMPlayerPrefixDir_obsolete=NULL;
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2006-04-09 13:52:45 +00:00
|
|
|
char * gtkOldSkin=NULL;
|
|
|
|
static char * prev=NULL;
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
GtkWidget * SkinBrowser = NULL;
|
2002-05-20 13:56:16 +00:00
|
|
|
|
|
|
|
void ShowSkinBrowser( void )
|
|
|
|
{
|
2002-11-27 22:48:56 +00:00
|
|
|
if ( SkinBrowser ) gtkActive( SkinBrowser );
|
2002-05-20 13:56:16 +00:00
|
|
|
else SkinBrowser=create_SkinBrowser();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HideSkinBrowser( void )
|
|
|
|
{
|
2002-11-27 22:48:56 +00:00
|
|
|
if ( !SkinBrowser ) return;
|
|
|
|
gtk_widget_hide( SkinBrowser );
|
2002-05-20 13:56:16 +00:00
|
|
|
gtk_widget_destroy( SkinBrowser );
|
2002-11-27 22:48:56 +00:00
|
|
|
SkinBrowser=NULL;
|
2002-05-20 13:56:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-14 16:04:25 +00:00
|
|
|
int gtkFillSkinList( gchar * mdir )
|
|
|
|
{
|
|
|
|
gchar * str[2];
|
|
|
|
gchar * tmp;
|
|
|
|
int i;
|
|
|
|
glob_t gg;
|
|
|
|
struct stat fs;
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
gtkOldSkin=strdup( skinName );
|
2002-04-18 21:24:42 +00:00
|
|
|
prev=gtkOldSkin;
|
2003-01-18 00:22:18 +00:00
|
|
|
|
|
|
|
str[0]="default";
|
2001-11-14 16:04:25 +00:00
|
|
|
str[1]="";
|
|
|
|
if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str );
|
|
|
|
|
|
|
|
glob( mdir,GLOB_NOSORT,NULL,&gg );
|
2002-11-27 22:48:56 +00:00
|
|
|
for( i=0;i<(int)gg.gl_pathc;i++ )
|
2001-11-14 16:04:25 +00:00
|
|
|
{
|
|
|
|
if ( !strcmp( gg.gl_pathv[i],"." ) || !strcmp( gg.gl_pathv[i],".." ) ) continue;
|
|
|
|
stat( gg.gl_pathv[i],&fs );
|
|
|
|
if ( S_ISDIR( fs.st_mode ) )
|
|
|
|
{
|
|
|
|
tmp=strrchr( gg.gl_pathv[i],'/' ); tmp++;
|
|
|
|
if ( !strcmp( tmp,"default" ) ) continue;
|
2003-01-18 00:22:18 +00:00
|
|
|
str[0]=tmp;
|
2001-11-14 16:04:25 +00:00
|
|
|
if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
globfree( &gg );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
static void prButton( GtkObject * object,gpointer user_data )
|
2002-02-23 15:12:55 +00:00
|
|
|
{
|
2006-04-09 13:52:45 +00:00
|
|
|
if ( sbSelectedSkin )
|
|
|
|
{
|
|
|
|
switch ( (int)user_data )
|
|
|
|
{
|
|
|
|
case 0: // cancel
|
2002-11-27 22:48:56 +00:00
|
|
|
if ( strcmp( sbSelectedSkin,gtkOldSkin ) ) ChangeSkin( gtkOldSkin );
|
|
|
|
break;
|
|
|
|
case 1: // ok
|
|
|
|
ChangeSkin( sbSelectedSkin );
|
|
|
|
if ( skinName ) free( skinName );
|
|
|
|
skinName=strdup( sbSelectedSkin );
|
|
|
|
break;
|
|
|
|
}
|
2006-04-09 13:52:45 +00:00
|
|
|
}
|
2002-05-20 13:56:16 +00:00
|
|
|
HideSkinBrowser();
|
2001-11-14 16:04:25 +00:00
|
|
|
}
|
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
static void on_SkinList_select_row( GtkCList * clist,gint row,gint column,GdkEvent * bevent,gpointer user_data )
|
2001-11-14 16:04:25 +00:00
|
|
|
{
|
|
|
|
gtk_clist_get_text( clist,row,0,&sbSelectedSkin );
|
2002-04-18 21:24:42 +00:00
|
|
|
if ( strcmp( prev,sbSelectedSkin ) )
|
|
|
|
{
|
|
|
|
prev=sbSelectedSkin;
|
|
|
|
ChangeSkin( sbSelectedSkin );
|
2002-05-28 21:52:37 +00:00
|
|
|
gtkActive( SkinBrowser );
|
2002-04-18 21:24:42 +00:00
|
|
|
}
|
2001-11-14 16:04:25 +00:00
|
|
|
if( !bevent ) return;
|
2002-04-18 21:24:42 +00:00
|
|
|
if( bevent->type == GDK_2BUTTON_PRESS )
|
|
|
|
{
|
|
|
|
if ( skinName ) free( skinName );
|
|
|
|
skinName=strdup( sbSelectedSkin );
|
2002-05-20 13:56:16 +00:00
|
|
|
HideSkinBrowser();
|
2002-04-18 21:24:42 +00:00
|
|
|
}
|
2001-11-14 16:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget * create_SkinBrowser( void )
|
|
|
|
{
|
|
|
|
GtkWidget * vbox5;
|
|
|
|
GtkWidget * scrolledwindow1;
|
|
|
|
GtkWidget * hbuttonbox4;
|
|
|
|
GtkWidget * Cancel;
|
|
|
|
GtkWidget * Ok;
|
|
|
|
GtkAccelGroup * accel_group;
|
|
|
|
|
|
|
|
accel_group = gtk_accel_group_new ();
|
|
|
|
|
2002-11-02 16:09:05 +00:00
|
|
|
SkinBrowser=gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
2001-11-14 16:04:25 +00:00
|
|
|
gtk_widget_set_name( SkinBrowser,MSGTR_SkinBrowser );
|
|
|
|
gtk_object_set_data( GTK_OBJECT( SkinBrowser ),MSGTR_SkinBrowser,SkinBrowser );
|
|
|
|
gtk_widget_set_usize( SkinBrowser,256,320 );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( SkinBrowser ),1 );
|
|
|
|
GTK_WIDGET_SET_FLAGS( SkinBrowser,GTK_CAN_DEFAULT );
|
|
|
|
gtk_widget_set_events( SkinBrowser,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 );
|
|
|
|
gtk_window_set_title( GTK_WINDOW( SkinBrowser ),MSGTR_SkinBrowser );
|
|
|
|
gtk_window_set_position( GTK_WINDOW( SkinBrowser ),GTK_WIN_POS_CENTER );
|
|
|
|
gtk_window_set_policy( GTK_WINDOW( SkinBrowser ),FALSE,FALSE,TRUE );
|
2002-11-27 22:48:56 +00:00
|
|
|
gtk_window_set_wmclass( GTK_WINDOW( SkinBrowser ),"SkinBrowser","MPlayer" );
|
2002-07-05 23:47:00 +00:00
|
|
|
|
|
|
|
gtk_widget_realize( SkinBrowser );
|
|
|
|
gtkAddIcon( SkinBrowser );
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
vbox5=AddVBox( AddDialogFrame( SkinBrowser ),0 );
|
|
|
|
AddLabel( MSGTR_SKIN_LABEL,vbox5 );
|
|
|
|
AddHSeparator( vbox5 );
|
2001-11-14 16:04:25 +00:00
|
|
|
|
|
|
|
scrolledwindow1=gtk_scrolled_window_new( NULL,NULL );
|
|
|
|
gtk_widget_set_name( scrolledwindow1,"scrolledwindow1" );
|
|
|
|
gtk_widget_ref( scrolledwindow1 );
|
2002-05-20 13:56:16 +00:00
|
|
|
gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"scrolledwindow1",scrolledwindow1,(GtkDestroyNotify)gtk_widget_unref );
|
2001-11-14 16:04:25 +00:00
|
|
|
gtk_widget_show( scrolledwindow1 );
|
|
|
|
gtk_box_pack_start( GTK_BOX( vbox5 ),scrolledwindow1,TRUE,TRUE,0 );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( scrolledwindow1 ),2 );
|
|
|
|
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC );
|
|
|
|
|
|
|
|
SkinList=gtk_clist_new( 1 );
|
|
|
|
gtk_widget_set_name( SkinList,"SkinList" );
|
|
|
|
gtk_widget_ref( SkinList );
|
2002-05-20 13:56:16 +00:00
|
|
|
gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"SkinList",SkinList,(GtkDestroyNotify)gtk_widget_unref );
|
2001-11-14 16:04:25 +00:00
|
|
|
gtk_widget_show( SkinList );
|
|
|
|
gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),SkinList );
|
|
|
|
gtk_clist_set_column_width( GTK_CLIST( SkinList ),0,80 );
|
|
|
|
gtk_clist_set_selection_mode( GTK_CLIST( SkinList ),GTK_SELECTION_SINGLE );
|
|
|
|
gtk_clist_column_titles_hide( GTK_CLIST( SkinList ) );
|
|
|
|
gtk_clist_set_shadow_type( GTK_CLIST( SkinList ),GTK_SHADOW_ETCHED_OUT );
|
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
AddHSeparator( vbox5 );
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
hbuttonbox4=AddHButtonBox( vbox5 );
|
|
|
|
gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox4 ),GTK_BUTTONBOX_SPREAD );
|
|
|
|
gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox4 ),10 );
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2002-11-27 22:48:56 +00:00
|
|
|
Ok=AddButton( MSGTR_Ok,hbuttonbox4 );
|
|
|
|
Cancel=AddButton( MSGTR_Cancel,hbuttonbox4 );
|
2001-11-14 16:04:25 +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 );
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2003-01-02 15:48:29 +00:00
|
|
|
gtk_signal_connect( GTK_OBJECT( SkinBrowser ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&SkinBrowser );
|
2001-11-14 16:04:25 +00:00
|
|
|
gtk_signal_connect( GTK_OBJECT( SkinList ),"select_row",GTK_SIGNAL_FUNC( on_SkinList_select_row ),NULL );
|
2002-11-27 22:48:56 +00:00
|
|
|
gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)1 );
|
|
|
|
gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)0 );
|
2001-11-14 16:04:25 +00:00
|
|
|
|
2006-07-13 16:17:24 +00:00
|
|
|
if ( ( sbMPlayerDirInHome_obsolete=calloc( 1,strlen( skinDirInHome_obsolete ) + 4 ) ) != NULL )
|
2006-03-27 11:39:27 +00:00
|
|
|
{ strcpy( sbMPlayerDirInHome_obsolete,skinDirInHome_obsolete ); strcat( sbMPlayerDirInHome_obsolete,"/*" ); }
|
2006-07-13 16:17:24 +00:00
|
|
|
if ( ( sbMPlayerDirInHome=calloc( 1,strlen( skinDirInHome ) + 4 ) ) != NULL )
|
2001-11-14 16:04:25 +00:00
|
|
|
{ strcpy( sbMPlayerDirInHome,skinDirInHome ); strcat( sbMPlayerDirInHome,"/*" ); }
|
2006-07-13 16:17:24 +00:00
|
|
|
if ( ( sbMPlayerPrefixDir_obsolete=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL )
|
2006-03-27 11:39:27 +00:00
|
|
|
{ strcpy( sbMPlayerPrefixDir_obsolete,skinMPlayerDir ); strcat( sbMPlayerPrefixDir_obsolete,"/*" ); }
|
2006-07-13 16:17:24 +00:00
|
|
|
if ( ( sbMPlayerPrefixDir=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL )
|
2001-11-14 16:04:25 +00:00
|
|
|
{ strcpy( sbMPlayerPrefixDir,skinMPlayerDir ); strcat( sbMPlayerPrefixDir,"/*" ); }
|
|
|
|
|
|
|
|
gtk_window_add_accel_group( GTK_WINDOW( SkinBrowser ),accel_group );
|
|
|
|
gtk_widget_grab_focus( SkinList );
|
|
|
|
|
|
|
|
return SkinBrowser;
|
|
|
|
}
|