Subclassing a Gtk2::TreeStore

A while ago, I asked a question that received the answer below from
Emmanuele. I solved my problem at the time without having to subclass
anything but I'm now trying to override the drag_data_received method ...

Emmanuele Bassi wrote:
On Tue, 2007-06-12 at 13:41 +0100, Dave Howorth wrote:

I've seen mention of 'gtk_tree_drag_dest_row_drop_possible' and the Perl
equivalent 'boolean = $drag_dest->row_drop_possible ($dest_path,
$selection_data)', which looks like it might be related to what I want
to do. But I can't find any description that tells me where it's
implemented, how it's called or how to override it.

you'll have to subclass a tree model implementation (like
Gtk2::TreeStore or Gtk2::ListStore) and override the Gtk2::TreeDragDest
interface method above, in order to control whether the destination row
is a valid drop point.

to know how to subclass and override a GInterface, see the
Glib::Object::Subclass perldoc.

... so I've looked at the perldoc and have tried to subclass the
TreeStore but I haven't found the right incantations to be able to
override the drag_data_received method whilst inheriting all the other
behaviour of the TreeStore.

My [non-working] code looks like this:

    package MyTreeStore;

    use Glib::Object::Subclass
#        interfaces => [ 'Gtk2::TreeDragDest' ],
#        signals => { drag_data_received => \&_drag_data_received },

    use Glib qw(TRUE FALSE);

        my ($self, $dest_path, $selection_data) = @_;

warn "DRAG_data_received($dest_path, $selection_data)\n";

        return SUPER->drag_data_received ($dest_path, $selection_data);

    sub _drag_data_received
        my ($self, $dest_path, $selection_data) = @_;

warn "_drag_data_received($dest_path, $selection_data)\n";

        return TRUE;
        return SUPER->drag_data_received ($dest_path, $selection_data);


Like this, it says "type MyTreeStore does not support property
'Glib::String'" when I invoke MyTreeStore->new. In fact, it says this
even if I comment out both of the DRAG_DATA_RECEIVED and
_drag_data_received functions.

If I uncomment the interfaces line (suggested as needed by the
INTERFACES section of the Glib::Object::Subclass perldoc) it says
"GLib-GObject-WARNING **: cannot add interface type `GtkTreeDragDest' to
type `MyTreeStore', since type `MyTreeStore' already conforms to
interface" as well as the Glib::String problem.

If I uncomment the signals line (suggested by the OVERRIDING BASE
METHODS section) it says "can't override class closure for unknown
signal drag_data_received", which doesn't really surprise me since
drag_data_received is a method rather than a signal.

Any hints gratefully received.

Thanks, Dave

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