Re: Gtk3::TargetEntry



On 06.12.2017 18:15, Jeff wrote:
In migrating my Gtk2 application to Gtk3, I am struggling to find the
new name for the Gtk3::TargetFlags

This doesn't work:

     my $target_entry = Gtk3::TargetEntry->new(
         'Glib::Scalar',    # some string representing the drag type
         Gtk3::TARGET_SAME_WIDGET,     # Gtk3::TargetFlags
         $ID_PAGE,          # some app-defined integer identifier
     );

GtkTargetFlags is represented as a normal flags class, so you should be able to simply use, e.g., qw/same-widget/. However, for some reason, the C-level constructor underlying Gtk3::TargetEntry->new has the flags argument typed simply as an unsigned integer, not as GtkTargetFlags. Hence, all the conversion magic is never invoked. I see three options for you:

* Use the recently introduced Glib::Object::Introspection->convert_sv_to_flags:

        Glib::Object::Introspection->convert_sv_to_flags (
                "Gtk3::TargetFlags", qw/same-widget/)

* Use the undocumented implementation detail that Glib::Flags objects dereference to the underlying integer:

        ${Gtk3::TargetFlags->new (qw/same-widget/)}

* Add an override for Gtk3::TargetEntry->new to Gtk3.pm that takes care of this automatically and submit a patch. The override for Gtk3::Widget->set_events might serve as an example.

-Torsten


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