summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/rofi.h6
-rw-r--r--lexer/theme-lexer.l1
-rw-r--r--lexer/theme-parser.y19
-rw-r--r--source/helper.c2
-rw-r--r--source/rofi.c34
-rw-r--r--source/theme.c10
-rw-r--r--source/widgets/widget.c3
7 files changed, 55 insertions, 20 deletions
diff --git a/include/rofi.h b/include/rofi.h
index fad90e49..bfa66d28 100644
--- a/include/rofi.h
+++ b/include/rofi.h
@@ -37,6 +37,12 @@ unsigned int rofi_get_num_enabled_modi ( void );
const Mode * rofi_get_mode ( unsigned int index );
/**
+ * @param str A GString with an error message to display.
+ *
+ * Queue an error.
+ */
+void rofi_add_error_message ( GString *str );
+/**
* @param code the code to return
*
* Return value are used for integrating dmenu rofi in scripts.
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index c9a8c152..117cf6f1 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -342,7 +342,6 @@ if ( queue == NULL ){
return T_ERROR;
}
<*>. {
- fprintf(stderr, "Invalid character: '%c'\n", *yytext);
return T_ERROR;
}
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index 074a90c8..fa1d8e94 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -33,7 +33,8 @@ int yylex (YYSTYPE *, YYLTYPE *);
Distance distance;
}
-%token <ival> T_ERROR "error from file parser"
+%token <ival> T_END 0 "end of file"
+%token <ival> T_ERROR 1 "error from file parser"
%token <ival> T_INT
%token <fval> T_DOUBLE
%token <sval> T_STRING
@@ -47,14 +48,14 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token <sval> T_LINK
%token <sval> FIRST_NAME
-%token BOPEN "bracket open";
-%token BCLOSE "bracket close";
-%token PSEP "property separator";
-%token PCLOSE "property close";
-%token NSEP "Name separator";
-%token NAME_PREFIX "Name element prefix ('#')";
-%token WHITESPACE "White space";
-%token PDEFAULTS "Default settings section ( '* { ... }')";
+%token BOPEN "bracket open"
+%token BCLOSE "bracket close"
+%token PSEP "property separator"
+%token PCLOSE "property close"
+%token NSEP "Name separator"
+%token NAME_PREFIX "Name element prefix ('#')"
+%token WHITESPACE "White space"
+%token PDEFAULTS "Default settings section ( '* { ... }')"
%type <ival> highlight_styles
%type <sval> entry
diff --git a/source/helper.c b/source/helper.c
index 76e334de..cb30a22d 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -614,7 +614,7 @@ int config_sanity_check ( void )
if ( found_error ) {
g_string_append ( msg, "Please update your configuration." );
- rofi_view_error_dialog ( msg->str, TRUE );
+ rofi_add_error_message ( msg );
return TRUE;
}
diff --git a/source/rofi.c b/source/rofi.c
index 10f2b69d..12b639c6 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -70,6 +70,13 @@
char *pidfile = NULL;
const char *cache_dir = NULL;
+GList *list_of_error_msgs = NULL;
+
+
+void rofi_add_error_message ( GString *str )
+{
+ list_of_error_msgs = g_list_append ( list_of_error_msgs, str );
+}
/** global structure holding the keyboard status */
struct xkb_stuff xkb = {
.xcb_connection = NULL,
@@ -369,6 +376,14 @@ static void cleanup ()
g_free ( config_path );
+
+ if ( list_of_error_msgs ) {
+ for ( GList *iter = g_list_first ( list_of_error_msgs );
+ iter != NULL; iter = g_list_next ( iter ) ){
+ g_string_free ( (GString*)iter->data, TRUE);
+ }
+ g_list_free ( list_of_error_msgs );
+ }
TIMINGS_STOP ();
}
@@ -660,10 +675,21 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
}
TICK_N ( "Parse ABE" );
// Sanity check
- if ( config_sanity_check ( ) ) {
+ config_sanity_check ( );
+ TICK_N ( "Config sanity check" );
+
+
+ if ( list_of_error_msgs != NULL ) {
+ GString *emesg = g_string_new ( "The following errors where detected when starting rofi:\n");
+ for ( GList *iter = g_list_first ( list_of_error_msgs ); iter != NULL; iter = g_list_next ( iter ) ) {
+ GString *msg = (GString*)(iter->data);
+ g_string_append( emesg, "\n\n");
+ g_string_append ( emesg, msg->str );
+ }
+ rofi_view_error_dialog ( emesg->str, ERROR_MSG_MARKUP );
+ g_string_free ( emesg, TRUE );
return G_SOURCE_REMOVE;
}
- TICK_N ( "Config sanity check" );
// Dmenu mode.
if ( dmenu_mode == TRUE ) {
// force off sidebar mode:
@@ -950,8 +976,8 @@ int main ( int argc, char *argv[] )
if ( config.theme ) {
TICK_N ( "Parse theme" );
if ( ! rofi_theme_parse_file ( config.theme ) ) {
- // TODO: instantiate fallback theme.?
-
+ // TODO: instantiate fallback theme.?
+
}
TICK_N ( "Parsed theme" );
}
diff --git a/source/theme.c b/source/theme.c
index ecb475a9..65810073 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -263,9 +263,12 @@ extern FILE* yyin;
*/
void yyerror ( YYLTYPE *yylloc, const char* s )
{
- fprintf ( stderr, "Parse error: %s\n", s );
- fprintf ( stderr, "From line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column );
- exit ( EXIT_FAILURE );
+ GString *str = g_string_new ("<big><b>Error while parsing theme file:</b></big>\n");
+ char *esc = g_markup_escape_text ( s, -1);
+ g_string_append_printf(str, "\tParser error: %s\n", esc );
+ g_free(esc);
+ g_string_append_printf(str, "\tLocation: line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column );
+ rofi_add_error_message ( str );
}
static gboolean rofi_theme_steal_property_int ( gpointer key, gpointer value, gpointer user_data )
@@ -866,7 +869,6 @@ gboolean rofi_theme_parse_file ( const char *file )
g_free ( filename );
yyin = NULL;
if ( parser_retv != 0 ){
- fprintf ( stderr, "Failed to parse theme: %s.\n", file );
return TRUE;
}
return FALSE;
diff --git a/source/widgets/widget.c b/source/widgets/widget.c
index c51e63ff..d17b3db9 100644
--- a/source/widgets/widget.c
+++ b/source/widgets/widget.c
@@ -111,12 +111,13 @@ void widget_draw ( widget *widget, cairo_t *d )
widget->h - margin_top - margin_bottom
);
cairo_clip ( d );
-
+ cairo_set_source_rgba ( d, 1.0,1.0,1.0, 1.0 );
rofi_theme_get_color ( widget, "background", d );
cairo_paint ( d );
// Set new x/y possition.
cairo_translate ( d, widget->x, widget->y );
+ cairo_set_source_rgba ( d, 0.0,0.0,0.0, 1.0 );
int left = distance_get_pixel ( widget->border.left, ORIENTATION_HORIZONTAL );
int right = distance_get_pixel ( widget->border.right, ORIENTATION_HORIZONTAL );