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); }
//------------------------------------------------------------------------------ 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; }
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); }
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); }
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); }
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); } }