1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:17:34 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -63,7 +63,7 @@ ErrorOr<void> BackgroundSettingsWidget::create_frame()
String path;
if (!m_wallpaper_view->selection().is_empty()) {
auto index = m_wallpaper_view->selection().first();
auto path_or_error = String::from_deprecated_string(static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->full_path(index));
auto path_or_error = String::from_byte_string(static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->full_path(index));
if (path_or_error.is_error()) {
GUI::MessageBox::show_error(window(), "Unable to load wallpaper"sv);
return;
@ -78,7 +78,7 @@ ErrorOr<void> BackgroundSettingsWidget::create_frame()
m_context_menu = GUI::Menu::construct();
auto const file_manager_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv));
m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", file_manager_icon, [this](GUI::Action const&) {
LexicalPath path { m_monitor_widget->wallpaper().value().to_deprecated_string() };
LexicalPath path { m_monitor_widget->wallpaper().value().to_byte_string() };
Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname(), path.basename()));
});
m_context_menu->add_action(*m_show_in_file_manager_action);
@ -88,7 +88,7 @@ ErrorOr<void> BackgroundSettingsWidget::create_frame()
[this](auto&) {
auto wallpaper = m_monitor_widget->wallpaper();
if (wallpaper.has_value())
GUI::Clipboard::the().set_data(URL::create_with_file_scheme(wallpaper.value().to_deprecated_string()).to_deprecated_string().bytes(), "text/uri-list");
GUI::Clipboard::the().set_data(URL::create_with_file_scheme(wallpaper.value().to_byte_string()).to_byte_string().bytes(), "text/uri-list");
},
this);
m_context_menu->add_action(*m_copy_action);
@ -144,14 +144,14 @@ ErrorOr<void> BackgroundSettingsWidget::load_current_settings()
{
auto ws_config = TRY(Core::ConfigFile::open("/etc/WindowServer.ini"));
auto selected_wallpaper = TRY(String::from_deprecated_string(Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv)));
auto selected_wallpaper = TRY(String::from_byte_string(Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv)));
if (!selected_wallpaper.is_empty()) {
auto index = static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->index(selected_wallpaper.to_deprecated_string(), m_wallpaper_view->model_column());
auto index = static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->index(selected_wallpaper.to_byte_string(), m_wallpaper_view->model_column());
m_wallpaper_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set);
m_monitor_widget->set_wallpaper(selected_wallpaper);
}
auto mode = TRY(String::from_deprecated_string(ws_config->read_entry("Background", "Mode", "Center")));
auto mode = TRY(String::from_byte_string(ws_config->read_entry("Background", "Mode", "Center")));
if (!m_modes.contains_slow(mode)) {
warnln("Invalid background mode '{}' in WindowServer config, falling back to 'Center'", mode);
mode = "Center"_string;

View file

@ -79,9 +79,9 @@ static void update_label_with_font(GUI::Label& label, Gfx::Font const& font)
void FontSettingsWidget::apply_settings()
{
GUI::ConnectionToWindowServer::the().set_system_fonts(
m_default_font_label->font().qualified_name().to_deprecated_string(),
m_fixed_width_font_label->font().qualified_name().to_deprecated_string(),
m_window_title_font_label->font().qualified_name().to_deprecated_string());
m_default_font_label->font().qualified_name().to_byte_string(),
m_fixed_width_font_label->font().qualified_name().to_byte_string(),
m_window_title_font_label->font().qualified_name().to_byte_string());
}
}

View file

@ -142,7 +142,7 @@ static ErrorOr<String> display_name_from_edid(EDID::Parser const& edid)
auto build_manufacturer_product_name = [&]() -> ErrorOr<String> {
if (product_name.is_empty())
return TRY(String::from_deprecated_string(manufacturer_name));
return TRY(String::from_byte_string(manufacturer_name));
return String::formatted("{} {}", manufacturer_name, product_name);
};
@ -170,7 +170,7 @@ ErrorOr<void> MonitorSettingsWidget::load_current_settings()
TRY(m_screen_edids.try_append(edid.release_value()));
} else {
dbgln("Error getting EDID from device {}: {}", m_screen_layout.screens[i].device.value(), edid.error());
screen_display_name = TRY(String::from_deprecated_string(m_screen_layout.screens[i].device.value()));
screen_display_name = TRY(String::from_byte_string(m_screen_layout.screens[i].device.value()));
TRY(m_screen_edids.try_append({}));
}
} else {

View file

@ -20,8 +20,8 @@ ThemePreviewWidget::ThemePreviewWidget(Gfx::Palette const& palette)
ErrorOr<void> ThemePreviewWidget::set_theme(String path)
{
auto config_file = TRY(Core::File::open(path.to_deprecated_string(), Core::File::OpenMode::Read));
TRY(set_theme_from_file(path.to_deprecated_string(), move(config_file)));
auto config_file = TRY(Core::File::open(path.to_byte_string(), Core::File::OpenMode::Read));
TRY(set_theme_from_file(path.to_byte_string(), move(config_file)));
return {};
}

View file

@ -20,7 +20,7 @@ namespace DisplaySettings {
static ErrorOr<String> get_color_scheme_name_from_pathname(StringView color_scheme_path)
{
return TRY(String::from_deprecated_string(color_scheme_path.replace("/res/color-schemes/"sv, ""sv, ReplaceMode::FirstOnly).replace(".ini"sv, ""sv, ReplaceMode::FirstOnly)));
return TRY(String::from_byte_string(color_scheme_path.replace("/res/color-schemes/"sv, ""sv, ReplaceMode::FirstOnly).replace(".ini"sv, ""sv, ReplaceMode::FirstOnly)));
}
ErrorOr<NonnullRefPtr<ThemesSettingsWidget>> ThemesSettingsWidget::try_create(bool& background_settings_changed)
@ -40,7 +40,7 @@ ErrorOr<void> ThemesSettingsWidget::setup_interface()
auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme();
TRY(m_theme_names.try_ensure_capacity(m_themes.size()));
for (auto& theme_meta : m_themes) {
TRY(m_theme_names.try_append(TRY(String::from_deprecated_string(theme_meta.name))));
TRY(m_theme_names.try_append(TRY(String::from_byte_string(theme_meta.name))));
if (current_theme_name == theme_meta.name) {
m_selected_theme = &theme_meta;
current_theme_index = m_theme_names.size() - 1;
@ -53,7 +53,7 @@ ErrorOr<void> ThemesSettingsWidget::setup_interface()
m_themes_combo->set_model(*GUI::ItemListModel<String>::create(m_theme_names));
m_themes_combo->on_change = [this](auto&, const GUI::ModelIndex& index) {
m_selected_theme = &m_themes.at(index.row());
auto selected_theme_path = String::from_deprecated_string(m_selected_theme->path);
auto selected_theme_path = String::from_byte_string(m_selected_theme->path);
ErrorOr<void> set_theme_result;
if (!selected_theme_path.is_error())
set_theme_result = m_theme_preview->set_theme(selected_theme_path.release_value());
@ -98,7 +98,7 @@ ErrorOr<void> ThemesSettingsWidget::setup_interface()
}
}
color_scheme_combo.on_change = [this](auto&, const GUI::ModelIndex& index) {
auto result = String::from_deprecated_string(index.data().as_string());
auto result = String::from_byte_string(index.data().as_string());
if (result.is_error())
return;
m_selected_color_scheme_name = result.release_value();
@ -139,7 +139,7 @@ ErrorOr<void> ThemesSettingsWidget::setup_interface()
if (current_theme_name == theme_meta.name) {
m_themes_combo->set_selected_index(index, GUI::AllowCallback::No);
m_selected_theme = &m_themes.at(index);
auto selected_theme_path = String::from_deprecated_string(m_selected_theme->path);
auto selected_theme_path = String::from_byte_string(m_selected_theme->path);
ErrorOr<void> set_theme_result;
if (!selected_theme_path.is_error())
set_theme_result = m_theme_preview->set_theme(selected_theme_path.release_value());
@ -178,7 +178,7 @@ void ThemesSettingsWidget::apply_settings()
if (!set_theme_result)
GUI::MessageBox::show_error(window(), "Failed to apply theme settings"sv);
} else if (find_descendant_of_type_named<GUI::CheckBox>("custom_color_scheme_checkbox")->is_checked()) {
auto set_theme_result = GUI::ConnectionToWindowServer::the().set_system_theme(m_selected_theme->path, m_selected_theme->name, m_background_settings_changed, color_scheme_path.to_deprecated_string());
auto set_theme_result = GUI::ConnectionToWindowServer::the().set_system_theme(m_selected_theme->path, m_selected_theme->name, m_background_settings_changed, color_scheme_path.to_byte_string());
if (!set_theme_result)
GUI::MessageBox::show_error(window(), "Failed to apply theme settings"sv);
} else {