Re: Gtk3::Application open signal
- From: Torsten Schoenfeld <kaffeetisch gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: Gtk3::Application open signal
- Date: Wed, 2 May 2018 22:46:19 +0200
On 23.04.2018 09:43, Jeffrey Ratcliffe wrote:
I've been failing to make the Gtk3::Application "open" signal work.
Below, I've adapted an example from maxperl's tutorial on github. This
should take filenames as arguments.
Unfortunately the open signal is never emitted.
I think this is due to the @ARGV semantics. In Perl, @ARGV does not
contain the program's name, but Gtk3::Application's run() expects the
C-style argv with the program's name at the beginning. So try to use
the following:
$app->run([$0, @ARGV]);
Also: I wrote a version of your program that more closely resembles the
Python version. Here it is, in case it is helpful:
#!/usr/bin/perl
package MyApp;
BEGIN {
use Glib::Object::Introspection;
Glib::Object::Introspection->setup(
basename => 'Gio',
version => '2.0',
package => 'Glib::IO');
}
use strict;
use warnings;
use Gtk3;
use Glib qw/TRUE FALSE/;
use Glib::Object::Subclass qw/Gtk3::Application/;
sub STARTUP {
my ($app) = @_;
return $app->SUPER::STARTUP ();
}
sub ACTIVATE {
my ($app) = @_;
my $window = Gtk3::ApplicationWindow->new ($app);
$window->set_title ('Welcome to GNOME');
$window->set_default_size (200, 200);
$window->signal_connect ('delete_event' => sub {$app->quit()});
$window->show_all ();
return $app->SUPER::ACTIVATE ();
}
sub OPEN {
my ($app, $files) = @_;
}
sub SHUTDOWN {
my ($app) = @_;
return $app->SUPER::SHUTDOWN ();
}
package main;
my $app = MyApp->new(
application_id => 'app.test',
flags => 'handles-open');
exit $app->run([$0, @ARGV]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]