From 1b09ecf47fe129e8b1afc6e4977200465ebf6aef Mon Sep 17 00:00:00 2001 From: Dustin Falgout Date: Sun, 25 Sep 2016 07:10:32 -0500 Subject: [PATCH] use gresource system to load css file --- .editorconfig | 2 +- ...reeter-application.css => greeter-syle.css} | 0 src/greeter.gresource.xml | 6 ++++++ src/lightdm-webkit2-greeter.c | 18 +++++++++++------- src/meson.build | 7 +++++++ 5 files changed, 25 insertions(+), 8 deletions(-) rename src/{lightdm-webkit2-greeter-application.css => greeter-syle.css} (100%) create mode 100644 src/greeter.gresource.xml diff --git a/.editorconfig b/.editorconfig index eae7dce..d16d726 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,6 +17,6 @@ charset = utf-8 max_line_length = 99 -continuation_indent_size = 8 +continuation_indent_size = 4 indent_brace_style = 1TBS curly_bracket_next_line = false diff --git a/src/lightdm-webkit2-greeter-application.css b/src/greeter-syle.css similarity index 100% rename from src/lightdm-webkit2-greeter-application.css rename to src/greeter-syle.css diff --git a/src/greeter.gresource.xml b/src/greeter.gresource.xml new file mode 100644 index 0000000..f54ca50 --- /dev/null +++ b/src/greeter.gresource.xml @@ -0,0 +1,6 @@ + + + + greeter.css + + \ No newline at end of file diff --git a/src/lightdm-webkit2-greeter.c b/src/lightdm-webkit2-greeter.c index 1f09596..89828ea 100644 --- a/src/lightdm-webkit2-greeter.c +++ b/src/lightdm-webkit2-greeter.c @@ -48,7 +48,7 @@ #include -#include "src/lightdm-webkit2-greeter-css-application.h" +#include "greeter-css.h" static GtkWidget *web_view; static GtkWidget *window; @@ -277,6 +277,7 @@ main(int argc, char **argv) { WebKitWebContext *context; GtkCssProvider *css_provider; WebKitCookieManager *cookie_manager; + GResource *css_resource; /* Prevent memory from being swapped out, since we see unencrypted passwords. */ mlockall (MCL_CURRENT | MCL_FUTURE); @@ -323,13 +324,16 @@ main(int argc, char **argv) { /* Setup CSS provider. We use CSS to set the window background to black instead * of default white so the screen doesnt flash during startup. */ + css_resource = greeter_css_get_resource(); css_provider = gtk_css_provider_new(); - gtk_css_provider_load_from_data(css_provider, - lightdm_webkit2_greeter_css_application, - lightdm_webkit2_greeter_css_application_length, NULL); - gtk_style_context_add_provider_for_screen(screen, - GTK_STYLE_PROVIDER(css_provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + + g_resources_register(css_resource); + gtk_css_provider_load_from_resource(css_provider, "/com/antergos/lightdm-webkit2-greeter"); + gtk_style_context_add_provider_for_screen( + screen, + GTK_STYLE_PROVIDER(css_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + ); /* Register and connect handler that will set the web extensions directory * so webkit can find our extension. diff --git a/src/meson.build b/src/meson.build index e7d786e..fd0abb4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,4 +1,5 @@ pkgg = import('pkgconfig') +gnome = import('gnome') configure_file(output: 'config.h', configuration: conf) @@ -36,6 +37,12 @@ pkgg.generate( # ------->>> LightDM Greeter <<<------- # # ===================================== # +greeter_css = gnome.compile_resources( + 'greeter-css', + 'greeter.gresource.xml', + source_dir : '.', + c_name : 'greeter_css') + greeter_sources = ['lightdm-webkit2-greeter.c'] greeter_incdir = include_directories('.')