mirror of
https://github.com/davatorium/rofi.git
synced 2025-07-31 21:59:25 -04:00
Indent.
This commit is contained in:
parent
bbe4a3d330
commit
760a634731
3 changed files with 73 additions and 61 deletions
|
@ -63,6 +63,7 @@ static char **get_dmenu ( )
|
|||
int index = 0;
|
||||
|
||||
char buffer[1024];
|
||||
|
||||
while ( fgets( buffer, 1024, stdin ) != NULL ) {
|
||||
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
|
||||
retv[index] = strdup( buffer );
|
||||
|
@ -122,6 +123,7 @@ SwitcherMode dmenu_switcher_dialog ( char **input )
|
|||
for ( unsigned int i=0; list[i] != NULL; i++ ) {
|
||||
free( list[i] );
|
||||
}
|
||||
|
||||
free( list );
|
||||
|
||||
return retv;
|
||||
|
|
|
@ -96,17 +96,19 @@ static struct json_object * read_json_file_descr(FILE *fd)
|
|||
while ( ( len = fread( buffer, 1, 64, fd ) ) > 0 ) {
|
||||
jo = json_tokener_parse_ex( tok, buffer, len );
|
||||
|
||||
if((err = json_tokener_get_error(tok)) != json_tokener_continue)
|
||||
{
|
||||
if ( ( err = json_tokener_get_error( tok ) ) != json_tokener_continue ) {
|
||||
if ( err != json_tokener_success ) {
|
||||
fprintf( stderr, "Error parsing json file: %s\n", json_tokener_error_desc( err ) );
|
||||
jo = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get reference before we destroy the tokener.
|
||||
if ( jo ) json_object_get( jo );
|
||||
|
||||
json_tokener_free( tok );
|
||||
return jo;
|
||||
}
|
||||
|
@ -120,21 +122,21 @@ static pmenu *get_json ( )
|
|||
#endif
|
||||
|
||||
struct json_object *jo = NULL;
|
||||
|
||||
if ( json_input_file != NULL ) {
|
||||
if ( json_input_file[0] == '-' && json_input_file[1] == '\0' ) {
|
||||
jo = read_json_file_descr( stdin );
|
||||
}
|
||||
else if (json_input_file[0] == '{' && strlen(json_input_file) > 3) {
|
||||
} else if ( json_input_file[0] == '{' && strlen( json_input_file ) > 3 ) {
|
||||
jo = json_tokener_parse( json_input_file );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FILE *fd = fopen( json_input_file, "r" );
|
||||
|
||||
if ( fd == NULL ) {
|
||||
fprintf( stderr, "Failed to open file: %s: %s\n",
|
||||
json_input_file, strerror( errno ) );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jo = read_json_file_descr( fd );
|
||||
fclose( fd );
|
||||
|
||||
|
@ -146,16 +148,20 @@ static pmenu *get_json ( )
|
|||
json_object_put( jo );
|
||||
jo = NULL;
|
||||
}
|
||||
|
||||
// Create error and exit.
|
||||
if ( jo == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pmenu *retv = allocate_clear( sizeof( *retv ) );
|
||||
|
||||
struct json_object *jo2;
|
||||
|
||||
if ( json_object_object_get_ex( jo, "prompt", &jo2 ) ) {
|
||||
retv->prompt = strdup( json_object_get_string( jo2 ) );
|
||||
}
|
||||
|
||||
if ( json_object_object_get_ex( jo, "run-in-terminal", &jo2 ) ) {
|
||||
retv->execute_in_term = json_object_get_int( jo2 );
|
||||
}
|
||||
|
@ -172,6 +178,7 @@ static pmenu *get_json ( )
|
|||
retv->num_entries++;
|
||||
}
|
||||
}
|
||||
|
||||
json_object_put( jo );
|
||||
|
||||
|
||||
|
@ -227,13 +234,16 @@ SwitcherMode json_switcher_dialog ( char **input )
|
|||
} else {
|
||||
fprintf( stderr, "No commands found in json file\n" );
|
||||
}
|
||||
|
||||
for ( unsigned int i=0; i < list->num_entries; i++ ) {
|
||||
free( list->entries[i] );
|
||||
free( list->commands[i] );
|
||||
}
|
||||
|
||||
if ( list->entries )free( list->entries );
|
||||
|
||||
if ( list->commands )free( list->commands );
|
||||
|
||||
if ( list->prompt )free( list->prompt );
|
||||
|
||||
return retv;
|
||||
|
|
|
@ -1202,8 +1202,7 @@ void run_switcher( int fmode, SwitcherMode mode )
|
|||
#endif // __QC_MODE__
|
||||
else if ( mode == JSON_DIALOG ) {
|
||||
retv = json_switcher_dialog ( &input );
|
||||
}
|
||||
else if ( mode == DMENU_DIALOG ) {
|
||||
} else if ( mode == DMENU_DIALOG ) {
|
||||
retv = dmenu_switcher_dialog ( &input );
|
||||
}
|
||||
|
||||
|
@ -1398,6 +1397,7 @@ int main( int argc, char *argv[] )
|
|||
find_arg_int( argc, argv, "-lines",&( config.menu_lines ) );
|
||||
|
||||
find_arg_int( argc, argv, "-loc", &( config.location ) );
|
||||
|
||||
if ( find_arg( argc, argv, "-hmode" ) >= 0 ) {
|
||||
config.wmode = HORIZONTAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue