-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Relative app icon paths #62
base: master
Are you sure you want to change the base?
[Feature]: Relative app icon paths #62
Conversation
neutrino2211
commented
Jun 19, 2022
- Move app icons into $app/Resources folder
- Add asset manager class in libfoundation
- Add higher-priority "icon_rel_path" field to application info.json
- Add assets field for folders to be copied into the build app dir
- Programatically add apps to DockViewController
- Use AssetManager to fetch app icon path in AppDelegates
- Move app icons into $app/Resources folder - Add asset manager class on libfoundation - Add higher-priority "icon_rel_path" field to application info.json - Add assets field for folders to be copied into the build app dir - Programatically add apps to DockViewController - Use AssetManager to fetch app icon path in AppDelegates
For issue #61 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
I have left several comments and please format all files. We use webkit code style. As I see you use vscode, you can consider downloading a plugin and configuring it with webkit code style.
Overall what you have done is a really great start point. Add we might considering the same asset management as used in iOS or similar (https://developer.apple.com/documentation/foundation/bundle). We might create shared Bundle class, which is inited at the start up of an application with info from a info.json
file linked with the application. Finally we could use something like UI::Bundle::main.path("README.txt")
inside our app to the the absolute path of a file from an asset folder.
If you have any questions feel free to ask them.
@@ -45,6 +45,12 @@ class AppListViewController : public UI::ViewController<AppListView> { | |||
LG::PNG::PNGLoader loader; | |||
|
|||
std::string icon_path = jdict_root->data()["icon_path"]->cast_to<LFoundation::Json::StringObject>()->data(); | |||
std::string icon_rel_path = jdict_root->data()["icon_rel_path"]->cast_to<LFoundation::Json::StringObject>()->data(); | |||
|
|||
if (!icon_rel_path.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding an "empty" icon if icon_rel_path
is not set. (here they are: https://github.com/opuntiaOS-Project/opuntiaOS/tree/master/base/res/icons/apps/missing.icon)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so that means icon_path
generated by prepare_app.py
should be completely omitted? Or is there any plan for it? Maybe always setting it to the missing icon path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should unify icon_path
and icon_rel_path
for sure, so yeah we should omit one of them. But also in case if there is no such field in info.json
which describes location of an icon, we should set a "missing icon".
As an alternative to this icon_path
and icon_rel_path
we could provide path to asset folder in the info.json
. And to require have a "special" folder which contains icons inside the asset folder. In other words to have a provided path to an asset folder and look there for a "AppIcon" folder to get all of the icons.
I currently have both the Also, I noticed that it was hard to convince the build system that things have changed if I didn't edit a cpp file, which got me thinking... Would it be weird to have the configurations inside |
Yeah, currently build system knows nothing about
I think fixing a build system should be enough. |
You can squash 6d12fe6 Adhere to webkit style guidelines commit into the previous one. We also use a commit naming like I will take a deeper look a bit later. |
Hey, sorry for a long reply. I got a crash during loading of AppList on x86 GNU testing your PR, have you seen this before?
|
I haven't honestly, that's new. I apologise for my silence as well. The past week was extremely busy for me. |
I also have the same issue, all this time I've been building for aarch64 because I'm using an M1Pro. I'll take a look at it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks homescreen
a lot cleaner now :)
icon_path
also looks good, but maybe we could write path of assets
folder to the config file and at runtime look AppIcon
folder inside provided assets
folder. What do you think?
class AssetManager { | ||
public: | ||
AssetManager(const std::string& name) | ||
:m_app_root(std::string() + "/Applications/" + name + ".app/Content") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if we could look for Content folder getting the binary path. I would to implement this similar to Apple's Bundle. They have the similar to what you have implemented. bundle.main
could be initialised with a binary path (see ProcessInfo::parse_info_file
) during the startup of UI Apps (again as a ProcessInfo).
Both UI and Foundation libs I try to make as close as possible to Apple's versions (as I have plans on launching recompiled iOS apps one day). So it would be great that all APIs have the similar behaviour to Apple's.
|
||
class AppDelegate : public UI::AppDelegate { | ||
public: | ||
AppDelegate() = default; | ||
virtual ~AppDelegate() = default; | ||
|
||
LG::Size preferred_desktop_window_size() const override { return LG::Size(220, 210); } | ||
const char* icon_path() const override { return "/res/icons/apps/activity_monitor.icon"; } | ||
const char* icon_path() const override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's fine to keep for now, but it would be good to get rid of these icon_path()
functions somehow. I didn't think on how to implement this, may be you can think of something.
Hey, I'm very sorry for the months of silence on this. A lot of things happened in my life these last few months that made open source impossible for me to do. Is the main branch still in need of this? If it is, I'd like to look into the ProcessInfo idea |