本文整理汇总了C++中gtk::SelectionData::get_data方法的典型用法代码示例。如果您正苦于以下问题:C++ SelectionData::get_data方法的具体用法?C++ SelectionData::get_data怎么用?C++ SelectionData::get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk::SelectionData
的用法示例。
在下文中一共展示了SelectionData::get_data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
}