mirror of https://github.com/davatorium/rofi.git
Indent round.
This commit is contained in:
parent
d8eaeec66d
commit
7061eb21ae
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
/**
|
||||
* The internal data structure holding the private data of the TEST Mode.
|
||||
*/
|
||||
enum FBFileType {
|
||||
enum FBFileType
|
||||
{
|
||||
UP,
|
||||
DIRECTORY,
|
||||
RFILE,
|
||||
|
@ -65,7 +64,8 @@ const char *icon_name[NUM_FILE_TYPES] =
|
|||
"folder",
|
||||
"gtk-file"
|
||||
};
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
char *path;
|
||||
enum FBFileType type;
|
||||
|
@ -99,7 +99,7 @@ static gint compare ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED gpointer d
|
|||
FBFile *fa = (FBFile*) a;
|
||||
FBFile *fb = (FBFile*) b;
|
||||
if ( fa->type != fb->type ) {
|
||||
return (fa->type - fb->type);
|
||||
return fa->type - fb->type;
|
||||
}
|
||||
|
||||
return g_strcmp0 ( fa->name, fb->name );
|
||||
|
@ -116,8 +116,7 @@ static void get_file_browser ( Mode *sw )
|
|||
DIR *dir = opendir ( cdir );
|
||||
if ( dir ) {
|
||||
struct dirent *rd = NULL;
|
||||
while ((rd = readdir (dir)) != 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.
|
||||
|
@ -128,8 +127,8 @@ static void get_file_browser ( Mode *sw )
|
|||
pd->array[pd->array_length].link = FALSE;
|
||||
pd->array_length++;
|
||||
continue;
|
||||
|
||||
} else if ( rd->d_name[0] == '.' ) {
|
||||
}
|
||||
else if ( rd->d_name[0] == '.' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -172,10 +171,12 @@ static void get_file_browser ( Mode *sw )
|
|||
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 ) ) {
|
||||
}
|
||||
else if ( S_ISREG ( statbuf.st_mode ) ) {
|
||||
pd->array[pd->array_length].type = RFILE;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
g_warning ( "Failed to stat file: %s, %s", file, strerror ( errno ) );
|
||||
}
|
||||
|
||||
|
@ -191,7 +192,6 @@ static void get_file_browser ( Mode *sw )
|
|||
g_qsort_with_data ( pd->array, pd->array_length, sizeof ( FBFile ), compare, NULL );
|
||||
}
|
||||
|
||||
|
||||
static int file_browser_mode_init ( Mode *sw )
|
||||
{
|
||||
/**
|
||||
|
@ -232,13 +232,15 @@ static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, un
|
|||
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 ) {
|
||||
|
@ -248,7 +250,8 @@ static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, un
|
|||
get_file_browser ( sw );
|
||||
return RESET_DIALOG;
|
||||
}
|
||||
} else if ( pd->array[selected_line].type == DIRECTORY ) {
|
||||
}
|
||||
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 );
|
||||
|
@ -258,7 +261,8 @@ static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, un
|
|||
free_list ( pd );
|
||||
get_file_browser ( sw );
|
||||
return RESET_DIALOG;
|
||||
} else if ( pd->array[selected_line].type == RFILE ) {
|
||||
}
|
||||
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 );
|
||||
|
@ -270,12 +274,12 @@ static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, un
|
|||
}
|
||||
}
|
||||
retv = RELOAD_DIALOG;
|
||||
} else if ( (mretv&MENU_CUSTOM_INPUT) && *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_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 );
|
||||
|
@ -284,17 +288,16 @@ static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, un
|
|||
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,13 +314,17 @@ 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 ( !get_entry ) {
|
||||
return NULL;
|
||||
}
|
||||
if ( pd->array[selected_line].type == UP ) {
|
||||
return g_strdup ( " .." );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if ( pd->array[selected_line].link ) {
|
||||
return g_strconcat ( "@", pd->array[selected_line].name, NULL );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return g_strdup ( pd->array[selected_line].name );
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +348,6 @@ static int file_browser_token_match ( const Mode *sw, rofi_int_matcher **tokens,
|
|||
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 );
|
||||
|
@ -352,7 +358,8 @@ static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line,
|
|||
}
|
||||
if ( rofi_icon_fetcher_file_is_image ( dr->path ) ) {
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query ( dr->path, height );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query ( icon_name[dr->type], height );
|
||||
}
|
||||
return rofi_icon_fetcher_get ( dr->icon_fetch_uid );
|
||||
|
@ -370,7 +377,6 @@ static char * _get_message ( const Mode *sw )
|
|||
return "n/a";
|
||||
}
|
||||
|
||||
|
||||
static char *_get_completion ( const Mode *sw, unsigned int index )
|
||||
{
|
||||
FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw );
|
||||
|
@ -396,13 +402,15 @@ ModeMode file_browser_mode_completer ( Mode *sw, int mretv, char **input, unsign
|
|||
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 ) {
|
||||
|
@ -412,25 +420,27 @@ ModeMode file_browser_mode_completer ( Mode *sw, int mretv, char **input, unsign
|
|||
get_file_browser ( sw );
|
||||
return RESET_DIALOG;
|
||||
}
|
||||
} else if ( pd->array[selected_line].type == DIRECTORY ) {
|
||||
}
|
||||
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 );
|
||||
get_file_browser ( sw );
|
||||
return RESET_DIALOG;
|
||||
} else if ( pd->array[selected_line].type == RFILE ) {
|
||||
}
|
||||
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 ) {
|
||||
}
|
||||
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_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 );
|
||||
|
@ -439,11 +449,11 @@ ModeMode file_browser_mode_completer ( Mode *sw, int mretv, char **input, unsign
|
|||
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;
|
||||
|
|
|
@ -192,7 +192,8 @@ static char *utf8_helper_simplify_string ( const char *s)
|
|||
gsize dl = g_unichar_fully_decompose ( uc, FALSE, buf2, G_UNICHAR_MAX_DECOMPOSITION_LENGTH );
|
||||
if ( dl ) {
|
||||
l = g_unichar_to_utf8 ( buf2[0], buf );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
l = g_unichar_to_utf8 ( uc, buf );
|
||||
}
|
||||
memcpy ( striter, buf, l );
|
||||
|
@ -212,9 +213,9 @@ static inline GRegex * R ( const char *s, int case_sensitive )
|
|||
|
||||
g_free ( str );
|
||||
return r;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,7 +497,8 @@ int helper_token_match ( rofi_int_matcher* const *tokens, const char *input )
|
|||
match ^= tokens[j]->invert;
|
||||
}
|
||||
g_free ( r );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for ( int j = 0; match && tokens[j]; j++ ) {
|
||||
match = g_regex_match ( tokens[j]->regex, input, 0, NULL );
|
||||
match ^= tokens[j]->invert;
|
||||
|
|
|
@ -103,7 +103,7 @@ ModeMode mode_result ( Mode *mode, int menu_retv, char **input, unsigned int sel
|
|||
return PREVIOUS_DIALOG;
|
||||
}
|
||||
else if ( menu_retv & MENU_QUICK_SWITCH ) {
|
||||
return ( menu_retv & MENU_LOWER_MASK );
|
||||
return menu_retv & MENU_LOWER_MASK;
|
||||
}
|
||||
|
||||
g_assert ( mode != NULL );
|
||||
|
|
|
@ -88,7 +88,6 @@ typedef struct
|
|||
*/
|
||||
IconFetcher *rofi_icon_fetcher_data = NULL;
|
||||
|
||||
|
||||
static void rofi_icon_fetch_entry_free ( gpointer data )
|
||||
{
|
||||
IconFetcherNameEntry *entry = (IconFetcherNameEntry *) data;
|
||||
|
@ -126,10 +125,8 @@ void rofi_icon_fetcher_init ( void )
|
|||
rofi_icon_fetcher_data->icon_cache_uid = g_hash_table_new ( g_direct_hash, g_direct_equal );
|
||||
rofi_icon_fetcher_data->icon_cache = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, rofi_icon_fetch_entry_free );
|
||||
|
||||
|
||||
GSList *l = gdk_pixbuf_get_formats ();
|
||||
for ( GSList *li = l; li != NULL; li = g_slist_next(li))
|
||||
{
|
||||
for ( GSList *li = l; li != NULL; li = g_slist_next ( li ) ) {
|
||||
gchar **exts = gdk_pixbuf_format_get_extensions ( (GdkPixbufFormat *) li->data );
|
||||
|
||||
for ( unsigned int i = 0; exts && exts[i]; i++ ) {
|
||||
|
@ -139,10 +136,8 @@ void rofi_icon_fetcher_init ( void )
|
|||
}
|
||||
|
||||
g_free ( exts );
|
||||
|
||||
}
|
||||
g_slist_free ( l );
|
||||
|
||||
}
|
||||
|
||||
void rofi_icon_fetcher_destroy ( void )
|
||||
|
@ -156,7 +151,6 @@ void rofi_icon_fetcher_destroy ( void )
|
|||
g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache_uid );
|
||||
g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache );
|
||||
|
||||
|
||||
g_list_foreach ( rofi_icon_fetcher_data->supported_extensions, (GFunc) g_free, NULL );
|
||||
g_list_free ( rofi_icon_fetcher_data->supported_extensions );
|
||||
g_free ( rofi_icon_fetcher_data );
|
||||
|
@ -203,8 +197,9 @@ static cairo_surface_t * rofi_icon_fetcher_get_surface_from_pixbuf(GdkPixbuf
|
|||
gint stride;
|
||||
gboolean alpha;
|
||||
|
||||
if ( pixbuf == NULL )
|
||||
if ( pixbuf == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
width = gdk_pixbuf_get_width ( pixbuf );
|
||||
height = gdk_pixbuf_get_height ( pixbuf );
|
||||
|
@ -229,16 +224,15 @@ static cairo_surface_t * rofi_icon_fetcher_get_surface_from_pixbuf(GdkPixbuf
|
|||
cstride = cairo_image_surface_get_stride ( surface );
|
||||
|
||||
cairo_surface_flush ( surface );
|
||||
while ( pixels < pixels_end )
|
||||
{
|
||||
while ( pixels < pixels_end ) {
|
||||
line = pixels;
|
||||
line_end = line + lo;
|
||||
cline = cpixels;
|
||||
|
||||
while ( line < line_end )
|
||||
{
|
||||
if ( alpha )
|
||||
while ( line < line_end ) {
|
||||
if ( alpha ) {
|
||||
a = line[3];
|
||||
}
|
||||
cline[RED_BYTE] = alpha_mult ( line[0], a );
|
||||
cline[GREEN_BYTE] = alpha_mult ( line[1], a );
|
||||
cline[BLUE_BYTE] = alpha_mult ( line[2], a );
|
||||
|
@ -318,7 +312,8 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
|||
if ( pb ) {
|
||||
g_object_unref ( pb );
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
icon_surf = rofi_icon_fetcher_get_surface_from_pixbuf ( pb );
|
||||
g_object_unref ( pb );
|
||||
}
|
||||
|
|
|
@ -248,7 +248,8 @@ void process_result ( RofiViewState *state )
|
|||
rofi_view_switch_mode ( state, modi[mode] );
|
||||
curr_switcher = mode;
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// On exit, free current view, and pop to one above.
|
||||
rofi_view_remove_active ( state );
|
||||
rofi_view_free ( state );
|
||||
|
|
|
@ -481,7 +481,8 @@ static void rofi_theme_print_index ( ThemeWidget *widget, int index )
|
|||
rofi_theme_print_index ( widget->widgets[i], index + 4 );
|
||||
}
|
||||
printf ( "}\n" );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if ( widget->properties ) {
|
||||
GList *list = NULL;
|
||||
ThemeWidget *w = widget;
|
||||
|
@ -1227,7 +1228,6 @@ static void rofi_theme_parse_merge_widgets_no_media ( ThemeWidget *parent, Theme
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
ThemeWidget *w = rofi_theme_find_or_create_name ( parent, child->name );
|
||||
rofi_theme_widget_add_properties ( w, child->properties );
|
||||
for ( unsigned int i = 0; i < child->num_widgets; i++ ) {
|
||||
|
@ -1244,7 +1244,6 @@ void rofi_theme_parse_merge_widgets ( ThemeWidget *parent, ThemeWidget *child )
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
ThemeWidget *w = rofi_theme_find_or_create_name ( parent, child->name );
|
||||
if ( child->media ) {
|
||||
w->media = g_slice_new0 ( ThemeMedia );
|
||||
|
|
Loading…
Reference in New Issue