linux assetsDir support linux style installs #180
|
@ -1,5 +1,14 @@
|
|||
#include "my_application.h"
|
||||
|
||||
// Added to check for location of assets folder
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// To get the home dir of the user
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
|
@ -12,6 +21,18 @@ struct _MyApplication {
|
|||
char** dart_entrypoint_arguments;
|
||||
};
|
||||
|
||||
// Redefining from flutter/engine::shell/platform/linux/fl_dart_project.cc
|
||||
// struct def required here to enable compiler to allow access to variables
|
||||
struct _FlDartProject {
|
||||
GObject parent_instance;
|
||||
|
||||
gboolean enable_mirrors;
|
||||
gchar* aot_library_path;
|
||||
gchar* assets_path;
|
||||
gchar* icu_data_path;
|
||||
gchar** dart_entrypoint_args;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
// Implements GApplication::activate.
|
||||
|
@ -53,6 +74,29 @@ static void my_application_activate(GApplication* application) {
|
|||
gtk_widget_show(GTK_WIDGET(window));
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
|
||||
// Check if assets folder is relative to the executable or if we can use a system copy
|
||||
struct stat info;
|
||||
if (stat(fl_dart_project_get_assets_path(project), &info ) != 0 ) {
|
||||
if( stat("/usr/share/cwtch/data/flutter_assets", &info ) != 0 ) {
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
const char *homedir = pw->pw_dir;
|
||||
// /home/$USER/.local/share/cwtch/data/flutter_assets
|
||||
project->assets_path = g_build_filename(homedir, ".local", "share", "cwtch", "data", "flutter_assets", nullptr);
|
||||
// /home/$USER/bin/cwtch/lib
|
||||
project->aot_library_path = g_build_filename(homedir, "bin", "cwtch", "lib", nullptr);
|
||||
// /home/$USER/.local/share/cwtch/data
|
||||
project->icu_data_path = g_build_filename(homedir, ".local", "share", "cwtch", "data", nullptr);
|
||||
} else {
|
||||
// /usr/share/cwtch/data/flutter_assets
|
||||
project->assets_path = g_build_filename("usr", "share", "cwtch", "data", "flutter_assets", nullptr);
|
||||
// /usr/lib/cwtch
|
||||
|
||||
project->aot_library_path = g_build_filename("usr", "lib", "cwtch", nullptr);
|
||||
// /usr/share/cwtch/data
|
||||
project->icu_data_path = g_build_filename("usr", "share", "cwtch", "data", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||
|
||||
FlView* view = fl_view_new(project);
|
||||
|
|
Loading…
Reference in New Issue
why not /usr/bin/cwtch?
cus this is where
libapp.so libflutter_linux_gtk.so libwindow_size_plugin.so
go? and I don't want to install them to just /usr/lib cus libapp.so and all are too generic so I'll put them in a cwtch sub dir... and cus I dont think libs ever get installed under /usr/bin/cwtch?