Re-Indent code

This commit is contained in:
Dave Davenport 2017-04-27 22:59:14 +02:00
parent b1ecb6ca77
commit ce4b1b23b4
17 changed files with 118 additions and 105 deletions

View File

@ -116,7 +116,6 @@ typedef enum
P_HIGHLIGHT,
} PropertyType;
/**
* Represent the color in theme.
*/

View File

@ -280,5 +280,10 @@ void rofi_view_workers_finalize ( void );
* @returns the current monitor workarea
*/
void rofi_view_get_current_monitor ( int *width, int *height );
/**
* Takes a screenshot.
*/
void rofi_capture_screenshot ( void );
/**@}*/
#endif

View File

@ -211,5 +211,5 @@ Mode *script_switcher_parse_setup ( const char *str )
gboolean script_switcher_is_valid ( const char *token )
{
return strchr ( token, ':') != NULL;
return strchr ( token, ':' ) != NULL;
}

View File

@ -679,7 +679,7 @@ char *rofi_expand_path ( const char *input )
unsigned int levenshtein ( const char *needle, const glong needlelen, const char *haystack, const glong haystacklen )
{
if ( needlelen == G_MAXLONG ){
if ( needlelen == G_MAXLONG ) {
// String to long, we cannot handle this.
return UINT_MAX;
}
@ -964,7 +964,6 @@ int helper_execute_command ( const char *wd, const char *cmd, int run_in_term )
return retv;
}
char *helper_get_theme_path ( const char *file )
{
char *filename = rofi_expand_path ( file );
@ -975,7 +974,8 @@ char *helper_get_theme_path ( const char *file )
if ( g_str_has_suffix ( file, ".rasi" ) ) {
filename = g_strdup ( file );
} else {
}
else {
filename = g_strconcat ( file, ".rasi", NULL );
}
// Check config directory.

View File

@ -283,13 +283,12 @@ static void print_list_of_modi ( int is_term )
}
}
printf ( " * %s%s%s%s\n",
active?"+":"" ,
is_term ? (active?color_green:color_red) : "",
active ? "+" : "",
is_term ? ( active ? color_green : color_red ) : "",
available_modi[i]->name,
is_term ? color_reset : ""
);
}
}
static void print_main_application_options ( int is_term )
{
@ -319,8 +318,8 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
print_options ();
printf ( "\n" );
x11_dump_monitor_layout ();
printf("\n");
printf("Detected modi:\n");
printf ( "\n" );
printf ( "Detected modi:\n" );
print_list_of_modi ( is_term );
printf ( "\n" );
printf ( "Compile time options:\n" );
@ -385,8 +384,8 @@ static void help_print_mode_not_found ( const char *mode )
{
int is_term = isatty ( fileno ( stdout ) );
fprintf ( stderr, "Mode %s%s%s is not found.\n",
is_term?color_red:"", mode, is_term?color_reset:"");
fprintf( stderr, "The following modi are known:\n");
is_term ? color_red : "", mode, is_term ? color_reset : "" );
fprintf ( stderr, "The following modi are known:\n" );
print_list_of_modi ( is_term );
printf ( "\n" );
}
@ -629,7 +628,7 @@ static int add_mode ( const char * token )
modi[num_modi] = mode;
num_modi++;
}
else if ( script_switcher_is_valid ( token ) ){
else if ( script_switcher_is_valid ( token ) ) {
// If not build in, use custom modi.
Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) {
@ -647,7 +646,7 @@ static gboolean setup_modi ( void )
char *switcher_str = g_strdup ( config.modi );
// Split token on ','. This modifies switcher_str.
for ( char *token = strtok_r ( switcher_str, sep, &savept ); token != NULL; token = strtok_r ( NULL, sep, &savept ) ) {
if ( add_mode ( token ) == -1 ){
if ( add_mode ( token ) == -1 ) {
help_print_mode_not_found ( token );
g_free ( switcher_str );
return TRUE;
@ -680,11 +679,12 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
{
if ( ev == NULL ) {
int status = xcb_connection_has_error ( xcb->connection );
if(status > 0) {
if ( status > 0 ) {
g_warning ( "The XCB connection to X server had a fatal error: %d", status );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE;
} else {
}
else {
g_warning ( "main_loop_x11_event_handler: ev == NULL, status == %d", status );
return G_SOURCE_CONTINUE;
}
@ -908,6 +908,11 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
return G_SOURCE_REMOVE;
}
static gboolean record ( void )
{
rofi_capture_screenshot ();
return G_SOURCE_CONTINUE;
}
/**
* @param argc number of input arguments.
* @param argv array of the input arguments.
@ -995,7 +1000,7 @@ int main ( int argc, char *argv[] )
xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
if ( xcb_connection_has_error ( xcb->connection ) ) {
g_warning( "Failed to open display: %s", display_str );
g_warning ( "Failed to open display: %s", display_str );
cleanup ();
return EXIT_FAILURE;
}
@ -1163,8 +1168,7 @@ int main ( int argc, char *argv[] )
if ( !dmenu_mode ) {
// setup_modi
if ( setup_modi () )
{
if ( setup_modi () ) {
cleanup ();
return EXIT_FAILURE;
}
@ -1215,6 +1219,11 @@ int main ( int argc, char *argv[] )
cleanup ();
return EXIT_SUCCESS;
}
unsigned int interval = 1;
if ( find_arg_uint ( "-record-screenshots", &interval ) ) {
g_timeout_add ( 1000 / (double) interval, record, NULL );
}
main_loop_source = g_water_xcb_source_new_for_connection ( NULL, xcb->connection, main_loop_x11_event_handler, NULL, NULL );
TICK_N ( "X11 Setup " );

View File

@ -173,7 +173,7 @@ static int lev_sort ( const void *p1, const void *p2, void *arg )
/**
* Stores a screenshot of Rofi at that point in time.
*/
static void menu_capture_screenshot ( void )
void rofi_capture_screenshot ( void )
{
const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
if ( CacheState.edit_surf == NULL ) {
@ -190,7 +190,7 @@ static void menu_capture_screenshot ( void )
GDateTime *now = g_date_time_new_now_local ();
// Format filename.
char *timestmp = g_date_time_format ( now, "rofi-%Y-%m-%d-%H%M" );
char *filename = g_strdup_printf ( "%s.png", timestmp );
char *filename = g_strdup_printf ( "%s-%05d.png", timestmp, 0 );
// Build full path
char *fpath = NULL;
if ( outp == NULL ) {
@ -202,7 +202,7 @@ static void menu_capture_screenshot ( void )
// Try the next index.
index++;
// Format filename.
filename = g_strdup_printf ( "%s-%d.png", timestmp, index );
filename = g_strdup_printf ( "%s-%05d.png", timestmp, index );
// Build full path
fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
}
@ -771,18 +771,18 @@ void __create_window ( MenuFlags menu_flags )
TICK_N ( "done" );
// Set the PID.
pid_t pid= getpid ();
xcb_ewmh_set_wm_pid (&(xcb->ewmh), CacheState.main_window, pid );
pid_t pid = getpid ();
xcb_ewmh_set_wm_pid ( &( xcb->ewmh ), CacheState.main_window, pid );
// Get hostname
const char *hostname = g_get_host_name ();
char *ahost = g_hostname_to_ascii ( hostname );
if ( ahost != NULL ) {
xcb_icccm_set_wm_client_machine(xcb->connection,
xcb_icccm_set_wm_client_machine ( xcb->connection,
CacheState.main_window,
XCB_ATOM_STRING, 8,
strlen(ahost), ahost);
g_free(ahost);
strlen ( ahost ), ahost );
g_free ( ahost );
}
}
@ -1164,7 +1164,7 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
xcb_flush ( xcb->connection );
break;
case SCREENSHOT:
menu_capture_screenshot ( );
rofi_capture_screenshot ( );
break;
case TOGGLE_SORT:
if ( state->case_indicator != NULL ) {