mirror of
https://github.com/davatorium/rofi.git
synced 2025-03-03 16:05:20 -05:00
First testing to use GResource to load default theme.
This commit is contained in:
parent
0bb64cf1ad
commit
cc3d889fea
3 changed files with 44 additions and 11 deletions
20
Makefile.am
20
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
|
||||
|
|
6
resources/resources.xml
Normal file
6
resources/resources.xml
Normal file
|
@ -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>
|
|
@ -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 ();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue