1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Merge pull request #711 from DaveDavenport/resources

Store default theme in the rofi binary using GResources.
This commit is contained in:
Dave Davenport 2017-11-01 20:15:07 +01:00 committed by GitHub
commit 4358894724
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 160 deletions

View file

@ -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
@ -92,7 +102,6 @@ SOURCES=\
include/history.h\
include/theme.h\
include/css-colors.h\
include/default-theme.h\
include/widgets/box.h\
include/widgets/container.h\
include/widgets/widget.h\
@ -109,11 +118,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=\
@ -129,6 +141,7 @@ rofi_CFLAGS=\
-I$(top_srcdir)/include/\
-I$(top_builddir)/lexer/\
-I$(top_srcdir)/lexer/\
-I$(top_builddir)/resources/\
-I$(top_srcdir)/config/\
-I$(top_builddir)/\
-Werror=missing-prototypes\
@ -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

View file

@ -135,6 +135,11 @@ AS_IF([test "x${enable_check}" != "xno"], [ PKG_CHECK_MODULES([check],[check >=
AM_CONDITIONAL([USE_CHECK], [test "x${enable_check}" != "xno" && test "$HAVE_CHECK" -eq 1])
dnl ---------------------------------------------------------------------
dnl Gets the resource compile tool path.
dnl ---------------------------------------------------------------------
AM_PATH_GLIB_2_0
dnl ---------------------------------------------------------------------
dnl Add extra compiler flags

View file

@ -1,145 +0,0 @@
/*
* rofi
*
* MIT/X11 License
* Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef ROFI_DEFAULT_THEME
#define ROFI_DEFAULT_THEME
const char *default_theme =
"* {"
" spacing: 2;"
" background-color: transparent;"
" background: #FDF6E3FF;"
" foreground: #002B36FF;"
" border-color: @foreground;"
" separatorcolor: @foreground;"
" red: #DC322FFF;"
" blue: #268BD2FF;"
" lightbg: #EEE8D5FF;"
" lightfg: #586875FF;"
" normal-foreground: @foreground;"
" normal-background: @background;"
" urgent-foreground: @red;"
" urgent-background: @background;"
" active-foreground: @blue;"
" active-background: @background;"
" selected-normal-foreground: @lightbg;"
" selected-normal-background: @lightfg;"
" selected-urgent-foreground: @background;"
" selected-urgent-background: @red;"
" selected-active-foreground: @background;"
" selected-active-background: @blue;"
" alternate-normal-foreground: @foreground;"
" alternate-normal-background: @lightbg;"
" alternate-urgent-foreground: @red;"
" alternate-urgent-background: @lightbg;"
" alternate-active-foreground: @blue;"
" alternate-active-background: @lightbg;"
"}"
"#window {"
" border: 1;"
" padding: 5;"
" background-color: @background;"
"}"
"#mainbox {"
" border: 0;"
" padding: 0;"
"}"
"#message {"
" border: 2px dash 0px 0px ;"
" padding: 2px 0px 0px ;"
" border-color: @separatorcolor;"
"}"
"#textbox {"
" text-color: @foreground;"
"}"
"#listview {"
" border-color: @separatorcolor;"
"}"
"#listview {"
" fixed-height: 0;"
" border: 2px dash 0px 0px ;"
" padding: 2px 0px 0px ;"
"}"
"#element {"
" border: 0;"
"}"
"#element normal.normal {"
" text-color: @normal-foreground;"
" background-color: @normal-background;"
"}"
"#element normal.urgent {"
" text-color: @urgent-foreground;"
" background-color: @urgent-background;"
"}"
"#element normal.active {"
" text-color: @active-foreground;"
" background-color: @active-background;"
"}"
"#element selected.normal {"
" text-color: @selected-normal-foreground;"
" background-color: @selected-normal-background;"
"}"
"#element selected.urgent {"
" text-color: @selected-urgent-foreground;"
" background-color: @selected-urgent-background;"
"}"
"#element selected.active {"
" text-color: @selected-active-foreground;"
" background-color: @selected-active-background;"
"}"
"#element alternate.normal {"
" text-color: @alternate-normal-foreground;"
" background-color: @alternate-normal-background;"
"}"
"#element alternate.urgent {"
" text-color: @alternate-urgent-foreground;"
" background-color: @alternate-urgent-background;"
"}"
"#element alternate.active {"
" text-color: @alternate-active-foreground;"
" background-color: @alternate-active-background;"
"}"
"#scrollbar {"
" border: 0;"
" width: 4px;"
" padding: 0;"
" handle-color: @normal-foreground;"
"}"
"#sidebar {"
" border: 2px dash 0px 0px ;"
" border-color: @separatorcolor;"
"}"
"#button selected {"
" background-color: @selected-normal-background;"
" text-color: @selected-normal-foreground;"
"}"
"#inputbar, case-indicator, entry, prompt, button {"
" spacing: 0;"
" text-color: @normal-foreground;"
"}"
"#inputbar { spacing: 3px; }";
#endif

View file

@ -171,7 +171,6 @@ rofi_sources = files(
'include/theme.h',
'include/rofi-types.h',
'include/css-colors.h',
'include/default-theme.h',
'include/widgets/box.h',
'include/widgets/container.h',
'include/widgets/widget.h',
@ -195,9 +194,14 @@ theme_parser_sources = files('lexer/theme-parser.y')
theme_lexer = flex.process(theme_lexer_sources)
theme_parser = bison.process(theme_parser_sources)
gnome = import('gnome')
default_theme = gnome.compile_resources('resources', files('resources/resources.xml'))
rofi = executable('rofi', rofi_sources + [
theme_lexer,
theme_parser,
default_theme,
],
dependencies: deps,
install: true,

6
resources/resources.xml Normal file
View 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>

View file

@ -52,6 +52,8 @@
#endif
#endif
#include "resources.h"
#include "rofi.h"
#include "display.h"
@ -69,8 +71,6 @@
#include "timings.h"
#include "default-theme.h"
// Plugin abi version.
// TODO: move this check to mode.c
#include "mode-private.h"
@ -887,18 +887,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 ();
}