mirror of
https://github.com/lbonn/rofi
synced 2024-11-24 21:03:24 +00:00
[Theme] Undo part of default theme changes, always pick build-in
This commit is contained in:
parent
214a6e061b
commit
acb1979f10
8 changed files with 82 additions and 31 deletions
15
Makefile.am
15
Makefile.am
|
@ -238,8 +238,7 @@ theme_DATA=\
|
|||
themes/solarized_alternate.rasi\
|
||||
themes/fancy.rasi\
|
||||
themes/iggy.rasi\
|
||||
themes/iggy.jpg\
|
||||
themes/default.rasi
|
||||
themes/iggy.jpg
|
||||
|
||||
##
|
||||
# Extra DIST
|
||||
|
@ -257,6 +256,7 @@ EXTRA_DIST+=\
|
|||
script/get_git_rev.sh\
|
||||
$(theme_DATA)\
|
||||
doc/default_configuration.rasi\
|
||||
doc/default_theme.rasi\
|
||||
Changelog
|
||||
##
|
||||
# Indent
|
||||
|
@ -328,6 +328,7 @@ textbox_test_CFLAGS=\
|
|||
-I$(top_builddir)/lexer/\
|
||||
-I$(top_srcdir)/lexer/\
|
||||
-I$(top_srcdir)/config/\
|
||||
-I$(top_builddir)/resources/\
|
||||
-I$(top_builddir)/
|
||||
|
||||
textbox_test_LDADD=\
|
||||
|
@ -368,7 +369,8 @@ widget_test_SOURCES=\
|
|||
config/config.c\
|
||||
lexer/theme-parser.y\
|
||||
lexer/theme-lexer.l\
|
||||
test/widget-test.c
|
||||
test/widget-test.c\
|
||||
resources/resources.c
|
||||
|
||||
box_test_LDADD=$(textbox_test_LDADD)
|
||||
box_test_CFLAGS=$(textbox_test_CFLAGS)
|
||||
|
@ -384,6 +386,7 @@ box_test_SOURCES=\
|
|||
include/theme.h\
|
||||
include/css-colors.h\
|
||||
config/config.c\
|
||||
resources/resources.c\
|
||||
test/box-test.c
|
||||
|
||||
scrollbar_test_LDADD=$(textbox_test_LDADD)
|
||||
|
@ -400,7 +403,8 @@ scrollbar_test_SOURCES=\
|
|||
include/theme.h\
|
||||
include/css-colors.h\
|
||||
config/config.c\
|
||||
test/scrollbar-test.c
|
||||
test/scrollbar-test.c\
|
||||
resources/resources.c
|
||||
|
||||
textbox_test_SOURCES=\
|
||||
source/widgets/widget.c\
|
||||
|
@ -424,6 +428,7 @@ textbox_test_SOURCES=\
|
|||
include/xrmoptions.h\
|
||||
include/helper.h\
|
||||
include/helper-theme.h\
|
||||
resources/resources.c\
|
||||
test/textbox-test.c
|
||||
|
||||
if USE_CHECK
|
||||
|
@ -448,6 +453,7 @@ theme_parser_test_SOURCES=\
|
|||
source/rofi-types.c\
|
||||
include/rofi-types.h\
|
||||
source/css-colors.c\
|
||||
resources/resources.c\
|
||||
test/theme-parser-test.c
|
||||
endif
|
||||
|
||||
|
@ -481,6 +487,7 @@ helper_test_CFLAGS=\
|
|||
-I$(top_builddir)/lexer/\
|
||||
-I$(top_srcdir)/lexer/\
|
||||
-I$(top_srcdir)/config/\
|
||||
-I$(top_builddir)/resources/\
|
||||
-I$(top_builddir)/
|
||||
|
||||
helper_test_LDADD=\
|
||||
|
|
|
@ -14,3 +14,5 @@ configuration {
|
|||
directories-first: true;
|
||||
}
|
||||
}
|
||||
|
||||
@theme "default"
|
||||
|
|
|
@ -34,8 +34,10 @@
|
|||
|
||||
%{
|
||||
#include "config.h"
|
||||
#include "resources.h"
|
||||
#include <stdio.h>
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
#include <helper.h>
|
||||
#include <math.h>
|
||||
#include <strings.h>
|
||||
|
@ -56,6 +58,8 @@ typedef enum {
|
|||
PT_FILE,
|
||||
/** Parse a string */
|
||||
PT_STRING,
|
||||
/** Parse a string */
|
||||
PT_STRING_ALLOC,
|
||||
/** Parse environment */
|
||||
PT_ENV
|
||||
} ParseType;
|
||||
|
@ -75,6 +79,8 @@ typedef struct _ParseObject {
|
|||
int str_len;
|
||||
/** String */
|
||||
const char *input_str;
|
||||
/** For where we need to free at end. (PT_STRING_ALLOC); */
|
||||
char *malloc_str;
|
||||
/** Position in file */
|
||||
YYLTYPE location;
|
||||
} ParseObject;
|
||||
|
@ -127,6 +133,7 @@ static double rofi_theme_parse_convert_hex ( char high, char low)
|
|||
break;\
|
||||
}\
|
||||
case PT_ENV:\
|
||||
case PT_STRING_ALLOC:\
|
||||
case PT_STRING:\
|
||||
{\
|
||||
yy_size_t len = MIN (max_size, current->str_len);\
|
||||
|
@ -273,6 +280,7 @@ C_COMMENT_OPEN "/*"
|
|||
|
||||
INCLUDE "@import"
|
||||
THEME "@theme"
|
||||
DEFAULT (?i:\"default\"?)
|
||||
|
||||
MEDIA "@media"
|
||||
|
||||
|
@ -363,6 +371,26 @@ if ( queue == NULL ) {
|
|||
<INCLUDE>{WHITESPACE} {}
|
||||
|
||||
/** Parse path. Last element in this INCLUDE */
|
||||
<INCLUDE>{DEFAULT} {
|
||||
yytext[yyleng-1] = '\0';
|
||||
/** Add Parse object */
|
||||
GBytes *theme_data = g_resource_lookup_data( resources_get_resource(),
|
||||
"/org/qtools/rofi/default.rasi", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
||||
if (theme_data) {
|
||||
const char *theme = g_bytes_get_data(theme_data, NULL);
|
||||
file_queue = g_queue_new ();
|
||||
ParseObject *po = g_malloc0(sizeof(ParseObject));
|
||||
po->type = PT_STRING_ALLOC;
|
||||
po->malloc_str = g_strdup(theme);
|
||||
po->input_str = po->malloc_str;
|
||||
po->str_len = strlen(po->malloc_str);
|
||||
current = po;
|
||||
g_queue_push_head ( file_queue, po );
|
||||
g_bytes_unref(theme_data);
|
||||
}
|
||||
// Pop out of include. */
|
||||
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
|
||||
}
|
||||
<INCLUDE>{STRING} {
|
||||
yytext[yyleng-1] = '\0';
|
||||
ParseObject *top = g_queue_peek_head ( file_queue );
|
||||
|
@ -666,6 +694,9 @@ if ( queue == NULL ) {
|
|||
if ( po->type == PT_FILE ) {
|
||||
fclose ( po->filein );
|
||||
}
|
||||
if ( po->type == PT_STRING_ALLOC ) {
|
||||
g_free( po->malloc_str);
|
||||
}
|
||||
g_free ( po );
|
||||
}
|
||||
po = g_queue_peek_head ( file_queue );
|
||||
|
@ -812,6 +843,9 @@ gboolean rofi_theme_parse_file ( const char *file )
|
|||
if ( po->type == PT_FILE ) {
|
||||
fclose ( po->filein );
|
||||
}
|
||||
if ( po->type == PT_STRING_ALLOC ) {
|
||||
g_free( po->malloc_str);
|
||||
}
|
||||
g_free ( po );
|
||||
}
|
||||
}
|
||||
|
@ -847,6 +881,9 @@ gboolean rofi_theme_parse_string ( const char *string )
|
|||
if ( po->type == PT_FILE ) {
|
||||
fclose ( po->filein );
|
||||
}
|
||||
if ( po->type == PT_STRING_ALLOC ) {
|
||||
g_free( po->malloc_str);
|
||||
}
|
||||
g_free ( po );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,6 @@ install_data(
|
|||
'themes/fancy.rasi',
|
||||
'themes/iggy.rasi',
|
||||
'themes/iggy.jpg',
|
||||
'themes/default.rasi',
|
||||
install_dir: themedir
|
||||
)
|
||||
|
||||
|
@ -312,6 +311,7 @@ test('widget test', executable('widget.test', [
|
|||
'test/widget-test.c',
|
||||
theme_parser,
|
||||
theme_lexer,
|
||||
default_theme,
|
||||
],
|
||||
objects: rofi.extract_objects([
|
||||
'source/widgets/widget.c',
|
||||
|
@ -329,6 +329,7 @@ test('box test', executable('box.test', [
|
|||
'test/box-test.c',
|
||||
theme_parser,
|
||||
theme_lexer,
|
||||
default_theme,
|
||||
],
|
||||
objects: rofi.extract_objects([
|
||||
'source/widgets/widget.c',
|
||||
|
@ -345,6 +346,7 @@ test('scrollbar test', executable('scrollbar.test', [
|
|||
'test/scrollbar-test.c',
|
||||
theme_parser,
|
||||
theme_lexer,
|
||||
default_theme,
|
||||
],
|
||||
objects: rofi.extract_objects([
|
||||
'source/widgets/widget.c',
|
||||
|
@ -361,6 +363,7 @@ test('textbox test', executable('textbox.test', [
|
|||
'test/textbox-test.c',
|
||||
theme_parser,
|
||||
theme_lexer,
|
||||
default_theme,
|
||||
],
|
||||
objects: rofi.extract_objects([
|
||||
'source/widgets/widget.c',
|
||||
|
@ -428,6 +431,7 @@ if check.found()
|
|||
'source/theme.c',
|
||||
'source/rofi-types.c',
|
||||
'source/css-colors.c',
|
||||
'resources/resources.c',
|
||||
]),
|
||||
dependencies: deps,
|
||||
))
|
||||
|
|
|
@ -17,6 +17,31 @@ some of the more 'off-script' use of rofi.
|
|||
This release was made possible by many contributors, see below for a full list. Big thanks again to SardemFF7 and
|
||||
TonCherAmi.
|
||||
|
||||
|
||||
## Default theme loading
|
||||
|
||||
In older version of **rofi** the default theme was (almost) always loaded based on some unclear rules, sometimes
|
||||
some random patch code was loaded and sometimes no theme was loaded before loading another theme.
|
||||
|
||||
The current version of rofi this is hopefully more logic. It loads the default
|
||||
theme by default using the default configuration. (Can be disabled by `-no-default-config`).
|
||||
Using `-theme`, or `@theme` primitive will discard the theme completely.
|
||||
|
||||
So the below css completely removes the default theme, and loads `iggy`.
|
||||
|
||||
```css
|
||||
configuration {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@theme "iggy"
|
||||
|
||||
element {
|
||||
children: [element-icon, element-text];
|
||||
}
|
||||
```
|
||||
|
||||
## File Browser
|
||||
|
||||
TonCherAmi made several very nice usability improvements to the file-browser. His changes allow you to define sorting
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/qtools/rofi">
|
||||
<file alias="default.rasi">themes/default.rasi</file>
|
||||
<file alias="default.rasi">doc/default_theme.rasi</file>
|
||||
<file alias="default_configuration.rasi">doc/default_configuration.rasi</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
|
@ -841,7 +841,7 @@ int main(int argc, char *argv[]) {
|
|||
"Pidfile location");
|
||||
|
||||
/** default configuration */
|
||||
{
|
||||
if (find_arg("-no-default-config") < 0) {
|
||||
GBytes *theme_data = g_resource_lookup_data(
|
||||
resources_get_resource(), "/org/qtools/rofi/default_configuration.rasi",
|
||||
G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
||||
|
@ -987,30 +987,6 @@ int main(int argc, char *argv[]) {
|
|||
windowid = config.monitor;
|
||||
}
|
||||
}
|
||||
// Load default theme, if no theme was set and we don't have a current theme
|
||||
// loaded.
|
||||
if (config.theme == NULL && rofi_theme_is_empty()) {
|
||||
GBytes *theme_data = g_resource_lookup_data(
|
||||
resources_get_resource(), "/org/qtools/rofi/default.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;
|
||||
}
|
||||
g_bytes_unref(theme_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make small commandline changes to the current theme.
|
||||
|
|
Loading…
Reference in a new issue