-
Notifications
You must be signed in to change notification settings - Fork 33
[Feature]: Relative app icon paths #62
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,4 @@ third_party/*/patches/.applied_* | |
| __pycache__/ | ||
| libs/libfreetype/include/ | ||
| utils/.cached/* | ||
| .vscode | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright (C) 2020-2022 The opuntiaOS Project Authors. | ||
| * + Contributed by Mainasara Tsowa <tsowamainasara@gmail.com> | ||
| * | ||
| * Use of this source code is governed by a BSD-style license that can be | ||
| * found in the LICENSE file. | ||
| */ | ||
|
|
||
| // Begining of possible AssetManager to locate/read/write to files and folders in the app directory | ||
| namespace LFoundation { | ||
|
|
||
| class AssetManager { | ||
| public: | ||
| AssetManager(const std::string& name) | ||
| :m_app_root(std::string() + "/Applications/" + name + ".app/Content") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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. |
||
| { | ||
| } | ||
|
|
||
| ~AssetManager() = default; | ||
|
|
||
| std::string find(std::string path) | ||
| { | ||
| return m_app_root + path; | ||
| } | ||
| private: | ||
| std::string m_app_root; | ||
| }; | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "assets": "Resources/Assets/", | ||
| "resources": ["Resources"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,18 @@ | ||
| #include "ViewController.h" | ||
| #include <libui/AppDelegate.h> | ||
| #include <libfoundation/AssetManager.h> | ||
|
|
||
| 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| { | ||
| LFoundation::AssetManager assets = LFoundation::AssetManager("activity_monitor"); | ||
| return assets.find("Resources/Assets/AppIcon").c_str();; | ||
| } | ||
|
|
||
| virtual bool application() override | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "assets": "Resources/Assets", | ||
| "resources": ["Resources"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "assets": "Resources/Assets", | ||
| "resources": ["Resources"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "assets": "Resources/Assets", | ||
| "resources": ["Resources"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding an "empty" icon if
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so that means
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should unify As an alternative to this |
||
| icon_path = content_dir + icon_rel_path; | ||
| } | ||
|
|
||
| new_ent.set_icon(loader.load_from_file(icon_path + "/32x32.png")); | ||
|
|
||
| std::string rel_exec_path = jdict_root->data()["exec_rel_path"]->cast_to<LFoundation::Json::StringObject>()->data(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.