1
mirror of https://github.com/mpv-player/mpv synced 2025-01-13 00:06:25 +01:00

- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>

- wsXDNDProcessSelection return Truae fix
- add url list saving support from Morten Volden <mvolden@tdcadsl.dk>
- fix bug's in this patches
- fix some memleak and bug


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7093 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
pontscho 2002-08-26 22:20:58 +00:00
parent c39611bbe9
commit 452e7bdc03
14 changed files with 125 additions and 33 deletions

View File

@ -13,6 +13,8 @@
#include "mplayer/mplayer.h"
#include "interface.h"
extern char *get_path(char *);
listItems appMPlayer;
char * skinDirInHome=NULL;

View File

@ -106,9 +106,22 @@ static config_t gui_opts[] =
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
char * gfgets( char * str, int size, FILE * f )
{
char * s = fgets( str,size,f );
char c;
if ( s )
{
c=s[ strlen( s ) - 1 ]; if ( c == '\n' || c == '\r' ) s[ strlen( s ) - 1 ]=0;
c=s[ strlen( s ) - 1 ]; if ( c == '\n' || c == '\r' ) s[ strlen( s ) - 1 ]=0;
}
return s;
}
int cfg_read( void )
{
char * cfg = get_path( "gui.conf" );
FILE * f;
// -- read configuration
mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg );
@ -122,26 +135,39 @@ int cfg_read( void )
free( cfg );
// -- read pl
{
FILE * f;
cfg=get_path( "gui.pl" );
if ( (f=fopen( cfg,"rt" )) == NULL ) return 1;
while ( !feof( f ) )
{
char tmp[512]; plItem * item = calloc( 1,sizeof( plItem ) ); char c;
if ( fgets( tmp,512,f ) == NULL ) continue;
c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
item->path=strdup( tmp );
fgets( tmp,512,f );
c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
item->name=strdup( tmp );
gtkSet( gtkAddPlItem,0,(void*)item );
}
fclose( f );
free( cfg );
}
cfg=get_path( "gui.pl" );
if ( (f=fopen( cfg,"rt" )) )
{
while ( !feof( f ) )
{
char tmp[512]; plItem * item;
if ( gfgets( tmp,512,f ) == NULL ) continue;
item=calloc( 1,sizeof( plItem ) );
item->path=strdup( tmp );
gfgets( tmp,512,f );
item->name=strdup( tmp );
gtkSet( gtkAddPlItem,0,(void*)item );
}
fclose( f );
}
free( cfg );
//-- read previously visited urls
cfg=get_path( "gui.url" );
if ( (f=fopen( cfg,"rt" )) )
{
while ( !feof( f ) )
{
char tmp[512]; URLItem * item;
if ( gfgets( tmp,512,f ) == NULL ) continue;
item=calloc( 1,sizeof( URLItem ) );
item->url=strdup( tmp );
gtkSet( gtkAddURLItem,0,(void*)item );
}
fclose( f );
}
free( cfg );
return 0;
}
@ -195,6 +221,19 @@ int cfg_write( void )
}
free( cfg );
// -- save URL's
cfg=get_path( "gui.url" );
if ( (f=fopen( cfg,"wt+" )) )
{
while ( URLList )
{
if ( URLList->url ) fprintf( f,"%s\n",URLList->url );
URLList=URLList->next;
}
fclose( f );
}
free( cfg );
return 0;
}

View File

@ -555,6 +555,8 @@ plItem * plCurrent = NULL;
plItem * plList = NULL;
plItem * plLastPlayed = NULL;
URLItem *URLList = NULL;
#if defined( MP_DEBUG ) && 0
void list( void )
{
@ -577,6 +579,9 @@ void * gtkSet( int cmd,float fparam, void * vparam )
equalizer_t * eq = (equalizer_t *)vparam;
plItem * item = (plItem *)vparam;
URLItem * url_item = (URLItem *)vparam;
int is_added = True;
switch ( cmd )
{
// --- handle playlist
@ -586,8 +591,7 @@ void * gtkSet( int cmd,float fparam, void * vparam )
plItem * next = plList;
while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; }
next->next=item; item->prev=next;
}
else { item->prev=item->next=NULL; plCurrent=plList=item; }
} else { item->prev=item->next=NULL; plCurrent=plList=item; }
list();
return NULL;
case gtkGetNextPlItem: // get current item from playlist
@ -638,6 +642,24 @@ void * gtkSet( int cmd,float fparam, void * vparam )
plList=NULL; plCurrent=NULL;
}
return NULL;
// ----- Handle url
case gtkAddURLItem:
if ( URLList )
{
URLItem * next_url = URLList;
is_added = False;
while ( next_url->next )
{
if ( !gstrcmp( next_url->url,url_item->url ) )
{
is_added=True;
break;
}
next_url=next_url->next;
}
if ( ( !is_added )&&( gstrcmp( next_url->url,url_item->url ) ) ) next_url->next=url_item;
} else { url_item->next=NULL; URLList=url_item; }
return NULL;
// --- subtitle
case gtkSetSubAuto:
sub_auto=(int)fparam;

View File

@ -144,10 +144,18 @@ typedef struct _plItem
char * name;
} plItem;
typedef struct _urlItem
{
struct _urlItem *next;
char * url;
} URLItem;
extern plItem * plList;
extern plItem * plCurrent;
extern plItem * plLastPlayed;
extern URLItem * URLList;
#define gtkSetContrast 0
#define gtkSetBrightness 1
#define gtkSetHue 2
@ -168,6 +176,7 @@ extern plItem * plLastPlayed;
#define gtkSetFontFactor 17
#define gtkSetAutoq 18
#define gtkClearStruct 19
#define gtkAddURLItem 20
extern float gtkEquChannels[6][10];

View File

@ -233,7 +233,6 @@ static void eqShow( GtkWidget * widget,gpointer user_data )
static void eqSelectChannelsListRow( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data )
{
char * tmp;
Channel=row - 1;
eqSetBands( Channel );
if ( Channel == -1 )

View File

@ -9,4 +9,4 @@ extern GtkWidget * Equalizer;
extern GtkWidget * create_Equalizer( void );
extern void ShowEqualizer( void );
#endif
#endif

View File

@ -10,4 +10,4 @@ extern GtkWidget * AddSubMenu( GtkWidget * Menu,char * label );
extern GtkWidget * AddSeparator( GtkWidget * Menu );
extern GtkWidget * create_PopUpMenu( void );
#endif
#endif

View File

@ -14,4 +14,4 @@ extern GtkWidget * create_OSSConfig( void );
extern void ShowPreferences( void );
#endif
#endif

View File

@ -266,7 +266,7 @@ static void plButtonReleased( GtkButton * button,gpointer user_data )
{
if ( CLFileSelected[i] )
{
gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,&itext );
gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext );
text[0][0]=itext[0][0]; text[0][1]=current_path;
gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
NrOfSelected++;

View File

@ -11,4 +11,4 @@ extern void HidePlayList( void );
extern GtkWidget * create_PlayList (void);
#endif
#endif

View File

@ -27,6 +27,18 @@ void ShowURLDialogBox( void )
if ( gtkVURLDialogBox ) gtkActive( URL );
else URL=create_URL();
if ( URLList )
{
URLItem * item = URLList;
g_list_free( URLComboEntrys );
URLComboEntrys=NULL;
while( item )
{
URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url );
item=item->next;
}
}
if ( URLComboEntrys )
{
gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data );
@ -53,6 +65,8 @@ static gboolean on_URL_destroy_event( GtkWidget * widget,GdkEvent * event,gpoint
static void on_Button_pressed( GtkButton * button,gpointer user_data )
{
URLItem * item;
if ( (int)user_data )
{
gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) );
@ -67,6 +81,10 @@ static void on_Button_pressed( GtkButton * button,gpointer user_data )
free( str ); str=tmp;
}
URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str );
item=calloc( 1,sizeof( URLItem ) );
item->url=gstrdup( str );
gtkSet( gtkAddURLItem,0,(void *)item );
guiSetFilename( guiIntfStruct.Filename,str ); guiIntfStruct.FilenameChanged=1;
mplEventHandling( evPlayNetwork,0 );

View File

@ -646,7 +646,7 @@ void mplMainKeyHandle( int KeyCode,int Type,int Key )
}
/* this will be used to handle Drag&Drop files */
void mplDandDHandler(int num,const char** files)
void mplDandDHandler(int num,char** files)
{
struct stat buf;
int f = 0;

View File

@ -1,6 +1,8 @@
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
@ -33,9 +35,8 @@ static int mplGotoTheNext = 1;
void mplFullScreen( void )
{
static int sx,sy;
#if 0
static int sx,sy;
// if ( !guiIntfStruct.Playing )
{
wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow );

View File

@ -126,6 +126,7 @@ wsXDNDProcessSelection(wsTWindow* wnd, XEvent *event)
}
free(delme);
return True;
}
Bool
@ -153,10 +154,11 @@ wsXDNDProcessClientMessage(wsTWindow* wnd, XClientMessageEvent *event)
}
} else {
/* need to check the whole list here */
int ret_left = 1;
unsigned long ret_left = 1;
int offset = 0;
Atom* ret_buff;
int ret_type,ret_format,ret_items;
Atom ret_type;
unsigned long ret_format,ret_items;
/* while there is data left...*/
while(ret_left){
XGetWindowProperty(wsDisplay,event->data.l[0],_XA_XdndTypeList,