From bbcca835a59b00d8f76d115da46672e210280118 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 10 Nov 2022 14:58:25 +0100 Subject: [PATCH] sculpt: make graph features configurable This patch makes the component graph better reusable for the phone version of Sculpt. In the phone version, the '+' menu does not exist. So we need to omit the corresponding button. Furthermore, the storage dialog is presented in a dedicate section of the GUI instead of presenting it inside the 'storage' graph node. The phone version also does not offer the inspect view. So we need to omit the corresponding buttons. --- repos/gems/src/app/sculpt_manager/feature.h | 34 +++++++++++++++++++ repos/gems/src/app/sculpt_manager/graph.cc | 8 +++-- .../src/app/sculpt_manager/view/fs_dialog.h | 15 ++++---- 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 repos/gems/src/app/sculpt_manager/feature.h diff --git a/repos/gems/src/app/sculpt_manager/feature.h b/repos/gems/src/app/sculpt_manager/feature.h new file mode 100644 index 0000000000..185a942027 --- /dev/null +++ b/repos/gems/src/app/sculpt_manager/feature.h @@ -0,0 +1,34 @@ +/* + * \brief Compile-time feature selection + * \author Norman Feske + * \date 2022-11-10 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _FEATURE_H_ +#define _FEATURE_H_ + +#include + +namespace Sculpt { struct Feature; }; + + +struct Sculpt::Feature +{ + /* show the '+' botton at the graph for opening the deploy popup dialog */ + static constexpr bool PRESENT_PLUS_MENU = true; + + /* manage storage from within the respective graph nodes */ + static constexpr bool STORAGE_DIALOG_HOSTED_IN_GRAPH = true; + + /* allow the browsing of file systems via the inspect view */ + static constexpr bool INSPECT_VIEW = false; +}; + +#endif /* _FEATURE_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/graph.cc b/repos/gems/src/app/sculpt_manager/graph.cc index 225d5a7ee2..8e2ab6dcc0 100644 --- a/repos/gems/src/app/sculpt_manager/graph.cc +++ b/repos/gems/src/app/sculpt_manager/graph.cc @@ -12,6 +12,7 @@ */ #include +#include #include using namespace Sculpt; @@ -157,7 +158,7 @@ void Graph::generate(Xml_generator &xml) const { xml.node("depgraph", [&] () { - if (_sculpt_partition.valid()) { + if (Feature::PRESENT_PLUS_MENU && _sculpt_partition.valid()) { gen_named_node(xml, "button", "global+", [&] () { _add_button_item.gen_button_attr(xml, "global+"); @@ -168,7 +169,10 @@ void Graph::generate(Xml_generator &xml) const xml.attribute("text", "+"); }); }); } - _gen_storage_node(xml); + if (Feature::STORAGE_DIALOG_HOSTED_IN_GRAPH) + _gen_storage_node(xml); + else + _gen_parent_node(xml, "storage", "Storage"); if (_storage_devices.usb_present) _gen_usb_node(xml); diff --git a/repos/gems/src/app/sculpt_manager/view/fs_dialog.h b/repos/gems/src/app/sculpt_manager/view/fs_dialog.h index c2e4529983..7db39f58c5 100644 --- a/repos/gems/src/app/sculpt_manager/view/fs_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/fs_dialog.h @@ -14,6 +14,7 @@ #ifndef _VIEW__FS_DIALOG_H_ #define _VIEW__FS_DIALOG_H_ +#include #include #include @@ -48,14 +49,16 @@ struct Sculpt::Fs_dialog : Noncopyable, Dialog void generate(Xml_generator &xml, File_system const &file_system) const { - xml.node("button", [&] () { - _inspect_item.gen_button_attr(xml, "browse"); + if (Feature::INSPECT_VIEW) { + xml.node("button", [&] () { + _inspect_item.gen_button_attr(xml, "browse"); - if (file_system.inspected) - xml.attribute("selected", "yes"); + if (file_system.inspected) + xml.attribute("selected", "yes"); - xml.node("label", [&] () { xml.attribute("text", "Inspect"); }); - }); + xml.node("label", [&] () { xml.attribute("text", "Inspect"); }); + }); + } if (!_used_target.valid() || _used_target == _target) { xml.node("button", [&] () {