Mercurial > mplayer.hg
comparison Gui/mplayer/gtk/fs.c @ 8713:d9639f835ecf
persistant history path from Pavel Rousar <p.rousar@sh.cvut.cz>
author | pontscho |
---|---|
date | Thu, 02 Jan 2003 12:33:06 +0000 |
parents | 5b67aed0fc28 |
children | dc27303ae528 |
comparison
equal
deleted
inserted
replaced
8712:9e32c8ee5862 | 8713:d9639f835ecf |
---|---|
306 | 306 |
307 free( dir ); | 307 free( dir ); |
308 } | 308 } |
309 | 309 |
310 if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; | 310 if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; |
311 fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); | 311 { |
312 char hist[fsPersistant_MaxPath + 1]; | |
313 | |
314 bzero( hist,fsPersistant_MaxPath + 1 ); | |
315 if ( fs_PersistantHistory( 0,hist,0 ) == 0 ) | |
316 { | |
317 fsTopList_items=g_list_append( fsTopList_items,hist ); | |
318 chdir( hist ); | |
319 } else fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); | |
320 } | |
312 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); | 321 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); |
313 fsTopList_items=g_list_append( fsTopList_items,"/home" ); | 322 fsTopList_items=g_list_append( fsTopList_items,"/home" ); |
314 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); | 323 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); |
315 fsTopList_items=g_list_append( fsTopList_items,"/" ); | 324 fsTopList_items=g_list_append( fsTopList_items,"/" ); |
316 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); | 325 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); |
325 if ( !fsFileSelect ) return; | 334 if ( !fsFileSelect ) return; |
326 gtk_widget_hide( fsFileSelect ); | 335 gtk_widget_hide( fsFileSelect ); |
327 gtk_widget_destroy( fsFileSelect ); | 336 gtk_widget_destroy( fsFileSelect ); |
328 fsFileSelect=NULL; | 337 fsFileSelect=NULL; |
329 } | 338 } |
339 | |
340 //---------------------------------------------------- | |
341 | |
342 /* | |
343 * int fs_PersistantHistory(int rw_command, char *subject) | |
344 * | |
345 * is used to read/write in the $HOME/.mplayer/persistant_history file | |
346 * parameters: rw_command = (0,1) <=> (read,write) | |
347 * subject - for i/o | |
348 * pos - position in history file (line) | |
349 * return: 0 = ok | |
350 * | |
351 */ | |
352 | |
353 int fs_PersistantHistory(int rw_command, char *subject, int pos) | |
354 { | |
355 FILE *pfile; | |
356 | |
357 char path[fsPersistant_MaxPath+1]; | |
358 int fdata,fpos = 0; | |
359 char *subpath = NULL; | |
360 const char *ph_filename = fsPersistant_FilePath; | |
361 | |
362 if (!subject) return -1; | |
363 if (pos < 0 || pos > fsPersistant_MaxPos) return -2; | |
364 bzero(path,fsPersistant_MaxPath+1); | |
365 | |
366 subpath = getenv("HOME"); | |
367 if (!subpath) return -3; | |
368 if (strlen(subpath)+strlen(fsPersistant_FilePath) > fsPersistant_MaxPath) return -4; | |
369 memcpy(path, subpath, strlen(subpath)); | |
370 memcpy(path+strlen(subpath), ph_filename, strlen(ph_filename)); | |
371 | |
372 if (rw_command == 0) | |
373 { | |
374 pfile = fopen(path,"r"); | |
375 if (!pfile) return -5; | |
376 while ((fdata = fgetc(pfile)) != EOF) | |
377 { | |
378 if (fpos > fsPersistant_MaxPath) { fclose(pfile);return -6; } | |
379 subject[fpos++] = fdata; | |
380 } | |
381 fclose(pfile); | |
382 return 0; | |
383 } | |
384 | |
385 if (rw_command == 1) | |
386 { | |
387 pfile = fopen(path,"w+"); | |
388 if (!pfile) return -6; | |
389 fprintf(pfile,"%s",subject); | |
390 fclose(pfile); | |
391 return 0; | |
392 } | |
393 else return -10; | |
394 } | |
395 //----------------------------------------------- | |
330 | 396 |
331 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) | 397 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) |
332 { | 398 { |
333 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | 399 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) ); |
334 CheckDir( fsFNameList,get_current_dir_name() ); | 400 CheckDir( fsFNameList,get_current_dir_name() ); |
419 { | 485 { |
420 chdir( fsSelectedFile ); | 486 chdir( fsSelectedFile ); |
421 fsSelectedFile=fsThatDir; | 487 fsSelectedFile=fsThatDir; |
422 CheckDir( fsFNameList,get_current_dir_name() ); | 488 CheckDir( fsFNameList,get_current_dir_name() ); |
423 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | 489 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); |
490 fs_PersistantHistory(1,get_current_dir_name(),0); //totem, write into history | |
424 return; | 491 return; |
425 } | 492 } |
426 | 493 |
427 switch( fsPressed ) | 494 switch( fsPressed ) |
428 { | 495 { |
487 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() ); | 554 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() ); |
488 if ( mplMainAutoPlay ) { mplMainAutoPlay=0; mplEventHandling( evPlay,0 ); } | 555 if ( mplMainAutoPlay ) { mplMainAutoPlay=0; mplEventHandling( evPlay,0 ); } |
489 } | 556 } |
490 | 557 |
491 void fs_Cancel_released( GtkButton * button,gpointer user_data ) | 558 void fs_Cancel_released( GtkButton * button,gpointer user_data ) |
492 { HideFileSelect(); } | 559 { |
560 HideFileSelect(); | |
561 fs_PersistantHistory(1,get_current_dir_name(),0); //totem, write into history file | |
562 } | |
493 | 563 |
494 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) | 564 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) |
495 { | 565 { |
496 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); | 566 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); |
497 fsPressed=1; | 567 fsPressed=1; |
535 GtkWidget * uppixmapwid; | 605 GtkWidget * uppixmapwid; |
536 GdkPixmap * uppixmap; | 606 GdkPixmap * uppixmap; |
537 GdkBitmap * upmask; | 607 GdkBitmap * upmask; |
538 GtkStyle * upstyle; | 608 GtkStyle * upstyle; |
539 | 609 |
610 | |
540 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | 611 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
541 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); | 612 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); |
542 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | 613 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); |
543 gtk_widget_set_usize( fsFileSelect,512,300 ); | 614 gtk_widget_set_usize( fsFileSelect,512,300 ); |
544 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); | 615 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); |