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


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

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


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

示例1: dropFunction

void ClipSelector::dropFunction( const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
                       const Gtk::SelectionData& selection_data, guint info, guint time)
{
  // drop target is of string type, load that sample
  
  int block = y / 18;
  cout << "DROP on block " << block << endl;
  
  const int length = selection_data.get_length();
  if( (length >= 0) ) // && (selection_data.get_format() == 8)
  {
    std::string filename = selection_data.get_data_as_string();
    std::cout << "Received " << filename << " in ClipSelector, loading now! " << std::endl;
    
    // audioFileLoader informs engine & updates StateStore
    int ret = top->offlineWorker->loadAudioBuffer( ID, block, filename );
    
    if ( ret == 0 ) // successful load, so store filename in vector
    {
      stateStore->addAudioBufferName(ID, Glib::path_get_basename(filename) );
    }
  }

  context->drag_finish(false, false, time);
}
开发者ID:harryhaaren,项目名称:oldLuppp2012,代码行数:25,代码来源:g_clipselector.cpp

示例2: dockable

void
Dockable::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
	if (selection_data.get_length() >= 0
	 && selection_data.get_format() == 8
	 && selection_data.get_data_type() == "SYNFIG_DOCK")
	{
		Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));

		DockBook *parent = dynamic_cast<DockBook*>(get_parent());
		DockBook *dockable_parent = dynamic_cast<DockBook*>(dockable.get_parent());

		if (parent)
		{
			if (dockable_parent != parent)
				 parent->add(dockable,parent->page_num(*this));
			else
				parent->reorder_child(dockable,parent->page_num(*this));
			dockable.present();
			context->drag_finish(true, false, time);
			App::dock_manager->update_window_titles();
			return;
		}
	}

	context->drag_finish(false, false, time);
}
开发者ID:d-j-a-y,项目名称:synfig,代码行数:27,代码来源:dockable.cpp

示例3: on_label_drop_drag_data_received

void TestDnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{ 
  if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
  {
    std::cout << "Received \"" << selection_data.get_data_as_string() << "\" in label " << std::endl;
  }

  context->drag_finish(false, false, time);
}
开发者ID:Limsik,项目名称:e17,代码行数:9,代码来源:TestDnDWindow.cpp

示例4: dockable

void
DockDialog::drop_on_append(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
	if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
	{
		Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
		append_dock_book()->add(dockable);
		context->drag_finish(true, false, time);
		return;
	}

	context->drag_finish(false, false, time);
}
开发者ID:sergiorm,项目名称:synfig_jcome,代码行数:13,代码来源:dockdialog.cpp

示例5: success

void
Toolbox::on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int /*x*/, int /*y*/, const Gtk::SelectionData& selection_data_, guint /*info*/, guint time)
{
	// We will make this true once we have a solid drop
	bool success(false);

	if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8))
	{
		synfig::String selection_data((gchar *)(selection_data_.get_data()));

		// For some reason, GTK hands us a list of URLs separated
		// by not only Carriage-Returns, but also Line-Feeds.
		// Line-Feeds will mess us up. Remove all the line-feeds.
		while(selection_data.find_first_of('\r')!=synfig::String::npos)
			selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r'));

		std::stringstream stream(selection_data);

		while(stream)
		{
			synfig::String filename,URI;
			getline(stream,filename);

			// If we don't have a filename, move on.
			if(filename.empty())
				continue;

			// Make sure this URL is of the "file://" type.
			URI=String(filename.begin(),filename.begin()+sizeof("file://")-1);
			if(URI!="file://")
			{
				synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str());
				continue;
			}

			// Strip the "file://" part from the filename
			filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());

			synfig::info("Attempting to open "+filename);
			if(App::open(filename))
				success=true;
			else
				synfig::error("Drop failed: Unable to open "+filename);
		}
	}
	else
		synfig::error("Drop failed: bad selection data");

	// Finish the drag
	context->drag_finish(success, false, time);
}
开发者ID:aaronaskew,项目名称:synfig,代码行数:51,代码来源:toolbox.cpp

示例6: dockable

void
DockBook::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
	if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
	{
		Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
		if(dockable.get_parent()!=this)
			add(dockable);
		dockable.present();
		context->drag_finish(true, false, time);
		return;
	}

	context->drag_finish(false, false, time);
}
开发者ID:blackwarthog,项目名称:synfig,代码行数:15,代码来源:dockbook.cpp

示例7: 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

示例8: onScriptDragNDropDataReceived

void ScriptSlots::onScriptDragNDropDataReceived(
    const Glib::RefPtr<Gdk::DragContext>& context, int, int,
    const Gtk::SelectionData& selection_data, guint, guint time)
{
    gig::Script* script = *((gig::Script**) selection_data.get_data());
    if (script && selection_data.get_length() == sizeof(gig::Script*)) {
        std::cout << "Drop received script \"" << script->Name << "\"" << std::endl;
        m_instrument->AddScriptSlot(script);
        appendNewSlot(script);
        // drop success
        context->drop_reply(true, time);
    } else {
        // drop failed
        context->drop_reply(false, time);
    }
}
开发者ID:svn2github,项目名称:linuxsampler,代码行数:16,代码来源:scriptslots.cpp

示例9: file_drag_data_received

void window_main::file_drag_data_received(
	const Glib::RefPtr<Gdk::DragContext> & context, //info about drag (available on source and dest)
	const int x,                                    //x-coord of drop
	const int y,                                    //y-coord of drop
	const Gtk::SelectionData & selection_data,      //data dropped
	const guint info,                               //type of info dropped
	const guint time)                               //time stamp of when drop happened
{
//DEBUG, dragging file on to window does not work on windows, not sure why

	if(selection_data.get_length() >= 0 && selection_data.get_format() == 8){
		//this will look like file:///home/foo/bar.txt
		std::string URI = selection_data.get_data_as_string();
		if(URI.size() > 7){
			std::string path = URI.substr(7);
			//get rid of newline on the end
			boost::trim(path);
			p2p::load_file(path);
		}
	}

	//tell other end we're done with drag and drop so it can free resources
	context->drag_finish(true, true, time);
}
开发者ID:sbunce,项目名称:p2p,代码行数:24,代码来源:window_main.cpp


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