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:
parent
ca01af6338
commit
25dff63006
8 changed files with 49 additions and 47 deletions
|
@ -48,16 +48,16 @@ typedef struct
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
} TextboxFlags;
|
||||
/**
|
||||
* Flags indicating current state of the textbox.
|
||||
|
|
|
@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
|
|||
// Reading one line per time.
|
||||
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
|
||||
// Evaluate one line.
|
||||
unsigned int index = 0, ti = 0;
|
||||
unsigned int index = 0, ti = 0;
|
||||
char *token = buffer;
|
||||
|
||||
// Tokenize it.
|
||||
|
|
|
@ -248,7 +248,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
|
|||
}
|
||||
|
||||
char *saveptr = NULL, *token;
|
||||
GRegex **retv = NULL;
|
||||
GRegex **retv = NULL;
|
||||
if ( !config.tokenize ) {
|
||||
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
|
||||
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
|
||||
|
|
|
@ -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,11 +376,10 @@ 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);
|
||||
iter != NULL; iter = g_list_next ( iter ) ) {
|
||||
g_string_free ( (GString *) iter->data, TRUE );
|
||||
}
|
||||
g_list_free ( list_of_error_msgs );
|
||||
}
|
||||
|
@ -412,7 +411,7 @@ static int add_mode ( const char * token )
|
|||
}
|
||||
else
|
||||
#endif // WINDOW_MODE
|
||||
// SSh dialog
|
||||
// SSh dialog
|
||||
if ( strcasecmp ( token, "ssh" ) == 0 ) {
|
||||
modi[num_modi] = &ssh_mode;
|
||||
num_modi++;
|
||||
|
@ -678,17 +677,18 @@ 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 ) {
|
||||
GString *msg = (GString*)(iter->data);
|
||||
g_string_append( emesg, "\n\n");
|
||||
GString *emesg = g_string_new ( "The following errors where detected when starting rofi:\n" );
|
||||
GList *iter = g_list_first ( list_of_error_msgs );
|
||||
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 );
|
||||
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 );
|
||||
|
@ -979,9 +979,8 @@ int main ( int argc, char *argv[] )
|
|||
|
||||
if ( config.theme ) {
|
||||
TICK_N ( "Parse theme" );
|
||||
if ( ! rofi_theme_parse_file ( config.theme ) ) {
|
||||
if ( !rofi_theme_parse_file ( config.theme ) ) {
|
||||
// TODO: instantiate fallback theme.?
|
||||
|
||||
}
|
||||
TICK_N ( "Parsed theme" );
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
/** Logging domain for theme */
|
||||
#define LOG_DOMAIN "Theme"
|
||||
|
||||
void yyerror ( YYLTYPE *ylloc, const char *,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;
|
||||
|
@ -257,20 +257,21 @@ 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.
|
||||
*/
|
||||
void yyerror ( YYLTYPE *yylloc, const char *what, const char* s )
|
||||
{
|
||||
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);
|
||||
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: <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 );
|
||||
char *esc = g_markup_escape_text ( s, -1 );
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -867,11 +868,11 @@ gboolean rofi_theme_parse_file ( const char *file )
|
|||
extern const char*input_str;
|
||||
str_len = 0;
|
||||
input_str = NULL;
|
||||
int parser_retv = yyparse(file);
|
||||
int parser_retv = yyparse ( file );
|
||||
yylex_destroy ();
|
||||
g_free ( filename );
|
||||
yyin = NULL;
|
||||
if ( parser_retv != 0 ){
|
||||
if ( parser_retv != 0 ) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -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 ();
|
||||
return TRUE;
|
||||
if ( parser_retv != 0 ) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "widgets/container.h"
|
||||
#include "theme.h"
|
||||
|
||||
#define LOG_DOMAIN "Widgets.Window"
|
||||
#define LOG_DOMAIN "Widgets.Window"
|
||||
|
||||
struct _window
|
||||
{
|
||||
|
|
|
@ -532,12 +532,12 @@ void listview_nav_page_next ( listview *lv )
|
|||
|
||||
static int listview_get_desired_height ( widget *wid )
|
||||
{
|
||||
listview *lv = (listview *) wid;
|
||||
listview *lv = (listview *) wid;
|
||||
if ( lv == NULL || lv->widget.enabled == FALSE ) {
|
||||
return 0;
|
||||
}
|
||||
int spacing = distance_get_pixel ( lv->spacing, ORIENTATION_VERTICAL );
|
||||
int h = lv->menu_lines;
|
||||
int h = lv->menu_lines;
|
||||
if ( !( lv->fixed_num_lines ) ) {
|
||||
if ( lv->dynamic ) {
|
||||
h = MIN ( lv->menu_lines, lv->req_elements );
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include "widgets/widget-internal.h"
|
||||
#include "theme.h"
|
||||
|
||||
#define WIDGET_DEFAULT_PADDING 2
|
||||
/** Default padding. */
|
||||
#define WIDGET_DEFAULT_PADDING 2
|
||||
|
||||
void widget_init ( widget *widget, const char *name )
|
||||
{
|
||||
|
@ -113,13 +114,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 );
|
||||
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 );
|
||||
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