diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-01-09 18:32:26 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-01-09 18:32:26 +0100 |
commit | 854aa554533fcb5f93559220b474043f28ce45d4 (patch) | |
tree | 1bb409371616df3162cc4dae62ed3ddf90b80a1e /source | |
parent | a199fa3275c2bf2dfe6320de1410266ac626c6db (diff) |
Better error reporting (1)
Diffstat (limited to 'source')
-rw-r--r-- | source/helper.c | 2 | ||||
-rw-r--r-- | source/rofi.c | 34 | ||||
-rw-r--r-- | source/theme.c | 10 | ||||
-rw-r--r-- | source/widgets/widget.c | 3 |
4 files changed, 39 insertions, 10 deletions
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 ); |