1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Improve error handling string.

This commit is contained in:
Dave Davenport 2017-01-09 22:40:11 +01:00
parent ca01af6338
commit 25dff63006
8 changed files with 49 additions and 47 deletions

View file

@ -70,9 +70,9 @@
char *pidfile = NULL;
const char *cache_dir = NULL;
/** List of error messages.*/
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 );
@ -376,7 +376,6 @@ 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 ) ) {
@ -678,14 +677,15 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
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" );
GList *iter = g_list_first ( list_of_error_msgs );
if ( iter != NULL ) {
int index = 0;
for (; iter != NULL && index < 2; iter = g_list_next ( iter ) ) {
GString *msg = (GString *) ( iter->data );
g_string_append ( emesg, "\n\n" );
g_string_append ( emesg, msg->str );
index++;
}
if ( g_list_length ( iter ) > 1 ) {
g_string_append_printf ( emesg, "\nThere are <b>%d</b> more errors.", g_list_length ( iter ) - 1 );
@ -981,7 +981,6 @@ int main ( int argc, char *argv[] )
TICK_N ( "Parse theme" );
if ( !rofi_theme_parse_file ( config.theme ) ) {
// TODO: instantiate fallback theme.?
}
TICK_N ( "Parsed theme" );
}

View file

@ -257,6 +257,7 @@ extern FILE* yyin;
/**
* @param yylloc The file location.
* @param what What we are parsing, filename or string.
* @param s Error message string.
*
* Error handler for the lex parser.
@ -883,10 +884,11 @@ gboolean rofi_theme_parse_string ( const char *string )
yyin = NULL;
input_str = string;
str_len = strlen ( string );
while ( yyparse (string) ) {
;
}
int parser_retv = yyparse ( string );
yylex_destroy ();
if ( parser_retv != 0 ) {
return TRUE;
}
return FALSE;
}
#endif

View file

@ -3,6 +3,7 @@
#include "widgets/widget-internal.h"
#include "theme.h"
/** Default padding. */
#define WIDGET_DEFAULT_PADDING 2
void widget_init ( widget *widget, const char *name )