Skip to content

Commit

Permalink
Add file explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
konect-V committed Aug 23, 2024
1 parent d60bd2a commit eb14572
Show file tree
Hide file tree
Showing 15 changed files with 803 additions and 9 deletions.
28 changes: 28 additions & 0 deletions bootstrap/sys-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,34 @@ packages:
- '-r'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: explorer
source:
subdir: 'sources/core/apps'
tools_required:
- host-gcc
pkgs_required:
- mlibc
- cjson
- freetype
- libjpeg
- kot-graphics
build:
- args:
- 'make'
- '-C'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@'
- 'build'
environ:
CC: "@OPTION:cc@"
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
- args:
- 'cp'
- '-r'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: bash
source:
Expand Down
Binary file added sources/core/apps/desktop/icons/explorer.tga
Binary file not shown.
6 changes: 6 additions & 0 deletions sources/core/apps/desktop/icons/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"executablePath": "/usr/bin/bash",
"appName": "Bash"
},
{
"cwdPath": "/usr/bin/",
"iconPath": "/usr/bin/icons/explorer.tga",
"executablePath": "/usr/bin/explorer",
"appName": "Explorer"
},
{
"cwdPath": "/usr/bin/",
"iconPath": "/usr/bin/icons/lock.tga",
Expand Down
3 changes: 1 addition & 2 deletions sources/core/apps/desktop/res/desktop.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"default_icon_path": "/usr/bin/icons/default.tga",
"font_path": "/usr/bin/res/desktop/default_font.ttf",
"wallpaper_path": "/usr/bin/res/desktop/default_wallpaper.jpg",
"pin_expected": ""
"wallpaper_path": "/usr/bin/res/desktop/default_wallpaper.jpg"
}
27 changes: 22 additions & 5 deletions sources/core/apps/desktop/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,6 @@ int process_icons(){
int c = 0;
int total_count = 0;
int icon_start_count = current_page * icons_max_count;
icons_text = malloc(sizeof(char*) * icons_max_count);
icons_executable_path = malloc(sizeof(char*) * icons_max_count);
icons_cwd_path = malloc(sizeof(char*) * icons_max_count);
icons_image = malloc(sizeof(raw_image_t*) * icons_max_count);

cJSON* item = NULL;
cJSON_ArrayForEach(item, icon_json_root) {
Expand All @@ -314,7 +310,23 @@ int process_icons(){
cJSON* cwdPath = cJSON_GetObjectItem(item, "cwdPath");
cJSON* appName = cJSON_GetObjectItem(item, "appName");

if(iconPath && executablePath && cwdPath && appName) {
if(iconPath && executablePath && cwdPath && appName){
if(icons_image[c] != NULL){
free_raw_image(icons_image[c]);
}

if(icons_image[c] != NULL){
free(icons_text[c]);
}

if(icons_image[c] != NULL){
free(icons_cwd_path[c]);
}

if(icons_image[c] != NULL){
free(icons_executable_path[c]);
}

if(iconPath->valuestring[0] != '\0'){
raw_image_t* icon = load_tga_image_file(iconPath->valuestring);

Expand Down Expand Up @@ -618,6 +630,11 @@ int main(int argc, char* argv[]){
get_textbox_info(font, "a", &char_width, NULL, NULL, NULL);
max_text_icon_length = ICON_IMAGE_WIDTH / char_width;

icons_text = calloc(icons_max_count, sizeof(char*));
icons_executable_path = calloc(icons_max_count, sizeof(char*));
icons_cwd_path = calloc(icons_max_count, sizeof(char*));
icons_image = calloc(icons_max_count, sizeof(raw_image_t*));

process_icons();

while(true){
Expand Down
Binary file added sources/core/apps/explorer/res/default.tga
Binary file not shown.
Binary file added sources/core/apps/explorer/res/default_font.ttf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sources/core/apps/explorer/res/directory.tga
Binary file not shown.
7 changes: 7 additions & 0 deletions sources/core/apps/explorer/res/explorer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default_icon_path": "/usr/bin/res/explorer/default.tga",
"file_default_icon_path": "/usr/bin/res/explorer/file.tga",
"directory_default_icon_path": "/usr/bin/res/explorer/directory.tga",
"font_path": "/usr/bin/res/explorer/default_font.ttf",
"wallpaper_path": "/usr/bin/res/explorer/default_wallpaper.jpg"
}
Binary file added sources/core/apps/explorer/res/file.tga
Binary file not shown.
Loading

0 comments on commit eb14572

Please sign in to comment.