From 888260b06b1f00b928cb1934eb353c6567c44938 Mon Sep 17 00:00:00 2001 From: QC Date: Fri, 27 Mar 2015 20:50:48 +0100 Subject: [PATCH] Small cleanup --- include/rofi.h | 4 +--- source/dialogs/dmenu.c | 2 +- source/rofi.c | 26 ++++++++------------------ 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/include/rofi.h b/include/rofi.h index 83480a44..d5932f7c 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -79,7 +79,6 @@ typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensi * @param num_lines Length of the array with strings to display. * @param input A pointer to a string where the inputted data is placed. * @param prompt The prompt to show. - * @param time The current time (used for window interaction.) * @param shift pointer to integer that is set to the state of the shift key. * @param mmc Menu menu match callback, used for matching user input. * @param mmc_data data to pass to mmc. @@ -90,9 +89,8 @@ typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensi * @returns The command issued (see MenuReturn) */ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prompt, - Time *time, menu_match_cb mmc, void *mmc_data, - int *selected_line, int sorting ) __attribute__ ( ( nonnull ( 1, 3, 4, 8 ) ) ); + int *selected_line, int sorting ) __attribute__ ( ( nonnull ( 1, 3, 4, 7 ) ) ); /** * @param sig The caught signal * diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 35f32273..c019f421 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -83,7 +83,7 @@ int dmenu_switcher_dialog ( char **input ) find_arg_int ( "-l", &selected_line ); do { - int mretv = menu ( list, length, input, dmenu_prompt, NULL, + int mretv = menu ( list, length, input, dmenu_prompt, token_match, NULL, &selected_line, FALSE ); // We normally do not want to restart the loop. diff --git a/source/rofi.c b/source/rofi.c index 5667ccee..632fb052 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -922,7 +922,7 @@ static void menu_paste ( MenuState *state, XSelectionEvent *xse ) } } -MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prompt, Time *time, +MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prompt, menu_match_cb mmc, void *mmc_data, int *selected_line, int sorting ) { int shift = FALSE; @@ -1148,10 +1148,6 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom // Key press event. else if ( ev.type == KeyPress ) { do { - if ( time ) { - *time = ev.xkey.time; - } - KeySym key = XkbKeycodeToKeysym ( display, ev.xkey.keycode, 0, 0 ); // Handling of paste @@ -1823,26 +1819,20 @@ int main ( int argc, char *argv[] ) SwitcherMode switcher_run ( char **input, Switcher *sw ) { + char *prompt = g_strdup_printf ( "%s:", sw->name ); int selected_line = 0; - SwitcherMode retv = MODE_EXIT; unsigned int cmd_list_length = 0; char **cmd_list = NULL; cmd_list = sw->get_data ( &cmd_list_length, sw ); - if ( cmd_list == NULL ) { - cmd_list = g_malloc_n ( 2, sizeof ( char * ) ); - cmd_list[0] = g_strdup ( "No applications found" ); - cmd_list[1] = NULL; - } + int mretv = menu ( cmd_list, cmd_list_length, + input, prompt, + sw->token_match, sw, + &selected_line, + config.levenshtein_sort ); - char *prompt = g_strdup_printf ( "%s:", sw->name ); - - int mretv = menu ( cmd_list, cmd_list_length, input, prompt, - NULL, sw->token_match, sw, &selected_line, - config.levenshtein_sort ); - - retv = sw->result ( mretv, input, selected_line, sw ); + SwitcherMode retv = sw->result ( mretv, input, selected_line, sw ); g_free ( prompt );