mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:37:34 +00:00
AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and create_with_file_protocol() already. This patch removes these function and updates all call sites to use the functions named according to the specification. See https://url.spec.whatwg.org/#concept-url-scheme
This commit is contained in:
parent
454bf1fde0
commit
4230dbbb21
61 changed files with 113 additions and 116 deletions
|
@ -88,7 +88,7 @@ NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(URL cons
|
|||
|
||||
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(String const& path)
|
||||
{
|
||||
return get_launch_handlers(URL::create_with_file_protocol(path));
|
||||
return get_launch_handlers(URL::create_with_file_scheme(path));
|
||||
}
|
||||
|
||||
void DirectoryView::handle_activation(GUI::ModelIndex const& index)
|
||||
|
@ -107,14 +107,14 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index)
|
|||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if (is_desktop()) {
|
||||
Desktop::Launcher::open(URL::create_with_file_protocol(path));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(path));
|
||||
return;
|
||||
}
|
||||
open(path);
|
||||
return;
|
||||
}
|
||||
|
||||
auto url = URL::create_with_file_protocol(path);
|
||||
auto url = URL::create_with_file_scheme(path);
|
||||
auto launcher_handlers = get_launch_handlers(url);
|
||||
auto default_launcher = get_default_launch_handler(launcher_handlers);
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
|
|||
auto location = general_tab.find_descendant_of_type_named<GUI::LinkLabel>("location");
|
||||
location->set_text(path);
|
||||
location->on_click = [this] {
|
||||
Desktop::Launcher::open(URL::create_with_file_protocol(m_parent_path, m_name));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(m_parent_path, m_name));
|
||||
};
|
||||
|
||||
if (S_ISLNK(m_mode)) {
|
||||
|
@ -104,7 +104,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
|
|||
link_location->set_text(link_destination);
|
||||
link_location->on_click = [link_destination] {
|
||||
auto link_directory = LexicalPath(link_destination);
|
||||
Desktop::Launcher::open(URL::create_with_file_protocol(link_directory.dirname(), link_directory.basename()));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(link_directory.dirname(), link_directory.basename()));
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -139,7 +139,7 @@ void do_copy(Vector<String> const& selected_file_paths, FileOperation file_opera
|
|||
copy_text.append("#cut\n"sv); // This exploits the comment lines in the text/uri-list specification, which might be a bit hackish
|
||||
}
|
||||
for (auto& path : selected_file_paths) {
|
||||
auto url = URL::create_with_file_protocol(path);
|
||||
auto url = URL::create_with_file_scheme(path);
|
||||
copy_text.appendff("{}\n", url);
|
||||
}
|
||||
GUI::Clipboard::the().set_data(copy_text.build().bytes(), "text/uri-list");
|
||||
|
@ -169,7 +169,7 @@ void do_paste(String const& target_directory, GUI::Window* window)
|
|||
if (uri_as_string.is_empty())
|
||||
continue;
|
||||
URL url = uri_as_string;
|
||||
if (!url.is_valid() || url.protocol() != "file") {
|
||||
if (!url.is_valid() || url.scheme() != "file") {
|
||||
dbgln("Cannot paste URI {}", uri_as_string);
|
||||
continue;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView c
|
|||
auto default_file_handler = directory_view.get_default_launch_handler(current_file_launch_handlers);
|
||||
if (default_file_handler) {
|
||||
auto file_open_action = default_file_handler->create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
|
||||
directory_view.launch(URL::create_with_file_protocol(full_path), launcher_handler);
|
||||
directory_view.launch(URL::create_with_file_scheme(full_path), launcher_handler);
|
||||
});
|
||||
if (default_file_handler->details().launcher_type == Desktop::Launcher::LauncherType::Application)
|
||||
file_open_action->set_text(String::formatted("Run {}", file_open_action->text()));
|
||||
|
@ -331,7 +331,7 @@ bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView c
|
|||
if (&handler == default_file_handler.ptr())
|
||||
continue;
|
||||
file_open_with_menu.add_action(handler.create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
|
||||
directory_view.launch(URL::create_with_file_protocol(full_path), launcher_handler);
|
||||
directory_view.launch(URL::create_with_file_scheme(full_path), launcher_handler);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -444,13 +444,13 @@ ErrorOr<int> run_in_desktop_mode()
|
|||
auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||
auto paths = directory_view->selected_file_paths();
|
||||
if (paths.is_empty()) {
|
||||
Desktop::Launcher::open(URL::create_with_file_protocol(directory_view->path()));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(directory_view->path()));
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& path : paths) {
|
||||
if (Core::File::is_directory(path))
|
||||
Desktop::Launcher::open(URL::create_with_file_protocol(path));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(path));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -469,7 +469,7 @@ ErrorOr<int> run_in_desktop_mode()
|
|||
});
|
||||
|
||||
auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_protocol("/bin/DisplaySettings"));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/bin/DisplaySettings"));
|
||||
});
|
||||
|
||||
TRY(desktop_view_context_menu->try_add_action(directory_view->mkdir_action()));
|
||||
|
@ -801,7 +801,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
|
|||
|
||||
for (auto& path : paths) {
|
||||
if (Core::File::is_directory(path))
|
||||
Desktop::Launcher::open(URL::create_with_file_protocol(path));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(path));
|
||||
}
|
||||
},
|
||||
window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue