1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-02-10 15:44:41 -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; char *pidfile = NULL;
const char *cache_dir = NULL; const char *cache_dir = NULL;
/** List of error messages.*/
GList *list_of_error_msgs = NULL; GList *list_of_error_msgs = NULL;
void rofi_add_error_message ( GString *str ) void rofi_add_error_message ( GString *str )
{ {
list_of_error_msgs = g_list_append ( list_of_error_msgs, str ); list_of_error_msgs = g_list_append ( list_of_error_msgs, str );
@ -376,7 +376,6 @@ static void cleanup ()
g_free ( config_path ); g_free ( config_path );
if ( list_of_error_msgs ) { if ( list_of_error_msgs ) {
for ( GList *iter = g_list_first ( list_of_error_msgs ); for ( GList *iter = g_list_first ( list_of_error_msgs );
iter != NULL; iter = g_list_next ( iter ) ) { iter != NULL; iter = g_list_next ( iter ) ) {
@ -678,14 +677,15 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
config_sanity_check ( ); config_sanity_check ( );
TICK_N ( "Config sanity check" ); TICK_N ( "Config sanity check" );
if ( list_of_error_msgs != NULL ) { if ( list_of_error_msgs != NULL ) {
GString *emesg = g_string_new ( "The following errors where detected when starting rofi:\n" ); GString *emesg = g_string_new ( "The following errors where detected when starting rofi:\n" );
GList *iter = g_list_first ( list_of_error_msgs ); 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 ); GString *msg = (GString *) ( iter->data );
g_string_append ( emesg, "\n\n" ); g_string_append ( emesg, "\n\n" );
g_string_append ( emesg, msg->str ); g_string_append ( emesg, msg->str );
index++;
} }
if ( g_list_length ( iter ) > 1 ) { if ( g_list_length ( iter ) > 1 ) {
g_string_append_printf ( emesg, "\nThere are <b>%d</b> more errors.", 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" ); TICK_N ( "Parse theme" );
if ( !rofi_theme_parse_file ( config.theme ) ) { if ( !rofi_theme_parse_file ( config.theme ) ) {
// TODO: instantiate fallback theme.? // TODO: instantiate fallback theme.?
} }
TICK_N ( "Parsed theme" ); TICK_N ( "Parsed theme" );
} }

View file

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

View file

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