X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcfilebox.C;h=212956b83a9050a76496559cfb22e9264f4fb064;hb=0a0a29dd9e484b5622b46173d51bb6cefc0a5da4;hp=1dc1f308d5739b7c41276ca7923a26bc1caa5025;hpb=43821d27c5b51c4250a251f20c98878f54deb288;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bcfilebox.C b/cinelerra-5.1/guicast/bcfilebox.C index 1dc1f308..212956b8 100644 --- a/cinelerra-5.1/guicast/bcfilebox.C +++ b/cinelerra-5.1/guicast/bcfilebox.C @@ -1,7 +1,7 @@ /* * CINELERRA - * Copyright (C) 1997-2011 Adam Williams + * Copyright (C) 1997-2017 Adam Williams * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -215,7 +215,7 @@ int BC_FileBoxDirectoryText::handle_event() while( *cp ) ++cp; if( cp > path && *--cp != '/' ) return 0; char *file_path = FileSystem::basepath(path); - char *dir_path = FileSystem::basepath(filebox->fs->get_current_dir()); + char *dir_path = FileSystem::basepath(filebox->directory); int ret = !strcmp(file_path, dir_path) ? 0 : 1; if( ret ) { strcpy(filebox->directory, file_path); @@ -497,7 +497,7 @@ BC_FileBox::BC_FileBox(int x, int y, const char *init_path, this->want_directory = want_directory; if(show_all_files) fs->set_show_all(); fs->complete_path(this->current_path); - fs->complete_path(this->submitted_path); + strcpy(this->submitted_path, this->current_path); fs->extract_dir(directory, this->current_path); fs->extract_name(filename, this->current_path); @@ -535,16 +535,12 @@ BC_FileBox::BC_FileBox(int x, int y, const char *init_path, // Test if current directory exists if(!fs->is_dir(directory)) { - sprintf(this->current_path, "~"); - fs->complete_path(this->current_path); - fs->set_current_dir(this->current_path); -// fs->update(this->current_path); - strcpy(directory, fs->get_current_dir()); + sprintf(directory, "~"); + fs->complete_path(directory); + strcpy(current_path,directory); filename[0] = 0; } - else - fs->set_current_dir(this->directory); - + fs->set_current_dir(directory); if(h_padding == -1) { @@ -580,10 +576,6 @@ void BC_FileBox::create_objects() int directory_title_margin = MAX(20, resources->filebox_text_images[0]->get_h()); -// Create recent dir list - create_history(); - update_history(); - // Directories aren't filtered in FileSystem so skip this if(!want_directory) { @@ -596,10 +588,6 @@ void BC_FileBox::create_objects() fs->set_filter(get_resources()->filebox_filter); } - fs->set_sort_order(sort_order); - fs->set_sort_field(column_type[sort_column]); - fs->update(directory); - create_icons(); create_tables(); @@ -637,11 +625,9 @@ void BC_FileBox::create_objects() add_subwindow(recent_popup = new BC_FileBoxRecent(this, x, y)); add_subwindow(directory_title = new BC_FileBoxDirectoryText(x, y, this)); - directory_title->reposition_window(x, y, - get_w() - recent_popup->get_w() - 20, 1); - recent_popup->reposition_window( - x + directory_title->get_w(), y, - directory_title->get_w(), 200); + directory_title->reposition_window(x, y, get_w() - recent_popup->get_w() - 20, 1); + x += directory_title->get_w() + 8; + recent_popup->reposition_window(x, y, directory_title->get_w(), 200); x = 10; y += directory_title->get_h() + 5; @@ -657,8 +643,16 @@ void BC_FileBox::create_objects() if( newest >= 0 ) { strcpy(directory, resources->filebox_history[newest].path); fs->change_dir(directory, 0); + strcpy(directory, fs->get_current_dir()); directory_title->update(fs->get_current_dir()); } + fs->set_sort_order(sort_order); + fs->set_sort_field(column_type[sort_column]); + fs->update(directory); + +// Create recent dir list + create_history(); + update_history(); listbox = 0; create_listbox(x, y, get_display_mode()); @@ -678,7 +672,7 @@ void BC_FileBox::create_objects() rename_thread = new BC_RenameThread(this); - + refresh(); show_window(); } @@ -742,7 +736,7 @@ int BC_FileBox::resize_event(int w, int h) get_w() - recent_popup->get_w() - 20, 1); recent_popup->reposition_window( - directory_title->get_x() + directory_title->get_w(), + directory_title->get_x() + directory_title->get_w() + 8, directory_title->get_y(), directory_title->get_w() + recent_popup->get_w(), recent_popup->get_h()); @@ -889,25 +883,13 @@ int BC_FileBox::delete_tables() BC_Pixmap* BC_FileBox::get_icon(char *path, int is_dir) { - char *suffix = strrchr(path, '.'); + if( is_dir ) return icons[ICON_FOLDER]; int icon_type = ICON_UNKNOWN; - - if(is_dir) return icons[ICON_FOLDER]; - - if(suffix) - { - suffix++; - if(*suffix != 0) - { - for(int i = 0; i < TOTAL_SUFFIXES; i++) - { - if(!strcasecmp(suffix, BC_WindowBase::get_resources()->suffix_to_type[i].suffix)) - { - icon_type = BC_WindowBase::get_resources()->suffix_to_type[i].icon_type; - break; - } - } - } + char *suffix = strrchr(path, '.'); + if( suffix && *++suffix ) { + suffix_to_type_t *stp = &BC_WindowBase::get_resources()->suffix_to_type[0]; + while( stp->suffix && strcasecmp(stp->suffix, suffix) ) ++stp; + if( stp->icon_type ) icon_type = stp->icon_type; } return icons[icon_type]; @@ -1044,12 +1026,17 @@ int BC_FileBox::submit_dir(char *dir) int BC_FileBox::submit_file(const char *path, int use_this) { + char path1[BCTEXTLEN]; + strcpy(path1, path); + char *cp = strchr(path1,'\n'); + if( cp ) *cp = 0; + // Deactivate textbox to hide suggestions textbox->deactivate(); // If file wanted, take the current directory as the desired file. // If directory wanted, ignore it. - if(!path[0] && !want_directory) + if(!path1[0] && !want_directory) { // save complete path strcpy(this->current_path, directory); @@ -1063,9 +1050,9 @@ int BC_FileBox::submit_file(const char *path, int use_this) } // is a directory, change directories - if(fs->is_dir(path) && !use_this) + if(fs->is_dir(path1) && !use_this) { - fs->change_dir(path, 0); + fs->change_dir(path1, 0); refresh(1); directory_title->update(fs->get_current_dir()); strcpy(this->current_path, fs->get_current_dir()); @@ -1084,7 +1071,7 @@ int BC_FileBox::submit_file(const char *path, int use_this) // Is a file or desired directory. Quit the operation. { char path2[BCTEXTLEN]; - strcpy(path2, path); + strcpy(path2, path1); // save directory for defaults fs->extract_dir(directory, path2); @@ -1120,7 +1107,7 @@ void BC_FileBox::update_history() strcpy(path, directory); // enfore one trailing slash char *cp = path; - while( *cp ) ++cp; + while( *cp && *cp != '\n' ) ++cp; while( cp > path && *(cp-1) == '/' ) --cp; *cp++ = '/'; *cp = 0;