Browse Source

use gresource system to load css file

sisyphus
Dustin Falgout 8 years ago
parent
commit
1b09ecf47f
  1. 2
      .editorconfig
  2. 0
      src/greeter-syle.css
  3. 6
      src/greeter.gresource.xml
  4. 16
      src/lightdm-webkit2-greeter.c
  5. 7
      src/meson.build

2
.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

0
src/lightdm-webkit2-greeter-application.css → src/greeter-syle.css

6
src/greeter.gresource.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/antergos/lightdm-webkit2-greeter">
<file>greeter.css</file>
</gresource>
</gresources>

16
src/lightdm-webkit2-greeter.c

@ -48,7 +48,7 @@
#include <config.h>
#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,
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);
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
);
/* Register and connect handler that will set the web extensions directory
* so webkit can find our extension.

7
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('.')

Loading…
Cancel
Save