Re: Drag and drop from Gtk::Tree to Gtk::CList



I had this problem as well. I hacked arround it by always setting the
row height when creating the list and subtracting by this known when
figuring out the drop row/col. i.e.

(clist creation)

    $list->set_row_height(18);

....

(drag received)

  $y -= 18;
  if ($y < 18) {
    $y = 0;
  }

  ($row, my $col) = $list->get_selection_info($x, $y);

Can't remember exactly why I did the < 18 check but I recall lots of
problems when dropping on the first row or headers.

This is an awful hack. It would be nice to find a better way to do
this or find were the bug is in Gtk or possibly Gtk-Perl.

Gavin

Johan Ankarloo <johan ankarloo volvo com> writes:

Hi again.

I thank you for the info. It wasn't the return value thou but instead
the $data->set statement that made it work. Apparently you have to set
some data before you can get some data. (Makes sense doesn't it?)


I found another problem along the line.

When the "drag_data_received" gets called i need to find out which row
and column the user released the button. To do this i tried to do the
following

Code:
-------------------------------------------------------------------
$clist->signal_connect('drag_data_received',sub{
      my ($w, $context, $data, $info, $time) = @_;
      my ($x, $y) = $w->get_pointer();
      my ($row, $column) = $w->get_selection_info( $x, $y );
 
      print "drag_data_received x:$x y:$y row:$row column:$column\n";
                             });
-------------------------------------------------------------------

but i always gets actually row+1, and if i drops it at the last row i
get uninitialized value.

Anybody who knows how to get which row and column the mouse was over
when the drag and drop ended?

Regards 
Johan

On Mon, 2002-03-18 at 20:44, Gavin Jefferies wrote:

Hi Johan, I think you have to set the data and return true in the
'drag_data_get' in order to get the 'drag_data_received' to notice the
drop. At least this is the only difference you have to my program
where I have this working.

Try 

$tree->signal_connect('drag_data_get',sub{
  my ($w,$context, $data, $info, $time) = @_;
  print "drag_data_get\n";
        $data->set($data->target, 888, 666);
        return 1;
                         });

Gavin

--
Gavin Jefferies. gavin at emptytree.com. http://emptytree.com/



Johan Ankarloo <johan ankarloo volvo com> writes:

Hi

I am trying to get drag and drop to work between a Gtk:Tree and a
Gtk::CList.

The problem that i have is that i can get the "drag_data_get" signal to
work but not the "drag_data_received" signal and it is that signal that
should trigger the actual change in the clist.

Code:
-------------------------------------------------------------------
$tree->drag_source_set('button1_mask', ['copy', 'move'],
{target=>'STRING', flags=>0, info=>0});

$tree->signal_connect('drag_data_get',sub{
  my ($w,$context, $data, $info, $time) = @_;
  print "drag_data_get\n";
                         });
$clist->drag_dest_set('all', ['copy', 'move'],{'target' => "STRING",
'flags' => 0, 'info' => 0});
$clist->signal_connect('drag_data_received',sub{
  my ($w, $context, $data, $info, $time) = @_;

  print "drag_data_received\n";
                         },$name);
-------------------------------------------------------------------


Any idea someone?

Regards

Johan Ankarloo

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list



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