summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-10-31 18:00:24 +0100
committerDave Davenport <qball@gmpclient.org>2017-10-31 18:00:24 +0100
commitcc3d889fea0ebc10894caa622fbac6d41c891bba (patch)
tree24954b53bc522cdfed0583de5256d5e00de92a8c
parent0bb64cf1adf3377f7c9847723dbb3ea19e06af13 (diff)
First testing to use GResource to load default theme.
-rw-r--r--Makefile.am20
-rw-r--r--resources/resources.xml6
-rw-r--r--source/rofi.c29
3 files changed, 44 insertions, 11 deletions
diff --git a/Makefile.am b/Makefile.am
index dbf77e99..8ee5f016 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,17 @@ pkgconfig_DATA = pkgconfig/rofi.pc
BUILT_SOURCES=\
lexer/theme-parser.h\
lexer/theme-parser.c\
- lexer/theme-lexer.c
+ lexer/theme-lexer.c\
+ resources/resources.c\
+ resources/resources.h
+
+$(top_builddir)/resources/resources.c: $(top_srcdir)/resources/resources.xml
+ mkdir -p $(top_builddir)/resources/
+ glib-compile-resources $< --generate-source --target=$@ --sourcedir=$(top_srcdir)
+
+$(top_builddir)/resources/resources.h: $(top_srcdir)/resources/resources.xml
+ mkdir -p $(top_builddir)/resources/
+ glib-compile-resources $< --generate-header --target=$@ --sourcedir=$(top_srcdir)
$(top_builddir)/lexer/theme-lexer.c: $(top_srcdir)/lexer/theme-lexer.l
@@ -109,11 +119,14 @@ SOURCES=\
include/dialogs/script.h\
include/dialogs/window.h\
include/dialogs/dialogs.h\
- include/dialogs/help-keys.h
+ include/dialogs/help-keys.h\
+ resources/resources.c\
+ resources/resources.h
rofi_SOURCES=\
lexer/theme-parser.y\
lexer/theme-lexer.l\
+ resources/resources.xml\
$(SOURCES)
rofi_CFLAGS=\
@@ -217,6 +230,7 @@ EXTRA_DIST+=\
doc/rofi.doxy.in\
script/get_git_rev.sh\
$(theme_DATA)\
+ doc/default_theme.rasi\
Changelog
##
# Indent
@@ -564,6 +578,8 @@ doxy: doc/rofi.doxy $(rofi_SOURCES)
clean-local:
-rm $(top_builddir)/gitconfig.h
+ -rm $(top_builddir)/resources/resources.h
+ -rm $(top_builddir)/resources/resources.c
$(top_builddir)/gitconfig.h: .FORCE
$(top_srcdir)/script/get_git_rev.sh $(top_srcdir) $(top_builddir)/gitconfig.h
diff --git a/resources/resources.xml b/resources/resources.xml
new file mode 100644
index 00000000..d42ae460
--- /dev/null
+++ b/resources/resources.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/qtools/rofi">
+ <file alias="default_theme.rasi">doc/default_theme.rasi</file>
+ </gresource>
+</gresources>
diff --git a/source/rofi.c b/source/rofi.c
index 8199e302..85ad95d2 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -52,6 +52,8 @@
#endif
#endif
+#include "resources/resources.h"
+
#include "rofi.h"
#include "display.h"
@@ -887,18 +889,27 @@ int main ( int argc, char *argv[] )
}
}
if ( rofi_theme_is_empty ( ) ) {
- if ( rofi_theme_parse_string ( default_theme ) ) {
- g_warning ( "Failed to parse default theme. Giving up.." );
- if ( list_of_error_msgs ) {
- for ( GList *iter = g_list_first ( list_of_error_msgs );
- iter != NULL; iter = g_list_next ( iter ) ) {
- g_warning ( "Error: %s%s%s",
+ GBytes *theme_data = g_resource_lookup_data (
+ resources_get_resource(),
+ "/org/qtools/rofi/default_theme.rasi",
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ NULL );
+ if ( theme_data ) {
+ const char *theme = g_bytes_get_data ( theme_data, NULL );
+ if ( rofi_theme_parse_string ( (const char *)theme ) ) {
+ g_warning ( "Failed to parse default theme. Giving up.." );
+ if ( list_of_error_msgs ) {
+ for ( GList *iter = g_list_first ( list_of_error_msgs );
+ iter != NULL; iter = g_list_next ( iter ) ) {
+ g_warning ( "Error: %s%s%s",
color_bold, ( (GString *) iter->data )->str, color_reset );
+ }
}
+ rofi_theme = NULL;
+ cleanup ();
+ return EXIT_FAILURE;
}
- rofi_theme = NULL;
- cleanup ();
- return EXIT_FAILURE;
+ g_bytes_unref ( theme_data );
}
rofi_theme_convert_old ();
}