Пример #1
0
void ScenesDock::_search_changed(const String& p_text) {

	if (!search_box->is_visible())
		return; //wtf

	_update_files(false);
}
Пример #2
0
void ScenesDock::_open_pressed(){


	TreeItem *sel = tree->get_selected();
	if (!sel) {
		return;
	}
	path = sel->get_metadata(0);
	/*if (path!="res://" && path.ends_with("/")) {
		path=path.substr(0,path.length()-1);
	}*/

	//tree_mode=false;

	if (split_mode) {
		tree->hide();
		file_list_vb->show();
		button_favorite->hide();
		button_fav_up->hide();
		button_fav_down->hide();
	}

	//file_options->show();

	_update_files(false);
	current_path->set_text(path);
	_push_to_history();

//	emit_signal("open",path);

}
Пример #3
0
void ScenesDock::_change_file_display() {

	if (display_mode->is_pressed()) {
		display_mode->set_icon( get_icon("FileThumbnail","EditorIcons"));

	} else {
		display_mode->set_icon( get_icon("FileList","EditorIcons"));
	}

	_update_files(true);
}
Пример #4
0
void ScenesDock::_search_toggled(){

	if (search_button->is_pressed()) {
		//search_box->clear();
		search_box->select_all();
		search_box->show();
		current_path->hide();
		search_box->grab_focus();

		_update_files(false);
	} else {

		//search_box->clear();
		search_box->hide();
		current_path->show();

		_update_files(false);

	}
}
Пример #5
0
void ScenesDock::_go_to_dir(const String& p_dir){

	DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
	if (da->change_dir(p_dir)==OK) {
		path=da->get_current_dir();
		_update_files(false);
	}
	current_path->set_text(path);
	memdelete(da);


}
Пример #6
0
void FileSystemDock::_change_file_display() {

	if (button_display_mode->is_pressed()) {
		display_mode = DISPLAY_LIST;
		button_display_mode->set_icon( get_icon("FileThumbnail","EditorIcons"));
	} else {
		display_mode = DISPLAY_THUMBNAILS;
		button_display_mode->set_icon( get_icon("FileList","EditorIcons"));
	}

	EditorSettings::get_singleton()->set("filesystem_dock/display_mode", display_mode);

	_update_files(true);
}
Пример #7
0
void ScenesDock::open(const String& p_path) {


	String npath;
	String nfile;

	if (p_path.ends_with("/")) {

		if (p_path!="res://")
			npath=p_path.substr(0,p_path.length()-1);
		else
			npath="res://";
	} else {
		nfile=p_path.get_file();
		npath=p_path.get_base_dir();
	}

	path=npath;

	if (tree_mode && nfile=="") {
		_update_tree();
		tree->grab_focus();
		tree->call_deferred("ensure_cursor_is_visible");
		_push_to_history();
		return;
	} else if (tree_mode){
		_update_tree();
		tree->grab_focus();
		tree->ensure_cursor_is_visible();
		_open_pressed();
		current_path->set_text(path);
	} else {
		_update_files(false);
		_push_to_history();
	}

	for(int i=0;i<files->get_item_count();i++) {

		String md = files->get_item_metadata(i);
		if (md==p_path) {
			files->select(i,true);
			files->ensure_current_is_visible();
			break;
		}
	}

}
Пример #8
0
void ScenesDock::_fs_changed() {

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());
	scanning_vb->hide();
	split_box->show();

	if (!tree->is_hidden()) {
		button_favorite->show();
		_update_tree();

	}

	if (!file_list_vb->is_hidden()) {

		_update_files(true);
	}

	set_process(false);
}
Пример #9
0
void ScenesDock::_bw_history() {

	if (history_pos>0)
		history_pos--;

	path=history[history_pos];

	if (tree_mode) {
		_update_tree();
		tree->grab_focus();
		tree->ensure_cursor_is_visible();
	} else {
		_update_files(false);
		current_path->set_text(path);
	}

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());

}
Пример #10
0
void ScenesDock::_fw_history() {

	if (history_pos<history.size()-1)
		history_pos++;

	path=history[history_pos];

	if (!tree->is_hidden()) {
		_update_tree();
		tree->grab_focus();
		tree->ensure_cursor_is_visible();

	}

	if (!file_list_vb->is_hidden()) {
		_update_files(false);
		current_path->set_text(path);
	}

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());

}
Пример #11
0
void ScenesDock::_fs_changed() {

	button_hist_prev->set_disabled(history_pos==0);
	button_hist_next->set_disabled(history_pos+1==history.size());
	scanning_vb->hide();

	if (tree_mode) {

		tree->show();
		button_favorite->show();
		button_fav_up->show();
		button_fav_down->show();
		_update_tree();
	} else {
		files->show();
		path_hb->show();
		button_instance->show();
		button_open->show();
		file_options->show();
		_update_files(true);
	}

	set_process(false);
}
Пример #12
0
void ScenesDock::_file_option(int p_option) {

	switch(p_option) {


		case FILE_SHOW_IN_EXPLORER:
		case FILE_OPEN: {
			int idx=-1;
			for(int i=0;i<files->get_item_count();i++) {
				if (files->is_selected(i)) {
					idx=i;
					break;
				}
			}

			if (idx<0)
				return;



			String path = files->get_item_metadata(idx);
			if (p_option == FILE_SHOW_IN_EXPLORER) {
				String dir = Globals::get_singleton()->globalize_path(path);
				dir = dir.substr(0, dir.find_last("/"));
				OS::get_singleton()->shell_open(String("file://")+dir);
				return;
			}

			if (path.ends_with("/")) {
				if (path!="res://") {
					path=path.substr(0,path.length()-1);
				}
				this->path=path;
				_update_files(false);
				current_path->set_text(path);
				_push_to_history();
			} else {

				if (ResourceLoader::get_resource_type(path)=="PackedScene") {

					editor->open_request(path);
				} else {

					editor->load_resource(path);
				}
			}
		} break;
		case FILE_INSTANCE: {

			for (int i = 0; i<files->get_item_count(); i++) {

				String path =files->get_item_metadata(i);
				if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") {
					emit_signal("instance",path);
				}
			}
		} break;
		case FILE_DEPENDENCIES: {

			int idx = files->get_current();
			if (idx<0 || idx>=files->get_item_count())
				break;
			String path = files->get_item_metadata(idx);
			deps_editor->edit(path);
		} break;
		case FILE_OWNERS: {

			int idx = files->get_current();
			if (idx<0 || idx>=files->get_item_count())
				break;
			String path = files->get_item_metadata(idx);
			owners_editor->show(path);
		} break;
		case FILE_MOVE: {

			move_dirs.clear();;
			move_files.clear();

			for(int i=0;i<files->get_item_count();i++) {

				String path = files->get_item_metadata(i);
				if (!files->is_selected(i))
					continue;

				 if (files->get_item_text(i)=="..") {
					 EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'"));
					 return;
				 }

				if (path.ends_with("/")) {
					move_dirs.push_back(path.substr(0,path.length()-1));
				} else {
					move_files.push_back(path);
				}
			}


			if (move_dirs.empty() && move_files.size()==1) {

				rename_dialog->clear_filters();
				rename_dialog->add_filter("*."+move_files[0].extension());
				rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
				rename_dialog->set_current_path(move_files[0]);
				rename_dialog->popup_centered_ratio();
				rename_dialog->set_title(TTR("Pick New Name and Location For:")+" "+move_files[0].get_file());


			} else {
				//just move
				move_dialog->popup_centered_ratio();
			}


		} break;
		case FILE_REMOVE: {

			Vector<String> torem;

			for(int i=0;i<files->get_item_count();i++) {

				String path = files->get_item_metadata(i);
				if (path.ends_with("/") || !files->is_selected(i))
					continue;
				torem.push_back(path);
			}

			if (torem.empty()) {
				EditorNode::get_singleton()->show_warning(TTR("No files selected!"));
				break;
			}

			remove_dialog->show(torem);
			//1) find if used
			//2) warn

		} break;
		case FILE_INFO: {

		} break;

	}
}
Пример #13
0
PyObject* dispatch_streams_(PyObject *self, PyObject *args, int (*fun)(FILE**, FILE **, FILE **, uint64_t)){
  /* Parse argument tuple and open FILE* for input and
   * output. This should raise an exception if something fails
   */  
  PyObject* seq = PySequence_Fast(args, "Expected the argument list");
  long num_sources = 0;
  long num_targets_1 = 0;
  long num_targets_2 = 0;
  uint64_t len = PySequence_Size(args);
  if(seq == NULL || len != 3){
    PyErr_SetString(PyExc_ValueError, "Expected exactly three arguments!");
    Py_DECREF(seq);
    return NULL;
  }

  PyObject* py_sources = PySequence_Fast_GET_ITEM(seq, 0);
  if(!PySequence_Check(py_sources)){
    PyErr_SetString(PyExc_ValueError, "Argument 0 is not a list!");
    Py_DECREF(seq);
    return NULL;
  }
  PyObject* py_targets_1 = PySequence_Fast_GET_ITEM(seq, 1);
  if(!PySequence_Check(py_targets_1)){
    PyErr_SetString(PyExc_ValueError, "Argument 1 is not a list!");
    Py_DECREF(seq);
    return NULL;
  }
  PyObject* py_targets_2 = PySequence_Fast_GET_ITEM(seq, 2);
  if(!PySequence_Check(py_targets_2)){
    PyErr_SetString(PyExc_ValueError, "Argument 2 is not a list!");
    Py_DECREF(seq);
    return NULL;
  }
  num_sources = PySequence_Size(py_sources);
  num_targets_1 = PySequence_Size(py_targets_1);
  num_targets_2 = PySequence_Size(py_targets_2);

  FILE** source_f = malloc(num_sources * sizeof(FILE*));
  FILE** target_f_1 = malloc(num_targets_1 * sizeof(FILE*));
  FILE** target_f_2 = malloc(num_targets_2 * sizeof(FILE*));
  
  bool error = false;
  if(!_update_files(py_sources, source_f, num_sources)){
    error = true;
  }
  if(!_update_files(py_targets_1, target_f_1, num_targets_1)){
    error = true;
  }
  if(!_update_files(py_targets_2, target_f_2, num_targets_2)){
    error = true;
  }

  if(!error){
    // for a child process for the dispatcher
    pid_t childPID = fork();
    if(childPID >= 0){
      if(childPID==0){
        // child
        fun(source_f, target_f_1, target_f_2, num_sources);
        free(target_f_1);
        free(target_f_2);
        free(source_f);
        exit(0);
      }
    }else{
      free(target_f_1);
      free(target_f_2);
      free(source_f);
      PyErr_SetString(PyExc_ValueError, "Unable to create dispatcher process");
      error = true;
    }

  }
  // cleanup 
  Py_DECREF(seq);
  if(error) return NULL;
  Py_RETURN_NONE;
}
Пример #14
0
void FileSystemDock::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_RESIZED: {


			bool new_mode = get_size().height < get_viewport_rect().size.height*3/4;

			if (new_mode != split_mode ) {

				split_mode=new_mode;

				//print_line("SPLIT MODE? "+itos(split_mode));
				if (split_mode) {

					file_list_vb->hide();
					tree->set_custom_minimum_size(Size2(0,0));
					tree->set_v_size_flags(SIZE_EXPAND_FILL);
					button_back->show();
				} else {

					tree->show();
					file_list_vb->show();
					tree->set_custom_minimum_size(Size2(0,200)*EDSCALE);
					tree->set_v_size_flags(SIZE_FILL);
					button_back->hide();
					if (!EditorFileSystem::get_singleton()->is_scanning()) {
						_fs_changed();
					}
				}
			}


		} break;
		case NOTIFICATION_ENTER_TREE: {

			if (initialized)
				return;
			initialized=true;

			EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed");
			EditorResourcePreview::get_singleton()->connect("preview_invalidated",this,"_preview_invalidated");

			button_reload->set_icon( get_icon("Reload","EditorIcons"));
			button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
			//button_instance->set_icon( get_icon("Add","EditorIcons"));
			//button_open->set_icon( get_icon("Folder","EditorIcons"));
			button_back->set_icon( get_icon("Filesystem","EditorIcons"));
			if (display_mode == DISPLAY_THUMBNAILS) {
				button_display_mode->set_icon(get_icon("FileList","EditorIcons"));
			} else {
				button_display_mode->set_icon(get_icon("FileThumbnail","EditorIcons"));
			}
			button_display_mode->connect("pressed",this,"_change_file_display");
			//file_options->set_icon( get_icon("Tools","EditorIcons"));
			files->connect("item_activated",this,"_select_file");
			button_hist_next->connect("pressed",this,"_fw_history");
			button_hist_prev->connect("pressed",this,"_bw_history");
			search_icon->set_texture( get_icon("Zoom","EditorIcons"));

			button_hist_next->set_icon( get_icon("Forward","EditorIcons"));
			button_hist_prev->set_icon( get_icon("Back","EditorIcons"));
			file_options->connect("item_pressed",this,"_file_option");


			button_back->connect("pressed",this,"_go_to_tree",varray(),CONNECT_DEFERRED);
			current_path->connect("text_entered",this,"_go_to_dir");
			_update_tree(); //maybe it finished already

			if (EditorFileSystem::get_singleton()->is_scanning()) {
				_set_scannig_mode();
			}

		} break;
		case NOTIFICATION_PROCESS: {
			if (EditorFileSystem::get_singleton()->is_scanning()) {
				scanning_progress->set_val(EditorFileSystem::get_singleton()->get_scanning_progress()*100);
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {

		} break;
		case NOTIFICATION_DRAG_BEGIN: {

			Dictionary dd = get_viewport()->gui_get_drag_data();
			if (tree->is_visible() && dd.has("type") ) {
				if  ( (String(dd["type"])=="files") || (String(dd["type"])=="files_and_dirs") || (String(dd["type"])=="resource")) {
					tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
				}
				if  ( (String(dd["type"])=="favorite") ) {
					tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
				}
			}


		} break;
		case NOTIFICATION_DRAG_END: {

			tree->set_drop_mode_flags(0);

		} break;
		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {

			int new_mode = int(EditorSettings::get_singleton()->get("filesystem_dock/display_mode"));

			if (new_mode != display_mode) {
				set_display_mode(new_mode);
			} else {
				_update_files(true);
			}
		} break;
	}

}
Пример #15
0
void FileSystemDock::_file_option(int p_option) {

	switch(p_option) {


		case FILE_SHOW_IN_EXPLORER:
		case FILE_OPEN: {
			int idx=-1;
			for(int i=0;i<files->get_item_count();i++) {
				if (files->is_selected(i)) {
					idx=i;
					break;
				}
			}

			if (idx<0)
				return;



			String path = files->get_item_metadata(idx);
			if (p_option == FILE_SHOW_IN_EXPLORER) {
				String dir = Globals::get_singleton()->globalize_path(path);
				dir = dir.substr(0, dir.find_last("/"));
				OS::get_singleton()->shell_open(String("file://")+dir);
				return;
			}

			if (path.ends_with("/")) {
				if (path!="res://") {
					path=path.substr(0,path.length()-1);
				}
				this->path=path;
				_update_files(false);
				current_path->set_text(path);
				_push_to_history();
			} else {

				if (ResourceLoader::get_resource_type(path)=="PackedScene") {

					editor->open_request(path);
				} else {

					editor->load_resource(path);
				}
			}
		} break;
		case FILE_INSTANCE: {

			Vector<String> paths;

			for (int i = 0; i<files->get_item_count(); i++) {
				if (!files->is_selected(i))
					continue;
				String path =files->get_item_metadata(i);
				if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") {
					paths.push_back(path);
				}
			}

			if (!paths.empty()) {
				emit_signal("instance", paths);
			}
		} break;
		case FILE_DEPENDENCIES: {

			int idx = files->get_current();
			if (idx<0 || idx>=files->get_item_count())
				break;
			String path = files->get_item_metadata(idx);
			deps_editor->edit(path);
		} break;
		case FILE_OWNERS: {

			int idx = files->get_current();
			if (idx<0 || idx>=files->get_item_count())
				break;
			String path = files->get_item_metadata(idx);
			owners_editor->show(path);
		} break;
		case FILE_MOVE: {

			move_dirs.clear();;
			move_files.clear();

			for(int i=0;i<files->get_item_count();i++) {

				String path = files->get_item_metadata(i);
				if (!files->is_selected(i))
					continue;

				 if (files->get_item_text(i)=="..") {
					 EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'"));
					 return;
				 }

				if (path.ends_with("/")) {
					move_dirs.push_back(path.substr(0,path.length()-1));
				} else {
					move_files.push_back(path);
				}
			}


			if (move_dirs.empty() && move_files.size()==1) {

				rename_dialog->clear_filters();
				rename_dialog->add_filter("*."+move_files[0].extension());
				rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
				rename_dialog->set_current_path(move_files[0]);
				rename_dialog->popup_centered_ratio();
				rename_dialog->set_title(TTR("Pick New Name and Location For:")+" "+move_files[0].get_file());


			} else {
				//just move
				move_dialog->popup_centered_ratio();
			}


		} break;
		case FILE_REMOVE: {

			Vector<String> torem;

			for(int i=0;i<files->get_item_count();i++) {

				String path = files->get_item_metadata(i);
				if (path.ends_with("/") || !files->is_selected(i))
					continue;
				torem.push_back(path);

			}

			if (torem.empty()) {
				EditorNode::get_singleton()->show_warning(TTR("No files selected!"));
				break;
			}

			remove_dialog->show(torem);
			//1) find if used
			//2) warn

		} break;
		case FILE_INFO: {

		} break;
		case FILE_REIMPORT: {


			Vector<String> reimport;
			for(int i=0;i<files->get_item_count();i++) {

				if (!files->is_selected(i))
					continue;

				String path = files->get_item_metadata(i);
				reimport.push_back(path);
			}

			ERR_FAIL_COND(reimport.size()==0);

			Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(reimport[0]);
			ERR_FAIL_COND(!rimd.is_valid());
			String editor=rimd->get_editor();

			if (editor.begins_with("texture_")) { //compatibility fix for old texture format
				editor="texture";
			}

			Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(editor);
			ERR_FAIL_COND(!rimp.is_valid());

			if (reimport.size()==1) {
				rimp->import_dialog(reimport[0]);
			} else {
				rimp->reimport_multiple_files(reimport);

			}

		} break;
		case FILE_COPY_PATH:

			int idx = files->get_current();
			if (idx<0 || idx>=files->get_item_count())
				break;
			String path = files->get_item_metadata(idx);
			OS::get_singleton()->set_clipboard(path);
	}
}
Пример #16
0
void ScenesDock::_open_pressed(){


	if (tree_mode) {

		TreeItem *sel = tree->get_selected();
		if (!sel) {
			return;
		}
		path = sel->get_metadata(0);
		/*if (path!="res://" && path.ends_with("/")) {
			path=path.substr(0,path.length()-1);
		}*/

		tree_mode=false;

		tree->hide();
		files->show();
		path_hb->show();
		button_favorite->hide();
		button_fav_up->hide();
		button_fav_down->hide();
		button_instance->show();
		button_open->show();
		file_options->show();

		_update_files(false);

		current_path->set_text(path);

		_push_to_history();


	} else {

		int idx=-1;
		for(int i=0;i<files->get_item_count();i++) {
			if (files->is_selected(i)) {
				idx=i;
				break;
			}
		}

		if (idx<0)
			return;



		String path = files->get_item_metadata(idx);

		if (path.ends_with("/")) {
			if (path!="res://") {
				path=path.substr(0,path.length()-1);
			}
			this->path=path;
			_update_files(false);
			current_path->set_text(path);
			_push_to_history();
		} else {

			if (ResourceLoader::get_resource_type(path)=="PackedScene") {

				editor->open_request(path);
			} else {

				editor->load_resource(path);
			}
		}
	}

//	emit_signal("open",path);

}