1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

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, P_HIGHLIGHT,
} PropertyType; } PropertyType;
/** /**
* Represent the color in theme. * Represent the color in theme.
*/ */

View file

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

View file

@ -211,5 +211,5 @@ Mode *script_switcher_parse_setup ( const char *str )
gboolean script_switcher_is_valid ( const char *token ) 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 ) 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. // String to long, we cannot handle this.
return UINT_MAX; return UINT_MAX;
} }
@ -964,7 +964,6 @@ int helper_execute_command ( const char *wd, const char *cmd, int run_in_term )
return retv; return retv;
} }
char *helper_get_theme_path ( const char *file ) char *helper_get_theme_path ( const char *file )
{ {
char *filename = rofi_expand_path ( 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" ) ) { if ( g_str_has_suffix ( file, ".rasi" ) ) {
filename = g_strdup ( file ); filename = g_strdup ( file );
} else { }
else {
filename = g_strconcat ( file, ".rasi", NULL ); filename = g_strconcat ( file, ".rasi", NULL );
} }
// Check config directory. // Check config directory.

View file

@ -283,13 +283,12 @@ static void print_list_of_modi ( int is_term )
} }
} }
printf ( " * %s%s%s%s\n", printf ( " * %s%s%s%s\n",
active?"+":"" , active ? "+" : "",
is_term ? (active?color_green:color_red) : "", is_term ? ( active ? color_green : color_red ) : "",
available_modi[i]->name, available_modi[i]->name,
is_term ? color_reset : "" is_term ? color_reset : ""
); );
} }
} }
static void print_main_application_options ( int is_term ) 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 (); print_options ();
printf ( "\n" ); printf ( "\n" );
x11_dump_monitor_layout (); x11_dump_monitor_layout ();
printf("\n"); printf ( "\n" );
printf("Detected modi:\n"); printf ( "Detected modi:\n" );
print_list_of_modi ( is_term ); print_list_of_modi ( is_term );
printf ( "\n" ); printf ( "\n" );
printf ( "Compile time options:\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 ) ); int is_term = isatty ( fileno ( stdout ) );
fprintf ( stderr, "Mode %s%s%s is not found.\n", fprintf ( stderr, "Mode %s%s%s is not found.\n",
is_term?color_red:"", mode, is_term?color_reset:""); is_term ? color_red : "", mode, is_term ? color_reset : "" );
fprintf( stderr, "The following modi are known:\n"); fprintf ( stderr, "The following modi are known:\n" );
print_list_of_modi ( is_term ); print_list_of_modi ( is_term );
printf ( "\n" ); printf ( "\n" );
} }
@ -629,7 +628,7 @@ static int add_mode ( const char * token )
modi[num_modi] = mode; modi[num_modi] = mode;
num_modi++; num_modi++;
} }
else if ( script_switcher_is_valid ( token ) ){ else if ( script_switcher_is_valid ( token ) ) {
// If not build in, use custom modi. // If not build in, use custom modi.
Mode *sw = script_switcher_parse_setup ( token ); Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) { if ( sw != NULL ) {
@ -647,7 +646,7 @@ static gboolean setup_modi ( void )
char *switcher_str = g_strdup ( config.modi ); char *switcher_str = g_strdup ( config.modi );
// Split token on ','. This modifies switcher_str. // Split token on ','. This modifies switcher_str.
for ( char *token = strtok_r ( switcher_str, sep, &savept ); token != NULL; token = strtok_r ( NULL, sep, &savept ) ) { 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 ); help_print_mode_not_found ( token );
g_free ( switcher_str ); g_free ( switcher_str );
return TRUE; return TRUE;
@ -680,11 +679,12 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
{ {
if ( ev == NULL ) { if ( ev == NULL ) {
int status = xcb_connection_has_error ( xcb->connection ); 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_warning ( "The XCB connection to X server had a fatal error: %d", status );
g_main_loop_quit ( main_loop ); g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} else { }
else {
g_warning ( "main_loop_x11_event_handler: ev == NULL, status == %d", status ); g_warning ( "main_loop_x11_event_handler: ev == NULL, status == %d", status );
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }
@ -908,6 +908,11 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
static gboolean record ( void )
{
rofi_capture_screenshot ();
return G_SOURCE_CONTINUE;
}
/** /**
* @param argc number of input arguments. * @param argc number of input arguments.
* @param argv array of the 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 ); xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
if ( xcb_connection_has_error ( xcb->connection ) ) { 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 (); cleanup ();
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -1163,8 +1168,7 @@ int main ( int argc, char *argv[] )
if ( !dmenu_mode ) { if ( !dmenu_mode ) {
// setup_modi // setup_modi
if ( setup_modi () ) if ( setup_modi () ) {
{
cleanup (); cleanup ();
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -1215,6 +1219,11 @@ int main ( int argc, char *argv[] )
cleanup (); cleanup ();
return EXIT_SUCCESS; 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 ); main_loop_source = g_water_xcb_source_new_for_connection ( NULL, xcb->connection, main_loop_x11_event_handler, NULL, NULL );
TICK_N ( "X11 Setup " ); 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. * 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" ); const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
if ( CacheState.edit_surf == NULL ) { if ( CacheState.edit_surf == NULL ) {
@ -190,7 +190,7 @@ static void menu_capture_screenshot ( void )
GDateTime *now = g_date_time_new_now_local (); GDateTime *now = g_date_time_new_now_local ();
// Format filename. // Format filename.
char *timestmp = g_date_time_format ( now, "rofi-%Y-%m-%d-%H%M" ); 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 // Build full path
char *fpath = NULL; char *fpath = NULL;
if ( outp == NULL ) { if ( outp == NULL ) {
@ -202,7 +202,7 @@ static void menu_capture_screenshot ( void )
// Try the next index. // Try the next index.
index++; index++;
// Format filename. // Format filename.
filename = g_strdup_printf ( "%s-%d.png", timestmp, index ); filename = g_strdup_printf ( "%s-%05d.png", timestmp, index );
// Build full path // Build full path
fpath = g_build_filename ( xdg_pict_dir, filename, NULL ); fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
} }
@ -771,18 +771,18 @@ void __create_window ( MenuFlags menu_flags )
TICK_N ( "done" ); TICK_N ( "done" );
// Set the PID. // Set the PID.
pid_t pid= getpid (); pid_t pid = getpid ();
xcb_ewmh_set_wm_pid (&(xcb->ewmh), CacheState.main_window, pid ); xcb_ewmh_set_wm_pid ( &( xcb->ewmh ), CacheState.main_window, pid );
// Get hostname // Get hostname
const char *hostname = g_get_host_name (); const char *hostname = g_get_host_name ();
char *ahost = g_hostname_to_ascii ( hostname ); char *ahost = g_hostname_to_ascii ( hostname );
if ( ahost != NULL ) { if ( ahost != NULL ) {
xcb_icccm_set_wm_client_machine(xcb->connection, xcb_icccm_set_wm_client_machine ( xcb->connection,
CacheState.main_window, CacheState.main_window,
XCB_ATOM_STRING, 8, XCB_ATOM_STRING, 8,
strlen(ahost), ahost); strlen ( ahost ), ahost );
g_free(ahost); g_free ( ahost );
} }
} }
@ -1164,7 +1164,7 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
xcb_flush ( xcb->connection ); xcb_flush ( xcb->connection );
break; break;
case SCREENSHOT: case SCREENSHOT:
menu_capture_screenshot ( ); rofi_capture_screenshot ( );
break; break;
case TOGGLE_SORT: case TOGGLE_SORT:
if ( state->case_indicator != NULL ) { if ( state->case_indicator != NULL ) {