当前位置: 首页>>代码示例>>C++>>正文


C++ SelectionData::get_uris方法代码示例

本文整理汇总了C++中gtk::SelectionData::get_uris方法的典型用法代码示例。如果您正苦于以下问题:C++ SelectionData::get_uris方法的具体用法?C++ SelectionData::get_uris怎么用?C++ SelectionData::get_uris使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gtk::SelectionData的用法示例。


在下文中一共展示了SelectionData::get_uris方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_drag_data_received

void AppWindow::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, 
	int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time)
	{
	
#ifdef DEBUG	
	std::cout << "ON_DRAG_DATA_RECEIVED: type: " << selection_data.get_data_type() << std::endl;
	std::cout << "ON_DRAG_DATA_RECEIVED: data: " << selection_data.get_data_as_string() << std::endl;
#endif // DEBUG

	if (selection_data.get_data_type() == "text/uri-list")
		{
		std::list<Glib::ustring> new_filenames = selection_data.get_uris();
			
		const std::list<Glib::ustring>::iterator begin = new_filenames.begin();
		const std::list<Glib::ustring>::iterator end = new_filenames.end();
		std::list<Glib::ustring>::iterator iter = new_filenames.begin();
		int counter = 0;
		
		while( iter != end )
			{
			// we erase the protocol in front of the filename
			if( (*iter).find(':') != std::string::npos )
				(*iter).erase(0, (*iter).find(':')+3);
			
			// unescape the URI
			char * tempfilename = curl_unescape( iter->c_str(), 0);
			(*iter) = tempfilename;
			// curl requires this to be freed like this
			curl_free( tempfilename );

#ifdef DEBUG			
	std::cout << "ON_DRAG_DATA_RECEIVED: URI: " << *iter << std::endl;
#endif // DEBUG

			iter++;
			counter++;
			}
		open_list( new_filenames, counter );
		}
	
	// if we're given plain text, maybe it's still an uri or a filename, we should better check
	// ImageManager.OpenFiles is safe anyway	
	else if( selection_data.get_data_type() == "text/plain" )
		{
			std::string data = selection_data.get_data_as_string();
			data.erase( data.find('\n') ); // erase any newlines, all we can do is one file
			// we erase the protocol in front of the filename
			if( data.find(':') != std::string::npos )
				data.erase(0, data.find(':')+3);
			
			// unescape the URI
			char * tempfilename = curl_unescape( data.c_str(), 0);
			data = tempfilename;
			// curl requires this to be freed like this
			curl_free( tempfilename );
			
			open_new_file( data );
		} 	
	context->drag_finish(true, false, time);
	}
开发者ID:BackupTheBerlios,项目名称:gimmage-svn,代码行数:60,代码来源:AppWindow.cpp

示例2: on_dropped_file

void Gui_MyWindow::on_dropped_file(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time){
    std::vector<std::string> paths;
    DEV_INFOS("D");
    if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8)){
        std::vector<Glib::ustring> file_list;
        file_list = selection_data.get_uris();
        for (auto &str: file_list){
            paths.push_back(str);
        }
        context->drag_finish(true, false, time);
    }
    else
        context->drag_finish(false, false, time);
    m_signal_drag_and_drop.emit(paths);

}
开发者ID:Kionage,项目名称:OpenCFU,代码行数:16,代码来源:Gui_MyWindow.cpp


注:本文中的gtk::SelectionData::get_uris方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。