Open achieved!!

This commit is contained in:
Sergiotarxz 2024-10-30 02:09:35 +01:00
parent 2f5c5d08a0
commit b817a9bb25
4 changed files with 69 additions and 32 deletions

View File

@ -31,6 +31,32 @@ use Exd;
use JSON; use JSON;
use Net::DBus; 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( Glib::Object::Introspection->setup(
basename => 'Gtk', basename => 'Gtk',
version => '4.0', version => '4.0',
@ -101,8 +127,7 @@ sub _build__gresources_path($self) {
sub start($self) { sub start($self) {
Glib::IO::resources_register( Glib::IO::resources_register(
Glib::IO::Resource::load( $self->_gresources_path ) ); Glib::IO::Resource::load( $self->_gresources_path ) );
my $app = Adw::Application->new( 'me.sergiotarxz.Exd', my $app = Adw::Application->new( 'me.sergiotarxz.Exd', [qw/handles-open/] );
[qw/handles-open/] );
my $bus = Net::DBus->session; my $bus = Net::DBus->session;
my $started = 0; my $started = 0;
eval { eval {
@ -117,19 +142,21 @@ sub start($self) {
$self->_startup; $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( $app->signal_connect(
activate => sub { activate => sub {
$self->_activate(undef); $self->_activate(undef);
} }
); );
my $file = shift @ARGV; $app->run( [ $0, @ARGV ] );
$app->signal_connect(
open => sub($files, $hint) {
warn $file;
$self->_activate($file);
}
);
$app->run();
} }
sub _startup($self) { sub _startup($self) {
@ -143,12 +170,15 @@ sub send_packet_to_daemon( $self, $instance, $packet ) {
} }
sub send_packet_check_if_activated( $self, $instance, $uuid ) { sub send_packet_check_if_activated( $self, $instance, $uuid ) {
$self->send_packet_to_daemon($instance, { $self->send_packet_to_daemon(
$instance,
{
type => 'check-activated', type => 'check-activated',
data => { data => {
uuid => $uuid, uuid => $uuid,
} }
}); }
);
} }
sub _daemon_runner($self) { sub _daemon_runner($self) {
@ -217,15 +247,21 @@ sub _on_check_activated($self, $instance_id, $data) {
if ( !$pid ) { if ( !$pid ) {
while (1) { while (1) {
eval { 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 $ua = Mojo::UserAgent->new;
my $activated = $ua->get($url)->result->json; my $activated = $ua->get($url)->result->json;
if ($activated) { if ($activated) {
say 'Program sucessfully activated, thank you!'; say 'Program sucessfully activated, thank you!';
$self->_exd->activate_license; $self->_exd->activate_license;
$self->send_packet_to_window($instance_id, { $self->send_packet_to_window(
$instance_id,
{
type => 'activated!', type => 'activated!',
}); }
);
exit; exit;
} }
}; };
@ -408,7 +444,6 @@ sub _activate( $self, $exd_file = undef ) {
$self->_run_on_first_time_activation if $self->_first_time; $self->_run_on_first_time_activation if $self->_first_time;
$self->instances->{$instance_id} = $self->instances->{$instance_id} =
Exd::Gui::Instance->new( instance_id => $instance_id, app => $self ); Exd::Gui::Instance->new( instance_id => $instance_id, app => $self );
warn $exd_file;
$self->instances->{$instance_id}->start($exd_file); $self->instances->{$instance_id}->start($exd_file);
} }
@ -435,3 +470,4 @@ sub _save( $self, $instance_id, $exd, $dest_file ) {
} }
1; 1;

View File

@ -74,7 +74,6 @@ sub start( $self, $exd_file ) {
$win->set_show_menubar(1); $win->set_show_menubar(1);
$self->window($win); $self->window($win);
if ( defined $exd_file ) { if ( defined $exd_file ) {
say $exd_file;
$self->_open_file($exd_file); $self->_open_file($exd_file);
} }
my $box_vertical = Gtk4::Box->new( 'vertical', 10 ); my $box_vertical = Gtk4::Box->new( 'vertical', 10 );

View File

@ -87,6 +87,7 @@ modules:
build-commands: build-commands:
- 'cd HiperthermiaSource; perl lib/Exd/Fontconfig.pm' - 'cd HiperthermiaSource; perl lib/Exd/Fontconfig.pm'
- 'cd HiperthermiaSource; perl lib/Exd/FileFormat/Fontconfig.pm' - 'cd HiperthermiaSource; perl lib/Exd/FileFormat/Fontconfig.pm'
- 'cd HiperthermiaSource; perl -Ilib lib/Exd/Gui.pm'
- 'cd HiperthermiaSource; chmod 755 -R _Inline/' - 'cd HiperthermiaSource; chmod 755 -R _Inline/'
- 'cp -vr HiperthermiaSource ${FLATPAK_DEST}/Hiperthermia' - 'cp -vr HiperthermiaSource ${FLATPAK_DEST}/Hiperthermia'
- 'glib-compile-resources --sourcedir=${FLATPAK_DEST}/Hiperthermia ${FLATPAK_DEST}/Hiperthermia/resources.xml' - 'glib-compile-resources --sourcedir=${FLATPAK_DEST}/Hiperthermia ${FLATPAK_DEST}/Hiperthermia/resources.xml'

1
run.pl
View File

@ -3,6 +3,7 @@
use v5.40.0; use v5.40.0;
use strict; use strict;
use warnings; use warnings;
use Carp::Always;
use File::Basename qw/dirname/; use File::Basename qw/dirname/;