WIP Flatpak
All checks were successful
FeedbackD-Configuration/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-09-11 20:01:39 -04:00
parent a0db4f0a23
commit 8921bc2cbd
4 changed files with 99 additions and 23 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
build/
build-flatpak/
.flatpak-builder/

2
Jenkinsfile vendored
View File

@ -5,7 +5,7 @@ pipeline {
stages {
stage('Prepare Build') {
steps {
sh 'mkdir build; cd build; cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILEr=clang++ ..'
sh 'mkdir build; cd build; cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..'
}
}
stage('Build') {

View File

@ -0,0 +1,47 @@
{
"app-id": "com.thebrokenrail.FeedbackD-Configuration",
"runtime": "org.gnome.Platform",
"runtime-version": "3.36",
"sdk": "org.gnome.Sdk",
"command": "feedbackd-configuration",
"finish-args": [
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--share=network",
"--talk-name=org.gtk.vfs",
"--talk-name=org.gtk.vfs.*",
"--parent-expose-pids"
],
"modules": [
{
"name": "feedbackd-configuration",
"builddir": true,
"buildsystem": "cmake",
"config-opts": [
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++"
],
"sources": [
{
"type": "dir",
"path": "."
}
],
"modules": [
{
"name": "libhandy1",
"builddir": true,
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libhandy.git",
"tag": "1.0.0"
}
]
}
]
}
]
}

View File

@ -11,8 +11,7 @@ static void on_startup() {
hdy_init();
}
#define CONFIG_JSON "/usr/share/feedbackd/themes/default.json"
#define ADMIN_CONFIG_JSON "admin://"CONFIG_JSON
#define CONFIG_JSON_URI "admin:///usr/share/feedbackd/themes/default.json"
JsonNode *root = NULL;
@ -142,8 +141,8 @@ static void load_profile(GtkListBox *list) {
}
}
// JSON File On admin://
GFile *file;
// JSON GIO File
GFile *file = NULL;
// Reload And Save Profiles
void reload_profiles(int save) {
@ -159,17 +158,20 @@ void reload_profiles(int save) {
json_generator_set_indent(generator, 4);
json_generator_set_indent_char(generator, ' ');
// Open JSON
GError *open_err = NULL;
GFileOutputStream *stream = g_file_replace(file, NULL, 0, G_FILE_CREATE_NONE, NULL, &open_err);
if (stream == NULL) {
g_error("Error Opening File Stream: %s", open_err->message);
}
// Write JSON
GError *write_err = NULL;
if (json_generator_to_stream(generator, G_OUTPUT_STREAM(stream), NULL, &write_err) == 0) {
g_error("Error Saving JSON: %s", write_err->message);
}
// Close JSON
GError *close_err = NULL;
if (g_output_stream_close(G_OUTPUT_STREAM(stream), NULL, &close_err) == 0) {
g_error("Error Closing File Stream: %s", close_err->message);
@ -177,7 +179,10 @@ void reload_profiles(int save) {
g_object_unref(stream);
// Restart FeedbackD
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
system("killall feedbackd");
#pragma GCC diagnostic pop
g_object_unref(generator);
}
@ -196,8 +201,45 @@ void on_new_event(GtkButton *button, GtkStack *stack) {
static void finish_mount(__attribute__((unused)) GObject *object, GAsyncResult *result, __attribute__((unused)) gpointer user_data) {
GError *err = NULL;
if (g_file_mount_enclosing_volume_finish(file, result, &err) == 0) {
g_error("Error Mounting JSON: %s", err->message);
g_error("Error Mounting GVFS: %s", err->message);
}
// Open JSON
GError *open_err = NULL;
GFileInputStream *stream = g_file_read(file, NULL, &open_err);
if (stream == NULL) {
g_error("Error Opening File Stream: %s", open_err->message);
}
// Create JSON Parser
JsonParser *parser = json_parser_new();
// Load JSON
GError *json_err = NULL;
if (json_parser_load_from_stream(parser, G_INPUT_STREAM(stream), NULL, &json_err) == 0) {
g_error("Error Parsing JSON: %s", json_err->message);
}
// Store JSON Data
root = json_node_copy(json_parser_get_root(parser));
// Free JSON Parser
g_object_unref(parser);
// Close JSON
GError *close_err = NULL;
if (g_input_stream_close(G_INPUT_STREAM(stream), NULL, &close_err) == 0) {
g_error("Error Closing File Stream: %s", close_err->message);
}
g_object_unref(stream);
// Cache JSON Objects
get_app_data()->full = get_profile("full");
get_app_data()->quiet = get_profile("quiet");
get_app_data()->silent = get_profile("silent");
// Reload Widgets
reload_profiles(0);
}
// App Start Handler
@ -209,6 +251,7 @@ static void on_activate(GtkApplication *app) {
if (window == NULL) {
GtkBuilder *builder = gtk_builder_new();
// Load Window
GError *err = NULL;
if (gtk_builder_add_from_resource(builder, "/main_window.glade", &err) == 0) {
g_error("Error Loading UI: %s", err->message);
@ -218,34 +261,18 @@ static void on_activate(GtkApplication *app) {
gtk_builder_connect_signals(builder, NULL);
JsonParser *parser = json_parser_new();
GError *json_err = NULL;
if (json_parser_load_from_file(parser, CONFIG_JSON, &json_err) == 0) {
g_error("Error Parsing JSON: %s", json_err->message);
}
root = json_node_copy(json_parser_get_root(parser));
file = g_file_new_for_uri(CONFIG_JSON_URI);
init_app_data();
get_app_data()->full_list = GTK_LIST_BOX(gtk_builder_get_object(builder, "full"));
get_app_data()->full = get_profile("full");
get_app_data()->quiet_list = GTK_LIST_BOX(gtk_builder_get_object(builder, "quiet"));
get_app_data()->quiet = get_profile("quiet");
get_app_data()->silent_list = GTK_LIST_BOX(gtk_builder_get_object(builder, "silent"));
get_app_data()->silent = get_profile("silent");
reload_profiles(0);
g_object_unref(parser);
g_object_unref(builder);
gtk_window_set_application(window, app);
file = g_file_new_for_uri(ADMIN_CONFIG_JSON);
// Mount File
GMountOperation *operation = gtk_mount_operation_new(window);
g_file_mount_enclosing_volume(file, G_MOUNT_MOUNT_NONE, operation, NULL, finish_mount, NULL);