Re: Drag and drop mysteries



On Wednesday 18 May 2005 09:57, Matthias Kaeppler wrote:

> Okay, I have finished reading and I'm not really satisfied. My program
> still doesn't work.
>      // enable drag and drop
>      m_target_entries.push_back( Gtk::TargetEntry("FILE") );
>      m_target_entries.push_back( Gtk::TargetEntry("DIR") );

>      m_view.drag_source_set(
>  m_target_entries,
>  Gdk::ModifierType( Gdk::BUTTON1_MASK | Gdk::BUTTON2_MASK ),
>  Gdk::DragAction( Gdk::ACTION_COPY | Gdk::ACTION_MOVE | Gdk::ACTION_LINK )
>  );
>      m_view.drag_dest_set(
>  m_target_entries,
>  Gtk::DEST_DEFAULT_ALL,
>  Gdk::DragAction( Gdk::ACTION_COPY | Gdk::ACTION_MOVE | Gdk::ACTION_LINK )
>  );
>
>      m_view.signal_drag_data_get()
>  .connect( sigc::mem_fun( *this, &DirBrowser::on_drag_data_get ) );
>      m_view.signal_drag_data_received()
>  .connect( sigc::mem_fun( *this, &DirBrowser::on_drag_data_received ) );
>
> [...]
>
> ##############################################################
>
> The signal handlers:
>
> ##############################################################
>
> void DirBrowser::on_drag_data_get
> ( const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData&,
> guint, guint )
> {
>      std::cout << "getting data" << std::endl;
> }
>
> void DirBrowser::on_drag_data_received
> ( const Glib::RefPtr<Gdk::DragContext>& context, int, int, const
> Gtk::SelectionData& data, guint, guint time )
> {
>      std::cout << "data received" << std::endl;
> }
>
> ##############################################################
>
> The on_drag_data_received is never called. Something is still wrong here.

It is quite difficult to comment on this as it is not complete.  I assume you 
have a tree model, and I assume you have tree view columns for the tree view.  
Apart from that, what I can see is:

1.  Your targets should be:

  m_target_entries.push_back(Gtk::TargetEntry("STRING"));
  m_target_entries.push_back(Gtk::TargetEntry("text/plain"));

2.  If, as I assume, DirBrowser is derived from Gtk::Widget you have connected 
signals to the virtual protected member functions which also dispatch those 
signals.

Chris

-- 
Summer is y-cumen in, lhude sing, cuccu!
Groweth sed and bloweth med, springeth the wude nu.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]