diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-03-04 19:41:06 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-03-04 19:41:06 +0100 |
commit | 3f4d58ef531a17d6667318a4e8f9390a383ffab6 (patch) | |
tree | 29aa6b8bd7c7420a236b3be2fd62404889d8ee53 | |
parent | 8ee37012d1b55e69a66fb88727b14c284b6a367f (diff) |
Indent code.
-rw-r--r-- | include/helper.h | 1 | ||||
-rw-r--r-- | include/mode-private.h | 12 | ||||
-rw-r--r-- | include/widgets/textbox.h | 20 | ||||
-rw-r--r-- | include/x11-helper.h | 12 | ||||
-rw-r--r-- | source/dialogs/combi.c | 8 | ||||
-rw-r--r-- | source/dialogs/dmenu.c | 4 | ||||
-rw-r--r-- | source/dialogs/run.c | 1 | ||||
-rw-r--r-- | source/dialogs/script.c | 4 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 5 | ||||
-rw-r--r-- | source/dialogs/window.c | 13 | ||||
-rw-r--r-- | source/helper.c | 6 | ||||
-rw-r--r-- | source/rofi.c | 46 | ||||
-rw-r--r-- | source/view.c | 14 | ||||
-rw-r--r-- | source/widgets/box.c | 8 | ||||
-rw-r--r-- | source/widgets/textbox.c | 4 | ||||
-rw-r--r-- | source/x11-helper.c | 22 |
16 files changed, 89 insertions, 91 deletions
diff --git a/include/helper.h b/include/helper.h index cccc1a24..a095a177 100644 --- a/include/helper.h +++ b/include/helper.h @@ -219,7 +219,6 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st */ int utf8_strncmp ( const char *a, const char* b, size_t n ); - /** * @param wd The work directory (optional) * @param cmd The cmd to execute diff --git a/include/mode-private.h b/include/mode-private.h index 67d3ca9d..04e0ea9d 100644 --- a/include/mode-private.h +++ b/include/mode-private.h @@ -2,7 +2,7 @@ #define ROFI_MODE_PRIVATE_H #include <gmodule.h> -#define ABI_VERSION 0x00000003 +#define ABI_VERSION 0x00000003 /** * @param data Pointer to #Mode object. @@ -113,9 +113,9 @@ struct rofi_mode /** Used for external plugins. */ unsigned int abi_version; /** Name (max 31 char long) */ - char name[32]; - char cfg_name_key[128]; - char *display_name; + char name[32]; + char cfg_name_key[128]; + char *display_name; /** * A switcher normally consists of the following parts: @@ -137,7 +137,7 @@ struct rofi_mode _mode_preprocess_input _preprocess_input; - _mode_get_message _get_message; + _mode_get_message _get_message; /** Pointer to private data. */ void *private_data; @@ -152,6 +152,6 @@ struct rofi_mode void *ed; /** Module */ - GModule *module; + GModule *module; }; #endif // ROFI_MODE_PRIVATE_H diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h index b7a70d16..20ed7e0a 100644 --- a/include/widgets/textbox.h +++ b/include/widgets/textbox.h @@ -46,16 +46,16 @@ typedef struct */ typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, - TB_MARKUP = 1 << 20, - TB_WRAP = 1 << 21, - TB_PASSWORD = 1 << 22, - TB_INDICATOR = 1 << 23, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, + TB_MARKUP = 1 << 20, + TB_WRAP = 1 << 21, + TB_PASSWORD = 1 << 22, + TB_INDICATOR = 1 << 23, } TextboxFlags; /** * Flags indicating current state of the textbox. diff --git a/include/x11-helper.h b/include/x11-helper.h index 8fc4db12..ed63b2d8 100644 --- a/include/x11-helper.h +++ b/include/x11-helper.h @@ -262,16 +262,16 @@ int x11_modifier_active ( unsigned int mask, int key ); */ void x11_disable_decoration ( xcb_window_t window ); - -typedef enum { +typedef enum +{ /** Default EWHM compatible window manager */ - WM_EWHM = 0, + WM_EWHM = 0, /** I3 Window manager */ - WM_I3 = 1, + WM_I3 = 1, /** Awesome window manager */ - WM_AWESOME = 2, + WM_AWESOME = 2, /** Openbox window manager */ - WM_OPENBOX = 4 + WM_OPENBOX = 4 } WindowManager; /** diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index 4699f151..3d408712 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -69,16 +69,18 @@ static void combi_mode_parse_switchers ( Mode *sw ) sizeof ( CombiMode ) * ( pd->num_switchers + 1 ) ); Mode *mode = rofi_collect_modi_search ( token ); - if ( mode ){ + if ( mode ) { pd->switchers[pd->num_switchers].disable = FALSE; pd->switchers[pd->num_switchers++].mode = mode; - } else { + } + else { // If not build in, use custom switchers. Mode *sw = script_switcher_parse_setup ( token ); if ( sw != NULL ) { pd->switchers[pd->num_switchers].disable = FALSE; pd->switchers[pd->num_switchers++].mode = sw; - } else { + } + else { // Report error, don't continue. fprintf ( stderr, "Invalid script switcher: %s\n", token ); token = NULL; diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index ea0880a2..85bf850a 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -473,10 +473,10 @@ static int dmenu_token_match ( const Mode *sw, GRegex **tokens, unsigned int ind static char *dmenu_get_message ( const Mode *sw ) { DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw ); - if ( pd->message ){ + if ( pd->message ) { return g_strdup ( pd->message ); } - return NULL; + return NULL; } #include "mode-private.h" diff --git a/source/dialogs/run.c b/source/dialogs/run.c index e9ba44c6..96ddd352 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -70,7 +70,6 @@ typedef struct unsigned int cmd_list_length; } RunModePrivateData; - /** * @param cmd The cmd to execute * @param run_in_term Indicate if command should be run in a terminal diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 5744f5ac..f653d719 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -76,11 +76,9 @@ static char **get_script_output ( const char *command, unsigned int *length ) static char **execute_executor ( Mode *sw, const char *result, unsigned int *length ) { - char **retv = NULL; - char *arg = g_shell_quote ( result ); char *command = g_strdup_printf ( "%s %s", (const char *) sw->ed, arg ); - retv = get_script_output ( command, length ); + char **retv = get_script_output ( command, length ); g_free ( command ); g_free ( arg ); return retv; diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index d2ffbed9..e8f67cd9 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -199,7 +199,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. @@ -284,10 +284,9 @@ static char ** get_ssh ( unsigned int *length ) retv = read_hosts_file ( retv, length ); } - FILE *fd = NULL; const char *hd = g_get_home_dir (); path = g_build_filename ( hd, ".ssh", "config", NULL ); - fd = fopen ( path, "r" ); + FILE *fd = fopen ( path, "r" ); if ( fd != NULL ) { char *buffer = NULL; diff --git a/source/dialogs/window.c b/source/dialogs/window.c index 2980270e..304b6a11 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -338,7 +338,7 @@ static int window_match ( const Mode *sw, GRegex **tokens, unsigned int index ) // If hack not in place it would not match queries spanning multiple fields. // e.g. when searching 'title element' and 'class element' GRegex *ftokens[2] = { tokens[j], NULL }; - if ( !test && c->title != NULL && c->title[0] != '\0' ) { + if ( c->title != NULL && c->title[0] != '\0' ) { test = helper_token_match ( ftokens, c->title ); } @@ -578,21 +578,20 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i } else { rofi_view_hide (); - if ( (current_window_manager&(WM_AWESOME|WM_OPENBOX)) != 0 ) - { + if ( ( current_window_manager & ( WM_AWESOME | WM_OPENBOX ) ) != 0 ) { // Get the desktop of the client to switch to uint32_t wmdesktop = 0; xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *r; // Get the current desktop. - unsigned int current_desktop = 0; - xcb_get_property_cookie_t c = xcb_ewmh_get_current_desktop ( &xcb->ewmh, xcb->screen_nbr ); + unsigned int current_desktop = 0; + xcb_get_property_cookie_t c = xcb_ewmh_get_current_desktop ( &xcb->ewmh, xcb->screen_nbr ); if ( !xcb_ewmh_get_current_desktop_reply ( &xcb->ewmh, c, ¤t_desktop, NULL ) ) { current_desktop = 0; } cookie = xcb_get_property ( xcb->connection, 0, rmpd->ids->array[selected_line], - xcb->ewmh._NET_WM_DESKTOP, XCB_ATOM_CARDINAL, 0, 1 ); + xcb->ewmh._NET_WM_DESKTOP, XCB_ATOM_CARDINAL, 0, 1 ); r = xcb_get_property_reply ( xcb->connection, cookie, NULL ); if ( r && r->type == XCB_ATOM_CARDINAL ) { wmdesktop = *( (uint32_t *) xcb_get_property_value ( r ) ); @@ -606,7 +605,7 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i // If we have to switch the desktop, do if ( wmdesktop != current_desktop ) { xcb_ewmh_request_change_current_desktop ( &xcb->ewmh, - xcb->screen_nbr, wmdesktop, XCB_CURRENT_TIME ); + xcb->screen_nbr, wmdesktop, XCB_CURRENT_TIME ); } } // Activate the window diff --git a/source/helper.c b/source/helper.c index 2bc2afa4..7a5e5cac 100644 --- a/source/helper.c +++ b/source/helper.c @@ -252,7 +252,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 ); @@ -863,8 +863,8 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st // uleft: value of the upper left cell; ulefts: maximum value of uleft and cells on the left. The arbitrary initial // values suppress warnings. int uleft = 0, ulefts = 0, left, lefts; - const gchar *pit = pattern, *sit; - enum CharClass prev = NON_WORD, cur; + const gchar *pit = pattern, *sit; + enum CharClass prev = NON_WORD, cur; for ( si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char ( sit ) ) { cur = rofi_scorer_get_character_class ( g_utf8_get_char ( sit ) ); score[si] = rofi_scorer_get_score_for ( prev, cur ); diff --git a/source/rofi.c b/source/rofi.c index 2770ee5c..33964ed0 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -48,7 +48,6 @@ #include <libgwater-xcb.h> - #include "xcb-internal.h" #include "xkb-internal.h" @@ -405,7 +404,7 @@ static void cleanup () * Collected modi */ // List of (possibly uninitialized) modi's -Mode ** available_modi = NULL; +Mode ** available_modi = NULL; unsigned int num_available_modi = 0; /** @@ -415,7 +414,7 @@ unsigned int num_available_modi = 0; */ Mode * rofi_collect_modi_search ( const char *name ) { - for ( unsigned int i = 0; i < num_available_modi; i++ ){ + for ( unsigned int i = 0; i < num_available_modi; i++ ) { if ( g_strcmp0 ( name, available_modi[i]->name ) == 0 ) { return available_modi[i]; } @@ -431,7 +430,7 @@ static gboolean rofi_collect_modi_add ( Mode *mode ) { Mode *m = rofi_collect_modi_search ( mode->name ); if ( m == NULL ) { - available_modi = g_realloc ( available_modi, sizeof(Mode *)*(num_available_modi+1)); + available_modi = g_realloc ( available_modi, sizeof ( Mode * ) * ( num_available_modi + 1 ) ); // Set mode. available_modi[num_available_modi] = mode; num_available_modi++; @@ -445,27 +444,28 @@ static void rofi_collect_modi_dir ( const char *base_dir ) GDir *dir = g_dir_open ( base_dir, 0, NULL ); if ( dir ) { const char *dn = NULL; - while ( ( dn = g_dir_read_name ( dir ) ) ) - { + while ( ( dn = g_dir_read_name ( dir ) ) ) { if ( !g_str_has_suffix ( dn, G_MODULE_SUFFIX ) ) { continue; } - char *fn = g_build_filename ( PLUGIN_PATH, dn, NULL ); - GModule *mod = g_module_open ( fn, G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL ); + char *fn = g_build_filename ( PLUGIN_PATH, dn, NULL ); + GModule *mod = g_module_open ( fn, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL ); if ( mod ) { Mode *m = NULL; - if ( g_module_symbol ( mod, "mode", (gpointer *)&m) ){ + if ( g_module_symbol ( mod, "mode", (gpointer *) &m ) ) { if ( m->abi_version != ABI_VERSION ) { - fprintf(stderr, "ABI version of plugin does not match: %08X expecting: %08X\n", m->abi_version, ABI_VERSION); + fprintf ( stderr, "ABI version of plugin does not match: %08X expecting: %08X\n", m->abi_version, ABI_VERSION ); g_module_close ( mod ); - } else { + } + else { m->module = mod; - if ( ! rofi_collect_modi_add ( m ) ) { + if ( !rofi_collect_modi_add ( m ) ) { g_module_close ( mod ); } } - } else { - fprintf(stderr, "Symbol 'mode' not found in module: %s\n", fn); + } + else { + fprintf ( stderr, "Symbol 'mode' not found in module: %s\n", fn ); g_module_close ( mod ); } } @@ -500,19 +500,19 @@ static void rofi_collect_modi ( void ) */ static void rofi_collect_modi_setup ( void ) { - for ( unsigned int i = 0; i < num_available_modi ; i++ ) { - mode_set_config ( available_modi[i] ); + for ( unsigned int i = 0; i < num_available_modi; i++ ) { + mode_set_config ( available_modi[i] ); } } static void rofi_collect_modi_destroy ( void ) { - for ( unsigned int i = 0; i < num_available_modi ; i++ ) { + for ( unsigned int i = 0; i < num_available_modi; i++ ) { if ( available_modi[i]->module ) { g_module_close ( available_modi[i]->module ); } } g_free ( available_modi ); - available_modi = NULL; + available_modi = NULL; num_available_modi = 0; } @@ -533,14 +533,16 @@ static int add_mode ( const char * token ) if ( mode ) { modi[num_modi] = mode; num_modi++; - } else { + } + else { // If not build in, use custom modi. Mode *sw = script_switcher_parse_setup ( token ); if ( sw != NULL ) { modi[num_modi] = sw; mode_set_config ( sw ); num_modi++; - } else { + } + else { // Report error, don't continue. fprintf ( stderr, "Invalid script switcher: %s\n", token ); } @@ -922,7 +924,7 @@ int main ( int argc, char *argv[] ) // Get DISPLAY, first env, then argument. // We never modify display_str content. - char *display_str = ( char *)g_getenv ( "DISPLAY" ); + char *display_str = ( char *) g_getenv ( "DISPLAY" ); find_arg_str ( "-display", &display_str ); xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr ); @@ -947,7 +949,7 @@ int main ( int argc, char *argv[] ) free ( errors ); } // Discover the current active window manager. - x11_helper_discover_window_manager(); + x11_helper_discover_window_manager (); TICK_N ( "Setup XCB" ); if ( xkb_x11_setup_xkb_extension ( xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION, diff --git a/source/view.c b/source/view.c index 9d92ae57..f036abaa 100644 --- a/source/view.c +++ b/source/view.c @@ -374,19 +374,19 @@ static void rofi_view_window_update_size ( RofiViewState * state ) widget_resize ( WIDGET ( state->main_window ), state->width, state->height ); } - static void rofi_view_reload_message_bar ( RofiViewState *state ) { - if ( state->mesg_box == NULL ){ - return ; + if ( state->mesg_box == NULL ) { + return; } char *msg = mode_get_message ( state->sw ); if ( msg ) { textbox_text ( state->mesg_tb, msg ); - widget_enable ( WIDGET (state->mesg_box ) ); + widget_enable ( WIDGET ( state->mesg_box ) ); g_free ( msg ); - } else { - widget_disable ( WIDGET (state->mesg_box ) ); + } + else { + widget_disable ( WIDGET ( state->mesg_box ) ); } } @@ -1679,7 +1679,7 @@ int rofi_view_error_dialog ( const char *msg, int markup ) // Need to resize otherwise calculated desired height is wrong. widget_resize ( WIDGET ( state->main_window ), state->width, 100 ); // resize window vertically to suit - state->height = widget_get_desired_height ( WIDGET (state->main_window)); + state->height = widget_get_desired_height ( WIDGET ( state->main_window ) ); // Calculte window position. rofi_view_calculate_window_position ( state ); diff --git a/source/widgets/box.c b/source/widgets/box.c index 14ab1e70..627716a3 100644 --- a/source/widgets/box.c +++ b/source/widgets/box.c @@ -51,11 +51,11 @@ static void box_update ( widget *wid ); static int box_get_desired_height ( widget *wid ) { - box *b = (box *) wid; - int spacing = distance_get_pixel ( b->spacing, b->type == BOX_VERTICAL ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL ); - int active_widgets = 0; - int height = 0; + box *b = (box *) wid; + int spacing = distance_get_pixel ( b->spacing, b->type == BOX_VERTICAL ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL ); + int height = 0; if ( b->type == BOX_VERTICAL ) { + int active_widgets = 0; for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; if ( !child->enabled ) { diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 421882e2..ed9cfef4 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -336,7 +336,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) int cursor_x = 0; int cursor_y = 0; - int cursor_width = 2; //MAX ( 2, font_height / 10 ); int cursor_height = font_height; if ( tb->changed ) { @@ -372,7 +371,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) x = ( ( tb->widget.w - tw - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ) / 2; } - int top = widget_padding_get_top ( WIDGET (tb) ); + int top = widget_padding_get_top ( WIDGET ( tb ) ); y = top + ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; rofi_theme_get_color ( WIDGET ( tb ), "foreground", draw ); @@ -380,6 +379,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) rofi_theme_get_color ( WIDGET ( tb ), "text", draw ); // draw the cursor if ( tb->flags & TB_EDITABLE && tb->blink ) { + int cursor_width = 2; //MAX ( 2, font_height / 10 ); cairo_rectangle ( draw, x + cursor_x, y + cursor_y, cursor_width, cursor_height ); cairo_fill ( draw ); } diff --git a/source/x11-helper.c b/source/x11-helper.c index f372e0ef..4b5dea57 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -55,7 +55,6 @@ /** Log domain for this module */ #define LOG_DOMAIN "X11Helper" - WindowManager current_window_manager = WM_EWHM; /** @@ -926,26 +925,27 @@ void x11_disable_decoration ( xcb_window_t window ) void x11_helper_discover_window_manager ( void ) { - xcb_window_t wm_win = 0; + xcb_window_t wm_win = 0; xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked ( &xcb->ewmh, - xcb_stuff_get_root_window ( xcb ) ); + xcb_stuff_get_root_window ( xcb ) ); if ( xcb_ewmh_get_supporting_wm_check_reply ( &xcb->ewmh, cc, &wm_win, NULL ) ) { xcb_ewmh_get_utf8_strings_reply_t wtitle; - xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked(&(xcb->ewmh), wm_win ); - if ( xcb_ewmh_get_wm_name_reply(&(xcb->ewmh), cookie, &wtitle, (void *)0)) - { - if ( wtitle.strings_len > 0 ){ + xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked ( &( xcb->ewmh ), wm_win ); + if ( xcb_ewmh_get_wm_name_reply ( &( xcb->ewmh ), cookie, &wtitle, (void *) 0 ) ) { + if ( wtitle.strings_len > 0 ) { g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Found window manager: %s", wtitle.strings ); - if ( g_strcmp0(wtitle.strings, "i3") == 0 ){ + if ( g_strcmp0 ( wtitle.strings, "i3" ) == 0 ) { current_window_manager = WM_I3; - } else if ( g_strcmp0 ( wtitle.strings, "awesome" ) == 0 ){ + } + else if ( g_strcmp0 ( wtitle.strings, "awesome" ) == 0 ) { current_window_manager = WM_AWESOME; - } else if ( g_strcmp0 ( wtitle.strings, "Openbox" ) == 0 ){ + } + else if ( g_strcmp0 ( wtitle.strings, "Openbox" ) == 0 ) { current_window_manager = WM_OPENBOX; } } - xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle); + xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle ); } } } |