Mercurial > mplayer.hg
comparison Gui/mplayer/gtk/fs.c @ 9055:4a42c0604ce1
- rewrite sub_fps
- add fps support
- rewrite history
author | pontscho |
---|---|
date | Tue, 21 Jan 2003 13:33:40 +0000 |
parents | 16fa828e3d4c |
children | 3086611e8213 |
comparison
equal
deleted
inserted
replaced
9054:1a8d13c9b7a5 | 9055:4a42c0604ce1 |
---|---|
302 free( dir ); | 302 free( dir ); |
303 } | 303 } |
304 | 304 |
305 if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; | 305 if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; |
306 { | 306 { |
307 char hist[fsPersistant_MaxPath + 1]; | 307 char * hist; |
308 int i, c = 1; | |
308 | 309 |
309 bzero( hist,fsPersistant_MaxPath + 1 ); | 310 for ( i=0;i < fsPersistant_MaxPos;i++ ) |
310 if ( fs_PersistantHistory( 0,hist,0 ) == 0 ) | 311 if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); c=0; } |
311 { | 312 if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); |
312 fsTopList_items=g_list_append( fsTopList_items,hist ); | |
313 chdir( hist ); | |
314 } else fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); | |
315 } | 313 } |
316 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); | 314 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); |
317 fsTopList_items=g_list_append( fsTopList_items,"/home" ); | 315 fsTopList_items=g_list_append( fsTopList_items,"/home" ); |
318 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); | 316 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); |
319 fsTopList_items=g_list_append( fsTopList_items,"/" ); | 317 fsTopList_items=g_list_append( fsTopList_items,"/" ); |
330 gtk_widget_hide( fsFileSelect ); | 328 gtk_widget_hide( fsFileSelect ); |
331 gtk_widget_destroy( fsFileSelect ); | 329 gtk_widget_destroy( fsFileSelect ); |
332 fsFileSelect=NULL; | 330 fsFileSelect=NULL; |
333 } | 331 } |
334 | 332 |
335 //---------------------------------------------------- | 333 int fs_PersistantHistory( char * subject ) |
336 | 334 { |
337 /* | 335 int i; |
338 * int fs_PersistantHistory(int rw_command, char *subject) | 336 |
339 * | 337 for ( i=0;i < fsPersistant_MaxPos;i++ ) if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) ) return 0; |
340 * is used to read/write in the $HOME/.mplayer/persistant_history file | 338 gfree( (void **)&fsHistory[fsPersistant_MaxPos - 1] ); |
341 * parameters: rw_command = (0,1) <=> (read,write) | 339 for ( i=fsPersistant_MaxPos - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1]; |
342 * subject - for i/o | 340 fsHistory[0]=gstrdup( subject ); |
343 * pos - position in history file (line) | 341 |
344 * return: 0 = ok | 342 return 0; |
345 * | |
346 */ | |
347 | |
348 int fs_PersistantHistory(int rw_command, char *subject, int pos) | |
349 { | |
350 FILE *pfile; | |
351 | |
352 char path[fsPersistant_MaxPath+1]; | |
353 int fdata,fpos = 0; | |
354 char *subpath = NULL; | |
355 const char *ph_filename = fsPersistant_FilePath; | |
356 | |
357 if (!subject) return -1; | |
358 if (pos < 0 || pos > fsPersistant_MaxPos) return -2; | |
359 bzero(path,fsPersistant_MaxPath+1); | |
360 | |
361 subpath = getenv("HOME"); | |
362 if (!subpath) return -3; | |
363 if (strlen(subpath)+strlen(fsPersistant_FilePath) > fsPersistant_MaxPath) return -4; | |
364 memcpy(path, subpath, strlen(subpath)); | |
365 memcpy(path+strlen(subpath), ph_filename, strlen(ph_filename)); | |
366 | |
367 if (rw_command == 0) | |
368 { | |
369 pfile = fopen(path,"r"); | |
370 if (!pfile) return -5; | |
371 while ((fdata = fgetc(pfile)) != EOF) | |
372 { | |
373 if (fpos > fsPersistant_MaxPath) { fclose(pfile);return -6; } | |
374 subject[fpos++] = fdata; | |
375 } | |
376 fclose(pfile); | |
377 return 0; | |
378 } | |
379 | |
380 if (rw_command == 1) | |
381 { | |
382 pfile = fopen(path,"w+"); | |
383 if (!pfile) return -6; | |
384 fprintf(pfile,"%s",subject); | |
385 fclose(pfile); | |
386 return 0; | |
387 } | |
388 else return -10; | |
389 } | 343 } |
390 //----------------------------------------------- | 344 //----------------------------------------------- |
391 | 345 |
392 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) | 346 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) |
393 { | 347 { |
480 { | 434 { |
481 chdir( fsSelectedFile ); | 435 chdir( fsSelectedFile ); |
482 fsSelectedFile=fsThatDir; | 436 fsSelectedFile=fsThatDir; |
483 CheckDir( fsFNameList,get_current_dir_name() ); | 437 CheckDir( fsFNameList,get_current_dir_name() ); |
484 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | 438 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); |
485 fs_PersistantHistory(1,get_current_dir_name(),0); //totem, write into history | |
486 return; | 439 return; |
487 } | 440 } |
488 | 441 |
489 switch( fsPressed ) | 442 switch( fsPressed ) |
490 { | 443 { |
514 guiSetDF( guiIntfStruct.Filename,fsSelectedDirectory,fsSelectedFile ); | 467 guiSetDF( guiIntfStruct.Filename,fsSelectedDirectory,fsSelectedFile ); |
515 guiIntfStruct.StreamType=STREAMTYPE_FILE; | 468 guiIntfStruct.StreamType=STREAMTYPE_FILE; |
516 guiIntfStruct.FilenameChanged=1; | 469 guiIntfStruct.FilenameChanged=1; |
517 gfree( (void **)&guiIntfStruct.AudioFile ); | 470 gfree( (void **)&guiIntfStruct.AudioFile ); |
518 gfree( (void **)&guiIntfStruct.Subtitlename ); | 471 gfree( (void **)&guiIntfStruct.Subtitlename ); |
472 fs_PersistantHistory( fsSelectedDirectory ); //totem, write into history | |
519 break; | 473 break; |
520 #ifdef USE_SUB | 474 #ifdef USE_SUB |
521 case fsSubtitleSelector: | 475 case fsSubtitleSelector: |
522 guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile ); | 476 guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile ); |
523 guiLoadSubtitle( guiIntfStruct.Subtitlename ); | 477 guiLoadSubtitle( guiIntfStruct.Subtitlename ); |
551 } | 505 } |
552 | 506 |
553 void fs_Cancel_released( GtkButton * button,gpointer user_data ) | 507 void fs_Cancel_released( GtkButton * button,gpointer user_data ) |
554 { | 508 { |
555 HideFileSelect(); | 509 HideFileSelect(); |
556 fs_PersistantHistory(1,get_current_dir_name(),0); //totem, write into history file | 510 fs_PersistantHistory( get_current_dir_name() ); //totem, write into history file |
557 } | 511 } |
558 | 512 |
559 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) | 513 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) |
560 { | 514 { |
561 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); | 515 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); |