diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-01-08 21:36:06 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-01-08 21:36:06 +0100 |
commit | baab2047adf24642cbc727b50a77dc544e934a76 (patch) | |
tree | f9437dda9ae91d4e59b67231eec2cb3b51a1fe93 /source | |
parent | 8c0c43952dceb78d717f036478b4d66c75267a3b (diff) |
Indent magic, rework makefile so lexer and yacc file are not passed.
Diffstat (limited to 'source')
-rw-r--r-- | source/dialogs/dmenu.c | 14 | ||||
-rw-r--r-- | source/dialogs/drun.c | 12 | ||||
-rw-r--r-- | source/dialogs/script.c | 2 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 2 | ||||
-rw-r--r-- | source/dialogs/window.c | 17 | ||||
-rw-r--r-- | source/helper.c | 22 | ||||
-rw-r--r-- | source/keyb.c | 2 | ||||
-rw-r--r-- | source/rofi.c | 93 | ||||
-rw-r--r-- | source/theme.c | 599 | ||||
-rw-r--r-- | source/view.c | 212 | ||||
-rw-r--r-- | source/widgets/box.c | 93 | ||||
-rw-r--r-- | source/widgets/container.c | 31 | ||||
-rw-r--r-- | source/widgets/listview.c | 104 | ||||
-rw-r--r-- | source/widgets/scrollbar.c | 40 | ||||
-rw-r--r-- | source/widgets/textbox.c | 82 | ||||
-rw-r--r-- | source/widgets/widget.c | 85 | ||||
-rw-r--r-- | source/x11-helper.c | 10 | ||||
-rw-r--r-- | source/xrmoptions.c | 108 |
18 files changed, 772 insertions, 756 deletions
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 3e5aaa66..d53e829c 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -137,21 +137,23 @@ static void async_read_callback ( GObject *source_object, GAsyncResult *res, gpo g_data_input_stream_read_upto_async ( pd->data_input_stream, &( pd->separator ), 1, G_PRIORITY_LOW, pd->cancel, async_read_callback, pd ); return; - } else { + } + else { GError *error = NULL; // Absorb separator, already in buffer so should not block. // If error == NULL end of stream.. - g_data_input_stream_read_byte ( stream, NULL, &error); + g_data_input_stream_read_byte ( stream, NULL, &error ); if ( error == NULL ) { // Add empty line. - read_add ( pd, "", 0); + read_add ( pd, "", 0 ); rofi_view_reload (); g_data_input_stream_read_upto_async ( pd->data_input_stream, &( pd->separator ), 1, G_PRIORITY_LOW, pd->cancel, - async_read_callback, pd ); + async_read_callback, pd ); return; - } else { - g_error_free (error); + } + else { + g_error_free ( error ); } } if ( !g_cancellable_is_cancelled ( pd->cancel ) ) { diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 4d07a1b6..5aa4dac7 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -192,7 +192,7 @@ static void exec_cmd_entry ( DRunModeEntry *e ) fprintf ( stderr, "Nothing to execute after processing: %s.\n", e->exec );; return; } - gchar *fp = rofi_expand_path ( g_strstrip ( str ) ); + gchar *fp = rofi_expand_path ( g_strstrip ( str ) ); gchar *exec_path = g_key_file_get_string ( e->key_file, "Desktop Entry", "Path", NULL ); if ( execsh ( exec_path, fp, e->terminal ) ) { char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL ); @@ -539,12 +539,12 @@ static int drun_token_match ( const Mode *data, GRegex **tokens, unsigned int in test = 1; } // Match against category. - if ( !test ){ - gchar **list = g_key_file_get_locale_string_list ( rmpd->entry_list[index].key_file, "Desktop Entry", "Categories" , NULL, NULL,NULL ); - for ( int iter = 0; !test && list && list[iter]; iter++){ - test = token_match ( ftokens, list[iter]); + if ( !test ) { + gchar **list = g_key_file_get_locale_string_list ( rmpd->entry_list[index].key_file, "Desktop Entry", "Categories", NULL, NULL, NULL ); + for ( int iter = 0; !test && list && list[iter]; iter++ ) { + test = token_match ( ftokens, list[iter] ); } - g_strfreev(list); + g_strfreev ( list ); } if ( test == 0 ) { match = 0; diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 86cd8bb5..2b018ff6 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -146,7 +146,7 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned rmpd->cmd_list = new_list; rmpd->cmd_list_length = new_length; - retv = RESET_DIALOG; + retv = RESET_DIALOG; } return retv; } diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index c0ba2f8c..8cfe68fd 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -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. diff --git a/source/dialogs/window.c b/source/dialogs/window.c index 0c779928..5e9d3be3 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -399,13 +399,12 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd ) // Check if we are in I3 mode. I3 has to be special and allow markup in it window name...... char *i3_socket_path = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), netatoms[I3_SOCKET_PATH] ); - if ( i3_socket_path != NULL ){ - g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Detected I3 Window manager running."); + if ( i3_socket_path != NULL ) { + g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Detected I3 Window manager running." ); pd->i3_mode = TRUE; g_free ( i3_socket_path ); } - // Create cache x11_cache_create (); @@ -488,15 +487,15 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd ) if ( has_names ) { if ( pd->i3_mode ) { char *output = NULL; - if (pango_parse_markup ( _window_name_list_entry ( names.strings, names.strings_len, - c->wmdesktop ),-1, 0, NULL, &output, NULL, NULL)){ + if ( pango_parse_markup ( _window_name_list_entry ( names.strings, names.strings_len, + c->wmdesktop ), -1, 0, NULL, &output, NULL, NULL ) ) { c->wmdesktopstr = output; } else { - c->wmdesktopstr = g_strdup ( "Invalid name"); + c->wmdesktopstr = g_strdup ( "Invalid name" ); } - - } else { + } + else { c->wmdesktopstr = g_strdup ( _window_name_list_entry ( names.strings, names.strings_len, c->wmdesktop ) ); } } @@ -634,7 +633,7 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i } } else if ( ( mretv & ( MENU_ENTRY_DELETE ) ) == MENU_ENTRY_DELETE ) { - xcb_ewmh_request_close_window ( &(xcb->ewmh), xcb->screen_nbr, rmpd->ids->array[selected_line], XCB_CURRENT_TIME, XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER); + xcb_ewmh_request_close_window ( &( xcb->ewmh ), xcb->screen_nbr, rmpd->ids->array[selected_line], XCB_CURRENT_TIME, XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER ); xcb_flush ( xcb->connection ); } return retv; diff --git a/source/helper.c b/source/helper.c index bbaf03c3..84307bdd 100644 --- a/source/helper.c +++ b/source/helper.c @@ -181,11 +181,13 @@ static gchar *fuzzy_to_regex ( const char * input ) else { g_string_append ( str, ".*(" ); } - if ( *iter == '\\' ){ - g_string_append_c ( str, '\\'); + if ( *iter == '\\' ) { + g_string_append_c ( str, '\\' ); iter = g_utf8_next_char ( iter ); // If EOL, break out of for loop. - if ( (*iter) == '\0' ) break; + if ( ( *iter ) == '\0' ) { + break; + } } g_string_append_unichar ( str, g_utf8_get_char ( iter ) ); g_string_append ( str, ")" ); @@ -246,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 ); @@ -297,19 +299,19 @@ int find_arg_str ( const char * const key, char** val ) const char ** find_arg_strv ( const char *const key ) { - const char **retv =NULL; - int length = 0; + const char **retv = NULL; + int length = 0; for ( int i = 0; i < stored_argc; i++ ) { - if ( strcasecmp ( stored_argv[i], key ) == 0 && i < (stored_argc -1 ) ){ + if ( strcasecmp ( stored_argv[i], key ) == 0 && i < ( stored_argc - 1 ) ) { length++; } } if ( length > 0 ) { - retv = g_malloc0((length+1)*sizeof(char*)); + retv = g_malloc0 ( ( length + 1 ) * sizeof ( char* ) ); int index = 0; for ( int i = 0; i < stored_argc; i++ ) { - if ( strcasecmp ( stored_argv[i], key ) == 0 && i < (stored_argc -1 ) ){ - retv[index++] = stored_argv[i+1]; + if ( strcasecmp ( stored_argv[i], key ) == 0 && i < ( stored_argc - 1 ) ) { + retv[index++] = stored_argv[i + 1]; } } } diff --git a/source/keyb.c b/source/keyb.c index 71aedd3e..049887fc 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -193,7 +193,7 @@ KeyBindingAction abe_find_action ( unsigned int mask, xkb_keysym_t key ) void abe_trigger_release ( void ) { - RofiViewState *state; + RofiViewState *state; state = rofi_view_get_active ( ); if ( state ) { diff --git a/source/rofi.c b/source/rofi.c index 38db3e66..24e2f28c 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -270,46 +270,47 @@ static void help ( G_GNUC_UNUSED int argc, char **argv ) printf ( "\n" ); x11_dump_monitor_layout (); printf ( "\n" ); - printf ( "Compile time options:\n"); + printf ( "Compile time options:\n" ); #ifdef WINDOW_MODE - printf ( "\t* window %senabled%s\n", is_term?color_green:"", is_term?color_reset:""); + printf ( "\t* window %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" ); #else - printf ( "\t* window %sdisabled%s\n", is_term?color_red:"", is_term?color_reset:""); + printf ( "\t* window %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" ); #endif #ifdef ENABLE_DRUN - printf ( "\t* drun %senabled%s\n", is_term?color_green:"", is_term?color_reset:""); + printf ( "\t* drun %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" ); #else - printf ( "\t* drun %sdisabled%s\n", is_term?color_red:"", is_term?color_reset:""); + printf ( "\t* drun %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" ); #endif #ifdef TIMINGS - printf ( "\t* timings %senabled%s\n", is_term?color_green:"", is_term?color_reset:""); + printf ( "\t* timings %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" ); #else - printf ( "\t* timings %sdisabled%s\n", is_term?color_red:"", is_term?color_reset:""); + printf ( "\t* timings %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" ); #endif #ifdef ENABLE_GCOV - printf ( "\t* gcov %senabled%s\n", is_term?color_green:"", is_term?color_reset:""); + printf ( "\t* gcov %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" ); #else - printf ( "\t* gcov %sdisabled%s\n", is_term?color_red:"", is_term?color_reset:""); + printf ( "\t* gcov %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" ); #endif #ifdef ENABLE_ASAN - printf ( "\t* asan %senabled%s\n", is_term?color_green:"", is_term?color_reset:""); + printf ( "\t* asan %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" ); #else - printf ( "\t* asan %sdisabled%s\n", is_term?color_red:"", is_term?color_reset:""); + printf ( "\t* asan %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" ); #endif printf ( "\n" ); - printf ( "For more information see: %sman rofi%s\n", is_term?color_bold:"",is_term?color_reset:"" ); + printf ( "For more information see: %sman rofi%s\n", is_term ? color_bold : "", is_term ? color_reset : "" ); #ifdef GIT_VERSION - printf ( " Version: %s"GIT_VERSION "%s\n", is_term?color_bold:"",is_term?color_reset:"" ); + printf ( " Version: %s"GIT_VERSION "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" ); #else - printf ( " Version: %s"VERSION "%s\n", is_term?color_bold:"",is_term?color_reset:"" ); + printf ( " Version: %s"VERSION "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" ); #endif - printf ( " Bugreports: %s"PACKAGE_BUGREPORT "%s\n", is_term?color_bold:"",is_term?color_reset:"" ); - printf ( " Support: %s"PACKAGE_URL "%s\n", is_term?color_bold:"",is_term?color_reset:"" ); - printf ( " %s#rofi @ freenode.net%s\n", is_term?color_bold:"",is_term?color_reset:"" ); + printf ( " Bugreports: %s"PACKAGE_BUGREPORT "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" ); + printf ( " Support: %s"PACKAGE_URL "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" ); + printf ( " %s#rofi @ freenode.net%s\n", is_term ? color_bold : "", is_term ? color_reset : "" ); if ( find_arg ( "-no-config" ) < 0 ) { - printf ( " Configuration file: %s%s%s\n", is_term?color_bold:"", config_path, is_term?color_reset:"" ); - } else { - printf ( " Configuration file: %sDisabled%s\n", is_term?color_bold:"", is_term?color_reset:"" ); + printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path, is_term ? color_reset : "" ); + } + else { + printf ( " Configuration file: %sDisabled%s\n", is_term ? color_bold : "", is_term ? color_reset : "" ); } } @@ -396,7 +397,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++; @@ -489,7 +490,8 @@ static inline void load_configuration_dynamic ( ) /** * Process X11 events in the main-loop (gui-thread) of the application. */ -static void main_loop_x11_event_handler_view ( xcb_generic_event_t *ev){ +static void main_loop_x11_event_handler_view ( xcb_generic_event_t *ev ) +{ RofiViewState *state = rofi_view_get_active (); if ( state != NULL ) { rofi_view_itterrate ( state, ev, &xkb ); @@ -585,12 +587,12 @@ unsigned int lazy_grab_retry_count_pt = 0; static gboolean lazy_grab_pointer ( G_GNUC_UNUSED gpointer data ) { // After 5 sec. - if ( lazy_grab_retry_count_kb > (5*1000)) { - fprintf(stderr, "Failed to grab keyboard after %u times. Giving up.\n", lazy_grab_retry_count_kb); + if ( lazy_grab_retry_count_kb > ( 5 * 1000 ) ) { + fprintf ( stderr, "Failed to grab keyboard after %u times. Giving up.\n", lazy_grab_retry_count_kb ); g_main_loop_quit ( main_loop ); return G_SOURCE_REMOVE; } - if ( take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ){ + if ( take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { return G_SOURCE_REMOVE; } lazy_grab_retry_count_kb++; @@ -599,11 +601,11 @@ static gboolean lazy_grab_pointer ( G_GNUC_UNUSED gpointer data ) static gboolean lazy_grab_keyboard ( G_GNUC_UNUSED gpointer data ) { // After 5 sec. - if ( lazy_grab_retry_count_pt > (5*1000)) { - fprintf(stderr, "Failed to grab pointer after %u times. Giving up.\n", lazy_grab_retry_count_pt); + if ( lazy_grab_retry_count_pt > ( 5 * 1000 ) ) { + fprintf ( stderr, "Failed to grab pointer after %u times. Giving up.\n", lazy_grab_retry_count_pt ); return G_SOURCE_REMOVE; } - if ( take_keyboard ( xcb_stuff_get_root_window ( xcb), 0 ) ){ + if ( take_keyboard ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { return G_SOURCE_REMOVE; } lazy_grab_retry_count_pt++; @@ -629,23 +631,23 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) // We grab this using the rootwindow (as dmenu does it). // this seems to result in the smallest delay for most people. if ( ( window_flags & MENU_NORMAL_WINDOW ) == 0 ) { - if ( find_arg ( "-lazy-grab") >= 0 ){ - if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 0) ){ - g_timeout_add ( 1,lazy_grab_keyboard, NULL); + if ( find_arg ( "-lazy-grab" ) >= 0 ) { + if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { + g_timeout_add ( 1, lazy_grab_keyboard, NULL ); } - if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 )) { - g_timeout_add ( 1,lazy_grab_pointer, NULL); + if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { + g_timeout_add ( 1, lazy_grab_pointer, NULL ); } - } else { - if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 500) ){ + } + else { + if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb ), 500 ) ) { fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); g_main_loop_quit ( main_loop ); return G_SOURCE_REMOVE; } - if ( ! take_pointer ( xcb_stuff_get_root_window ( xcb ), 100 ) ) { - fprintf ( stderr, "Failed to grab mouse pointer, even after %d uS.", 100*1000); + if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 100 ) ) { + fprintf ( stderr, "Failed to grab mouse pointer, even after %d uS.", 100 * 1000 ); } - } } TICK_N ( "Grab keyboard" ); @@ -949,26 +951,25 @@ int main ( int argc, char *argv[] ) TICK_N ( "Parse theme" ); rofi_theme_parse_file ( config.theme ); TICK_N ( "Parsed theme" ); - } else { + } + else { rofi_theme_convert_old_theme ( ); } const char ** theme_str = find_arg_strv ( "-theme-str" ); if ( theme_str ) { - for ( int index = 0; theme_str && theme_str[index]; index++ ){ - if ( ! rofi_theme_parse_string ( theme_str[index] ) ){ - fprintf(stderr, "Failed to parse: %s\n", theme_str[index]); + for ( int index = 0; theme_str && theme_str[index]; index++ ) { + if ( !rofi_theme_parse_string ( theme_str[index] ) ) { + fprintf ( stderr, "Failed to parse: %s\n", theme_str[index] ); exit ( EXIT_FAILURE ); } } g_free ( theme_str ); } - - - if ( find_arg ( "-dump-theme" ) >= 0 ){ + if ( find_arg ( "-dump-theme" ) >= 0 ) { rofi_theme_print ( rofi_theme ); - exit (EXIT_SUCCESS); + exit ( EXIT_SUCCESS ); } // Dump. // catch help request diff --git a/source/theme.c b/source/theme.c index ed8b7bd1..0defa28b 100644 --- a/source/theme.c +++ b/source/theme.c @@ -10,27 +10,27 @@ #include "view.h" /** Logging domain for theme */ -#define LOG_DOMAIN "Theme" +#define LOG_DOMAIN "Theme" -void yyerror ( YYLTYPE *ylloc, const char *); +void yyerror ( YYLTYPE *ylloc, const char * ); static gboolean distance_compare ( Distance d, Distance e ) { - return ( d.type == e.type && d.distance == e.distance && d.style == e.style ); + return d.type == e.type && d.distance == e.distance && d.style == e.style; } ThemeWidget *rofi_theme_find_or_create_name ( ThemeWidget *base, const char *name ) { - for ( unsigned int i = 0; i < base->num_widgets;i++){ - if ( g_strcmp0(base->widgets[i]->name, name) == 0 ){ + for ( unsigned int i = 0; i < base->num_widgets; i++ ) { + if ( g_strcmp0 ( base->widgets[i]->name, name ) == 0 ) { return base->widgets[i]; } } - base->widgets = g_realloc ( base->widgets, sizeof(ThemeWidget*)*(base->num_widgets+1)); - base->widgets[base->num_widgets] = g_malloc0(sizeof(ThemeWidget)); + base->widgets = g_realloc ( base->widgets, sizeof ( ThemeWidget* ) * ( base->num_widgets + 1 ) ); + base->widgets[base->num_widgets] = g_malloc0 ( sizeof ( ThemeWidget ) ); ThemeWidget *retv = base->widgets[base->num_widgets]; retv->parent = base; - retv->name = g_strdup(name); + retv->name = g_strdup ( name ); base->num_widgets++; return retv; } @@ -39,7 +39,7 @@ ThemeWidget *rofi_theme_find_or_create_name ( ThemeWidget *base, const char *nam */ Property *rofi_theme_property_create ( PropertyType type ) { - Property *retv = g_malloc0 ( sizeof(Property) ); + Property *retv = g_malloc0 ( sizeof ( Property ) ); retv->type = type; return retv; } @@ -51,21 +51,22 @@ void rofi_theme_property_free ( Property *p ) g_free ( p->name ); if ( p->type == P_STRING ) { g_free ( p->value.s ); - } else if ( p->type == P_LINK ) { + } + else if ( p->type == P_LINK ) { g_free ( p->value.link.name ); } - g_free(p); + g_free ( p ); } void rofi_theme_free ( ThemeWidget *widget ) { - if ( widget == NULL ){ + if ( widget == NULL ) { return; } if ( widget->properties ) { g_hash_table_destroy ( widget->properties ); } - for ( unsigned int i = 0; i < widget->num_widgets; i++ ){ + for ( unsigned int i = 0; i < widget->num_widgets; i++ ) { rofi_theme_free ( widget->widgets[i] ); } g_free ( widget->widgets ); @@ -79,14 +80,16 @@ void rofi_theme_free ( ThemeWidget *widget ) static void rofi_theme_print_distance ( Distance d ) { if ( d.type == PW_PX ) { - printf("%upx ", (int)d.distance ); - } else if ( d.type == PW_PERCENT ) { - printf("%f%% ", d.distance ); - } else { - printf("%fem ", d.distance ); + printf ( "%upx ", (int) d.distance ); + } + else if ( d.type == PW_PERCENT ) { + printf ( "%f%% ", d.distance ); + } + else { + printf ( "%fem ", d.distance ); } if ( d.style == DASH ) { - printf("dash "); + printf ( "dash " ); } } /** Textual representation of Window Location */ @@ -105,56 +108,59 @@ const char const * WindowLocationStr[9] = { static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p ) { int pl = strlen ( p->name ); - printf("%*s%s:%*s ", depth, "", p->name, (int)pnl-pl,"" ); + printf ( "%*s%s:%*s ", depth, "", p->name, (int) pnl - pl, "" ); switch ( p->type ) { - case P_POSITION: - printf("%s;", WindowLocationStr[p->value.i]); - break; - case P_STRING: - printf("\"%s\";", p->value.s); - break; - case P_INTEGER: - printf("%d;", p->value.i); - break; - case P_DOUBLE: - printf("%.2f;", p->value.f); - break; - case P_BOOLEAN: - printf("%s;", p->value.b?"true":"false"); - break; - case P_COLOR: - printf("#%02X%02X%02X%02X;", - (unsigned char)(p->value.color.alpha*255.0), - (unsigned char)(p->value.color.red*255.0), - (unsigned char)(p->value.color.green*255.0), - (unsigned char)(p->value.color.blue*255.0)); - break; - case P_PADDING: - if ( distance_compare ( p->value.padding.top, p->value.padding.bottom) && - distance_compare ( p->value.padding.left, p->value.padding.right) && - distance_compare ( p->value.padding.left, p->value.padding.top) ) { - rofi_theme_print_distance ( p->value.padding.left ); - } else if ( distance_compare ( p->value.padding.top, p->value.padding.bottom) && - distance_compare ( p->value.padding.left, p->value.padding.right)){ - rofi_theme_print_distance ( p->value.padding.top ); - rofi_theme_print_distance ( p->value.padding.left ); - } else if ( !distance_compare ( p->value.padding.top, p->value.padding.bottom) && - distance_compare ( p->value.padding.left, p->value.padding.right)){ - rofi_theme_print_distance ( p->value.padding.top ); - rofi_theme_print_distance ( p->value.padding.left ); - rofi_theme_print_distance ( p->value.padding.bottom); - } else { - rofi_theme_print_distance ( p->value.padding.top ); - rofi_theme_print_distance ( p->value.padding.right ); - rofi_theme_print_distance ( p->value.padding.bottom); - rofi_theme_print_distance ( p->value.padding.left ); - } - printf(";"); - break; - case P_LINK: - printf("%s;", p->value.link.name); - break; + case P_POSITION: + printf ( "%s;", WindowLocationStr[p->value.i] ); + break; + case P_STRING: + printf ( "\"%s\";", p->value.s ); + break; + case P_INTEGER: + printf ( "%d;", p->value.i ); + break; + case P_DOUBLE: + printf ( "%.2f;", p->value.f ); + break; + case P_BOOLEAN: + printf ( "%s;", p->value.b ? "true" : "false" ); + break; + case P_COLOR: + printf ( "#%02X%02X%02X%02X;", + (unsigned char) ( p->value.color.alpha * 255.0 ), + (unsigned char) ( p->value.color.red * 255.0 ), + (unsigned char) ( p->value.color.green * 255.0 ), + (unsigned char) ( p->value.color.blue * 255.0 ) ); + break; + case P_PADDING: + if ( distance_compare ( p->value.padding.top, p->value.padding.bottom ) && + distance_compare ( p->value.padding.left, p->value.padding.right ) && + distance_compare ( p->value.padding.left, p->value.padding.top ) ) { + rofi_theme_print_distance ( p->value.padding.left ); + } + else if ( distance_compare ( p->value.padding.top, p->value.padding.bottom ) && + distance_compare ( p->value.padding.left, p->value.padding.right ) ) { + rofi_theme_print_distance ( p->value.padding.top ); + rofi_theme_print_distance ( p->value.padding.left ); + } + else if ( !distance_compare ( p->value.padding.top, p->value.padding.bottom ) && + distance_compare ( p->value.padding.left, p->value.padding.right ) ) { + rofi_theme_print_distance ( p->value.padding.top ); + rofi_theme_print_distance ( p->value.padding.left ); + rofi_theme_print_distance ( p->value.padding.bottom ); + } + else { + rofi_theme_print_distance ( p->value.padding.top ); + rofi_theme_print_distance ( p->value.padding.right ); + rofi_theme_print_distance ( p->value.padding.bottom ); + rofi_theme_print_distance ( p->value.padding.left ); + } + printf ( ";" ); + break; + case P_LINK: + printf ( "%s;", p->value.link.name ); + break; } putchar ( '\n' ); } @@ -162,52 +168,51 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p static void rofi_theme_print_index ( ThemeWidget *widget ) { GHashTableIter iter; - gpointer key, value; - if ( widget->properties ){ - int index = 0; - GList *list = NULL; - ThemeWidget *w = widget; - while ( w){ - if ( g_strcmp0(w->name,"Root") == 0 ) { + gpointer key, value; + if ( widget->properties ) { + int index = 0; + GList *list = NULL; + ThemeWidget *w = widget; + while ( w ) { + if ( g_strcmp0 ( w->name, "Root" ) == 0 ) { break; } list = g_list_prepend ( list, w->name ); - w = w->parent; + w = w->parent; } if ( g_list_length ( list ) > 0 ) { index = 4; for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) { - char *name = (char *)iter->data; - if ( iter->prev == NULL ){ + char *name = (char *) iter->data; + if ( iter->prev == NULL ) { putchar ( '#' ); } - fputs(name, stdout); + fputs ( name, stdout ); if ( iter->next ) { - putchar('.'); + putchar ( '.' ); } } - printf(" {\n"); - } else { + printf ( " {\n" ); + } + else { index = 4; - printf("* {\n"); + printf ( "* {\n" ); } size_t property_name_length = 0; - g_hash_table_iter_init (&iter, widget->properties); - while (g_hash_table_iter_next (&iter, &key, &value)) - { - Property *p = (Property*)value; - property_name_length = MAX ( strlen (p->name), property_name_length ); + g_hash_table_iter_init ( &iter, widget->properties ); + while ( g_hash_table_iter_next ( &iter, &key, &value ) ) { + Property *p = (Property *) value; + property_name_length = MAX ( strlen ( p->name ), property_name_length ); } - g_hash_table_iter_init (&iter, widget->properties); - while (g_hash_table_iter_next (&iter, &key, &value)) - { - Property *p = (Property*)value; + g_hash_table_iter_init ( &iter, widget->properties ); + while ( g_hash_table_iter_next ( &iter, &key, &value ) ) { + Property *p = (Property *) value; rofi_theme_print_property_index ( property_name_length, index, p ); } - printf("}\n"); + printf ( "}\n" ); g_list_free ( list ); } - for ( unsigned int i = 0; i < widget->num_widgets;i++){ + for ( unsigned int i = 0; i < widget->num_widgets; i++ ) { rofi_theme_print_index ( widget->widgets[i] ); } } @@ -219,12 +224,12 @@ void rofi_theme_print ( ThemeWidget *widget ) /** * Main lex parser. */ -int yyparse(); +int yyparse (); /** * Destroy the internal of lex parser. */ -void yylex_destroy( void ); +void yylex_destroy ( void ); /** * Global handle input file to flex parser. @@ -237,16 +242,17 @@ extern FILE* yyin; * * Error handler for the lex parser. */ -void yyerror(YYLTYPE *yylloc, const char* s) { - fprintf(stderr, "Parse error: %s\n", s); - fprintf(stderr, "From line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column); - exit(EXIT_FAILURE); +void yyerror ( YYLTYPE *yylloc, const char* s ) +{ + fprintf ( stderr, "Parse error: %s\n", s ); + fprintf ( stderr, "From line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column ); + exit ( EXIT_FAILURE ); } -static gboolean rofi_theme_steal_property_int ( gpointer key, gpointer value, gpointer user_data) +stati |