mirror of
https://github.com/lbonn/rofi
synced 2024-11-10 14:24:27 +00:00
Better error reporting (1)
This commit is contained in:
parent
a199fa3275
commit
854aa55453
7 changed files with 55 additions and 20 deletions
|
@ -36,6 +36,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
|
||||
*
|
||||
|
|
|
@ -342,7 +342,6 @@ if ( queue == NULL ){
|
|||
return T_ERROR;
|
||||
}
|
||||
<*>. {
|
||||
fprintf(stderr, "Invalid character: '%c'\n", *yytext);
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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" );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue