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


C++ gtk::SelectionData类代码示例

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


在下文中一共展示了SelectionData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: on_routine_drop

//------------------------------------------------------------------------------
void DbMySQLRoutineGroupEditor::on_routine_drop(const Glib::RefPtr<Gdk::DragContext>& context
                                               ,int x, int y
                                               , const Gtk::SelectionData& selection_data
                                               , guint info, guint time)
{
  bool dnd_status = false;
  
  if ( selection_data.get_target() == WB_DBOBJECT_DRAG_TYPE)
  {
    std::list<db_DatabaseObjectRef> objects;

    const std::string selection = selection_data.get_data_as_string();

    objects= bec::CatalogHelper::dragdata_to_dbobject_list(_be->get_catalog(), selection);
    
    for (std::list<db_DatabaseObjectRef>::const_iterator obj= objects.begin(); 
         obj != objects.end(); ++obj)
    {
      if (obj->is_instance<db_mysql_Routine>())
      {
        db_mysql_RoutineRef routine = db_mysql_RoutineRef::cast_from(*obj);
        if ( routine.is_valid() )
          _be->append_routine_with_id(routine.id());
      }
    }

    recreate_model_from_string_list(_routines_model, _be->get_routines_names());

    dnd_status = true;
  }
  context->drag_finish(dnd_status, false, time);
}
开发者ID:abibell,项目名称:mysql-workbench,代码行数:33,代码来源:mysql_routinegroup_editor_fe.cpp

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

示例4: on_button_drag_data_get

void DnDWindow::on_button_drag_data_get(
        const Glib::RefPtr<Gdk::DragContext>&,
        Gtk::SelectionData& selection_data, guint, guint)
{
  selection_data.set(selection_data.get_target(), 8 /* 8 bits format */,
          (const guchar*)"I'm Data!",
          9 /* the length of I'm Data! in bytes */);
}
开发者ID:andres-arana,项目名称:degree-7542-tp,代码行数:8,代码来源:dndwindow.cpp

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

示例6: onFileDropped

void GtkMainWindow::onFileDropped(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time)
{
	string str = selection_data.get_data_as_string();
	string str2 = Glib::filename_from_uri(str);
	string str3 = rtrim(str2);
	bool want_uncertain = true;
	string content_type = Gio::content_type_guess(str3, selection_data.get_data_as_string(), want_uncertain);
	if(content_type == "application/x-bittorrent")
	{
		shared_ptr<Torrent> t = m_core->addTorrent(str3);
		m_treeview->addCell(t);
	}
}
开发者ID:colatkinson,项目名称:gTorrent,代码行数:13,代码来源:GtkMainWindow.cpp

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

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

示例9: srcSelect

void ImportClassesBox::ClassesTreeView::on_drag_data_get(
    const Glib::RefPtr<Gdk::DragContext>& ,
    Gtk::SelectionData& selection_data, guint, guint)
{
    Glib::RefPtr<Gtk::TreeSelection> srcSelect(get_selection());
    if (srcSelect) {
	Gtk::TreeModel::iterator iter = srcSelect->get_selected();
	if (iter) {
	    Gtk::TreeModel::Row row = *iter;
	    std::string className = row.get_value(mColumns.m_col_name);
	    selection_data.set(selection_data.get_target(), className);
	}
    }
}
开发者ID:GG31,项目名称:vle,代码行数:14,代码来源:ImportClassesBox.cpp

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

示例11: on_drag_data_get

void CIconView::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, 
	Gtk::SelectionData& selection_data, guint info, guint time)
	{
	std::list<Gtk::TreeModel::Path> selected_items = ThumbsIconView.get_selected_items();
	
	std::list<Gtk::TreeModel::Path>::iterator path_list_iter = selected_items.begin();
	std::list<Gtk::TreeModel::Path>::iterator path_list_end = selected_items.end();
	
	
	//std::list<Glib::ustring>* filenames = new std::list<Glib::ustring>;
	
	std::list<Glib::ustring> filenames;
	while( path_list_iter != path_list_end )
		{
		Gtk::TreeModel::iterator model_iter = refImageList->get_iter( *path_list_iter );
		Gtk::TreeModel::Row row = *model_iter;
		
		std::cout << row[ ImageListColumns.filenames_column ] << std::endl;
		
		filenames.push_back( row[ ImageListColumns.filenames_column] );

		path_list_iter++;
		}
	
	selection_data.set_uris( filenames );
	}
开发者ID:BackupTheBerlios,项目名称:gimmage-svn,代码行数:26,代码来源:IconView.cpp

示例12: onFileDropped

/**
* Does something when a file is dropped onto the window.
*/
void GtkMainWindow::onFileDropped(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time)
{
	std::string sel_data = selection_data.get_data_as_string();
	if(m_core->isLink(sel_data))
	{
		std::shared_ptr<gt::Torrent> t = m_core->addTorrent(sel_data);
		if (t)//Checks if t is not null
			m_treeview->addCell(t);
	}
	else
	{
		std::string fn = Glib::filename_from_uri(sel_data);
		boost::algorithm::trim(fn); //d-don't worry guys! w-we only need boo-boost for libtorrent! th-that's all!
		bool want_uncertain = true;
		std::string content_type = Gio::content_type_guess(fn, sel_data, want_uncertain);
		if(content_type == "application/x-bittorrent" || content_type == ".torrent")
		{
			std::shared_ptr<gt::Torrent> t = m_core->addTorrent(fn);
			if (t)//Checks if t is not null
			{
				t->onStateChanged = std::bind(&GtkMainWindow::torrentStateChangedCallback, this, std::placeholders::_1, std::placeholders::_2);
				m_treeview->addCell(t);
			}
			//TODO Add error dialogue if torrent add is unsuccessful
		}
	}
}
开发者ID:Quaker762,项目名称:gtorrent-gtk,代码行数:30,代码来源:GtkMainWindow.cpp

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

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

示例15: tmp

void
Dockable::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint /*info*/, guint /*time*/)
{
	Dockable* tmp(this);
	dnd_success_=true;

	selection_data.set(8, reinterpret_cast<const guchar*>(&tmp), sizeof(Dockable**));
}
开发者ID:d-j-a-y,项目名称:synfig,代码行数:8,代码来源:dockable.cpp


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