diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-01-09 22:29:31 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-01-09 22:29:31 +0100 |
commit | ca01af6338382c75f31555160f40aa5385be6521 (patch) | |
tree | a7722edb1e926ba49ab107b09ab15c53ed71f161 /source | |
parent | b010da57d74922ba35e94e254417a569fa3097d5 (diff) |
Try to improve error handling and messages
Diffstat (limited to 'source')
-rw-r--r-- | source/rofi.c | 6 | ||||
-rw-r--r-- | source/theme.c | 15 | ||||
-rw-r--r-- | source/widgets/container.c | 3 | ||||
-rw-r--r-- | source/widgets/widget.c | 4 |
4 files changed, 17 insertions, 11 deletions
diff --git a/source/rofi.c b/source/rofi.c index 12b639c6..b64d5017 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -681,11 +681,15 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) 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 ) ) { + GList *iter = g_list_first ( list_of_error_msgs ); + if ( iter != NULL ) { GString *msg = (GString*)(iter->data); g_string_append( emesg, "\n\n"); g_string_append ( emesg, msg->str ); } + if ( g_list_length(iter)> 1 ){ + g_string_append_printf(emesg, "\nThere are <b>%d</b> more errors.", g_list_length(iter)-1 ); + } rofi_view_error_dialog ( emesg->str, ERROR_MSG_MARKUP ); g_string_free ( emesg, TRUE ); return G_SOURCE_REMOVE; diff --git a/source/theme.c b/source/theme.c index 65810073..6979b07d 100644 --- a/source/theme.c +++ b/source/theme.c @@ -12,7 +12,7 @@ /** Logging domain for theme */ #define LOG_DOMAIN "Theme" -void yyerror ( YYLTYPE *ylloc, const char * ); +void yyerror ( YYLTYPE *ylloc, const char *,const char * ); static gboolean distance_compare ( Distance d, Distance e ) { return d.type == e.type && d.distance == e.distance && d.style == e.style; @@ -261,11 +261,14 @@ extern FILE* yyin; * * Error handler for the lex parser. */ -void yyerror ( YYLTYPE *yylloc, const char* s ) +void yyerror ( YYLTYPE *yylloc, const char *what, const char* s ) { - GString *str = g_string_new ("<big><b>Error while parsing theme file:</b></big>\n"); + char *what_esc = g_markup_escape_text ( what, -1); + GString *str = g_string_new(""); + g_string_printf ( str, "<big><b>Error while parsing them:</b></big> <i>%s</i>\n", what_esc); + g_free ( what_esc ); char *esc = g_markup_escape_text ( s, -1); - g_string_append_printf(str, "\tParser error: %s\n", esc ); + g_string_append_printf(str, "\tParser error: <i>%s</i>\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 ); @@ -864,7 +867,7 @@ gboolean rofi_theme_parse_file ( const char *file ) extern const char*input_str; str_len = 0; input_str = NULL; - int parser_retv = yyparse(); + int parser_retv = yyparse(file); yylex_destroy (); g_free ( filename ); yyin = NULL; @@ -880,7 +883,7 @@ gboolean rofi_theme_parse_string ( const char *string ) yyin = NULL; input_str = string; str_len = strlen ( string ); - while ( yyparse () ) { + while ( yyparse (string) ) { ; } yylex_destroy (); diff --git a/source/widgets/container.c b/source/widgets/container.c index 51150287..d2fd6327 100644 --- a/source/widgets/container.c +++ b/source/widgets/container.c @@ -33,9 +33,6 @@ #define LOG_DOMAIN "Widgets.Window" -/** The default border width of the container */ -#define DEFAULT_BORDER_WIDTH 2 - struct _window { widget widget; diff --git a/source/widgets/widget.c b/source/widgets/widget.c index d17b3db9..03f21e4f 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -3,10 +3,12 @@ #include "widgets/widget-internal.h" #include "theme.h" +#define WIDGET_DEFAULT_PADDING 2 + void widget_init ( widget *widget, const char *name ) { widget->name = g_strdup ( name ); - widget->padding = (Padding){ { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID } }; + widget->padding = (Padding){ { WIDGET_DEFAULT_PADDING, PW_PX, SOLID }, { WIDGET_DEFAULT_PADDING, PW_PX, SOLID }, { WIDGET_DEFAULT_PADDING, PW_PX, SOLID }, { WIDGET_DEFAULT_PADDING, PW_PX, SOLID } }; widget->border = (Padding){ { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID } }; widget->margin = (Padding){ { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID } }; |