Re: Reorderable && DnD



On Mon, 2004-08-30 at 08:47, muppet wrote:
On Aug 30, 2004, at 1:37 AM, Kevin C. Krinke wrote:

So far I can only get the list to accept DnD events or be reorderable. 
 It seems that setting the callbacks for DnD events trumps the 
reorderablity of the list. Can anyone confirm this?

i seem to recall hearing this same explanation from one of the gtk+ 
gurus.  can't remember now if it was on gtk-devel-list or in #gtk+.  it 
makes sense, of course, as the reorderable behavior is implemented with 
DnD callbacks.  ;-)

if you chain carefully, you may be able to get it to work.  i have 
never tried, so YMMV.

Hmm. Well I suppose the question is now become how to chain the
callbacks... or wait... I've got a better idea to solve the problem.

Instead of messing with the TreeView and it's reorderability, I've
discovered the simple solution of making the VBox containing the
TreeView DnD aware and leaving the TreeView set reorderable.

I don't know how well this will work in larger situations but for my
purposes this does the trick.

Here's how I thought it "should" work (based on RTFM en eg's):

perl -e '
use Gtk2 -init;
use Gtk2::SimpleList;
$d = new Gtk2::Dialog ( "test", undef, [], "gtk-ok" => "none" );
$sl = new Gtk2::SimpleList ( "test" => "text" );
$d->vbox->add( $sl );
@{ $sl->{data} } = ( ["test1"], ["test2"], ["test3"] );
$sl->drag_dest_set( [ "drop", "motion" ], [ "copy", "move" ],
                    ( { "target" => "STRING",
                        "flags" => [],
                        "info" => TARGET_STRING },
                      { "target" => "text/plain",
                        "flags" => [],
                        "info" => TARGET_STRING }
                    ) );
$d->vbox->signal_connect(
  "drag_data_received" =>
  sub { ( $w, $drag_context, $x, $y, $data, $info, $time ) = ( @_ );
        print STDOUT ref( $w ) . ": " . $data->data() . "\n";
        return( 0 );
      }
);
$sl->set_reorderable( 1 );
$d->show_all();
$d->run();
$d->destroy();
exit();
'

Here's how I am now accomplishing the goal of a Reorderable && DnD aware
SimpleList:

perl -e '
use Gtk2 -init;
use Gtk2::SimpleList;
$d = new Gtk2::Dialog ( "test", undef, [], "gtk-ok" => "none" );
$sl = new Gtk2::SimpleList ( "test" => "text" );
$d->vbox->add( $sl );
$sl->set_reorderable( 1 );
@{ $sl->{data} } = ( ["test1"], ["test2"], ["test3"] );
$sl->drag_dest_set( [ "drop", "motion" ], [ "copy", "move" ],
                    ( { "target" => "STRING",
                        "flags" => [],
                        "info" => TARGET_STRING },
                      { "target" => "text/plain",
                        "flags" => [],
                        "info" => TARGET_STRING }
                    ) );
$sl->signal_connect(
  "drag_data_received" =>
  sub { ( $w, $drag_context, $x, $y, $data, $info, $time ) = ( @_ );
        print STDOUT ref( $w ) . ": " . $data->data() . "\n";
        return( 0 );
      }
);
$d->show_all();
$d->run();
$d->destroy();
exit();
'

-- 
Kevin C. Krinke <kckrinke opendoorsoftware com>
Open Door Software Inc.




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