mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
TextEditor: Unveil the full path to the config file
Unveil ~/.config/TextEditor.ini instead of the whole config directory.
This commit is contained in:
parent
aacb1f0bf4
commit
7d579b04c5
3 changed files with 15 additions and 3 deletions
|
@ -9,7 +9,6 @@
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <Applications/TextEditor/TextEditorWindowGML.h>
|
#include <Applications/TextEditor/TextEditorWindowGML.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCpp/SyntaxHighlighter.h>
|
#include <LibCpp/SyntaxHighlighter.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
|
@ -47,7 +46,7 @@ MainWidget::MainWidget()
|
||||||
{
|
{
|
||||||
load_from_gml(text_editor_window_gml);
|
load_from_gml(text_editor_window_gml);
|
||||||
|
|
||||||
m_config = Core::ConfigFile::open_for_app("TextEditor", Core::ConfigFile::AllowWriting::Yes);
|
m_config = open_config_file();
|
||||||
|
|
||||||
m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
||||||
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
||||||
|
@ -345,6 +344,15 @@ MainWidget::~MainWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RefPtr<Core::ConfigFile> s_config;
|
||||||
|
|
||||||
|
RefPtr<Core::ConfigFile> MainWidget::open_config_file()
|
||||||
|
{
|
||||||
|
if (!s_config)
|
||||||
|
s_config = Core::ConfigFile::open_for_app("TextEditor", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
return s_config;
|
||||||
|
}
|
||||||
|
|
||||||
Web::OutOfProcessWebView& MainWidget::ensure_web_view()
|
Web::OutOfProcessWebView& MainWidget::ensure_web_view()
|
||||||
{
|
{
|
||||||
if (!m_page_view) {
|
if (!m_page_view) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibFileSystemAccessClient/Client.h>
|
#include <LibFileSystemAccessClient/Client.h>
|
||||||
#include <LibGUI/ActionGroup.h>
|
#include <LibGUI/ActionGroup.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -42,6 +43,8 @@ public:
|
||||||
void update_title();
|
void update_title();
|
||||||
void initialize_menubar(GUI::Window&);
|
void initialize_menubar(GUI::Window&);
|
||||||
|
|
||||||
|
static RefPtr<Core::ConfigFile> open_config_file();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWidget();
|
MainWidget();
|
||||||
void set_path(StringView const&);
|
void set_path(StringView const&);
|
||||||
|
|
|
@ -32,6 +32,7 @@ int main(int argc, char** argv)
|
||||||
parser.parse(argc, argv);
|
parser.parse(argc, argv);
|
||||||
|
|
||||||
String file_to_edit_full_path;
|
String file_to_edit_full_path;
|
||||||
|
auto config_filename = MainWidget::open_config_file()->filename();
|
||||||
|
|
||||||
if (file_to_edit) {
|
if (file_to_edit) {
|
||||||
FileArgument parsed_argument(file_to_edit);
|
FileArgument parsed_argument(file_to_edit);
|
||||||
|
@ -47,7 +48,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unveil(Core::StandardPaths::config_directory().characters(), "rw") < 0) {
|
if (unveil(config_filename.characters(), "rwc") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue