NAME

Intertangle::API::Gtk3::Helper - Collection of helper utilities for Gtk3 and Glib

VERSION

version 0.007

FUNCTIONS

_setup_disable_xinput2

fun _setup_disable_xinput2() {

Checks to see if running under X11 and that the environment variable $ENV{INTERTANGLE_API_GTK3_USE_XINPUT2} is not set to a true value. If so, disables the XInput 2 extension.

This is necessary because GDK has an issue with some forms of mouse scrolling under XInput 2. XInput 2 provides support for smooth scrolling, but sometimes it sends emulated smooth scroll events that have zero for their deltas when dealing with mice that do not support smooth scrolling natively (i.e., they use buttons 4 and 5). This prevents widgets from responding.

This is similar to $ENV{GDK_CORE_DEVICE_EVENTS} as documented here https://developer.gnome.org/gtk3/stable/gtk-x11.html.

_setup_gtk

fun _setup_gtk()

Setup Gtk3.

First, this calls _setup_disable_xinput2().

Then this initialises Gtk3.

CLASS METHODS

gval

classmethod gval( $glib_typename, $value )

Given a Glib type name, wraps a Perl value in an object that can be passed to other Glib-based functions.

  • $glib_typename

    The name of a type under the Glib:: namespace. For example, passing in "int" gives a wrapper to the gint C type which is known as Glib::Int in Perl.

  • $value

    The value to put inside the wrapper.

See Glib::Object::Introspection::GValueWrapper in Glib::Object::Introspection for more information.

genum

classmethod genum( $package, $sv )

Returns an enumeration value of type $package which contains the matching enum value given in $sv as a string.

  • $package

    The package name of a Glib enumeration.

  • $sv

    A string representation of the enumeration value.

For example, for GtkPackType enum, we set $package to 'Gtk3::PackType' and $sv to 'GTK_PACK_START'. This can be passed on to other Glib::Object::Introspection methods.

callback

classmethod callback( $invocant, $callback_name, @args )

A helper function to redirect to other callback functions. Given an $invocant and the name of the callback function, $callback_name, which is defined in the package of $invocant, calls that function with arguments ( @args, $invocant ).

For example, if we are trying to call the callback function Target::Package::on_event_cb and $target is a blessed reference of type Target::Package, then by using

Intertangle::API::Gtk3::Helper->callback( $target, on_event_cb => @rest_of_args );

effectively calls

Target::Package::on_event_cb( @rest_of_args, $target );

AUTHOR

Zakariyya Mughal <zmughal@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Zakariyya Mughal.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.