Use a gresource to store the css
This makes build / test faster since one can skip install. It's also more obvious which file is being used.
This commit is contained in:
@ -1,9 +1,4 @@
|
|||||||
|
|
||||||
install_data(
|
|
||||||
'themes/default.css',
|
|
||||||
install_dir: pkgdatadir + '/themes',
|
|
||||||
)
|
|
||||||
|
|
||||||
install_data(
|
install_data(
|
||||||
'keyboards/keyboards.xml',
|
'keyboards/keyboards.xml',
|
||||||
install_dir: pkgdatadir + '/keyboards/',
|
install_dir: pkgdatadir + '/keyboards/',
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
* Copyright (C) 2003-2004 Dodji Seketeli. All Rights Reserved.
|
* Copyright (C) 2003-2004 Dodji Seketeli. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define G_LOG_DOMAIN "eek-theme"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -256,13 +257,59 @@ parse_stylesheet (const char *filename,
|
|||||||
{
|
{
|
||||||
enum CRStatus status;
|
enum CRStatus status;
|
||||||
CRStyleSheet *stylesheet;
|
CRStyleSheet *stylesheet;
|
||||||
|
g_autoptr (GFileInputStream) stream = NULL;
|
||||||
|
g_autoptr (GFileInfo) info = NULL;
|
||||||
|
g_autoptr (GFile) file = NULL;
|
||||||
|
g_autofree guchar* contents = NULL;
|
||||||
|
goffset size;
|
||||||
|
gsize out = 0;
|
||||||
|
GError *err = NULL;
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
status = cr_om_parser_simply_parse_file ((const guchar *) filename,
|
g_debug ("Parsing %s", filename);
|
||||||
CR_UTF_8,
|
if (g_strcmp0 (filename, "resource://") > 0) {
|
||||||
&stylesheet);
|
file = g_file_new_for_uri (filename);
|
||||||
|
stream = g_file_read (file, NULL, &err);
|
||||||
|
if (!stream) {
|
||||||
|
g_warning ("Failed to open %s: %s", filename, err->message);
|
||||||
|
g_clear_error (&err);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
info = g_file_input_stream_query_info (stream,
|
||||||
|
G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
||||||
|
NULL,
|
||||||
|
&err);
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
g_warning ("Failed to stat %s: %s", filename, err->message);
|
||||||
|
g_clear_error (&err);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = g_file_info_get_size (info);
|
||||||
|
contents = g_malloc0 (size);
|
||||||
|
if (!g_input_stream_read_all (G_INPUT_STREAM (stream),
|
||||||
|
contents,
|
||||||
|
size,
|
||||||
|
&out,
|
||||||
|
NULL,
|
||||||
|
&err)) {
|
||||||
|
g_warning ("Failed to read %s: %s", filename, err->message);
|
||||||
|
g_clear_error (&err);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
status = cr_om_parser_simply_parse_buf (contents,
|
||||||
|
size,
|
||||||
|
CR_UTF_8,
|
||||||
|
&stylesheet);
|
||||||
|
} else {
|
||||||
|
status = cr_om_parser_simply_parse_file ((const guchar *) filename,
|
||||||
|
CR_UTF_8,
|
||||||
|
&stylesheet);
|
||||||
|
}
|
||||||
|
|
||||||
if (status != CR_OK)
|
if (status != CR_OK)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,6 +4,13 @@ dbus_src = gnome.gdbus_codegen(
|
|||||||
join_paths(dbusdir, 'sm.puri.OSK0.xml')
|
join_paths(dbusdir, 'sm.puri.OSK0.xml')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
squeekboard_resources = gnome.compile_resources(
|
||||||
|
'squeekboard-resources',
|
||||||
|
'squeekboard.gresources.xml',
|
||||||
|
|
||||||
|
c_name: 'squeekboard',
|
||||||
|
)
|
||||||
|
|
||||||
sources = [
|
sources = [
|
||||||
'imservice.c',
|
'imservice.c',
|
||||||
'server-context-service.c',
|
'server-context-service.c',
|
||||||
@ -40,7 +47,8 @@ sources = [
|
|||||||
'../eekboard/eekboard-context-service.c',
|
'../eekboard/eekboard-context-service.c',
|
||||||
'../eekboard/eekboard-context.c',
|
'../eekboard/eekboard-context.c',
|
||||||
'../eekboard/eekboard-service.c',
|
'../eekboard/eekboard-service.c',
|
||||||
# '../eekboard/eekboard-xklutil.c',
|
# '../eekboard/eekboard-xklutil.c',
|
||||||
|
squeekboard_resources,
|
||||||
wl_proto_sources,
|
wl_proto_sources,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -338,9 +338,9 @@ update_widget (ServerContextService *context)
|
|||||||
context->widget = NULL;
|
context->widget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
theme_path = g_build_filename (THEMESDIR, "default.css", NULL);
|
theme = eek_theme_new ("resource:///sm/puri/squeekboard/style.css",
|
||||||
|
NULL,
|
||||||
theme = eek_theme_new (theme_path, NULL, NULL);
|
NULL);
|
||||||
g_free (theme_path);
|
g_free (theme_path);
|
||||||
|
|
||||||
keyboard = eekboard_context_service_get_keyboard (EEKBOARD_CONTEXT_SERVICE(context));
|
keyboard = eekboard_context_service_get_keyboard (EEKBOARD_CONTEXT_SERVICE(context));
|
||||||
|
|||||||
6
src/squeekboard.gresources.xml
Normal file
6
src/squeekboard.gresources.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/sm/puri/squeekboard">
|
||||||
|
<file compressed="true">style.css</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
||||||
Reference in New Issue
Block a user