1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[FileBrowser] Prepend '@' before filename if link.

This commit is contained in:
Dave Davenport 2020-10-16 21:09:36 +02:00
parent 9a21040d0e
commit 10678e55d8

View file

@ -64,6 +64,7 @@ typedef struct {
char *path; char *path;
enum FBFileType type; enum FBFileType type;
uint32_t icon_fetch_uid; uint32_t icon_fetch_uid;
gboolean link;
} FBFile; } FBFile;
typedef struct typedef struct
@ -118,6 +119,7 @@ static void get_file_browser ( Mode *sw )
pd->array[pd->array_length].path = NULL; pd->array[pd->array_length].path = NULL;
pd->array[pd->array_length].type = UP; pd->array[pd->array_length].type = UP;
pd->array[pd->array_length].icon_fetch_uid = 0; pd->array[pd->array_length].icon_fetch_uid = 0;
pd->array[pd->array_length].link = FALSE;
pd->array_length++; pd->array_length++;
continue; continue;
@ -142,6 +144,7 @@ static void get_file_browser ( Mode *sw )
pd->array[pd->array_length].path = g_build_filename ( cdir, rd->d_name, 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].type = (rd->d_type == DT_DIR)? DIRECTORY: RFILE;
pd->array[pd->array_length].icon_fetch_uid = 0; pd->array[pd->array_length].icon_fetch_uid = 0;
pd->array[pd->array_length].link = FALSE;
pd->array_length++; pd->array_length++;
break; break;
case DT_LNK: case DT_LNK:
@ -150,6 +153,7 @@ static void get_file_browser ( Mode *sw )
pd->array[pd->array_length].name = g_filename_to_utf8 ( rd->d_name, -1, NULL, NULL, NULL); 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].path = g_build_filename ( cdir, rd->d_name, NULL );
pd->array[pd->array_length].icon_fetch_uid = 0; pd->array[pd->array_length].icon_fetch_uid = 0;
pd->array[pd->array_length].link = TRUE;
// Default to file. // Default to file.
pd->array[pd->array_length].type = RFILE; pd->array[pd->array_length].type = RFILE;
{ {
@ -285,13 +289,15 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_
// Only return the string if requested, otherwise only set state. // 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 == DIRECTORY ){ if ( pd->array[selected_line].type == UP ){
return g_strdup ( pd->array[selected_line].name);
} else if ( pd->array[selected_line].type == UP ){
return g_strdup( " .."); return g_strdup( " ..");
} 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); return g_strdup ( pd->array[selected_line].name);
} }
}
return g_strdup("n/a"); return g_strdup("n/a");
} }