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