Help language development. Donate to The Perl Foundation

Gnome::GObject cpan:MARTIMM last updated on 2022-11-17

# Test of event handler api to see if Object and Signal modules are working
# correctly to handle the coercion of arguments and named arguments. Also to
# see if the deprecation messages are ok.

use v6;

use Gnome::Gtk3::Window;
use Gnome::Gtk3::Tooltip;
use Gnome::Gtk3::Main;

use Gnome::N::NativeLib;
use Gnome::N::N-GObject;
use Gnome::N::GlibToRakuTypes;

#use Gnome::N::X;

my Gnome::Gtk3::Main $m .= new;

class Handlers {
  method tooltip-query (
    gint $x, gint $y, gboolean $kb-mode, Gnome::Gtk3::Tooltip() $tooltip,
    Gnome::Gtk3::Window() :_native-object($button),
    --> gboolean
  ) {
    note "\n query-tooltip\nXY: $x, $y";
    note "keyboard mode: $kb-mode";

    note "tooltip available: $tooltip.get-class-name()";
    note "tooltip: ", $button.get-tooltip-text;


  method exit-program ( Gnome::Gtk3::Window() :$_native-object ) {
    note "Destroy event, widget: ", $_native-object.get-name;

my Handlers $h .= new;

with my Gnome::Gtk3::Window $w .= new {
  .register-signal( $h, 'exit-program', 'destroy');
  .register-signal( $h, 'tooltip-query', 'query-tooltip');