Skip to content

File Explorer#753

Open
dgshanee wants to merge 8 commits intopwmt:developfrom
dgshanee:develop
Open

File Explorer#753
dgshanee wants to merge 8 commits intopwmt:developfrom
dgshanee:develop

Conversation

@dgshanee
Copy link

@dgshanee dgshanee commented Jun 9, 2025

I implemented a working file explorer using GLTK! Everything seems to be working, but one bug that needs to be fixed is that the index, when enter is pressed, does not exit out of the index screen immediately. I plan to fix that, but let me know what you think.

example

return ZATHURA_EXPLORER_TYPE_FILE_INVALID;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We handle file type detection via mime types. Please check the open auto completion and follow the same pattern.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using MIME types here is proving to be very buggy and slow no matter what I do. Is there an edge case I'm not accounting for when simply checking the file extensions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We support more than PDF files (depending on the installed plugins). So the common pattern to check whether a file can be displayed or not is to check the mimetype and then match it with the registered types. Please look at list_files as a template.

// takes a dir and gets its children and adds it to the parent
bool zathura_explorer_generate_r(zathura_error_t* error, girara_tree_node_t* root, char *path, int trace){
/* Only 3 recursive calls to prevent it from getting too big */
if (trace > 5){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of building everything in the beginning, child nodes of directories could be computed on demand when a directory is opened.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way it's built now, it would require the GTK Tree to continually be rebuilt and re-rendered on each expansion. I can do this, but without rewriting all changes from scratch, this would be less memory-efficient than simply building everything in the beginning.

struct dirent *dp;


dir = opendir(path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check list_files from zathura/completion.c.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list_files instead of my implementation would be hard to string together because the file tree nodes have their own data type that zathura_explorer_generate uses.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but in any case it is the template to follow. It handles all file types supported by zathura (which is more than PDF).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. I'll work on it when I get back. Sorry for the confusion

@dgshanee
Copy link
Author

@sebastinas I implemented most of the changes you suggested. Everything is working fine, but I could not get the unresolved changes implemented without major bugs or reworking the entire PR. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants