mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-11 13:50:48 -05:00
[Lexer] Fix lexer parsing default theme from resource.
This commit is contained in:
parent
de69f5290e
commit
d3cd5b3e43
2 changed files with 33 additions and 38 deletions
|
@ -86,7 +86,6 @@ typedef struct _ParseObject {
|
||||||
} ParseObject;
|
} ParseObject;
|
||||||
|
|
||||||
|
|
||||||
GList *imported_files = NULL;
|
|
||||||
GList *prev_imported_files = NULL;
|
GList *prev_imported_files = NULL;
|
||||||
GQueue *file_queue = NULL;
|
GQueue *file_queue = NULL;
|
||||||
GQueue *queue = NULL;
|
GQueue *queue = NULL;
|
||||||
|
@ -145,6 +144,7 @@ static double rofi_theme_parse_convert_hex ( char high, char low)
|
||||||
} else {\
|
} else {\
|
||||||
result = 0;\
|
result = 0;\
|
||||||
}\
|
}\
|
||||||
|
break;\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
|
@ -371,25 +371,31 @@ if ( queue == NULL ) {
|
||||||
|
|
||||||
/** Parse path. Last element in this INCLUDE */
|
/** Parse path. Last element in this INCLUDE */
|
||||||
<INCLUDE>{DEFAULT} {
|
<INCLUDE>{DEFAULT} {
|
||||||
yytext[yyleng-1] = '\0';
|
ParseObject *top = g_queue_peek_head ( file_queue );
|
||||||
/** Add Parse object */
|
g_assert ( top != NULL );
|
||||||
GBytes *theme_data = g_resource_lookup_data( resources_get_resource(),
|
GBytes *theme_data = g_resource_lookup_data( resources_get_resource(),
|
||||||
"/org/qtools/rofi/default.rasi", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
"/org/qtools/rofi/default.rasi", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
||||||
if (theme_data) {
|
if (theme_data) {
|
||||||
const char *theme = g_bytes_get_data(theme_data, NULL);
|
const char *theme = g_bytes_get_data(theme_data, NULL);
|
||||||
file_queue = g_queue_new ();
|
top->location = *yylloc;
|
||||||
ParseObject *po = g_malloc0(sizeof(ParseObject));
|
ParseObject *po = g_malloc0(sizeof(ParseObject));
|
||||||
po->type = PT_STRING_ALLOC;
|
po->type = PT_STRING_ALLOC;
|
||||||
po->malloc_str = g_strdup(theme);
|
po->malloc_str = g_strdup(theme);
|
||||||
po->input_str = po->malloc_str;
|
po->input_str = po->malloc_str;
|
||||||
po->str_len = strlen(po->malloc_str);
|
po->str_len = strlen(po->malloc_str)-1;
|
||||||
current = po;
|
current = po;
|
||||||
g_queue_push_head ( file_queue, po );
|
g_queue_push_head ( file_queue, po );
|
||||||
g_bytes_unref(theme_data);
|
g_bytes_unref(theme_data);
|
||||||
|
|
||||||
|
yypush_buffer_state (yy_create_buffer ( 0, YY_BUF_SIZE ));
|
||||||
|
yylloc->first_line = yylloc->last_line = 1;
|
||||||
|
yylloc->first_column = yylloc->last_column = 1;
|
||||||
|
yylloc->filename = NULL;//"default theme";
|
||||||
}
|
}
|
||||||
// Pop out of include. */
|
// Pop out of include.
|
||||||
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
|
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
|
||||||
}
|
}
|
||||||
|
|
||||||
<INCLUDE>{STRING} {
|
<INCLUDE>{STRING} {
|
||||||
yytext[yyleng-1] = '\0';
|
yytext[yyleng-1] = '\0';
|
||||||
ParseObject *top = g_queue_peek_head ( file_queue );
|
ParseObject *top = g_queue_peek_head ( file_queue );
|
||||||
|
@ -397,10 +403,6 @@ if ( queue == NULL ) {
|
||||||
char *file2 = helper_get_theme_path ( &yytext[1], ".rasi" );
|
char *file2 = helper_get_theme_path ( &yytext[1], ".rasi" );
|
||||||
char *filename = rofi_theme_parse_prepare_file ( file2, top->filename );
|
char *filename = rofi_theme_parse_prepare_file ( file2, top->filename );
|
||||||
g_free ( file2 );
|
g_free ( file2 );
|
||||||
if ( g_list_find_custom ( imported_files, filename, (GCompareFunc)g_strcmp0 ) != NULL ) {
|
|
||||||
g_debug ( "Skipping file: '%s' already parsed.", filename );
|
|
||||||
} else {
|
|
||||||
g_debug ( "Parsing file: '%s'", filename );
|
|
||||||
FILE *f = fopen ( filename, "rb" );
|
FILE *f = fopen ( filename, "rb" );
|
||||||
if ( f ) {
|
if ( f ) {
|
||||||
top->location = *yylloc;
|
top->location = *yylloc;
|
||||||
|
@ -410,7 +412,6 @@ if ( queue == NULL ) {
|
||||||
po->filein = f;
|
po->filein = f;
|
||||||
current = po;
|
current = po;
|
||||||
g_queue_push_head ( file_queue, po );
|
g_queue_push_head ( file_queue, po );
|
||||||
imported_files = g_list_append ( imported_files, po->filename );
|
|
||||||
|
|
||||||
yypush_buffer_state (yy_create_buffer ( 0, YY_BUF_SIZE ));
|
yypush_buffer_state (yy_create_buffer ( 0, YY_BUF_SIZE ));
|
||||||
yylloc->first_line = yylloc->last_line = 1;
|
yylloc->first_line = yylloc->last_line = 1;
|
||||||
|
@ -423,7 +424,6 @@ if ( queue == NULL ) {
|
||||||
g_free ( str );
|
g_free ( str );
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Pop out of include. */
|
// Pop out of include. */
|
||||||
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
|
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,6 @@ if ( queue == NULL ) {
|
||||||
po->str_len = strlen(val);
|
po->str_len = strlen(val);
|
||||||
current = po;
|
current = po;
|
||||||
g_queue_push_head ( file_queue, po );
|
g_queue_push_head ( file_queue, po );
|
||||||
imported_files = g_list_append ( imported_files, po->filename );
|
|
||||||
|
|
||||||
yypush_buffer_state (yy_create_buffer ( 0, YY_BUF_SIZE ));
|
yypush_buffer_state (yy_create_buffer ( 0, YY_BUF_SIZE ));
|
||||||
yylloc->first_line = yylloc->last_line = 1;
|
yylloc->first_line = yylloc->last_line = 1;
|
||||||
|
@ -829,7 +828,6 @@ gboolean rofi_theme_parse_file ( const char *file )
|
||||||
po->filename = filename;
|
po->filename = filename;
|
||||||
po->filein = yyin;
|
po->filein = yyin;
|
||||||
current = po;
|
current = po;
|
||||||
imported_files = g_list_append ( imported_files, po->filename );
|
|
||||||
g_queue_push_head ( file_queue, po );
|
g_queue_push_head ( file_queue, po );
|
||||||
g_debug ( "Parsing top file: '%s'", filename );
|
g_debug ( "Parsing top file: '%s'", filename );
|
||||||
|
|
||||||
|
@ -849,9 +847,7 @@ gboolean rofi_theme_parse_file ( const char *file )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Free up.
|
// Free up.
|
||||||
g_list_free_full ( imported_files, g_free );
|
|
||||||
g_queue_free ( file_queue );
|
g_queue_free ( file_queue );
|
||||||
imported_files = NULL;
|
|
||||||
file_queue = NULL;
|
file_queue = NULL;
|
||||||
if ( parser_retv != 0 ) {
|
if ( parser_retv != 0 ) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -887,8 +883,6 @@ gboolean rofi_theme_parse_string ( const char *string )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Free up.
|
// Free up.
|
||||||
g_list_free_full ( imported_files, g_free );
|
|
||||||
imported_files = NULL;
|
|
||||||
g_queue_free ( file_queue );
|
g_queue_free ( file_queue );
|
||||||
file_queue = NULL;
|
file_queue = NULL;
|
||||||
if ( parser_retv != 0 ) {
|
if ( parser_retv != 0 ) {
|
||||||
|
|
|
@ -344,6 +344,7 @@ t_entry_list {
|
||||||
$$ =$1;
|
$$ =$1;
|
||||||
}
|
}
|
||||||
| t_entry_list_included T_RESET_THEME t_entry_list {
|
| t_entry_list_included T_RESET_THEME t_entry_list {
|
||||||
|
|
||||||
rofi_theme_reset();
|
rofi_theme_reset();
|
||||||
rofi_theme_free($1);
|
rofi_theme_free($1);
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
|
|
Loading…
Reference in a new issue