diff options
author | Dave Davenport <qball@gmpclient.org> | 2020-11-03 23:57:02 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2020-11-03 23:57:02 +0100 |
commit | 7061eb21ae1625260eeb5715d42a820450c6c513 (patch) | |
tree | da5638189d2526bd421e15d500f92bfaf992405c | |
parent | d8eaeec66d0d2f4d4c75992b0dcf211d0f42f49d (diff) |
Indent round.
-rw-r--r-- | config/config.c | 2 | ||||
-rw-r--r-- | include/dialogs/filebrowser.h | 2 | ||||
-rw-r--r-- | include/rofi-icon-fetcher.h | 2 | ||||
-rw-r--r-- | source/dialogs/combi.c | 2 | ||||
-rw-r--r-- | source/dialogs/drun.c | 14 | ||||
-rw-r--r-- | source/dialogs/filebrowser.c | 340 | ||||
-rw-r--r-- | source/dialogs/run.c | 4 | ||||
-rw-r--r-- | source/dialogs/script.c | 20 | ||||
-rw-r--r-- | source/dialogs/window.c | 30 | ||||
-rw-r--r-- | source/helper.c | 84 | ||||
-rw-r--r-- | source/mode.c | 2 | ||||
-rw-r--r-- | source/rofi-icon-fetcher.c | 257 | ||||
-rw-r--r-- | source/rofi.c | 15 | ||||
-rw-r--r-- | source/theme.c | 29 | ||||
-rw-r--r-- | source/view.c | 14 | ||||
-rw-r--r-- | source/widgets/textbox.c | 26 | ||||
-rw-r--r-- | source/xrmoptions.c | 4 |
17 files changed, 426 insertions, 421 deletions
diff --git a/config/config.c b/config/config.c index 111ec742..942063bc 100644 --- a/config/config.c +++ b/config/config.c @@ -173,5 +173,5 @@ Settings config = { .benchmark_ui = FALSE, /** normalize match */ - .normalize_match = FALSE + .normalize_match = FALSE }; diff --git a/include/dialogs/filebrowser.h b/include/dialogs/filebrowser.h index 3609501a..ea440a71 100644 --- a/include/dialogs/filebrowser.h +++ b/include/dialogs/filebrowser.h @@ -38,7 +38,7 @@ /** #Mode object representing the run dialog. */ extern Mode file_browser_mode; -Mode *create_new_file_browser (void); +Mode *create_new_file_browser ( void ); ModeMode file_browser_mode_completer ( Mode *sw, int mretv, char **input, unsigned int selected_line, char **path ); /**@}*/ #endif // ROFI_DIALOG_FILE_BROWSER_H diff --git a/include/rofi-icon-fetcher.h b/include/rofi-icon-fetcher.h index daa3e5e6..19a46241 100644 --- a/include/rofi-icon-fetcher.h +++ b/include/rofi-icon-fetcher.h @@ -45,8 +45,6 @@ uint32_t rofi_icon_fetcher_query ( const char *name, const int size ); */ cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ); - - gboolean rofi_icon_fetcher_file_is_image ( const char * const path ); /** @} */ #endif // ROFI_ICON_FETCHER_H diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index ab6a9a62..cef3a3ef 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -181,7 +181,7 @@ static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned } } if ( ( mretv & MENU_CUSTOM_INPUT ) ) { - return mode_result ( pd->switchers[0].mode, mretv, input, selected_line ); + return mode_result ( pd->switchers[0].mode, mretv, input, selected_line ); } return MODE_EXIT; } diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 94200cbc..969fe35f 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -736,11 +736,11 @@ static void drun_write_str ( FILE *fd, const char *str ) } static void drun_write_integer ( FILE *fd, int32_t val ) { - fwrite ( &val,sizeof(val), 1, fd ); + fwrite ( &val, sizeof ( val ), 1, fd ); } static void drun_read_integer ( FILE *fd, int32_t *type ) { - if ( fread ( type, sizeof ( int32_t), 1, fd ) != 1 ) { + if ( fread ( type, sizeof ( int32_t ), 1, fd ) != 1 ) { g_warning ( "Failed to read entry, cache corrupt?" ); return; } @@ -821,7 +821,7 @@ static void write_cache ( DRunModePrivateData *pd, const char *cache_file ) drun_write_strv ( fd, entry->keywords ); drun_write_str ( fd, entry->comment ); - drun_write_integer ( fd, (int32_t)entry->type ); + drun_write_integer ( fd, (int32_t) entry->type ); } fclose ( fd ); @@ -893,7 +893,7 @@ static gboolean drun_read_cache ( DRunModePrivateData *pd, const char *cache_fil drun_read_string ( fd, &( entry->comment ) ); int32_t type = 0; - drun_read_integer( fd, &( type ) ); + drun_read_integer ( fd, &( type ) ); entry->type = type; } @@ -1041,10 +1041,10 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i } } else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) { - RofiHelperExecuteContext context = { .name = NULL }; - gboolean run_in_term = ( ( mretv & MENU_CUSTOM_ACTION ) == MENU_CUSTOM_ACTION ); + RofiHelperExecuteContext context = { .name = NULL }; + gboolean run_in_term = ( ( mretv & MENU_CUSTOM_ACTION ) == MENU_CUSTOM_ACTION ); // FIXME: We assume startup notification in terminals, not in others - if ( ! helper_execute_command ( NULL, *input, run_in_term, run_in_term ? &context : NULL ) ) { + if ( !helper_execute_command ( NULL, *input, run_in_term, run_in_term ? &context : NULL ) ) { retv = RELOAD_DIALOG; } } diff --git a/source/dialogs/filebrowser.c b/source/dialogs/filebrowser.c index b2294a3a..80730f17 100644 --- a/source/dialogs/filebrowser.c +++ b/source/dialogs/filebrowser.c @@ -35,7 +35,6 @@ #include <sys/stat.h> #include <dirent.h> - #include "mode.h" #include "helper.h" #include "mode-private.h" @@ -47,13 +46,13 @@ #include "rofi-icon-fetcher.h" - -#define FILEBROWSER_CACHE_FILE "rofi3.filebrowsercache" +#define FILEBROWSER_CACHE_FILE "rofi3.filebrowsercache" /** * The internal data structure holding the private data of the TEST Mode. */ -enum FBFileType { +enum FBFileType +{ UP, DIRECTORY, RFILE, @@ -65,30 +64,31 @@ const char *icon_name[NUM_FILE_TYPES] = "folder", "gtk-file" }; -typedef struct { - char *name; - char *path; +typedef struct +{ + char *name; + char *path; enum FBFileType type; uint32_t icon_fetch_uid; - gboolean link; + gboolean link; } FBFile; typedef struct { - GFile *current_dir; - FBFile *array; - unsigned int array_length; + GFile *current_dir; + FBFile *array; + unsigned int array_length; } FileBrowserModePrivateData; static void free_list ( FileBrowserModePrivateData *pd ) { for ( unsigned int i = 0; i < pd->array_length; i++ ) { - FBFile *fb = & ( pd->array[i] ); + FBFile *fb = &( pd->array[i] ); g_free ( fb->name ); g_free ( fb->path ); } - g_free (pd->array); - pd->array = NULL; + g_free ( pd->array ); + pd->array = NULL; pd->array_length = 0; } #include <sys/types.h> @@ -96,10 +96,10 @@ static void free_list ( FileBrowserModePrivateData *pd ) static gint compare ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED gpointer data ) { - FBFile *fa = (FBFile*)a; - FBFile *fb = (FBFile*)b; - if ( fa->type != fb->type ){ - return (fa->type - fb->type); + FBFile *fa = (FBFile*) a; + FBFile *fb = (FBFile*) b; + if ( fa->type != fb->type ) { + return fa->type - fb->type; } return g_strcmp0 ( fa->name, fb->name ); @@ -113,85 +113,85 @@ static void get_file_browser ( Mode *sw ) * this gets called on plugin initialization. */ char *cdir = g_file_get_path ( pd->current_dir ); - DIR *dir = opendir ( cdir ); + DIR *dir = opendir ( cdir ); if ( dir ) { struct dirent *rd = NULL; - while ((rd = readdir (dir)) != NULL ) - { - if ( g_strcmp0 ( rd->d_name, ".." ) == 0 ){ - pd->array = g_realloc ( pd->array, (pd->array_length+1)*sizeof(FBFile)); - // Rofi expects utf-8, so lets convert the filename. - pd->array[pd->array_length].name = g_strdup ( ".." ); - pd->array[pd->array_length].path = NULL; - pd->array[pd->array_length].type = UP; - pd->array[pd->array_length].icon_fetch_uid = 0; - pd->array[pd->array_length].link = FALSE; - pd->array_length++; - continue; - - } else if ( rd->d_name[0] == '.' ) { + while ( ( rd = readdir ( dir ) ) != NULL ) { + if ( g_strcmp0 ( rd->d_name, ".." ) == 0 ) { + pd->array = g_realloc ( pd->array, ( pd->array_length + 1 ) * sizeof ( FBFile ) ); + // Rofi expects utf-8, so lets convert the filename. + pd->array[pd->array_length].name = g_strdup ( ".." ); + pd->array[pd->array_length].path = NULL; + pd->array[pd->array_length].type = UP; + pd->array[pd->array_length].icon_fetch_uid = 0; + pd->array[pd->array_length].link = FALSE; + pd->array_length++; + continue; + } + else if ( rd->d_name[0] == '.' ) { continue; } switch ( rd->d_type ) { - case DT_BLK: - case DT_CHR: - case DT_FIFO: - case DT_UNKNOWN: - case DT_SOCK: - default: - break; - case DT_REG: - case DT_DIR: - pd->array = g_realloc ( pd->array, (pd->array_length+1)*sizeof(FBFile)); - // Rofi expects utf-8, so lets convert the filename. - pd->array[pd->array_length].name = g_filename_to_utf8 ( rd->d_name, -1, NULL, NULL, NULL); - pd->array[pd->array_length].path = g_build_filename ( cdir, rd->d_name, NULL ); - pd->array[pd->array_length].type = (rd->d_type == DT_DIR)? DIRECTORY: RFILE; - pd->array[pd->array_length].icon_fetch_uid = 0; - pd->array[pd->array_length].link = FALSE; - pd->array_length++; - break; - case DT_LNK: - pd->array = g_realloc ( pd->array, (pd->array_length+1)*sizeof(FBFile)); - // Rofi expects utf-8, so lets convert the filename. - pd->array[pd->array_length].name = g_filename_to_utf8 ( rd->d_name, -1, NULL, NULL, NULL); - pd->array[pd->array_length].path = g_build_filename ( cdir, rd->d_name, NULL ); - pd->array[pd->array_length].icon_fetch_uid = 0; - pd->array[pd->array_length].link = TRUE; - // Default to file. - pd->array[pd->array_length].type = RFILE; - { - // If we have link, use a stat to fine out what it is, if we fail, we mark it as file. - // TODO have a 'broken link' mode? - // Convert full path to right encoding. - char *file = g_filename_from_utf8(pd->array[pd->array_length].path,-1, NULL, NULL, NULL ); - if ( file ) { - struct stat statbuf; - if ( stat(file, &statbuf ) == 0 ) { - if ( S_ISDIR(statbuf.st_mode ) ) { - pd->array[pd->array_length].type = DIRECTORY; - } else if ( S_ISREG ( statbuf.st_mode ) ) { - pd->array[pd->array_length].type = RFILE; - } - } else { - g_warning("Failed to stat file: %s, %s" , file, strerror(errno)); + case DT_BLK: + case DT_CHR: + case DT_FIFO: + case DT_UNKNOWN: + case DT_SOCK: + default: + break; + case DT_REG: + case DT_DIR: + pd->array = g_realloc ( pd->array, ( pd->array_length + 1 ) * sizeof ( FBFile ) ); + // Rofi expects utf-8, so lets convert the filename. + pd->array[pd->array_length].name = g_filename_to_utf8 ( rd->d_name, -1, NULL, NULL, NULL ); + pd->array[pd->array_length].path = g_build_filename ( cdir, rd->d_name, NULL ); + pd->array[pd->array_length].type = ( rd->d_type == DT_DIR ) ? DIRECTORY : RFILE; + pd->array[pd->array_length].icon_fetch_uid = 0; + pd->array[pd->array_length].link = FALSE; + pd->array_length++; + break; + case DT_LNK: + pd->array = g_realloc ( pd->array, ( pd->array_length + 1 ) * sizeof ( FBFile ) ); + // Rofi expects utf-8, so lets convert the filename. + pd->array[pd->array_length].name = g_filename_to_utf8 ( rd->d_name, -1, NULL, NULL, NULL ); + pd->array[pd->array_length].path = g_build_filename ( cdir, rd->d_name, NULL ); + pd->array[pd->array_length].icon_fetch_uid = 0; + pd->array[pd->array_length].link = TRUE; + // Default to file. + pd->array[pd->array_length].type = RFILE; + { + // If we have link, use a stat to fine out what it is, if we fail, we mark it as file. + // TODO have a 'broken link' mode? + // Convert full path to right encoding. + char *file = g_filename_from_utf8 ( pd->array[pd->array_length].path, -1, NULL, NULL, NULL ); + if ( file ) { + struct stat statbuf; + if ( stat ( file, &statbuf ) == 0 ) { + if ( S_ISDIR ( statbuf.st_mode ) ) { + pd->array[pd->array_length].type = DIRECTORY; } - - g_free ( file ); + else if ( S_ISREG ( statbuf.st_mode ) ) { + pd->array[pd->array_length].type = RFILE; + } + } + else { + g_warning ( "Failed to stat file: %s, %s", file, strerror ( errno ) ); } + + g_free ( file ); } - pd->array_length++; - break; - } + } + pd->array_length++; + break; + } } closedir ( dir ); } - g_qsort_with_data ( pd->array, pd->array_length, sizeof (FBFile ), compare, NULL ); + g_qsort_with_data ( pd->array, pd->array_length, sizeof ( FBFile ), compare, NULL ); } - static int file_browser_mode_init ( Mode *sw ) { /** @@ -203,16 +203,16 @@ static int file_browser_mode_init ( Mode *sw ) { char *path = g_build_filename ( cache_dir, FILEBROWSER_CACHE_FILE, NULL ); char *file = NULL; - if ( g_file_get_contents (path, &file, NULL, NULL ) ) { - if ( g_file_test ( file, G_FILE_TEST_IS_DIR ) ){ - pd->current_dir = g_file_new_for_path( file ); + if ( g_file_get_contents ( path, &file, NULL, NULL ) ) { + if ( g_file_test ( file, G_FILE_TEST_IS_DIR ) ) { + pd->current_dir = g_file_new_for_path ( file ); } g_free ( file ); } // Store it based on the unique identifiers (desktop_id). g_free ( path ); if ( pd->current_dir == NULL ) { - pd->current_dir = g_file_new_for_path(g_get_home_dir () ); + pd->current_dir = g_file_new_for_path ( g_get_home_dir () ); } } // Load content. @@ -228,73 +228,76 @@ static unsigned int file_browser_mode_get_num_entries ( const Mode *sw ) static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line ) { - ModeMode retv = MODE_EXIT; - FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); + ModeMode retv = MODE_EXIT; + FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); if ( mretv & MENU_NEXT ) { retv = NEXT_DIALOG; - } else if ( mretv & MENU_PREVIOUS ) { + } + else if ( mretv & MENU_PREVIOUS ) { retv = PREVIOUS_DIALOG; - } else if ( mretv & MENU_QUICK_SWITCH ) { + } + else if ( mretv & MENU_QUICK_SWITCH ) { retv = ( mretv & MENU_LOWER_MASK ); - } else if ( ( mretv & MENU_OK ) ) { - if ( selected_line < pd->array_length ) - { + } + else if ( ( mretv & MENU_OK ) ) { + if ( selected_line < pd->array_length ) { if ( pd->array[selected_line].type == UP ) { GFile *new = g_file_get_parent ( pd->current_dir ); - if ( new ){ - g_object_unref ( pd->current_dir ); - pd->current_dir = new; - free_list (pd); - get_file_browser ( sw ); - return RESET_DIALOG; - } - } else if ( pd->array[selected_line].type == DIRECTORY ) { + if ( new ) { + g_object_unref ( pd->current_dir ); + pd->current_dir = new; + free_list ( pd ); + get_file_browser ( sw ); + return RESET_DIALOG; + } + } + else if ( pd->array[selected_line].type == DIRECTORY ) { char *path = g_build_filename ( cache_dir, FILEBROWSER_CACHE_FILE, NULL ); - g_file_set_contents (path, pd->array[selected_line].path, -1, NULL ); - g_free(path); + g_file_set_contents ( path, pd->array[selected_line].path, -1, NULL ); + g_free ( path ); GFile *new = g_file_new_for_path ( pd->array[selected_line].path ); g_object_unref ( pd->current_dir ); pd->current_dir = new; - free_list (pd); + free_list ( pd ); get_file_browser ( sw ); return RESET_DIALOG; - } else if ( pd->array[selected_line].type == RFILE ) { - char *d = g_filename_from_utf8 (pd->array[selected_line].path, -1, NULL, NULL, NULL); - char *cmd = g_strdup_printf("xdg-open '%s'", d ); - g_free(d); + } + else if ( pd->array[selected_line].type == RFILE ) { + char *d = g_filename_from_utf8 ( pd->array[selected_line].path, -1, NULL, NULL, NULL ); + char *cmd = g_strdup_printf ( "xdg-open '%s'", d ); + g_free ( d ); char *cdir = g_file_get_path ( pd->current_dir ); - helper_execute_command ( cdir,cmd, FALSE,NULL ); + helper_execute_command ( cdir, cmd, FALSE, NULL ); g_free ( cdir ); g_free ( cmd ); return MODE_EXIT; } } retv = RELOAD_DIALOG; - } else if ( (mretv&MENU_CUSTOM_INPUT) && *input ) { - char *p = rofi_expand_path ( *input ); + } + else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input ) { + char *p = rofi_expand_path ( *input ); char *dir = g_filename_from_utf8 ( p, -1, NULL, NULL, NULL ); - g_free (p); - if ( g_file_test ( dir, G_FILE_TEST_EXISTS ) ) - { - if ( g_file_test ( dir, G_FILE_TEST_IS_DIR ) ){ + g_free ( p ); + if ( g_file_test ( dir, G_FILE_TEST_EXISTS ) ) { + if ( g_file_test ( dir, G_FILE_TEST_IS_DIR ) ) { g_object_unref ( pd->current_dir ); pd->current_dir = g_file_new_for_path ( dir ); g_free ( dir ); - free_list (pd); + free_list ( pd ); get_file_browser ( sw ); return RESET_DIALOG; } - } g_free ( dir ); retv = RELOAD_DIALOG; - } else if ( ( mretv & MENU_ENTRY_DELETE ) == MENU_ENTRY_DELETE ) { + } + else if ( ( mretv & MENU_ENTRY_DELETE ) == MENU_ENTRY_DELETE ) { retv = RELOAD_DIALOG; } return retv; } - static void file_browser_mode_destroy ( Mode *sw ) { FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); @@ -311,17 +314,21 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_ FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); // Only return the string if requested, otherwise only set state. - if ( !get_entry ) return NULL; - if ( pd->array[selected_line].type == UP ){ - return g_strdup( " .."); - } else { + if ( !get_entry ) { + return NULL; + } + if ( pd->array[selected_line].type == UP ) { + return g_strdup ( " .." ); + } + else { if ( pd->array[selected_line].link ) { - return g_strconcat ( "@", pd->array[selected_line].name, NULL); - } else { - return g_strdup ( pd->array[selected_line].name); + return g_strconcat ( "@", pd->array[selected_line].name, NULL ); + } + else { + return g_strdup ( pd->array[selected_line].name ); } } - return g_strdup("n/a"); + return g_strdup ( "n/a" ); } /** @@ -338,21 +345,21 @@ static int file_browser_token_match ( const Mode *sw, rofi_int_matcher **tokens, FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); // Call default matching function. - return helper_token_match ( tokens, pd->array[index].name); + return helper_token_match ( tokens, pd->array[index].name ); } - static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line, int height ) { FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); g_return_val_if_fail ( pd->array != NULL, NULL ); - FBFile *dr = &( pd->array[selected_line] ); + FBFile *dr = &( pd->array[selected_line] ); if ( dr->icon_fetch_uid > 0 ) { return rofi_icon_fetcher_get ( dr->icon_fetch_uid ); } - if ( rofi_icon_fetcher_file_is_image ( dr->path ) ){ - dr->icon_fetch_uid = rofi_icon_fetcher_query ( dr->path, height ); - } else { + if ( rofi_icon_fetcher_file_is_image ( dr->path ) ) { + dr->icon_fetch_uid = rofi_icon_fetcher_query ( dr->path, height ); + } + else { dr->icon_fetch_uid = rofi_icon_fetcher_query ( icon_name[dr->type], height ); } return rofi_icon_fetcher_get ( dr->icon_fetch_uid ); @@ -363,25 +370,24 @@ static char * _get_message ( const Mode *sw ) FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); if ( pd->current_dir ) { char *dirname = g_file_get_parse_name ( pd->current_dir ); - char *str = g_markup_printf_escaped("<b>Current directory:</b> %s", dirname); + char *str = g_markup_printf_escaped ( "<b>Current directory:</b> %s", dirname ); g_free ( dirname ); return str; } return "n/a"; } - static char *_get_completion ( const Mode *sw, unsigned int index ) { FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); - char *d = g_strescape ( pd->array[index].path,NULL ); + char *d = g_strescape ( pd->array[index].path, NULL ); return d; } -Mode *create_new_file_browser (void ) +Mode *create_new_file_browser ( void ) { - Mode *sw = g_malloc0(sizeof(Mode)); + Mode *sw = g_malloc0 ( sizeof ( Mode ) ); *sw = file_browser_mode; @@ -392,58 +398,62 @@ Mode *create_new_file_browser (void ) #if 0 ModeMode file_browser_mode_completer ( Mode *sw, int mretv, char **input, unsigned int selected_line, char **path ) { - ModeMode retv = MODE_EXIT; - FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); + ModeMode retv = MODE_EXIT; + FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); if ( mretv & MENU_NEXT ) { retv = NEXT_DIALOG; - } else if ( mretv & MENU_PREVIOUS ) { + } + else if ( mretv & MENU_PREVIOUS ) { retv = PREVIOUS_DIALOG; - } else if ( mretv & MENU_QUICK_SWITCH ) { + } + else if ( mretv & MENU_QUICK_SWITCH ) { retv = ( mretv & MENU_LOWER_MASK ); - } else if ( ( mretv & MENU_OK ) ) { - if ( selected_line < pd->array_length ) - { + } + else if ( ( mretv & MENU_OK ) ) { + if ( selected_line < pd->array_length ) { if ( pd->array[selected_line].type == UP ) { GFile *new = g_file_get_parent ( pd->current_dir ); - if ( new ){ - g_object_unref ( pd->current_dir ); - pd->current_dir = new; - free_list (pd); - get_file_browser ( sw ); - return RESET_DIALOG; - } - } else if ( pd->array[selected_line].type == DIRECTORY ) { + if ( new ) { + g_object_unref ( pd->current_dir ); + pd->current_dir = new; + free_list ( pd ); + get_file_browser ( sw ); + return RESET_DIALOG; + } + } + else if ( pd->array[selected_line].type == DIRECTORY ) { GFile *new = g_file_new_for_path ( pd->array[selected_line].path ); g_object_unref ( pd->current_dir ); pd->current_dir = new; - free_list (pd); + free_list ( pd ); get_file_browser ( sw ); return RESET_DIALOG; - } else if ( pd->array[selected_line].type == RFILE ) { - *path = g_strescape ( pd->array[selected_line].path,NULL ); + } + else if ( pd->array[selected_line].type == RFILE ) { + *path = g_strescape ( pd->array[selected_line].path, NULL ); return MODE_EXIT; } } retv = RELOAD_DIALOG; - } else if ( (mretv&MENU_CUSTOM_INPUT) && *input ) { - char *p = rofi_expand_path ( *input ); + } + else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input ) { + char *p = rofi_expand_path ( *input ); char *dir = g_filename_from_utf8 ( p, -1, NULL, NULL, NULL ); - g_free (p); - if ( g_file_test ( dir, G_FILE_TEST_EXISTS ) ) - { - if ( g_file_test ( dir, G_FILE_TEST_IS_DIR ) ){ + g_free ( p ); + if ( g_file_test ( dir, G_FILE_TEST_EXISTS ) ) { + if ( g_file_test ( dir, G_FILE_TEST_IS_DIR ) ) { g_object_unref ( pd->current_dir ); pd->current_dir = g_file_new_for_path ( dir ); g_free ( dir ); - free_list (pd); + free_list ( pd ); get_file_browser ( sw ); return RESET_DIALOG; } - } g_free ( dir ); retv = RELOAD_DIALOG; - } else if ( ( mretv & MENU_ENTRY_DELETE ) == MENU_ENTRY_DELETE ) { + } + else if ( ( mretv & MENU_ENTRY_DELETE ) == MENU_ENTRY_DELETE ) { retv = RELOAD_DIALOG; } return retv; diff --git a/source/dialogs/run.c b/source/dialogs/run.c index 71800213..b889ca82 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -376,12 +376,12 @@ static ModeMode run_mode_result ( Mode *sw, int mretv, char **input, unsigned in if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) { if ( !exec_cmd ( rmpd->cmd_list[selected_line], run_in_term ) ) { - retv = RELOAD_DIALOG; + retv = RELOAD_DIALOG; } } else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) { if ( !exec_cmd ( *input, run_in_term ) ) { - retv = RELOAD_DIALOG; + retv = RELOAD_DIALOG; } } else if ( ( mretv & MENU_ENTRY_DELETE ) && rmpd->cmd_list[selected_line] ) { diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 45b94954..701bbb42 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -279,19 +279,19 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned unsigned int new_length = 0; if ( ( mretv & MENU_CUSTOM_COMMAND ) ) { - //retv = 1+( mretv & MENU_LOWER_MASK ); - script_mode_reset_highlight ( sw ); - if ( selected_line != UINT32_MAX ) { - new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), &( rmpd->cmd_list[selected_line] ) ); - } - else { - if ( rmpd->no_custom == FALSE ) { - new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), NULL ); + //retv = 1+( mretv & MENU_LOWER_MASK ); + script_mode_reset_highlight ( sw ); + if ( selected_line != UINT32_MAX ) { + new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), &( rmpd->cmd_list[selected_line] ) ); } else { - return RELOAD_DIALOG; + if ( rmpd->no_custom == FALSE ) { + new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), NULL ); + } + else { + return RELOAD_DIALOG; + } } - } } else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line].entry != NULL ) { if ( rmpd->cmd_list[selected_line].nonselectable ) { diff --git a/source/dialogs/window.c b/source/dialogs/window.c index e0eff96a..71478407 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -698,21 +698,21 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i xcb_flush ( xcb->connection ); } else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) { - GError *error = NULL; - gboolean run_in_term = ( ( mretv & MENU_CUSTOM_ACTION ) == MENU_CUSTOM_ACTION ); - gsize lf_cmd_size = 0; - gchar *lf_cmd = g_locale_from_utf8 ( *input, -1, NULL, &lf_cmd_size, &error ); - if ( error != NULL ) { - g_warning ( "Failed to convert command to locale encoding: %s", error->message ); - g_error_free ( error ); - return RELOAD_DIALOG; - } - - RofiHelperExecuteContext context = { .name = NULL }; - if ( ! helper_execute_command ( NULL, lf_cmd, run_in_term, run_in_term ? &context : NULL ) ) { - retv = RELOAD_DIALOG; - } - g_free ( lf_cmd ); + GError *error = NULL; + gboolean run_in_term = ( ( mretv & MENU_CUSTOM_ACTION ) == MENU_CUSTOM_ACTION ); + gsize lf_cmd_size = 0; + gchar *lf_cmd = g_locale_from_utf8 ( *input, -1, NULL, &lf_cmd_size, &error ); + if ( error != NULL ) { + g_warning ( "Failed to convert command to locale encoding: %s", error->message ); + g_error_free ( error ); + return RELOAD_DIALOG; + } + + RofiHelperExecuteContext context = { .name = NULL }; + if ( !helper_execute_command ( NULL, lf_cmd, run_in_term, run_in_term ? &context : NULL ) ) { + retv = RELOAD_DIALOG; + } + g_free ( lf_cmd ); } return retv; } diff --git a/source/helper.c b/source/helper.c index 33e94d25..1eb2b902 100644 --- a/source/helper.c +++ b/source/helper.c @@ -179,43 +179,44 @@ static gchar *fuzzy_to_regex ( const char * input ) return retv; } -sta |