mirror of
https://github.com/davatorium/rofi.git
synced 2025-07-31 21:59:25 -04:00
Merge pull request #711 from DaveDavenport/resources
Store default theme in the rofi binary using GResources.
This commit is contained in:
commit
4358894724
6 changed files with 55 additions and 160 deletions
22
Makefile.am
22
Makefile.am
|
@ -22,7 +22,17 @@ pkgconfig_DATA = pkgconfig/rofi.pc
|
||||||
BUILT_SOURCES=\
|
BUILT_SOURCES=\
|
||||||
lexer/theme-parser.h\
|
lexer/theme-parser.h\
|
||||||
lexer/theme-parser.c\
|
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
|
$(top_builddir)/lexer/theme-lexer.c: $(top_srcdir)/lexer/theme-lexer.l
|
||||||
|
|
||||||
|
@ -92,7 +102,6 @@ SOURCES=\
|
||||||
include/history.h\
|
include/history.h\
|
||||||
include/theme.h\
|
include/theme.h\
|
||||||
include/css-colors.h\
|
include/css-colors.h\
|
||||||
include/default-theme.h\
|
|
||||||
include/widgets/box.h\
|
include/widgets/box.h\
|
||||||
include/widgets/container.h\
|
include/widgets/container.h\
|
||||||
include/widgets/widget.h\
|
include/widgets/widget.h\
|
||||||
|
@ -109,11 +118,14 @@ SOURCES=\
|
||||||
include/dialogs/script.h\
|
include/dialogs/script.h\
|
||||||
include/dialogs/window.h\
|
include/dialogs/window.h\
|
||||||
include/dialogs/dialogs.h\
|
include/dialogs/dialogs.h\
|
||||||
include/dialogs/help-keys.h
|
include/dialogs/help-keys.h\
|
||||||
|
resources/resources.c\
|
||||||
|
resources/resources.h
|
||||||
|
|
||||||
rofi_SOURCES=\
|
rofi_SOURCES=\
|
||||||
lexer/theme-parser.y\
|
lexer/theme-parser.y\
|
||||||
lexer/theme-lexer.l\
|
lexer/theme-lexer.l\
|
||||||
|
resources/resources.xml\
|
||||||
$(SOURCES)
|
$(SOURCES)
|
||||||
|
|
||||||
rofi_CFLAGS=\
|
rofi_CFLAGS=\
|
||||||
|
@ -129,6 +141,7 @@ rofi_CFLAGS=\
|
||||||
-I$(top_srcdir)/include/\
|
-I$(top_srcdir)/include/\
|
||||||
-I$(top_builddir)/lexer/\
|
-I$(top_builddir)/lexer/\
|
||||||
-I$(top_srcdir)/lexer/\
|
-I$(top_srcdir)/lexer/\
|
||||||
|
-I$(top_builddir)/resources/\
|
||||||
-I$(top_srcdir)/config/\
|
-I$(top_srcdir)/config/\
|
||||||
-I$(top_builddir)/\
|
-I$(top_builddir)/\
|
||||||
-Werror=missing-prototypes\
|
-Werror=missing-prototypes\
|
||||||
|
@ -217,6 +230,7 @@ EXTRA_DIST+=\
|
||||||
doc/rofi.doxy.in\
|
doc/rofi.doxy.in\
|
||||||
script/get_git_rev.sh\
|
script/get_git_rev.sh\
|
||||||
$(theme_DATA)\
|
$(theme_DATA)\
|
||||||
|
doc/default_theme.rasi\
|
||||||
Changelog
|
Changelog
|
||||||
##
|
##
|
||||||
# Indent
|
# Indent
|
||||||
|
@ -564,6 +578,8 @@ doxy: doc/rofi.doxy $(rofi_SOURCES)
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
-rm $(top_builddir)/gitconfig.h
|
-rm $(top_builddir)/gitconfig.h
|
||||||
|
-rm $(top_builddir)/resources/resources.h
|
||||||
|
-rm $(top_builddir)/resources/resources.c
|
||||||
|
|
||||||
$(top_builddir)/gitconfig.h: .FORCE
|
$(top_builddir)/gitconfig.h: .FORCE
|
||||||
$(top_srcdir)/script/get_git_rev.sh $(top_srcdir) $(top_builddir)/gitconfig.h
|
$(top_srcdir)/script/get_git_rev.sh $(top_srcdir) $(top_builddir)/gitconfig.h
|
||||||
|
|
|
@ -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])
|
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 ---------------------------------------------------------------------
|
||||||
dnl Add extra compiler flags
|
dnl Add extra compiler flags
|
||||||
|
|
|
@ -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
|
|
|
@ -171,7 +171,6 @@ rofi_sources = files(
|
||||||
'include/theme.h',
|
'include/theme.h',
|
||||||
'include/rofi-types.h',
|
'include/rofi-types.h',
|
||||||
'include/css-colors.h',
|
'include/css-colors.h',
|
||||||
'include/default-theme.h',
|
|
||||||
'include/widgets/box.h',
|
'include/widgets/box.h',
|
||||||
'include/widgets/container.h',
|
'include/widgets/container.h',
|
||||||
'include/widgets/widget.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_lexer = flex.process(theme_lexer_sources)
|
||||||
theme_parser = bison.process(theme_parser_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 + [
|
rofi = executable('rofi', rofi_sources + [
|
||||||
theme_lexer,
|
theme_lexer,
|
||||||
theme_parser,
|
theme_parser,
|
||||||
|
default_theme,
|
||||||
],
|
],
|
||||||
dependencies: deps,
|
dependencies: deps,
|
||||||
install: true,
|
install: true,
|
||||||
|
|
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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "resources.h"
|
||||||
|
|
||||||
#include "rofi.h"
|
#include "rofi.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
|
@ -69,8 +71,6 @@
|
||||||
|
|
||||||
#include "timings.h"
|
#include "timings.h"
|
||||||
|
|
||||||
#include "default-theme.h"
|
|
||||||
|
|
||||||
// Plugin abi version.
|
// Plugin abi version.
|
||||||
// TODO: move this check to mode.c
|
// TODO: move this check to mode.c
|
||||||
#include "mode-private.h"
|
#include "mode-private.h"
|
||||||
|
@ -887,7 +887,14 @@ int main ( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( rofi_theme_is_empty ( ) ) {
|
if ( rofi_theme_is_empty ( ) ) {
|
||||||
if ( rofi_theme_parse_string ( default_theme ) ) {
|
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.." );
|
g_warning ( "Failed to parse default theme. Giving up.." );
|
||||||
if ( list_of_error_msgs ) {
|
if ( list_of_error_msgs ) {
|
||||||
for ( GList *iter = g_list_first ( list_of_error_msgs );
|
for ( GList *iter = g_list_first ( list_of_error_msgs );
|
||||||
|
@ -900,6 +907,8 @@ int main ( int argc, char *argv[] )
|
||||||
cleanup ();
|
cleanup ();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
g_bytes_unref ( theme_data );
|
||||||
|
}
|
||||||
rofi_theme_convert_old ();
|
rofi_theme_convert_old ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue