本文整理汇总了C++中gtk::SelectionData类的典型用法代码示例。如果您正苦于以下问题:C++ SelectionData类的具体用法?C++ SelectionData怎么用?C++ SelectionData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SelectionData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: drag_data_get_vfunc
bool NatnTreeMdl::drag_data_get_vfunc(const TreeModel::Path& path, Gtk::SelectionData& selection_data) const
{
bool res = false;
// Set selection. This will evolve DnD process
int row_index = path[0];
string data = iNodesInfo.at(row_index);
selection_data.set_text(data);
res = true;
return res;
}
开发者ID:yborisovstc,项目名称:fap2-studio-gtk,代码行数:10,代码来源:navi.cpp
示例17: drag_data_received_vfunc
//------------------------------------------------------------------------------
bool ListModelWrapper::drag_data_received_vfunc(const Gtk::TreeModel::Path& dest,
const Gtk::SelectionData& selection_data) {
bool ret = false;
// Currently this works for linear lists
try {
(*_tm)->reorder(bec::NodeId((const char*)selection_data.get_data()), dest.front());
ret = true;
} catch (const std::logic_error& e) {
}
return ret;
}
开发者ID:pk-codebox-evo,项目名称:mysql-workbench,代码行数:12,代码来源:listmodel_wrapper.cpp
示例18: on_drag_data_get
//
// D&Dで受信側がデータ送信を要求してきた
//
void TabLabel::on_drag_data_get( const Glib::RefPtr<Gdk::DragContext>& context,
Gtk::SelectionData& selection_data, guint info, guint time )
{
#ifdef _DEBUG
std::cout << "TabLabel::on_drag_data_get target = " << selection_data.get_target()
<< " " << m_fulltext << std::endl;;
#endif
Gtk::EventBox::on_drag_data_get( context, selection_data, info, time );
m_sig_tab_drag_data_get( selection_data );
}
开发者ID:shinnya,项目名称:jd-mirror,代码行数:15,代码来源:tablabel.cpp
示例19: onDragDataGet
void ApplicationList::onDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context,
Gtk::SelectionData& data, guint info, guint time)
{
Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_TreeView.get_selection();
Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
if(iter && ((*iter)[m_appColumns.m_col_type] == MODULE))
{
Glib::ustring name = (*iter)[m_appColumns.m_col_name];
data.set(data.get_target(), MODULE,
(const guchar*)name.c_str(), name.size()+1);
}
else if(iter && ((*iter)[m_appColumns.m_col_type] == RESOURCE))
{
Glib::ustring name = (*iter)[m_appColumns.m_col_name];
data.set(data.get_target(), RESOURCE,
(const guchar*)name.c_str(), name.size()+1);
}
else if(iter && ((*iter)[m_appColumns.m_col_type] == APPLICATION))
{
Glib::ustring name = (*iter)[m_appColumns.m_col_name];
data.set(data.get_target(), APPLICATION,
(const guchar*)name.c_str(), name.size()+1);
}
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:25,代码来源:application_list.cpp
示例20: 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
注:本文中的gtk::SelectionData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论