Open achieved!!
This commit is contained in:
parent
2f5c5d08a0
commit
b817a9bb25
@ -31,6 +31,32 @@ use Exd;
|
||||
use JSON;
|
||||
use Net::DBus;
|
||||
|
||||
use Inline C =>
|
||||
<<'EOF' => LIBS => '', ccflags => '-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -pthread';
|
||||
#include "glib-2.0/gio/gio.h"
|
||||
|
||||
void
|
||||
__get_first_file(SV *class, size_t int_files) {
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
|
||||
GFile *file = (((GFile **)int_files)[0]);
|
||||
char *path = g_file_get_path(file);
|
||||
|
||||
PUSHMARK(SP);
|
||||
EXTEND(SP, 2);
|
||||
PUSHs(class);
|
||||
PUSHs(sv_2mortal(newSVpv(path, 0)));
|
||||
PUTBACK;
|
||||
|
||||
call_pv("_activate", G_DISCARD);
|
||||
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
}
|
||||
EOF
|
||||
|
||||
Glib::Object::Introspection->setup(
|
||||
basename => 'Gtk',
|
||||
version => '4.0',
|
||||
@ -101,8 +127,7 @@ sub _build__gresources_path($self) {
|
||||
sub start($self) {
|
||||
Glib::IO::resources_register(
|
||||
Glib::IO::Resource::load( $self->_gresources_path ) );
|
||||
my $app = Adw::Application->new( 'me.sergiotarxz.Exd',
|
||||
[qw/handles-open/] );
|
||||
my $app = Adw::Application->new( 'me.sergiotarxz.Exd', [qw/handles-open/] );
|
||||
my $bus = Net::DBus->session;
|
||||
my $started = 0;
|
||||
eval {
|
||||
@ -117,19 +142,21 @@ sub start($self) {
|
||||
$self->_startup;
|
||||
}
|
||||
);
|
||||
my $file = Glib::IO::File::new_for_path('hola');
|
||||
print Data::Dumper::Dumper $file;
|
||||
$app->signal_connect(
|
||||
open => sub( $app, $files, $n_files, $hint ) {
|
||||
if ( $n_files > 0 ) {
|
||||
$self->__get_first_file($files);
|
||||
}
|
||||
}
|
||||
);
|
||||
$app->signal_connect(
|
||||
activate => sub {
|
||||
$self->_activate(undef);
|
||||
}
|
||||
);
|
||||
my $file = shift @ARGV;
|
||||
$app->signal_connect(
|
||||
open => sub($files, $hint) {
|
||||
warn $file;
|
||||
$self->_activate($file);
|
||||
}
|
||||
);
|
||||
$app->run();
|
||||
$app->run( [ $0, @ARGV ] );
|
||||
}
|
||||
|
||||
sub _startup($self) {
|
||||
@ -142,13 +169,16 @@ sub send_packet_to_daemon( $self, $instance, $packet ) {
|
||||
$self->_write_to_script->flush;
|
||||
}
|
||||
|
||||
sub send_packet_check_if_activated( $self, $instance, $uuid) {
|
||||
$self->send_packet_to_daemon($instance, {
|
||||
sub send_packet_check_if_activated( $self, $instance, $uuid ) {
|
||||
$self->send_packet_to_daemon(
|
||||
$instance,
|
||||
{
|
||||
type => 'check-activated',
|
||||
data => {
|
||||
uuid => $uuid,
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
sub _daemon_runner($self) {
|
||||
@ -196,11 +226,11 @@ sub _daemon_runner($self) {
|
||||
if ( $packet->{type} eq 'font-scan' ) {
|
||||
next;
|
||||
}
|
||||
if ( $packet->{type} eq 'check-activated') {
|
||||
$self->_on_check_activated($instance_id, $packet->{data});
|
||||
if ( $packet->{type} eq 'check-activated' ) {
|
||||
$self->_on_check_activated( $instance_id, $packet->{data} );
|
||||
next;
|
||||
}
|
||||
warn 'Packet not recognized: '. Data::Dumper::Dumper $packet;
|
||||
warn 'Packet not recognized: ' . Data::Dumper::Dumper $packet;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
@ -212,20 +242,26 @@ sub _build__exd($self) {
|
||||
return Exd->new;
|
||||
}
|
||||
|
||||
sub _on_check_activated($self, $instance_id, $data) {
|
||||
sub _on_check_activated( $self, $instance_id, $data ) {
|
||||
my $pid = fork;
|
||||
if (!$pid) {
|
||||
if ( !$pid ) {
|
||||
while (1) {
|
||||
eval {
|
||||
my $url = $self->_exd->licenser_server.'/get_paid/'.$self->_exd->uuid;
|
||||
my $url =
|
||||
$self->_exd->licenser_server
|
||||
. '/get_paid/'
|
||||
. $self->_exd->uuid;
|
||||
my $ua = Mojo::UserAgent->new;
|
||||
my $activated = $ua->get($url)->result->json;
|
||||
if ($activated) {
|
||||
say 'Program sucessfully activated, thank you!';
|
||||
$self->_exd->activate_license;
|
||||
$self->send_packet_to_window($instance_id, {
|
||||
$self->send_packet_to_window(
|
||||
$instance_id,
|
||||
{
|
||||
type => 'activated!',
|
||||
});
|
||||
}
|
||||
);
|
||||
exit;
|
||||
}
|
||||
};
|
||||
@ -233,7 +269,7 @@ sub _on_check_activated($self, $instance_id, $data) {
|
||||
warn $@;
|
||||
}
|
||||
sleep 5;
|
||||
if (!kill 0, $self->parent_pid) {
|
||||
if ( !kill 0, $self->parent_pid ) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -408,7 +444,6 @@ sub _activate( $self, $exd_file = undef ) {
|
||||
$self->_run_on_first_time_activation if $self->_first_time;
|
||||
$self->instances->{$instance_id} =
|
||||
Exd::Gui::Instance->new( instance_id => $instance_id, app => $self );
|
||||
warn $exd_file;
|
||||
$self->instances->{$instance_id}->start($exd_file);
|
||||
}
|
||||
|
||||
@ -435,3 +470,4 @@ sub _save( $self, $instance_id, $exd, $dest_file ) {
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
@ -74,7 +74,6 @@ sub start( $self, $exd_file ) {
|
||||
$win->set_show_menubar(1);
|
||||
$self->window($win);
|
||||
if ( defined $exd_file ) {
|
||||
say $exd_file;
|
||||
$self->_open_file($exd_file);
|
||||
}
|
||||
my $box_vertical = Gtk4::Box->new( 'vertical', 10 );
|
||||
|
@ -87,6 +87,7 @@ modules:
|
||||
build-commands:
|
||||
- 'cd HiperthermiaSource; perl lib/Exd/Fontconfig.pm'
|
||||
- 'cd HiperthermiaSource; perl lib/Exd/FileFormat/Fontconfig.pm'
|
||||
- 'cd HiperthermiaSource; perl -Ilib lib/Exd/Gui.pm'
|
||||
- 'cd HiperthermiaSource; chmod 755 -R _Inline/'
|
||||
- 'cp -vr HiperthermiaSource ${FLATPAK_DEST}/Hiperthermia'
|
||||
- 'glib-compile-resources --sourcedir=${FLATPAK_DEST}/Hiperthermia ${FLATPAK_DEST}/Hiperthermia/resources.xml'
|
||||
|
Loading…
Reference in New Issue
Block a user